Skip to content
Toolkit

ADR-0131 — A deletion frees what the resource held, through one place

Status: Accepted · Date: 2026-08-30 · Track: 010 phase 04, third slice · Builds on: ADR-0129, ADR-0126

Context

A workspace's stored figure is derived from the rows that hold it (ADR-0129), which is what makes it impossible for the number to drift from the rows. It says nothing about the store. Deleting a row moves the figure to zero whether or not a byte was freed, and three delete paths were freeing three different amounts:

  • StaticPageHandler.Delete removed file_path — the archive — and left the whole bundle_prefix expansion behind. For a bundle that is the larger half, and it is the half with no other referent: once the row is gone, nothing anywhere records where that prefix was.
  • FileLinkHandler.Delete removed file_path, which for a file link is everything, by luck rather than by rule.
  • LinkHandler.Delete — which deletes a row of any type by id, a static page and a file link included — freed nothing at all. The same resource lost its bytes through one door and kept them through another.

So the figure and the store disagreed after every bundle deletion, and after every deletion at all through the generic path. A derived number exists to make that disagreement impossible; here it was making it invisible.

Decision

One function frees what a resource holds — releaseStoredArtifact(storage, settings) — and every path that deletes a resource calls it. Three properties, each a rule rather than a preference:

The expansion goes first. It is the larger half and the one with no other referent. The archive can be found again from file_path by anyone reconciling a bucket; a prefix nobody records is unreachable the moment the row is gone.

The release is best effort, and the deletion is not conditional on it. The row is going whatever the store says. A delete that refused because a byte could not be removed would leave the owner holding a resource they cannot get rid of, over a failure that is the operator's to reconcile. A failure is logged, which is where that reconciliation starts.

The generic path reads the row before deleting it, because what a resource holds on the store is only knowable from the row, and it releases only when the row is the caller's workspace's — the tenant test the deletion itself makes, made before the release rather than after. A row that cannot be read is still deleted: the release is what is skipped, never the deletion.

LinkHandler therefore takes a FileStorage, wired at the composition root.

Consequences

  • Deleting a bundle now frees its archive, its entries and its manifest, and the derived figure and the store agree afterwards.
  • The three delete paths free the same amount, because they run the same code. A fourth path added later that does not call it is the defect again — which is why the function exists rather than three correct copies.
  • Nothing is freed on released (009's lifecycle): an archive is served from the row itself, so its bytes outlive the name and not the row. Whether an archived resource's bytes should expire on their own is a lifecycle question and not this track's.

Source: docs/decisions/0131-a-deletion-frees-what-the-resource-held-through-one-place.md

Library