Repository navigation
feat(supervision): add resting vs active state for secondmate in-flight counting - #761
Closed
Freudator86 wants to merge 6 commits into
Closed
Freudator86 wants to merge 6 commits into
Freudator86 wants to merge 6 commits into
Conversation
…ht counting A persistent secondmate's own state/<id>.meta counted as in-flight for stop-hook/turnend-guard supervision exactly like a crewmate/scout, so a secondmate that is deliberately idle-but-alive still blocked turn-end whenever its supervising primary had no fresh watcher beacon. kind=secondmate meta can now carry supervision=resting to exclude it from that count while staying fully alive; supervision=active and legacy meta with no field still count as before. Liveness probing/respawn and dormant registry entries are untouched - this is purely a supervision-counting change.
… leaked CLAUDECODE env var
…ion counting in remaining docs
secondmate_liveness_sweep() in bin/fm-bootstrap.sh no longer echoes a "respawned" success line (it went silent independently of this feature, matching the sibling test_sweep_respawns_confirmed_dead_secondmate case). The resting-vs-active test still asserted the old noisy behavior; update it to expect silence on success while still verifying via the tmux call log that kill-then-respawn actually happens, unaffected by supervision=resting.
Contributor
Author
|
Closing to let no-mistakes open a fresh PR carrying the pipeline signature. This PR was originally opened by pushing directly (bypassing no-mistakes), so it never carried the required '## Pipeline' signature and the 'Require no-mistakes' check could never pass. Not merged; content is preserved on branch fm/secondmate-rest-q4 and is being resubmitted through no-mistakes. |
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.
Resubmission note
This is a clean resubmission of #391, which was already reviewed and repeatedly confirmed mergeable across several rebase rounds, then held pending human maintainer review. On 2026-07-18 the
Freudator86/firstmatefork silently lost its GitHub fork relationship with this repo, which auto-closed #391 without a merge - a fork-relationship glitch, not a review rejection. The branch content survived intact on the (now-renamed) detached repo and has been rebased cleanly onto currentmainhere. See #391 for the original review history and discussion.One small adjustment was needed during the rebase:
bin/fm-bootstrap.sh's secondmate liveness sweep went silent on a successful respawn somewhere between the original PR and currentmain(an unrelated upstream change), sotests/fm-secondmate-liveness.test.sh'stest_sweep_unaffected_by_supervision_restingcase was updated to expect silence on success (matching the pre-existing sibling test) while still verifying via the tmux call log that kill-then-respawn happens for a resting secondmate exactly as before.Intent
Add a 'resting vs active' supervision state for persistent secondmates, so a resting secondmate does not count as in-flight work for stop-hook/turnend-guard supervision, while an active one still does.
Background:
state/<id>.metarecordskind=secondmatefor persistent secondmates; previously ANY secondmate meta counted as in-flight for supervision purposes exactly like an ordinary crewmate/scout task, so a secondmate that is deliberately idle-but-alive still blocked the primary's turn-end whenever there was no fresh watcher beacon. This is purely a supervision-COUNTING change, not a lifecycle change: persistent secondmates stay alive regardless of this field.Implementation:
bin/fm-supervision-lib.sh'sfm_supervision_status(the shared predicate used by bothfm-guard.shandfm-turnend-guard.sh) now readskind=andsupervision=from eachstate/*.metafile via a newfm_sup_resting_secondmatehelper, and skips a meta file only when it is BOTHkind=secondmateANDsupervision=restingwhen computingFM_SUP_IN_FLIGHT.supervision=activeand legacy meta with nosupervision=field at all still count exactly as before - a deliberate safe default so pre-existing secondmates are never silently dropped from supervision. Ordinary crewmate/scout meta is completely unaffected.dormantis a distinct, pre-existing, unrelated concept (a registry-only entry indata/secondmates.mdwith no livestate/<id>.metaat all) and this change does not touch or conflate it.Deliberately out of scope: no command or plumbing was added to actually set/toggle
supervision=restingon a live secondmate - that lifecycle mechanism is left for a future task; this change only wires the counting predicate and documents the field.bin/fm-turnend-guard.shitself was deliberately NOT modified: the predicate change infm-supervision-lib.shalone was sufficient to fix its behavior (verified by tests), keeping the change minimal.Secondmate liveness probing and respawn behavior in
bin/fm-bootstrap.sh(theSECONDMATE_LIVENESSsweep) is unrelated to this predicate and is verified unaffected bysupervision=restingvia a dedicated test.What Changed
bin/fm-supervision-lib.sh'sfm_supervision_status(shared byfm-guard.shandfm-turnend-guard.sh) now readskind=/supervision=from eachstate/*.metavia a newfm_sup_resting_secondmatehelper, excluding a meta only when it is bothkind=secondmateandsupervision=restingfromFM_SUP_IN_FLIGHT;supervision=active, legacy meta with nosupervision=field, and ordinary crewmate/scout meta all still count exactly as before.tests/fm-turnend-guard.test.sh(resting excluded, active/legacy counts, ordinary crewmate/scout unaffected, resting-secondmate-plus-real-in-flight-work still counts, silent-vs-blocking hook behavior) and a new test intests/fm-secondmate-liveness.test.shproving the liveness/respawn sweep is unaffected bysupervision=resting.state/<id>.metasupervision=field and the resting/active exception inAGENTS.mdanddocs/turnend-guard.md.Risk Assessment
Low: a small, well-scoped change to a single shared predicate function with a safe default (absent/non-"resting" values still count as in-flight), backed by tests covering the predicate, the hook-level behavior, and non-interference with the unrelated liveness/respawn sweep; docs are updated consistently with the code.
Testing
After rebasing onto current
main:All resting/active/legacy predicate assertions and hook-level silent-vs-block assertions pass. (The suite's separate, pre-existing live-Pi-TUI regression case fails in this sandbox for an unrelated environmental reason - no live Pi tooling available - and fails identically against unmodified
main.)All 11 assertions pass, including the resting-secondmate-liveness-sweep case (updated per the resubmission note above).
All pass (these were incidentally touched by the branch's own earlier lint/portability fix commits, carried through the rebase).