Skip to content

Sessions: canonical v1 writer and cross-process ownership - #185

Merged
oratis merged 8 commits into
mainfrom
codex/session-writer
Aug 2, 2026
Merged

Sessions: canonical v1 writer and cross-process ownership#185
oratis merged 8 commits into
mainfrom
codex/session-writer

Conversation

@oratis

@oratis oratis commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • define one canonical <id>.v1.jsonl schema for core and desktop writes
  • normalize legacy core/desktop sessions into an atomic sidecar stream on first write without changing legacy bytes
  • use the same create-new <id>.writer.lock ownership contract in TypeScript and Rust
  • prefer canonical reads, deduplicate listings, and preserve legacy metadata during Rust normalization
  • make explicit archive/delete operate on both generations
  • document format, recovery, corruption, and stale-lock policy

Validation

  • pnpm docs:check
  • pnpm lint (3 pre-existing warnings, 0 errors)
  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • cargo check --manifest-path apps/desktop/src-tauri/Cargo.toml
  • cargo test --manifest-path apps/desktop/src-tauri/Cargo.toml (32 passed)

Stack

Depends on #184 through #180. This completes the canonical writer/ownership slice; stale-lock recovery moves to the future single-owner app-server rather than unsafe client lock stealing.

@oratis
oratis changed the base branch from codex/runtime-host to main August 2, 2026 06:36
@oratis
oratis marked this pull request as ready for review August 2, 2026 06:39
@oratis

oratis commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

Review: approved ✅

The write-side counterpart to #182, and the ordering (read compatibility first, then canonical writes) is correct.

What I checked

  • Legacy bytes are never rewritten. Normalization goes into a separate atomic <id>.v1.jsonl sidecar stream on first write. Combined with Sessions: dual-read legacy formats with corruption diagnostics #182's non-mutating reads, this means a bad canonical writer can be rolled back by deleting sidecars, with legacy history intact. That is the property that makes this safe to ship.
  • <id>.writer.lock uses create-new semantics in both TypeScript and Rust. Same contract on both sides is essential — CLI and desktop genuinely can run concurrently against one session, and a lock that only one implementation honours is worse than no lock, because it looks safe.
  • Listing dedup across generations prevents the same session appearing twice during the transition window.
  • Archive/delete operating on both generations is easy to forget and would otherwise leave orphaned legacy files after a user explicitly deleted a session — a privacy-relevant miss. Good that it's handled.
  • docs/design/session-format-v1.md documenting stale-lock policy and recovery is what makes this maintainable; an undocumented lock protocol rots fast.

Follow-up worth tracking (not blocking): stale-lock recovery is the part most likely to bite in the field (hard kill leaves the lock behind). The policy is documented; a real crash-and-recover drill would be a good addition whenever the release-gate drills in #208 get exercised.

Validation: CI green; full suite green locally at the stack tip.

@oratis
oratis merged commit 2e1ee48 into main Aug 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant