Skip to content

ci: guard tracked agent guidance against model names - #81

Merged
TusanHomichi merged 9 commits into
mainfrom
ci/78-guidance-name-guard
Oct 8, 2026
Merged

TusanHomichi merged 9 commits into
mainfrom
ci/78-guidance-name-guard

Conversation

@TusanHomichi

@TusanHomichi TusanHomichi commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Primary Issue

Closes #78

Problem And Outcome

Model and vendor names in tracked agent guidance keep coming back. #71 introduced them, and #76 (merged in #79) removed them at the guidance rung only. After this PR, pr-gate fails within seconds when tracked guidance names a model, a model family, or a vendor product. Contributors can run the same check locally with one command.

Changes

  • scripts/check-guidance-names.sh: a POSIX sh script using git and awk, with no dependency on the system grep. Three lists sit at the top, each with instructions for extending it:

    • the scanned set (pathspecs);
    • the pattern list;
    • the tool-entrypoint allowlist.

    How it decides:

    • git grep finds candidate lines in the tracked files.
    • awk strips allowlisted file-name tokens, then re-tests the rest of the line. A name counts as a match when there is no letter or digit before it and no letter after it, so IDs joined to version digits or _ are caught.
    • Entrypoint files are still scanned; only the allowlisted tokens are removed from a line.
    • Files git treats as binary are scanned too.

    Fail-closed behavior (exit 2):

    • any scanned entry, including the literal root AGENTS.md and CLAUDE.md, matches no tracked file;
    • a scanned file is missing from the working tree, or is no longer a regular file there;
    • a committed entry is not a regular file (for example, a symlink);
    • git grep writes anything to stderr or errors;
    • awk errors.

    A residual hit prints path:line: text and exits 1.

  • .github/workflows/pr-gate.yml: a Guidance names step runs right after checkout, before the toolchain and web installs.

  • CONTRIBUTING.md: the guard is the first command in the local sequence, and a paragraph names it as the rung-2 guard for this class.

  • docs/development.md: a map line for scripts/.

Correction-ladder rung: 2 (a repository guard the gates run). There is no ADR, because this enforces an existing rule and adds no product behavior.

Scope

  • In scope:
  • Out of scope:
    • other per-tool instruction locations (none exist in the tree today);
    • the content of the guidance itself.
  • Scan contract (stated in the script header): locally, tracked guidance as it exists in the working tree and in the index, with index hits marked (staged); in CI, the checked-out commit. Untracked files, stash entries, and other refs are not scanned.
  • Accepted as policy:
    • Ordinary English words that collide with a pattern are flagged.
    • A NUL byte placed directly before a name is out of class: the shell drops NULs when capturing output.
    • The pattern list is the one tracked place that holds these names. It is data, sits outside the scanned set, and the owner approved it on ci: guard tracked agent guidance against model and vendor names #78.

Verification

  • Candidate revision: ada0485, on main at 6c4c477. Gates ran on 81bc8b7, 0f06748, 83e1b0c, 46d301b, and ada0485, after each round of automated-review fixes.
  • Local evidence:
    • The verifier role ran the full CONTRIBUTING sequence on ada0485, and every step exited 0: the guard, npm ci/check/build, cargo fmt --check, clippy -D warnings, cargo test --workspace (28 result lines, all ok), cargo build -p consolebook-server, and npm run e2e with system Chrome 155 rather than the Playwright download (56 passed).
    • git diff --check origin/main..HEAD was clean.
    • Receipts and per-log SHA-256 are archived locally.
  • Negative control: a scratch commit on the candidate (30d6af6 on ada0485), never pushed, reintroduces one vendor name in prose at CLAUDE.md:6. The guard exits 1 and prints CLAUDE.md:6: ….
  • Other controls:
    • The implementer role ran dirty-tree controls. These fail: a prose vendor name; IDs joined to digits or _; a name inside a file git treats as binary; a name in a nested web/AGENTS.md. A line holding only an entrypoint file name passes. A missing scanned entry, a removed root entrypoint, and git grep or awk errors all exit 2.
    • shellcheck is clean.
    • Exit codes are identical across gawk, mawk, nawk, and busybox awk under dash, busybox sh, and bash --posix.
  • Hosted: before the rebase, run 37698835855 passed on 8317340 through workflow_dispatch; its Guidance names step printed ok (11 files scanned). This PR's pr-gate passed on 81bc8b7, 0f06748, 83e1b0c, and 46d301b, and runs again on ada0485.
  • Listed the exact verification commands run below
  • Added or updated tests when behavior changed (the guard is the check; controls above)
  • Added or updated an ADR when a durable decision changed (not applicable: no product behavior)
  • All fixtures and examples are invented; no real agency data
- scripts/check-guidance-names.sh
- web/: npm ci, npm run check, npm run build
- cargo fmt --check
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace
- cargo build -p consolebook-server
- web/: CONSOLEBOOK_E2E_CHROMIUM=<system Chrome 155> npm run e2e
- git diff --check origin/main..HEAD

Review And Merge Notes

  • Review focus:
    • the awk boundary rule and allowlist stripping;
    • fail-closed paths;
    • whether the scanned set is the right size.
  • Review performed: independent review by the reviewer role, in two rounds.
    • Round 1 on the first candidate found four gaps: IDs joined to digits or _; -I skipping files git treats as binary; nested entrypoints; an awk status ambiguity.
    • Round 2 found two more: root entrypoints were no longer required, and the allowlist boundary did not match the hit test.
    • All six are fixed in the second and third commits.
    • Automated review on 81bc8b7 raised two P2s: a scanned file deleted but not staged still passed, and suffixed allowlist tokens hid names. Both are fixed in 896e3fc.
    • A third independent pass found two more fail-closed gaps, a committed symlink and git grep errors that reach only stderr. Both are fixed in 0f06748. It also found left-side allowlist variants such as old_CLAUDE.md; these were first declined as out of class. Automated review on 0f06748 raised them as a P2, and the decline was reversed because the case mirrors the right-side fix. A leading-boundary rule is in 83e1b0c, and independent delta review found nothing.
    • Automated review on 83e1b0c found that staged-only content was not scanned locally. This could not reach main. The index pass and the scan contract are in 46d301b, and independent delta review found nothing.
    • Automated review on 46d301b found that right-side suffixes such as @, ~, +, and / still stripped. In 622f8ca the right side became an explicit delimiter list, mirroring the left. Independent delta review then caught a CRLF regression, which ada0485 fixes.
    • A final delta review on 0f06748 found nothing blocking. Accepted as is: a local GIT_TRACE or an invalid global git config fails the guard, with the reason printed.
    • The placement fork (a standalone script or an inline workflow step) went to the decision advisor. The acceptance requires one documented local command and one place for the lists, which decided it for the script.
  • Remaining authority: none. Merge goes by the usual merge rule.
  • User or operator impact: none at runtime. Contributors get a new first gate command.

🤖 Generated with Claude Code

TusanHomichi and others added 3 commits October 8, 2026 01:43
Add scripts/check-guidance-names.sh, the rung-2 guard for the class #76
cleaned up: tracked agent guidance naming specific models or vendors
instead of roles. The scanned set, pattern list, and entrypoint-name
allowlist live at the top of the script. Allowlisted tokens are stripped
from a hit line and the remainder is re-tested, so entrypoint files stay
in the scan. The guard fails closed when a scanned entry matches no
tracked file or git grep errors.

pr-gate runs it first, before the toolchain and web installs.
CONTRIBUTING.md lists it in the local sequence and names its rung;
docs/development.md maps scripts/.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match names joined to version digits or underscores (the prefilter no
longer uses -w; awk applies the boundary rule), scan files git treats
as binary, cover nested AGENTS.md and CLAUDE.md, and stop reading an
awk failure as a residual hit.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep literal AGENTS.md and CLAUDE.md beside their glob entries so removing
a root entrypoint still fails closed, and strip allowlisted tokens with
the same boundary the name check uses.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 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-10-08T01:47:00.827067Z ada0485 New commits
ℹ️ 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: 81bc8b7a68

ℹ️ 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".

Comment thread scripts/check-guidance-names.sh Resolved
Comment thread scripts/check-guidance-names.sh Resolved
TusanHomichi and others added 2 commits October 8, 2026 02:10
Fail closed when a scanned tracked file is missing from the working tree,
and strip an allowlisted entrypoint name only when nothing word-like
follows it, so a suffixed name such as a backup copy no longer hides a
forbidden word.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refuse tracked symlinks and other non-regular entries in the scanned set,
paths whose working-tree copy is no longer a regular file, and any
git grep stderr output, since git grep can skip such files while still
exiting 0 or 1.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: 0f067487ff

ℹ️ 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".

Comment thread scripts/check-guidance-names.sh Resolved
Strip an allowlisted entrypoint name only at line start or after
whitespace, a path separator, or opening punctuation, so a prefixed
variant such as MY_ or my- no longer hides a forbidden word.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: 83e1b0ccfc

ℹ️ 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".

Comment thread scripts/check-guidance-names.sh Resolved
Add a git grep --cached pass so content staged for commit is checked
even when the working tree differs, mark index hits as staged, and
state the scan contract in the script header: working tree and index
locally, the checked-out commit in CI.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: 46d301b5bf

ℹ️ 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".

Comment thread scripts/check-guidance-names.sh Resolved
TusanHomichi and others added 2 commits October 8, 2026 03:32
Strip an allowlisted entrypoint name only when end of line, whitespace,
closing punctuation, or sentence-ending dots or dash follow it, so a
backup or path suffix after the name no longer hides a forbidden word.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A CRLF working tree left a carriage return after an end-of-line
entrypoint name, which the right-side delimiter list rejects; drop one
trailing CR before stripping and testing.

Refs #78

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TusanHomichi
TusanHomichi merged commit 2679b66 into main Oct 8, 2026
1 check passed
@TusanHomichi
TusanHomichi deleted the ci/78-guidance-name-guard branch October 8, 2026 01:54
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.

ci: guard tracked agent guidance against model and vendor names

1 participant