scrub_commit_message Factory-Account trailer is non-idempotent (#223 regression, red offline test on main) #231

Closed
opened 2026-10-15 10:13:11 +00:00 by matou-build-agent · 1 comment

Follow-up to #223 (which finished #200's Factory-Account: <fp> trailer and was closed by a concurrent session).

Symptom

tests/rehearsal-heal-lib-test.sh case 8b fails on origin/main as of cd6ecc9 ("8b: trailer duplicated on re-scrub") — a NEW offline red introduced by #223's close. rehearsal-heal-lib.sh's scrub_commit_message stamps a SECOND Factory-Account: trailer on a re-scrub / amend.

Root cause

scrub_commit_message always prefixes the message with rehearsal healer: . A word: value subject line is parsed by git interpret-trailers AS a trailer, so --if-exists addIfDifferent --trailer "Factory-Account: <fp>" appends the fingerprint into that same paragraph with no separating blank line:

rehearsal healer: fix #379
Factory-Account: abc123def456

On the next amend the existing trailer is no longer recognised as its own trailer block, so addIfDifferent adds it again → duplicate. Reproduced deterministically on git 2.43.0. The prepare-commit-msg HOOK is unaffected (its --in-place path blank-line-separates correctly for worker subjects); the bug is isolated to the scrub amend.

Fix (landed)

Stamp the trailer in scrub_commit_message by hand instead of via interpret-trailers: a grep -qi '^Factory-Account:' idempotency guard + an explicit blank line so the trailer is its own final paragraph. Robust to the rehearsal healer: prefix; same end result. tests/rehearsal-heal-lib-test.sh case 8b (already present, asserting idempotency) now passes — 34/34. Full offline suite's only remaining reds are the pre-existing #200/#202/#205/#225 env fp-keying / uutils-date ones.

Root change — reaches the running self-copy + consumers only at the next re-vendor + FACTORY_REF bump (GOTCHAS 4).

Follow-up to #223 (which finished #200's `Factory-Account: <fp>` trailer and was closed by a concurrent session). ## Symptom `tests/rehearsal-heal-lib-test.sh` case **8b** fails on `origin/main` as of cd6ecc9 ("8b: trailer duplicated on re-scrub") — a NEW offline red introduced by #223's close. `rehearsal-heal-lib.sh`'s `scrub_commit_message` stamps a SECOND `Factory-Account:` trailer on a re-scrub / amend. ## Root cause `scrub_commit_message` always prefixes the message with `rehearsal healer: `. A `word: value` subject line is parsed by `git interpret-trailers` AS a trailer, so `--if-exists addIfDifferent --trailer "Factory-Account: <fp>"` appends the fingerprint into that same paragraph with **no separating blank line**: ``` rehearsal healer: fix #379 Factory-Account: abc123def456 ``` On the next amend the existing trailer is no longer recognised as its own trailer block, so `addIfDifferent` adds it again → duplicate. Reproduced deterministically on git 2.43.0. The `prepare-commit-msg` HOOK is unaffected (its `--in-place` path blank-line-separates correctly for worker subjects); the bug is isolated to the scrub amend. ## Fix (landed) Stamp the trailer in `scrub_commit_message` by hand instead of via `interpret-trailers`: a `grep -qi '^Factory-Account:'` idempotency guard + an explicit blank line so the trailer is its own final paragraph. Robust to the `rehearsal healer: ` prefix; same end result. `tests/rehearsal-heal-lib-test.sh` case 8b (already present, asserting idempotency) now passes — 34/34. Full offline suite's only remaining reds are the pre-existing #200/#202/#205/#225 env fp-keying / uutils-`date` ones. Root change — reaches the running self-copy + consumers only at the next re-vendor + `FACTORY_REF` bump (GOTCHAS 4).
Author
Member

Close-report — landed, proven (ruled by agent under ADR 0174, veto anytime)

What landed: rehearsal-heal-lib.sh's scrub_commit_message now stamps the Factory-Account: <fp> trailer by hand — a grep -qi '^Factory-Account:' idempotency guard + an explicit blank line so the trailer is its own final paragraph — instead of git interpret-trailers, which mis-parsed scrub's mandatory rehearsal healer: subject (a word: value line) as a trailer and appended the fingerprint with no separator, duplicating it on the next amend.

Commit: 0805bd9 on main (cd6ecc9..0805bd9). The prepare-commit-msg hook was deliberately NOT touched — its interpret-trailers --in-place path blank-line-separates correctly for the worker/reconcile subjects it stamps (verified idempotent on amend), so the bug was isolated to the scrub amend.

Proof: bash tests/rehearsal-heal-lib-test.sh → OK: 34 cases (case 8b "trailer duplicated on re-scrub" was the red; now green). Full offline suite re-run: the only reds are the pre-existing claude-call-guards / limit-lib / session-runner ones (the #200/#202/#205/#225 env fp-keying + uutils-date families — red on the pristine tree too, confirmed by stashing all changes).

Ruling (ADR 0174): a two-way-door repair of a red offline test on main — one revertible edit to a root harness file, inert until re-vendor (GOTCHAS 4), with the regression test already present and now green. No one-way door.

Provenance: two standing sessions independently picked up #223; the elitebook session landed cd6ecc9 and closed #223 first. This session's parallel implementation was DISCARDED rather than landed (no duplicate work on main — the run-29782 lesson), and only this one-line idempotency regression it surfaced is carried forward here. Journal: docs/journal/2026-10-15-231.md.

## Close-report — landed, proven (ruled by agent under ADR 0174, veto anytime) **What landed:** `rehearsal-heal-lib.sh`'s `scrub_commit_message` now stamps the `Factory-Account: <fp>` trailer by hand — a `grep -qi '^Factory-Account:'` idempotency guard + an explicit blank line so the trailer is its own final paragraph — instead of `git interpret-trailers`, which mis-parsed scrub's mandatory `rehearsal healer: ` subject (a `word: value` line) as a trailer and appended the fingerprint with no separator, duplicating it on the next amend. **Commit:** `0805bd9` on `main` (`cd6ecc9..0805bd9`). The `prepare-commit-msg` hook was deliberately NOT touched — its `interpret-trailers --in-place` path blank-line-separates correctly for the worker/reconcile subjects it stamps (verified idempotent on amend), so the bug was isolated to the scrub amend. **Proof:** `bash tests/rehearsal-heal-lib-test.sh` → `OK: 34 cases` (case 8b "trailer duplicated on re-scrub" was the red; now green). Full offline suite re-run: the only reds are the pre-existing `claude-call-guards` / `limit-lib` / `session-runner` ones (the #200/#202/#205/#225 env fp-keying + uutils-`date` families — red on the pristine tree too, confirmed by stashing all changes). **Ruling (ADR 0174):** a two-way-door repair of a red offline test on `main` — one revertible edit to a root harness file, inert until re-vendor (GOTCHAS 4), with the regression test already present and now green. No one-way door. **Provenance:** two standing sessions independently picked up #223; the elitebook session landed cd6ecc9 and closed #223 first. This session's parallel implementation was DISCARDED rather than landed (no duplicate work on `main` — the run-29782 lesson), and only this one-line idempotency regression it surfaced is carried forward here. Journal: `docs/journal/2026-10-15-231.md`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#231
No description provided.