Commit Graph

1 Commits

Author SHA1 Message Date
Bo 94fd8eafea feat(corpus): advisory skill-metadata resolution audit — context_rel.with (ag-f0i #context-rel-resolution) (#565)
## Summary

Adds `scripts/audit-skill-metadata.sh` — an **advisory** auditor that
checks every non-empty `context_rel[].with` in `skills/*/SKILL.md`
resolves to an existing skill directory. The `skill-frontmatter.v2`
schema declares `context_rel.with` as a *skill slug*; the existing
`validate-skill-frontmatter.sh` checks presence/shape only — nothing
checked resolution. This closes that gap.

- Advisory by default (exit 0, logs findings); `--strict` exits
non-zero; `--json` emits a verdict naming `file` + `field` + `value`.
- Reads the skill universe from `--skills-root` /
`$SKILL_METADATA_SKILLS_ROOT` (default `skills/`).
- `tests/scripts/audit-skill-metadata.bats` (9 tests, tmp-generated
fixtures so no committed `SKILL.md` is seen by repo-wide scanners).

## Scope (ag-f0i, advisory slice)

The bead's original premise was partly stale:
`skills/domain/references/ubiquitous-language.md` does not exist, and
`practices`/`produces` canonicality would require a canonical registry
that does not yet exist (inventing one is out of scope per PROGRAM.md
"prefer existing patterns over new policy surfaces"). This PR ships the
**one well-defined, non-inventing resolution check** —
`context_rel.with` → existing skill — and splits the rest into
follow-ups.

`consumes[]` is intentionally **not** failed: per schema it may be an
artifact-kind *or* a skill slug (open vocabulary).

## Drift found (advisory, not gating this PR)

Live run: 75 skills checked, **5 finite findings**, all in
`session-bootstrap` (`context_rel.with` → `AGENTS.md` /
`AGENTS-WORKFLOW.md` / `AGENTS-CI.md` / `AGENTS-CODEX.md` /
`AGENTS-RUNTIME.md`, i.e. doc files rather than peer skills). Filed as a
backfill follow-up. Gate stays advisory until the backfill lands.

## Follow-ups (discovered-from ag-f0i)

- Backfill `session-bootstrap` context_rel.with edges (5 finite
violations).
- Promote `audit-skill-metadata.sh --strict` to a required CI gate after
backfill.
- Stand up a canonical `practices` registry, then extend the auditor to
validate practices canonicality (+ `produces` resolution).

## Test plan

- [x] `bats tests/scripts/audit-skill-metadata.bats` — 9/9 pass
- [x] `shellcheck scripts/audit-skill-metadata.sh` — clean
- [x] advisory run vs live tree: 5 finite findings, exit 0; `--strict`
exit 1; `--json` verdict correct
- [x] `heal.sh --strict` — clean
- [x] No Go changed (build/test unaffected)

Closes-scenario: ag-f0i#context-rel-resolution
Bounded-context: BC1-Corpus
Evidence: bats tests/scripts/audit-skill-metadata.bats (9/9); shellcheck
clean; advisory run = 5 finite findings
2026-05-28 01:55:18 -04:00