fix(609): review fixes — exclude merge commits, unfold folded values, correct the fail-posture doc

Cross-family review (High + Medium + Low), all three reproduced before fixing:

High -- on a pull_request event actions/checkout lands on a synthetic merge commit whose
body the forge composes from the PR description, so a description ending in an example
marker armed a guard no author armed. Excluded merge commits from the range; merging main
into a PR branch is separately forbidden, so no author-written commit is skipped.

Medium -- a folded value (`no` + continuation ` yes`) was split into independent lines and
the continuation armed on its own, inverting the value the author wrote. Read with `unfold`
so the value is judged whole.

Low -- the module docstring promised fail-open while marker resolution deliberately fails
closed. The posture is right; the docstring was wrong. Documented as the one exception.

Both new negative controls verified red against the unfixed matcher. Decision record
amended to state the residual honestly rather than overclaim: a quoted example that is the
FINAL paragraph of an ordinary commit is a trailer by git's own grammar and does arm. What
the change buys is that discussing the marker can no longer disable anything.

fixes #609

Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-25 18:29:46 +02:00
co-authored by Claude Opus 5
parent c597c49f02
commit cc9481f541
3 changed files with 80 additions and 13 deletions
+19 -7
View File
@@ -4,8 +4,9 @@
Replaces the line-level append-only guard (ersatztv#303 H9) with lifecycle checks that preserve its
spirit — rationale is never silently rewritten or deleted; every history touch is deliberate and
reviewable. A `Decisions-Edit: yes` commit trailer is kept ONLY for rationale-prose edits; routine
lifecycle metadata writes are token-free. Fail-open on tooling trouble (missing refs, git errors,
parse issues), matching the old guard.
lifecycle metadata writes are marker-free. Fail-open on tooling trouble (missing refs, git errors,
parse issues), matching the old guard — with ONE deliberate exception: resolving the edit marker
itself fails CLOSED (`_edit_trailer_armed`), because a fail-open marker lookup is just #609 again.
"""
from __future__ import annotations
@@ -267,16 +268,27 @@ def _edit_trailer_armed(mb: str, head: str) -> bool:
marker must be an explicit yes, so a trailer written to *record that no edit was intended* can
never disable the guard — the ersatztv#609 failure mode, one abstraction level up.
Git errors return False (the guard stays ON), matching the rest of the fail-safe posture here:
a lost marker costs a contributor one clear error message, a lost guard costs silent history
rewrites in the one PR that most needed policing.
This is the one git helper here that deliberately does NOT fail open (see the module docstring):
on a git error it returns False, leaving the guard ON. A lost marker costs a contributor one
clear error message and a re-push; a lost guard costs a silent history rewrite in the PR that
most needed policing. Failing open here would reintroduce #609 through a different door.
`--no-merges` skips merge commits: on a `pull_request` event `actions/checkout` lands on a
synthetic merge commit whose body is composed by the forge, not by the author, so a trailer
parsed out of it was never a deliberate marker. Merging main into a PR branch is separately
forbidden (`.husky/pre-push` → `prepush-rebase-check.sh`), so no author-written commit is lost.
`unfold` joins RFC-822 continuation lines before the value is compared. Without it, a folded
`Decisions-Edit: no\\n yes` yields two lines and the continuation ` yes` arms the exemption on
its own — the value the author actually wrote is `no`.
"""
out = _run(["git", "log", f"--format=%(trailers:key={EDIT_TRAILER},valueonly)", f"{mb}..{head}"])
fmt = f"--format=%(trailers:key={EDIT_TRAILER},valueonly,unfold)"
out = _run(["git", "log", "--no-merges", fmt, f"{mb}..{head}"])
if out is not None and any(ln.strip().lower() in _EDIT_TRAILER_AFFIRMATIVE for ln in out.splitlines()):
return True
# Retired-form nudge: without it, a contributor using the pre-#609 habit gets a bare "prose
# changed" failure and no hint that the marker's FORM (not their intent) is what changed.
if _LEGACY_EDIT_TOKEN in (_run(["git", "log", "--format=%B", f"{mb}..{head}"]) or "").lower():
if _LEGACY_EDIT_TOKEN in (_run(["git", "log", "--no-merges", "--format=%B", f"{mb}..{head}"]) or "").lower():
print(
f"::warning::decisions-validate: the commit range carries the retired "
f"{_LEGACY_EDIT_TOKEN} marker but no '{EDIT_TRAILER}: yes' trailer — since ersatztv#609 "