fix(#4670): bound the commit-claim window to the plan's own history (#4813)

* test(#4670): add failing-first coverage for the bounded commit-claim window

* fix(#4670): bound the commit-claim window to the plan's own history

The reconciliation measured plan_head_before..HEAD — a window that grows
with every later plan's task and SUMMARY commits plus execute-phase's own
phase-completion commit — so an honest plan flagged commit_claim_mismatch
as soon as anything landed after it (real project: claims 3/5/2 measured
20/10/5).

The executor now also records plan_head_after (HEAD at its measurement
moment, after the last task commit, before the SUMMARY commit), and
verify-work reconciles exactly against plan_head_before..plan_head_after
with a merge-base ancestry check; SUMMARYs without the anchor fall back to
the legacy warning path instead of an unsound BLOCKER. Both #3968 failure
modes (claimed commits never made; task commits lost) still block, driven
by the issue's own fixture scenarios.

Emitted-Drift-Ack-Growth: verify-work.md — reconciliation gains the bounded window and legacy fallback (#4670)
Emitted-Drift-Ack-Growth: gsd-executor.md — plan_head_after anchor documented in the measurement protocol (#4670)

* fix(#4670): name the history-rewrite case and keep the executor under its cap

Review findings: the BLOCKER enumeration named only the two #3968 causes,
so an honest plan whose recorded window was rewritten afterwards (rebase,
amend, cherry-pick) got a mislabeled diagnosis — the clause now names that
case with the manual-recount remedy. The executor's growth crossed the
LARGE-tier hard cap (49152), so the plan_head_after documentation is
compressed to the minimal capture + frontmatter write (verify-work.md
carries the semantics), the #2751 PROSE_ALLOWLIST entry is re-pointed at
the shifted line (#4670 moved it from 823 to 825), the compact-content
baseline is regenerated, and the changeset records the two un-established
edges (shared-base waves, subrepo ledgers).

Emitted-Drift-Ack-Growth: gsd-executor.md — plan_head_after anchor documented in the measurement protocol (#4670)

* docs(#4670): backfill changeset PR number

* docs(#4670): backfill changeset PR number

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-16 22:06:03 -04:00
committed by GitHub
parent 652796e903
commit 651511d1e3
6 changed files with 108 additions and 20 deletions

View File

@@ -183,18 +183,31 @@ instrument — the executor's own narration is never the last word. For each `*-
BASE=$(grep -oE '^plan_head_before: [0-9a-f]{7,40}' "$SUMMARY_FILE" | awk '{print $2}')
CLAIMED=$(grep -oE '^commits: [0-9]+' "$SUMMARY_FILE" | grep -oE '[0-9]+' || echo absent)
ACTUAL=$(git rev-list --count "${BASE}"..HEAD)
AFTER=$(grep -oE '^plan_head_after: [0-9a-f]{7,40}' "$SUMMARY_FILE" | awk '{print $2}')
```
- A `commits: absent` or `plan_head_before: absent` SUMMARY (pre-#3968 legacy) is reported as
a WARNING with the measured git state, not a mismatch.
- `ACTUAL == CLAIMED` is consistent. `ACTUAL == CLAIMED + 1` is ALSO consistent: the
SUMMARY/metadata commit itself lands after the executor measured, so exactly one
post-measurement commit is expected.
- Anything else is a **BLOCKER** — the phase must not read as done: real project evidence
(#3968) showed 14 plans declaring `commits: 1` with zero git activity, their code sitting
uncommitted and one `git reset --hard` from loss. Record it as `commit_claim_mismatch`
with both numbers and the SUMMARY path; a mismatch means either the executor narrated
instead of measuring or commits were lost after the fact — both require reconciliation
before the phase can pass.
- **Bounded reconciliation (#4670).** A SUMMARY carrying `plan_head_after:` (the executor's
HEAD at its measurement moment — after the last task commit, before the SUMMARY commit) is
reconciled against the plan's OWN window:
```bash
if git merge-base --is-ancestor "$AFTER" HEAD 2>/dev/null \
&& [ "$(git rev-list --count "${BASE}..${AFTER}")" = "$CLAIMED" ]; then
: # consistent
fi
```
Consistent → done. Anything else is a **BLOCKER** — `commit_claim_mismatch` with both
numbers and the SUMMARY path: commits claimed but never made (#3968), task commits lost
after the fact, or the plan's recorded window rewritten afterwards (a rebase/amend/cherry-pick
of those commits makes `$AFTER` a non-ancestor — recount that plan's commits manually
before treating it as a genuine mismatch). The unbounded `${BASE}..HEAD` count is NOT
evidence either way: it grows with every later plan's commits and execute-phase's own
phase-completion commit, so an honest plan would read as a mismatch (#4670).
- **Legacy fallback (#4670).** A SUMMARY with a base but no `plan_head_after:` (pre-#4670)
cannot be bounded to its own window — report the measured `${BASE}..HEAD` count as a
**WARNING** with the SUMMARY's task-commit list for manual counting. The old
`ACTUAL == CLAIMED` / `ACTUAL == CLAIMED + 1` tolerance was a guess that later plans'
commits defeat; it must never produce a BLOCKER on the unsound window.
</step>
<step name="extract_tests">