4.0 KiB
4.0 KiB
Change: Add Clean
Why
The check capability writes a machine report and a human report, but nothing acts on
them. The SessionStart banner already tells users their docs may be stale and
advertises /hygiene check; the check skill now delivers a report — but the feature
loop is still open: no /hygiene clean or /hygiene sweep exists, so the report
sits in .dochygiene/ and nothing is ever fixed. patch_applier.py and its 263
tests are already built; this change wires the remaining pieces so the plugin
actually remediates doc rot.
What Changes
patch_applier.py(already built — 263 tests pass): a standalone deterministic script that applies a report's entries to project files in per-file transactions, with a content-hash guard, incompatible-ops detection, and precise git staging. Marked DONE in the task list.skills/hygiene-clean/SKILL.md: the orchestration skill — loads the current report, partitions entries by safety tier and op type, gatesconfirm-tier entries with a batch-confirm prompt (per-entry opt-out), applies deterministic entries viapatch_applier.py, delegates generative entries to a Sonnet subagent (viaworkflows/distill.md), stages precisely, and commits once viagit-context commit-apply.workflows/distill.md: the generative Sonnet workflow invoked fordistill/split/generativeentries; isolated from the skill via a LOOP-GUARD subagent pointer.commands/hygiene.mdupdate: replaces the "not yet implemented (Phase 4)" stubs forcleanandsweepwith live routing to thehygiene-cleanskill.- Integration tests (
tests/test_clean_integration.py): fixture-repo tests covering invariant #5 GAP (dirty→checkpoint+exactly-one cleanup commit; clean→one commit; all-skipped→zero commits) and invariant #7 sweep-gating GAP (confirm escalates undersweep).
Capabilities
New Capabilities
doc-clean: the clean pipeline and its guarantees — thehygiene-cleanskill orchestration (load report → gate confirms → git preflight → apply deterministic entries → dispatch generative → stage precisely → single commit → stamplast_clean), the per-file transaction model inpatch_applier.py(content-hash guard, descending-anchor application, incompatible-ops detection, precise staging), safety-tier gating (invariant #7), git-safety (invariant #5: WIP checkpoint, single commit, tracked-files-only, rollback on hard failure), and thesweepcomposition (/hygiene sweep= check-then-clean without double-commit). One capability because the applier, the skill, the gating, and git safety are a single atomic pipeline — splitting them would scatter tightly coupled guarantees across capability boundaries.
Modified Capabilities
None. The doc-check capability is consumed, not modified — the clean skill
reads the report written by check without changing any check requirement.
Impact
- Affected specs: creates one new capability —
doc-clean. Consumes the frozenreport-schema,doc-scanner,state-store, anddoc-checkcapabilities without modifying them. - Affected code: introduces
skills/hygiene-clean/SKILL.md,workflows/distill.md, integration tests, and CONTEXT.md updates forskills/hygiene-clean/andscripts/. Updatescommands/hygiene.md(stub replacement only — no structural change).patch_applier.pyand its unit tests already exist and pass. - Out of scope (named owners):
token_estimateweighting (injection_frequency,weighted_tokens, bottom-up rollup) — v2 bonus per PRD phase 5.- Link rewrite after
move-to-archive— v1 moves only, next/hygiene checkflags new orphans. - Live model-classification regression harness — separate, manually invoked.
- Dependencies: depends on
report-schema(frozen),doc-scanner,state-store,doc-check(produces the report this change consumes), and the already-builtpatch_applier.py. No upstream capability specs are modified.