Repository navigation
fix(meetings): the interlock's order on the worker's clock, the loop's passes apart, handlers before destinations, the late notice first - #388
Conversation
…notice on the worker's clock The notice's confirmation and the monitor's heartbeats were stored at times bounded to one heartbeat interval past the manager's clock, each on its own, and capture opened on a heartbeat whose bounded time was at or after the notice's. With a worker clock more than an interval ahead both bounds take the manager's clock plus the interval, so a heartbeat the worker made before the notice, applied in the same millisecond or delivered after it, counted as one after it and opened capture without a stop monitor shown to be watching the chat after the notice. The notice's time is now kept as the worker reported it. A heartbeat counts only once the notice is confirmed and only when the worker made it at or after the notice, both on the worker's clock; a counted one is kept at its bounded time, which the freshness checks use, and the notice's confirmation clears any heartbeat time from before it. The wait for a first heartbeat after the notice counts from the notice, but from no later than the notice's confirmation window after the bot entered the call, so a worker clock that runs ahead does not hold a run without a monitor in the call. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/types.ts, src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, docs/features/MEETING_BOTS.md.
… a pass that does not finish stops no later one start() ran tick() one pass at a time, and a tick dispatches the due jobs before it enforces any limit. A provider slow to answer a dispatch (a worker pulling the bot's image, a scheduler that does not reply) held that pass open, and every later pass was skipped while it waited: no stop monitor that went quiet was suspended, no armed kill fired, and no notice, waiting-room or alone limit ended a run. A call inside the limits that never answered, a command to a worker that froze, stopped every later pass the same way. start() now runs the dispatches and the upkeep (the limits, kills, purges, eviction and the reconcile) as two passes apart, each one at a time, and a pass still running five intervals after it began is no longer waited for: the next starts beside it, with a warning. tick() runs the two in turn, as before. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-send-dispatch.test.ts, docs/features/MEETING_BOTS.md.
…tions deliver() enqueued an event for each of the owner's destinations first and called the handlers after, and an event sent again goes to the destinations only, so that a handler receives it once. When the first attempt failed in the destinations step (the destination lookup or the enqueue throwing), the handlers were never called, and the retry, finding the event stored, skipped them too: the handlers never received it. The purge's last step hit this whenever the destinations were unreachable for one pass, and no in-process handler ever heard bot:purged for that run; a participant's message or a report's event went the same way. The handlers now receive a stored event first and the destinations' deliveries are enqueued after, so a failing destination keeps the event from no handler; an event sent again still goes to the destinations only. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
… before the count is written and the event delivered A participant_joined report wrote the new count, delivered the event and only then posted the short notice to the participant who arrived. A write or a delivery that failed (the run store, the destination lookup or the enqueue) raised before the notice, and the worker's retry of the report, whose event is stored by then, applies nothing again: the participant who joined after the notice was never told the bot was taking notes, while capture went on. The short notice now goes first, before the count's write and the event's delivery, so neither failing keeps it back; the retry still posts nothing a second time. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
…bot is kept The transcript sink and recordTranscript dropped a turn while the run's captureStartedAt was unset, and the manager writes it only once the bot has answered startCapture. A bot starts publishing as the command reaches it, so a final from its first audio could arrive before that answer, or before a slow run-store write, and was dropped without a word. A run now takes turns once its capture has started or while the capture interlock holds (in the call, the notice confirmed, a fresh heartbeat after it, no suspension), which is when the command is sent; MeetingManager.takesTurns is that check, and the sink and recordTranscript both read it. A turn from audio a provider passed on before the interlock held is still dropped. Files: src/io/channels/meetings/MeetingManager.ts, src/io/channels/meetings/MeetingTranscriptSink.ts, src/io/channels/meetings/__tests__/manager-lifecycle.test.ts, docs/features/MEETING_BOTS.md.
|
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 |
Reviewer's GuideThis PR fixes meeting lifecycle races by enforcing worker-clock ordering for the capture interlock, decoupling dispatch from upkeep with stuck-pass recovery, delivering handlers before destinations, posting late-arrival notices first, and accepting transcript finals during an in-flight capture start; documentation and targeted regression tests cover each behavior. Sequence diagram for the meeting capture interlocksequenceDiagram
participant Worker
participant Manager
participant Provider
Worker->>Manager: processProviderEvent(providerName, ctx)
Manager->>Manager: notice_posted
Manager->>Manager: clear monitorSeenAt
Manager-->>Worker: notice confirmed
Worker->>Manager: monitor_heartbeat
alt heartbeat at or after noticePostedAt
Manager->>Manager: reportedAt(event.at)
Manager->>Provider: startCapture
Provider-->>Manager: capture started
else heartbeat before noticePostedAt
Manager-->>Worker: heartbeat not counted
end
Sequence diagram for handler-first event deliverysequenceDiagram
participant Report as Provider report
participant Manager
participant Handler
participant Destinations
participant Outbox
Report->>Manager: processProviderEvent(providerName, ctx)
Manager->>Handler: MeetingManagerEvent
Handler-->>Manager: handled
Manager->>Destinations: destinationsFor(ownerRef)
Destinations-->>Manager: destination refs
Manager->>Outbox: enqueue(event delivery)
alt destination lookup or enqueue fails
Manager-->>Report: error after handler delivery
end
Sequence diagram for late-arrival notice orderingsequenceDiagram
participant Worker
participant Manager
participant Provider
participant RunStore
participant Handler
Worker->>Manager: participant_joined
Manager->>Provider: postChat(lateArrivalText)
Provider-->>Manager: notice posted
Manager->>RunStore: updateParticipants
RunStore-->>Manager: updated run
Manager->>Handler: bot event
Handler-->>Manager: handled
Manager-->>Worker: report applied
Sequence diagram for transcript finals during capture startupsequenceDiagram
participant Worker
participant Manager
participant Sink
participant TranscriptStore
participant Provider
Manager->>Provider: startCapture
Worker->>Sink: appendNext(transcript input)
Sink->>Manager: takesTurns(run)
alt capture interlock holds while startCapture is in flight
Sink->>TranscriptStore: appendNext(input)
Sink->>Manager: recordTranscript(turn)
Manager-->>Sink: transcript accepted
else capture cannot start
Manager-->>Sink: transcript dropped
end
Provider-->>Manager: startCapture response
Manager->>Manager: set captureStartedAt
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82bac722f5
ℹ️ 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".
| const began = this.passStartedAt.get(pass); | ||
| if (began !== undefined && this.loopIntervals - began < STUCK_PASS_INTERVALS) return; | ||
| if (began !== undefined) this.config.logger?.warn(`[MeetingManager] the ${pass} pass begun ${this.loopIntervals - began} intervals ago has not finished; the next one starts beside it`); | ||
| const mark = this.loopIntervals; | ||
| this.passStartedAt.set(pass, mark); | ||
| void work() |
There was a problem hiding this comment.
Bound stuck operations instead of spawning repeated passes
If a dependency consistently never settles—for example, every provider.command(..., { name: 'kill' }) call to a frozen worker—this starts another upkeep pass every five intervals, and each pass reaches and hangs on the same run before processing later runs. The advertised bypass therefore both leaves other bots' limits unenforced and accumulates an unbounded number of pending passes; apply a timeout/cancellation boundary to the stuck operation, or otherwise ensure replacement passes can skip the blocked run rather than merely invoking the same pass again.
Useful? React with 👍 / 👎.
## [0.13.88](v0.13.87...v0.13.88) (2026-10-13) ### fix * **guardrails:** close a blocked stream even when its refusal cannot be saved (#387) ([864941b](864941b)) * **meetings:** the follow-ups' forward fixes: the interlock's order on the worker's clock, the loop's two passes, handlers before destinations, the late notice first, finals during startCapture (#388) ([16dce24](16dce24))
Summary
Follow-up fixes to the meeting-participant channel (
src/io/channels/meetings/), one commit each, each with the regression case that fails on the code before it:start()rantick()one pass at a time, and a tick dispatches before it enforces limits, so a dispatch the provider was slow to answer (a worker pulling its image) skipped every later pass: no suspension of a quiet stop monitor, no kill, no notice, waiting-room or alone limit. A call inside the limits that never answered stopped every later pass the same way.start()now runs the dispatches and the upkeep (limits, kills, purges, eviction, the reconcile) as two passes apart, each one at a time, and a pass still running five intervals after it began is no longer waited for.tick()keeps its order.bot:purgedfor every in-process handler whenever the destinations were unreachable for one pass. The handlers now receive a stored event first.participant_joinedreport wrote the count and delivered the event before it posted the short notice; a failing write or delivery raised before the notice, and the worker's retry applies nothing again, so a participant who joined after the notice was never told. The notice now goes first.startCapture. The sink andrecordTranscriptdropped turns untilcaptureStartedAtwas written, which happens once the bot answersstartCapture; a bot publishes as the command reaches it, so its first finals could be dropped. A run now takes turns once its capture has started or while the interlock holds (MeetingManager.takesTurns, read by both).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), Batch-1 gated tests, Browser tests and the release dry run. The regression cases: in
manager-send-dispatch.test.ts, a heartbeat made before the notice by a worker an hour ahead opens no capture (same millisecond, and delivered after the notice); a run whose monitor never reports leaves within the bound under that skew; the loop's three cases (each pass one at a time with the upkeep going on beside a held dispatch; a held provider dispatch with a quiet stop monitor suspended meanwhile; a command that never answers holding the next upkeep pass back five intervals at most). Inmanager-lifecycle.test.ts, the handlers receive a report's event whose destinations failed, once, andbot:purgedwhen the purge's last step failed at the destinations; a late arrival is given the short notice when the count's write or the delivery fails, once across the worker's retry; a final heard whilestartCaptureis held is kept.Migration notes
None: no schema change, and
takesTurnsis added. Behaviour a host may notice:noticePostedAtholds the worker's time again (as before the bound was introduced); the manager's event handlers are called before the outbox enqueue; a heartbeat applied before the notice is confirmed is not counted.Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).Summary by Sourcery
Harden meeting lifecycle processing against timing skew, slow operations, and partial delivery failures while preserving early capture transcripts and participant notices.
Bug Fixes:
Enhancements:
Documentation:
Tests: