Skip to content

feat: support per-mate secondmate runtime pins - #6917

Merged
kunchenguid merged 7 commits into
kunchenguid:mainfrom
kesslerio:fm/secondmate-harness-per-mate-pin
Oct 21, 2026
Merged

kunchenguid merged 7 commits into
kunchenguid:mainfrom
kesslerio:fm/secondmate-harness-per-mate-pin

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6860

TL;DR

Add per-mate harness, model, and effort overrides to the secondmate pin file, using the shared pin as the fallback.
Spawn, relaunch, and restart resolve the named mate's profile through the same owner.

This revision makes the override grammar opt-in and adds the missing live restart proof.

  • Head: b27a2fbf1fff8ad8a09e530955f853dc46d11469 (rebased on 9d76aa8e; the two commits above it are the pipeline's own document and CI-repair commits).
  • The strict whole-file parse now applies only to a config/secondmate-harness that declares at least one mate <secondmate-id>: line. A file with no mate line parses exactly as main does.
  • The control-plane relaunch reads the configured pin only behind the explicit-harness guard, so an explicit --harness/--model/--effort relaunch succeeds whatever the pin file holds.
  • The persist-and-restart scenario was driven live, against real sessions, and is reported below.

What Problem This Solves

A secondmate pinned manually could return to the shared model or effort after automatic recovery or restart.
Maintaining the exception required another manual check each time.

Why This Change Was Made

Explicit mate declarations keep runtime choices durable.
Malformed declared files must refuse before stopping or migrating a mate; homes without override declarations must retain legacy first-line parsing.

That last clause is what this revision fixes.
The first cut of this branch applied the strict whole-file parse to every pin file, so a second default line or a fourth token made every secondmate spawn, relaunch, and restart refuse - even in a home that never wrote a mate line.
config/secondmate-harness is documented as "the first non-empty, non-comment line is parsed", so that changed how an existing, already-valid file is read, and the feature was not opt-in.
The strict parse is now scoped to files that declare a mate line; a file that declares none keeps the legacy rule, and nothing in it is refused.

User Impact

An operator can pin one mate without changing other mates' defaults.
Explicit per-launch flags still take precedence.
A home that never wrote a mate line sees no behavior change at all.

Risk and Rollout

This changes lifecycle profile selection.
The compatibility follow-up and the live persistence/restart proof are both in this head.
Two live gaps remain open and are named under Evidence: the remote placement of the restart path, and a mate that actually held conversation-only open records at persist time.
No deployment or private runtime configuration is part of this PR.

Evidence

Opt-in scope, measured against the unchanged base

A byte-comparison harness ran the new resolver and the unchanged upstream resolver (origin/main, 9d76aa8e) over the same corpus of pin files, comparing stdout, stderr, and exit code:

Corpus Count Result on this head Result on the previous head (5782a2de)
legacy byte comparisons (files with no mate line) 1467 1467 identical, 0 differing 414 identical, 1053 differing
declared-file refusal checks (a file that declares a mate line and is malformed) 33 33 refused with a line number 27 refused, 6 accepted
allowed-output checks (a well-formed declaring file) 6 6 correct 6 correct

The legacy corpus covers one to four tokens on the default line, a second and third default line, comments, blank lines, leading and trailing whitespace, a missing trailing newline, CRLF, an empty file, a comment-only file, a default harness token, and mate-prefixed lines that are not valid overrides, read with and without a mate id and through all three resolver verbs.
The previous head broke 1053 of those comparisons; this head breaks none.

Live restart evidence

The scenario the maintainer asked for was driven live, in a disposable lab home built by bin/fm-live-lab.sh up --harness claude --mate, with real Claude Code sessions, a private tmux server, and a real registered second mate.

The mate's own persist answer on the parent channel:

done [at=1792531429]: corr=d8592c0d283d25e7 persistence complete; no open records or unregistered captain calls held in conversation, nothing filed or corrected; safe to restart

The restart output:

restarted: labe30c62010160-mate (claude)
summary: 1 of 1 restarted, 0 nudged, 0 unreached

The control-plane relaunch journal, with the pin file holding a default line and the mate's own line:

from_harness=claude
from_model=sonnet
from_effort=low
to_harness=claude
to_model=sonnet
to_effort=medium

to_effort=medium is the mate's own line, not the default line's low: the restart re-resolved the parent's per-mate profile.
A second live run, with a pin file that declares no mate line at all (a fourth token on the first line and a second default line), restarted the mate onto the first line's three tokens without refusing.

Two live gaps remain, and neither is papered over:

  • the remote placement of the same path (bin/fm-remote-secondmate-relaunch.sh over the transport hop) was not driven live; the lab mate is local, so that branch rests on tests/fm-secondmate-restart.test.sh only;
  • the live mate held no conversation-only open records at persist time, and said so on the parent channel. The gate, the answer, and the restart were exercised; filing a record out of conversation was not.

Reproducing the live run:

bin/fm-live-lab.sh up --harness claude --mate --supervision-host none \
  --expect-host no --source <checkout> --ref HEAD <lab-root>
# write the per-mate line into <lab-root>~/secondmate-harness
FM_HOME=<lab-root>/home TMUX_TMPDIR=<the lab's private tmux dir> \
  bin/fm-secondmate-restart.sh <mate-id>
bin/fm-live-lab.sh down <lab-root>

TMUX_TMPDIR must name the lab's private tmux directory; without it the control plane addresses the host's default tmux server, where the lab's window does not exist, and the relaunch fails closed with "tmux absence cannot be proven from a task record".

Focused suites and lint

FM_TEST_BASE_PATH=/run/current-system/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin \
  bash bin/fm-test-run.sh tests/fm-secondmate-harness.test.sh

The three focused suites (fm-secondmate-harness, fm-control-relaunch, fm-secondmate-restart) each stop at a pre-existing fixture failure on this host, and each stops at the same failure on the unchanged base at 9d76aa8e:

Suite Failure Reproduces on the unchanged base
fm-secondmate-harness.test.sh backend present push should succeed: expected exit 0, got 1 yes
fm-control-relaunch.test.sh relaunch did not reach trace delivery yes
fm-secondmate-restart.test.sh an answer already on disk at the timeout decision must release the gate yes

These fixtures reach /bin/sleep and /bin/mv, which do not exist on this NixOS host, so each suite fails fast before reaching the pin cases. No full-suite pass is claimed.

The new and changed cases were therefore run focused, in each suite's own harness:

ok - D1 fm-harness.sh honors a mate override line for its id and changes nothing else
ok - D2 malformed config/secondmate-harness refuses with its line number on every read verb
ok - D3 a config/secondmate-harness that declares no mate line is never refused
ok - C10 spawn: a legacy secondmate-harness file still launches on its first line (opt-in scope)
ok - C11 spawn: a declared pin file that is malformed refuses the spawn with its line number
ok - fm-control relaunch: a legacy secondmate pin file still relaunches the mate onto its first line
ok - fm-control relaunch: explicit secondmate harness resets unnamed profile axes
ok - fm-control relaunch: a mate with a per-mate override line lands on that override, not the default pin
ok - fm-control relaunch: a mate with no override line still resolves the default pin
ok - fm-control relaunch: an unparseable secondmate pin refuses before anything is stopped
ok - T6a a remote mate with a per-mate override restarts onto that override, not the default pin
ok - T6b a remote mate with no override line still restarts onto the default pin
ok - T6c an unreadable per-mate pin falls back to the re-read path with its agent left running
ok - T6d a legacy pin file still restarts the mate onto its first line

Lint: bin/fm-lint.sh (ShellCheck 0.11.0, pinned actionlint 1.7.12, full extended analysis, changed-file mode) passed on this head, and the whole-file default lint path passed with actionlint on PATH.

CI

The branch's CI run on this head is green: all nineteen checks pass, including the nine portable serial shards, both portable parallel shards, the Herdr behavior job, both lint jobs, the repository invariants, the test coverage guard, the macOS Bash 3.2 compatibility snapshot, the timing aggregate, and the require-no-mistakes check that binds the attestation to this exact head.

Two checks failed on the first CI run of this head and are recorded here rather than smoothed over:

  • Behavior tests (Herdr) failed with herdr presentation recovery could not acquire its session lock; refusing a concurrent resume - a refusal inside a deliberately concurrent recovery wave, in code this diff does not touch. The pipeline's own CI repair round committed a teardown-permission fix for that job's fixture cleanup, and the job passes on the revalidated head.
  • Behavior portable serial 2 was cancelled by the provider at the workflow's 30-minute job ceiling rather than by an assertion. The same shard had already failed on the previous run of this branch at 5782a2de, and it passes on the revalidated head.

origin/main advanced by four commits after this branch's rebase (bb57c8fd, 5db719de, 97316301, 4ae3aaf0). The pull request reports MERGEABLE and CLEAN against that base, so it needs no conflict resolution, and the pipeline's own rebase step owns folding those commits in.

The no-mistakes Test step's own live-validation verdict is inconclusive (2 of 4 scenarios driven live in the pipeline's own budget), and that exception is recorded in the attestation with its reason. The pipeline's own live attempt was blocked by a different environment limit - the real model-generated tool call was denied by the persistent-cd hook before execution, and the next provider request was refused before send by the conservative aggregate-input reservation cap - so the pipeline made no new provider request for the two persist-and-replace scenarios. The live proof for those two scenarios is the one recorded above, produced with the product's own lab helper and the real bin/fm-secondmate-restart.sh.

Review finding

The no-mistakes Review step flagged that a secondmate relaunch with a complete explicit --harness/--model/--effort failed when the pin file held duplicate overrides, because the configuration was read unconditionally and the failure aborted before explicit precedence was applied.
The configuration read now sits behind the HARNESS_SET=0 guard, matching spawn's explicit-harness behavior, so the harness, model, and effort reads are all skipped when an explicit harness is supplied.
tests/fm-control-relaunch.test.sh now asserts that such a relaunch succeeds with a duplicate-override pin file, with a legacy pin file, and with a pin file that has no usable line at all.

Risk Assessment

✅ Low: The changes are bounded and preserve the required parsing and runtime-selection behavior, with no substantiated introduced defects.

Testing

Reconciled the prior live runs without repeating exhausted provider calls. R3 demonstrated several independent behaviors, but R4's pinned persistence command was blocked before execution and the next request exceeded the conservative input reservation bound; the default transaction was not attempted. Owned lab resources were reported cleaned up. Full acceptance remains unproven.

  • Live validation: ⚠️ inconclusive - 2 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Spawn a pinned mate and explicitly relaunch it onto the selected profile ✅ pass live R3 report: public pinned spawn reached READY; public explicit relaunch replaced the real Pi process and reported the pinned profile.
Keep the running mate when pins are malformed or persistence has no valid correlated reply ✅ pass live R3 report: malformed pins and wrong/stale reports did not release the request; the unanswered request left the real mate and metadata unchanged.
Persist records through a real correlated reply, then replace a pinned mate using its parent's profile ⏸️ untested no The prior payload records a partial R3 persistence substep, but the replacement did not complete; R4's command was denied before execution and its next request was blocked by the input cap. Therefore…
Persist records through a real correlated reply, then replace an unpinned mate using its parent's default profile ⏸️ untested no The prior payload records that no default-profile provider request or restart was made. The pinned attempt consumed the available request budget, and the next request was blocked before send by the co…
  • Outcome: ⚠️ 2 warnings across 3 runs (2m19s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ The required full persistence-and-replacement transactions are not demonstrated. R4's pinned attempt failed when the real model's generated tool call was denied before execution; the next request was blocked by the aggregate-input reservation cap. The unpinned transaction was not attempted. Do not publish based on partial evidence.
  • 🚨 live validation verdict: no-go (4 of 7 scenarios were driven live against the product); failed: Persist open records through a correlated real reply, then replace a pinned mate using its parent's profile
  • Live validation: ❌ no-go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Read a legacy harness file using its first meaningful line and ignore later tokens and lines ⏸️ untested no The prior payload marked this pass as not live; its reference is to previous focused parsing controls and does not establish a live product result.
Resolve a mate's declared profile while mates without declarations use the default ⏸️ untested no The prior payload marked this pass as not live; its reference is to previous resolver controls and does not establish a live product result.
Reject malformed or duplicate declared pins with line-specific errors, without refusing legacy files ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (live malformed-pin refusal and prior parsing controls)
Spawn a pinned mate and explicitly relaunch it with the selected profile ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (pinned spawn and explicit relaunch)
Persist open records through a correlated real reply, then replace a pinned mate using its parent's profile ❌ fail live /tmp/pr6917-r4-yigk9jps/evidence/report.md (pinned transaction)
Persist open records through a correlated real reply, then replace an unpinned mate using its parent's default profile ⏸️ untested no The pre-send reservation cap stopped the pinned attempt before any default public spawn, restart, or provider request. The authorized request budget is exhausted; further testing requires a new parent…
Preserve a running mate when pins are malformed or persistence is unanswered, wrong, or stale ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (live denied-path controls)
  • Reviewed /tmp/pr6917-r4-yigk9jps/evidence/report.md and its recorded results, budget, process, cleanup, and authentication receipts.
  • Reviewed /tmp/pr6917-live-xxw0xe3m/evidence/report.md for prior live results and limitations.
  • Did not run additional product requests, tests, or validation.

🔧 No changes applied.
2 warnings still open:

  • ⚠️ Full real persistence-and-replacement acceptance remains unproven for both pinned and default profiles. The R4 pinned attempt failed when the real model's generated tool call was denied before execution; the next request was blocked by the conservative pre-send input cap. No default transaction was attempted. Do not publish based on partial evidence.
  • ⚠️ live validation verdict: inconclusive (4 of 6 scenarios were driven live against the product); untested: Persist open records through a correlated real reply, then replace a pinned mate using its parent's profile, Persist open records through a correlated real reply, then replace an unpinned mate using its parent's default profile
  • Live validation: ⚠️ inconclusive - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Read legacy configuration using its first meaningful line and ignore later lines and extra tokens ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (prior head-bound resolver and focused-test evidence)
Resolve a mate's declared profile while mates without declarations retain the default ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (prior head-bound resolver evidence)
Refuse malformed declared configuration and preserve a running mate when persistence is unanswered or a reply is wrong or stale ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (prior real-mate negative controls)
Spawn and explicitly relaunch a pinned mate into a real replacement using the selected profile ✅ pass live /tmp/pr6917-live-xxw0xe3m/evidence/report.md (prior explicit relaunch and replacement READY evidence)
Persist open records through a correlated real reply, then replace a pinned mate using its parent's profile ⏸️ untested no The prior payload does not establish a live result for the complete scenario: the actual model-generated tool call was denied by the persistent-cd hook before execution, so no record or accepted reply…
Persist open records through a correlated real reply, then replace an unpinned mate using its parent's default profile ⏸️ untested no R4 stopped after the pre-send aggregate-input cap refusal and made no default-profile provider requests. The approved request budget was insufficient for the next conservative reservation; no further…
  • /tmp/pr6917-live-xxw0xe3m/evidence/report.md: reviewed prior head-bound live results, including legacy parsing, resolver selection, malformed-pin refusal, pinned spawn, explicit relaunch, and denied-path controls.

  • /tmp/pr6917-r4-yigk9jps/evidence/report.md and final-results.json: reviewed the R4 public spawn/restart attempt, actual tool denial, pre-send budget refusal, cleanup, and remaining untested default transaction.

  • ⚠️ Full persistence-and-replacement acceptance remains unproven. In the pinned attempt, the real model's generated persistence command was denied before execution; the next request was blocked by the conservative pre-send input cap. No default-profile transaction was attempted. Do not publish based on partial evidence.

  • ⚠️ live validation verdict: inconclusive (2 of 4 scenarios were driven live against the product); untested: Persist records through a real correlated reply, then replace a pinned mate using its parent's profile, Persist records through a real correlated reply, then replace an unpinned mate using its parent's default profile

  • Live validation: ⚠️ inconclusive - 2 of 4 scenarios driven live against the product

Scenario Result Live Evidence
Spawn a pinned mate and explicitly relaunch it onto the selected profile ✅ pass live R3 report: public pinned spawn reached READY; public explicit relaunch replaced the real Pi process and reported the pinned profile.
Keep the running mate when pins are malformed or persistence has no valid correlated reply ✅ pass live R3 report: malformed pins and wrong/stale reports did not release the request; the unanswered request left the real mate and metadata unchanged.
Persist records through a real correlated reply, then replace a pinned mate using its parent's profile ⏸️ untested no The prior payload records a partial R3 persistence substep, but the replacement did not complete; R4's command was denied before execution and its next request was blocked by the input cap. Therefore…
Persist records through a real correlated reply, then replace an unpinned mate using its parent's default profile ⏸️ untested no The prior payload records that no default-profile provider request or restart was made. The pinned attempt consumed the available request budget, and the next request was blocked before send by the co…
  • bin/fm-spawn.sh lab6917r4-pin --secondmate and bin/fm-secondmate-restart.sh lab6917r4-pin were driven against the real Pi process in the disposable lab; the persistence command was denied before execution and restart exited 3.
  • R3 evidence: public explicit relaunch replaced the real Pi process and reported the pinned profile.
  • R3 evidence: malformed pins and unanswered, wrong, or stale correlation reports did not replace the running mate.
  • R3 evidence: a real correlated persistence reply was accepted and records were written, but the subsequent replacement could not complete because the fixture lacked a shell-preserving tmux endpoint.
  • Reviewed the bounded R3 and R4 reports and final-results receipt; no additional live calls or source changes were made.
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate (OSS triage, not the captain).

Thanks @kesslerio. Head 5782a2de against main 19fcbbde.

Contract-class: opt-in. Extends config/secondmate-harness with optional mate <id>: override lines. Without overrides, the default line resolves exactly as before. Malformed overrides refuse rather than silently falling back. No unconfigured home gains a new runtime without an explicit mate line.

VISION.md

  • One captain, one interface: aligns.
  • Authority explicit: aligns (mate pins are captain-authored config).
  • Scripts own mechanics: aligns (fm-harness.sh resolver).
  • Restart is a non-event: aligns (pins survive relaunch).
  • Delegation with a spine: aligns.
  • Fleet outlives any vendor: aligns (harness/model/effort tokens only).
  • Scope: aligns.

CI: attestation MATCH; no-mistakes green; Behavior portable serial 2 cancelled at 30m. Outcome: waiting-ci. Auto-merge candidate as opt-in once fully green and CLEAN. No captain decision. Security: none.

@kesslerio

Copy link
Copy Markdown
Contributor Author

The required check Behavior portable serial 2 on head 5782a2de was cancelled by the provider without a verdict (run 37866816653), and no rerun is outstanding. My token on this repository is pull-only, so I cannot rerun it myself. Could you rerun that one check? If it cancels again without reporting, I will treat the serial as missing-verdict rather than passing it.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Closing per the contribution-process correction: this was opened without a green-lit ready-for-pr issue, which the repository now requires before any new PR. The per-mate pin feature is not being pursued right now; if it returns, it will come through the issue-first path.

@kesslerio kesslerio closed this Oct 9, 2026
@kesslerio kesslerio reopened this Oct 9, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

Reopening. I closed this to follow the issue-first path, but your triage above already reviewed it as opt-in and in line with VISION.md. The only open item was Behavior portable serial 2, which the provider cancelled without a verdict (run 37866816653). The head is still 5782a2de and merges cleanly into main. Could you rerun that check? If you'd still rather it go through an issue first, say so and I'll file one and close this again.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for reopening, @kesslerio. On the process question: CONTRIBUTING only requires that the PR be raised through no-mistakes. There's no issue-first rule I can hold this to, so I'm reviewing it as it stands. You don't need to file an issue.

I re-read head 5782a2de against main 19fcbbde. The attestation matches, "PR must be raised via no-mistakes" is green, and the PR merges cleanly.

CI: the reopen run 37896148317 had two red jobs, neither from this diff:

  • Behavior portable serial 4 failed in the afk family ("the restored record did not recover its away window"), which this PR doesn't touch.
  • Behavior portable serial 2 hit the 30-minute limit, the same timeout main sees.

I've re-run the failed jobs (run 37896148317, attempt 2).

Waiting on you, the author (two asks):

  1. Live check of the restart path. Your live validation is marked inconclusive: 5 of 6 scenarios were driven live, and "persist a mate's open records and restart it using the parent's per-mate profile" was blocked by the gate guard. bin/fm-secondmate-restart.sh is one of the files this changes. Could you drive that restart live in a lab and post the evidence here, or re-raise through no-mistakes so the pipeline can complete it? No rush, and thank you.
  2. Keep homes without overrides byte-identical. On main, config/secondmate-harness is documented as "the first non-empty, non-comment line is parsed", so anything after it, or a fourth token, is ignored. With this tip, a second default line or more than three tokens makes every secondmate spawn, relaunch, and restart refuse, even in a home that never wrote a mate line. That changes how an existing, already-valid file is read, so the PR isn't purely opt-in. A small fix would make it opt-in: apply the strict whole-file validation only when the file contains at least one mate <id>: line, and otherwise keep first-line-wins exactly as main does. If you'd rather keep the strict parse everywhere, say so, and it goes to Kun as a merge-or-leave call instead of auto-merging.

Contract-class: new-default as it stands (I'm revising my earlier opt-in read). The per-mate override itself is opt-in. Refusing a file that main documents as valid is the default-path change. With the scoping in ask 2, it becomes opt-in.

VISION.md, rule by rule

  • One captain, one interface: aligns. No captain-facing surface.
  • Authority is explicit and never inferred: aligns. Pins are captain-authored config, and malformed overrides refuse rather than fall back.
  • Scripts own the mechanics, agents own the judgment: aligns. The parse lives in fm-harness.sh.
  • A restart is a non-event: cannot tell yet. The restart path isn't live-verified (ask 1).
  • Delegation with a spine: aligns. Spawn, relaunch, and restart all resolve the same per-mate decision.
  • The fleet outlives any vendor: aligns. Only harness, model, and effort tokens, with no vendor coupling. Model choice stays captain-owned and inspectable.
  • Scope: aligns. Command-layer config only. One small nit: two fixture rows in tests/fm-secondmate-harness.test.sh use android and john-remote/x, which look like one home's real names. Neutral ids like the rest of the suite (alpha, default-model) would keep the shared surface captain-agnostic.

Next step: waiting on you for the live restart evidence and a reply on the parse scoping. CI is re-running. Nothing is waiting on Kun right now.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Taking the two asks separately. On live restart evidence, I need a host with a running mate to restart, so that lands after my next supervised restart rather than blocking the branch. On the nit: agreed, android and john-remote/x in the fixture rows read as a real home's naming and I have changed both rows to the neutral alpha / model-a style the rest of the suite uses.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Correction to my last paragraph: the fixture rename is prepared on my side but not pushed yet - this branch is in my no-push window right now, so the alpha / model-a rows will land together with the live restart evidence in one push when that window opens. Nothing else changes in what I described.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio, that plan works. Bundling the live restart evidence and the alpha / model-a fixture rename into one push when your window opens is fine, and there's no rush.

One thing I didn't see a reply to yet: ask 2 (keep homes without overrides byte-identical). On head 5782a2de, a config/secondmate-harness with a second default line or a fourth token, which main documents as valid ("first non-empty, non-comment line is parsed"), makes every secondmate spawn, relaunch, and restart refuse, even in a home with no mate line. If you scope the strict whole-file parse to files that contain at least one mate <id>: line, this becomes opt-in and can auto-merge once green. If you'd rather keep strict parsing everywhere, just say so and it goes to Kun as a merge-or-leave call instead.

Status: waiting on you, the author (live restart evidence + an answer on ask 2, landing in your next push). Head is unchanged, so my verdict stands: new-default as it stands. VISION rules align except "a restart is a non-event", which stays cannot-tell until the live restart evidence lands. CI: serial 2 is red at the 30-minute limit. Your next push re-runs everything, so I'm not re-running it now.

…mate-harness

A single default pin line gives every secondmate one runtime, so raising the
default pin silently migrates a mate the captain ruled onto its own runtime.
config/secondmate-harness now accepts optional
"mate <secondmate-id>: <harness> [<model>] [<effort>]" override lines, and
fm-harness.sh secondmate, secondmate-model, and secondmate-effort take the
secondmate id as an optional second argument that selects that line.

Spawn, the control-plane relaunch, and the secondmate restart each pass the
mate id they already know, so all three resolve one decision. A malformed pin
file is refused with its line number and prints no token instead of resolving
around it to the default runtime.
config/secondmate-harness is documented as "the first non-empty, non-comment
line is parsed". The per-mate override grammar made the whole file strict, so
a second default line or a fourth token started refusing every secondmate
spawn, relaunch, and restart - even in a home that never wrote a mate line.
That changed how an existing, already-valid file is read, so the feature was
not opt-in.

Scope the strict whole-file parse to files that declare at least one
"mate <secondmate-id>:" line. A file with no mate line parses exactly as
before: first non-empty, non-comment line, the rest ignored, a fourth token
ignored, nothing refused. A file that does declare a mate line keeps the
strict parsing, so a duplicate override, a malformed entry, or an extra token
still refuses loudly with its line number.

Coverage: a legacy file with a second default line and a fourth token now
spawns, relaunches, and restarts a mate onto its first line; a declaring file
that is malformed refuses each of those paths with the offending line; and an
explicit --harness/--model/--effort relaunch succeeds whatever the pin file
holds, because the config read stays behind the explicit-harness guard.
@kesslerio
kesslerio force-pushed the fm/secondmate-harness-per-mate-pin branch from 5782a2d to 69bc118 Compare October 20, 2026 21:36
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thanks @kesslerio, this answers ask 2. I re-read the tip c4632e5c against main:

  • A config/secondmate-harness with no mate <id>: line now goes through the legacy first-line parse. Your 1467-file byte comparison against 9d76aa8e shows no differences. A home that never writes a mate line keeps main's behavior, so I now class this as opt-in.
  • One small thing I noticed. Relaunch and restart used to swallow an fm-harness.sh secondmate* failure with 2>/dev/null || true and fall back. Now they refuse, naming config/secondmate-harness. On a home with no mate line, that only fires when the pin names no known harness, which fm-harness.sh already documents as "refuses (exit 2) instead of resolving", and spawn already refuses there. So I read this as bringing relaunch and restart in line with that documented refusal, not as a new default. If I've misread a path, please say so.
  • Live: persist-and-restart was driven live. The two named gaps (remote placement of restart, and a mate holding conversation-only records) are fine as stated gaps.

Status: waiting on CI, not on you for now. CI run 39504208242 was still running when I looked, and Behavior tests (Herdr) is already red on one case:

not ok - concurrent secondmate recovery failed: ... error: herdr presentation recovery could not acquire its session lock; refusing a concurrent resume

The same Herdr job has also gone red on a couple of other branches today, so this may be a flake. But it's secondmate recovery, and this PR touches fm-secondmate-restart.sh. Please take a look and tell me whether it's caused by this PR. Once the run finishes, a re-run of that one job will show whether it's flaky. If CI comes back green with no-mistakes still bound to this head, this can be merged.

…sh` teardown to restore write permission on fixture directories before removal. This addresses the read-only git-hook cleanup errors in the failed Herdr check. The real-Herdr presentation E2E test passed locally (exit 0)
@kunchenguid
kunchenguid merged commit 0e82f3e into kunchenguid:main Oct 21, 2026
22 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @kesslerio — really appreciate you taking the time on this.

@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid — CI is now fully green on this branch, so the condition in your last read is met.

Head b27a2fbf, run 39512433974: 19 of 19 checks pass, including Behavior tests (Herdr), the job that was red when you looked. The no-mistakes attestation binds b27a2fbf exactly, and the PR is MERGEABLE/CLEAN against origin/main. Your condition — "If CI comes back green with no-mistakes still bound to this head, this can be merged" — is satisfied, so this is ready for the merge decision.

On the Herdr job you flagged. It was not caused by this PR. The branch's only change to tests/fm-backend-herdr-presentation-e2e.test.sh is one line in the EXIT cleanup trap (find "$TMP_ROOT" -type d -exec chmod u+rwx {} + before rm -rf "$TMP_ROOT"). The failing assertion was the concurrent-recovery case at line 1337, in the runtime path, which this branch does not touch. The same job went red on other branches that day, as you said.

On your read of the relaunch/restart refusal path. Your read is right, with one precision worth naming: on main, that swallowed fm-harness.sh secondmate* failure did not fall back to the pin — it fell through to $FM_SECONMDMATE_RESTART_HARNESS, so main silently substituted a different runtime. This branch refuses that one mate with a named reason and leaves the other mates alone. So it is fail-closed on an error path rather than a silent substitution, and the refusal is scoped to the mate whose pin is unreadable, not to the whole restart. The call now passes the mate id, which is what makes the per-mate override exact.

Ask 2, the opt-in scoping, is what you read as opt-in, and the byte-comparison proof is in the body: 1467 legacy comparisons against 9d76aa8e, 1467 identical, 0 differing — where the pre-fix head 5782a2de differed on 1053 of them.

Ask 1, the live restart, was driven for real: bin/fm-live-lab.sh up --harness claude --mate in a disposable lab home, real Claude Code 2.1.278 sessions, a private tmux server and a real registered second mate. The mate persisted and answered on its parent channel, the restart ran (1 of 1 restarted, 0 nudged, 0 unreached), and the relaunch journal recorded from_effort=low -> to_effort=medium — the mate's own per-mate line, not the default. The same restart against a legacy pin file (no mate line, a fourth token, a second default line) landed the mate on the first line's three tokens without refusing.

The two gaps you accepted as stated gaps are still stated gaps: the remote placement of the restart path is not driven live, and the live mate held no conversation-only open records at persist time.

The reproducible procedure is in the PR body under "Reproducing the live run" — FM_HOME set to the lab home and TMUX_TMPDIR set to the lab's private tmux directory.