Skip to content

fix(bin): stop finished workers filling the away spend cap and apply yolo changes to running ships - #15

Merged
demy00 merged 4 commits into
mainfrom
feature/fm-away-overnight-fix-g2
Oct 20, 2026
Merged

demy00 merged 4 commits into
mainfrom
feature/fm-away-overnight-fix-g2

Conversation

@demy00

@demy00 demy00 commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Intent

"Ooh, we need to fix this ASAP. I mean the overnight runs. This is just bad."

Context: on the night of 2026-10-19 the away session (Claude home, supervision host) stalled after the first batch. Away mode was entered with spend cap 16, meant as 5 active workers on top of 11 old idle task records. Two causes stopped all further work for about 6 hours:

  1. The away spend cap in bin/fm-spawn.sh (spawn_refuse_if_away_spend_cap) counts every non-secondmate state/*.meta. A worker that has finished (ready PR reported, or scout report delivered) keeps its record until cleanup, and cleanup of a ship needs its PR merged. So finished workers filled the cap and every queued spawn was refused all night, including independent work with no blockers.
  2. The project ada was switched to +yolo in data/projects.md during the evening, but the three Ada tasks already running had yolo=off recorded at spawn. Their green PRs into the feature branch were left unmerged as needing the captain, which also blocked the dependent queued steps.

What Changed

  • bin/fm-spawn.sh: the away spend cap now counts only workers that are still working. A task stops counting if fm-crew-state.sh reads it as one of these:

    • done
    • failed while idle
    • parked on a decision a human owes
    • its tmux/herdr endpoint is proven gone

    A task whose state can't be read still counts. The recheck after the task-set lock reuses the first check's reads. Relaunches stay exempt, and the code comment notes the known edge where a dead backend can let the total go over the cap. The refusal message now reports how many tasks were not counted.

  • New bin/fm-project-yolo-apply.sh <project> [<task-id>...]: rewrites yolo= in the project's live ship task metas to match the project's registered +yolo posture, under each task's lifecycle and meta locks. It also rewrites the posture tokens in queued ship backlog notes through fm-tasks-axi.sh. Busy or unreadable tasks are skipped, the run exits 1, and it is safe to rerun. It is covered by the new tests/fm-project-yolo-apply.test.sh, and tests/fm-branch-supervision.test.sh gains spend-cap cases.

  • Docs and skills: AGENTS.md, the project-management and afk skills, fm-afk-contract.sh, fm-project-mode.sh, docs/architecture.md, docs/pi-supervision-branch.md and docs/scripts.md now describe the new spend-cap semantics, with --spend meaning how many workers may run at once. They also say to run the apply script right after changing a project's +yolo.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The latest fix round cleanly reverts the R2-1 relaunch-cap machinery exactly as directed (relaunch exemption restored at the top of spawn_refuse_if_away_spend_cap, refusal wording, tests and docs reverted, known dead-backend edge documented), and the kept F1-F3 and per-fixture R2-2 changes remain consistent with the stated overnight-stall intent.

Testing

I ran the two focused suites for this change, tests/fm-branch-supervision.test.sh and tests/fm-project-yolo-apply.test.sh, and both passed. I then replayed the 2026-10-19 incident as CLI transcripts. - Spend cap: with the base fm-spawn.sh, a cap of 4 with 4 finished records and 1 working worker refused every queued spawn ("5 ordinary task(s) are live"). With the fix, 3 spawns were admitted and the 4th was refused once 4 real workers were working, and the refusal named the 4 uncounted finished tasks. - Admitted spawns in the replay: they exit 1 later because the fixture passes no repo argument, the same shape the existing suite uses. That happens after the cap check (fm-spawn.sh:1642 vs ~1939). - Yolo apply: fm-project-yolo-apply.sh ada flipped 3 live ada ship tasks from yolo=off to on. It rewrote the queued ada-4 note token to "yolo on" and appended a posture sentence to ada-5. The other project's live task and queued item were not touched, and the command exited 0. - Environment: the replays needed the same env the suite's tests/lib.sh sets (FM_GATE_REFUSE_BYPASS, FM_TEST_SEAM). Without it the gate shell's NO_MISTAKES_GATE=1 makes fm-spawn refuse early. - Not visual: this is a CLI/shell change with no UI, so there are no screenshots. - Cleanup: the worktree is clean. Removing the scratch dirs in /tmp was denied, so /tmp/fmreplay., /tmp/fmreplay2. and /tmp/fmyolo.* are left behind. They are small and outside the worktree.

Evidence: Away spend cap incident replay: base vs fix transcript

Source: Away spend cap incident replay: base vs fix transcript

# Note: ADMITTED spawns exit 1 later (line ~1939, no repo positional in this fixture), after passing the away spend cap check (line 1642).
=== [BASE 5d67f6e] away entered with --spend 4; records: 4 finished scouts + 1 working ===
$ fm-spawn.sh queued-1 --mode no-mistakes --yolo off
  REFUSED (exit 1): error: spawn refused - the away-posture record caps concurrent workers at 4 and 5 ordinary task(s) are live in this home; task queued-1 stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)
$ fm-spawn.sh queued-2 --mode no-mistakes --yolo off
  REFUSED (exit 1): error: spawn refused - the away-posture record caps concurrent workers at 4 and 5 ordinary task(s) are live in this home; task queued-2 stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)
$ fm-spawn.sh queued-3 --mode no-mistakes --yolo off
  REFUSED (exit 1): error: spawn refused - the away-posture record caps concurrent workers at 4 and 5 ordinary task(s) are live in this home; task queued-3 stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)
$ fm-spawn.sh queued-4 --mode no-mistakes --yolo off
  REFUSED (exit 1): error: spawn refused - the away-posture record caps concurrent workers at 4 and 5 ordinary task(s) are live in this home; task queued-4 stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)

=== [FIX 374d83d] away entered with --spend 4; records: 4 finished scouts + 1 working ===
$ fm-spawn.sh queued-1 --mode no-mistakes --yolo off
  ADMITTED past the away spend cap (exit 1)
$ fm-spawn.sh queued-2 --mode no-mistakes --yolo off
  ADMITTED past the away spend cap (exit 1)
$ fm-spawn.sh queued-3 --mode no-mistakes --yolo off
  ADMITTED past the away spend cap (exit 1)
$ fm-spawn.sh queued-4 --mode no-mistakes --yolo off
  REFUSED (exit 1): error: spawn refused - the away-posture record caps concurrent workers at 4 and 4 ordinary worker(s) are still working in this home (4 task(s) that finished, wait on a human decision, or lost their endpoint are not counted; a task whose state cannot be read counts); task queued-4 stays queued for the captain's return or for a worker to finish (spend cap: bin/fm-afk-contract.sh)
Evidence: Away spend cap replay script

Source: Away spend cap replay script

#!/usr/bin/env bash
# Replay of the 2026-10-19 stall: away cap 4, 1 worker still working,
# 4 finished records (scout reports delivered, done) waiting on cleanup.
# Usage: replay-away-cap.sh <repo-root-whose-bin-to-use> <label> <scratch-dir>
set -u
BIN_ROOT=$1
LABEL=$2
T=$3
home=$T/home
root=$T/root
fb=$T/fakebin
mkdir -p "$home/state" "$home/data" "$home/config" "$root" "$fb"
git init -q -b main "$root"
git -C "$root" -c user.name=t -c user.email=t@t commit -q --allow-empty -m init
ln -s "$BIN_ROOT/bin" "$root/bin"
cat > "$fb/tmux" <<'SH'
#!/usr/bin/env bash
case "${1:-}" in
  display-message) printf '%%1\n' ;;
  capture-pane) printf 'all quiet\n> \n' ;;
esac
exit 0
SH
chmod +x "$fb/tmux"

mark() { # mark <id> busy|idle
  local gen
  gen=$("$BIN_ROOT/bin/fm-busy-event.sh" arm "$home/state" "$1")
  if [ "$2" = busy ]; then
    "$BIN_ROOT/bin/fm-busy-event.sh" apply "$home/state" "$1" busy --gen "$gen" --source claude-hook --event user-prompt-submit
  else
    "$BIN_ROOT/bin/fm-busy-event.sh" apply "$home/state" "$1" idle --gen "$gen" --source claude-hook --event stop
  fi
}

for id in scout-a scout-b scout-c scout-d live-1; do
  mkdir -p "$home/wt/$id"
  printf 'window=fm:fm-%s\nworktree=%s\nkind=scout\nharness=claude\n' "$id" "$home/wt/$id" > "$home/state/$id.meta"
  if [ "$id" = live-1 ]; then
    mark "$id" busy
    printf 'working [at=1]: implementing\n' > "$home/state/$id.status"
  else
    mark "$id" idle
    printf 'done [at=1]: report written to data/%s/report.md\n' "$id" > "$home/state/$id.status"
  fi
done

echo "=== [$LABEL] away entered with --spend 4; records: 4 finished scouts + 1 working ==="
FM_HOME="$home" "$BIN_ROOT/bin/fm-afk-contract.sh" enter --spend 4 >/dev/null
for n in 1 2 3 4; do
  echo "\$ fm-spawn.sh queued-$n --mode no-mistakes --yolo off"
  out=$(PATH="$fb:$PATH" FM_HOME="$home" FM_ROOT_OVERRIDE="$root" \
    "$BIN_ROOT/bin/fm-spawn.sh" "queued-$n" --mode no-mistakes --yolo off 2>&1)
  st=$?
  if printf '%s' "$out" | grep -q "caps concurrent workers"; then
    echo "  REFUSED (exit $st): $(printf '%s' "$out" | grep "caps concurrent workers" | head -1)"
  else
    echo "  ADMITTED past the away spend cap (exit $st)"
    # Model the admitted spawn as a live working worker, like a launched agent.
    mkdir -p "$home/wt/queued-$n"
    printf 'window=fm:fm-queued-%s\nworktree=%s\nkind=scout\nharness=claude\n' "$n" "$home/wt/queued-$n" > "$home/state/queued-$n.meta"
    printf 'working [at=1]: implementing\n' > "$home/state/queued-$n.status"
    mark "queued-$n" busy
  fi
done
Evidence: Project +yolo switch applied to live tasks and queued notes (before/after)

Source: Project +yolo switch applied to live tasks and queued notes (before/after)

=== before: recorded yolo of live ship tasks ===
ada-1.meta:yolo=off
ada-2.meta:yolo=off
ada-3.meta:yolo=off
other-1.meta:yolo=off
=== before: data/backlog.md ===
## In flight

## Queued
- [ ] ada-4 - Ada step 4 (repo: ada) (kind: ship) (since 2026-10-20)
  mode no-mistakes, yolo off; runs after ada-3.

- [ ] ada-5 - Ada step 5 (repo: ada) (kind: ship) (since 2026-10-20)
  Runs after ada-4.
- [ ] other-q - Other step (repo: other) (kind: ship) (since 2026-10-20)
  mode no-mistakes, yolo off
## Done

$ fm-project-yolo-apply.sh ada
ada-1: yolo off -> on
ada-2: yolo off -> on
ada-3: yolo off -> on
ada-4: queued note yolo off -> on
ada-5: queued note yolo unrecorded -> on
applied: ada yolo=on to 3 live ship task(s) and 2 queued ship item(s) in this home
(exit 0)

=== after: recorded yolo of live ship tasks ===
ada-1.meta:yolo=on
ada-2.meta:yolo=on
ada-3.meta:yolo=on
other-1.meta:yolo=off
=== after: data/backlog.md ===
## In flight

## Queued
- [ ] ada-4 - Ada step 4 (repo: ada) (kind: ship) (since 2026-10-20)
  mode no-mistakes, yolo on; runs after ada-3.
- [ ] ada-5 - Ada step 5 (repo: ada) (kind: ship) (since 2026-10-20)
  Runs after ada-4.
  Delivery posture: yolo on (project registry).
- [ ] other-q - Other step (repo: other) (kind: ship) (since 2026-10-20)
  mode no-mistakes, yolo off
## Done
Evidence: Yolo switch replay script

Source: Yolo switch replay script

#!/usr/bin/env bash
# Replay of the 2026-10-19 posture miss: ada switched to +yolo in the evening
# while three ada ship tasks were already running with yolo=off recorded, and
# dependent ada steps were queued with "yolo off" in their notes.
# Usage: replay-yolo-switch.sh <repo-root> <scratch-home>
set -u
ROOT=$1
home=$2
mkdir -p "$home/state" "$home/data" "$home/projects/ada" "$home/projects/other"
{
  printf '# Projects\n\n'
  printf -- '- ada [no-mistakes +yolo] - Ada library (added 2026-10-01)\n'
  printf -- '- other [no-mistakes] - another library (added 2026-10-01)\n'
} > "$home/data/projects.md"
printf '## In flight\n\n## Queued\n\n## Done\n' > "$home/data/backlog.md"
for id in ada-1 ada-2 ada-3; do
  printf 'window=fm-%s\nproject=%s\nkind=ship\nmode=no-mistakes\nyolo=off\nbranch=feature/ada-g2\n' "$id" "$home/projects/ada" > "$home/state/$id.meta"
done
printf 'window=fm-other-1\nproject=%s\nkind=ship\nmode=no-mistakes\nyolo=off\n' "$home/projects/other" > "$home/state/other-1.meta"
tx() { FM_HOME="$home" "$ROOT/bin/fm-tasks-axi.sh" "$@" >/dev/null; }
tx add ada-4 "Ada step 4" --repo ada --kind ship --body "mode no-mistakes, yolo off; runs after ada-3."
tx add ada-5 "Ada step 5" --repo ada --kind ship --body "Runs after ada-4."
tx add other-q "Other step" --repo other --kind ship --body "mode no-mistakes, yolo off"

echo "=== before: recorded yolo of live ship tasks ==="
grep -H '^yolo=' "$home/state/"*.meta | sed "s|$home/state/||"
echo "=== before: data/backlog.md ==="
cat "$home/data/backlog.md"
echo
echo "\$ fm-project-yolo-apply.sh ada"
FM_HOME="$home" "$ROOT/bin/fm-project-yolo-apply.sh" ada 2>&1
echo "(exit $?)"
echo
echo "=== after: recorded yolo of live ship tasks ==="
grep -H '^yolo=' "$home/state/"*.meta | sed "s|$home/state/||"
echo "=== after: data/backlog.md ==="
cat "$home/data/backlog.md"
Evidence: fm-branch-supervision suite log

Source: fm-branch-supervision suite log

ok - branch prompt is byte-stable across homes, cwd, timezone, and time, above the cache floor
ok - outcome store is append-only and refuses sequence reuse after a torn tail
ok - outcome append refreshes a bounded, verbatim display tail of the newest rows without moving the cursor
ok - the display tail keeps only whole newest rows within its 1 MiB budget, never shortening one
ok - outcome seed-tail writes an absent display tail from a valid store's newest rows without moving a marker, and leaves an existing one to append
ok - seed-tail validates and publishes only a bounded newest window, not old malformed history
ok - routine task and fleet no-change outcomes stay stored and silent captain outcomes are refused
ok - startup replay cannot advance the cursor across an unrendered captain outcome
ok - malformed and ahead-of-store cursor state fail closed before any outcome can be skipped
ok - cursor advancement refuses to legitimize an ahead processed marker
ok - middle sequence conflicts fail closed for every store read and append
ok - outcome lookup returns exact sequence rows and distinguishes missing receipts
ok - outcome stores require terminated single-line JSON records
ok - the processed marker is sequence-bound, never ahead of the read cursor, never backwards, and never adopts delivered history
ok - outcome store: present shows each routine row once and each captain row until it is acknowledged
ok - outcome store: present and unprocessed name each captain row's recorded age without writing it
ok - lease exclusivity, same-actor refresh, release, staleness, and sweep hold
ok - fm-control and fm-teardown refuse the other actor's live lease and pass through otherwise
ok - PR merge, local landing, and new-task spawn refuse the branch actor and spare main
ok - a home without a live branch lease takes no lock and clears leftover leases in any calling context
ok - an unmarked main honors a live branch lease across processes and ignores a previous session's
ok - a lease file makes an unmarked guard exclude a concurrent claim for the complete mutation
ok - a host home's unmarked main excludes the host's first claim for its whole mutation, and other homes take no lock
ok - lease liveness requires an exact valid session-lock pid
ok - concurrent stale-lease claims serialize so exactly one actor succeeds
ok - guard stale cleanup cannot race with or delete a newer lease claim
ok - lease guard excludes a concurrent actor for the complete mutation
ok - a claim naming the other actor fails loudly instead of silently impersonating it
ok - release commands authorize the caller and bulk release drops only that actor's leases
ok - the branch cannot force a teardown or bypass fm-control for a relaunch
ok - the away-posture record relocates the PR merge and a spawn under the spend cap to the branch, never local landing, and only while confirmed, valid, and away
ok - relocated branch spawn admits only already-queued dispatchable work, including on a manual-backend home
ok - the away spend cap is rechecked under the task-set lock so concurrent spawns cannot both publish
ok - the away spend cap counts only workers still spending, never finished or decision-parked ones
ok - the away spend cap keeps slots for workers still owing work and frees only stopped ones
ok - a quiet-mode record never caps a present captain's spawn, while the away record's cap still binds
exit 0
Evidence: fm-project-yolo-apply suite log

Source: fm-project-yolo-apply suite log

ok - a project switched to +yolo hands its live ship tasks the new merge authority, and nothing else
ok - a project switched off +yolo takes merge authority back from its live ship tasks
ok - a Gerrit project's live tasks never gain merge authority
ok - a registry posture that does not resolve changes no task
ok - named task ids limit the apply to those live ship tasks of the project
ok - a task under a lifecycle action is left untouched and named for a rerun
ok - a project's queued ship items carry its registered posture, and no other item changes
ok - a project switched off +yolo withdraws the posture from its queued ship notes
ok - named task ids limit the apply to those queued items
ok - a backlog that cannot be read leaves the apply incomplete, after the live tasks
ok - usage errors exit 2 and --help prints the usage
exit 0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed (3) ✅
  • ⚠️ bin/fm-spawn.sh:1545 - spawn_task_stopped_spending treats every state: parked and state: failed result as "stopped spending". In fm-crew-state.sh, though, parked covers any no-mistakes gate (awaiting_approval, fix_review, awaiting_agent), and that includes the common case where the crewmate itself owes the answer and keeps working (responding to review findings, running fixes). Only a gate carrying the ask-user: authority decision component (FM_GATE_HUMAN_DECISION, fm-classify-lib.sh:2474) is waiting on a human. In the same way, a run-step failed is reported whether or not the pane is busy, so a worker actively fixing a failed run is also skipped. Concrete case: --spend 5 with 5 ship workers whose pipelines are parked at review with auto-fix findings. The cap counts 0 working, so 5 more spawns go through and 10 workers spend at once while away. The away spend cap no longer bounds spend. Fix: count parked as stopped only when it comes from the status log (needs-decision) or carries the human-decision component. Treat run-step failed as stopped only when the pane is not busy, or keep counting it.
  • ⚠️ .agents/skills/project-management/SKILL.md:54 - The posture-change procedure only reaches live ship tasks. AGENTS.md section 7 has firstmate record each ship's yolo in the backlog item note at intake and pass it explicitly to the spawn. So queued ship items for the project (the dependent Ada steps in the 2026-10-19 incident) still carry yolo=off in their notes. Once their blockers clear they spawn with --yolo off, and their green PRs again wait for the captain, which is the same failure as intent cause 2. The remedy is a procedure/scope choice (re-resolve yolo from the registry at dispatch, or have the apply step also update queued notes), so it needs the author's decision.
  • ℹ️ bin/fm-spawn.sh:1543 - Finished workers whose agent or pane has gone (dead/missing endpoint, worktree gone) read as state: unknown in fm-crew-state.sh, so they still count against the cap (fail-closed by design). An old idle scout whose report was delivered but whose agent exited, for example after a backend restart, keeps holding an away slot. Part of the 'old idle task records' in the incident could still fill the cap. Worth confirming that this fail-closed trade-off is intended.
  • ℹ️ bin/fm-spawn.sh:1563 - Every away spawn now runs fm-crew-state.sh serially for every non-secondmate record, each bounded at 15s (no-mistakes status, backend probes). With around 16 records, one spawn can take tens of seconds, or minutes in the worst case. It is acceptable because it runs only while away and before any lock is held, but stopping early once live reaches the cap would bound it.

🔧 Fix: Tighten away spend cap and apply yolo to queued ships
3 issues (2 warnings, 1 info) still open:

  • ⚠️ bin/fm-spawn.sh:1578 - The F3 fix lets a record whose tmux/herdr endpoint is proven gone free its away slot. spawn_refuse_if_away_spend_cap still exempts every relaunch ([ &#34;$RELAUNCH&#34; -ne 1 ] || return 0), and its comment says a relaunch "replaces a worker that already counts". That stops being true once dead-endpoint records no longer count. Concrete case: --spend 5, five ship workers on tmux, the tmux server dies (a definitive no-server reads missing). All five read as gone, so live=0 and five fresh spawns are admitted. firstmate then recovers the original five through fm-control.sh relaunch (fm-spawn --relaunch), which skips the cap, so 10 workers spend while away. The cap no longer bounds concurrent spend. The smallest remedy is to have a relaunch of a record that currently reads as stopped (dead endpoint) count against the cap, or refuse it. That changes when relaunch is refused, so the remedy needs the author's decision.
  • ⚠️ tests/fm-branch-supervision.test.sh:1691 - test_away_spend_cap_holds_slots_for_workers_still_owing_work checks only the combined counts (3 working, 3 stopped) across six fixtures, so a wrong classifier with the same totals still passes. For example, the pre-fix behavior for parked and failed (every parked frees, every failed run-step counts) would free ship-gate and ship-asked and keep ship-fixing and ship-failed. Together with scout-gone freed and scout-flaky counted, that again gives live=3 and stopped=3, so the test passes even though an ordinary gate lost its slot and an idle failed run kept one. The fix-round instructions asked for one behavior per case (an ordinary gate holds a slot, a human ask-user gate does not, a busy failed run holds one). Fix: assert per fixture, for example by running the spawn once per fixture (or per pair) with --spend 1 and checking refused or admitted. Then each classification is proven on its own.
  • ℹ️ bin/fm-project-yolo-apply.sh:250 - apply_queued reads the item with show, checks state=queued, then writes with update --body-file, all without a backlog lock. A dispatch that starts the item in between gets its now in-flight note rewritten, and the spawn may already have taken the old posture. The window is narrow, and the rerun semantics plus the live-task pass cover most of it. Noted only.

🔧 Fix: Count stopped-worker relaunches against away cap, split cap tests
2 issues (1 warning, 1 info) still open:

  • ⚠️ bin/fm-spawn.sh:1619 - The new relaunch cap classifies the task at the moment fm-spawn --relaunch runs. But fm-control's do_relaunch (bin/fm-control.sh:1000-1011) always stops the old agent (do_exit) before it calls fm-spawn --relaunch. By then fm-crew-state reports tmux:dead/missing as backend target gone, so spawn_task_stopped_spending treats every real relaunch as stopped. The exemption for 'a relaunch of a task that still counts' therefore never applies on the supported path, and the branch can only relaunch through fm-control. Concrete case: away is entered with cap 4 while 5 workers are working (or some states are unreadable and count). firstmate relaunches a stuck working worker X. fm-control kills X's agent, X now reads as stopped, the other workers give live=4>=cap, and fm-spawn refuses. The rollback then reports 'agent stopped but relaunch did not reach replacement launch; no agent is running'. A working worker was destroyed instead of being replaced. Before this fix round, relaunch was always exempt. The test calls fm-spawn --relaunch directly against a live fixture, so it does not model the real kill-then-relaunch order. The remedy is to classify the task (or run the cap check) in fm-control before do_exit and pass that verdict to fm-spawn. That is cross-script work, so it needs the author's decision.
  • ℹ️ bin/fm-spawn.sh:1726 - The relaunch cap check runs only once, before any lock: the recheck at line 1726 sits inside the RELAUNCH=0 path, and relaunch takes only its per-task control lock. Two concurrent relaunches of different stopped tasks, or a relaunch racing a fresh spawn whose recheck reuses the cached stopped-id set, can both be admitted with one slot left, so the count goes over the cap. The window is narrow because firstmate normally drives these one at a time. Noted only.

🔧 Fix: Restore relaunch exemption from away cap, document dead-backend edge
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-branch-supervision.test.sh (includes test_away_spend_cap_counts_only_working_workers, test_away_spend_cap_holds_slots_for_workers_still_owing_work, test_away_spend_cap_is_rechecked_under_the_task_set_lock, test_quiet_record_never_caps_a_present_captains_spawn) - all ok, exit 0
  • bash tests/fm-project-yolo-apply.test.sh - all 11 cases ok, exit 0
  • Incident replay replay-away-cap.sh against base 5d67f6e bin/ (via git archive) and fixed bin/: away entered with --spend 4, 4 finished scout records + 1 working worker, then 4 sequential fm-spawn.sh queued-N calls
  • Incident replay replay-yolo-switch.sh: ada registered +yolo, 3 live ada ship tasks with yolo=off, queued ada/other ship items, then fm-project-yolo-apply.sh ada with before/after meta and data/backlog.md
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…osture changes

- fm-spawn.sh: the away spend cap counts only ordinary workers whose
  current state (fm-crew-state.sh) is still working; done, failed, and
  decision-parked tasks waiting on a merge, cleanup, or decision hold no
  slot. Unreadable state still counts, and the recheck under the task-set
  lock reuses the first reads and recounts records.
- fm-project-yolo-apply.sh: new guarded command that applies a project's
  registered +yolo posture to its live ship tasks in this home, under each
  task's lifecycle and meta locks; gerrit stays off, an unresolvable
  registry entry changes nothing, and merge gates are unchanged.
- Docs: --spend now reads as concurrent working workers; project-management
  says to run the apply command after changing a project's posture.
- Tests: finished workers do not consume away slots; live tasks follow a
  changed project posture.
@demy00

demy00 commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Worker notes

Skills used: firstmate-coding-guidelines, tdd

Regression tests fail with the fix reverted

Final head 374d83d with bin/fm-spawn.sh restored to base 5d67f6e and bin/fm-project-yolo-apply.sh removed:

tests/fm-branch-supervision.test.sh:
not ok - spend-cap refusal lost its count (missing: 'caps concurrent workers at 2 and 2 ordinary worker(s) are still working')
tests/fm-project-yolo-apply.test.sh:
not ok - applying the registered posture: expected exit 0, got 127

Before the first commit, the original spend-cap test against base failed with not ok - finished workers still consumed away slots (unexpected: 'caps concurrent workers'), and the base refusal read "caps concurrent workers at 2 and 4 ordinary task(s) are live". With the fix both suites pass (logs above).

Decisions taken through the review gate

  • F1/F2/F3 and R2-2 fixed as recorded in the Review section above.
  • R2-1 (counting relaunches of stopped records against the cap) was applied, then withdrawn after R3-1 showed fm-control.sh kills the old agent before fm-spawn --relaunch, so a full cap would destroy a working worker instead of replacing it. Every relaunch stays exempt; the cap comment documents the known edge (a dead backend can let fresh spawns plus later relaunches exceed the cap).

Noticed

  • A local bin/fm-test-run.sh --changed run had 8 failing scripts, none caused by this diff. Six fail identically on unmodified base: fm-muse-harness, fm-harness-precedence and fm-calm-claude-mod (harness ancestry and plugin shape checks under a Claude parent process), fm-afk-return (evidence publication), fm-teardown-endpoint-safety (control window), and fm-backend (zsh fm_backend_source herdr does not load the adapter). fm-backend-herdr-presentation-e2e and fm-control-relaunch never reach the changed code (no away record; relaunch returns early). All 19 CI checks pass.
  • This repo has no CHANGELOG.md, and adding one would need a new audience entry in docs/documentation-audiences.json, so none was created here.
  • The queued-note rewrite in fm-project-yolo-apply.sh runs without a backlog lock (review R2-3); a dispatch landing in between can keep the old posture, and a rerun covers it.

Better idea

  • One posture-setting command that edits a project's +yolo in data/projects.md and applies it to live tasks and queued notes in the same step, so the registry and the running fleet can never drift.

Also tidied

  • Nothing outside the change: no unrelated cleanup was needed in the touched code.

@demy00
demy00 merged commit 61c250a into main Oct 20, 2026
19 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