Repository navigation
Description
Status
Partially addressed by #491. That work repaired the most immediate torn-snapshot failure modes:
- a torn or undecodable latest snapshot no longer prevents Save, Delete, or sidecar access;
- appending after a torn tail inserts a record boundary instead of gluing records together;
- the newest prior valid snapshot remains loadable;
- persistence failures are operator-visible; and
- torn-snapshot and related ownership/retention cases have regression coverage.
This issue now tracks the remaining durability contract rather than repeating that completed work.
Remaining problem
The local JSONL store still uses unsynced append writes and process-local synchronization. A successful Save therefore has no documented power-loss durability boundary, multiple mecatl processes sharing a directory do not have a general cross-process serialization contract, and a torn events-log tail still terminates replay with an error after yielding the valid prefix.
Desired outcome
Finish the local JSONL durability model so operators know exactly what a successful write guarantees and interrupted or concurrent access cannot hide an otherwise valid snapshot or event history.
Remaining scope
- Define and document the durability boundary, including whether successful Save/EventLog append implies file and directory
fsync. - Add cross-process coordination for snapshot and sidecar mutation, or explicitly reject unsupported shared-directory use with an enforceable guard.
- Decide and implement recovery semantics for a truncated/corrupt final EventLog record while preserving the valid prefix.
- Verify snapshot replacement/append, deletion, listing, and sidecar ordering under interruption.
- Add multi-process and failure-injection tests for the remaining guarantees.
- Update architecture/implementation notes and user-facing storage/privacy documentation.
Acceptance criteria
- The documented contract states exactly when snapshot and event writes are durable against process crash and power loss.
- Concurrent processes cannot expose malformed snapshot bytes as the successful latest state or interleave sidecar records.
- A torn final events record has an explicit, tested recovery policy; prior valid events remain usable.
- Interrupted mutation and deletion preserve a recoverable, explainable store state.
- Existing stores remain readable without manual migration, or an explicit migration path is provided.
- Failure-injection coverage includes process interruption and concurrent-process access, not only goroutines.
-
task lint,task test, and the offline demo remain green.
Relevant code
internal/adapter/store/jsonlstore/jsonlstore.gointernal/adapter/store/jsonlstore/resolve.gointernal/adapter/store/jsonlstore/eventlog.goengine/adapter/sessnap/sessnap.goengine/port/store.go
Completed foundation
- fix(jsonlstore): opaque session ids — review follow-ups on #464 #491 — opaque session IDs and torn-snapshot review follow-ups
Activity
[-]store: make JSONL session snapshots crash-safe and recoverable[/-][+]store: finish JSONL durability guarantees[/+]