Skip to content

feat(B-0058): alignment-clause coverage audit tool#2102

Merged
AceHack merged 2 commits into
mainfrom
b-0058/alignment-clause-coverage-audit
May 8, 2026
Merged

feat(B-0058): alignment-clause coverage audit tool#2102
AceHack merged 2 commits into
mainfrom
b-0058/alignment-clause-coverage-audit

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 8, 2026

Summary

  • Adds tools/alignment/audit_clause_coverage.ts — a new TS tool that scans all skills (.claude/skills/*/SKILL.md) and agents (.claude/agents/*.md) for references to the 21 alignment clauses (HC-1..HC-7, SD-1..SD-9, DIR-1..DIR-5) from docs/ALIGNMENT.md.
  • Reports per-surface clause citations and flags surfaces with zero coverage as gaps.
  • Supports --json, --md, --out DIR, and --gate N output modes matching the sibling tools' conventions.
  • Registers the new script in tools/alignment/README.md.

This is slice 1 of B-0058 (responsibility #2: new-surface alignment-clause consistency check). Detection surface only — does not block commits or PRs. The --gate flag is advisory.

Focused checks

  • dotnet build -c Release0 Warning(s), 0 Error(s)
  • bun tools/alignment/audit_clause_coverage.ts → runs clean, exit 0 ✓
  • bun tools/alignment/audit_clause_coverage.ts --json → valid JSON output ✓
  • bun tools/alignment/audit_clause_coverage.ts --gate 1 → exit 1 (correctly trips) ✓
  • bun tools/alignment/audit_clause_coverage.ts --help → prints usage, exit 0 ✓
  • bun tools/alignment/audit_clause_coverage.ts --bogus → prints error, exit 2 ✓

Baseline snapshot

Metric Value
Total surfaces 260 (248 skills, 12 agents)
Surfaces with ≥1 clause citation 3
Surfaces with zero citations 257
Clauses cited by at least one surface 13/21
Uncited clauses HC-3, HC-5, SD-3, SD-4, SD-5, SD-7, SD-9, DIR-3

Test plan

  • Verify bun tools/alignment/audit_clause_coverage.ts runs clean on CI
  • Verify --json output parses as valid JSON
  • Verify --gate 1 exits with code 1
  • Verify --out creates clause-coverage.json + clause-coverage.md

🤖 Generated with Claude Code

New TS script at tools/alignment/audit_clause_coverage.ts — scans
.claude/skills/*/SKILL.md and .claude/agents/*.md for references to
the 21 alignment clauses (HC-1..HC-7, SD-1..SD-9, DIR-1..DIR-5)
from docs/ALIGNMENT.md. Reports per-surface clause citations and
flags surfaces with zero coverage.

This is slice 1 of B-0058 (responsibility #2: new-surface audit).
Detection surface only — does not block commits.

Baseline: 3/260 surfaces cite any clause. 8 clauses uncited
anywhere (HC-3, HC-5, SD-3..SD-5, SD-7, SD-9, DIR-3).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 8, 2026 16:40
@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.

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 alignment auditing tool to measure how well skills and agent definitions cite the HC/SD/DIR clauses from docs/ALIGNMENT.md, enabling coverage reporting and optional advisory gating.

Changes:

  • Introduces tools/alignment/audit_clause_coverage.ts to scan .claude/skills/*/SKILL.md and .claude/agents/*.md for clause references and emit human/JSON/Markdown reports (plus --out artifacts).
  • Adds an optional --gate N advisory threshold to exit non-zero when surfaces fall below the minimum citation count.
  • Registers the new tool in tools/alignment/README.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tools/alignment/README.md Adds the new audit script to the alignment tools registry table.
tools/alignment/audit_clause_coverage.ts Implements clause extraction, surface enumeration, report emission, and optional gating.

Comment thread tools/alignment/audit_clause_coverage.ts Outdated
Comment thread tools/alignment/audit_clause_coverage.ts
Comment thread tools/alignment/audit_clause_coverage.ts
@AceHack AceHack enabled auto-merge (squash) May 8, 2026 16:47
- Remove persona name from code comment (use role-ref only)
- Add eslint-disable-line for sonarjs/no-os-command-from-path
- Handle non-zero git exit status in repoRoot()
- Eliminate non-null assertion via local binding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@AceHack AceHack merged commit 4c2374b into main May 8, 2026
25 checks passed
@AceHack AceHack deleted the b-0058/alignment-clause-coverage-audit branch May 8, 2026 16:52
AceHack added a commit that referenced this pull request May 8, 2026
Adds test coverage for the two alignment tools shipped in PRs #2102-2105:
- audit_clause_coverage.test.ts (26 tests): extractClauses regex logic,
  ALL_CLAUSES constant, audit() integration, main() CLI arg parsing + gate
- audit_clause_drift.test.ts (8 tests): main() CLI arg parsing, no-drift
  baseline (HEAD vs HEAD), default base ref

Exports extractClauses and ALL_CLAUSES from audit_clause_coverage.ts to
enable direct unit testing of the core regex matching logic.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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