Repository navigation
fix(fm-secondmate-restart): check capacity before stopping mate on relaunch - #78
Merged
adibirzu merged 2 commits intoSep 14, 2026
Merged
Conversation
…launch A capacity refusal in fm-spawn.sh --relaunch left a secondmate agent-free with a bare shell, because the old agent had already been stopped. Move the capacity guard into fm-control.sh do_relaunch() so it runs before anything is stopped. A refusal is now reported as refused: in fm-secondmate-restart.sh, with the agent still alive. - Source fm-capacity-lib.sh in fm-control.sh and guard relaunch before safe_checkpoint / journal writes. - Add refused_count and refused: reporting in fm-secondmate-restart.sh. - Update summary format and exit-code help. - Document the pre-stop relaunch capacity check in docs/configuration.md. - Add regression test T5b covering a capacity refusal during restart.
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.
Summary
bin/fm-secondmate-restart.shstopped a mate's agent before checking machine capacity; when the replacement launch was then refused by the 10-agent guard, the mate was left dead with a bare shell and reported as unreached. This change moves the capacity guard intobin/fm-control.sh do_relaunch()so it runs before the old agent is stopped, and reports the refusal honestly.What changed
bin/fm-control.sh: sourcesfm-capacity-lib.shand consults the machine-capacity guard immediately after resolving the relaunch profile, before any checkpoint/journal/agent-stop work. A refusal exits with a clearrelaunch of <id> refused: machine capacity declined the replacement launchmessage and leaves the running agent untouched.bin/fm-secondmate-restart.sh: recognizes a capacity refusal from the relaunch output and reports it asrefused: <id>: ...instead ofunreached. Addedrefused_count, updated the summary line, and updated the exit-code help.docs/configuration.md: noted in the "Machine capacity" section that relaunches consult capacity before stopping the existing agent.tests/fm-secondmate-restart.test.sh: updated existing summary assertions to the new format and added regression testT5bthat forces a capacity refusal and verifies the mate stays alive and the refusal is reported.Verification
Local test runs, serialized with the host's one-suite-at-a-time lock (Actions minutes are exhausted on this fork, so these are the CI evidence):
Code Review (Stage 1)
Note: the changeset size is inflated because this branch merged the latest
adibirzu/firstmatemain (including PRs #75 and #76) so theRequire no-mistakesworkflow runs the new direct-PR attestation validator. The fix itself remains the same small set of changes inbin/fm-control.sh,bin/fm-secondmate-restart.sh,tests/fm-secondmate-restart.test.sh, anddocs/configuration.md.Independent Second-Level Review
Reviewer: opencode-go/muse-spark-1.3-contributor (independent of the authoring lane opencode-go/kimi-k2.7-code)
Report: data/fm-pr78-second-level-review/report.md
Verdict: PASS (reviewed at 86a8c0a; head 0fcc125 adds only a merge of main)