Repository navigation
feat(storekit): OrphanedLayouts(root) — the ONE orphan-layout discovery both sweep closes need (closes #393) - #394
Conversation
…very both sweep closes need Two closes of one ruling need the same discovery and R2 forbids two copies: the `charly-registry` store cutover (#12) sweeps the pre-store per-ref layouts a deleted writer left INSIDE the store's own tree, and `charly-registry#11` sweeps the pre-rename `~/.cache/charly/images` root. Discovering orphaned layouts is a property of the store layout, not of any policy a plugin owns, so it belongs here beside the store it inspects. - The predicate is `NamedStores()`'s marker test INVERTED: one `LayoutFile` constant read two ways — what is a store at a cache root is junk inside a store. - The CALLER names the root, because liveness is policy and this is mechanism. The function cannot answer "no merged writer still writes this" (`NamedStores()` cannot either — it returns exactly the marker-carrying children in question), so the contract is the opposite: the caller passes a root in which a marker-carrying child cannot be live — a store's own tree (orphan by construction) or a root the migration table retired. - Discovery and sizing only, never deletion: the destructive half stays with the surface that also reports it (`--dry-run` first). - `Orphan.Bytes` counts every file in the tree, the marker included — a size that omitted it under-reported a real sweep (measured while writing the first consumer's assertion). Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Change class: code (sdk Go mechanism kit Security screen: PASS — no scope mismatch (diff = the two described files), no secrets/egress/network, no guardrail or supply-chain change, not security machinery. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
Closes #393. Two closes of one ruling need the same discovery and R2 forbids two copies:
charly-registry's store cutover (#12, merged) sweeps the pre-store per-ref layouts a deleted writer left inside the store's own tree, andcharly-registry#11sweeps the pre-rename~/.cache/charly/imagesroot (measured still present,3.5M). Discovering orphaned layouts is a property of the store layout, not of any policy a plugin owns, so the boundary law puts it here, beside the store it inspects — one definition, both closes.Three properties, each deliberate:
NamedStores()'s marker test, INVERTED.NamedStores()calls a marker-carrying child of the cache root a store; the same directory inside a store's own tree is junk — a store keeps every byte inblobs/<alg>/<digest>and its entries inindex.jsonand never reads a child layout. OneLayoutFileconstant, two directions, so the two readings cannot drift — and a test asserts the agreement rather than trusting it.NamedStores()answers nothing here either (it returns exactly the marker-carrying children in question), so a function that tried to guess "no merged writer still writes this" would be policy wearing a mechanism's name. The contract is the opposite: the caller passes a root in which a marker-carrying child cannot be live — a store's own tree (a child layout is an orphan by construction) or a root the migration table retired (the caller's justification, recorded in that migration).--dry-runfirst, then the removal). A missing root returns(nil, nil), the same shapeNamedStores()uses.Orphan.Bytescounts every file in the tree, the marker included — that is whatos.RemoveAllreclaims, and a size that omitted the marker under-reported a real sweep by the marker's own bytes. (I made that exact mistake in the first consumer's assertion; the contract now names it so the next reader does not.)What this is NOT: not a liveness oracle, not a recursive walker (direct children only, pinned by a test), not a deleter, and not a second copy — the local
orphanedLayoutsincharly-registrybecomes a delegation to this function in the follow-up consumer leg.BLOCKS
plugin-cleanapplying this to~/.cache/charly/images(the half that closescharly-registry#11) andcharly-registry'scache sweepdelegating here instead of keeping its local copy. Blocking artefact: this mechanism's publication — both consumers must depend on a MERGED, TAGGED ref (Policy B), never on a branch or a local copy. Unblocks on: this landing onmainand being tagged by the org'stag-on-merge.sdk#393with theCLAIM(6178608434), whereoci-plugin-lead(this package's owner, task-12) can take the leg instead if it prefers.How tested
On the committed head
6af34ebaa1d66c5ae7cfad2582e183ea1146aad4(tree304aaa27b392d2c7c16dd78e7a3325ea698a8e05):The coverage fails without the change (mutation, not assertion)
Both mutations were reverted; the suite is green on the committed tree, and discovery deletes nothing — one arm asserts the orphan is still on disk after the call.
Rulebook compliance
/charly-internals:plugin,goandgit-workflowloaded; this repo'sAGENTS.mdread, and its placement rule honoured: a reusable mechanism library consumed by more than one plugin, kind-blind, free of capability code. This is a store-layout mechanism with no policy in it.sdk#390,sdk#391) are separate mechanisms with their own root fixes and are not touched here.charly-registry#11sweep) arrives as the trigger, and the copy incharly-registrybecomes a delegation rather than staying a sibling implementation.(nil, nil)rather than an error a caller must swallow.git statuschecked before staging; no force-push, no amend after the first push.GOWORK=offon the committed tree, so nothing resolved through a workspace the consumers do not have.charly/pr-validatoris the merge gate.Change classification
A Go mechanism addition in the sdk library (
storekit/orphans.go+storekit/orphans_test.go, 258 lines added, no schema and no wire change — the CUE source lives inspecand is untouched). Behavioural dependency for two consumers, both gated on this landing and being tagged (Policy B).Filed issues
OrphanedLayouts(root)— the ONE orphan-layout discovery both sweep closes need (the predicate is NamedStores() inverted; the caller names the root) #393 — this mechanism (claimed here, with the contract and the two waiting consumers).~/.cache/charly/imagesorphan.orphanedLayoutsthis replaces by delegation.Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)