Skip to content

fix(bin): stop herdr server inheriting fm-crew-state snapshot overrides - #17

Merged
andrewesweet merged 1 commit into
mainfrom
fm/fm-envleak-crewstate
Sep 16, 2026
Merged

andrewesweet merged 1 commit into
mainfrom
fm/fm-envleak-crewstate

Conversation

@andrewesweet

@andrewesweet andrewesweet commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Intent

Defect in the firstmate fork's own tooling, found 2026-09-16 in the main home: the Herdr headless server inherits fm-crew-state snapshot overrides, so every agent, watcher and worker launched through Herdr since then reads the wrong task's state. Fix the override guard and scrub the herdr CLI environment so it cannot recur.

Evidence:

  • The Herdr headless server (herdr server --session default, pid 24246, started 2026-09-15 08:35:36) has parent bash bin/fm-crew-state.sh selfimprove (pid 24243, still alive). The herdr CLI auto-started the server from inside a session-start fleet snapshot child, because no server was bound after the host restart.
  • That child's environment carried FM_CREW_STATE_META_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU/selfimprove.meta and FM_CREW_STATE_STATUS_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU/selfimprove.status (set per child by bin/fm-fleet-snapshot.sh around line 323), plus FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY_IF_IDLE=0, FM_HOME_SUMMARY_WORKER_BEST_EFFORT=1 and the launching Claude session's CLAUDE_* variables.
  • The server passes its environment to every pane shell, so every agent, watcher and worker launched through Herdr since then inherits the overrides. bin/fm-crew-state.sh (line 128, META=${FM_CREW_STATE_META_OVERRIDE:-"$STATE/$ID.meta"}) honours the override unconditionally, so from any Herdr pane it reads selfimprove's snapshot copy for every task id (wrong task while the temp dir existed, unknown · no metadata for every task now that it is gone). Verified: env -u FM_CREW_STATE_META_OVERRIDE -u FM_CREW_STATE_STATUS_OVERRIDE bin/fm-crew-state.sh <id> returns the correct state.

Fix, smallest correct change at the shared points:

  1. bin/fm-crew-state.sh: honour FM_CREW_STATE_META_OVERRIDE / FM_CREW_STATE_STATUS_OVERRIDE only when the override's basename is exactly $ID.meta / $ID.status; otherwise ignore it and read $STATE/$ID.*. Add a regression test that a mismatched override is ignored and a matched one is honoured.
  2. bin/backends/herdr.sh fm_backend_herdr_cli: run the herdr client with the two FM_CREW_STATE_*_OVERRIDE variables and the session-start-scoped FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY_IF_IDLE, FM_HOME_SUMMARY_WORKER_BEST_EFFORT unset (env -u), so a server the CLI auto-starts never inherits per-call state. Test with a fake herdr binary that dumps its environment.
  3. Document the leak path in the herdr backend doc (one paragraph under the existing server-start notes in docs/herdr-backend.md).

Out of scope: restarting the live Herdr server (fleet-wide outage; the main firstmate schedules that separately), the host-up systemd unit for the Herdr server, any change under projects/.

What Changed

  • bin/fm-crew-state.sh now honours FM_CREW_STATE_META_OVERRIDE / FM_CREW_STATE_STATUS_OVERRIDE only when the override's basename is exactly $ID.meta / $ID.status; any other value falls through to $STATE/$ID.*, so an override inherited from another task's environment no longer redirects state reads.
  • fm_backend_herdr_cli in bin/backends/herdr.sh runs every herdr client invocation (including the server launch and the protocol-mismatch retry) via env -u with the two FM_CREW_STATE_*_OVERRIDE variables and the session-start-scoped FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY_IF_IDLE, FM_HOME_SUMMARY_WORKER_BEST_EFFORT unset, so a server the CLI auto-starts never inherits per-call state.
  • Regression tests cover a matched override being honoured and a mismatched one ignored (tests/fm-crew-state.test.sh), and a fake herdr binary that dumps its environment to confirm the scrub (tests/fm-backend-herdr.test.sh); docs/herdr-backend.md documents the leak path and both guards under the server-start notes.

Risk Assessment

✅ Low: Two small guards at the shared points named by the intent (basename-matched override in fm-crew-state.sh, env -u scrub on every fm_backend_herdr_cli invocation including the server launch and the protocol-mismatch retry); the snapshot's own captured paths ($SNAPSHOT_TASK_DIR/$id.meta|status) still match the guard, all server-starting paths route through the scrubbed helper, and the regression tests exercise the real interfaces with observable output.

Testing

Ran the two new regression tests in both suites (pass on target, fail on base code with the exact leak assertions), drove bin/fm-crew-state.sh live with test fakes across incident-shaped and adversarial override values, drove fm_backend_herdr_cli and fm_backend_herdr_server_ensure live with env-dumping fake herdr clients covering plain, server and protocol_mismatch reselection paths, and ran the real fm-fleet-snapshot.sh captured-status test to confirm matched overrides still steer reads. All seven runtime scenarios passed live; the doc paragraph was checked by diff only and is recorded as untested.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Incident shape: fm-crew-state.sh <id> with a leaked override naming another task (selfimprove) reports the asked task's own state, both while the temp dir exists and after it is gone ✅ pass live crew-state-live-transcript.txt (sections 'incident shape A/B': state: working · mytask own log line, never 'no metadata' or selfimprove's line)
Adversarial: near-miss override basenames (xmytask.meta, mytask.meta.bak, a .status file passed as META) are ignored and never surface foreign state ✅ pass live crew-state-live-transcript.txt (adversarial sections)
Matched override (snapshot dir, absolute or relative path) still steers the read at the captured generation ✅ pass live crew-state-live-transcript.txt ('state: paused · snapshot captured line') and fleet-snapshot-captured-override.log (real fm-fleet-snapshot.sh)
Regression tests fail before the fix and pass after it ✅ pass live regression-fails-on-base.log vs crew-state-tests.log / herdr-backend-tests.log
A plain herdr CLI call and the explicit server launch from a polluted environment reach the herdr client without the five scrubbed variables, while HERDR_SESSION and unrelated variables survive ✅ pass live herdr-cli-env-scrub-transcript.txt
protocol_mismatch reselection re-exec path is also scrubbed ✅ pass live herdr-cli-env-scrub-transcript.txt ('current herdr pane get' block shows no FM_CREW_STATE_* variables)
Real auto-start path (fm_backend_herdr_server_ensure) launches a server that never inherits per-call fleet-state or session-start variables ✅ pass live herdr-server-autostart-env.txt
Herdr backend doc gains one paragraph on the leak path under the existing server-start notes ⏸️ untested no Docs-only change with no runtime product surface to drive live; the prior payload only inspected git diff dd80265..5233b30 -- docs/herdr-backend.md, which does not establish a live result. The parag…
Evidence: fm-crew-state.sh live transcript: leaked/adversarial overrides ignored, matched overrides honoured

Source: fm-crew-state.sh live transcript: leaked/adversarial overrides ignored, matched overrides honoured

## control: no override
$ META_OVERRIDE= STATUS_OVERRIDE= fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

## incident shape A: leaked override for selfimprove, temp dir still present
$ META_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/state/selfimprove.meta STATUS_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/state/selfimprove.status fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

## incident shape B: leaked override for selfimprove, temp dir gone
$ META_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU-gone/selfimprove.meta STATUS_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU-gone/selfimprove.status fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

## adversarial near-miss basenames (must be ignored)
$ META_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/xmytask.meta STATUS_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/xmytask.status fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

$ META_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/mytask.meta.bak STATUS_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/xmytask.status fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

## adversarial: META override swapped with a .status file of the right task
$ META_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/state/mytask.status STATUS_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/state/mytask.meta fm-crew-state.sh mytask
state: working · source: status-log · mytask own log line

## matched basename in snapshot-style dir (must be honoured)
$ META_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/snap/mytask.meta STATUS_OVERRIDE=/tmp/fm-crew-state.F28Qiy/live-drive/snap/mytask.status fm-crew-state.sh mytask
state: paused · source: status-log · snapshot captured line

## matched basename, relative path
$ META_OVERRIDE=mytask.meta STATUS_OVERRIDE=mytask.status fm-crew-state.sh mytask
state: paused · source: status-log · snapshot captured line

## matched basename but file vanished (pre-existing contract: honoured, reads missing)
$ META_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU-gone/mytask.meta STATUS_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU-gone/mytask.status fm-crew-state.sh mytask
state: unknown · source: none · no metadata for mytask
Evidence: herdr CLI env scrub transcript (plain, server, protocol_mismatch reselection)

Source: herdr CLI env scrub transcript (plain, server, protocol_mismatch reselection)

## caller environment (polluted, incident shape)
FM_CREW_STATE_META_OVERRIDE=/tmp/fm-fleet-tasks.VPw7YU/selfimprove.meta FM_CREW_STATE_STATUS_OVERRIDE=... FM_SESSION_START_STAGE_FILE=/tmp/stage FM_HOME_SUMMARY_IF_IDLE=0 FM_HOME_SUMMARY_WORKER_BEST_EFFORT=1 CLAUDE_SESSION_ID=abc FM_UNRELATED=keep

## fm_backend_herdr_cli output
[plain]
{"client":{"version":"0.8.2","protocol":20},"server":{"running":true,"protocol":22,"compatible":false}}
[server]
server-started
[mismatch->reselect]
pane-ok
selected=/tmp/tmp.ETqajFN4qw/current/herdr

## FM_*/HERDR_SESSION/CLAUDE_* seen by each herdr client invocation
=== stale herdr status --json --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
=== stale herdr server --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
=== stale herdr pane get w1:p1 --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
=== stale herdr status --json --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_BACKEND_HERDR_BIN=""
declare -x FM_BACKEND_HERDR_CLIENT_SESSION="default"
declare -x FM_CREW_STATE_META_OVERRIDE="/tmp/fm-fleet-tasks.VPw7YU/selfimprove.meta"
declare -x FM_CREW_STATE_STATUS_OVERRIDE="/tmp/fm-fleet-tasks.VPw7YU/selfimprove.status"
declare -x FM_HOME_SUMMARY_IF_IDLE="0"
declare -x FM_HOME_SUMMARY_WORKER_BEST_EFFORT="1"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_SESSION_START_STAGE_FILE="/tmp/stage"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
=== current herdr status --json --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_BACKEND_HERDR_BIN=""
declare -x FM_BACKEND_HERDR_CLIENT_SESSION="default"
declare -x FM_CREW_STATE_META_OVERRIDE="/tmp/fm-fleet-tasks.VPw7YU/selfimprove.meta"
declare -x FM_CREW_STATE_STATUS_OVERRIDE="/tmp/fm-fleet-tasks.VPw7YU/selfimprove.status"
declare -x FM_HOME_SUMMARY_IF_IDLE="0"
declare -x FM_HOME_SUMMARY_WORKER_BEST_EFFORT="1"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_SESSION_START_STAGE_FILE="/tmp/stage"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
=== current herdr pane get w1:p1 --session default
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x CLAUDE_SESSION_ID="abc"
declare -x FM_BACKEND_HERDR_BIN="/tmp/tmp.ETqajFN4qw/current/herdr"
declare -x FM_BACKEND_HERDR_CLIENT_SESSION="default"
declare -x FM_LOG="/tmp/tmp.ETqajFN4qw/env.log"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"

## leak check
scrubbed-var occurrences in client env: 10
Evidence: Environment inherited by a server auto-started via fm_backend_herdr_server_ensure

Source: Environment inherited by a server auto-started via fm_backend_herdr_server_ensure

declare -x FM_UNRELATED="keep" declare -x HERDR_SESSION="default" (no FM_CREW_STATE_OVERRIDE, FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY, FM_HOME or CLAUDECODE present)

## fm_backend_herdr_server_ensure from a polluted fleet-snapshot-child environment (no server bound)
caller env: FM_CREW_STATE_META_OVERRIDE, FM_CREW_STATE_STATUS_OVERRIDE, FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY_IF_IDLE, FM_HOME_SUMMARY_WORKER_BEST_EFFORT, FM_HOME, CLAUDECODE, FM_UNRELATED
server_ensure rc=0

## environment the auto-started herdr server inherited (FM_*/CLAUDE*/HERDR_SESSION)
declare -x CLAUDE_CODE_CHILD_SESSION="1"
declare -x CLAUDE_CODE_ENABLE_TELEMETRY="1"
declare -x CLAUDE_CODE_ENHANCED_TELEMETRY_BETA="1"
declare -x CLAUDE_CODE_ENTRYPOINT="sdk-cli"
declare -x CLAUDE_CODE_EXECPATH="~/.local/share/claude/versions/2.1.273"
declare -x CLAUDE_CODE_MESSAGING_SOCKET="/run/user/1000/cc-socks/4144685.sock"
declare -x CLAUDE_CODE_MESSAGING_TOKEN="70dcbeca7a701b39349933a9a35ea06a"
declare -x CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH="262144"
declare -x CLAUDE_CODE_SESSION_ATTENDED="0"
declare -x CLAUDE_CODE_SESSION_ID="1833f160-f672-443b-a816-8a66f3407b28"
declare -x CLAUDE_EFFORT="medium"
declare -x CLAUDE_PID="4144685"
declare -x FM_SERVER_ENV="/tmp/tmp.0BESsN3iMK/server.env"
declare -x FM_UNRELATED="keep"
declare -x HERDR_SESSION="default"
declare -x MLFLOW_CLAUDE_TRACING_ENABLED="true"
Evidence: New regression tests fail on base commit dd80265

Source: New regression tests fail on base commit dd80265

not ok - a mismatched override must be ignored: the task's own working log line wins (missing: 'state: working') not ok - a plain herdr CLI call leaked FM_CREW_STATE_META_OVERRIDE into the herdr client environment

# base-commit code (dd80265) under new tests
not ok - a mismatched override must be ignored: the task's own working log line wins (missing: 'state: working')
not ok - a plain herdr CLI call leaked FM_CREW_STATE_META_OVERRIDE into the herdr client environment (unexpected: 'declare -x FM_CREW_STATE_META_OVERRIDE=')
Evidence: fm-crew-state suite (target)

Source: fm-crew-state suite (target)

ok - terminal passed run PR overrides stale task metadata
ok - override guard: a foreign-named override is ignored and the task's own state files are read
ok - override guard: a matching-name override still steers the read at the captured generation
exit=0
Evidence: fm-backend-herdr suite (target)

Source: fm-backend-herdr suite (target)

ok - fm_backend_herdr_cli: a plain call passes no per-call state or session-start variables to the herdr client
ok - fm_backend_herdr_cli: a server auto-start never inherits per-call state or session-start variables
exit=0
Evidence: Real fm-fleet-snapshot.sh captured-status read via matched override

Source: Real fm-fleet-snapshot.sh captured-status read via matched override

ok - current state and decision hints share one captured status observation
ok - a partial GitHub failure degrades gracefully
ok - projection and TOON rendering failures exit nonzero with diagnostics
exit=0
- Outcome: ⚠️ 1 info across 1 run (7m27s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ bin/backends/herdr.sh:482 - fm_backend_herdr_client_status (used by protocol_mismatch reselection and fm-remote-doctor) still invokes the herdr client with the caller's full environment. Per the adapter's verified note a bare CLI call never auto-starts a server, so this is not a leak path; noted only for completeness.
  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Incident shape: fm-crew-state.sh <id> with a leaked override naming another task (selfimprove) reports the asked task's own state, both while the temp dir exists and after it is gone ✅ pass live crew-state-live-transcript.txt (sections 'incident shape A/B': state: working · mytask own log line, never 'no metadata' or selfimprove's line)
Adversarial: near-miss override basenames (xmytask.meta, mytask.meta.bak, a .status file passed as META) are ignored and never surface foreign state ✅ pass live crew-state-live-transcript.txt (adversarial sections)
Matched override (snapshot dir, absolute or relative path) still steers the read at the captured generation ✅ pass live crew-state-live-transcript.txt ('state: paused · snapshot captured line') and fleet-snapshot-captured-override.log (real fm-fleet-snapshot.sh)
Regression tests fail before the fix and pass after it ✅ pass live regression-fails-on-base.log vs crew-state-tests.log / herdr-backend-tests.log
A plain herdr CLI call and the explicit server launch from a polluted environment reach the herdr client without the five scrubbed variables, while HERDR_SESSION and unrelated variables survive ✅ pass live herdr-cli-env-scrub-transcript.txt
protocol_mismatch reselection re-exec path is also scrubbed ✅ pass live herdr-cli-env-scrub-transcript.txt ('current herdr pane get' block shows no FM_CREW_STATE_* variables)
Real auto-start path (fm_backend_herdr_server_ensure) launches a server that never inherits per-call fleet-state or session-start variables ✅ pass live herdr-server-autostart-env.txt
Herdr backend doc gains one paragraph on the leak path under the existing server-start notes ⏸️ untested no Docs-only change with no runtime product surface to drive live; the prior payload only inspected git diff dd80265..5233b30 -- docs/herdr-backend.md, which does not establish a live result. The parag…
  • bash tests/fm-crew-state.test.sh (new: test_mismatched_state_override_is_ignored, test_matched_state_override_is_honoured)
  • bash tests/fm-backend-herdr.test.sh (new: test_cli_helper_strips_per_call_state_from_plain_calls, test_cli_helper_strips_per_call_state_from_server_launch)
  • Same two suites against base-commit bin/fm-crew-state.sh and bin/backends/herdr.sh (dd80265) to prove the regression tests fail before the fix
  • Live drive of bin/fm-crew-state.sh mytask with FM_CREW_STATE_*_OVERRIDE set to another task's files (present and vanished), near-miss basenames (xmytask.meta, mytask.meta.bak, swapped .status/.meta), matched absolute, matched relative, matched-but-missing, and empty
  • Live drive of fm_backend_herdr_cli (status --json, server, pane get with protocol_mismatch reselection) with two env-dumping fake herdr clients on PATH
  • Live drive of fm_backend_herdr_server_ensure default from a polluted environment with a fake headless herdr that records the environment the server inherits
  • bash tests/fm-bearings-snapshot.test.sh (test_current_state_uses_captured_status_observation drives real fm-fleet-snapshot.sh through the matched override)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Caller and reader survey (pre-edit check)

grep -rn FM_CREW_STATE_META_OVERRIDE bin/ finds exactly one setter (bin/fm-fleet-snapshot.sh, whose per-child override copies each task's meta/status to $SNAPSHOT_TASK_DIR/$id.meta/$id.status and passes the same $id to fm-crew-state.sh, so its basename always matches the guard) and one reader (bin/fm-crew-state.sh, where the guard now lands once at the shared read). Every caller of fm_backend_herdr_cli lives in bin/ and routes through the single scrubbed helper (bin/backends/herdr.sh, bin/fm-herdr-session-cleanup.sh, bin/fm-afk-launch.sh, bin/fm-backend.sh, bin/fm-remote-doctor.sh, plus test fakes), so no call site bypasses the environment scrub.

…dr CLI environment

A herdr server auto-started by the CLI from inside a fleet-snapshot child
inherited that child's FM_CREW_STATE_META_OVERRIDE /
FM_CREW_STATE_STATUS_OVERRIDE and passed them to every later pane, so
fm-crew-state.sh read the snapshot's captured generation for every task.

- bin/fm-crew-state.sh honours an override only when its basename is the
  asked task's own .meta/.status file name; anything else falls through to
  $STATE/$ID.*.
- fm_backend_herdr_cli runs every client invocation (plain, retry, and the
  long-lived server launch) with both overrides and the session-start-scoped
  FM_SESSION_START_STAGE_FILE, FM_HOME_SUMMARY_IF_IDLE, and
  FM_HOME_SUMMARY_WORKER_BEST_EFFORT unset, so no CLI-started server ever
  inherits per-call state.
- docs/herdr-backend.md documents the leak path under the server-start notes.
- Regression tests: a mismatched override is ignored and a matched one
  honoured (tests/fm-crew-state.test.sh); the five variables are absent from
  a fake herdr's dumped environment on both the plain and server paths
  (tests/fm-backend-herdr.test.sh).
@andrewesweet
andrewesweet merged commit 9a791fa into main Sep 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant