You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jcode session migrate: session storage migration & v2 sidecar fast-path for large sessions
Summary
Add a session-storage migration command (jcode session migrate [path] [--dry-run]) and a v2 sidecar format that pairs the existing JSONL log with an indexed SQLite sidecar so resume and /tree open large sessions in <100 ms. Mirrors pi migrate and pi_agent_rust's "Session Store V2 Sidecar".
Sidecar is regenerable from the JSONL at any time. Mismatched sidecar → treat as corrupt and rebuild.
2. Read path
On open:
mmap the JSONL.
If sidecar exists and is up to date (mtime + size match metadata), use it for index queries.
Otherwise, rebuild sidecar in the background while serving reads from the JSONL.
3. Write path
Every appended entry updates the sidecar in the same transaction the JSONL is fsync'd in.
Durability mode (see separate consideration): strict (fsync every write), balanced (fsync every N entries or T seconds), throughput (fsync on flush only). Pi_agent_rust ships these as --session-durability.
This issue should be split — recommend 5 sub-issues
The original body says "session migration & v2 sidecar fast-path" but pi_agent_rust treats this as five separable deliverables. Land them in order so each one is independently shippable and testable:
#17a — v2 sidecar SQLite index (fast resume/list)
SQLite file at ~/.jcode/agent/sessions.idx.db with WAL + a *.lock file.
Picker that benefits from a fast index: src/tui/session_picker.rs + src/tui/session_picker/loading.rs (the latter already does deferred loading, but is bound by the underlying file scan).
jcode session migrate: session storage migration & v2 sidecar fast-path for large sessionsSummary
Add a session-storage migration command (
jcode session migrate [path] [--dry-run]) and a v2 sidecar format that pairs the existing JSONL log with an indexed SQLite sidecar soresumeand/treeopen large sessions in <100 ms. Mirrorspi migrateand pi_agent_rust's "Session Store V2 Sidecar".Reference:
pi_agent_rustSession Indexing and Session Store V2 Sidecar (Large Session Fast-Path).Why
Current state in jcode
src/session_active_pids.rsandsrc/storage/exist; no v2 sidecar, no migration command.src/tui/session_picker/loading.rs) parses each JSONL on demand, which gets slow on large sessions.Implementation checklist
1. v2 sidecar schema
.sqlite3sidecar with tables:entries(id PK, parent_id, ts, kind, branch_leaf_marker, byte_offset, byte_len)branches(leaf_id PK, name, labeled_at)metadata(key PK, value)2. Read path
3. Write path
strict(fsync every write),balanced(fsync every N entries or T seconds),throughput(fsync on flush only). Pi_agent_rust ships these as--session-durability.4. CLI subcommand
jcode session migrate [path] [--dry-run] [--force]path:~/.jcode/sessions/recursively.--dry-run: print what would be migrated; no writes.--force: rebuild sidecars even when up to date.jcode session verify <path>to check sidecar/JSONL coherence.5. Resume picker speedup
6. Doctor integration
jcode doctor --only sessionsreports number of sessions, total size, sidecar coverage, last migrate time.Testing
Unit
strictmode survives a kill -9 between writes with no entry loss.Bench
Manual
/treeopens fast.Acceptance criteria
jcode session migrateis idempotent and lossless.--dry-runpreviews accurately.References
pi_agent_rust: Session Indexing, Session Store V2 Sidecar, Subcommandpi migrate.Tracking: physically split into sub-issues
This issue is now an umbrella. Concrete work lives in:
--session-durability strict|balanced|throughputflag #35 — [#17c]--session-durability strict|balanced|throughputflagjcode session rollback#36 — [#17d] Rollback ledger + periodic checkpoints +jcode session rollbackjcode session migratesubcommand: idempotent v1 → tree-aware schema upgrade #37 — [#17e]jcode session migratesubcommand (idempotent v1 → tree schema)Land in order. Close this issue when all five sub-issues are closed.
Implementation notes addendum (Devin gap-analysis pass, 2026-05-21)
This issue should be split — recommend 5 sub-issues
The original body says "session migration & v2 sidecar fast-path" but pi_agent_rust treats this as five separable deliverables. Land them in order so each one is independently shippable and testable:
#17a — v2 sidecar SQLite index (fast resume/list)
~/.jcode/agent/sessions.idx.dbwith WAL + a*.lockfile.(cwd, last_modified),(session_id),(tag).mtimenewer than its row, mark stale; reindex affected rows on first read.#17b — Crash-resilient save path (temp file + atomic persist)
appendFileSync-style writes withwrite_temp_then_rename. On crash mid-write, the previous version of the file is intact.src/session.rs.#17c —
--session-durability strict|balanced|throughputflagstrict: fsync after every entry (slow, safest)balanced(default): fsync every N entries or T msthroughput: rely on OS page cache#17d — Rollback ledger + checkpoints + segmented log
(timestamp, branch_leaf, checkpoint_path).jcode session rollback <session-id> [--to-checkpoint <ts>].#17e —
jcode session migratesubcommand--dry-run,--all,--session <id>.Verified jcode code paths
src/session.rs,src/session/.src/tui/session_picker.rs+src/tui/session_picker/loading.rs(the latter already does deferred loading, but is bound by the underlying file scan).Cross-references
/tree,/fork,/clonein-place navigation #2 Tree branching — both this issue and Session tree branching:/tree,/fork,/clonein-place navigation #2 bump the session schema; align so they land as one consistent v3 format.jcode doctordiagnostic command #8jcode doctor --only sessionsshould detect stale index and missing checkpoints.Reference