| 1 | # Prompt Audit — Budget and Governance Lint |
| 2 | |
| 3 | > Maintainer-only, read-only. Audits the agent-facing Markdown corpus without modifying it and is intentionally not wired into CI or pre-commit hooks. Generation roles never load this doc, the tool, or its manifest. |
| 4 | |
| 5 | ## Run |
| 6 | |
| 7 | ```bash |
| 8 | python3 skills/ppt-master/scripts/prompt_audit.py # text summary |
| 9 | python3 skills/ppt-master/scripts/prompt_audit.py --json # stable JSON report |
| 10 | ``` |
| 11 | |
| 12 | Requires `tiktoken` (not part of `requirements.txt` — end users never need it): |
| 13 | |
| 14 | ```bash |
| 15 | pip install 'tiktoken>=0.7.0' |
| 16 | ``` |
| 17 | |
| 18 | Exit code `1` on any deterministic error; advisory duplicate/schema candidates stay warnings. With `--json`, setup failures also use a stable `AUDIT_SETUP_ERROR` JSON envelope instead of a traceback or plain-text error. |
| 19 | |
| 20 | ## What It Checks |
| 21 | |
| 22 | | Area | Failure class | |
| 23 | |---|---| |
| 24 | | Corpus and hot-file token ceilings | error on budget overflow | |
| 25 | | Declared load sets (route/stage scenarios) | error on budget overflow, unknown files, selector/registry drift | |
| 26 | | Load coverage | error when a corpus file is in no load set and has no `coverage.exempt` entry | |
| 27 | | Registry claims (layout patterns, modes, styles, renderings, types, charts) | error on ID/count/index drift | |
| 28 | | Markdown references and declared authority edges | error on broken links or unreferenced edges | |
| 29 | | Cross-file exact/near duplicates | warning; intentional cases are adjudicated via `duplicates.accepted` | |
| 30 | | Schema multi-definition | warning when an owner field also has grammar-like text in any non-owner file | |
| 31 | |
| 32 | ## Manifest Maintenance — `prompt_audit_manifest.json` |
| 33 | |
| 34 | The manifest is audit-only (`audit_only: true`, `runtime_consumed: false`); it is a lint fixture, never prompt context. It hand-transcribes the load rules stated in `SKILL.md` and the role/workflow docs, so **every change to read instructions in those docs must update the matching load set in the same change** — the coverage check catches unclassified files, but only humans can catch a changed read rule for an existing file. |
| 35 | |
| 36 | - **New corpus file** → when no existing category exemption matches it, the audit fails with `LOAD_COVERAGE_GAP` until you add it to the load sets that read it or exempt it with a one-line reason. Exempt only material that never enters role context (for example, a legacy tombstone, generated maintenance asset, maintainer-only doc, or license notice); represent conditional runtime reads as incremental load sets. |
| 37 | - **Intentional duplicate** → run `--json`, copy the finding's `kind`, `fingerprint`, and `paths` into `duplicates.accepted` with a reason. The acceptance identity is all three values, so separate path pairs with identical prose remain independently reviewable. Editing either reported raw block changes its fingerprint; stale acceptance fails with `DUPLICATE_ACCEPTED_STALE`. `--skip-near-duplicates` deliberately leaves accepted near pairs unchecked because that scan did not run. |
| 38 | - **Schema owner** → every configured field must have a definition signal in its declared owner. One grammar-like non-owner is enough to surface a candidate; split fields into separate owner entries when they belong to different artifacts. |
| 39 | - **Budget ceilings** (`budget_policy: fixed_upper_bound`): budgets are stable, deliberately rounded limits rather than mirrors of the current token count. Establish a new ceiling with roughly 10% working headroom and round it up in 250-token increments below 10k, 1k increments below 100k, or 5k increments from 100k upward; the manifest loader enforces those increments. Once set, do not raise or lower a passing ceiling, including to restore headroom after prompt growth. Raise it only after the current audit reports `BUDGET_CORPUS`, `BUDGET_FILE`, or `BUDGET_LOAD_SET` against that exact ceiling; then choose the next rounded limit with comparable headroom, record the overflow-triggering scope in the same change, and leave it unchanged until another actual overflow. |
| 40 |