fix(609): scope the decisions edit token to the subject line or a trailer #614
Closed
timothy
wants to merge 6 commits from
fix/609-decisions-edit-token-scope into main
pull from: fix/609-decisions-edit-token-scope
merge into: :main
:main
:renovate/dotnet-monorepo
:renovate/meziantou.analyzer-3.x
:renovate/lucene.net
:renovate/sqlitepclraw.bundle_e_sqlite3-3.x
:renovate/cliwrap-3.x
:913-scripted-playout-401
:release/v26.15.0-notes
:issue-806-guard-populations
:scratch/767b-poisoned
:scratch/767b-control
:release/v26.14.0-notes
:release/v26.14.0
:docs/510-skill-logo-bug-policy
:fix/510-watermark-resolution-policy
:fix/629-verdict-classifier-falseopens
:fix/609-decisions-edit-token-scope
:issue-135-clear-to-none
:release/v26.12.0-notes
:fix/409b-lastscan-api-parity
:fix/401-updatechannel-mirror-422
:fix/327-playlist-rename-validation
:fix/410-scancancel-log-level
:fix/409-447-librariesscreen-neverscanned
:fix/338-zap-exit-code
:fix/367-plex-budget-message
:fix/310-debom-legacy-cs
:ci/604-lane-rebalance
:feat/388-design-mirror
:feat/247-test-ownership
:feat/247-primary-action
:feat/357-player-owned-playback
:feat/357-jellyfin-plugin-poc
:fix/289-mcp-hardening
:issue58-mcp
:feat/244-channels-extract
:ci/auto-bump-prod-compose
:feat/multi-rerun-collections-api
:feat/collections-api
:feat/quick-wins
:feat/185-docs-part2
:feat/140-collections-screen
:feat/146-channel-edit
:feat/147-classic-ui-link
:issue22-renovate-dashboard
:feat/91-cutover
:feat/63-composite-create
:feat/65-library-browse
:feat/85-epg
:feat/86-schedule-editor
:feat/109-dashboard-data
:feat/99-session-tracking
:fix/dockerfile-node-tag
:feat/59-spa-foundation
:docs/59-ui-redesign-brief
:feat/102-json-guide
:feat/111-schedule-durations
:feat/104-artwork-upload
:feat/103-media-sources-api
:feat/playouts-read-api
:feat/108-health-api
:feat/105-picker-list-endpoints
:issue-97-channel-state-api
:issue42-jellyfin-musicvideos
:issue46-rest-api-error-contract
:dependabot/nuget/ErsatzTV.FFmpeg.Tests/multi-d307a2e06f
:qsv-improvements
:hdr-vulkan-cuda-test
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1ef581403c |
fix(609): close round-5 test gaps and a prose misattribution
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 11s
PR Gates / Docs update reminder (pull_request) Successful in 14s
PR Gates / decisions lifecycle (pull_request) Successful in 19s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m23s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 29s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 6m20s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 21m10s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 21m57s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Fable's round-5 review ran the 16 tmp_path tests that no prior round could execute (16/16 pass) and mutation-tested every fix. Six of seven reverts were killed; one survived, which is finding 1. 1. The exact-arity refusal in `_token_armed` had ZERO coverage -- deleting it passed all 55 tests, because nothing fed malformed git-log output to that function. Now pinned by a test that stubs `_run` with 2-field and 4-field output and asserts refusal, plus a 3-field control proving the refusal is about arity rather than the token. Verified the new test kills the mutation. 2. `test_integration_separator_in_subject_cannot_inject` did not actually pin the NUL framing: with `\x1f` framing restored and the arity check kept, it still passed, because one or two injected separators break arity and get absorbed. Added a case with THREE separators, which restores a multiple-of-3 arity and would false-arm under that revert -- so it pins the framing itself. 3. The decision record attributed the "old git echoes the trailers atom" case to the arity check. Wrong: an echoed atom is one well-formed field, so arity cannot catch it -- that case is handled by the `git --version` capability probe. Corrected in the record. Not changed: review also noted subject matching is now case-insensitive, so `[DECISIONS-EDIT]` arms where the old substring check was case-sensitive. Deliberate and harmless -- arming still requires typing the token. |
||
|
|
990d32f31a |
fix(609): anchor and bound the git version probe
Both round-4 findings, both in the version regex introduced in round 3. Both reproduced against the old code and confirmed closed. 1. The regex was UNANCHORED, so the first dotted number anywhere in the output won. `wrapper 2026.1; git version 2.20.1` read as 2026.1 -> True, enabling trailer parsing on a git that cannot expand the atom, whose verbatim echo then reads as a non-empty trailer and FALSELY ARMS. Now anchored to the canonical `git version X.Y` prefix. 2. Digits were unbounded, so a pathological version string raised ValueError instead of returning the documented safe False -- Python refuses int() conversion of a literal over 4300 digits. Digits are now bounded to 5 each, plus a try/except that the bounded regex should make unreachable. Adds seven probe cases: the wrapper-prefix and multiline-shim strings, Apple git, an rc suffix, a three-digit major, and the 5000-digit pathological input. |
||
|
|
851dca2596 |
fix(609): close round-3 review findings
All four LOW; no HIGH remained. The subject_of fix from round 2 was confirmed
correct across every message shape and all 38 historical commits.
1. The old-git compat check was a VALUE sentinel: it blanked any trailer whose
value happened to equal the atom string, so a legitimate
`Decisions-Edit: %(trailers:key=Decisions-Edit,valueonly)` was silently
discarded. Replaced with a capability probe on `git --version` (>= 2.22).
Detecting by version instead of by sniffing output removes the collision
class entirely rather than narrowing it. Unknown/unparseable version resolves
to False -- trailers ignored, subject-only matching -- which is the safe
direction: a trailer-only token not arming is an annoyance, whereas reading an
unexpanded atom as a value would falsely arm and disable the guard.
2. The compat test never called `_token_armed`, so it pinned nothing -- deleting
the guard would have left it green. Replaced with three tests that drive the
real function through a stubbed `_run`, covering old git (trailers ignored),
modern git (trailer arms), a tokened subject surviving an unusable trailer,
and version-string parsing incl. unparseable input. Proven non-vacuous:
forcing the probe True makes the old-git test fail.
3. `_repo()` still ignored return codes from init/config/base-commit and never
checked that the base sha resolved, so a rejected base could leave it
returning ("", <root sha>) and negative range tests would pass vacuously. All
commands are now checked and the base sha is asserted to be a full 40 chars.
4. docs/decisions.md line 65 still said "append it, as every prior use does".
37 of 38 append; docs(434) is mid-subject.
|
||
|
|
aa4a8fb849 |
fix(609): close round-2 review findings
HIGH -- `subject_of` used `lstrip("\n")`, so it returned the first NON-EMPTY
line. `git commit --cleanup=verbatim` accepts a message that begins with a blank
line and `%B` returns it raw, so body prose on line 2 was promoted to "subject"
and armed the token. Now literally line 1: an empty first line yields "", which
arms nothing -- failing toward the guard running.
LOW -- the old-git compat guard was a PREFIX match (`startswith("%(trailers")`)
that also `continue`d before the subject was evaluated. So a legitimate trailer
value beginning with that text was discarded, and worse, a perfectly good tokened
SUBJECT was thrown away because of its trailer field. Now an exact match against
the full atom, neutralising only the trailer and leaving the subject honoured.
LOW -- docstrings still said every historical use "appends" the token. Of the 38
uses, 37 append and `docs(434)` is mid-subject.
LOW (plausible) -- the `_repo` test helper ignored every git return code, so a
rejected commit would leave HEAD at base and every negative assertion would pass
vacuously. Return codes are now checked and HEAD is asserted to have moved.
Adds a regression test for the verbatim leading-blank-line case and one pinning
the compat guard to an exact atom match.
|
||
|
|
243bec708d |
fix(609): close two false-arm holes found in cross-family review
Codex review of the first attempt found both, and both were in the git plumbing
that my unit tests never touched -- they only exercised the pure predicate.
1. HIGH: git's `%s` is the first PARAGRAPH, not the first line. It joins
consecutive non-blank lines with spaces, so
`fix: harmless subject`
`This explains [decisions-edit] on line two.`
came back as ONE line containing the token and armed it -- the exact
false-arm this change exists to prevent. The first line is now taken from
`%B` via `subject_of()`.
2. HIGH: the in-band `\x1f`/`\x1e` field separators were injectable. A subject
containing a literal `\x1f` was split at the wrong place and its tail read as
a trailer, arming the token. Framing is now NUL, which git forbids inside a
commit message and which therefore cannot be injected, with exact-arity
parsing (fields must be a multiple of three) that refuses to arm otherwise.
Also from the same review:
- Refuse to arm on a `%(trailers:...)` atom echoed literally by a git older than
2.22, which would otherwise read as a non-empty trailer (exit 0, so `_run`
returns it rather than None).
- Record corrected: 38 subject-tokened commits in ancestry, not "twenty"; and it
no longer claims a blanket fail-safe -- `_token_armed` failing is safe, but the
surrounding `_diff_findings` fails open earlier on an unresolvable merge-base,
skipping every check. That predates this change.
Adds 8 integration tests that drive `_token_armed` against a real throwaway git
repo -- the gap that let both defects pass. Verified non-vacuous by
reconstructing the old implementation in memory: it arms on both inputs, the new
one does not.
Note `--format` uses git's `%x00` escape, not a literal NUL: a NUL in argv raises
ValueError from subprocess, which broke every diff-engine test until fixed.
|
||
|
|
4596603020 |
fix(609): scope the decisions edit token to the subject line or a trailer
The token was armed by a bare substring match over every commit message in the
range, so a commit that merely DESCRIBED the mechanism armed it and skipped the
entire `if not token:` block -- all three rationale-rewrite comparisons (active
survivors, active->archive laundering, archive survivors). `removed` and `demoted`
still ran, so the job printed `decisions-validate: OK` while doing nothing. It
bit in PR#605, which had hand-resolved an append-vs-append conflict inside
docs/decisions.md -- precisely the operation the guard exists to police.
Now recognized in exactly two places:
* the commit SUBJECT line -- the established form. All twenty prior tokened
commits append it to the subject (or place it mid-subject, as docs(434)
does); none put it on its own line, so the obvious "own-line only" rule
would have broken every historical use.
* a `Decisions-Edit: <reason>` git trailer -- the forward-looking form, which
can carry a reason the bracketed marker cannot.
Fail-open posture unchanged: unresolvable git means the token reads unarmed, so
the guard still runs.
Verified by measuring the guard rather than reading a green check -- a positive
control over the real corpus across all three placements: no token fires (exit 1),
subject token suppresses (exit 0), body-only mention fires (exit 1). Plus an
end-to-end matcher test against a throwaway git repo covering the established
form, mid-subject placement, the trailer, a merge commit quoting a tokened PR
title, a multi-commit range, and an unresolvable ref.
fixes #609
|