Repository navigation
feat(bin): restart live secondmates during updates - #110
Merged
Merged
Conversation
* feat(update): restart second mates whose instructions changed /updatefirstmate pulled new bytes onto disk and then asked each advanced second mate to re-read them. A running agent holds AGENTS.md and every loaded skill frozen from launch and no verified harness offers a reload, so that steer could not reach a loaded skill at all and left the mate holding two contradictory copies of its own job description. An eligible mate is now restarted instead, in the same home and endpoint, through the existing transactional relaunch. The restart is gated on the mate first writing down the open work it holds only in conversation - the open-record half of /stow, never its memory sweeps - so an unregistered captain call is flushed before the conversation is spent. Anything that leaves the reload unprovable falls back to the old re-read message and is reported as exactly that, never as a clean reload. Remote mates take the same path: fm-remote-secondmate-control.sh gains a relaunch verb whose host-local leg runs that same control plane, since the mate is an ordinary local secondmate from its host's point of view. The primary resolves the profile and passes it explicitly, because config/secondmate-harness is not inherited and the file on that host belongs to a different home. fm-update.sh now splits its advanced live mates into a restart set and a nudge residual, and both sets require a changed instruction surface, which also closes the over-nudge against the session-start sweep. Restart is stricter still: a bin/-only advance reloads itself on the next call, so it never costs a conversation. Colocated tests cover the gating, the persist-then-restart order, the task-subset persist request, each unsafe fallback, the remote hop, and the remote sync's new instruction-surface report. * no-mistakes(review): Fix restart correlation, concurrent waits, and lifecycle reporting * no-mistakes(review): Parallelize relaunches and classify replacement incarnations * no-mistakes(review): Gate restart actions on live agent state * no-mistakes(review): Handle failed restart workers without hanging * no-mistakes(review): Nudge legacy remotes and preserve persist recovery * no-mistakes(review): Document one-time secondmate restart rollout * no-mistakes(review): Honor arrived replies and refresh remote profiles * no-mistakes(review): Revert remote parent profile reconciliation * no-mistakes(review): Reset remote profile defaults and honor published results * no-mistakes(review): Preserve fallback nudges for unverifiable secondmates * no-mistakes(document): Document second-mate restart update flow * no-mistakes(lint): Fix ShellCheck warnings in restart scripts
* feat(update): restart every live second mate after a successful update /updatefirstmate only restarted a second mate when that pass advanced its AGENTS.md or .agents/skills. An already-current home was skipped entirely, a bin/-only advance was steered instead, and a remote host that could not report its instruction diff was downgraded to a re-read. A running agent also freezes its launch-time wiring - turn-end hooks, harness flags, per-harness feature switches - and none of that is derivable from a file diff, so an unchanged tracked surface is not evidence the agent is already on the current behavior. Restart is now unconditional on a successful update of that home. Every live second mate the pass leaves on the target commit is restarted, whether it advanced or was already there. The safety contract is unchanged: open records are persisted before the agent is replaced, nothing is forced, stashed, or discarded, a home the pass had to skip is not restarted at all, and a mate whose runtime cannot prove a restart keeps the honest re-read path and is never reported as reloaded. bin/fm-ff-lib.sh gains a settled-state hook that fires for a home left at the base whether it advanced or was already there, and never for a skipped one; the instruction-gated hook the session-start convergence sweep uses is untouched. Regressions: fm-update pins the already-current mate into the restart set and the unprovable one into the nudge set, and fm-secondmate-restart drives both real commands end to end - an already-current home is named, persisted, and genuinely replaced with its checkout untouched, while the unprovable one keeps its running agent. * no-mistakes(document): Document unconditional secondmate restarts
The OMP second mate restart had no behavioral regression: the pass was proven only as far as capability. This adds the end-to-end test, plus the seam and the artifact cleanup that test proved missing. bin/fm-omp-secondmate-restart-lib.sh now owns the local OMP restart: stop the home's session owner, prove it gone, retire the four session artifacts bin/fm-spawn.sh refuses to launch over, launch the replacement through bin/fm-spawn.sh <id> --secondmate, then reconcile the durable record to the endpoint that launch published. The stop and the launch are overridable through FM_RESTART_STOP_CMD and FM_RESTART_SPAWN_CMD, which default to kill and bin/fm-spawn.sh, so production behavior is unchanged when neither is set. bin/fm-secondmate-restart.sh routes a local harness=omp mate there; every other harness and the remote hop are untouched. Without the artifact retirement an OMP restart could not complete at all: .omp-ext.ts and .omp-ready survive the agent, and the launch owner refuses a second mate launch while either is on disk. tests/fm-secondmate-restart.test.sh T17 drives the whole real pass - capability resolution, fm-send over the real OMP doorbell against a live modelled session, the parent-owned persist gate, and the restart orchestration - with only the stop and the launch replaced. Both stubs record the world at the moment they ran, so the order is asserted rather than assumed: the absence probe sees all four artifacts still present, and the launch sees none. Claude-Session: https://claude.ai/code/session_01Aq7cTZDgRxGYYAzPnaAwEh
…t end to end The branch was missing the end-to-end OMP restart regression, and the implementation it was supposed to cover was missing too: an earlier validation run of this branch was cancelled after a fix was hand-committed while it was active, which orphaned eight no-mistakes(review) fix commits in the local gate. Those commits are the real implementation. They are recovered here in full - their content is in the tree, squashed into this commit rather than replayed as eight commit objects because the branch had already been pushed past them. Nothing from them was dropped. On top of that recovered implementation: - fm_control_omp_secondmate_prepare_relaunch also proves the OMP home's session-lock owner gone before it retires anything. bin/fm-spawn.sh refuses a second mate launch while that pid is alive, and an artifact removed under a live owner is indistinguishable from a fresh one, so the next launch would accept a duplicate against a still-running mate. The endpoint proof stays first; both proofs precede the removal. - FM_RESTART_STOP_CMD (default kill, invoked as "<cmd> <pid>" to stop and "<cmd> -0 <pid>" to probe) and FM_RESTART_SPAWN_CMD (default bin/fm-spawn.sh) make the two real side effects overridable. Unset, both are the real thing and behavior is unchanged. - fm-control's agent_state passes the task's durable record to fm_backend_agent_state. Without it an OMP or Hermes endpoint cannot be attributed from its own process identity and reads ambiguous, which refused every lifecycle verb on a healthy OMP second mate - the relaunch could not take its first state reading. tests/fm-secondmate-restart.test.sh T17 drives the whole real chain: capability routing, fm-send over the real OMP doorbell against a live modelled session, the parent-owned persist gate, and fm-control's relaunch transaction with its OMP preparation step. Only the stop and the launch are stubbed, and both stubs record the world at the moment they ran, so the order is asserted rather than assumed: the absence probe sees all four session artifacts still present, the launch sees none. Claude-Session: https://claude.ai/code/session_01Aq7cTZDgRxGYYAzPnaAwEh
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
Port upstream kunchenguid#3614 and kunchenguid#3690 so /updatefirstmate restarts live second mates onto the current instruction surface, and finish it with the end-to-end OMP restart regression it was missing.
A running agent holds AGENTS.md and its loaded skills frozen from launch and no verified harness offers a reload, so a re-read steer cannot replace either; replacing the agent is the only thing that guarantees the new bytes are read and re-resolves launch-time wiring. kunchenguid#3690 widened that to every live mate on the target commit because launch-time wiring is not in a git diff.
Deliberate, not mistakes: the persist request is a GATE released only by that mate's own correlated answer, never a clock, and a timeout deliberately leaves the expectation OPEN for the pending-reply ladder; it asks only for /stow's open-record subset, never the memory/learnings/captain sweeps; an unanswered or unprovable mate gets the re-read nudge and is reported as a nudge, and a failed relaunch as unknown; a remote mate runs the SAME host-local control-plane relaunch over fm-on with the PARENT's pin; OMP mates MUST be restartable (nudge-only was rejected); a fresh endpoint on restart is accepted, and the new endpoint metadata is revalidated rather than waiting on the retired target.
History note: an earlier run of this branch was cancelled after a fix was hand-committed while it was active, orphaning eight no-mistakes(review) fix commits. Those are the real implementation; their content is recovered here in full, squashed rather than replayed because the branch was already pushed past them. Nothing was dropped. A parallel reimplementation written before that recovery was deleted in favour of them.
Added on top: (1) FM_RESTART_STOP_CMD (default kill; " " to stop, " -0 " to probe) and FM_RESTART_SPAWN_CMD (default bin/fm-spawn.sh) make the two real side effects overridable, identical to production when unset. This exact seam shape was specified by the author after other test structures failed; do not propose a different one. (2) fm_control_omp_secondmate_prepare_relaunch also proves the home's session-lock owner gone before retiring anything, because bin/fm-spawn.sh refuses a launch while that pid lives and an artifact removed under a live owner is indistinguishable from a fresh one. (3) fm-control's agent_state passes the durable record to fm_backend_agent_state; without it an OMP endpoint reads ambiguous and every lifecycle verb refused on a healthy mate. (4) tests/fm-secondmate-restart.test.sh T17 drives the whole real chain - capability routing, real fm-send over the real OMP doorbell against a live modelled session, the persist gate, and fm-control's relaunch transaction - stubbing only the stop and the launch; both stubs record the world as they ran, so the absence probe must see all four artifacts present and the launch none, then it asserts " --secondmate --harness omp" and the new endpoint with the retired one gone. (5) docs/agent-control.md documents that preparation step.
Two findings raised by the cancelled run were never fixed and should resurface: bin/fm-remote-secondmate-control.sh's state probe drops endpoint metadata (same defect as (3), remotely), and cmd_relaunch accepts
cursorwhile cmd_launch rejects it. Both are genuine; fix them.Firstmate-Validation-Generation: f528daba6dd64db1d79197ee63edbfe3
What Changed
/updatefirstmateand spawn/remote routing to restart settled live secondmates on the target commit, with re-read nudges for unprovable endpoints.Risk Assessment
🚨 High: Two explicit remote lifecycle requirements remain violated, including a relaunch path that can stop a mate before replacement launch fails.
Testing
The end-to-end OMP restart regression and update/liveness paths passed with observable stop/absence/marker-cleanup/spawn/new-metadata assertions; remote update and remote fail-closed checks passed. The full remote lifecycle script timed out during a later marked-send integration stage, leaving that portion unverified.
Evidence: Targeted restart/update evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-remote-secondmate-control.sh:254- The remote state probe drops durable metadata when callingfm_backend_agent_state(bin/fm-remote-secondmate-control.sh:254; line 326 does the same). The intent explicitly requires fixing this remote counterpart. Without metadata, OMP identity validation can be bypassed and endpoint state misclassified.bin/fm-remote-secondmate-control.sh:389-cmd_relaunchacceptscursorat line 389, but remotecmd_launchrejects it at line 313 andfm-spawn.shhas no verified secondmate launch template for it. A cursor relaunch can stop the old mate, then fail during replacement launch. The intent explicitly identifies this mismatch as genuine and requires fixing it.bin/fm-remote-secondmate-control.sh:254- The remote state probe calls fm_backend_agent_state without the durable metadata argument. OMP endpoint identity validation therefore receives no launch metadata and can classify a healthy remote OMP mate as ambiguous/unreadable, preventing correct lifecycle handling. Pass "$REMOTE_ENDPOINT_META" as the third argument.bin/fm-remote-secondmate-control.sh:389- cmd_relaunch accepts the cursor harness, but cmd_launch rejects cursor. A remote cursor relaunch can stop the existing mate and then fail replacement launch due to inconsistent harness validation. Align the accepted harness set or explicitly reject cursor in relaunch before stopping anything.timeout 180 bash tests/fm-secondmate-restart.test.shbash tests/fm-update.test.shbash tests/fm-remote-secondmate-lifecycle-e2e.test.shInspected executable remote lifecycle behavior and harness validation inbin/fm-remote-secondmate-control.sh.🔧 Fix: Fixed remote metadata propagation and cursor relaunch validation
1 warning still open:
tests/fm-remote-secondmate-lifecycle-e2e.test.sh- The remote lifecycle E2E suite progressed through remote state/liveness and fail-closed checks but exceeded the 180-second timeout during the later marked-send/routed-reply phase, so complete remote relaunch-path evidence is unavailable in this environment.bash tests/fm-secondmate-restart.test.shbash tests/fm-update.test.shtimeout 90s bash tests/fm-secondmate-liveness.test.shtimeout 180s bash tests/fm-remote-secondmate-lifecycle-e2e.test.shbash -n bin/fm-remote-secondmate-control.sh bin/fm-secondmate-restart.sh bin/fm-control.sh bin/fm-update.sh tests/fm-secondmate-restart.test.sh tests/fm-update.test.shgit status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.