Skip to content

fix(hooks): codex-gate-check.sh stale-certification loophole (#437)#438

Merged
BaseInfinity merged 2 commits into
mainfrom
fix/codex-gate-stale-certification
Jul 6, 2026
Merged

fix(hooks): codex-gate-check.sh stale-certification loophole (#437)#438
BaseInfinity merged 2 commits into
mainfrom
fix/codex-gate-stale-certification

Conversation

@BaseInfinity

Copy link
Copy Markdown
Owner

Summary

  • ROADMAP docs(v1.85.0): post-ship retrospective fixes for v1.84.0 #437: codex-gate-check.sh only checked .reviews/handoff.json's status field as a literal string — any number of commits after certification would sail through the gate on the same stale status forever. Proven live during v1.84.0: 2 real post-certification commits both passed the gate on a stale round-11 CERTIFIED handoff.
  • Fix: certification now records commit_sha (HEAD at cert time); the gate compares it to current HEAD and blocks a mismatch or missing field as stale (exit 2). Allows exactly one commit after certification, blocks the next until re-cert. CODEX_GATE_SKIP=1 unchanged as the escape hatch.
  • TDD: 2 new tests proven RED before the fix, GREEN after (191/191 hook tests, up from 189).
  • 3-round Codex cross-model review: round 1 caught a duplicate protocol copy in the wizard doc missing the instruction; round 2's mutation testing proved my first regression test had real slack and surfaced a third, separate flow-diagram copy also missed — rebuilt the test as a per-line check, proved it against all 3 mutation scenarios, round 3 CERTIFIED clean.
  • Incidental fix: a latent BRE-regex bug in tests/test-self-update.sh's multi-reviewer checks (bare ? is literal in basic regex, not a quantifier), exposed while trimming skills/sdlc/SKILL.md back under its char budget.
  • Version bump 1.85.0 → 1.86.0.

Test plan

  • test-hooks.sh — 191/191 (up from 189)
  • test-doc-consistency.sh — 53/53 (new per-line CERTIFIED/commit_sha check, proven against 3 independent mutations)
  • test-self-update.sh — 153/153
  • test-skill-graduations.sh — 6/6 (char budget)
  • test-workflow-triggers.sh — 170/170
  • Codex cross-model review — CERTIFIED (round 3)
  • CI green on this PR

A CERTIFIED/REVIEWED handoff.json status was checked as a literal string
with no freshness check -- any number of commits made after certification
would sail through the gate on the same stale status forever. Proven live
during the v1.84.0 release: 2 real post-certification commits both passed
the gate on a round-11 CERTIFIED handoff that was never re-issued.

Certification now records commit_sha (HEAD at cert time) in handoff.json;
the gate compares it to current HEAD and treats a mismatch -- or a missing
field, e.g. an old-format handoff.json predating this fix -- as stale
(exit 2, same as an uncertified commit). This allows exactly one commit
after certification and blocks the next one until re-cert.
CODEX_GATE_SKIP=1 remains the logged-justification escape hatch.

TDD: 2 new tests proven RED against the unmodified hook, GREEN after;
2 existing tests updated to real git-repo fixtures with a matching
commit_sha (191/191 hook tests green, up from 189).

3-round Codex cross-model review: round 1 caught a second, duplicate copy
of the review protocol in the wizard doc missing the commit_sha
instruction. Round 2's mutation testing proved the first regression test
(a whole-file count comparison) had real slack, and surfaced a third,
entirely separate flow-diagram copy that had also been missed. Rebuilt
the test as a per-line proximity check and proved it against all 3
mutation scenarios independently before round 3 certified clean.

Also fixes a latent bug in tests/test-self-update.sh's multi-reviewer
checks (bare ? treated as literal in basic regex, not a quantifier),
exposed while trimming skills/sdlc/SKILL.md back under its char budget.

Version bump 1.85.0 -> 1.86.0.
CI's test-cowork-drift.sh caught cowork/skills/sdlc/SKILL.md drifting
from the canonical skills/sdlc/SKILL.md -- the commit_sha instructions
added for #437 in the previous commit never got copied to this second
tracked location.

Byte-for-byte cp of content already certified in PR #438's round-3
review. Fast-tracked through a scoped 2-round Codex check (round 1
correctly flagged the fix wasn't actually staged yet; round 2 confirmed
staging + re-verified the diff-empty/tests-pass content).
@BaseInfinity BaseInfinity merged commit 586b781 into main Jul 6, 2026
4 checks passed
@BaseInfinity BaseInfinity deleted the fix/codex-gate-stale-certification branch July 6, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant