Skip to content

fix(bin): treat the live launchd poller as valid supervision - #3

Open
DQ4443 wants to merge 2 commits into
mainfrom
worktree-agent-a1491bf769e3a623a
Open

DQ4443 wants to merge 2 commits into
mainfrom
worktree-agent-a1491bf769e3a623a

Conversation

@DQ4443

@DQ4443 DQ4443 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

What Changed

  • bin/fm-supervision-lib.sh now tracks both supervisor beacons (state/.last-poller-beat and state/.last-watcher-beat) and reports a combined FM_SUP_SUPERVISED verdict: either beacon fresh within the grace window counts as supervised, so fm-guard.sh and fm_supervision_unhealthy no longer false-alarm when only the launchd poller is up. The banner beacon description now names which supervisor beat and when (e.g. "poller 4s ago").
  • bin/fm-turnend-guard.sh short-circuits on a genuinely healthy poller via a new fm_poller_healthy helper in bin/fm-wake-lib.sh (pidfile pid alive plus fresh beacon) before falling back to the watcher lock check, so turns are no longer blocked when the poller alone is supervising. Banner and remediation text in fm-guard.sh, fm-turnend-guard.sh, and fm-wake-drain.sh now points at both supervisors (verify the poller, or arm the watcher escape hatch).
  • Docs (docs/architecture.md, docs/scripts.md, docs/configuration.md, docs/turnend-guard.md, CONTRIBUTING.md) and the guard/wake-queue/watcher-lock tests are updated to the poller-as-valid-supervision model, including new turnend-guard test coverage for the poller-healthy path. The full test suite passed in the pipeline run; the review left two informational notes (the pre-existing beacon-freshness grace tradeoff now extended to the poller, and duplicated .poll.pid parsing between fm-poll.sh and fm_poller_healthy).

Risk Assessment

✅ Low: A well-bounded, fail-closed extension of existing supervision checks whose new poller-health predicate exactly matches the poller's pidfile and beacon contract, with hermetic tests covering the fresh, stale, and dead-pid cases and no stale consumers of the renamed banner or status fields.

Testing

Completed 1 recorded test check.

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-supervision-lib.sh:72 - The pull-based fm-guard.sh path judges supervision by beacon freshness alone (fm_supervision_status), so a poller or watcher that died within the last FM_GUARD_GRACE seconds (default 300) reads as supervised and stays silent. This is the pre-existing watcher tradeoff extended to the poller, and the sharper liveness check in fm-turnend-guard.sh covers the end-of-turn case; noting it as an acknowledged design tradeoff, not a defect.
  • ℹ️ bin/fm-wake-lib.sh:99 - The .poll.pid parsing convention (pid via sed -n '1p', identity via sed -n '2,$p') is now duplicated between the poller's singleton guard in bin/fm-poll.sh and fm_poller_healthy in bin/fm-wake-lib.sh. Factoring a small shared read-pidfile helper would keep the two consumers from drifting if the pidfile format ever changes.
✅ **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"
⚠️ **Document** - 1 info
  • ℹ️ docs/turnend-guard.md:3 - docs/turnend-guard.md cites 'AGENTS.md section 8' as the home of the 'no turn ends blind' discipline (lines 3 and 16), but the rewritten AGENTS.md's section 8 is now 'Restart and recovery' and no section states that discipline. Pre-existing at the base commit (paradigm rewrite), not caused by this change; re-pointing or rewording needs a decision about where that discipline lives in the new AGENTS.md.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

DQ4443 and others added 2 commits July 6, 2026 02:22
The 2026-07-05 workflow-paradigm cutover made the launchd poller
(bin/fm-poll.sh, beacon state/.last-poller-beat) the live supervisor and
retired the push-based watcher (bin/fm-watch.sh) to an escape hatch, but the
supervision-health predicates still checked the watcher alone.
With the poller up and healthy the turn-end guard fired
"TURN WOULD END BLIND - SUPERVISION IS OFF" every turn, and fm-wake-drain.sh
printed the same false alarm.

Make the checks additive - watcher-healthy OR poller-healthy means supervised:
- fm-supervision-lib.sh: fm_supervision_status now reads both beacons, adds
  FM_SUP_POLLER_FRESH and FM_SUP_SUPERVISED, and describes the freshest beacon
  in FM_SUP_BEACON_DESC; fm_supervision_unhealthy keys off FM_SUP_SUPERVISED.
- fm-wake-lib.sh: new fm_poller_healthy mirrors fm_watcher_healthy against the
  poller's own liveness record (live pid on line 1 of state/.poll.pid, matching
  process identity on line 2, and a fresh state/.last-poller-beat).
- fm-turnend-guard.sh: accept the turn when either supervisor is genuinely
  alive; the block banner and reason now name the poller as primary.
- fm-guard.sh: the pull-based banner keys off supervision, not the watcher
  alone, so a live poller stays silent.

The old watcher path is untouched and still works as the documented escape
hatch, and the guard still fires when neither supervisor is live and work is in
flight (a dead poller that only left a fresh beacon still blocks).

Tests extend the predicate and hook coverage with poller cases, and the drain
test asserts a fresh poller beacon silences the banner.
docs/turnend-guard.md is updated to reality (poller primary, watcher hatch).
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.

1 participant