Repository navigation
fix(meetings): the channel's follow-ups: lease, delivery, store and transport edge cases - #386
Conversation
manager-lifecycle.test.ts took its harness from manager-send-dispatch.test.ts, and a test file that is imported registers its tests again in the file that imports it, so every send and dispatch case also ran inside the lifecycle file. The harness, its room service and its entitlement hook move unchanged to a module of their own, which both files import; the harness also takes the owner's destinations, for the cases that read the outbox. Files: src/io/channels/meetings/__tests__/manager-harness.ts (new), src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts.
…urge fails, and a report sent again is delivered again A report that is an event of its own (a chat message, a stop command, a participant report) is stored before it is applied, and its row is its record: when the application threw, the worker's retry found the row and changed nothing. A stop phrase whose delivery failed never reached the purge, and a stop whose purge failed was lost on the retry, so the bot went on listening after a participant asked it to stop. The purge of a stop now runs even when the message's delivery throws, whose error is raised after it; a repeated stop report that finds the run not yet behind the fence carries the stop out; and a repeated report's event goes to the destinations again, which the outbox keeps once each, so a delivery the first attempt never enqueued goes out. A handler still receives an event once. The page says what a retry does. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…as the event store holds it The manager checks a run before it emits a transcript or a participant's message, and the event store strips the payload of a content event that arrives behind the run's fence. A purge whose fence went up between the check and the store's write left the stored row without the words, while the handlers still received them from the manager's own copy, after the participant had asked for the purge. A content event is now read back once it is stored, and its delivery and its handlers carry the stored payload: none, when a fence went up on its way. Other events keep the copy they were stored from. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
… done, so events that fail to go out are sent on the next pass The purge wrote the run's terminal row and then emitted bot:purged and bot:done. An emit that threw (the owner's destinations unreachable, the outbox down) left a done run whose end no destination ever heard of, since nothing returns to a done run. The purge's last step is now its write: the events go first, and events that fail to go out leave the run purging, so the next pass runs the steps again and sends them, stored once and delivered again. No other path writes a purging run's end, so the events cannot announce an end that does not come. A kept run's later purge sends bot:purged before it rewrites the row, so the caller's retry sends one that failed. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…al past the manager's clock The stop monitor's heartbeat, the notice's confirmation, the bot's arrival in the call and the alone timer are stored at the time the worker reports, and the limits compare them with the manager's clock. A worker whose clock ran ahead kept a stop monitor that had gone quiet counted healthy, and capture open, for as long as its clock ran ahead, and held the notice and alone limits open the same way. Those times now count as no later than one heartbeat interval past the manager's clock. Within that interval the worker's own times keep their order, which the capture interlock reads (a heartbeat at or after the notice). Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, docs/features/MEETING_BOTS.md.
…n the waiting room The limit read joinedAt, which only admission writes, so in the waiting room it counted from the dispatch: the container's start and the join came out of the bot's ten minutes, and the manager, the limit's backstop, told the bot to leave before the container's own limit would. A waiting_room report now writes joinedAt, the bot's arrival in the waiting room, and admission moves it on to the time the bot entered the call, which the notice's confirmation counts from. A run that never reports a waiting room counts from the dispatch as before. joinedAt gains its TSDoc. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/types.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…e leaves with stop_monitor_failed The limits counted a stop monitor as quiet only from its last heartbeat, so a run in the call whose monitor never reported at all was never quiet: capture stayed closed, as the interlock requires, but the bot stayed in the meeting under its notice until the alone or the total limit, up to four hours. Such a run now leaves with stop_monitor_failed once the monitor's window and the recovery wait have both passed since the notice (60 seconds with the defaults), the same wait a monitor that went quiet and stayed quiet gets. It captured nothing, so it is not billed. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…se capture has not started The capture interlock rested on the provider alone: the transcript sink and recordTranscript checked the fence and the run's end, so a turn transcribed from audio a provider passed on before startCapture was stored and forwarded as bot:transcript. The sink and recordTranscript now also drop a turn for a run whose capture has not started (no captureStartedAt). A run whose capture was suspended has started, so the last finals of the audio before the suspension are kept. Files: src/io/channels/meetings/MeetingTranscriptSink.ts, src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…se is recorded as dispatched, not left unwatched A dispatcher that stopped after the provider started the bot and before it recorded the dispatch left the job undispatched. Once the bot's first report moved the run on, the next dispatcher to lease the job found a run past dispatching and removed the job, so reconcile, which compares the dispatched jobs with the providers' usage, no longer watched the run: a container that died afterwards was never noticed. The dispatch pass now records such a job as dispatched under its own lease. recoverDispatch's usage flag drops an initial value no path reads, which the linter reported as a useless assignment. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, docs/features/MEETING_BOTS.md.
… new state, and a run already leaving keeps its reason and kill deadline leave() wrote the move to leaving against the state of the run it was handed. A report that moved the run in between (the bot reaching the waiting room as the owner pressed leave) made the write miss, and leaveBot answered false with the bot still in the meeting. And a second leave of a run already leaving rewrote its reason and restarted its kill: an owner's leave during a leave for a failed stop monitor turned an unbilled end into a billed one, and each repeat put the kill off. A leave now tries again, a few times, from the state the run is in now. A run already leaving answers true and keeps the reason it was told and its deadline; a purging run's deadline is kept too. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…fter the bot left keeps its end Behind the fence, left, done and crashed reports wrote the seconds they carried over the run's total, and those reports are applied again when the worker sends them again: a left report retried after done replaced the final total with its smaller one, and the purge settled that. A crashed report on a run that had already left rewrote its leaving time, emitted a second bot:left and settled the crash's count in place of the left report's. The stored total now takes the largest of what the reports gave, wherever a report or the completion writes it, and behind the fence the first leaving time stands. A crashed report on a run that has left only retries the cleanup still owed. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…er the report's event is stored A participant report decided whether to keep or start the alone timer on the run read before it stored its event. A report that no one was left, overtaken while its event was stored by one that someone had joined, wrote back the timer the other had cleared: a timer that had run out, so the next pass ended the run as alone with a participant in the call. The count and the timer are now written from the row read again once the report's event is stored. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts.
…sequence, and purgeRun purges a failed run A provider's left report with permission_denied (the platform refused the bot the meeting's permission) completed the run under its Keep: a run kept in the owner's account kept what it took, and the host had to notice the reason and call purgeRun itself. Such a run now runs the purge sequence whatever its Keep, the host's purge hooks included, unbilled as before. purgeRun answered false for a run that failed before it joined, so a host deleting a session never ran its purge hooks for that run. It now purges such a run as it purges a done one: its hooks run, bot:purged goes out and the row records purgedAt. False is left for a run that does not exist. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
pageSeen wrote the page's time onto the run whatever its state, so a page that kept reporting after the run ended wrote a page time back onto the terminal, content-free row the end had cleared it from. It now writes only to a run that is not over. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
The timer start() sets ran tick() every second whether or not the last pass had finished, so a store slower than the interval stacked passes on each other: each step is idempotent, so the overlap was safe, but every pass went on adding the same reads and writes to a store that was already behind. A pass due while one is still running is now skipped. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, docs/features/MEETING_BOTS.md.
…st can go, not on every pass With stores that forget (the in-memory ones), every pass listed every done and failed run to find the few past their grace, a scan that grew with each run a single-process host had finished. The pass now lists them when the earliest can be forgotten, and at least once a minute: a run that ends later can go no sooner than a grace after it ends, at least a day, and a run a pending delivery held back is looked at again within the minute. Durable stores, which omit forget, are untouched. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…e makes The case that a purge whose last write fails leaves no done row holding the run's content made runs.replace fail, but an active purge finishes with runs.update, so the failure was never hit and the case passed on a purge that succeeded. It now makes the update from purging to done fail once, checks that it did, that the run is still purging with its content in place, and that the retried purge then writes the content-free row. Files: src/io/channels/meetings/__tests__/manager-lifecycle.test.ts.
… it connects, deletes a room it cannot mint for, and passes on any rejection of a delete MeetingRoom.create minted the agent's subscribe-only token at dispatch, and the manager, which keeps no token, never handed it on, so a host had to rebuild the agent's grant through its room service itself; a token minted at dispatch can also expire before the agent joins, since a run can wait in the waiting room longer than a token lives. MeetingRoom.agentToken(roomName) now mints it when the agent is about to connect, for the agent's identity, subscribe-only, with the helper's token lifetime. A room whose token could not be minted after it was made stayed open until its empty timeout; create now deletes it again and passes the mint's failure on. And delete read the status of any rejection as a property, so a rejection with no object (undefined, null) turned into a TypeError in place of the service's own failure; it is now passed on as it is. Files: src/io/channels/meetings/MeetingRoom.ts, src/io/channels/meetings/__tests__/meeting-room.test.ts, docs/features/MEETING_BOTS.md.
…r util.inspect SecretBox redacted its JSON form, but util.inspect, which console.log and many loggers use, printed its fields, the current and previous 32-byte keys among them, byte by byte; a SqlRunStore, which holds the box and the database adapter, printed both. Each now answers util.inspect with the marker its toJSON returns. Files: src/io/channels/meetings/signing.ts, src/io/channels/meetings/stores/sql.ts, src/io/channels/meetings/__tests__/signing.test.ts, src/io/channels/meetings/__tests__/sql-stores.ddl.test.ts, docs/features/MEETING_BOTS.md.
…unds, rounded to whole milliseconds A turn's start and end are INTEGER columns, and the values went to Postgres as they came. After a reconnect the transcriber's clock is moved by the replayed audio's duration, which frames of fractional milliseconds make fractional, and Postgres refuses a fraction for an integer: the append failed and the listen session ended with sink_failed. The bounds are now bound as whole milliseconds, rounded, in append and appendNext; the columns are unchanged. Files: src/io/channels/meetings/stores/sql.ts, src/io/channels/meetings/__tests__/sql-stores.postgres.test.ts, docs/features/MEETING_BOTS.md.
…nding leaves it as it is SqlOutbox.markFailed wrote the state back to pending whatever the delivery's state, so a sender whose attempt raced another and reported its failure after the destination had taken the delivery made it pending again, and it was sent a second time. The in-memory outbox kept the state but still counted the attempt, and turned a delivered row dead once a day had passed since its first failure. Both now leave a delivery that is delivered or dead as it is; the shared contract case runs against both. Files: src/io/channels/meetings/stores/sql.ts, src/io/channels/meetings/stores/memory.ts, src/io/channels/meetings/stores/types.ts, src/io/channels/meetings/__tests__/store-contract.ts, docs/features/MEETING_BOTS.md.
…eanwhile answers that event's sequence
Event ids are unique across runs, but each append locks only its own run's anchor. Two runs' appends of one id both found no event with it, and the unique index refused the second with a 23505 error where the contract answers { inserted: false, seq }. The insert now does nothing on that conflict and the append answers the sequence of the event that holds the id, as it does for an id already stored; the run's counter advances only when its row is written.
Files: src/io/channels/meetings/stores/sql.ts, src/io/channels/meetings/__tests__/sql-stores.postgres.test.ts, docs/features/MEETING_BOTS.md.
… runs, and the turn is taken, when one of them throws The orchestrator re-emits the endpoint detector's turn_complete as its own with emit(), inside the detector's async handler. A listener that threw stopped emit() there: the listeners after it, waitForUserTurn()'s among them, never heard the turn, the turn was not taken, and the throw rejected the handler with nothing to catch it, an unhandled rejection. Each listener now runs in turn; one that throws or rejects is reported as 'error' when something listens for it, and otherwise as a console warning, and the turn goes on. The re-emit case now checks that the orchestrator hands on the detector's own event object. Files: src/io/voice-pipeline/VoicePipelineOrchestrator.ts, src/io/voice-pipeline/__tests__/VoicePipelineOrchestrator.test.ts.
…a pause held; the LiveKit transport stops a replay at a renewed pause and replays nothing once closed
A listen session that a slow sink had paused, then stopped with close('stopped'), flushed the transcriber first and released the pause only once it had stopped taking audio, so the up to two seconds the transport held were replayed to no one. The stop now releases the pause first, while the session still takes audio, and the held frames reach the transcriber before its flush; a purge still discards them.
LiveKitStreamTransport replayed its held frames from a detached copy, so a consumer that paused again on the first replayed frame still received the rest; the replay now goes one frame at a time and stops at a renewed pause, the frames not yet emitted staying held with their length. And close() kept what a pause held, with no lifecycle check on resume, so a session's cleanup resume after the transport closed emitted buffered audio and a gap; close() now drops the buffer, and a closed transport replays nothing.
Files: src/io/voice-pipeline/ListenSession.ts, src/io/voice-pipeline/LiveKitStreamTransport.ts, src/io/voice-pipeline/__tests__/ListenSession.test.ts, src/io/voice-pipeline/__tests__/LiveKitStreamTransport.test.ts, docs/features/VOICE_PIPELINE.md, docs/features/MEETING_BOTS.md.
…ager per host, the descriptor's TSDoc, the barrel's header and the page's sidebar place The architecture page said the meeting-participant channel owns capture consent; it enforces the capture interlock and records no consent. The Meeting Bots page said usage reports drive entitlement.meter, where the manager meters a report only when the run holds a reservation and its capture has started; it now says so, and that the provider's reports set the cadence. Its run example built a new manager, with new in-memory stores and its own timer, on every send, so a host that copied it would leave each run apart from the manager its events route uses; the example now builds the manager once and sends through it. MeetingProviderDescriptor's TSDoc called the descriptor a payload; the root index's meetings export gets its section comment, the meetings barrel its module header; and Meeting Bots no longer shares the third place in the Voice & Speech section with Telephony Providers. Files: docs/architecture/ARCHITECTURE.md, docs/features/MEETING_BOTS.md, docs/publication-manifest.cjs, src/extensions/types.ts, src/index.ts, src/io/channels/meetings/index.ts.
…e completion's TSDoc reflowed The in_call report capped its time twice, once for joinedAt and once for the alone timer, reading the manager's clock each time; it now caps it once for both. complete()'s TSDoc is reflowed to the file's width. Files: src/io/channels/meetings/MeetingManager.ts.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Sorry @jddunn, your pull request is larger than the review limit of 150,000 diff characters |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66074f4044
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (input.runId !== this.options.runId) throw new Error('a sink writes one run'); | ||
| const run = await this.options.manager.getRun(input.runId); | ||
| if (!run || run.state === 'purging' || run.state === 'done' || run.state === 'failed') return undefined; | ||
| if (!run || run.state === 'purging' || run.state === 'done' || run.state === 'failed' || run.captureStartedAt === undefined) return undefined; |
There was a problem hiding this comment.
Reject transcripts while capture is suspended
When the stop monitor becomes stale, enforceLimits() sets captureSuspendedAt and asks the provider to suspend capture, but this predicate accepts every run whose capture started at least once. Buffered audio or audio from a delayed/noncompliant provider can therefore still be persisted and emitted as bot:transcript while the stop mechanism is unavailable. Require capture to be currently active (including captureSuspendedAt === undefined) here, in append(), and in recordTranscript().
Useful? React with 👍 / 👎.
| const turn: TranscriptTurn = { ...input, seq, turnId: `${input.runId}:${seq}` }; | ||
| await trx.run(`INSERT INTO ${this.t.turns} (run_id, seq, turn_id, at, text, speaker, start_ms, end_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [turn.runId, seq, turn.turnId, turn.at, turn.text, turn.speaker ?? null, turn.startMs ?? null, turn.endMs ?? null]); | ||
| await trx.run(`INSERT INTO ${this.t.turns} (run_id, seq, turn_id, at, text, speaker, start_ms, end_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [turn.runId, seq, turn.turnId, turn.at, turn.text, turn.speaker ?? null, wholeMs(turn.startMs), wholeMs(turn.endMs)]); | ||
| return turn; |
There was a problem hiding this comment.
Return the normalized transcript bounds
For fractional transcript bounds, the insert persists wholeMs(turn.startMs/endMs) but appendNext() returns the original unrounded turn. MeetingTranscriptSink then uses that returned object for bot:transcript and its own return value, so callers can observe (for example) 12.5 immediately while a later read() returns 13 for the same turn. Construct or return the turn using the normalized values so the stored record and observable event agree.
Useful? React with 👍 / 👎.
## [0.13.86](v0.13.85...v0.13.86) (2026-10-13) ### fix * **guardrails:** a blocked tool call is refused before it runs, and a blocked external call leaves the saved pause (#384) ([dcfe023](dcfe023)) * **meetings:** the channel's follow-ups: lease, delivery, store and transport edge cases (#386) ([d925ceb](d925ceb)) ### docs * correct the GMI paper's T1 grading, preset moods and gate re-run cap (#385) ([4f649e6](4f649e6)) * fourteenth round of audit follow-ups (the P2 leftovers of the cold reads) (#377) ([0a7da7d](0a7da7d))
Summary
Edge cases in the meeting-participant channel and the two voice-pipeline pieces it listens through: dispatch leases, report retries and event delivery, the limits, the room helper, the Postgres stores and the LiveKit transport. Every public signature is kept; what is added is additive (
MeetingRoom.agentToken, an'error'event onVoicePipelineOrchestrator). No schema change.The manager (
src/io/channels/meetings/MeetingManager.ts), one commit each:bot:purgedandbot:donego out before the purge's terminal write, so events that fail to go out leave the run purging and the next pass sends them; a kept run's later purge sendsbot:purgedbefore rewriting the row.joinedAtis written there and moved to the call at admission), not from the dispatch.stop_monitor_failedonce the window and the recovery wait pass (60 s with the defaults), unbilled.recordTranscriptdrop a turn for a run whose capture has not started.permission_deniedends now run the purge sequence whatever the Keep, andpurgeRunpurges a run that failed before it joined (its hooks run; it answers true).pageSeenleaves a run that is over as it was written;start()runs one pass at a time; terminal runs are listed for eviction when the first can go, at least once a minute, not on every pass.The room helper (
MeetingRoom.ts):agentToken(roomName)mints the listening agent's subscribe-only token when it connects, since a token minted at dispatch can expire in a long waiting room; a room whose token cannot be minted is deleted again; a delete passes on a rejection that is not an object as it is.Secrets:
SecretBoxandSqlRunStoreprint a redacted marker underutil.inspect(and soconsole.log), as theirtoJSONdoes.The stores:
SqlTranscriptStorerounds fractional turn bounds to the INTEGER columns' whole milliseconds;markFailedleaves a delivered or dead delivery as it is (Postgres and memory);SqlEventStore.appendanswers the holding event's sequence when another run's append of the same id commits while it waits on the unique index, instead of failing with 23505.The voice pipeline:
VoicePipelineOrchestratorruns everyturn_completelistener and still takes the turn when one throws or rejects (reported as'error', or a console warning with no listener);ListenSession'sclose('stopped')releases its transport pause before the flush, so the audio the transport held reaches the transcriber;LiveKitStreamTransportstops a replay at a renewed pause and replays nothing once closed.Tests and docs: the manager's test files share one harness module (the lifecycle file had been registering the send-and-dispatch tests a second time); the purge-write failure case now fails the write the purge makes. The Meeting Bots page, the voice pipeline page and the architecture page say what the code now does (the capture interlock, when usage is metered, one manager per host in the run example), with the descriptor's TSDoc, the barrel's module header and the page's sidebar place.
Linked issues
None.
Type of change
How this was verified
CI on this pull request: Test & Lint (build, lint, type check and the suite with coverage, the Postgres cases on the service container), Batch-1 gated tests, Browser tests and the release dry run. Each fix commit carries the regression case that fails without it: in
manager-lifecycle.test.tsandmanager-send-dispatch.test.tsfor the manager,meeting-room.test.ts,signing.test.ts,sql-stores.ddl.test.ts, the sharedstore-contract.ts(memory and Postgres) andsql-stores.postgres.test.tsfor the stores, andVoicePipelineOrchestrator.test.ts,LiveKitStreamTransport.test.tsandListenSession.test.ts(the session over the real LiveKit transport and the hearing fakes) for the voice pipeline.Migration notes
None: no signature or schema change. Behaviour a host may notice: a
permission_deniedend purges a kept run;purgeRunon a failed run answers true and runs the purge hooks; a run whose stop monitor never reports leaves after 60 s; turns before capture are dropped;bot:purgedandbot:donemay reach the destinations before the purged run's row readsdone.Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).