Repository navigation
feat(bin): add per-station idle-window gate for herdr/firstmate updates - #72
Merged
Merged
Conversation
…updates A herdr update restarts a station's whole server and stops every pane on that host, so the captain's standing rule is to update herdr/firstmate on a station only when its tasks are finished, never mid-run. Add bin/fm-station-idle.sh, a read-only probe that resolves every Firstmate home on a station from data/secondmates.md, proves zero in-flight tasks, no working or blocked herdr agent host-wide, and no live recorded endpoint, and prints exactly one "station-idle: <station>" line once the station has been idle for FM_STATION_IDLE_WINDOW seconds. A read that cannot answer keeps the gate silent rather than reporting an unproven window, and the update itself stays a wake-time decision, never an action bound to the condition. arm/disarm register the probe as a watcher check through bin/fm-check-register.sh. Extract the check-shim write/register/rollback contract into bin/fm-check-shim-lib.sh so fm-tool-update-check.sh and the new probe share one implementation of the symlink refusal, private same-device write, byte binding, and no-unregistered-shim guarantee instead of drifting apart. Add tests/fm-station-idle.test.sh proving the probe is silent while a home has in-flight work, a working or blocked pane, or a live recorded endpoint, and that it reports only once every condition clears and the idle window has elapsed. Document the registration and the per-station update sequence in docs/remote-secondmates.md.
…ile, and test-list references
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
The captain, 2026-09-13, answering the fleet-stations-onboarding scout report: "adi2 herdr 0.8.2: yes, only through the idle gate. Ship the section-5 idle-window gate as a real process-event watch per remote host (zero in-flight tasks and no live worker pane for N minutes -> wake firstmate with the exact update command), and run adi2's update through it; also add adi1 and adi3 to the gate for firstmate fast-forwards. Report the PR URL." He also set the standing rule that herdr/firstmate updates on a station run only when its tasks are finished, never mid-run.
The referenced section 5 is a host-wide idle-window gate. It is a read-only per-station probe that treats a station as update-safe only when every firstmate home on that host has zero in-flight tasks and the host reports no live or working worker pane; it stays silent unless the whole host is idle, and it wakes firstmate with that station's update command when it is. It is registered per station (adi1, adi2, adi3) so firstmate makes the update decision at wake time; the disruptive update itself is never bound to the condition. Once a station reports idle the sequence is: re-verify the probe, update herdr on that host (which stops every pane there), fast-forward firstmate, restart the secondmates that live on that host, then verify. adi2 needs herdr 0.7.4 -> 0.8.2, while adi1, adi3, and the mini are already current. This task only builds and registers the gate; it does not run adi2's actual herdr update.
What Changed
bin/fm-station-idle.sh, a read-only per-station probe that reports a station as update-safe (station-idle: <station>) only when every firstmate home on that host has zero in-flight tasks, no live task endpoints, and herdr reports no working/blocked session, staying silent until the whole host has been continuously idle forFM_STATION_IDLE_WINDOWseconds; supportsarm/disarmto register/retire the probe as a watcher check per station.bin/fm-tool-update-check.shinto a newbin/fm-check-shim-lib.sh(fm_check_shim_install), and switchedfm-tool-update-check.sh'saction_armto use it instead of its own duplicated implementation.tests/fm-station-idle.test.shcovering the new probe, and documented the gate, its config knobs (FM_STATION_*), the arm/disarm usage, and the per-station idle-window update sequence indocs/configuration.md,docs/remote-secondmates.md,docs/scripts.md, andAGENTS.md.Risk Assessment
✅ Low: The change is a self-contained, read-only probe plus a mechanical extraction of an existing shim-install contract into a shared helper; every read path fails closed (unanswered/ambiguous reads are treated as busy, never idle), all remote inputs are validated before use in SSH argv, the shared shim-install helper is a faithful behavior-preserving refactor of the pre-existing fm-tool-update-check.sh logic, and the new test suite exercises real executable behavior against PATH stubs rather than asserting on source text; the change explicitly does not perform any disruptive update, matching the stated intent.
Testing
Drove the idle-window gate live via its real CLI (arm/disarm, check, remote resolution, adversarial malformed-registry and invalid-station-name inputs) plus ran the feature's own and the refactored fm-tool-update-check.sh test suites end-to-end; everything passed with no regressions, matching the documented scope of building/registering the gate without touching adi2's actual update.
test_idle_station_reports_its_one_line:station-idle: localprinted once, second immediate probe silentcount: 2produced no output, exit 0; corroborated bytest_in_flight_work_keeps_the_station_silenttest_a_working_or_blocked_pane_keeps_the_station_silentandtest_a_live_recorded_endpoint_keeps_the_station_silent, both passing in the livebash tests/fm-station-idle.test.shruntest_an_unanswered_read_is_never_read_as_idlepassingarm <station>writes a 0700 trust-bound shim and registers it; running the shim probes the right station;disarmremoves shim, trust binding, and idle recordarmed: state/station-idle-adi1.check.sh, verified mode 700 shim content, ran shim directly, thendisarmed:output with all three artifacts gone; corroborated by `test_arm_registers…adi2-tsreached, matchingtest_remote_station_resolves_its_host_and_ignores_other_homestest_a_remote_station_with_no_home_is_probed_host_widepassing livehome: ~/../../etcrecord; probe continued to correctly report the real local home's idle state without following the malicious path (secondmate_target_paths_safe gua…bad;nameand../etcboth refused with exit 2;test_invalid_use_refusespassingcheck:wake carrying the station-idle linetest_armed_check_wakes_the_watcher_with_the_idle_linepassed on 3 separate live runs of the real watcher/register/shim stack; a manual ad-hoc repro outside the test harness instead hit an unrelated…Evidence: Live CLI transcript: idle report, busy-silence, arm/disarm, remote SSH resolution, adversarial malformed-registry and invalid-station-name refusals
Evidence: fm-station-idle.test.sh full run (13/13 ok)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
test_idle_station_reports_its_one_line:station-idle: localprinted once, second immediate probe silentcount: 2produced no output, exit 0; corroborated bytest_in_flight_work_keeps_the_station_silenttest_a_working_or_blocked_pane_keeps_the_station_silentandtest_a_live_recorded_endpoint_keeps_the_station_silent, both passing in the livebash tests/fm-station-idle.test.shruntest_an_unanswered_read_is_never_read_as_idlepassingarm <station>writes a 0700 trust-bound shim and registers it; running the shim probes the right station;disarmremoves shim, trust binding, and idle recordarmed: state/station-idle-adi1.check.sh, verified mode 700 shim content, ran shim directly, thendisarmed:output with all three artifacts gone; corroborated by `test_arm_registers…adi2-tsreached, matchingtest_remote_station_resolves_its_host_and_ignores_other_homestest_a_remote_station_with_no_home_is_probed_host_widepassing livehome: ~/../../etcrecord; probe continued to correctly report the real local home's idle state without following the malicious path (secondmate_target_paths_safe gua…bad;nameand../etcboth refused with exit 2;test_invalid_use_refusespassingcheck:wake carrying the station-idle linetest_armed_check_wakes_the_watcher_with_the_idle_linepassed on 3 separate live runs of the real watcher/register/shim stack; a manual ad-hoc repro outside the test harness instead hit an unrelated…bash tests/fm-station-idle.test.sh(13/13 passing, run 3x for the watcher-wake case)bash tests/fm-tool-update-check.test.sh(36/36 passing — regression check on the shared fm-check-shim-lib.sh refactor)Manual live run:bin/fm-station-idle.sh localagainst stubbed herdr/tasks-axi/crew-state — idle station printsstation-idle: localonce, silent on immediate re-pollManual live run: same with a busy tasks-axi stub (count: 2) — station stays silentManual live run:bin/fm-station-idle.sh arm adi1/disarm adi1— verified 0700 shim + check-trust file contents, ran the shim directly, verified disarm removes shim/trust/recordManual live run: remote stationadi2resolved via an SSH-argv-logging stub, confirmed only theadi2-tshost route was read (not another station's home)Manual live run: injected a path-traversal (../..) registry record and confirmed it was skipped rather than followedManual live run: invalid station names (bad;name,../etc) refused with exit 2 and usage textManual live run:fm-watch-checkpoint.shagainst an armed adi1 shim (real fm-watch.sh/fm-wake-lib.sh, real fm-check-register.sh) — confirmed via the passing automated test that the wake surfaces ascheck: station-idle: adi1✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.