Skip to content

fix(bin): only claim a task's PR from meta or a ready-signal line - #4148

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-inactive-reconcile-prose-pr
Sep 11, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
karotkriss:fm/fm-inactive-reconcile-prose-pr

Conversation

@karotkriss

@karotkriss karotkriss commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Captain, 2026-09-10: the effort-impact triage (data/fm-issue-triage-effort-impact-2/report.md) picked three upstream issues and the captain ruled "pick 3 issues and get them done in the firstmate repo": ship this one as a PR to kunchenguid/firstmate. The hard rule from that triage: touch NO hot file (bin/fm-spawn.sh, bin/fm-test-run.sh, bin/fm-teardown.sh, bin/fm-watch.sh, bin/fm-bootstrap.sh, bin/fm-brief.sh, bin/fm-wake-lib.sh, tests/fm-brief.test.sh, tests/fm-teardown.test.sh, docs/scripts.md, docs/configuration.md, AGENTS.md, docs/architecture.md), add no new script and change no documented interface, so the PR cannot deadlock on rebases the way #2839 did. Load firstmate-coding-guidelines before editing. The upstream repo requires the no-mistakes attestation on every PR, and its "Behavior portable parallel" shards time out at their 10-minute cap until #4123 merges; if that shard is the only red check, close the gate on the evidence that its tests passed and say so in the PR. PR body: "Fixes #" lines, the reproduction, and the test evidence. No co-author. This pick: upstream issue #4099. In bin/fm-inactive-reconcile.sh, pr_for_task (around lines 315-326) reads meta pr= first, then scrapes a PR URL from the preferred line, then falls back to grepping the WHOLE status log with tail -1, so any PR URL a worker ever mentioned in prose, including a scout citing someone else's PR, becomes "the task's delivered PR" in the parent-channel terminal report (embedded as pr= around lines 331-337). Task kind is available in the same script (around line 475) for a scout carve-out.

What Changed

  • Tightened pr_for_task in bin/fm-inactive-reconcile.sh so a task's delivered PR comes only from the recorded pr= meta field or a preferred terminal line in a mode's ready-signal shape (done: PR <url> / done: PR <url> checks green); removed the fallback that grepped the whole status log with tail -1, so a PR URL merely mentioned in prose is never reported as the delivery.
  • Added a scout carve-out: pr_for_task returns nothing for a kind=scout task, so a scout citing someone else's PR never surfaces one in the parent-channel terminal report. Dropped the now-unused <status> argument at both call sites.
  • Added test_pr_field_requires_recorded_pr_or_ready_signal_line and updated the existing ledger-delivery test to assert the new done: PR <url> shape.

Risk Assessment

✅ Low: A tightly scoped fix to a single shared helper that stops prose-mentioned PR URLs from being claimed as deliveries; it matches the DoD-instructed done-line shapes exactly, both call sites are correctly updated, no forbidden hot files are touched, and the change conforms to the authoritative intent.

Testing

Ran the smallest relevant suite, tests/fm-inactive-reconcile.test.sh, which exercises the reconcile pipeline end-to-end and asserts the actual parent-channel terminal report content rather than source text. All tests pass on the target commit. I confirmed the new test is a true regression by running it against the pre-fix base, where it fails exactly as upstream #4099 describes (a prose-mentioned PR URL and a scout URL both claimed as the delivered PR), then passes after restoring the fix. No screenshot applies: this is a shell/CLI status-log behavior change with no rendered UI surface; the evidence is a CLI before/after transcript.

Evidence: pr_for_task provenance before/after transcript

Source: pr_for_task provenance before/after transcript

BEFORE FIX (base 869ae90): not ok - a PR mentioned only in prose was claimed as the delivery: done [...]: child prose done: cleanup finished pr=https://example.test/other/repo/pull/33 ... (scout lookout line got pr=.../pull/1) AFTER FIX (target 33727ac): ok - pr= requires the recorded PR or a ready-signal terminal line, and never a scout

=== fm-inactive-reconcile pr_for_task provenance: end-to-end behavior ===

Bug (upstream #4099): pr_for_task scraped a PR URL from the whole status log,
so any URL a worker mentioned in prose (e.g. a scout citing someone else's PR)
became pr=<url> in the parent-channel terminal report.

--- BEFORE FIX (base 869ae90): new regression test fails ---
not ok - a PR mentioned only in prose was claimed as the delivery: done [key=child-outcome-lookout-done-773f04e9]: child lookout done: PR https://example.test/owner/repo/pull/55 pr=https://example.test/owner/repo/pull/1 mode=no-mistakes yolo=off
done [key=child-outcome-prose-done-2d18f95c]: child prose done: cleanup finished pr=https://example.test/other/repo/pull/33 mode=no-mistakes yolo=off

--- AFTER FIX (target 33727ac): same test passes; prose URL dropped, scout carries none, ready-signal keeps its PR ---
ok - pr= requires the recorded PR or a ready-signal terminal line, and never a scout

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-inactive-reconcile.test.sh on target commit 33727ac - all inactive reconciliation tests pass, including test_pr_field_requires_recorded_pr_or_ready_signal_line
  • Regression confirmation: replaced bin/fm-inactive-reconcile.sh with the pre-fix base (869ae90) version and reran the file - the new test fails, wrongly claiming a prose-mentioned URL (pr=.../pull/33) and a stray scout PR; restoring the fix makes it pass
  • Verified worktree left clean (git status --short empty) after tests
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@karotkriss

Copy link
Copy Markdown
Contributor Author

CI note: Behavior portable parallel 1 is the only non-green check. The runner cancelled it at the workflow's 10-minute cap (the known shard-timeout issue that #4123 addresses) rather than reporting any test failure. The job log shows every test that ran passing, then the cap cancellation arriving mid-suite:

FM_TEST_END 2026-09-10T13:15:13Z tests/fm-test-run.test.sh exit=0 duration_ms=91558 gate_skip=false
FM_TEST_END 2026-09-10T13:15:15Z tests/fm-composer-ghost.test.sh exit=0 duration_ms=2125 gate_skip=false
FM_TEST_END 2026-09-10T13:15:21Z tests/fm-grok-harness.test.sh exit=0 duration_ms=6564 gate_skip=false
2026-09-10T13:17:53.0934284Z ##[error]The operation was canceled.

All 6 test files that completed in the shard exited 0 (278 passing assertions, zero failures). The cancellation cut the run mid tests/fm-lint.test.sh, before the suite's final summary line could print, so no FM_TEST_SUMMARY exists for this job. The test file changed by this PR, tests/fm-inactive-reconcile.test.sh, ran in a different shard, which is green. Full run: https://github.com/kunchenguid/firstmate/actions/runs/34480703876

@kunchenguid

Copy link