Skip to content

store: finish JSONL durability guarantees #469

Closed

Description

@JAORMX

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.go
  • internal/adapter/store/jsonlstore/resolve.go
  • internal/adapter/store/jsonlstore/eventlog.go
  • engine/adapter/sessnap/sessnap.go
  • engine/port/store.go

Completed foundation

Activity

  1. changed the title [-]store: make JSONL session snapshots crash-safe and recoverable[/-] [+]store: finish JSONL durability guarantees[/+] on Aug 17, 2026
  2. self-assigned this
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions