Skip to content

feat(bin): refuse a fresh worker spawn whose brief names no skills - #26

Merged
demy00 merged 3 commits into
mainfrom
feature/fm-skill-spawn-gate-r2
Nov 10, 2026
Merged

demy00 merged 3 commits into
mainfrom
feature/fm-skill-spawn-gate-r2

Conversation

@demy00

@demy00 demy00 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Intent

The captain asked for a review of skill usage across recent worker PRs. Firstmate then proposed building the firstmate-side recommendations from that review (recs 1, 6 and 9: refuse to start a worker whose instructions name no skills, check Docker disk, tools and credentials before starting a worker, and script the weekly skill table). The captain's answer, 2026-10-16: "build the firstmate improvements."

This task is recommendation 1: make skill selection a spawn gate.

Recommendation 1, as the review wrote it: workers load the skills their instructions name (132 of 132 named skills loaded, against 46% without a list), but the skills section was missing from every brief over several days and selector errors were swallowed. Change: bin/fm-spawn.sh refuses a ship or scout brief without a # Required skills section, unless --no-skills "<reason>" is given. bin/fm-skill-select.sh: when the selector model scores no skill above the floor, fall back to the repository's own skills table (a "Skills to load" table in the project's AGENTS.md); it should exit non-zero on usage errors before anything spawns. Batch scripts call the same gate. Where: bin/fm-spawn.sh, bin/fm-skill-select.sh, and the AGENTS.md skill-selection line.

Captain 2026-11-09, releasing the held firstmate fixes: "5 yup" (start them, two at a time).

What Changed

  • bin/fm-spawn.sh now refuses a fresh ship or scout spawn if the brief has no nonempty # Required skills section. The new --no-skills "<reason>" flag skips the check and saves the reason as no_skills= in the task record. The flag is refused in four cases: when the brief already names skills, on --secondmate, on --relaunch, and in batch spawns. Relaunches are never gated.
  • bin/fm-skill-select.sh has a new fallback status. It falls back when no skill scores at or above the 0.8 floor, when the selector is off, or when it errors. In those cases it reads the installed skills named in the Skills column of the "Skills to load" table in the project's AGENTS.md, without a network call, and --apply writes them into the brief. Usage and configuration errors, such as a missing flag or an unreadable brief, still exit 2, so a chained spawn never starts.
  • Updated AGENTS.md, docs/configuration.md, docs/scripts.md, the bin/fm-brief.sh header and CHANGELOG.md to describe the gate and the fallback. bin/fm-live-lab.sh and the test fixtures and spawn tests now pass --no-skills or write a skills section. New tests cover the gate, the opt-out refusals and the AGENTS.md fallback.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The spawn gate, the --no-skills opt-out (relaunch keeps it through preserve_relaunch_meta, batch spawns go through the same per-task gate) and the fixer's off/error AGENTS.md fallback all trace correctly; the fallback stays local, does not run before candidates exist or after a write, and is covered by behavioral tests.

Testing

Ran the focused fm-skill-select, fm-task-delivery and fm-spawn-orca-worktree suites; all passed. Ran the CLI by hand with no API key on an isolated home. It printed the off line, reported status: fallback, and wrote a # Required skills section listing tdd and typescript from the project AGENTS.md table into the brief. A missing brief and a missing --project each exited 2. Saved the transcript and the spawn-gate test lines as evidence.

Evidence: fm-skill-select off-path fallback and usage-error CLI transcript

Source: fm-skill-select off-path fallback and usage-error CLI transcript

$ cat projects/webapp/AGENTS.md
# webapp
## Skills to load
| Kind of work | Files | Skills |
| --- | --- | --- |
| Any fix or behaviour change | | `tdd`, `typescript` |
| Docs only | `**/*.md` | none |

$ fm-skill-select.sh brief.md --project webapp --harness claude --apply   # no TYPESAFE_API_KEY
skill-select: off (TYPESAFE_API_KEY absent from the environment and /tmp/demo/home/.env)
skill-select:
  status: fallback
  reason: TYPESAFE_API_KEY absent from the environment and /tmp/demo/home/.env; using the Skills to load table in the project AGENTS.md
  skills: tdd typescript
  brief: written
exit=0

$ cat brief.md
# Task
## Captain's intent
Fix the flaky login test.

## Firstmate spec
Reproduce first.

# Required skills
Load each of these skills before any other task work (after the Setup isolation check), with your tool's skill mechanism or by reading the SKILL.md at the path shown, and follow it throughout this task:
- `tdd` (`/tmp/demo/user/.claude/skills/tdd/SKILL.md`)
- `typescript` (`/tmp/demo/user/.claude/skills/typescript/SKILL.md`)
If one of them cannot be loaded, append `blocked [at=<epoch>]: required skill <name> cannot be loaded` and stop.
List the skills you loaded in your final report or PR description.

# Setup
x

$ fm-skill-select.sh missing.md --project webapp --harness claude --apply
error: brief file not readable: /tmp/demo/missing.md
exit=2

$ fm-skill-select.sh brief.md --harness claude --apply   # no --project
error: --project or --project-dir required
exit=2
Evidence: fm-spawn skills-gate test results

Source: fm-spawn skills-gate test results

ok - fm-spawn: a fresh ship or scout brief must name skills or record an explicit --no-skills reason
ok - fm-spawn: --no-skills records its one-line reason in the task record

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ CHANGELOG.md - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ bin/fm-skill-select.sh:411 - The AGENTS.md "Skills to load" fallback only runs after the selector answers with status none. It never runs on an off path (no TYPESAFE_API_KEY, a never-send match, or no candidates, line ~411) or on an error outcome. Before this change that was harmless because skill selection was opt-in. Now fm-spawn.sh refuses any brief without a # Required skills section. Concrete case: a home with no TYPESAFE_API_KEY runs fm-skill-select.sh --apply on a project whose AGENTS.md lists tdd. It prints skill-select: off, writes nothing, and the spawn is refused. Firstmate then has to --set by hand, even though the project's own table could have supplied the skills locally with no network. This matches the intent's literal wording (fall back when the model scores none above the floor). Applying the fallback on off/error as well would widen that scope, so the author should decide.
  • ℹ️ bin/fm-spawn.sh:4379 - The skills gate runs after the project-capacity admission check. A brief with no skills section on a full project is first told deferred (backlog item stays queued), and is only refused for the missing skills when it is dispatched again later. Moving the gate ahead of the capacity check, next to the other brief-content checks, would report the actionable refusal first. Low impact.

🔧 Fix: Use AGENTS.md skills fallback on off and error outcomes
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-skill-select.test.sh (covers the fallback on none, off with no key, off on a never-send match, and HTTP 500 error; also the usage errors that exit 2)
  • bash tests/fm-task-delivery.test.sh (fm-spawn gate: refusals, --no-skills reason recorded in the task record, refusals for a contradicting flag, secondmate, relaunch and batch)
  • bash tests/fm-spawn-orca-worktree.test.sh (spawn suite changed by this branch)
  • Manual: ran bin/fm-skill-select.sh brief.md --project webapp --harness claude --apply without TYPESAFE_API_KEY on an isolated HOME and FM_HOME; the project AGENTS.md has a Skills to load table. Then ran the same command with a missing brief, and again without --project.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Skills used

firstmate-coding-guidelines, firstmate-self-repo, pipeline.

Also tidied

  • bin/fm-brief.sh header and docs/scripts.md no longer call the # Required skills section optional or opt-in, since a fresh spawn now requires it.
  • Kept main's existing CHANGELOG.md entry in docs/documentation-audiences.json instead of the earlier patch's duplicate.

Noticed

These test files fail identically on clean main (4123a5eb) and are not touched by this change; each needs its own fix:

  • tests/fm-muse-harness.test.sh: "fm-harness.sh under process 'muse-bin-0.1.0-R708.1' reported '', expected muse"
  • tests/fm-hermes-harness.test.sh: "NUL argv identity lost when names/ps args are blind"
  • tests/fm-control.test.sh: "Hermes gateway diagnostic missing (missing: 'gateway')"
  • tests/fm-cursor-harness.test.sh: "a real cursor-agent ancestor must detect cursor, got ''"
  • tests/fm-gotmp.test.sh: "teardown exited non-zero with a valid tasktmp"
  • tests/fm-remote-secondmate-lifecycle-e2e.test.sh: "the exited rex agent was not projected dead from its own host"

All six were run locally on macOS; they may be platform-specific since CI is green.

Better idea

  • The review's info finding on bin/fm-spawn.sh (the skills check runs after the project-capacity check, so a full project first defers a skill-less brief and only refuses it on a later dispatch) was not applied in this run. Moving the check next to the other brief-content checks would report the actionable refusal first; it is a small follow-up.

A fresh ship or scout spawn now refuses a brief with no # Required skills
section unless --no-skills "<reason>" records why in the task record.
fm-skill-select falls back to the project AGENTS.md Skills to load table
when no skill clears the floor. Test briefs gain a skills section.
…ilure only reports it. I couldn't run the hc test locally because `herdr-core` isn't installed here, so the fix is unconfirmed until CI reruns. - **Behavior tests (herdr-core):** `tests/fm-backend-hc-appdetect-smoke.test.sh` writes its own worker brief, and that brief had no `# Required skills` section. This PR's new spawn check in `bin/fm-spawn.sh` (around line 4380) correctly refused it. This PR had already updated the other spawn tests' briefs, but this one was missed. - **Fix:** added `# Required skills` with `- tdd` to the test's brief, the same change this PR made to `tests/fm-backend-autodetect-smoke.test.sh`. Both spawn cases in that test use this brief, so both are covered. The spawn check itself is unchanged. - **Full suite:** it fails whenever any lane fails, so it should pass once the hc lane does. No separate fix needed. - **Checked locally:** `bash -n` passes. Running the test only prints "skip: hc not found". The spawn check passes a brief as long as the section has content, which this one now does
@demy00
demy00 merged commit beeeade into main Nov 10, 2026
25 checks passed
demy00 added a commit that referenced this pull request Nov 13, 2026
…ixed 3 root causes in 4 files and verified each one locally. - **Test coverage guard, and tests/fm-test-run.test.sh (parallel 2), which runs the same guard.** - Invariant: no more than 15% of portable serial scripts may lack a duration hint. - Cause: the merge brought in 2 upstream tests with no hint, `fm-remote-inherit-generation` and `fm-supervision-host-herdr-live-e2e`. That moved the count from 44 to 46 out of 306, which is just over 15%. - Fix: added serial hints in `bin/fm-test-run.sh` for both: 3436 ms and 132 ms. These are their passing Ubuntu `FM_TEST_END` timings from this PR's own CI run, 43525853047. - Recorded where the numbers came from in `docs/fm-test-portable-shards.md`. - The guard now reports ok: 44 scripts without a hint, and the largest shard is 1198585 ms against a 1200000 ms budget. - **Serial 8: tests/fm-lane-capacity-integration.test.sh.** - Invariant: every brief for a fresh spawn must have a `# Required skills` section. This is the fork's gate from #26. - Cause: this test is new from upstream, and its `write_brief` fixture had no such section, so `fm-spawn` refused with exit 1. - Fix: added `# Required skills` with `- tdd` to the fixture, the same way `tests/fm-project-capacity.test.sh` does. The one other place this test writes a brief already gets the fix, because it goes through `write_brief`. - **Serial 1: tests/fm-gotmp.test.sh, "teardown exited non-zero".** - Invariant: each fake root's `bin/` must hold every lib that teardown sources. - Cause: the fork's `fm-dod-lib.sh` sources the fork-only `fm-task-branch-lib.sh`, and teardown also reaches the `fm-supervision-engine-lib.sh` lazy source in `fm-lease-lib.sh`. Neither file was linked into the upstream test's fake roots. - Fix: added symlinks for both libs in both fake-root builders in that file. - Other tests that use `fm-dod-lib` source it from the real `bin/` and passed in CI. - **Full suite** was only the roll-up of the failed jobs. Verification, run locally: - `bin/fm-test-run.sh --check-coverage`: ok. - `tests/fm-test-run.test.sh`, `tests/fm-gotmp.test.sh` and `tests/fm-lane-capacity-integration.test.sh`: all pass. Both of the last two failed before the fix. - shellcheck and `git diff --check`: clean
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