Skip to content

Consolidate atomic JSON persistence primitives #144

Description

@lastobelus

Outcome

Consolidate Markover atomic JSON file replacement behind one well-tested internal primitive while preserving each store's supported scheduling, ownership, recovery, and shutdown behavior.

Problem

Markover implements the same store-level same-directory temporary write and atomic rename independently in:

  • src/review-store.ts;
  • src/workspace-store.ts;
  • src/settings-store.ts; and
  • src/service-endpoint.ts.

The implementations differ in exclusive temporary creation, byte flushing, file mode, explicit chmod, cleanup, and retry behavior. Keeping these copies increases the chance that a durability or privacy fix reaches only some stores.

The earlier enrichment target is stale: #156 removed the unused private-enrichment runtime and preserved any sidecar bytes without a replacement store. PR #161 also removed unsupported cross-process settings locking and live watching while preserving the in-process queue and atomic replacement.

Acceptance criteria

  • Define one internal atomic JSON replacement primitive with same-directory temporary files, exclusive wx creation, complete-byte flush before rename, user-only file mode where supported, explicit non-Windows permission enforcement where needed, atomic rename, and temporary-file cleanup.
  • Migrate review, workspace, settings, and service-endpoint writers whose file-replacement requirements match.
  • Keep store-specific scheduling outside the primitive: review serialization, workspace latest-snapshot and shutdown behavior, the settings in-process writer queue, and service-endpoint ownership remain independently testable. Preserve Simplify settings writer topology #161's supported settings topology; do not reintroduce cross-process settings locking or live settings-file watching.
  • Preserve existing JSON formatting, paths, error behavior, schemas, and public contracts unless a separately justified correction is recorded.
  • Add direct primitive coverage plus store-specific regression coverage for successful replacement, failure before rename, cleanup, concurrency/ordering, and restart or shutdown behavior where applicable.
  • Gate POSIX permission assertions on platforms that expose POSIX mode semantics.
  • Run the complete local CI suite and verify that no portable review, private workspace, settings, or service-endpoint behavior changes unintentionally.
  • Deliver as a child of PR Add private remote attachment retrieval #191, address automated review, then retarget the green pull request to main after PR Add private remote attachment retrieval #191 merges.

Scope boundaries

  • Internal durability and refactoring only; no user-facing feature or settings change and no UI QA.
  • No persistence schema migration, compatibility reader, or data rewrite.
  • Do not replace higher-level queues, locks, mutation gates, recovery policy, or lifecycle ownership with a generic abstraction.
  • Startup diagnostics, instance descriptors, remote creation journals, create-only credentials, and directory publication have separate lifecycle or ownership contracts and are outside this named store slice.

Relationships

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions