Skip to content

ci: run the rules-index check on every pull request - #15965

Merged
kyle-sexton merged 4 commits into
mainfrom
ci/15933-run-rules-index-check-in-ci
Nov 13, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
ci/15933-run-rules-index-check-in-ci

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Closes #15933

Summary

A pull request that adds, removes or renames a file under .claude/rules/ (or a nested AGENTS.md/CLAUDE.md) without regenerating the "Conventions that load on demand" table in AGENTS.md now fails CI. The check already existed as the instruction-placement plugin's opt-in pre-commit hook; nothing ran it in CI, and the table drifted twice.

Dogfooding step: this repository's own lint-repo job now runs the instruction-placement plugin's render-index.sh check on every pull request, as the rules-index hygiene gate.

Fix

  • .github/workflows/pr-require-checks.yml: new ungated step rules_index (bash plugins/instruction-placement/scripts/render-index.sh check --file AGENTS.md), run through scripts/run-hygiene-gate.sh rules-index, with a rules-index= row in the "Aggregate hygiene results" CHECK_RESULTS list. Ungated because a rules-only change is docs-only, the exact edit that leaves the table stale.
  • scripts/check-affected-gates.txt: rules-index listed as a CI-only whole-repo scanner.
  • render-index.sh check failure message now names the fix: after DRIFTED it prints one ADD, CHANGE or REMOVE line per differing row (keyed by the surface path, with the row's text), a NOTE line when every row matches and only the surrounding text differs, then a FIX line with the write command, naming both --file and --root so it rewrites the same tree from any directory (a review finding on this PR). What counts as drift is unchanged.
  • git-hooks/index-check.sh prints the same row lines under its own regenerate command (not check's FIX line, which names the pre-commit scratch tree).
  • AGENTS.md: one line below the generated table says CI's rules-index check fails a PR that leaves it stale. It sits outside the generated block, so the renderer's preamble, which every consuming repository gets, is unchanged.
  • CARRY_REFUSES (babysit_merge_policy.py and .github/scripts/pr-merge/merge-holds.mjs, the same list) adds plugins/instruction-placement/scripts/**: the workflow now runs a script from there, and test_merge_holds_sync.py requires every script a hold path runs to stop an approval carrying. Found by the first CI run on this PR.
  • Changelog fragments for instruction-placement (minor) and source-control (patch).

Verification

  • Current main: render-index.sh check --file AGENTS.md prints IN-SYNC (exit 0), before and after rebasing onto the latest main.

  • Demo from the issue, on a throwaway checkout with .claude/rules/demo-rule.md added and staged and no row: exit 1 with

    DRIFTED	<root>/AGENTS.md
    ADD	| `.claude/rules/demo-rule.md` | `demo/**` | Demo rule |
    FIX	bash "<plugin>/scripts/render-index.sh" write --file "<root>/AGENTS.md" --root "<root>"
    
  • render-index.test.sh: 141 cases, 0 failures (new: ADD row and FIX line, the FIX command run from an unrelated directory restores sync, CHANGE and REMOVE rows, NOTE when only the preamble drifts). index-check.test.sh: 24 passed (new: the hook names the row and omits FIX).

  • check-affected-gates.test.sh 6/6; check-lane-coverage.sh --check: all 84 gate steps fed to the aggregator; aggregate-hygiene-results.sh --self-test passed; actionlint and shellcheck on the changed files clean.

  • test_merge_holds_sync.py 21 OK, the babysit risk and floor-path tests OK, merge-holds.test.mjs 71/71, ruff clean.

  • Left out: the full .github suite (CI runs it).

Related

🤖 Generated with Claude Code

The AGENTS.md "Conventions that load on demand" table is generated from
.claude/rules/ and the nested instruction files, but only an opt-in local
git hook checked it. A new rules-index hygiene step in lint-repo runs
`render-index.sh check --file AGENTS.md`, and its outcome is a row in the
aggregate hygiene result.

On drift, `render-index.sh check` now prints one ADD, CHANGE or REMOVE
line per differing row, keyed by surface path, then a FIX line with the
write command. The pre-commit hook prints the same row lines. What counts
as drift is unchanged.

AGENTS.md points at the check below the generated table.

Closes #15933

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 13, 2026 14:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T14:32:36.084692Z 49c4a2e Draft marked ready
ℹ️ 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.

@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: 49c4a2e29d

ℹ️ 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 Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed e71f793a62e6f91a6e4437bd218234caf4306bbc: read 11 of 11 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15965 at e71f793a

I found no security issues. I read every hunk of all 11 changed files. This lane already reviewed an earlier head of this pull request, so I only looked for blocking findings (CRITICAL or IMPORTANT).

critical-findings: 0

Trusted-path files

Merge-hold control: CARRY_REFUSES (merge-holds.mjs L1073, babysit_merge_policy.py L4083)

  • Both copies of the list gain the same entry, plugins/instruction-placement/scripts/**, so they still match.
  • A push that touches that directory now stops an earlier approval from carrying over to the new head. The change only adds refusals and lifts no hold, so the merge hold gets tighter, not weaker.

.github/workflows/pr-require-checks.yml

  • The new rules_index step runs bash plugins/instruction-placement/scripts/render-index.sh check --file AGENTS.md from the pull request's checkout, inside the existing lint-repo job.
  • What I checked:
    • The trigger is pull_request (L34), not pull_request_target.
    • The job's permissions are contents: read and checks: read (L1403-L1405).
    • The step adds no secret, no token and no ${{ }} expression to its run: line.
  • The job already runs scripts from the pull request's own tree (for example scripts/check-adr-numbers.sh), so the step widens no trust boundary.
  • The new rules-index= row in the aggregator only feeds the hygiene result list.

AGENTS.md

  • The change adds one line after the generated block. It deletes, narrows and softens no instruction, so the instruction-surface lens finds nothing.

Other files

  • render-index.sh: print_row_diff passes both blocks to awk through ENVIRON rather than through program text or -v, so a row's content cannot inject awk code. print_fix only prints a command; nothing runs it.
    • Every output line starts with ADD, CHANGE, REMOVE, NOTE or FIX followed by a tab, so a row's content cannot start a GitHub workflow command (::) in the CI log.
  • index-check.sh: the change only prints the row lines, filtered with a fixed grep -E pattern, to stderr.
  • Tests, check-affected-gates.txt and the changelog fragments: no security surface. The eval of the printed FIX line in render-index.test.sh runs only on a test fixture the test builds itself.

Notes

  • Settled threads: the two threads on the FIX line's --root and the one on the AGENTS.md sentence are resolved, with no lines changed since. I am not raising them again.
  • Embedded text: the PR context, settled-threads and prior-findings files hold no instructions aimed at this lane.
  • Spend: one extra step in the existing lint-repo job on every pull request uses a few seconds of Actions runner time. It is not a hold and not counted as a finding.
  • Not run: this run had no shell and no GitHub access, so I posted nothing; the job posts this review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 2 inline finding(s) on 49c4a2e29d5e759cf94e9d2efec06a671e18c7ea; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread AGENTS.md Resolved
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed e71f793a62e6f91a6e4437bd218234caf4306bbc: read 11 of 11 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15965 at e71f793a: no blocking findings

I read every hunk of all 11 changed files in .claude-lane/pr.diff. This lane has already reviewed earlier heads of this PR, so this round reports blocking findings only: advisory ones are dropped.

Prior findings

  • Missing --root in the FIX command (render-index.sh): fixed. Both drift exits now call print_fix, which prints write --file "$TARGET" --root "$PWD" after the cd "$ROOT" (render-index.sh#L169, called at L571 and L585).
    • TARGET is made absolute before the cd (L411-L419), so the printed command names the right file and tree from any directory.
    • The new test runs the extracted FIX command from $neutral and then asserts IN-SYNC. Unlike the old prefix-only assertion, this test fails if --root is dropped.
  • Test coverage for the AGENTS.md sentence: advisory; the owner declined it in the settled thread. Not raised again.

What I checked

  • Workflow wiring (pr-require-checks.yml):
    • The new rules_index step follows the neighbouring hygiene gates: continue-on-error, the run-hygiene-gate.sh shell, and no select-tests gate.
    • Its outcome feeds the aggregate CHECK_RESULTS list as rules-index=.
    • check-affected-gates.txt lists it as a CI-only whole-repo scanner.
  • print_row_diff:
    • Rows are keyed by the first code span, both for | `path` table rows and for - `dir/` grouped-tail lines. Table rows are keyed by full file paths and tail lines by directories ending in /, so the keys don't collide.
    • The header and separator rows don't match row().
    • The NOTE line appears only when no row line is printed.
  • index-check.sh:
    • The new grep runs under set -uo pipefail without -e. If no row lines match (the empty-block drift case), its exit status is ignored and the hook still exits 1.
    • $'\t' is valid because the hook runs under bash once check-lib.sh is sourced.
    • The err_of change in the test correctly keeps stderr that contains table | characters.
  • CARRY_REFUSES: both copies (merge-holds.mjs and babysit_merge_policy.py) add the same entry at the end, which keeps the two lists matching.

Closing issue #15933

  • Every "Done when" item is met by the diff:
    • The CI step plus its row in the aggregate result.
    • The ADD/CHANGE/REMOVE lines name the row.
    • AGENTS.md has the sentence pointing at the check.
    • The PR body names the dogfooding step.
  • The PR says the check passes on main as it stands. I could not run it here, so that claim is unverified.
  • The tests and checks listed in the PR body are likewise unverified: this lane has no shell.

Rules, manifests and other inputs

  • Changelog fragments: minor for the new render-index.sh check output and patch for widening the hold list both fit the change.
  • Plugin manifests: none changed.
  • Path-scoped rules: the .claude/rules/ files whose globs match a changed file (ruff-pin.md, cost-claims.md, skill-bodies-state-current-rules.md on the one-line babysit_merge_policy.py edit) raise nothing.
  • Embedded instructions: none found in the PR context, settled threads or prior findings.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 3 commits November 13, 2026 09:50
…t scripts

pr-require-checks.yml now runs plugins/instruction-placement/scripts/
render-index.sh, so test_merge_holds_sync.py requires that directory in
CARRY_REFUSES: a push touching a script a hold path runs must stop an
approval carrying. Add it to both copies of the list
(babysit_merge_policy.py and merge-holds.mjs).

Refs: #15933

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc
`check` renders from --root, but the FIX line it printed had only
--file, so running it from another directory rendered that directory's
rules into the target. The FIX line now carries --root, and a test runs
it from an unrelated directory and checks the target comes back in sync.

Refs: #15933

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 999cb91 Nov 13, 2026
95 checks passed
@kyle-sexton
kyle-sexton deleted the ci/15933-run-rules-index-check-in-ci branch November 13, 2026 15:33
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run the rules-index check in CI

1 participant