Skip to content

fix(pr-convention-policy): stop pinning the lockstep parser to declaration flags - #520

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/lockstep-regex-flag-tolerance
Sep 3, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/lockstep-regex-flag-tolerance

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No linked issue: found while driving #519, whose CI was red for a reason unrelated to its diff.

Summary

main is red on pr-convention-lockstep, and has been since 2026-09-02, on a gate that has not actually drifted. The check stopped being able to read the reusable and reported that as drift. This restores it.

Fix

parseGatePatterns matched the gate's regex declarations with a literal /i; terminator. melodic-software/ci-workflows commit 3e32b0a made CLOSING_KEYWORD global, /gi;, so every occurrence on a line can be classified. The match then failed and the check raised gate reusable: CLOSING_KEYWORD / NO_ISSUE_MARKER regex declarations not found, which reads as drift but is a parse failure.

Declaration flags were never part of the contract this check enforces. Only the pattern body is extracted, and both probes are rebuilt with "i" regardless, so pinning the flag set asserted an incidental detail of how the reusable happened to be written on the day the parser was authored. The matcher now accepts any valid flag set. Drift detection is unchanged and still functional: the extracted body is probed against every policy keyword and marker, so a keyword surviving only in a comment still fails.

Why main went red without anyone touching it: this repo's last CI run on main was 2026-09-02T06:04Z and the ci-workflows commit landed at 06:48Z, 44 minutes later. No run had observed it until #519 opened.

Verification

  • Reproduced on main's own tree before changing anything: node components/pr-convention-policy/lockstep-drift.mjs against live sources fails with the exact CI message.
  • With the fix, the same live run reports pr-convention lockstep: all copies and caller pins match policy.json and exits 0. That is the load-bearing check that no real drift was hiding behind the parse failure, so this is not a detector being loosened to hide a problem.
  • npm run test:pr-convention-lockstep: 14 tests, 14 pass.
  • Red under mutation, which this suite's design calls for: reverting only the parser change and re-running leaves 13 passing and fails exactly the new declaration flags are not part of the contract test.
  • The new test asserts the substantive properties rather than the message: a gi-declared gate still yields probes that match Closes #12 and No linked issue, the rebuilt probe is not global, and the extracted body is identical whichever flags were declared.

Two commits, deliberately. e11eb1c is mechanical Biome formatting plus three per-call noConsole suppressions for the CLI entrypoint; it landed on its own because these files had never been Biome-formatted. The CI Biome job scopes itself to a path list that excludes this component while the lefthook lane globs every staged JS/TS file, so any edit here drags the accumulated formatting diff in. 4344d9a is the actual fix. Reviewing the second commit alone is sufficient, and the first is verified behavior-neutral: after it, the live check still failed with exactly the original error and the 13 pre-existing tests still passed.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits September 3, 2026 15:10
Mechanical only, no behavior change: the live check still fails with exactly the
error it failed with before this commit, and the 13 existing tests still pass.

These two files had never been Biome-formatted, because the CI Biome job scopes
itself to a path list that does not include this component while the lefthook
lane globs every staged JS/TS file. Touching either file for any reason
therefore drags in the accumulated formatting diff, which would bury a one-line
change. Landing it on its own so the fix that follows stays reviewable.

The three console calls are the CLI entrypoint's interface, not stray debugging,
so they get per-call suppressions with that justification rather than a
component-wide rule disable that would blind noConsole everywhere else here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ation flags

`main` has been red since ci-workflows 3e32b0a landed on 2026-09-02T06:48Z,
44 minutes after this repo's last CI run, so no run had seen it until now. That
commit made `CLOSING_KEYWORD` global, `/gi;`, so every occurrence on a line can
be classified. The parser matched a literal `/i;`, so it stopped finding the
declaration and reported `gate reusable: CLOSING_KEYWORD / NO_ISSUE_MARKER regex
declarations not found`: a parse failure wearing a drift error's clothes, on a
gate that had not drifted at all.

Flags on the declaration were never part of the contract. Only the pattern body
is extracted, and both probes are constructed with "i" regardless, so pinning
the flag set asserted an incidental detail of how the reusable happened to be
written. Accept any valid flag set; real drift is still caught functionally by
probing the extracted body against every policy keyword and marker.

Confirmed against the live sources that nothing else had drifted: with this fix
the check reports "all copies and caller pins match policy.json" and exits 0.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T19:14:07.647943Z 4344d9a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 2m 41s —— View job


Code review complete ✅

  • Gather context (PR diff, description, changed files)
  • Run /review:code-review per repo instructions
  • Post inline findings (if any)
  • Final summary

Scope: components/pr-convention-policy/lockstep-drift.mjs and lockstep-drift.test.mjs (2 commits: e11eb1c mechanical Biome formatting, 4344d9a the actual fix). No .github/workflows/claude-security-review.yml exists in this repo, so security scope would fall to this lane per REVIEW.md, but this diff has no security surface (no auth, no secrets, no injection).

Verified independently (not just restating the author's claims):

  • Confirmed e11eb1c is behavior-neutral: git diff e11eb1c~1 e11eb1c -- components/pr-convention-policy/lockstep-drift.mjs is whitespace/wrapping plus three biome-ignore comments only — no logic touched.
  • Traced the regex change in parseGatePatterns (lockstep-drift.mjs#L119-L135): /(.+)\/[dgimsuvy]*;/ is still safe under greedy backtracking — since . excludes \n, matching is confined to the declaration's own line, and greedy .+ tries the longest match first, so it resolves to the rightmost valid /[flags]; terminator on that line (the real one), not an accidental internal /. Confirmed against the GOOD_GATE fixture, whose CLOSING_KEYWORD body itself contains an internal escaped \/ — that inner slash isn't followed by valid flag chars + ;, so it can't be mismatched as the terminator.
  • Confirmed the flag character class [dgimsuvy] is exactly the eight valid JS regex flags (d/g/i/m/s/u/v/y) — not over- or under-permissive.
  • Confirmed the rebuilt probes (new RegExp(keyword[1], "i")) are unchanged, so declared flags genuinely don't leak into drift detection either way, matching the PR's claim that flags were never part of the enforced contract.
  • Traced assertPatternsEnforce (the consumer of parseGatePatterns's output) — untouched and unaffected by this change.

Not independently executed: I did not run node --test / npm run test:pr-convention-lockstep myself — this review lane's tool grant doesn't include arbitrary command execution, only Read/Glob/Grep/git diff/gh pr *. The PR's stated 14/14 pass and mutation-testing results are author-claimed and unverified by me; my confidence above rests on static tracing of the regex and control flow, not on running the suite.

Findings: None that clear the high-signal bar (no correctness bugs, no missed edge cases in the regex logic, no security surface). The three near-identical biome-ignore lint/suspicious/noConsole comments in the CLI entrypoint are slightly repetitive but each documents a distinct call site per the stated policy of scoping suppressions to the call rather than the file — not worth flagging as a nit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4344d9a509

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

kyle-sexton and others added 2 commits September 3, 2026 15:16
…oded i

Review caught a real hole in the previous commit. Accepting any flag set while
rebuilding both probes with a hardcoded "i" meant a gate that DROPPED `i` would
still be probed case-insensitively and pass. Both declared bodies are lowercase
and depend on `i` to accept the documented `Closes #12`, so that gate would have
become case-sensitive in production while this check reported it healthy, which
is precisely the enforcement drift the check exists to catch.

Capture the flags and build each probe from them. `g` and `y` are stripped,
because they make `.test()` advance lastIndex and assertPatternsEnforce probes
each pattern once per policy keyword, so a retained `g` would make every probe
after the first read a moved cursor rather than the pattern. Neither flag
changes what the pattern matches, so dropping just those two is safe; every
behavior-affecting flag now survives into the probe.

Two tests added: a gate declared `/g;` without `i` is reported as enforcement
drift naming the rejected `Closes` keyword, and a `/gi;` gate probes true for
every policy keyword in sequence rather than only the first.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…from comments

The comment-hygiene lane reads a closing keyword followed by `#<digits>` as a
tracker reference, and two of the new comments spelled one out as the example of
what the lowercase pattern bodies need the `i` flag to accept. The scanner is
right that the form does not belong in a comment; the point survives fine as
"the documented capitalised keyword forms".

Comment text only. No behavior change: 16 tests still pass and the live check
still reports all copies and caller pins matching.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@kyle-sexton
kyle-sexton merged commit ff3adfd into main Sep 3, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the fix/lockstep-regex-flag-tolerance branch September 3, 2026 23:03
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