Skip to content

fix(bin): refuse spawn into a project with an unborn HEAD - #6987

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
Azd325:fm/firstmate-unborn-head-spawn-refusal
Oct 18, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
Azd325:fm/firstmate-unborn-head-spawn-refusal

Conversation

@Azd325

@Azd325 Azd325 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • bin/fm-spawn.sh now refuses a fresh spawn when the project is a git repository whose HEAD has no commit. It exits 1 with an error that suggests git commit --allow-empty. Relaunches and secondmate spawns are not affected.
  • .agents/skills/project-management/SKILL.md now tells the captain that a newly created local project needs a first commit before spawn can dispatch work into it.
  • tests/fm-spawn-worktree-settle.test.sh adds a test for the refusal. The existing spawn fixtures (fm-self-repo-role, fm-spawn-batch, fm-task-delivery) now make a first commit so they pass the new guard.

Risk Assessment

✅ Low: The change adds a narrow early guard (only for a fresh ship or scout spawn into a git repository whose HEAD does not resolve), adds one doc line, and gives the fixtures a first commit. The round-1 fix (git_commit in the consent-foreign fixture) is correct and minimal, and the new regression test uses an independent oracle and fails without the guard.

Testing

I ran the real bin/fm-spawn.sh against a git-init'd project with no commit through the existing settle test harness. Spawn refused at once, named the unborn HEAD and the remedy, published no task metadata, and made no commit. The three suites whose fixtures needed a first commit pass. With the guard disabled, the regression test fails with 'expected exit 1, got 0'. I restored the file afterwards. I did not drive a Herdr or tmux lab. The harness-level test ran the real script, so I judged that enough.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Spawn into a git-init'd project with no commit is refused at once, naming the unborn HEAD and the commit remedy ✅ pass live tests/fm-spawn-worktree-settle.test.sh: 'ok - a project with an unborn HEAD is refused at once with its cause named'
Adversarial: refusal publishes no task metadata and spawn makes no commit in the project ✅ pass live The same test asserts no state/<id>.meta file and an empty git rev-list --all.
Guard is load-bearing: with the guard disabled the regression test fails ✅ pass live Mutation run output: 'not ok - spawn into a project with no commit should be refused: expected exit 1, got 0'.
Fixture projects with a first commit still spawn through the self-repo role, batch and delivery paths ✅ pass live fm-self-repo-role, fm-spawn-batch and fm-task-delivery all passed with exit 0.

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 tests/fm-self-repo-role.test.sh:610 - A spawn test still uses a project fixture with no commit, and the new guard breaks it. In the consent case spawn-consent-b4, $TMP_ROOT/consent-foreign is made with a bare git init -q. The test then runs the real bin/fm-spawn.sh against it and checks assert_not_contains &#34;$out&#34; &#34;spawn refused&#34; (line 615). The new unborn-HEAD guard (bin/fm-spawn.sh:3506) runs before the self-repo role gate (bin/fm-spawn.sh:~3742). It exits with error: spawn refused: project ... has no commit yet. So the assertion fails and the suite goes red. The guard also masks what the case means to prove: that the role gate lets a foreign project pass. The user intent says: "tests whose fixture projects are created with a bare git init must give each fixture project a first commit instead of weakening the guard." Fix: after line 610, add git_commit &#34;$proj&#34; init. The file already defines git_commit at line 60. The other spawn fixtures with no commit (tests/fm-spawn-batch.test.sh:87,95 and tests/fm-task-delivery.test.sh:37) are already fixed. The role-check fixture at line 177 runs fm-role.sh and not spawn, so it needs no change.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Spawn into a git-init'd project with no commit is refused at once, naming the unborn HEAD and the commit remedy ✅ pass live tests/fm-spawn-worktree-settle.test.sh: 'ok - a project with an unborn HEAD is refused at once with its cause named'
Adversarial: refusal publishes no task metadata and spawn makes no commit in the project ✅ pass live The same test asserts no state/<id>.meta file and an empty git rev-list --all.
Guard is load-bearing: with the guard disabled the regression test fails ✅ pass live Mutation run output: 'not ok - spawn into a project with no commit should be refused: expected exit 1, got 0'.
Fixture projects with a first commit still spawn through the self-repo role, batch and delivery paths ✅ pass live fm-self-repo-role, fm-spawn-batch and fm-task-delivery all passed with exit 0.
  • bash tests/fm-spawn-worktree-settle.test.sh
  • bash tests/fm-self-repo-role.test.sh
  • bash tests/fm-spawn-batch.test.sh
  • bash tests/fm-task-delivery.test.sh
  • Mutation check: guard condition replaced with if false &amp;&amp;, settle test rerun, file restored
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325 — a fast, honest refusal instead of a misleading 60s isolation timeout is a real improvement. This is waiting on you (author), not the captain. I approved the fork CI runs (38032666724, 38032666729) after reading the diff (no workflow or secret surface).

VISION verdict (head c7de95e0 vs main fb75c1f): One captain — aligns (outcome named, no new noise). Authority — the bin guard aligns; the new skill sentence cannot tell (see 3). Scripts/judgment — aligns (exact check in script). Restart — aligns (read-only, before any record). Delegation with a spine — aligns (strengthens a refusal path). Vendor — aligns (plain git). Scope — aligns.
Contract-class: the fm-spawn.sh guard is restore (spawn into a fresh repo already fails; now it fails at once with the right cause). The skill line is cannot-tell.

Three things before this can land:

  1. Closing link is wrong. Closes #6954 would auto-close the project-less scout question, which this PR doesn't address. This matches Project creation leaves an empty repository, so every spawn into a new project fails with a misleading isolation timeout #5051 (empty repo → misleading isolation timeout; feat(bin): seed the first commit of a brand-new empty GitHub repo #1608 is the seeding half). Could you switch it to Refs #5051 (or Closes #5051 if you mean the precondition half)?
  2. Skill sentence. "make one initial commit before dispatching work" reads as firstmate committing into the project, which sits against the same file's "Do not create a commit merely because initialization ran" and VISION's "the first mate reads projects but does not change them". Dropping it (or phrasing it as "spawn refuses; tell the captain the project needs a first commit") keeps this a clean restore.
  3. Live validation is 0/3. When you get a chance, could you try one real spawn into a freshly git inited project and paste the refusal output, or re-raise through no-mistakes so live validation passes? No rush at all.