Skip to content

fix: inherit supervision host opt-out across secondmates - #6154

Merged
kunchenguid merged 5 commits into
mainfrom
fm/fm-supervision-host-off-inherit-r1
Sep 30, 2026
Merged

kunchenguid merged 5 commits into
mainfrom
fm/fm-supervision-host-off-inherit-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Intent

let's do a follow up to propagate off because that would feel more intuitive

in that fix let's move off to an inherited config

no need to care about backwards compatibility of the off change. i have not announced the feature and the gap is small

Context: PR #6124 (merged 2026-09-29) made the supervision host run by default on a Claude primary when config/supervision-host is absent, with a file holding off as the opt-out on every harness, and a present file still meaning <engine> [<model>]. It documented that config/supervision-host is local to each home and not inherited: a primary's off never reaches a secondmate, and a mate that must stay off writes its own off. This follow-up reverses that rule so the primary's off propagates to secondmate homes as an inherited config, under the primary-authoritative inherited-local-material contract owned by the secondmate-provisioning skill, with docs/configuration.md and tests updated to match. How a mate that deliberately runs the host while the primary is off can still express that is to be resolved if it is needed. It is validated with a real secondmate spawn and convergence cycle, which PR 6124 could not drive. Default-on for the other harnesses and away-daemon retirement are out of scope.

What Changed

  • Replace the off value in config/supervision-host with a separate config/supervision-host-off flag that takes precedence over engine selection.
  • Propagate the opt-out from primary to secondmate homes and remove it on convergence when the primary clears it, while keeping engine settings local to each home.
  • Update configuration guidance and add propagation, spawn, and live-lab readiness coverage for the new gate.

Risk Assessment

✅ Low: The opt-out change uses the existing primary-authoritative inheritance path and shared host gate, with no substantiated source defect found.

Testing

The targeted up-readiness regression passed for off and on. Disposable-home checks showed off inheritance, restoration after a mate-local edit, and removal when the primary opts back in. Longer targeted tests timed out, with one timing-sensitive lab teardown check failing. A real secondmate spawn and running-home cycle was not driven, so the required lifecycle proof remains open.

  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A primary opts out and its mate inherits a disabled supervision-host gate despite a mate-local engine line ✅ pass live Disposable-home opt-out and convergence transcript
A mate-local opt-out deletion is reversed by convergence, and removing the primary opt-out enables the mate again ✅ pass live Disposable-home opt-out and convergence transcript
A real secondmate spawns under an opted-out primary and remains opted out through running-home convergence ⏸️ untested no The disposable-home gate and inheritance path was exercised, but it cannot establish a real spawn or running-home cycle. The previously identified worktree-boundary and lab-home path constraints preve…
Evidence: Disposable-home opt-out and convergence transcript

Source: Disposable-home opt-out and convergence transcript

Primary off -> mate inherits, even with mate-local engine line:
mate inherited opt-out: yes
mate gate: off
Adversarial mate local edit -> primary convergence restores off:
mate gate restored: off
Primary removes opt-out -> mate converges back to local engine:
mate inherited opt-out removed: yes
mate gate: on
- Outcome: ⚠️ 1 warning across 2 runs (23m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (3 of 4 scenarios were driven live against the product); untested: A real secondmate spawns under an opted-out primary and remains opted out through running-home convergence
  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A primary opts out and its mate inherits off despite having a local host engine ✅ pass live Inherited supervision opt-out and convergence CLI transcript
A primary clears off and its mate converges back to its local host engine ✅ pass live Inherited supervision opt-out and convergence CLI transcript
A mate cannot bypass the off gate with a symlink flag ✅ pass live Inherited supervision opt-out and convergence CLI transcript
A real secondmate spawns under an opted-out primary and remains opted out through running-home convergence ⏸️ untested no Disposable in-worktree homes supported the executable propagation and gate checks, but not this lifecycle proof: the required private tmux socket path exceeds the host limit, while the supported short…
  • bash tests/fm-secondmate-harness.test.sh (timed out during the combined command)
  • bash tests/fm-supervision-host.test.sh (timed out)
  • bash tests/fm-live-lab.test.sh
  • Ran propagate_inheritable_config and the executable supervision-host gate against disposable primary and mate homes, then cleared the opt-out and repeated the checks

🔧 Fix applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: A real secondmate spawns under an opted-out primary and remains opted out through running-home convergence
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A primary opts out and its mate inherits a disabled supervision-host gate despite a mate-local engine line ✅ pass live Disposable-home opt-out and convergence transcript
A mate-local opt-out deletion is reversed by convergence, and removing the primary opt-out enables the mate again ✅ pass live Disposable-home opt-out and convergence transcript
A real secondmate spawns under an opted-out primary and remains opted out through running-home convergence ⏸️ untested no The disposable-home gate and inheritance path was exercised, but it cannot establish a real spawn or running-home cycle. The previously identified worktree-boundary and lab-home path constraints preve…
  • bash tests/fm-live-lab-up-mate.test.sh
  • bash tests/fm-live-lab.test.sh (partial: one timing-sensitive check failed before timeout)
  • bash tests/fm-secondmate-harness.test.sh (partial: timed out)
  • bash tests/fm-supervision-host.test.sh (partial: timed out)
  • Ran propagate_inheritable_config and the executable supervision-host gate against disposable primary and mate homes, including local-edit and primary-removal convergence.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes supervision host opt-out configuration inheritance.

The PR appears safe to merge based on the reviewed changes, though the stated real-spawn lifecycle validation remains open.

Reviews (4) · Last reviewed commit: "no-mistakes(ci): Fixed Lint 2 by making ..."

Comment thread bin/fm-live-lab.sh Resolved
Move the supervision host's off opt-out out of config/supervision-host into
its own presence flag, config/supervision-host-off, and add that flag to the
primary-authoritative inherited config set. A primary that opts out now opts
every secondmate home out at spawn and convergence, and clearing it converges
them back. config/supervision-host stays the home-local engine choice.

Shape: config/supervision-host mixed two things, a fleet posture (off) and a
per-home engine and model. Only the posture should follow the primary, so it
becomes a separate presence flag that rides the existing inherited-config
mechanism (FM_INHERITABLE_CONFIG in bin/fm-config-inherit-lib.sh) with no new
machinery, while the engine line stays local. The parse stays in its one
owner, fm_supervision_host_enabled. There is no migration or compatibility
handling for a home that still holds off in config/supervision-host.

Primary off, mate on: inherited material is primary-authoritative by design,
so a mate cannot keep the host while the primary is opted out, and a mate's
own opt-out is removed at the next convergence while the primary has none.
Running the host on a mate is the primary's choice for the fleet; no override
mechanism is added.

Live validation (disposable bin/fm-live-lab.sh lab, Claude primary with a
real seeded secondmate, --supervision-host off):
- up: every readiness check ok, including "host: none running, as expected"
  and a live mate session; the spawned mate home held the inherited
  config/supervision-host-off and the gate read primary OFF, mate OFF.
- primary removed its opt-out, then bin/fm-config-push.sh reported
  "supervision-host-off: pushed - mirrored primary absence" and a config
  reread sent; the gate read primary ON, mate ON, and the live mate handled
  the reread.
- primary opted out again and pushed: "supervision-host-off: pushed", mate
  gate OFF.
- down stopped every lab process and left no lab process running.

Out of scope, follow-up: default-on for the other harnesses, away-daemon
retirement, rollout.
…b readiness now requires the inherited flag in the mate home and a disabled mate supervision-host gate. The focused behavior test, shellcheck, and diff checks pass. Left ci-1–ci-3 untouched as directed
@kunchenguid
kunchenguid force-pushed the fm/fm-supervision-host-off-inherit-r1 branch from b39d999 to bb137e5 Compare September 30, 2026 02:52
@kunchenguid kunchenguid changed the title fix: inherit supervision host opt-out in secondmate homes fix: inherit supervision host opt-out across secondmates Sep 30, 2026
…e resolvable to ShellCheck; its off/on readiness test and ShellCheck now pass locally. Behavior portable serial 5 failed in the unchanged remote-reply test at generation 7. That test passes locally, and no PR-caused defect was identified, so no remote-reply code was changed
@kunchenguid
kunchenguid merged commit 12e90e1 into main Sep 30, 2026
19 of 20 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-supervision-host-off-inherit-r1 branch September 30, 2026 05:09
RooseveltAdvisors added a commit to RooseveltAdvisors/firstmate that referenced this pull request Sep 30, 2026
…locally, and shellcheck at warning level is clean. **Behavior portable serial 5.** The failing test was `tests/fm-remote-secondmate-lifecycle-e2e.test.sh`, which reported "the watcher did not exit on its auto-relaunch wake within the bound". This PR doesn't touch that code. The test gave the watcher a fixed 1500 × 0.02s loop, about 30 seconds, and on a busy CI runner the sleeps take longer than that. It now waits up to 120 seconds by the clock (`SECONDS + 120`). A working relaunch still exits within seconds, so only a hung watcher reaches the limit. The whole script passes locally ("ALL TESTS PASSED", about 5m46s). **Greptile Review.** - **Missing skill file:** An earlier review step in this run had changed the ship/scout launch brief in `bin/fm-dod-lib.sh` to say "if absent, continue without it". That reopened Greptile's P1: a worker on a host without `~/.agents/skills/caveman/SKILL.md` would run without `caveman full`, which breaks the requirement that every future crewmate and scout activates it. The brief now says "if absent, still apply `full` from its known rules". This keeps the short wording that review step asked for, and activation no longer depends on the file being there. `tests/fm-task-delivery.test.sh` checks this clause in the generated launch brief for each ship/scout kind; it passes, and so does `tests/fm-brief.test.sh`. - **Stale PR base on GitHub:** The newest Greptile P1s point at `bin/fm-supervision-engine-lib.sh` and `bin/fm-config-inherit-lib.sh`. Those changes come from kunchenguid#6124 and kunchenguid#6154, which are already in this branch's base commit (`c35b9a69`). GitHub still compares the PR against an older base (`b3d41332`), so Greptile reviewed code that isn't part of this change. This branch changes neither file, and those comments should go away once the PR is compared against the current base. - **Still open:** The two P1s I left alone before are unchanged. Fresh firstmate and secondmate sessions get the directive only through `data/captain-shared.md` and the session-start digest; a review step in this run deliberately removed it from `AGENTS.md`. Crewmates and scouts that are already running need a relaunch or a message through `bin/fm-send.sh` after merge, which code can't do for them. The changes are uncommitted in `tests/fm-remote-secondmate-lifecycle-e2e.test.sh`, `bin/fm-dod-lib.sh` and `tests/fm-task-delivery.test.sh`
ironerumi added a commit to ironerumi/firstmate that referenced this pull request Oct 2, 2026
* fix: grant Claude workers access to Firstmate task channels (#5884)

* fix(bin): grant Claude workers their task-channel dirs via --add-dir

Since Claude Code 2.1.257, a file-tool read (Read/Glob/Grep, and an
Edit's mandatory prior read) of a path outside the working directories
parks --permission-mode auto panes on a one-time interactive question,
and a "Block" answer lands permissions.blockReadsOutsideWorkingDirectories
in user settings, refusing the same reads even under bypass. Firstmate
launches Claude with no --add-dir, so a secondmate's parent-home steering
inbox and a ship or scout worker's launch record, steering inbox, brief
dir, and code-root .agents/skills were all outside: workers wedged on
the question the first time they read a steer.

Every Claude launch, spawn and relaunch, in both permission modes, now
grants exactly the task's channel directories: state/<id>.inbox for a
secondmate (in the parent home), or state/operational-inbox,
state/<id>.inbox, data/<id>, and the code root's .agents/skills for a
ship or scout. Paths resolve to real paths and lazily created channel
dirs are made before launch so the grant never names a not-yet-existing
directory; the whole state/ is deliberately never granted.

The grant keeps the bypass-mode launch argv changed on purpose: it also
protects bypass workers against a machine-recorded Block answer.

* no-mistakes(document): Consolidate Claude launch guidance in configuration reference

* no-mistakes(document): Clarify Claude permission documentation reference

* fix(bin): prevent idle recovery loops without stranding wakes (#4819)

* fix(supervision): prevent idle recovery loops without stranding wakes

* no-mistakes(review): Remove unused wake-append rollback helper

* fix: reduce remote worker and polling helper process churn (#5889)

* fix(bin): stop the remote-job worker busy-polling an idle queue

The serving loop slept 50ms between passes and re-ran state preparation
(chmod on every queue directory), the heartbeat publish, and the stale sweep
on every pass. It now blocks on a worker.wake FIFO that staging,
cancellation, and lane exit nudge, keeps a short fast-poll window after
activity, refreshes the heartbeat at most once a second, and runs the sweep
(which re-applies the queue directories' 0700 modes) at startup and then on
a bounded interval. Lane-owned records are no longer re-read every pass.

Measured with a fork/execve-interposing counter on a --serve worker in a
disposable HOME and queue, bash 3.2, 20-second windows (the counter slows
the old loop to about 5 passes a second, so real-host rates were higher):
  idle worker             146 forks/s, 61 execs/s -> 4.8 forks/s, 3.1 execs/s
  one running long job    232 forks/s, 100 execs/s -> 15 forks/s, 11 execs/s
Stage-to-result latency for a no-op job, idle and back to back, stayed at
about 0.8-1.2s in both versions (dominated by job execution, not pickup).

* perf(bin): drop per-cycle forks from watcher, drain, and lock helpers

The watcher, drain, inactive-reconcile scan, and branch-outcome reads forked
small external commands on every cycle where bash can do the same work.

- fm-wake-lib.sh gains fm_dirname_to, fm_basename_to, and
  fm_epoch_seconds_to, exact stand-ins for $(dirname --), $(basename --),
  and $(date +%s); the clock uses printf %(%s)T on bash 4.2+ and still forks
  date exactly once on stock macOS bash 3.2.
- fm_lock_abs_path, fm_wake_signal_seen_path, fm_path_age, the watcher's
  age_of and wedge timer, and the recovery-marker line count use them or
  plain reads instead of dirname/basename/tr/date/wc.
- window_to_task reads a meta file once instead of two
  grep | tail -1 | cut -d= -f2- pipelines per file per call.
- fm-classify-lib.sh reads uname -s once at source time instead of in every
  status stat helper.
- Libraries sourced every cycle derive their own directory without forking
  dirname, including the backend adapter siblings a subshell re-sources on
  each probe.

tests/fm-fork-free-helpers.test.sh pins each replacement against the command
it replaces on edge-case inputs, under every available bash and both the C
and a UTF-8 locale; CI's stock macOS bash lane runs it under /bin/bash 3.2.

Measured with a fork/execve-interposing counter in a disposable home, one
tmux crew task, FM_POLL=1 (forks and execs per watcher cycle, per run
otherwise):
  watcher cycle      bash 5.3  299/138 -> 199/66   bash 3.2  341/146 -> 224/80
  drain              bash 5.3  492/238 -> 430/200  bash 3.2  567/250 -> 491/212
  inactive scan      bash 5.3   27/14  ->  17/4    bash 3.2   37/14  ->  17/4
  branch-outcome     bash 5.3   40/21  ->  35/16   bash 3.2   48/24  ->  38/19

* test: note the interpreter-expanded version probe for shellcheck

* no-mistakes(review): Fix worker idle bounds and fork-free contributions snapshot

* no-mistakes(review): Coalesce buffered worker wake nudges into one wake

* no-mistakes(review): Coalesce wake nudges via pending marker so publishers never block

* no-mistakes(review): Claim wake nudges atomically via noclobber pending marker

* no-mistakes(review): Release abandoned wake claims only after a 30-second bound

* no-mistakes(review): Drop worker wake FIFO; load path helpers side-effect free

* no-mistakes(document): Document remote worker polling and preemption cadence

* no-mistakes(ci): Fixed both failing CI shards: isolated remote and teardown test fixtures now include fm-path-lib.sh, which fm-wake-lib.sh requires. The three affected tests, fm-lint.sh, and git diff --check pass locally

* fix: keep remote reply listeners and watcher cycles running (#5941)

* fix: keep a successor watcher and remote-reply listeners across the gaps that dropped them

A main-only supervision pass-through exited without leaving a watcher, and each remote-reply poll released its claim until the next cycle, so short-lived listeners stayed down.

* no-mistakes(document): Clarify listener and supervision continuity documentation

* no-mistakes(ci): Fixed the three Greptile findings: failed ingestion leaves one durable capture, failed reads exit instead of relistening, and the disposable-checkout guard rejects state paths outside the marked lab. Added behavioral tests; the remote-reply and watcher-lock suites