The domain-event fiber can observe session-set(error) after the
turn.start command is accepted but before dispatchWake stamps the claim
in-flight. Phase-guarding the release left that pending claim behind
with nothing else to clear it, blocking every future wake for the
thread. Release regardless of phase — releaseClaim only rewinds
in-flight claims, so a pending release is just a drop.
Regression test verified to fail against the phase-guarded release.
Co-Authored-By: Claude Fable 5 <[email protected]>
- Serialize wake claim transitions with a semaphore so the post-dispatch
cursor ack and a concurrent release can no longer interleave; the ack
and wake-count increment are now one critical section with the claim
check (Macroscope)
- Rewind the cursor on session-set(error): the provider reactor emits it
before provider.turn.start.failed, so dropping the claim there left the
failure handler nothing to restore and acked events were lost. A clean
session finish still just frees the claim (Bugbot, high)
- Only mark boot reconciliation complete when every orphan ended
successfully, so failures are retried on the next poll (Bugbot)
- Drop the registration when session teardown runs before the engine is
bound, instead of leaving a monitor that can wake a dead session
(Bugbot)
Co-Authored-By: Claude Fable 5 <[email protected]>
Findings from a multi-agent review panel (23 confirmed after two-lens
adversarial verification), grouped by root cause:
Lifecycle identity
- Thread a monitor generation through monitor commands, events, and the
projected monitor state; reject updates/ends whose generation is not
the active one, and make every registry removal generation-conditional
so a delayed lifecycle event cannot delete a newer monitor
- Re-validate registration, projected monitor status, archive state,
generation, and claim at the wake send boundary (after the fresh fetch,
not before it)
Event loss
- Diff before the readiness exit: actionable activity now wins over
ending as ready, so a bot comment landing in the same poll as green CI
is never discarded
- Persist non-actionable cursor transitions so resolved→reopened is
still detectable
- Acknowledge the cursor only if the wake claim still exists, so a
user-turn release is not overwritten
Readiness
- Collapse reviews to each reviewer's latest opinionated review, so an
approval supersedes that reviewer's earlier changes-requested
- Re-include pre-monitor review threads once they are edited or reopened
Snapshot integrity
- Final terminal/head revalidation after pagination, with one bounded
refetch on head change
- Fetch the last 10 comments per review thread and track per-thread
updatedAt so edits to non-final comments are visible
- Reopened threads wake regardless of self-authorship
- Include the changes-requested review body in the wake prompt
Lifecycle events
- Archive atomically emits thread.monitor-ended before thread.archived,
mirroring settle
- Treat a queued-but-unadopted user turn as busy at the send boundary
- Boot reconciliation isolates per-thread failures (Bugbot)
UI
- Gate ready-state PR actions on the checkout PR matching the monitored
PR number
- Wake snoozed threads on monitor ready/needs-attention/session-ended
- Legacy sidebar renders the ready payoff and a needs-attention state;
session failure outranks Monitoring
- Reset merge confirmation when PR or monitor status changes
- endThreadMonitor honors a caller-provided endedAt
Co-Authored-By: Claude Fable 5 <[email protected]>
- Ignore review-thread activity whose latest comment is the viewer's own
reply, breaking the self-triggered wake cycle
- Retry boot reconciliation on the first successful poll instead of
swallowing a failed shell snapshot at startup
- Remove the registration when archive teardown dispatch fails so
archived threads are never polled or woken again
- Stamp wake claims with the turn command's createdAt so provider
turn-start failures (which echo that timestamp) match the release
condition; a fresh post-dispatch timestamp could never match
Co-Authored-By: Claude Fable 5 <[email protected]>
- Stop prepareMcpSession ending the active monitor on session start
(session recycles no longer kill their own babysit)
- Fail closed at the wake send boundary: a failed fresh PR fetch discards
the wake instead of falling back to the stale poll state
- Correlate provider.turn.start.failed releases by dispatch time and
rewind wakeCount alongside the cursor
- Monotonic generation allocator; generation-conditional
updateCursor/incrementWake/remove so stale polls can't mutate a
newer monitor
- Dispatch thread.monitor.end before removing the registration in
session teardown; end monitors on thread.archived
- Preserve wakeCount on idempotent monitor.start replay (breaker can't
be reset)
- Key check-run cursors by head SHA + name + run id; detect
resolved→unresolved thread reopens
- Human changes-requested reviews now block readiness
- Thread monitoringStartedAt from the registration so pre-existing
unresolved threads don't block readiness forever
- Use the PR's base ref in the wake prompt instead of hard-coded main
- Boot reconcile: threads projecting "monitoring" with no registration
are ended as session-ended
Co-Authored-By: Claude Fable 5 <[email protected]>
Threads can now formally monitor a PR after creating it. The agent calls a
new monitor_start MCP tool; a dedicated PullRequestMonitor service polls
GitHub every 30s, diffs review comments / reviews / check runs against a
per-thread cursor, and wakes the thread with a self-contained prompt when
there is something to address. The server — never the agent — declares the
PR ready from head-SHA-anchored GitHub state.
- GitHub monitor snapshot fetch (reviews, threads, check runs, mergeability)
with pure cursor-diff and readiness modules
- thread.monitor.start/update/end domain events through decider/projector,
monitor state on the thread shell, migration 034 (monitor_json)
- Wake dispatch protocol: claim → fresh terminal revalidation at the send
boundary → dispatch → cursor ack only after accepted start; user turns
always win and rewind in-flight wake cursors so events re-diff; 10-wake
circuit breaker ends as needs-attention
- Monitoring holds the thread unsettled; user settle ends the monitor;
session teardown ends it as session-ended
- UI: steady cyan Monitoring pill (never masks approval/input/failed),
blockers sub-line, header MonitorStrip with Stop, emerald Ready-to-merge
state with confirm dialog; clients can only end a monitor as "stopped"
Co-Authored-By: Claude Fable 5 <[email protected]>