Skip to content

fix(supervision): distinguish ordinary wakes from recovery - #744

Merged
kunchenguid merged 3 commits into
mainfrom
fm/fm-pi-ordinary-resume-dedupe-p4
Jul 20, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
fm/fm-pi-ordinary-resume-dedupe-p4

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Fix the Firstmate supervision-instruction conflict that caused a Pi primary to call fm_watch_arm_pi after ordinary wakes. Keep AGENTS.md harness-agnostic and leave the emitted session-start block as the sole owner of harness-specific verbs. Explicitly distinguish first-cycle arming, ordinary-wake continuation, and failure-only recovery for every supported harness: Pi and OpenCode must leave ordinary continuity to their extension or plugin, Claude and Grok must re-arm their tracked background task, and Codex must take its next foreground checkpoint. Keep Pi recovery able to call fm_watch_arm_pi when the cycle is missing or failed, preserve OpenCode recovery semantics, update turn-end guard output to recovery-only language, add colocated renderer regression coverage for Pi and at least one model-owned harness, and do not change watcher algorithms, adapters, or extension continuity implementation. Deliver a green PR but do not merge it because landing timing must be coordinated with the main Firstmate.

What Changed

  • Separate first-cycle arming, ordinary-wake continuation, and failure recovery in emitted supervision instructions for every supported harness.
  • Keep Pi and OpenCode ordinary continuity extension/plugin-owned, while Claude and Grok re-arm tracked background tasks and Codex starts its next foreground checkpoint.
  • Make watcher and turn-end guard follow-ups recovery-only, and update protocol documentation and regression coverage for the distinct paths.

Risk Assessment

✅ Low: The repaired passive guard follow-ups now state recovery-only conditions and delegate harness-specific actions to the shared renderer, while ordinary continuity paths remain unchanged.

Testing

The supplied full-suite baseline was green; focused renderer, guard, and watcher-lock regressions also passed. Manual CLI evidence confirms Pi and OpenCode leave ordinary continuity to their extension/plugin while retaining recovery paths, Claude and Grok re-arm tracked tasks, Codex continues with a foreground checkpoint, and the turn-end guard presents recovery-only wording when it prevents a blind turn end.

Evidence: Rendered session-start and recovery behavior across all supported harnesses, plus an actual unhealthy Claude turn-end guard invocation.
Firstmate supervision instruction rendering - end-to-end validation transcript
Each session-start block is rendered by bin/fm-supervision-instructions.sh.

[claude session start]
SUPERVISION OPERATING INSTRUCTIONS - primary harness: claude
- Ordinary wake: re-arm exactly one bin/fm-watch-arm.sh Claude Code background task as directed below.
3. First cycle: run `bin/fm-watch-arm.sh` as its own Claude Code background task.
7. Failure or missing cycle only: treat any `watcher: FAILED ...` result as an alarm and repair it before ending the turn.
8. Ordinary wake: when the background task completes with `signal:`, `stale:`, `check:`, or `heartbeat`, drain queued wakes, then start exactly one fresh background task before running other fleet commands to handle the wake.
[claude recovery-only guard instruction]
repair missing watcher supervision with bin/fm-watch-arm.sh as its own Claude Code background task, never shell &.

[codex session start]
SUPERVISION OPERATING INSTRUCTIONS - primary harness: codex
- Ordinary wake: take the next foreground bin/fm-watch-checkpoint.sh checkpoint as directed below.
3. First cycle: run one foreground watcher checkpoint with `bin/fm-watch-checkpoint.sh --seconds "${FM_CODEX_WATCH_CHECKPOINT:-180}"`.
4. Ordinary wake: if the command prints `signal:`, `stale:`, `check:`, or `heartbeat`, drain queued wakes, handle that wake, then start the next checkpoint.
8. Failure or missing cycle only: drain queued wakes, inspect the failure, then start a fresh foreground checkpoint.
[codex recovery-only guard instruction]
repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.

[pi session start]
SUPERVISION OPERATING INSTRUCTIONS - primary harness: pi
- Ordinary wake: the Pi extension already owns watcher continuity; do not arm another cycle.
3. First cycle: arm with the `fm_watch_arm_pi` tool.
7. Ordinary wake: do not call `fm_watch_arm_pi` again because continuity is extension-owned rather than model-memory-owned.
9. Failure or missing cycle only: if the extension reports a watcher failure, drain queued wakes, inspect the failure text, call `fm_watch_arm_pi`, and restart Pi with both extensions loaded if needed.
[pi recovery-only guard instruction]
repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /Users/kunchen/.no-mistakes/worktrees/016d88035d58/01KXY99KXAF8ZETYGW2YG3RTS9/.pi/extensions/fm-primary-turnend-guard.ts -e /Users/kunchen/.no-mistakes/worktrees/016d88035d58/01KXY99KXAF8ZETYGW2YG3RTS9/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.

[opencode session start]
SUPERVISION OPERATING INSTRUCTIONS - primary harness: opencode
- Ordinary wake: the OpenCode TUI plugin already owns watcher continuity; do not arm manually.
2. First cycle: let `.opencode/plugins/fm-primary-watch-arm.js` arm supervision after the OpenCode session goes idle.
5. Ordinary wake: do not ask the model to re-arm because continuity is plugin-owned.
7. Failure or missing cycle only: if the plugin reports a watcher failure, drain queued wakes, inspect the failure text, and use `bin/fm-watch-arm.sh` manually only as a short recovery probe.
[opencode recovery-only guard instruction]
repair missing watcher supervision by letting the OpenCode TUI plugin arm after idle; use bin/fm-watch-arm.sh only as a manual recovery probe if the plugin reports failure.

[grok session start]
SUPERVISION OPERATING INSTRUCTIONS - primary harness: grok
- Ordinary wake: re-arm exactly one bin/fm-watch-arm.sh Grok tracked background task as directed below.
3. First cycle: arm with Grok's tracked background tool, as its own call:
6. Failure or missing cycle only: `watcher: FAILED ...` means supervision is down; fix and re-arm.
4. Ordinary wake: re-arm the next cycle with the same background `bin/fm-watch-arm.sh` call if work remains in flight or X mode still needs polling.
[grok recovery-only guard instruction]
repair missing watcher supervision with bin/fm-watch-arm.sh as its own Grok tracked background task, never shell &.

[actual Claude turn-end guard with an in-flight task and no watcher]
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  TURN WOULD END BLIND - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher holds this home lock (last beat: never).
●  repair missing watcher supervision with bin/fm-watch-arm.sh as its own Claude Code background task, never shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
guard exit status: 2 (2 means it prevented a blind turn end)
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (52m50s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • 🚨 .pi/extensions/fm-primary-turnend-guard.ts:145 - Required criterion: “update turn-end guard output to recovery-only language.” The Pi passive guard still prepends “Resume supervision according to the session-start operating block” to its forced follow-up, so an unhealthy Pi cycle receives the old non-recovery-only instruction before the shared repair reason.
  • 🚨 .opencode/plugins/fm-primary-turnend-guard.js:85 - Required criterion: “update turn-end guard output to recovery-only language.” The OpenCode passive guard still emits “Resume supervision according to the session-start operating block” in its forced follow-up. This path remains reachable when the coordinator does not handle the idle event.

🔧 Fix: Make passive guard follow-ups recovery-only
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 tests failed with exit code 1
  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"

🔧 Fix: Verify OpenCode watcher test stability
✅ Re-checked - no issues remain.

  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • Baseline full suite previously completed successfully: command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • bash tests/fm-supervision-instructions.test.sh
  • bash tests/fm-turnend-guard.test.sh
  • bash tests/fm-watcher-lock.test.sh
  • Manual evidence: rendered bin/fm-supervision-instructions.sh --harness <claude|codex|pi|opencode|grok> and --repair-line; invoked a fixture-backed bin/fm-turnend-guard.sh with an in-flight task and no watcher.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid
kunchenguid merged commit 68c6110 into main Jul 20, 2026
5 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-pi-ordinary-resume-dedupe-p4 branch July 20, 2026 00:18
kirubeltadesse added a commit to kirubeltadesse/firstmate that referenced this pull request Jul 20, 2026
* fix: restore fleet snapshots on stock macOS Bash (kunchenguid#578)

* fix: restore stock macOS snapshot parsing

* no-mistakes(document): Clarify Linux gate and macOS CI coverage

* fix(afk): make Pi escalation and return catch-up reliable (kunchenguid#587)

* fix: close away-mode blocker supervision gap

* no-mistakes(review): Gate teardown retries and verify U+2063 dedupe

* no-mistakes(test): Fail closed on incomplete Pi composer separators

* no-mistakes(document): Document Pi composer recognition and return gating

* feat: support Pi max reasoning profiles (kunchenguid#537)

* support Pi max thinking profiles

* no-mistakes(review): Captain, allow Pi max dispatch profiles

* chore: no-mistakes(document): Clarify yolo response ownership (kunchenguid#595)

* Clarify validation response ownership

* no-mistakes(document): Clarify yolo response ownership

* feat: establish instruction ownership foundation (kunchenguid#619)

* Add instruction owners foundation

* no-mistakes(document): Refresh project-management owner pointers

* fix: compress Firstmate contract and enforce delivery rigor ownership (kunchenguid#626)

* docs: compress firstmate operating contract

* docs: make delivery rigor single-owner

PR B already removed personal and stacked review requirements, but it did not explicitly assign rigor to the selected delivery path or forbid risk-based manual clean gates. That gap still permitted the Hi Bit inversion.

* no-mistakes(review): Honor configured merge authority across faster delivery paths

* no-mistakes(document): Align docs with compressed operating contract

* feat: add durable captain decision holds (kunchenguid#593)

* Add durable captain decision holds

* no-mistakes(review): Validate decision hold retries and origin paths

* no-mistakes(review): Enforce durable decision lifecycle boundaries

* no-mistakes(review): Harden decision display and partial retry recovery

* no-mistakes(test): Update scout teardown fixtures for decision inventory

* no-mistakes(document): Align decision lifecycle and scout teardown documentation

* no-mistakes: apply CI fixes

* no-mistakes(review): Reconcile terminal decision holds

* no-mistakes(document): Align captain decision-hold documentation

* fix(bin): harden PR check artifacts (kunchenguid#556)

* fix: harden PR check artifacts

* fix: close PR check migration gaps

* fix: close PR check retry gaps

* fix: clarify migration outcomes and ESM boundary

* fix: keep failed migrations authoritative

* test: use inert PR validation fixtures

* no-mistakes(review): Reserve noncanonical PR quarantine namespace

* no-mistakes(review): Prevalidate final PR-check teardown artifacts

* no-mistakes(review): Preserve X metadata and validate teardown IDs

* no-mistakes(review): Initialize migration state before watcher exclusion

* no-mistakes(review): Isolate failed poll migrations from bootstrap recovery

* no-mistakes(review): Allow safe polling during incomplete private repairs

* no-mistakes(review): Authenticate watcher checks at execution time

* no-mistakes(review): Preserve custom checks with hash-bound registration

* no-mistakes(review): Clean custom check snapshots on watcher signals

* no-mistakes(review): Stop watcher checks promptly on signals

* no-mistakes(review): Terminate watcher check groups before cleanup

* no-mistakes(document): Correct stale X-mode watcher documentation

* fix: drain returned watcher check groups

* no-mistakes(review): Harden quarantine links and recover validated replacement polls

* no-mistakes(review): Preserve X mode across shim version transitions

* no-mistakes(review): Refresh legacy X shims before marker short-circuits

* no-mistakes(document): Correct persisted PR-check artifact documentation

* no-mistakes(document): Correct stale PR-check documentation

* fix: bind PR poll repair provenance

* no-mistakes(review): Enforce single-link ownership for custom check artifacts

* no-mistakes(review): Preserve private checks, X polling, and lifecycle IDs

* no-mistakes(review): Separate task creation and legacy teardown validation

* no-mistakes(review): Restore safe legacy operations and teardown validation

* no-mistakes(review): Disambiguate migration obligations and preserve legacy retries

* no-mistakes(review): Preserve fail-closed diagnostics and legacy quarantine evidence

* no-mistakes(review): Reconcile legacy migration retries and teardown collisions

* no-mistakes(review): Force legacy namespace reconciliation before marker short-circuits

* no-mistakes(document): Document private poll artifact safety contracts

* no-mistakes(lint): Suppress intentional literal-dollar lint finding

* fix: migrate historical X poll identity

* fix: harden PR check artifacts

* no-mistakes(review): Preserve fail-closed diagnostics and legacy quarantine evidence

* no-mistakes(review): Reconcile legacy migration retries and teardown collisions

* fix: migrate historical X poll identity

* no-mistakes(review): Harden X-mode artifact publication against symlink corruption

* no-mistakes(review): Guard X artifact publication

* no-mistakes(review): Enforce private X artifact reads

* no-mistakes(test): Fix backend compatibility fixture dependencies

* no-mistakes(document): Refresh PR-check documentation

* no-mistakes(lint): Remove unused x-mode test locals

* no-mistakes: apply CI fixes

* fix(bin): compact session-start backlog digest (kunchenguid#636)

* fix: compact session-start backlog digest

* no-mistakes(test): Fix legacy backend fixture helper

* no-mistakes(test): Fix watcher exit wait helper

* no-mistakes(document): Document compact backlog digest

* fix: dedupe stale watcher guard banners (kunchenguid#637)

* fix: dedupe stale watcher guard banner

* no-mistakes(review): Keep read-only guard state nonmutating

* no-mistakes(document): Clarify stale watcher docs

* fix(bin): balance bearings landed baseline (kunchenguid#640)

* fix: balance bearings landed defaults

* no-mistakes(document): Document balanced landed baseline

* no-mistakes: apply CI fixes

* fix: clarify captain-facing translation contract (kunchenguid#644)

* docs: clarify captain-facing translation contract

* no-mistakes(review): Restore runtime fallback mandate

* no-mistakes(document): Align Bearings translation wording

* fix(bin): make bootstrap output and nudges deterministic (kunchenguid#646)

* fix: make bootstrap nudges deterministic

* no-mistakes(review): Honor state override for bootstrap nudges

* no-mistakes(review): Update benign bootstrap documentation labels

* no-mistakes(review): Validate bootstrap nudge retry markers

* no-mistakes(document): Align bootstrap nudge documentation

* no-mistakes: apply CI fixes

* docs(secondmate-provisioning): clarify concise registry ownership (kunchenguid#649)

* Clarify concise secondmate registry contract

* no-mistakes(review): Expand secondmate registry boilerplate coverage

* no-mistakes(document): Point route docs to owner

* fix(bin): strip quoted blocked_by values during decision hold resolve (kunchenguid#654)

* fix(bin): strip quotes on blocked_by in decision-hold resolve

tasks-axi quotes multi-entry blocked_by as "a,b,c", so the comma-boundary
membership test only matched middle elements. Strip surrounding quotes
before matching so first and last hold ids resolve correctly.

* no-mistakes(document): Refresh decision-hold regression evidence

* feat(secondmate): inherit shared captain preferences (kunchenguid#656)

* feat(secondmate): inherit shared captain preferences

* no-mistakes(review): Honor shared captain data overrides

* no-mistakes(review): Honor bootstrap data override registry

* no-mistakes(document): Refresh shared inheritance docs

* no-mistakes(document): Clarify inherited local-material docs

* feat: gate local agent secret injection (kunchenguid#658)

* feat(spawn): gate local agent secret injection

* fix(spawn): align final Keychain slot

* no-mistakes: apply CI fixes

* test: isolate Herdr autodetect smoke sessions (kunchenguid#662)

* test: isolate herdr autodetect smoke session

* no-mistakes(review): Restored autodetect smoke gate bypass

* no-mistakes(test): Harden Herdr lab provisioning

* no-mistakes(document): Refresh Herdr lab docs

* docs: adopt under way for active work (kunchenguid#666)

* Revert "feat: gate local agent secret injection (kunchenguid#658)" (kunchenguid#668)

This reverts commit c27135c.

* fix(pi): distinguish stale locks when arming watcher (kunchenguid#681)

* fix(pi): distinguish stale locks when arming watcher

* no-mistakes(test): Stabilize watcher extension async waits

* no-mistakes(document): Document Pi lock recovery

* fix: accept secondmate house vocabulary (kunchenguid#685)

* fix: accept secondmate as house vocabulary

* no-mistakes(test): Update captain vocabulary contract test

* no-mistakes(document): Align secondmate documentation vocabulary

* fix(bin): parse handoff homes after registry parentheticals (kunchenguid#686)

* fix: parse secondmate home after pre-field parentheses

Registry summaries often include parentheticals before the structured
(home: ...) field. Match that field with a greedy prefix so handoff
no longer reports "has no home" for those entries.

* no-mistakes(document): Refresh handoff test comments

* feat: add native session-start nudges (kunchenguid#687)

* feat: add native session-start nudges

* no-mistakes(document): Document nudge script inventory

* docs: call built-in defaults the firstmate repo, not template (kunchenguid#688)

Relabel absent-captain and related domain defaults wording so it names
the firstmate repo rather than treating "template" as this domain's
identity label. Keep the design-tenet "shared template" statements and
unrelated launch/PR-poll template uses unchanged.

* fix(bin): repair fm-brief.sh parse error and harden set -u array expansion (kunchenguid#205)

* fix(bin): use set -u-safe empty-array expansion in pr-merge and spawn

Expanding "${arr[@]}" on an empty array under set -u fails on bash < 4.4
(notably macOS bash 3.2). Quote the portable "${arr[@]+"${arr[@]}"}" idiom
in fm-pr-merge and fm-spawn batch dispatch so empty arrays expand to nothing.

Co-authored-by: Cursor <[email protected]>

* test(brief): harden fm-brief regression coverage for parse and scaffolds

Tighten bash -n checking, pin literal backtick rendering in the no-mistakes
DOD wording assertion, and keep a scout/secondmate scaffold smoke test so the

Co-authored-by: Cursor <[email protected]>
kunchenguid#166 apostrophe regression cannot return unnoticed.

---------

Co-authored-by: Cursor <[email protected]>

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* fix(x-mode): dedupe pending mention wakes (kunchenguid#745)

* fix(x-mode): dedupe pending mention wakes

* no-mistakes(review): fix x-poll claim error deduplication

* no-mistakes(review): separate claim diagnostics from relay recovery

* no-mistakes(document): Document X-mode once-only mention wakes

* refactor: slim AGENTS.md to ~200 lines, reference files for details

* docs: use canonical expanded reference files from main repo

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Korallis <[email protected]>
Co-authored-by: Johans Ballestar <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
LoneExile added a commit to LoneExile/firstmate that referenced this pull request Jul 20, 2026
…henguid#744)

Split the emitted supervision instruction into an ordinary-wake
continuation vs a repair/recovery action, matching this fork's kunchenguid#693
model where the omp extension owns successor continuity.

- fm-supervision-instructions.sh: new ordinary_wake_line() (omp case:
  'the omp extension already owns watcher continuity; do not arm another
  cycle'); repair_line() omp case reworded to 'repair a missing or failed
  watcher cycle'; the after-wake line now renders ordinary_wake_line
  instead of a hardcoded re-arm recipe.
- resume -> repair wording in fm-guard.sh, fm-bootstrap.sh,
  fm-turnend-guard.sh fallbacks, AGENTS.md section 8, docs/turnend-guard.md,
  docs/supervision-protocols/unknown.md (adds the ordinary-wake vs
  failure-only distinction).
- .omp turn-end guard follow-up now states the watcher cycle is missing/
  failed/unhealthy and points at the harness recovery instruction.
- tests: new non-vacuous test_ordinary_wake_line_distinct_from_repair;
  REQUIRED_REASON + omp-extension recovery asserts + watcher-lock banner
  greps updated to the repair wording.

Full suite green (81) modulo the known fm-pr-check-security flake;
fm-lint rc=0.
raywest added a commit to raywest/firstmate that referenced this pull request Jul 20, 2026
* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* no-mistakes(document): Document stale-wake liveness cadence

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: Ray West <[email protected]>
quinnbot-ai added a commit to quinnbot-ai/firstmate that referenced this pull request Jul 20, 2026
…ss merge regression (#18)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* fix(x-mode): dedupe pending mention wakes (kunchenguid#745)

* fix(x-mode): dedupe pending mention wakes

* no-mistakes(review): fix x-poll claim error deduplication

* no-mistakes(review): separate claim diagnostics from relay recovery

* no-mistakes(document): Document X-mode once-only mention wakes

* feat(wake): enrich drained signals with bounded status context (kunchenguid#747)

* feat(wake): enrich drained signal context

* no-mistakes(review): Bound wake enrichment reads

* no-mistakes(document): Document wake-drain annotations

* docs(wake): explain at-least-once drain boundary

* no-mistakes(review): Prevent symlink races in wake annotations

* no-mistakes(review): Exercise wake symlink race regression

* test: document intentional AFK marker subprocesses

* fix(wake): isolate annotation marker state

* fix(watch): resolve fork/upstream pause-liveness merge conflict; add divergence runbook

The fork/upstream sync merge (67c79e2) combined pause_state_class's parked-gate
override (fork-local) with the new exited-agent liveness gate (upstream) in a
way that was syntactically clean but behaviorally wrong: any class=paused
verdict, including a plain authoritative "state: paused" read, was silently
downgraded to none whenever the agent wasn't CONFIRMED dead - even for
"unknown" liveness, which must never license an action on its own. Split
crew_absorb_class into a line-based classifier shared with pause_state_class
so the parked-gate-override case can bypass the liveness gate entirely (an
explicit declaration is authoritative) while a confirmed-live agent at a
plain "paused" read still gets a fresh surface, and unknown liveness keeps
trusting whatever classification already stood. Full fm-watch-triage suite
(56 tests) now passes clean.

Also adds docs/fm-main-divergence/runbook.md: the verified, exercised
command sequence for hard-aligning the primary checkout's local main to
fork/main once this branch merges, plus the audit proving no local-only
content is at risk and a root-cause note on why /updatefirstmate's
base_mode="origin" never pulls fork-only merges.

* no-mistakes(review): Captain: refresh fork tracking refs

* no-mistakes(review): Reclaim orphaned Treehouse handoff writer files

* no-mistakes(review): Recover X-mode wakes

* docs: fail closed on runbook fetches

* no-mistakes(test): Captain: restore second mate charter role

* no-mistakes(document): Document paused wake recovery

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: QuinnBot <[email protected]>
quinnbot-ai added a commit to quinnbot-ai/firstmate that referenced this pull request Jul 21, 2026
…ss merge regression (#18)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* fix(x-mode): dedupe pending mention wakes (kunchenguid#745)

* fix(x-mode): dedupe pending mention wakes

* no-mistakes(review): fix x-poll claim error deduplication

* no-mistakes(review): separate claim diagnostics from relay recovery

* no-mistakes(document): Document X-mode once-only mention wakes

* feat(wake): enrich drained signals with bounded status context (kunchenguid#747)

* feat(wake): enrich drained signal context

* no-mistakes(review): Bound wake enrichment reads

* no-mistakes(document): Document wake-drain annotations

* docs(wake): explain at-least-once drain boundary

* no-mistakes(review): Prevent symlink races in wake annotations

* no-mistakes(review): Exercise wake symlink race regression

* test: document intentional AFK marker subprocesses

* fix(wake): isolate annotation marker state

* fix(watch): resolve fork/upstream pause-liveness merge conflict; add divergence runbook

The fork/upstream sync merge (67c79e2) combined pause_state_class's parked-gate
override (fork-local) with the new exited-agent liveness gate (upstream) in a
way that was syntactically clean but behaviorally wrong: any class=paused
verdict, including a plain authoritative "state: paused" read, was silently
downgraded to none whenever the agent wasn't CONFIRMED dead - even for
"unknown" liveness, which must never license an action on its own. Split
crew_absorb_class into a line-based classifier shared with pause_state_class
so the parked-gate-override case can bypass the liveness gate entirely (an
explicit declaration is authoritative) while a confirmed-live agent at a
plain "paused" read still gets a fresh surface, and unknown liveness keeps
trusting whatever classification already stood. Full fm-watch-triage suite
(56 tests) now passes clean.

Also adds docs/fm-main-divergence/runbook.md: the verified, exercised
command sequence for hard-aligning the primary checkout's local main to
fork/main once this branch merges, plus the audit proving no local-only
content is at risk and a root-cause note on why /updatefirstmate's
base_mode="origin" never pulls fork-only merges.

* no-mistakes(review): Captain: refresh fork tracking refs

* no-mistakes(review): Reclaim orphaned Treehouse handoff writer files

* no-mistakes(review): Recover X-mode wakes

* docs: fail closed on runbook fetches

* no-mistakes(test): Captain: restore second mate charter role

* no-mistakes(document): Document paused wake recovery

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: QuinnBot <[email protected]>
quinnbot-ai added a commit to quinnbot-ai/firstmate that referenced this pull request Jul 21, 2026
…d guard (#16)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix: harden watcher arm relay leases

* no-mistakes(review): Harden relay leases and cleanup identity

* no-mistakes(review): Harden tmux ownership and review remote selection

* no-mistakes(review): Harden watcher relay and tmux recovery safety

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* fix(x-mode): dedupe pending mention wakes (kunchenguid#745)

* fix(x-mode): dedupe pending mention wakes

* no-mistakes(review): fix x-poll claim error deduplication

* no-mistakes(review): separate claim diagnostics from relay recovery

* no-mistakes(document): Document X-mode once-only mention wakes

* no-mistakes(test): Fix strict target-validation test fixtures

* no-mistakes(document): Document relay lease hardening

* no-mistakes(lint): Fix relay lease lint warnings

* fix: reject symlinked Codex roots before spawn metadata

* fix: reject symlinked Codex root before metadata

* no-mistakes(review): Harden relay leases and normalize PR remotes

* feat(wake): enrich drained signals with bounded status context (kunchenguid#747)

* feat(wake): enrich drained signal context

* no-mistakes(review): Bound wake enrichment reads

* no-mistakes(document): Document wake-drain annotations

* docs(wake): explain at-least-once drain boundary

* no-mistakes(review): Prevent symlink races in wake annotations

* no-mistakes(review): Exercise wake symlink race regression

* test: document intentional AFK marker subprocesses

* fix(wake): isolate annotation marker state

* no-mistakes(test): Fix malformed tangle guard test fixtures

* no-mistakes(document): Document watcher and daemon lease lifecycle

* fix: preserve pre-metadata spawn refusal

* no-mistakes(test): Preserve failed lease metadata and attached arm lifecycle logs

* no-mistakes(review): Fix shared PR review fetch ref

* no-mistakes(review): Harden daemon lease ownership handoff

* no-mistakes(review): Harden stale daemon lease recovery and arm tick validation

* no-mistakes(review): Fence stale AFK lease recovery

* no-mistakes(review): Fence watcher identity lease publication

* no-mistakes(review): Guard reclaimed AFK launcher locks

* no-mistakes(review): Harden relay and launcher lease races

* no-mistakes(document): Document daemon lease recovery grace

* no-mistakes(lint): Isolate lease test helper shells

* fix: harden watcher arm relay leases

* no-mistakes(review): Harden relay leases and cleanup identity

* no-mistakes(review): Harden tmux ownership and review remote selection

* no-mistakes(review): Harden watcher relay and tmux recovery safety

* no-mistakes(test): Fix strict target-validation test fixtures

* no-mistakes(document): Document relay lease hardening

* no-mistakes(lint): Fix relay lease lint warnings

* fix: reject symlinked Codex roots before spawn metadata

* fix: reject symlinked Codex root before metadata

* no-mistakes(review): Harden relay leases and normalize PR remotes

* no-mistakes(test): Fix malformed tangle guard test fixtures

* no-mistakes(document): Document watcher and daemon lease lifecycle

* fix: preserve pre-metadata spawn refusal

* no-mistakes(test): Preserve failed lease metadata and attached arm lifecycle logs

* no-mistakes(review): Fix shared PR review fetch ref

* no-mistakes(review): Harden daemon lease ownership handoff

* no-mistakes(review): Harden stale daemon lease recovery and arm tick validation

* no-mistakes(review): Fence stale AFK lease recovery

* no-mistakes(review): Fence watcher identity lease publication

* docs: retain wake drain annotations

* fix: preserve spawn refusal metadata boundary

* fix: retain prepublication spawn rollback

* test: model stable tmux endpoint cleanup

* fix: retain prelaunch endpoint recovery state

* feat(herdr): add optional presentation spaces (kunchenguid#784)

* feat(herdr): add optional presentation spaces

* no-mistakes(review): Harden Herdr projection creation and spawn serialization

* no-mistakes(review): Captain, disarm Herdr cleanup before launch submission

* no-mistakes(test): Correct stale Orca metadata failure fixture

* no-mistakes(document): Document Herdr presentation projection accurately

* fix: preserve watcher lease handoffs

* fix(spawn): isolated CODEX_HOME for crewmate codex spawns (#3)

* fix: isolate Codex crewmate MCP config

* no-mistakes(review): Harden Codex home cleanup failures

* no-mistakes(review): Harden isolated Codex crewmate launches

* fix: scope Codex trust to worktree

* no-mistakes(review): Harden Codex crewmate launch isolation

* no-mistakes(review): Record failed Codex endpoint cleanup

* no-mistakes(review): Harden case-insensitive Codex launch isolation

* no-mistakes(review): Harden Codex raw launch isolation

* no-mistakes(review): Harden Codex spawn isolation

* no-mistakes(review): Harden Codex launch isolation cleanup

* no-mistakes(review): Harden Codex wrappers and Orca cleanup metadata

* no-mistakes(review): Harden Codex isolation and cleanup

* no-mistakes(review): Captain: Harden Codex spawn isolation

* no-mistakes(review): Harden Codex launch isolation

* no-mistakes(review): Captain: Harden Codex launch isolation

* no-mistakes(review): Captain: harden Codex activation and backend cleanup

* no-mistakes(review): Harden Codex launch isolation

* no-mistakes(review): Captain: preserve raw custom shell launches

* no-mistakes(review): Harden Codex isolation and Zellij cleanup

* no-mistakes(review): Confirm strict Zellij cleanup closures

* no-mistakes(review): Harden Codex activation result isolation

* no-mistakes(review): Harden Codex launch isolation

* fix: harden failed spawn teardown

* fix: harden Codex launch cleanup

* no-mistakes(review): Harden indirect Codex launch isolation

* no-mistakes(review): Harden Codex activation and builtin dispatch

* no-mistakes(review): Harden Orca cleanup and raw launch parsing

* no-mistakes(review): Confirm Orca terminal absence before cleanup

* no-mistakes(test): Disable external review diff drivers

* no-mistakes(test): Fix spawn isolation test fixture

* no-mistakes(review): Respect explicit CODEX_HOME overrides

* no-mistakes(document): Document Codex crewmate isolation

* no-mistakes(lint): Fix ShellCheck lint diagnostics

---------

Co-authored-by: QuinnBot <[email protected]>

* fix: isolate review diffs and Herdr prompt parsing (#2)

* fix(watcher): preserve coalesced pause tracking

* no-mistakes(review): Preserve immediate gone-worker wake detection

* no-mistakes(review): Preserve pause-only signal handoffs

* no-mistakes(test): Fix C-locale Herdr composer detection

* no-mistakes(document): Document coalesced pause recovery

---------

Co-authored-by: nickespo7-del <[email protected]>

* feat: surface operations inbox events in session start and watcher wakes (#4)

* feat: surface operations inbox events

* no-mistakes(review): Harden ops inbox polling

* no-mistakes(review): Bound operations inbox polling

* no-mistakes(review): Harden operations inbox polling

* no-mistakes(review): Harden operations inbox polling

* no-mistakes(review): Captain: bound ops inbox marker traversal

* no-mistakes(review): Bound escaped operations inbox command capture

* no-mistakes(document): Document operations-inbox controls

* test: align ops inbox digest baseline

* fix: keep watcher dependencies fork-local

* fix: keep ops inbox signal output clean

---------

Co-authored-by: QuinnBot <[email protected]>

* fix(watcher): preserve coalesced pause handoffs

* fix(spawn): restore isolated Codex homes

* fix(spawn): resolve isolated CODEX_HOME to a real path for macOS (#6)

* fix(spawn): resolve isolated CODEX_HOME to a real path for macOS

* test(spawn): assert real-path CODEX_HOME activation contract

* style: apply formatter pass to fm-codex-home.py

---------

Co-authored-by: QuinnBot <[email protected]>

* Fix teardown landed-work safeguards (#7)

* Fix teardown landed-work safeguards

* no-mistakes(review): Harden teardown landing safeguards

* no-mistakes(review): Harden teardown cleanup safety

* no-mistakes(review): Captain: harden Orca spawn cleanup

* no-mistakes(review): Captain: harden cleanup safety

* no-mistakes(review): Fix cmux cross-window task discovery

* no-mistakes(review): Harden teardown ownership and legacy cleanup

* no-mistakes(test): Fix teardown lock and endpoint cleanup

* no-mistakes(test): Fix Herdr composer detection under C locale

* no-mistakes(document): Document teardown containment safeguards

---------

Co-authored-by: QuinnBot <[email protected]>

* test: cover legacy teardown task temp paths (#8)

Co-authored-by: QuinnBot <[email protected]>

* fix: absorb declared pauses at parked gates (#9)

* fix: absorb declared pauses at parked gates

* no-mistakes(document): Document parked-gate pause handling

---------

Co-authored-by: QuinnBot <[email protected]>

* fix(spawn): pin worktree-local git identity with Epstein boundary (#14)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* Pin crew worktree git identities

* no-mistakes(review): Captain: retry shared Git config initialization

* no-mistakes(review): Normalize worktree config boolean handling

* no-mistakes(test): Captain, isolate review diffs from external renderers

* no-mistakes(lint): Silence unused retry loop variable

* no-mistakes(lint): Remove unused ShellCheck local

* test: align secondmate charter assertion

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* feat(watch): escalate busy-looking zero-progress crews (#12)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* Escalate busy crews with no progress

* no-mistakes(review): Captain: escalate AFK busy-progress wedges

* no-mistakes(review): Scope pane progress parsing to current footer

* no-mistakes(review): Captain: Harden busy-progress watcher safeguards

* no-mistakes(review): Captain: clear teardown busy-progress state

* no-mistakes(review): Harden busy-progress marker recovery

* fix: cache watcher busy state

* test: bound watcher cache cleanup

* no-mistakes(test): Captain: stabilize tmux smoke and review diffs

* no-mistakes(test): Captain: fix Herdr UTF-8 prompt classification

* no-mistakes(test): Captain: fix transient Herdr worktree detection

* no-mistakes(test): Fix checkpoint cleanup and spawn isolation

* no-mistakes(document): Document busy-progress watcher escalation

* test(brief): restore portable charter assertion

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* fix(spawn): durable worktree leases prevent held-slot reallocation (#13)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* fix: hold treehouse worktrees until teardown

* no-mistakes(review): rollback treehouse leases on spawn failures

* no-mistakes(review): recover stranded treehouse lease handoffs

* no-mistakes(review): Harden treehouse lease recovery

* fix: serialize treehouse lease handoffs

* fix: harden treehouse lease cleanup

* no-mistakes(review): Tombstone returned treehouse lease handoffs

* fix: harden treehouse teardown handoffs

* fix: ignore transient lease handoffs

* no-mistakes(test): Fix lease-aware test fixtures

* no-mistakes(test): Fix locale-safe composer and watcher races

* no-mistakes(test): Close AFK launcher signal race

* no-mistakes(document): Document durable treehouse task leases

* fix: preserve Orca abort cleanup through activation

* fix: retain fork charter portability updates

* test: model leased treehouse allocations in identity fixture

* fix: close failed spawn endpoint before lease return

* fix: retain committed lease on activation failure

* fix: retain recovery metadata after lease commit

* test: match durable lease handoff format

* test: retain committed lease after endpoint closure

* test: model absent endpoint in spawn abort fixture

* test: initialize fixture repositories on main

* fix: preserve durable returned lease tombstones

* fix: make leased spawn setup failures deterministic

* test: forward task temp failure injection

* ci: trace tangle guard hang

* test: make lease setup failure injection deterministic

* ci: allow bounded watcher lifecycle tests to finish

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* fix(spawn): tolerate transient cwd reads and clean up refused spawns (#15)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(spawn): tolerate transient worktree cwd

* no-mistakes(review): Guard leased worktree CWD resolution

* no-mistakes(test): Captain: synchronize secondmate charter role assertion

* no-mistakes(test): Stabilize Herdr heartbeat test waits

* no-mistakes(document): Document spawn isolation safeguards

* test: include lease helper in teardown fixture

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* Fix fail-closed fm-send delivery verification (#17)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: durable pause recognition across watcher restarts (#1)

* fix: prevent no-mistakes gate agents from driving the fleet (kunchenguid#518)

* feat: contain no-mistakes gate agents from driving the fleet

Add bin/fm-gate-refuse-lib.sh, sourced at the top of fm-spawn/fm-send/
fm-teardown before any fleet mutation. It fails closed when NO_MISTAKES_GATE
is set, and via an unspoofable git-common-dir backstop when invoked from a
no-mistakes gate worktree (.no-mistakes/repos/*.git) even with the marker
unset. A normal firstmate session has neither signal and is unaffected.

Set disable_project_settings: true in the tracked .no-mistakes.yaml so the
installed pipeline neutralizes gate agents' project instructions for this repo
(trusted-only, honored from the default branch).

firstmate's own suite runs from a gate worktree during validation, so the
shared test helpers set FM_GATE_REFUSE_BYPASS=1 to exempt it; the dedicated
tests/fm-gate-refuse.test.sh strips it to verify real refusal.

* no-mistakes(review): Captain, refuse empty no-mistakes gate markers

* no-mistakes(document): Document no-mistakes gate authority boundary

* fix: guard secondmate primary sessions from blind turn ends (kunchenguid#505)

* fix: guard secondmate own-home turn ends

Remove the .fm-secondmate-home early-exit in fm-turnend-guard.sh so the
'no turn ends blind' backstop fires in a secondmate's own primary session,
matching the cd-guard's scope: the own home is guarded, child crew/scout
worktrees stay exempt via the retained git-dir/git-common-dir test. This
was pure scoping from the guard's primary-only origin and guarded against
no secondmate-specific hazard.

Add secondmate regression tests (blind-turn block, idle-by-default,
stop_hook_active loop guard, deferred-death recovery loop, child-worktree
exemption) and record the autonomous background-notify re-invoke
measurement (Claude Code 2.1.207, 11s) in docs/turnend-guard.md.

* no-mistakes(document): Correct secondmate guard documentation, captain

* fix: force-include marked secondmate homes in turn-end guard

The prior remove-only form (just deleting the .fm-secondmate-home check)
left the DEFAULT secondmate topology unguarded: a treehouse-leased home is
a linked git worktree (git-dir != git-common-dir), which the retained
git-dir exemption still skipped, so its own primary session could still end
a turn blind. Invert the marker: a genuinely-marked home is force-included
as a guarded primary (treehouse-leased linked OR git-cloned plain), and the
git-dir exemption applies only to UNMARKED child worktrees. Marker
validation (regular non-symlink file, non-empty id-token content) blocks a
stray or empty marker from spoofing inclusion.

Add real linked-worktree regression tests: a treehouse-leased LINKED
secondmate home is guarded, a stray/empty marker stays exempt, and the
unmarked child worktree stays exempt - the topology the plain git-init
fixtures masked. Predicates, in-flight gate, and loop guard untouched.

* fix: force ASCII collation in secondmate marker validation

Add a function-scoped local LC_ALL=C in fm_root_is_secondmate_home so the
[A-Za-z0-9._-] id allowlist matches under C collation, not the ambient
locale - a locale-crafted non-ASCII marker id can no longer slip through
the range match and spoof force-inclusion of a linked child worktree.
Add a regression test proving a non-ASCII marker id is rejected and the
linked worktree stays exempt.

* no-mistakes(test): fix backend baseline gate-refusal dependency

* no-mistakes(document): Correct secondmate turn-end guard documentation

* fix: make bootstrap diagnostics backend-aware (kunchenguid#519)

* fix: make bootstrap required-tool detection backend-aware

Bootstrap demanded tmux and treehouse for every backend except orca, so a
herdr/zellij/cmux home with tmux absent was wrongly told MISSING: tmux.

Required tools now follow the resolved backend via the single-owner
fm_backend_required_tools helper (bin/fm-backend.sh): each backend's own
session-provider CLI, jq for the JSON-emitting adapters (herdr/zellij/cmux),
and treehouse for session-provider-only backends (orca owns its worktree).
The treehouse lease-support check is gated to backends that use treehouse.

Adds install hints for herdr/zellij/cmux, regression tests for the full
backend dependency matrix (herdr-without-tmux repro plus each boundary),
and updates the authoritative Toolchain docs.

* no-mistakes(review): Captain, prevent executing Herdr install guidance

* no-mistakes(review): Captain, harden backend-aware bootstrap diagnostics

* no-mistakes(review): Captain, separate manual dependency remediation

* no-mistakes(review): Captain, align bootstrap diagnostic consumers

* no-mistakes(document): Align backend adapter dependency comments

* fix: preserve follow-up platform context after inbox cleanup (kunchenguid#520)

* fix: recover X/Discord follow-up platform after inbox cleanup

A milestone follow-up posted directly by request_id after the inbox was
drained - and with no task link, because one persistent secondmate's single
x_request slot collides across concurrent requests - resolved platform only
from the local inbox, so a >280 Discord reply silently defaulted to the X
280-char budget and threaded as (1/2).

- fm-x-poll records a durable per-request reply context
  (state/x-context/<rid>.json) at stash time, keyed by request_id so
  concurrent requests never overwrite each other; it survives inbox cleanup
  and restart.
- fm-x-reply resolves platform/budget through registry -> inbox -> relay
  (the relay lookup confined to a live follow-up), recovering the original
  platform independent of task-link availability.
- Fail-safe: a follow-up whose platform/budget cannot be authoritatively
  resolved and that would split is refused (exit 8) and held for retry,
  never wrongly split; fm-x-followup keeps the link on that exit.
- fm-x-dismiss clears the durable context for a dismissed mention.

Refactors reply-context extraction into a single owner and adds regression
coverage for all four cases.

* no-mistakes(review): Captain, fail closed on incomplete follow-up context

* no-mistakes(review): Captain, bound X context registry retention

* no-mistakes(review): Captain, align context retention with answer binding

* no-mistakes(document): Align X follow-up context documentation

* no-mistakes(document): Align durable X follow-up documentation

* fix: preserve secondmate routing markers in terminal sends (kunchenguid#533)

* fix: preserve secondmate routing markers

* no-mistakes(review): Captain, preserve trailing newlines in marked secondmate sends

* no-mistakes(test): Captain, tolerate bootstrap timeout elapsed drift

* no-mistakes(document): Refresh Herdr marker documentation

* fix: align Grok effort handling with 0.2.99 (kunchenguid#527)

* fix: align grok effort docs and spawn with 0.2.99 ceiling

grok 0.2.99 accepts only low|medium|high for --reasoning-effort and
rejects both xhigh and max. Omit unsupported values on spawn, flag them
in crew-dispatch validation, and update harness-adapters.

* no-mistakes(test): Captain: refresh gotmp teardown fixture dependencies

* no-mistakes(document): Clarify Grok effort documentation ownership

* fix: preserve declared pauses across watcher restarts

* no-mistakes(review): Preserve unknown-state stale wake safety

* no-mistakes(test): Stabilize PR review diffs

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Korallis <[email protected]>
Co-authored-by: nickespo7-del <[email protected]>

* fix(herdr): distinguish submitted codex redraws

* no-mistakes(review): Harden Herdr submit and nested inbox detection

* no-mistakes(review): Harden Herdr confirmation and Codex activation

* no-mistakes(review): Track all operations inbox events

* no-mistakes(review): Captain: harden activation and bound inbox polling

* no-mistakes(review): Captain: harden activation, cleanup, and inbox markers

* no-mistakes(review): Harden activation and bound inbox scans

* no-mistakes(review): Prevent capped inbox runners resetting deadlines

* no-mistakes(review): Harden submit verification and cleanup recovery

* no-mistakes(test): Preserve pause recheck grace

* no-mistakes(document): Document operations-inbox scan bounds

* no-mistakes(lint): Remove unused Herdr scan variable

* test(orca): align abort cleanup fixture

* no-mistakes(review): Fix Codex home cleanup identity arguments

* no-mistakes(review): Harden failed-spawn cleanup safety

* no-mistakes(review): Harden cleanup safety, captain

* no-mistakes(review): Fail closed unknown Herdr preflight

* no-mistakes(test): Fix teardown patch equivalence and OpenCode lock race

* no-mistakes(test): Captain: align teardown tests with lock preflight

* no-mistakes(document): Document submit and failed-spawn safeguards

* fix(teardown): honor checkout default branch

* no-mistakes(review): Harden teardown and inbox fingerprinting

* no-mistakes(review): Bound ops inbox fingerprint scans

* no-mistakes(review): Harden spawn cleanup and inbox overflow detection

* no-mistakes(review): Stabilize overflowed inbox fingerprints

* no-mistakes(review): Harden leased spawn cleanup and watcher reaping

* no-mistakes(review): Captain: harden treehouse lease cleanup validation

* no-mistakes(review): Guard treehouse leases against active worktree collisions

* no-mistakes(test): Update spawn test fakes for verified treehouse leases

* no-mistakes(document): Document strict spawn isolation and watcher timeout reaping

* test(orca): preserve fixture default branch

* no-mistakes(review): Captain: fail closed on unconfirmed submits

* no-mistakes(review): Require confirmed Orca terminal absence before teardown

* no-mistakes(review): Preserve Orca resources without terminal confirmation

* no-mistakes(review): Captain: Preserve leases pending endpoint confirmation

* no-mistakes(review): Preserve confirmed Orca terminal absence

* no-mistakes(review): Honor confirmed Orca terminal absence

* no-mistakes(review): Harden fm-send and Orca cleanup

* no-mistakes(review): Harden backend agent liveness and Orca recovery

* no-mistakes(review): Fail closed without native backend liveness

* no-mistakes(review): Captain: harden explicit target liveness

* no-mistakes(test): Fix fm-send test liveness fixtures

* no-mistakes(test): Preserve endpoints on failed worktree cleanup

* no-mistakes(test): Return lease before failed Codex activation cleanup

* no-mistakes(document): Document fail-closed steering and teardown safety

* no-mistakes(review): Fail closed on unverified Python liveness

* fix(orca): retain abort cleanup state

* fix(orca): preserve abort cleanup safety

* test(send): model a live tmux agent

* test(codex): keep activation fixture alive

* fix(teardown): check locks before safety approval

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Korallis <[email protected]>
Co-authored-by: nickespo7-del <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* fix(watch): sync fork with upstream through 4ab61fa, fix pause-liveness merge regression (#18)

* fix(bin): keep watcher supervision continuous across child cycles (kunchenguid#693)

* fix: make watcher supervision continuous

* no-mistakes(review): Bound watcher retries and log attached signals

* no-mistakes(review): Add bounded successor-recovery wake fallbacks

* no-mistakes(review): Prevent overlapping successor-arm retries

* no-mistakes(review): Resume supervision after late arm closes

* no-mistakes(review): Bind OpenCode recovery to attempted arm

* no-mistakes(test): Synchronize peer beacon regression fixture

* no-mistakes(test): Synchronize Pi and OpenCode late-close lifecycle fixtures

* no-mistakes(document): Captain: document watcher successor protocol behavior

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: fetch current PR head for review diffs (kunchenguid#722)

* fix: always fetch PR head for review diffs

Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded
pr_head= so reviewers never hold a merge over a "missing" fix that already
landed on the remote PR. Recorded SHA is offline fallback only; local branch
is last resort with a warning. Store the tip under refs/fm-review/ so a later
base-branch fetch cannot clobber the compare tip via FETCH_HEAD.

* no-mistakes(test): Isolate session-start nudge tests from gate state

* no-mistakes(document): Correct review-diff documentation

* docs: resolve five contract contradictions across AGENTS.md, README, and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck

* docs(harness): correct Grok exit guidance (kunchenguid#742)

* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution

* fix(watcher): bound stale wakes for parked crew (kunchenguid#743)

* fix(watcher): bound stale wakes for exited paused crew

* no-mistakes(review): Gate pause suppression on confirmed agent death

* no-mistakes(test): Fixed stale pause cadence

* no-mistakes(document): Document dead-agent hold cadence

* fix(supervision): distinguish ordinary wakes from recovery (kunchenguid#744)

* fix(supervision): distinguish ordinary wakes from repair

* no-mistakes(review): Make passive guard follow-ups recovery-only

* no-mistakes(document): Clarify recovery-only turn-end guard documentation

* fix(x-mode): dedupe pending mention wakes (kunchenguid#745)

* fix(x-mode): dedupe pending mention wakes

* no-mistakes(review): fix x-poll claim error deduplication

* no-mistakes(review): separate claim diagnostics from relay recovery

* no-mistakes(document): Document X-mode once-only mention wakes

* feat(wake): enrich drained signals with bounded status context (kunchenguid#747)

* feat(wake): enrich drained signal context

* no-mistakes(review): Bound wake enrichment reads

* no-mistakes(document): Document wake-drain annotations

* docs(wake): explain at-least-once drain boundary

* no-mistakes(review): Prevent symlink races in wake annotations

* no-mistakes(review): Exercise wake symlink race regression

* test: document intentional AFK marker subprocesses

* fix(wake): isolate annotation marker state

* fix(watch): resolve fork/upstream pause-liveness merge conflict; add divergence runbook

The fork/upstream sync merge (67c79e2) combined pause_state_class's parked-gate
override (fork-local) with the new exited-agent liveness gate (upstream) in a
way that was syntactically clean but behaviorally wrong: any class=paused
verdict, including a plain authoritative "state: paused" read, was silently
downgraded to none whenever the agent wasn't CONFIRMED dead - even for
"unknown" liveness, which must never license an action on its own. Split
crew_absorb_class into a line-based classifier shared with pause_state_class
so the parked-gate-override case can bypass the liveness gate entirely (an
explicit declaration is authoritative) while a confirmed-live agent at a
plain "paused" read still gets a fresh surface, and unknown liveness keeps
trusting whatever classification already stood. Full fm-watch-triage suite
(56 tests) now passes clean.

Also adds docs/fm-main-divergence/runbook.md: the verified, exercised
command sequence for hard-aligning the primary checkout's local main to
fork/main once this branch merges, plus the audit proving no local-only
content is at risk and a root-cause note on why /updatefirstmate's
base_mode="origin" never pulls fork-only merges.

* no-mistakes(review): Captain: refresh fork tracking refs

* no-mistakes(review): Reclaim orphaned Treehouse handoff writer files

* no-mistakes(review): Recover X-mode wakes

* docs: fail closed on runbook fetches

* no-mistakes(test): Captain: restore second mate charter role

* no-mistakes(document): Document paused wake recovery

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: QuinnBot <[email protected]>

* fix: harden watcher arm relay leases

* no-mistakes(review): Harden relay leases and cleanup identity

* no-mistakes(review): Harden tmux ownership and review remote selection

* no-mistakes(review): Harden watcher relay and tmux recovery safety

* no-mistakes(test): Fix strict target-validation test fixtures

* no-mistakes(document): Document relay lease hardening

* no-mistakes(lint): Fix relay lease lint warnings

* fix: reject symlinked Codex roots before spawn metadata

* fix: reject symlinked Codex root before metadata

* no-mistakes(review): Harden relay leases and normalize PR remotes

* no-mistakes(test): Fix malformed tangle guard test fixtures

* no-mistakes(document): Document watcher and daemon lease lifecycle

* fix: preserve pre-metadata spawn refusal

* no-mistakes(test): Preserve failed lease metadata and attached arm lifecycle logs

* no-mistakes(review): Fix shared PR review fetch ref

* no-mistakes(review): Harden daemon lease ownership handoff

* no-mistakes(review): Harden stale daemon lease recovery and arm tick validation

* no-mistakes(review): Fence stale AFK lease recovery

* no-mistakes(review): Fence watcher identity lease publication

* docs: retain wake drain annotations

* fix: preserve spawn refusal metadata boundary

* fix: retain prepublication spawn rollback

* test: model stable tmux endpoint cleanup

* fix: retain prelaunch endpoint recovery state

* fix: preserve watcher lease handoffs

* no-mistakes(review): Harden tmux ownership and review remote selection

* no-mistakes(test): Fix strict target-validation test fixtures

* no-mistakes(document): Document relay lease hardening

* no-mistakes(test): Fix malformed tangle guard test fixtures

* fix: preserve pre-metadata spawn refusal

* no-mistakes(test): Preserve failed lease metadata and attached arm lifecycle logs

* no-mistakes(review): Harden stale daemon lease recovery and arm tick validation

* no-mistakes(review): Fence stale AFK lease recovery

* no-mistakes(review): Guard reclaimed AFK launcher locks

* no-mistakes(review): Harden relay and launcher lease races

* no-mistakes(document): Document daemon lease recovery grace

* no-mistakes(lint): Isolate lease test helper shells

* no-mistakes(review): Publish lease before watcher binding

* no-mistakes(test): Fix watcher and Herdr teardown regressions

* no-mistakes(test): Fix watcher and Codex activation test fixtures

* no-mistakes(test): Preserve paused recovery across watcher restarts

* no-mistakes(test): Remove duplicate pause-liveness test invocation

* no-mistakes(test): Fix attached arm lifecycle ledger race

* no-mistakes(document): Document lease and Git identity helpers

* no-mistakes(lint): Resolve ShellCheck warnings in lease regression tests

* no-mistakes(review): Reclaim reused watcher locks during normal arm

* no-mistakes(review): Fence watcher lock reclaim race

* fix: fence watcher restart reclaim

* no-mistakes(review): Fence arm lease release by owner PID

* no-mistakes(document): Correct operations inbox and relay lease docs

* no-mistakes(lint): Remove unused treehouse lease assignment

* no-mistakes(lint): Captain: remove unused treehouse lease assignment

* fix(spawn): preserve prepublication refusal boundary

* test(spawn): model stable tmux cleanup identity

* test(spawn): cover stable data-root refusal cleanup

* test(spawn): cover stable abort cleanup paths

* test(spawn): model stable isolation cleanup

* fix(watch): surface attached relay handoff failures

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Israel Wilson <[email protected]>
Co-authored-by: QuinnBot <[email protected]>
Co-authored-by: nickespo7-del <[email protected]>
Co-authored-by: Korallis <[email protected]>
Marl0nL added a commit to Marl0nL/firstmate that referenced this pull request Jul 24, 2026