Skip to content

fix(bin): harden watcher continuity and stale-wake handling - #5

Merged
raywest merged 8 commits into
mainfrom
fm/fm-fork-sync-u1
Jul 20, 2026
Merged

raywest merged 8 commits into
mainfrom
fm/fm-fork-sync-u1

Conversation

@raywest

@raywest raywest commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Intent

Sync the fork with upstream: merge upstream/main (kunchenguid/firstmate) into the fork's main via a genuine merge commit (never rebase), reconciling conflicts between the fork's 4 ahead PRs (kimi crewmate/scout harness adapter, a watcher stale-suppression restart-refire fix, flaky-test stabilization, and a GLM harness_profile dispatch axis) and upstream's advances since divergence (notably kunchenguid#743 bound-stale-wakes-for-parked-crew and kunchenguid#693 continuous-watcher-supervision, both touching the same bin/fm-watch.sh area as the fork's own stale-suppression fix). The critical decision: upstream's kunchenguid#743 added agent-liveness detection (dead/alive/unknown) to bound stale wakes, and its structure is a superset of the fork's fix, but a naive line-based auto-merge combined them incorrectly - it treated 'unknown' agent liveness the same as 'alive' as license to bypass the pause cadence and re-derive crew state every poll, which silently regressed the fork's own regression-test guarantee (a misattributed no-mistakes run-step outcome must not re-trigger a stale wake on every watcher restart). Fixed pause_state_class so only a CONFIRMED-alive agent bypasses the bounded-pause cadence; dead and unknown liveness both stay bounded/throttled - this satisfies upstream's own new test (a live external-decision gate must still surface immediately) while preserving the fork's regression coverage (an unknown-liveness misattributed-run-step case must stay throttled, not re-read crew state or re-surface every restart). Also reverted a fork-side status-log-text wrapper that the merge had left in place at the first-sight branch, since it suppressed upstream's required immediate surface for a live decision gate and is strictly inferior to the new agent-liveness signal. For tests/fm-watcher-lock.test.sh, took upstream's rewritten restart-attaches-to-healthy-peer test wholesale (bin/fm-watch-arm.sh is a file the fork never touched - 0-line diff from the merge base - so upstream fully owns that behavior; the fork's old test asserted the now-obsolete opposite contract). For docs/architecture.md, merged both sides' explanatory prose rather than picking one, since they describe complementary facets of the same merged behavior. Also fixed an unrelated pre-existing fork bug found during full-suite validation: tests/fm-kimi-harness.test.sh was missing its executable bit since the original kimi-adapter PR (confirmed via git ls-tree at the prior branch tip, predates this merge) and was silently failing every CI run of the full suite with a shell permission-denied error - not a real test failure. Verified: all four fork features (kimi adapter, watcher fix, flaky-test stabilization, GLM axis) still functional post-merge with no silent regressions where upstream touched neighboring code (fm-spawn.sh, fm-bootstrap.sh, the harness-adapters skill). Full local suite: 84/84 test files green, both watcher suites green (fm-watch-triage.test.sh 35/35, fm-watcher-lock.test.sh 26/26), shellcheck clean.

What Changed

  • Keep watcher supervision continuous across child cycles and retain bounded stale-wake cadence for paused or captain-held crew unless the agent is confirmed alive.
  • Add continuity safeguards and lifecycle handling across the primary harness adapters, with updated supervision documentation and expanded live coverage.
  • Fetch current PR heads for review diffs, reconcile harness/protocol contracts, and restore the Kimi harness test’s executable mode.

Risk Assessment

⚠️ Medium: This is a broad cross-cutting merge across watcher, arm-wrapper, and harness-continuity paths, but the reviewed conflict resolution and intent-critical pause semantics are internally consistent with no substantiated defects found.

Testing

The supplied full-suite baseline had already passed; targeted watcher, Kimi, Codex-profile, secondmate, bootstrap, and instruction-owner suites passed, while manual CLI evidence confirmed unknown-liveness throttling, immediate live-gate surfacing, and healthy-peer restart attachment. This is shell-only behavior, so the reviewer-visible terminal transcript is the applicable UI evidence.

Evidence: Watcher end-to-end CLI transcript
Watcher merge end-to-end CLI evidence
====================================
unknown liveness (node) + previously-classified paused status:
  watcher remains armed; stdout is empty; no stale wake is queued; crew state was not re-read.
confirmed-live decision gate (grok):
  watcher stdout: stale: demo:fm-decision-gate
  queued wake: 1784514972	1	stale	demo:fm-decision-gate	stale: demo:fm-decision-gate
restart while a verified peer is healthy:
  arm stdout: watcher: already running pid 89149
  arm stdout: watcher: attached pid=89149 (beacon 12s)
  arm stdout: watcher: FAILED - cycle ended without an actionable reason
RESULT: all three externally visible contracts behaved as required.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - medium risk

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • 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"
  • Configured full-suite command was reported as a successful baseline (not rerun).
  • bash tests/fm-watch-triage.test.sh
  • bash tests/fm-watcher-lock.test.sh
  • bash tests/fm-kimi-harness.test.sh
  • bash tests/fm-spawn-dispatch-profile.test.sh
  • bash tests/fm-secondmate-harness.test.sh
  • bash tests/fm-bootstrap.test.sh
  • bash tests/fm-instruction-owners.test.sh
  • bash /var/folders/md/6d3x0xmj0rd3sxvq647l2jnh0000gn/T/no-mistakes-evidence/01KXYKH1KVB3924F6M7XQXG8SJ/watcher-e2e-evidence.sh
  • git rev-list --parents -n 1 92290c90b4af3aff9136a1da0313fa6e3928c519 and git ls-tree -r --long 92290c90b4af3aff9136a1da0313fa6e3928c519 tests/fm-kimi-harness.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

kunchenguid and others added 8 commits July 18, 2026 17:36
…nchenguid#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: 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
…and skills (kunchenguid#736)

* docs: resolve five contract contradictions

* no-mistakes(test): align owner-pointer assertions with reworded docs; skip absent shellcheck
* docs(harness): reverify grok exit command

* no-mistakes(test): Correct Grok exit resume attribution
* 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
…id#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
Merges kunchenguid/firstmate main into the fork, bringing in kunchenguid#743, kunchenguid#693,
kunchenguid#744, kunchenguid#736, kunchenguid#722, and other upstream commits since the fork diverged at
bc1a21b, while preserving the fork's four features (kimi adapter, watcher
stale-suppression fix, flaky-test stabilization, GLM harness_profile axis).

Conflict resolution:

- bin/fm-watch.sh (pause_state_class and its three call sites): upstream's
  kunchenguid#743 added agent-liveness detection to bound stale wakes for a parked
  crew whose agent has confidently exited. The fork's #2 fixed a different
  case in the same defect class - a stale/misattributed no-mistakes
  run-step outcome outranking a crew's own later paused: declaration,
  causing a bare stale wake to refire on every watcher restart. Upstream's
  structure is the superset (kept), but its early-return treated any
  non-dead liveness read (both "alive" and "unknown") as license to bypass
  the pause cadence and re-derive the crew-state read every poll. That
  regressed the fork's throttling guarantee for an "unknown" liveness read
  (no live pane to sample), which is exactly the fork's regression
  scenario. Fixed by narrowing the bypass to a CONFIRMED-alive agent only
  (a live decision gate that must not be hidden behind the cadence, per
  upstream's own test_exited_declared_pause_is_bounded_but_live_gate_surfaces);
  dead and unknown liveness both stay on the bounded/throttled cadence. The
  fork's first-sight wrapper (trusting the status log's paused: word over a
  crew-state verdict) was reverted in favor of upstream's plain
  pause_state_class dispatch, since the agent-liveness signal is a strict
  improvement over that text heuristic and the wrapper suppressed
  upstream's required immediate surface for a live decision gate. Both the
  fork's regression test
  (test_nonterminal_stale_paused_survives_misattributed_run_step_across_restarts)
  and upstream's new test
  (test_exited_declared_pause_is_bounded_but_live_gate_surfaces) are kept
  and pass.

- docs/architecture.md: merged both sides' substance (upstream's dead-agent
  bounded-cadence description plus the fork's "only positive working
  evidence displaces pause treatment" sentence) rather than picking one;
  they describe complementary facets of the same merged behavior.

- tests/fm-watch-triage.test.sh: kept both new tests (fork's misattributed
  run-step regression, upstream's exited-pause/live-gate coverage) and
  both registrations.

- tests/fm-watcher-lock.test.sh: upstream's kunchenguid#693 rewrote the watcher-arm
  script's restart peer handling (attach-and-follow a healthy peer instead
  of reporting-without-attaching) - a feature the fork never touched
  (0-line diff from the merge base). Took upstream's test
  (test_watch_restart_attaches_to_healthy_peer) wholesale since it now
  matches the actual upstream-owned implementation; the fork's prior
  version asserted the opposite (now-obsolete) contract. The fork's
  TERM-resistant-peer race fix (the ready-file synchronization helper) was
  shared context in both versions and is unaffected.

Also fixed in this branch: tests/fm-kimi-harness.test.sh was missing its
executable bit since the fork's kimi-adapter PR first added it (pre-dates
this merge, confirmed via git ls-tree at the prior tip) - blocked the full
suite; fixed via chmod +x.

Sanity-checked: kimi adapter, GLM harness_profile axis, and the
flaky-test fixes all verified intact post-merge with no silent
regressions from upstream's neighboring-line changes.

Full suite: 84/84 test files green, both watcher suites green
(35/35 and 26/26), shellcheck clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants