Skip to content

tools(hygiene): B-0162 — role-ref check (soft-launch)#1205

Merged
AceHack merged 1 commit intomainfrom
mechanize-b-0162-role-ref-check
May 2, 2026
Merged

tools(hygiene): B-0162 — role-ref check (soft-launch)#1205
AceHack merged 1 commit intomainfrom
mechanize-b-0162-role-ref-check

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 2, 2026

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; --strict flag 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

…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>
Copilot AI review requested due to automatic review settings May 2, 2026 16:53
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@AceHack AceHack merged commit ca08355 into main May 2, 2026
27 checks passed
@AceHack AceHack deleted the mechanize-b-0162-role-ref-check branch May 2, 2026 16:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.sh to scan a closed list of current-state docs for attribution-style mentions of known names.
  • Parses persona names from docs/EXPERT-REGISTRY.md and combines them with additional hardcoded name sets.
  • Adds --strict / ROLE_REF_CHECK_SOFT_LAUNCH behavior 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)
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.

2 participants