check-drift
Check enrolled regenerated outputs for drift without regenerating them. Report findings and name the relevant repair commands.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- check-drift
- metadata
- { "tags": "drift-detection, regeneration, verification, release-gate", "bundles": "crux-docs", "triggers": "check drift | is the tree in sync | run the drift gates | any drift? | verify all regenerated outputs | pre-release drift check", "risk_level": "low", "routing_note": "Read-only. Runs every enrolled regenerator's `--dry-run` gate in one pass and reports one table — gate, verdict, drifted paths, and the regenerator that fixes it; never regenerates. The whole-tree counterpart to `verify-code-docs`. Emits a `lint` log op.", "requires_access": "write-tree" }
- description
- Check enrolled regenerated outputs for drift without regenerating them. Report findings and name the relevant repair commands.
03 SKILL.md 正文
Check Drift
<!-- BEGIN GENERATED: runtime-compat -->
Runtime compatibility
This skill is portable across Claude Code, Codex, OpenCode, and OMP (Oh My Pi). This section overrides platform-specific labels below.
- Before running a command that uses
CRUX_PLUGIN_ROOT, set it to the installed plugin root. In Claude Code, use the value ofCLAUDE_PLUGIN_ROOT. In Codex, OpenCode, and OMP, derive it from the absolute path of this selectedSKILL.md: the plugin root is the parent of itsskills/directory (in OMPbash,skill://<name>resolves to the skill directory). In a source checkout, use the checkoutcrux/directory. - For project-local skills, use
.claude/skillsin Claude Code,.agents/skillsin Codex,.opencode/skillsin OpenCode (which also reads the singular.opencode/skill), and.omp/skillsin OMP. SetCRUX_LOCAL_SKILLS_DIRto that path before following any command below that uses it. - Translate Claude Code tool labels such as
Agent,Read,Write,Bash,WebSearch, andWebFetchto the matching capability in the current session. Codex names its own capabilities; OpenCode uses the lowercase formssubagent,read,edit,shell,websearch, andwebfetch, whereeditcovers bothEditandWrite; OMP usestask,read,edit,write,bash,grep,glob,find,todo, andweb_search(wherereadalso handles URLs andskill://URIs). Do not attempt to invoke the Claude Code labels as literal commands on another host. - Install the generated role agents before delegating:
install-codex-agentsin Codex,install-opencode-agentsin OpenCode,install-omp-agentsin OMP. Codex names themcrux_architect,crux_brainstormer,crux_commander,crux_dev_lead,crux_developer,crux_historian,crux_librarian,crux_night_gardener,crux_reviewer, andcrux_wayfinder; OpenCode and OMP use the bare role namesarchitect,brainstormer,commander,dev-lead,developer,historian,librarian,night-gardener,reviewer, andwayfinder(in OMP,scoutmay also be used for reconnaissance alongsidewayfinder). If a required role or capability is unavailable, report that truthfully instead of claiming it ran. - Argument placeholders such as
$adrand$bookbind only in Claude Code. On a host without argument binding they are unset — take the value from the user's phrase. The "Fields OpenCode ignores" section ofOPENCODE_GUIDE.mdnames the invocation-control fields OpenCode ignores. <!-- END GENERATED: runtime-compat -->
Overview
Every derived artifact in this repo has a vendored regenerator and a --dry-run drift gate — the enrollment roster is the "regenerative outputs" table in the repo-root AGENTS.md. This skill runs all of those gates in one read-only pass and reports a single table, so a developer or a release gate learns in one step whether any regenerated output has drifted from its source.
It is the whole-tree counterpart to verify-code-docs, which runs the one code/ gate. Same contract, wider surface: it never regenerates anything. For every drifted or broken gate it names the regenerator the user runs to fix it.
Read-only invariant. This skill invokes each enrolled regenerator with --dry-run only. It writes nothing under the tree, crux/catalog/, opencode/agents/, or any source file. When it finds drift, it recommends the regenerator by name; the user (or a CI hook) decides whether to run it.
The one side effect, named rather than glossed. Running a gate imports the plugin's own
Python modules, so the interpreter writes __pycache__/*.pyc beside them inside the installed
plugin. That is bytecode, not content: no source file, no catalog, no file under the tree and
nothing in the project under inspection is touched. Set PYTHONDONTWRITEBYTECODE=1 to suppress it.
Report it if a reader asks what the run wrote; do not report the run as having written nothing at all.
When to use
- User says: "check drift", "is the tree in sync", "run the drift gates", "any drift?", "verify all regenerated outputs", "pre-release drift check".
- Before a release, before opening a PR, or after a change that touches any source of a regenerated output (ADR frontmatter, a skill's SKILL.md, an agent definition, the writing-rules block,
plugin.json's version). - When
audit-docsreports drift and you want the full regenerated-output picture in one table.
Do not use this skill for:
- Regenerating anything — this skill is read-only. Run the recommended regenerator yourself.
- The document-graph integrity walk (index ↔ files ↔ cross-references) — that is
audit-docs. This skill checks only the regenerated-output drift gates. - Fixing a single code-doc drift —
verify-code-docsis the focused version for that one gate.
The pipeline
Execute in order. Never reorder, never skip a gate.
0. Resolve per-repo configuration (.bionic.yml)
Run python3 "${CRUX_PLUGIN_ROOT}/scripts/bionic-config.py" from the repo root. On exit 1, STOP and surface the {"error": ...} payload. Use the returned docs_dir wherever a gate below needs <docs_dir> (default bionic).
1. Run every enrolled drift gate
Run each command below from the repo root — both tables: the roster gates here, and the guards in Guards that carry no roster row further down. The second table's verdicts are reported exactly like the first's, and its rows count toward the step-4 accounting the same way, so enrolled there means every row of both tables. Parse each command's stdout as JSON regardless of its exit code — the exit code alone does not tell clean from drift. Collect a verdict per gate; do not stop on the first drift.
| Gate (output) | Scope | Dry-run command | Regenerator that fixes it |
|---|---|---|---|
crux/catalog/skills.json + agents.json |
plugin-authoring | validate-catalog.py --dry-run |
validate-catalog.py |
crux/box/micro-crux.md and root preview when present |
plugin-authoring | generate-micro-crux.py --dry-run |
generate-micro-crux.py |
docs/code/ |
project | uv run --no-config extract-code-docs.py --dry-run --config <docs_dir>/manifest.yml |
uv run --no-config extract-code-docs.py --config <docs_dir>/manifest.yml (skill extract-code-docs) |
<docs_dir>/arch/ spine |
project | derive-arch.py --dry-run --docs-dir <docs_dir> |
derive-arch.py --docs-dir <docs_dir> (skill derive-arch) |
<docs_dir>/adrs/summaries/ |
project | summarize-adrs.py --dry-run |
summarize-adrs.py |
<docs_dir>/adrs/doctrine/ |
project | compile-doctrine.py --dry-run |
compile-doctrine.py (skill compile-doctrine) |
opencode/agents/ |
plugin-authoring | generate-opencode-agents.py --dry-run |
generate-opencode-agents.py |
<docs_dir>/adrs/lineage.md |
project | generate-lineage.py --dry-run |
generate-lineage.py (skill link-adr-graph) |
<docs_dir>/adrs/index.md |
project | generate-adr-index.py --dry-run |
generate-adr-index.py |
<docs_dir>/index.md ## ADRs rollup |
project | generate-index-rollup.py --dry-run |
generate-index-rollup.py |
README.md version footer |
plugin-authoring | generate-readme-footer.py --dry-run |
generate-readme-footer.py |
| writing-rules block (3 surfaces) | plugin-authoring | generate-writing-rules.py --dry-run |
generate-writing-rules.py |
| runtime-compatibility block | plugin-authoring | generate-runtime-compat.py --dry-run |
generate-runtime-compat.py |
<tree>/AGENTS.md §10 routing-table region |
plugin-authoring | generate-routing-table.py --dry-run |
generate-routing-table.py |
<docs_dir>/adrs/reviews/index.md |
project | generate-reviews-index.py --dry-run |
generate-reviews-index.py |
<docs_dir>/journal/index.md |
project | generate-journal-index.py --dry-run |
generate-journal-index.py |
<docs_dir>/log/summary.md |
project | generate-log-summary.py --dry-run |
generate-log-summary.py (skill cleanup-campsite) |
crux/catalog/rules.json (the rules the plugin ships) |
plugin-authoring | generate-rules-catalog.py --dry-run |
generate-rules-catalog.py |
USER_GUIDE.md crux-mods reach-table region |
plugin-authoring | generate-mods-reach-tables.py --dry-run |
generate-mods-reach-tables.py |
This row's gate answers two questions, and only one of them is drift. Beside the byte comparison it checks PUBLICATION ELIGIBILITY: every slug cited on a shipped surface must resolve to a source record whose decision has been accepted.[^pubelig] A refusal exits 1 with a
validation_errorslist rather than adriftkey, and each row names the citing path, the citation, the source record, its raw status and the reason. File such a row BROKEN, never DRIFT, and do not name the regenerator as its remedy — re-running it refuses again. The remedy depends on the row's reason: accept a Proposed decision; for a Deprecated or Superseded one, migrate the citation to the rule that displaced it or remove it; an observation-backed rule needs an owner decision before it can ship. A status change moves no byte of the catalog, so a row reported clean by byte comparison alone would be a false green here.
The operations-log summary gate passes with pending work.
generate-log-summary.py --dry-runlists each settled month that has a detail file and no section underpending_months, and exits 0 when they are its only finding, because a month settles by date alone. Report the pending months beside the clean verdict and namecleanup-campsiteas the remedy, which runs the catch-up. Each failure in its JSON carries akind: aregionfailure is fixed by runninggenerate-log-summary.py; astructurefailure (a section for a month that is not settled, a second section, a section without a detail file, a marker error, or an incomplete split) is not, and its remedy is a hand edit ofsummary.mdoroperation-log.py repair.
Invoke each via uv run "${CRUX_PLUGIN_ROOT}/scripts/<name>" ... from the repo root. This roster is the source of truth for what a derived artifact owes; if the repo-root AGENTS.md roster grows a row, add its gate here.
The micro-crux gate verifies the shipped guide in staged plugin trees. It also verifies the root preview in an authoring checkout when present. A consuming project reports N/A. This gate remains selected at release; it is not a cycle-time documentation-tree skip.
Guards that carry no roster row
These answer real questions and run like the roster gates, but they regenerate nothing, so they are deliberately absent from the regenerative-outputs roster — that roster's subject is derived artifacts. They are declared here instead, which is the one place a reader looks for what gets executed. Each emits the same envelope the roster gates do, including the self-declared not-applicable lane.
| Guard | Scope | Command | What it answers |
|---|---|---|---|
<docs_dir>/observations/ records |
project | check_observations.py |
the CHK-OBS-* rules; reports concern_enabled: false when the concern is off |
<docs_dir>/promptbooks/index.md |
project | check-promptbook-index.py |
CHK-PB-11 completeness: a missing row, a duplicate row, a row naming an absent book, and the three count surfaces |
The Scope column says whose tree the row's gate inspects. That is the difference between a
verdict about this project and a verdict about the plugin. A project row's output lives in the
documentation tree, so its gate measures the project wherever the plugin is installed. A
plugin-authoring row's output lives in the plugin's own source checkout — the catalogs, the
opencode/ projection, the plugin README.md footer, and the writing-rules, routing-table,
runtime-compatibility and crux-mods reach-table regions. Every one of those roster rows is
inapplicable in a consuming project, and its gate reports so itself: exit 0 with
"surface_absent": true and a reason, having
written nothing. Report those rows N/A with the reason, never as clean and never as broken.
Run the whole roster every time. Do not decide in advance which rows apply — the gate is what
decides, and reading its surface_absent payload is how you learn. A plugin-authoring gate that
returns a drift verdict in a consuming project has resolved a path inside the installed plugin, and
that is a defect to report, not drift to fix.[^scope]
1.A. Run the validation checks
A validation check is not a drift gate. It regenerates nothing, so it owns no row in the repo-root AGENTS.md "regenerative outputs" roster, and enrolling it there would break the derived-artifact rule rather than keep it — a roster row promises a regenerator, and a validation check has none to promise. The roster count is unchanged by this section.
Run each check below from the repo root, after the drift gates and before the report.
| Check | Command | What a finding means | The fix |
|---|---|---|---|
| rule citations resolve | lint-governs-references.py |
a rule:<slug> citation names a rule that does not exist or has been retired, or a ledger handle does not resolve |
edit the citation, or restore the rule |
Invoke it as uv run "${CRUX_PLUGIN_ROOT}/scripts/lint-governs-references.py" with no flags. --path is its one flag: it narrows the scan to the files and directories you name, and passing none is what selects the default scope — the plugin source and the documentation tree. There is no --dry-run, because the linter never writes, so every run is already the read-only form.
A citation failure is BROKEN, never DRIFT. Regenerating fixes nothing here, because nothing is derived: a citation is authored text making a claim about a rule, and a stale claim is repaired by editing the claim. Report each finding in the same table as the gates, with BROKEN as its verdict and the path, line and token as the problem. A retired-slug finding names the rule that displaced it — carry that name into the report, because it is the fix.[^retired]
An empty resolved scope is BROKEN, not a clean pass. A check that scanned nothing has verified nothing. The linter exits nonzero and names the condition; report it as BROKEN and fix the scope. The same holds for its other refusals — a containment breach, a non-regular file, a file past the byte ceiling, a scope past the file ceiling, or a file that does not decode. Each is a refusal the check reports rather than a file it silently skips.
Zero rule: citations inside a non-empty scope is clean. The citation form is greenfield by the decision's own premise, so a pass over a scope that carries no citation yet is a real pass. Do not read it as a broken check, and never plant a citation to give the check something to find.
2. Classify each gate's verdict
Shared exit-code semantics (the same contract verify-code-docs, CHK-CODE-4, CHK-CAT-3, and CHK-ARCH-1 use): 0 clean, 1 drift or a validation error with valid JSON on stdout, any other non-zero with empty or unparseable stdout = crash (surface stderr, never a document finding). Map each gate to one verdict:
- clean — exit 0, JSON says no drift (
{"drift": false}/{"clean": true}/added=changed=removed=0/ empty diff), novalidation_errors, and nosurface_absentkey. That last clause is part of the definition, not a later correction: asurface_absentpayload carries{"drift": false}at exit 0 and matches every other clause here, so a reader matching these bullets top-down would call it clean four bullets before reaching N/A. It is N/A. - DRIFT — exit 1 with a JSON drift payload (
{"drift": true, "paths": [...]}, non-emptyadded/changed/removed, or a section diff). Capture the drifted paths. The fix is the regenerator in the table's third column. - BROKEN — the JSON carries a non-empty
validation_errorskey (a malformedgovernsentry, a malformed reconciliation ledger, a schema error). Regenerating does NOT fix a validation error; the named input must be repaired first. Report the problems. - CRASH — non-zero exit with empty or unparseable stdout (a missing dependency, an unhandled exception). Surface stderr; this is an environment problem, never a document finding.
- N/A — exit 0 with
"surface_absent": trueon the JSON. The verdict keys on that payload key, not on which gate printed it. Everyplugin-authoringgate emits it outside the plugin's own source checkout, carrying areasonthat names why the row does not apply; report the reason, and recommend no regenerator, because there is no output in this project for one to write. Four project gates emit it too:generate-reviews-index.pywhen the tree carries no<docs_dir>/adrs/reviews/, which is every project that has not yet run a decision review;generate-journal-index.pywhen the tree carries no<docs_dir>/journal/at all;generate-log-summary.pywhen the tree carries no<docs_dir>/log/, which is every tree whose operations log is not yet split; andextract-code-docs.pywhencode.extractorsis empty, which is every project that has configured no extractor. That last one used to exit 0 with EMPTY stdout and one line on stderr, so a reader aggregating exit codes counted it as a clean gate and a tree that had scanned nothing reported its code docs verified. There is no derived artifact, so nothing can have drifted, and nothing was measured either. Report it as N/A, never as clean — a gate that scanned an absent surface has verified nothing, and recording it green is the vacuous-green shape this skill exists to prevent. The fix is never the regenerator, and it differs by surface: considermigrate-adrswhen historical decisions need assessment,init-docswhen the journal surface was never created,cleanup-campsitewhen the operations log is not yet split, and configurecode.extractorsin<docs_dir>/manifest.ymlwhen no extractor is declared.
Warnings ride alongside, never change the verdict. Read any top-level warnings key (validate-catalog.py emits one — the models.yml verified: staleness clock; check-doctrine-reconciliation.py's S1 warn lane is similar). Surface it as WARNING beside the gate's verdict. A gate at exit 0 with a non-empty warnings list is a clean pass worth reporting with its warning, not a failure.
Shallow clones. A tree that has published a clause migration needs full Git history. In a shallow clone (the default actions/checkout depth of 1 in CI, for example) the governing readers (summaries, doctrine, rules catalog, arch and reviews index) refuse with history-unavailable. Set fetch-depth: 0 in CI, or run git fetch --unshallow locally. Report such a refusal as REFUSAL, never as drift.
3. The one roster exception — derive-arch.py --dry-run exit 2
derive-arch.py --dry-run has a third lane the others do not: exit 2, and stderr says which of two lanes it is (copy the CHK-ARCH-1 distinction exactly).
- Crash lane — a missing dependency or unhandled exception. Verdict CRASH; surface stderr; fix the environment.
- Deliberate refusal — stderr names
StaleProjectionInput. A spine file that projects a gated artifact declined because that artifact is not what its own regenerator produces. Nothing was written. This is not a crash and not arch drift. Verdict REFUSAL: report the capability failure, name the stale input from stderr, and recommend that input's own regenerator (validate-catalog.pyfor the skill catalog,generate-adr-index.pyfor the ADR index) followed by a re-derive. Do NOT recommend re-deriving arch as the fix — a re-derive reads the same stale input and refuses again.
4. Report one table
Print a single table with one row per gate and one row per validation check: name · verdict (clean / DRIFT / BROKEN / CRASH / REFUSAL / N/A) · drifted paths (or the problem / stderr summary) · the command that fixes it. Then the roster accounting, which keeps membership separate from execution result. Report all five counts, every time, even when some are zero:
enrolled <N> ROSTER ROWS -- membership, not a result
executed passing <C> rows whose gate ran and inspected >=1 configured input, no drift
failed <D> rows whose gate reported DRIFT / BROKEN / CRASH / REFUSAL
skipped/inapplicable <X> rows whose gate reported N/A: nothing configured, or no surface
no evidence <E> rows whose gate exited 0 having inspected ZERO configured inputs
Count ROWS, not commands. The unit is the repo-root roster row, because that is what
membership means; one command may cover several rows (validate-catalog.py covers both
skills.json and agents.json). Attribute a command's verdict to every row it covers, or the identity below fails
for a reason that has nothing to do with drift.
enrolled == executed passing + failed + skipped/inapplicable. The no evidence count is not a fourth disjoint bucket — it re-counts the rows that measured nothing, and every N/A row is one of them. It is reported separately because it is the number a reader needs and the other four hide: a clean process exit that inspected no configured inputs never establishes that those inputs were checked.
Never write "all gates clean" while skipped/inapplicable or no evidence is above zero. Say how many measured nothing, and name them.
A measured zero is not no evidence. A gate with extractors configured that finds zero drift inspected its inputs and found them in sync; that is a real pass and belongs in executed passing. Only a gate that inspected nothing belongs in no evidence. A gate that inspected the plugin's own copy of itself measured nothing about this project either, and is never recorded as executed passing for a project row — that reading is what let a downstream run report the plugin's 56 shipped skills as a clean project gate. Do not collapse the two, and never drop a row from the roster to improve the pass count -- membership is fixed by the repo-root AGENTS.md roster, not by how a run turned out.
For DRIFT rows, the recommended fix is the third-column regenerator. For BROKEN rows, the fix is repairing the named input, then re-running its regenerator — except a validation-check row, whose fix is editing the authored text the finding names, with no regenerator involved. For CRASH rows, the fix is the environment. For a REFUSAL row, the fix is the named upstream input's regenerator, then a re-derive.
5. Record the lint operation
One lint op entry (the same op verify-code-docs uses — a targeted check, distinct from audit's full walk). Write the entry through the log writer (<docs_dir>/AGENTS.md §6).[^log-writer] Write the body below to a file outside the tree, then run:
uv run "${CRUX_PLUGIN_ROOT}/scripts/operation-log.py" append --repo-root <repo-root> \
--op lint --subject 'check-drift (C clean / D drift / B broken / X crash)' --date YYYY-MM-DD --body-file <path>
The entry it writes at the top of the current month's detail file <docs_dir>/log/YYYY-MM.md:
## [YYYY-MM-DD] lint | check-drift (C clean / D drift / B broken / X crash)
Body, 1–3 lines: the summary line, and for any non-clean gate its name plus the regenerator that fixes it. On an all-clean pass, log it anyway — a verification is an event:
## [YYYY-MM-DD] lint | check-drift (all N gates clean)
A refused append adds no entry: fix the cause it names, then rerun the append alone (§6). Then run the commit step of §6 over the result's commit_paths and restore_paths.
6. Hand-off
- If every gate is clean, report the all-clean table and stop.
- If any gate drifted, list the exact regenerator command per drifted gate and let the user run them. This skill never runs them.
- If a gate is BROKEN or CRASH or REFUSAL, surface the problem and the specific next action; a release must not proceed on a broken gate.
[^scope]: rule:regenerator-declares-its-scope, rule:out-of-scope-is-surface-absent, rule:drift-report-carries-scope-and-reconciles
See also
verify-code-docs— the single-gate version: the read-only drift check for just thecode/concern. This skill is that pattern applied to every enrolled regenerator.audit-docs— the document-graph integrity walk; its CHK-CAT-3 / CHK-CODE-4 / CHK-ARCH-1 run three of these gates individually, and CHK-DRIFT-1 folds in the rest.compile-doctrine,derive-arch,link-adr-graph,extract-code-docs— the skills that actually regenerate the outputs this skill only checks.- The repo-root
AGENTS.md"regenerative outputs" table — the enrollment roster this skill's gate list mirrors. The validation checks of §1.A are deliberately absent from it.
[^retired]: rule:retired-cite-fails-lint — a retired slug fails the lint, and the failure names the rule that displaced it.
[^pubelig]: rule:shipped-citation-requires-an-accepted-decision, rule:an-ineligible-citation-refuses-the-projection
[^log-writer]: rule:log-entries-go-through-the-log-writer, rule:no-writer-writes-the-legacy-log-file
04 同仓库更多 Skills
whiteboarding
Explore an idea through docs-informed dialogue before committing to a design. Capture the exploration for later filing as a brief.
verify-code-docs
Check generated code documentation against source and report drift without regenerating it.
transition-observation
Apply a human disposition to an observation's lifecycle state without changing its claim or body.
transition-invariant
Ratify, reject, or retire an invariant on human direction. Update lifecycle metadata without changing the invariant's body.
transition-decision
Apply a human ratify, reject, or defer verdict to a recovered decision candidate; ratification creates a Proposed ADR or observation.
transition-brief
Publish or abandon a draft brief, updating lifecycle metadata and indexes without changing its body.