Repository navigation
v0.0.3 — deletion, and the erasure ordering trap
Purely additive over v0.0.2: 13 new exported identifiers, nothing removed and nothing changed. Existing code compiles untouched.
go get github.com/antst/go-yjs@v0.0.3
What is new
backend/persistence gains a Deleter, because it had no way to remove a document's durable state at all — not on either profile, not anywhere. An application holding only the contract could create and replace forever and never erase, so every deployment had to reach around the contract to its own backend. Owner-delete cascades, tenant deletion and erasure requests are ordinary requirements of anything storing user content.
type Deleter interface {
Delete(context.Context, DeleteRequest) error
}DeletingStore and DeletingCheckpointStore compose it with each profile, mirroring CompactingStore.
Optional rather than mandatory
The obvious objection: compaction is a performance strategy, deletion is compliance, so Delete belongs on the store interfaces directly.
It loses to a case that objection does not consider — some media are forbidden to delete. WORM storage, object locks, regulated archival. The same compliance pressure demanding erasure in one regime demands immutability in another. A caller needing erasure type-asserts and fails loudly when it is absent, which beats an implementation whose Delete silently does nothing.
Semantics
- Idempotent — deleting an absent document returns nil, never
ErrNotFound. A cascade retries; the second attempt must not fail the operation it is completing. - Strict, not eventual — after
Deletereturns nil, a subsequent load MUST reportErrNotFound. A load still returning content is indistinguishable from the delete not happening. - Fence-aware, with a rejected delete leaving state intact — a superseded owner must not erase what its replacement is serving.
- Context-honouring.
The ordering trap
This existed before this release and applied to anyone deleting out of band.
Deleting durable state while a document is live resurrects it: the live document is unaffected and its next save writes the state back. Registry.Invalidate is necessary and not sufficient — it drains the current generation, and a later Acquire opens a fresh one from storage that has not been deleted yet.
Erasure needs three steps: stop admitting acquisitions (application state the OpenFunc consults), then Invalidate, then delete. Getting it wrong loses no data and reports no error; it silently restores content that was supposed to be erased. Documented on both Deleter and InProcessRegistry.Invalidate.
Tests
Eleven subtests across three suites, including that a document can be written again after deletion without its old history returning.
Ten deliberately broken stores now run against the conformance suites in child processes and each must fail — six for the checkpoint contract, four for deletion (non-idempotent, leaves state, purges everything, ignores cancellation). The rejection test fails if either violation list is empty.
Status
crdt/ and protocol/ remain ready to build on — differential oracle across 13 surfaces in both directions on every push, both codecs byte-exact, 20 fuzz targets over the untrusted-byte surface.
The backend layer has now had four contract gaps found by a single real port, in two days. That is the argument both for shipping conformance suites and for continuing to treat the layer as young. Nothing here has run for a week.