Repository navigation
fix(afk): validate supervisor backend and target before arming away mode - #67
Merged
Merged
Conversation
Extract validate_supervisor_target into fm-supervisor-target-lib.sh, shared by the away-mode daemon's own startup check and a new pre-arm check in fm-afk-launch.sh, so a broken or unrecognized FM_SUPERVISOR_BACKEND/target is rejected before state/.afk is written instead of failing silently once an escalation tries to deliver. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015MFSYTbWodjcKFrjAQZ41S
sKeLe100
added a commit
that referenced
this pull request
Sep 15, 2026
…fk-launch tests (fork #67, upstream #4048) Upstream #4048 requires a confirmed away-posture record before any daemon entry and fork #67 refuses a native entry whose primary pane cannot be verified in tmux or herdr. Each side's tests only set up its own precondition, so on the merged tree upstream's two successful native entries were refused by the fork's host check and the fork's three host refusals were pre-empted by upstream's record gate. The successful entries now open a tracked captain tmux pane (skipping without tmux, as the fork's native lifecycle unit already does) and the refusal units confirm the posture first, so each assertion proves its own gate. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013AKRYBp95BX5y6ne9wPhtr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Edge case follow-up from the afk-delivery-unreachable review, decided 2026-08-27: the /afk pre-arm check should validate FM_SUPERVISOR_BACKEND is a valid/recognized backend and that its target actually exists, before writing state/.afk. Currently it's possible to enter away mode with a broken or nonexistent supervision target, which would silently fail to deliver away-mode escalations.
What Changed
validate_supervisor_targettobin/fm-supervisor-target-lib.sh, which now also ownsFM_SUPERVISOR_SUPPORTED_BACKENDS(tmux herdr). It rejects an unrecognized backend (unsupported-backend) and then a target that does not resolve to a live pane under that backend (target-not-found).bin/fm-afk-launch.shruns that check in bothstartandstart-nativebefore writingstate/.afk, so arming away mode with a broken or nonexistent supervision target now fails up front with a specific message instead of leaving the flag set while the daemon refuses afterward. Instart-nativea fallback-default backend is tolerated, mirroring the daemon.bin/fm-supervise-daemon.shreplaces its separate backend and target startup checks with a single call to the shared validator, keeping the existing startup error text and log lines. Docs updated indocs/configuration.mdanddocs/scripts.md;tests/fm-afk-launch.test.shadds native-entry cases for a nonexistent target and an unsupported backend, and the native lifecycle test now skips without tmux and runs against a real captain pane.Risk Assessment
✅ Low: The change adds a shared pre-arm validation that both /afk entry paths and the daemon now route through, exactly matching the stated intent, with no reachable path that arms away mode into an invalid backend/target; only a test-cleanup nit and a diagnostic-message reordering remain.
Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-supervisor-target-lib.sh:33- The commit message and bin/fm-supervisor-target-lib.sh:33-35 both claim validate_supervisor_target is "shared by the daemon's own startup refusal", but bin/fm-supervise-daemon.sh still runs its own inline copies of the same two rules (fm_backend_list_contains at line 1563 and fm_backend_target_exists at line 1623) and never calls the new function. Only the FM_SUPERVISOR_SUPPORTED_BACKENDS constant moved. Result: two live definitions of the same accept/reject rule that can drift (e.g. adding a third check to the lib silently would not tighten the daemon). Remedy touches daemon error messages/exit paths, so it needs author sign-off: either have fm_super_main call validate_supervisor_target, or correct the lib comment and commit message to say the daemon shares only the backend list.bin/fm-afk-launch.sh:479- The 6-line reason-to-message case block is copied verbatim into both fm_afk_launch_start (lines 479-486) and fm_afk_launch_start_native (lines 568-576), differing only in the variable names. A single helper (e.g. fm_afk_launch_log_supervisor_reason <reason> <backend> <target>) called from both would remove the duplicate and keep the two refusal messages from drifting apart. Purely mechanical, no behavior change.bin/fm-afk-launch.sh:484- validate_supervisor_target only ever prints 'unsupported-backend' or 'target-not-found', so the*)generic-message branch in each case block (bin/fm-afk-launch.sh:484 and :574) is an unreachable component the intent does not require. Recommend dropping it (or collapsing it with the dedup above) rather than keeping a third message path nothing can produce.tests/fm-afk-launch.test.sh:544- unit_native_lifecycle now skips entirely when tmux is absent (tests/fm-afk-launch.test.sh:544). That is the honest fix for the test's new need for a real pane, but it means the native happy path gets zero coverage on a tmux-less runner where it previously ran with the synthetic %0 target. Noting the coverage tradeoff; no action required if the test hosts always have tmux.🔧 Fix: share validate_supervisor_target with daemon startup refusal
2 infos still open:
tests/fm-afk-launch.test.sh:549- unit_native_lifecycle creates a real tmux session (fm-test-native-lifecycle-$$) but never appends it to TRACK_TMUX_SESSIONS, unlike every other session-creating test in this file (lines 240, 961). The kill-session at line 566 only runs on the normal path, so if the run is interrupted (Ctrl-C/SIGTERM) or aborts between line 549 and 566, the EXIT trap's GLOBAL_CLEANUP does not know about this session and it is left running on the developer's machine. Fix is mechanical: addTRACK_TMUX_SESSIONS="$TRACK_TMUX_SESSIONS $cap_session"right after creation.bin/fm-supervise-daemon.sh:1609- Moving the backend check into validate_supervisor_target also moved it from before target discovery to after the FALLBACK-target refusal. Concrete case: FM_SUPERVISOR_BACKEND=zellij with no FM_SUPERVISOR_TARGET and no $TMUX_PANE/$HERDR_ENV. Previously the daemon exited with "does not support supervisor backend 'zellij'"; now target_source=FALLBACK(firstmate:0) fires first and it exits with the "cannot verify ... hosted in tmux or herdr" message. Both still refuse and exit 1, and the new message is not incorrect, so this is a diagnostic-wording change, not a delivery bug. The existing daemon tests set TMUX_PANE=%0 so they still reach the backend message and are unaffected. Noting the tradeoff; no action needed.bin/fm-test-run.sh --changed --exclude-family real-herdr-gated🔧 **Document** - 1 issue found → auto-fixed ✅
bin/fm-afk-start.sh:152- docs/configuration.md's "refusal happens at every arm entry point" paragraph still lists bin/fm-afk-start.sh alongside fm-afk-launch.sh, but fm-afk-start.sh only checks target resolvability (discover_supervisor_target) and does not call the new validate_supervisor_target, so an unsupported backend or nonexistent target is not refused on that path. Left as-is because closing it would change executable behavior; worth a follow-up to either share the validator there or narrow the doc claim.🔧 Fix: clarify which afk entry points validate supervisor target
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.