Shapes now carry a content fingerprint (signature + whitespace/comment- insensitive body_sha; migration 0080) and the proposer runs inside the coverage refresh, the one moment bodies exist: symbol elsewhere → textual containment → body references the canon → signature resemblance → semantic (capped per refresh, unreached rows stay unexamined for the next). A hit is a proposal on the row (proposed_snippet_id/basis/score), never a classification; rows with no canon hit group by the derive-first rule (identical body in ≥2 places, same name in ≥3 files) as proposal_basis= derive + a group key. list_shapes(proposal=any|canon|derive|<basis>) is the queue; confirm_shape_proposals(project_id, snippet_id|path|basis) confirms in batches as agent instances; any classify_shapes/hook stamp retires the proposal. Readout carries proposed + derive_groups (line, payload, card). Plugin 0.1.35 (skill: the machine proposes, judgment classifies). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4.9 KiB
name, description
| name | description |
|---|---|
| shape-accounting | Use when a project's shape accounting needs attention — the pattern_coverage line from enter_project shows unclassified shapes or is missing on a forge-served project, the operator asks about coverage/accounting/canon, or you just proved a code-to-canon relationship (an audit enumerated call sites, a consolidation repointed consumers, a verify pass confirmed a helper's users). Triggers on "coverage", "accounted", "unclassified", "classify shapes", "what uses this", or finishing any consolidation. |
Shape accounting — every shape classified against canon
The snippet library records canon (small); the shape ledger accounts for every extracted definition in a project's bound repos (total). Each ledger row carries a status:
canonical— IS a snippet's reference (the coverage sync stamps these mechanically; you rarely set it).instanceof snippet N — conforms to recorded canon. Canon in another project counts (a family-level button shape fully accounts for a local use).variantof snippet N — a deliberate, named departure. Reason required — the why IS the record.exempt— judged genuinely one-off. Reason required. A recorded judgment, not silence — it stops the next pass re-litigating it.unclassified— nobody has judged it yet. This is the todo list.
The loop
- Seed / refresh — the ledger fills from coverage computation. Entering a
project triggers a background seed automatically; when you need it current
now (before a classification batch, or when the line is missing on a
forge-served project), call
refresh_pattern_coverage(project_id)— it returns the fresh accounting line. Takes seconds; it moves repo archives. - Read the todo —
list_shapes(project_id, status="unclassified"), optionally scoped bypathto the directories the coverage line names as largest.snippet_id=Nreads a consumer map. - Judge in batches —
classify_shapes(project_id, [{path, symbol, status, snippet_id?, reason?}]). All-or-nothing: a bad item applies nothing. Rows, never prose — a consumer list in a note or verification detail cannot be sorted, queried, or diffed.
Rows that arrive on their own
Two feeds keep the ledger current between your batches, so most shapes never need a hand judgment:
- The sync stamps a snippet's own reference location
canonical(classified_by: mechanical). - The write path stamps instances as you work: when you
get_snippeta canon and then Write/Edit code that references or resembles it, the definitions being written land asinstancerows (classified_by: hook, the evidence inreason), and the prior-art hook tells you what landed ("Shape accounting: recorded at … → instance of #N"). Offered-but-unopened snippets stamp nothing — so pull the canon you are instantiating; that pull is what turns your reuse into accounting. A hook row is evidence, not judgment: it never overrides a classification you made, and aclassify_shapescall overrides it.
The machine proposes, judgment classifies
Every coverage refresh runs the mechanical proposer over the unclassified rows: same symbol as a canon elsewhere → textual containment → body references a canon → signature resemblance → semantic (capped per refresh). A hit is a proposal on the row, never a classification. Work the queue in bulk:
list_shapes(project_id, proposal="canon", snippet_id=N)orpath="dir"— read the page;proposalcarries snippet_id, basis, score.confirm_shape_proposals(project_id, snippet_id=N)(orpath=,basis=) for the ones that hold — hundreds at a time;symbolandreferenceproposals are near-certain,semanticdeserves a look.classify_shapesthe rest — variant, exempt, or instance of a different snippet. Any judgment retires the proposal.
list_shapes(project_id, proposal="derive") lists the derive-first
candidates — the same body in ≥2 places or the same name defined in ≥3
files, with no canon at all (proposal.group names the family; the coverage
payload's derive_groups ranks the biggest). That is the consolidation
queue, not a classification queue: see below.
The derive-first rule
N same-shaped occurrences matching no recorded canon is never N loose
classifications — it is a consolidation candidate: derive one reference from
the dominant form, create_snippet it, migrate the outliers, then classify
the rest as instances. Canon is determined from the code; consistency comes
from the derivation, not from asking permission.
What this buys
Divergence becomes mechanical: when button B appears where button A is canon,
the ledger says unintended divergence or justified variant with its
reason — nobody re-derives the history. get_snippet shows each snippet's
instances and variants, so "what uses this?" is answered from rows before
any contract change lands on its consumers.