tools(hygiene): B-0162 — role-ref check (soft-launch)#1205
Merged
Conversation
…oft-launch by default) Implements the pre-commit hook from B-0162 (P1 backlog row; 5 catches on PR #1202 alone past mechanization breakeven). Script: tools/hygiene/check-role-ref-on-current-state-surfaces.sh Behavior: - Scans closed-list current-state surfaces (CLAUDE.md, AGENTS.md, GOVERNANCE.md, ALIGNMENT.md, CONFLICT-RESOLUTION.md, AGENT-BEST- PRACTICES.md, GLOSSARY.md, WONT-DO.md, VISION.md, ROADMAP.md) - Parses persona-roster from docs/EXPERT-REGISTRY.md (canonical source per B-0162 acceptance criteria) - Plus extra personas (Otto, Amara, Ani, Sova, Rodney, Nazar, Ilyana), human-maintainer names (Aaron, Max), external-AI- instance names (Claude.ai, Codex, Gemini) - Detects attribution patterns (Name + date, Per Name, Name's said/grants/proposed/etc.) - Excludes inline-code spans + likely rule-references - Reports per-violation diagnostic with file/line/suggested-fix Soft-launch default per B-0162 acceptance criterion 9: ships as warning-only (exit 0 with warnings) so existing pre-existing violations across CLAUDE.md/VISION.md/AGENTS.md don't break CI on first land. --strict flag OR ROLE_REF_CHECK_SOFT_LAUNCH=0 env var promotes to error mode. Self-test: 26 violations found across 10 current-state surfaces (mostly pre-existing tech debt predating the role-ref convention that B-0162 codifies). Composes with: - docs/AGENT-BEST-PRACTICES.md Otto-279 carve-out - tools/hygiene/audit-orphan-role-refs.sh (post-strip lint) - tools/hygiene/check-archive-header-section33.sh (sibling pattern) Future work: - Wire into .github/workflows/gate.yml as warning-mode lint job - After soak period (no false positives observed for ~7 days), promote to --strict mode + cleanup pre-existing violations - Pre-commit hook integration (.husky/ or .git/hooks/pre-commit) Per first-principles trust calculus: 5-recurrence past mechanization-breakeven trace from B-0162's P2→P1 promotion checks out; the script earns its landing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds a new hygiene checker to detect direct name-attribution on current-state surfaces and encourage role-refs, with a soft-launch default (warnings) and an opt-in strict mode (fail).
Changes:
- Introduces
tools/hygiene/check-role-ref-on-current-state-surfaces.shto scan a closed list of current-state docs for attribution-style mentions of known names. - Parses persona names from
docs/EXPERT-REGISTRY.mdand combines them with additional hardcoded name sets. - Adds
--strict/ROLE_REF_CHECK_SOFT_LAUNCHbehavior to control whether violations fail the run.
Comment on lines
+134
to
+136
| pattern="\\bClaude\\.ai( 2026|: |[ '][a-z])" | ||
| else | ||
| pattern="\\b${name}( 2026| 2027|'s [a-z]| said| grants| proposed| asked| corrected| confirmed| disclosed)" |
| # because of the dot. | ||
|
|
||
| if [[ "$name" == "Claude.ai" ]]; then | ||
| pattern="\\bClaude\\.ai( 2026|: |[ '][a-z])" |
Comment on lines
+69
to
+82
| # Closed-list of current-state surfaces (per Otto-279 carve-out: any | ||
| # surface NOT in the history-surface allow-list) | ||
| CURRENT_STATE_SURFACES=( | ||
| "CLAUDE.md" | ||
| "AGENTS.md" | ||
| "GOVERNANCE.md" | ||
| "docs/ALIGNMENT.md" | ||
| "docs/CONFLICT-RESOLUTION.md" | ||
| "docs/AGENT-BEST-PRACTICES.md" | ||
| "docs/GLOSSARY.md" | ||
| "docs/WONT-DO.md" | ||
| "docs/VISION.md" | ||
| "docs/ROADMAP.md" | ||
| ) |
Comment on lines
+23
to
+59
| # What this checks: | ||
| # For every file in the closed current-state-surface list: | ||
| # - Scan for `\b<Name>\b` patterns where <Name> is in the | ||
| # known-roster (parsed from docs/EXPERT-REGISTRY.md + | ||
| # hardcoded human-maintainer / external-AI names) | ||
| # - Distinguish attribution (Name + date OR Name + ' grants ' / 'said' | ||
| # etc.) from rule-references (Name-NN, Name's <noun-phrase>) | ||
| # - Report violations with file/line/suggested-fix | ||
| # - Exit non-zero on any violation | ||
| # | ||
| # What this does NOT do: | ||
| # - Does NOT scan history surfaces (memory/, docs/research/**, | ||
| # docs/ROUND-HISTORY.md, docs/DECISIONS/**, docs/aurora/**, | ||
| # docs/hygiene-history/**, commit messages) | ||
| # - Does NOT auto-fix | ||
| # - Does NOT enforce on lines that legitimately reference names | ||
| # (rule references like "Otto-279" or quoted material) | ||
| # | ||
| # Composes with: | ||
| # - docs/AGENT-BEST-PRACTICES.md (Otto-279 carve-out) | ||
| # - tools/hygiene/audit-orphan-role-refs.sh (post-strip lint) | ||
| # - tools/hygiene/check-archive-header-section33.sh (sibling pattern) | ||
| # - .github/workflows/gate.yml (wired as a lint job — TODO) | ||
| # | ||
| # Self-test: | ||
| # $ tools/hygiene/check-role-ref-on-current-state-surfaces.sh | ||
| # → exit 0 if all current-state surfaces are clean | ||
| # → exit 1 with per-file diagnostic if any direct name | ||
| # attribution is found | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Soft-launch flag: when set, exit 0 even on violations (warnings printed | ||
| # but build doesn't fail). Per B-0162 acceptance criteria: | ||
| # "Soft-launch: ship as warning-only first, then promote to error after | ||
| # a soak period (existing pattern per check-tick-history-shard-schema.sh)." | ||
| SOFT_LAUNCH="${ROLE_REF_CHECK_SOFT_LAUNCH:-1}" |
Comment on lines
+133
to
+143
| if [[ "$name" == "Claude.ai" ]]; then | ||
| pattern="\\bClaude\\.ai( 2026|: |[ '][a-z])" | ||
| else | ||
| pattern="\\b${name}( 2026| 2027|'s [a-z]| said| grants| proposed| asked| corrected| confirmed| disclosed)" | ||
| fi | ||
|
|
||
| # grep for the pattern, exclude inline-code lines (start with ` or contain `<name>`) | ||
| matches=$(grep -nE "$pattern" "$surface" 2>/dev/null \ | ||
| | grep -v -E '^[0-9]+:\s*```' \ | ||
| | grep -v -F "\`${name}\`" \ | ||
| || true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements B-0162 (P1; 5 catches on PR #1202 past mechanization breakeven).
tools/hygiene/check-role-ref-on-current-state-surfaces.sh— scans current-state surfaces for direct name attribution (Name + date, Per Name, Name's said/etc.), reports violations with file/line/suggested-fix.Soft-launch by default per B-0162 acceptance criterion 9 — exit 0 with warnings;
--strictflag promotes to error mode. Self-test: 26 pre-existing violations found (mostly CLAUDE.md/VISION.md/AGENTS.md tech debt predating the role-ref convention).Future work (separate PRs): CI wire-up as warning-mode lint job; post-soak promotion to strict mode; pre-commit hook integration.
🤖 Generated with Claude Code