ox plan · re-scoped and trimmed 2026-09-29 · replaces the broader capture-and-import split plan
Import past Claude Code and Codex sessions
One command, ox session import, uploads the Claude Code and Codex sessions a coworker ran in this repo before SageOx, or outside it, to the team's Ledger. Every selected session is uploaded once, with its summary created on the coworker's machine first, and nothing changes on the server or in live capture.
Overview
Everything else from the earlier plan is out of scope: durable live capture, streaming, server-side processing and the large-session viewer. Handling deleted sessions is out of scope too, and four guards are deferred until usage shows they're needed (see What we cut). This is one PR behind #999, with three decisions to make first.
What ships
One command, one PR
About 1.55k production lines and 1.8k test lines, behind #999, whose redaction fix makes credential-command output redaction work on native history. No server change, no change to live capture, no go.mod change, no new meta.json field, and no new Ledger location.
How it's exactly-once
The Ledger is the index
Each session's Ledger name and ses_ ID are pure functions of the native session: its start time, agent and native ID. Re-runs, crashes and a second machine all land on the same path. There is no import journal and no durable local state. An import only adds new directories, never edits a tracked file, and matches none of the daemon's retry paths (see Risks, #1105–#1107).
Decisions needed
- Ryan approves the import name and one local cache path. The name is the dedup key. default: approve
- Partial sessions (ox recorded only part of the session): don't upload the missing part in v1. default: not in v1
- Validation failures: upload a deterministic fallback summary instead of holding the session. default: fallback
Biggest risk
Each session is imported once
Import takes a snapshot. Activity added to a session after its import stays out of the Ledger unless ox records it live, and so does the beginning of a session ox started recording late (decision 2). The preview counts both, so nothing is lost silently.
Every selected session
Uploaded, or explicitly reported
Each candidate ends in exactly one state: uploaded, listed with a reason, or failed with the exact retry command. Nothing is dropped silently, and the run exits 1 if anything failed.
Never twice
One Ledger copy per native session
An import is skipped if the session is already imported, ox recorded it live (finished or still pending upload), or it's still running. Recordings from older ox versions are recognized by ox's own marker in the transcript. Name collisions converge on one directory and one ses_ ID. Not covered in v1: sessions removed from the Ledger or aborted earlier.
Summary first
Nothing lands without one
The CLI summarizes each session with the coworker's own claude or codex, isolated with no tools and no session persistence, before anything is written to the Ledger. The daemon never summarizes an import.
Sessions run one at a time, so a crash costs at most one session's work. Real transcript bytes never touch sessions/: the directory enters the Ledger already pointerized, which is stricter than the live stop path. Click a step to inspect it.
Step 04 · summarize
Summary before anything is written
- Prompt:
BuildInlineSummaryPromptover a transcript trimmed to about 300k characters, keeping the head, the tail and evenly spaced middle turns. - Runner: the session's own vendor (
claudeorcodex) with tools disabled, no session persistence and recording off. - Runner failures are held and retryable. Validation failures are re-prompted twice, then get a deterministic fallback (decision 3).
Crash hereOnly staging exists. The next run sweeps it and redoes this session.
| Step | What happens | Code on main it reuses | If it crashes here |
|---|---|---|---|
| 01 Discover | Scans ~/.claude/projects (depth-2 <uuid>.jsonl only) and $CODEX_HOME sessions plus archived sessions, reading structure only. A session belongs to this repo when every working directory it used resolves to this repo's git common dir. The same session filed under two folders collapses to its longest copy. | New nativeimport package; the Codex walk is ported from the archived C3 codexhistory. | Nothing written. |
| 02 Classify | Builds a Ledger index and gives every candidate exactly one state (see Exactly once). The preview stops here, with no LLM call and no writes. | Ledger HEAD tree, meta.json native_sessions and session_id, local capture carriers, recording states. | Nothing written. |
| 03 Convert + redact | Adapter read of the exact discovered file, converted into raw.jsonl through a strict RawWriter that refuses on any broken team rule. | adapters.Read, ConvertRawEntries, RawWriter, #999's credential-output redaction. | Staging swept, session redone. |
| 04 Summarize | Isolated vendor CLI, with bounded retries and two failure classes (see Summaries first). | BuildInlineSummaryPrompt, agentwork runners, WriteSessionArtifacts. | Staging swept, session redone. |
| 05 Stage + scan | Writes the metadata and runs an uncapped secret scan with chokepoint auto-redaction in staging. A residual finding holds the session back. | MutateSessionMeta, scanPaths (with a new cap parameter), autoRedactSessionFindings. | Staging swept, session redone. |
| 06 LFS upload | Uploads the content, then writes the pointer files inside staging. An upload failure holds the session; import never falls back to committing content. | lfs.UploadSessionFiles, WritePointerFiles. | Staging swept; the uploaded objects are harmless orphans. |
| 07 Rename + commit | Under the repo lock: recheck that HEAD lacks the name, check that staging holds only known artifact files, rename it into sessions/<name>/, then run a scoped commit. | WithRepoLock, gitutil.CommitLedgerSnapshot. | Committed locally; the next run pushes it first. |
| 08 Push | Pushes with retry and the Ledger's accept-theirs rule on sessions/. Pushes go out in batches, every 10 sessions and at the end of the run, so a bulk import causes only a few pull/rebase cycles. If another machine landed the same session first, the two converge on one directory and one ses_ ID. | pushLedger, PushWithRetry. | On the remote; the next run reports it as already imported. |
| 09 Notify | Fire-and-forget upload notification keyed by the deterministic session_id. A 404 or 409 counts as success. | notifySessionUploaded. | The session is in the Ledger; a missed notify is tolerated. |
Session IDs
Four identifiers are involved, and import adds no new kind of ID. Live recording mints its IDs at random. Import instead derives the two IDs ox owns from the one Claude Code or Codex already assigned, and that derivation is what makes it exactly-once without a journal.
Existing sessions · unchanged
Nothing already uploaded gets a new name or ID
The new derivation applies only to sessions created by ox session import.
- Live recording keeps working exactly as today. It still mints
ses_<UUIDv7>at start and names sessions<time>-<username>-OxXXXX. - Every session already in the Ledger keeps its name and
ses_ID. Import only reads theirmeta.jsonto skip sessions ox already recorded. Its commits add only its own newsessions/…-import-…/directories and never modify an existing tracked file, not evensessions/.gitignore. - Recordings without a
session_idkeep deriving the same ID. The namespace (legacySessionNamespace, documented as "must never change") stays as it is. Import applies the same formula to new names. - No collisions. A live name ends in the ox instance ID (
Oxplus 4 characters), and an import name ends in a full native session UUID after-import-<agent>-, so the two can never be equal. Live IDs are UUIDv7 and imported IDs are UUIDv5, so those sets can't overlap either. - Links already in circulation keep resolving:
/c/URLs,SageOx-Sessiontrailers and PR bodies.
The plan doesn't change the live path at all.
Assigned by Claude Code or Codex
Native session ID
3f9a1c2b-7d4e-4a01-9c55-2b8e0f6d1a73
Claude: the transcript's filename, repeated as every record's sessionId. Codex: the rollout's filename, repeated as session_meta.payload.id.
native start (UTC, to the minute), -import-, the agent, then the native ID verbatim Derived by ox
Ledger session name
2026-09-12T14-03-import-claude-3f9a1c2b-7d4e-4a01-9c55-2b8e0f6d1a73
The directory sessions/<name>/. The prefix is the session's own first timestamp in UTC, never the current time.
UUIDv5 of repo_id + "/" + name in ox's legacy namespace Derived by ox
SageOx session ID
ses_1106b069-bd55-538d-9919-65adbb9337f2
The link https://<endpoint>/c/ses_…, and the key the server stores the session under.
The example values are computed exactly: a hypothetical Claude session 3f9a1c2b-7d4e-4a01-9c55-2b8e0f6d1a73, first entry at 2026-09-12 14:03 UTC, in a hypothetical repo repo_0198a3c4-5e6f-7a8b-9c0d-1e2f3a4b5c6d. The namespace is legacySessionNamespace, 5e6238b7-9403-4ee4-b5ec-8a6d37a5de14 (internal/lfs/meta.go:35).
Today versus this plan
| Identifier | Live recording on main today | Imported session under this plan |
|---|---|---|
| Native session ID | Since v0.17.0 (#1025), recorded in meta.json native_sessions[] as {id, source, first_seen, last_seen}. source is the reason the agent's session started: startup, resume, clear or compact. Recordings made before v0.17.0 have none, so import recognizes them by ox's own marker in the native transcript instead (see Exactly once). | Read from the native file, which is rejected if any record disagrees. Recorded as native_sessions: [{id, source: "import", first_seen, last_seen}], where the two times are the earliest and latest imported entries. |
| Ledger session name | <UTC time at recording start>-<username>-<OxXXXX>, for example 2026-09-12T14-03-lau-Ox7f3a (GenerateSessionName, store.go:84). It depends on when recording started and which AI coworker instance started it. | <native start, UTC>-import-<claude|codex>-<native session UUID>. A pure function of the native session, so it's the same on every machine and every retry. |
| SageOx session ID | ses_<UUIDv7>, minted at random when recording starts (recording.go:1261). It's carried in .recording.json and the raw.jsonl header from the start, because it goes out during the session in SageOx-Session trailers and PR bodies. It's written to meta.json at upload. Recordings older than the session_id field have none, and ox and the server both derive ses_<UUIDv5(repo_id/name)> for them (EffectiveSessionID, meta.go:1206). | ses_<UUIDv5(repo_id/name)>: the same legacy derivation, applied to the deterministic name. Written explicitly to meta.json session_id and to the raw.jsonl header, so the two always agree. |
| AI coworker instance ID | OxXXXX: the last segment of every live name, and meta.json agent_id. | None. No live AI coworker instance is behind an import, so agent_id is empty and the name can't collide with a live one. |
There was no importer on main before this plan. The archived C4, never merged, named sessions <start to the second>-codex-import-<sha256 of repo, native ID, generation and content digest>. Because the name hashed the content, a session that grew got a new name and a new ses_ ID unless C4's ~450-line append-only extension path kept the old one. This plan puts only identity in the name: the native ID itself, and no content.
What each choice solves
Derived, not minted
One ID from every retry and machine
A random ses_<UUIDv7> per attempt would give one conversation two IDs whenever an upload is retried after a crash, or two machines import the same history: two /c/ links and two server records. Live recording can mint at random because the ID goes into the raw.jsonl header the moment recording starts, and every later step reads it back. An import has no earlier state to keep it in. Deriving it replaces the journal C4 needed.
The native ID, verbatim
Unique by construction, and readable
Claude Code and Codex mint a new random UUID for every session (v4 and v7), so different sessions get different names. A hash would only add a small collision chance and hide which session it is; the full ID is the one claude --resume and codex resume take. No content goes into the name, so a session that gains turns after import keeps its name, and a rerun reports "newer activity since import" instead of creating a second entry.
No username; an -import- segment
Every machine agrees, and nothing collides
Coworkers' machines can carry different display names, so the name leaves the username out. -import- in place of -<username>-OxXXXX can never collide with a live name. The name keeps the 16-character timestamp prefix existing parsers expect and passes the daemon's name rule.
The legacy namespace
No server change
The server already derives exactly this ses_ value, with the same namespace, for any meta.json without a session_id (meta.go:21–35). IsValidSessionID accepts any canonical UUID. Import also writes the ID explicitly, so the server never has to derive it.
Can two sessions share a name?
| Checked on one developer machine, 2026-09-29 | Claude Code | Codex |
|---|---|---|
| Session files | 1,723, all UUIDv4 | 159, all UUIDv7 |
| Names shared by two different sessions | 0 | 0 |
| One session in two files | 2. Each changed working directory between checkouts of the repo, and Claude kept a copy under both folders. Both copies get one name, and the longest is uploaded. | 0 |
| Minutes in which 2+ sessions started | 195, up to 60 in one minute | 16, up to 6 |
The timestamp alone collides constantly, so the native ID has to be in the name. A name repeats only when the native ID repeats, which means one session seen twice. Two edge cases remain: claude --session-id lets a script reuse an ID, and a copied session continued on two machines keeps one name, so the second copy's extra turns aren't uploaded. Codex forks get new IDs, so they never share a name; the history they copy is covered in What we cut.
How each ID is used
| Where | ID | What happens |
|---|---|---|
Preview and --session | native | The preview lists each candidate by the first 8 characters of its native ID, and --session takes a unique prefix of 8 or more. It's the ID Claude Code and Codex use for the session (their resume commands take it), and it exists before anything is uploaded. |
| Already imported? | name, native | Is sessions/<name>/ in the Ledger's HEAD? The check needs no index, because the name is computed from the native session. A meta that lists this native ID with source = "import" also counts, so a session is recognized under any name. |
| Recorded live? | native, ses_, agent | Does any meta's native_sessions[] list this ID with a source other than import? Agent names are compared canonically, so claude and claude-code match. The same ID is also checked against local captures not yet uploaded. Recordings made before v0.17.0 are matched through ox's own marker in the transcript instead, by ses_ ID, session name or agent ID. |
Run output and --json | ses_ | Each uploaded session prints → https://<endpoint>/c/ses_…. JSON rows carry native_id, session_name, session_id and url. |
| Server notification | ses_ and name | The upload notification sends session_id and session_name, so the server can bind them before it ingests the Ledger. A resend carries the same ID, and a 404 or 409 counts as success. |
| Integrity | ses_ | The raw.jsonl header and meta.json carry the same value, so doctor's session-ID divergence check stays quiet. |
| Not used for | — | PR or commit linkage. Imported sessions get no SageOx-Session trailers and no linkage status. Linking past sessions to past PRs would be a separate feature. |
Trade-offs. Version-5 UUIDs aren't time-ordered the way live recordings' version-7 IDs are. That's already true of every legacy recording, so consumers must already handle it. The repo_id is part of the ses_ input, so the same native session under a re-registered repo would get a different ID, but the name check still keeps it to one directory per Ledger. A later naming change wouldn't re-import anything, because check 5 also matches the native ID recorded in meta.json. Names already in the Ledger never change, though, so Ryan approves the format first (decision 1).
Exactly once
Dedup needs no new state because identity is deterministic. The dedup key is (agent, native session ID). On one developer machine it was stable in every file checked: Claude's filename UUID equalled every record's sessionId in 1,723 of 1,723 files, and Codex's equalled session_meta.payload.id in 159 of 159.
Identity
The Ledger name and the ses_ ID are both derived from (agent, native session ID), so every retry and every machine computes the same pair. Session IDs has the exact formulas, how they compare with live recording, and where each ID is used.
Every candidate takes the first rung it matches
- Before anything runs
- 1Run lock. Is another import running against this Ledger from any worktree?stop · in progress
- 2Ledger health. A rebase in progress, unmerged paths or conflict markers stop the run, the wedge states in #1105. Import commits left unpushed by an earlier run are pushed first, and if that push fails the run stops without adding commits.stop · ledger_wedged ◆ push first
- ·Ledger sync through the daemon, as other commands do. A stale view can only cause a duplicate attempt, which check 10 converges.best effort
- Per candidate: never uploaded
- 3Scope and readability. Another repo, ox's own summarizer runs, subagent threads, mixed repos, unreadable files, and transcripts with no conversation (header and footer only, #1106). Duplicate local copies of one session collapse to the longest.ignored / ineligible
- 4In progress. The invoking AI coworker's own session, a Codex turn in flight, a file changed in the last 30 minutes, or an active or paused recording.in_progress
- 5Already imported.
sessions/<name>/is inHEAD, or another meta carriessource = "import"for this ID.already_imported - 6Recorded live by ox, published or pending locally: a meta lists this native ID (ox 0.17 and later, agent names compared canonically), or ox's own marker in the transcript names a recording in the Ledger (older ox, see below).recorded_live
- Fixable, then uploaded
- 7Usable summarizer for the session's vendor? If not,
--summarizer <other>resolves it.needs_summarizer - ✓Everything else is ready and selected by default.✓ ready → uploaded
- At publish time
- 8Just-in-time recheck. Is the file unchanged and still quiet, and under the lock, does
HEADstill lack the name?became_active / landed_meanwhile - 9Commit validity.
CommitLedgerSnapshotrefuses non-pointer content and unresolved conflicts.held - 10Two writers, one name. A push rebase with accept-theirs on
sessions/keeps one directory and oneses_ID.converges
Not checked in v1, so these read as ready: sessions a coworker removed from the Ledger or aborted live, since deletion is out of scope; Codex forks, which upload with the parent history they copied; and recordings from ox's first four weeks (2026-02-16 to 03-12), which predate its marker. What we cut gives the cost of each.
Recordings from older ox versions
ox has stored native IDs only since v0.17.0. But since 2026-03-12, every session ox recorded begins with ox's own prime output, <session-context agent_id="Ox…" url="…">, and Claude Code and Codex keep it in the native transcript. Check 6 matches that marker against the Ledger exactly, with no LFS download and no new state.
| Recording made | What ox left in the transcript | Matched against |
|---|---|---|
| v0.17.0 and later (09-21) | Nothing needed: the recording's meta.json lists the native ID. | native_sessions[] |
| 05-01 to 09-21 | The marker's url ends in /c/ses_<id> (#575). | session_id in meta.json |
| 03-12 to 05-01 | The marker's url ends in /sessions/<name>/view (#209). | The session directory name |
| Recording started after prime | The marker has only agent_id, no url. | A recording named …-<agent_id> that starts inside the session |
| 02-16 to 03-12 | Nothing: ox's first four weeks predate the marker. | Not matched. Claude's 30-day default retention has deleted those transcripts; a Codex rollout from then is the one case left. |
Only ox's own output counts: Claude's SessionStart hook output (including the side file Claude writes when that output is too large) and the result of ox agent prime; Codex's ox agent prime output and hook-injected messages. A marker quoted anywhere else, such as in source code or a pasted log, is ignored. Checked on one machine: each of the 7 recordings available locally matched exactly one native session by ses_, and again by agent ID and start time, and 5 incidental mentions were correctly ignored.
Scenarios
| Scenario | Outcome | Guarantee |
|---|---|---|
| Re-run, same or later day | Every earlier import is in HEAD under its deterministic name, so all are already_imported. There are no LLM calls, no LFS batches and no commits. | never twice |
| Crash at any step | See the pipeline. Staging is swept and redone, a local commit is pushed first, and a pushed session reads as imported. | every session · never twice |
| Two machines, same session | Both compute the same name and ses_ ID. After the daemon sync, the second sees already_imported. In a true race, or from a stale view, the push rebase converges to one directory, and the replayed side's summary wins. | never twice |
| Same Claude session in two folders | It changed working directory between checkouts, and Claude kept a copy under each folder. Both copies produce one name, and the longest is uploaded. | never twice |
| ox also recorded it live | It's recorded_live, naming the recording. If ox started recording late, the preview says how many earlier entries aren't in the Ledger (decision 2). | never twice over every session |
| Recorded on this machine, not yet uploaded | It's found in the local capture's header/footer or its local meta, so it's recorded_live. Let the normal upload finish. | never twice |
| Recorded live by an older ox | The recording has no native ID, but the transcript still holds ox's marker, so it's recorded_live, naming the recording. Only recordings from before 2026-03-12 lack the marker. | never twice |
| Grew after import | already_imported, with "N newer entries not uploaded". Resuming it under auto recording starts a live recording, which can carry the imported history again. | known gap |
| Removed from the Ledger, or aborted live | Deletion is out of scope, so import keeps no memory of it. It reads as ready and is uploaded again only if the coworker confirms it. | out of scope · R2 |
| Still running | It's in_progress: "finish it, then rerun". A live session is never snapshotted partway. | every session |
| Codex fork | It has its own native ID and name, so it's imported as its own session, including the parent history it copied. | known gap |
| Huge session | The staged secret scan runs without the 8 MiB cap. Output over the adapter's 64 MiB cap is reported as "too large", never dropped silently. | every session · safety |
| Summary fails | A runner failure is held with the exact retry command. A validation failure gets two re-prompts, then the fallback summary (decision 3). | every session · summary first |
| Secret found | It's redacted at conversion. A residual finding is auto-redacted in staging, or the session is held. A broken team rule refuses the whole run up front. | safety |
Summaries first
The CLI produces the summary synchronously for each session, before anything reaches the Ledger. The daemon can never pick up an import: import writes no .needs-summary and no pending status, staging sits outside every daemon scan root, and the committed raw.jsonl is already a pointer, which the daemon skips.
How
Reuse the daemon's pure pieces, not its state machine
- Thin sessions get the existing deterministic "brief session" summary, with no LLM call.
- Prompt:
BuildInlineSummaryPromptoverTrimEntriesForBudget(new and pure). It keeps the head, the tail and evenly spaced middle turns up to about 300k characters, and leaves input under budget unchanged. - Runner: the session's own vendor, using the coworker's own login, which pays. Claude defaults to Haiku. The preview names the CLI, model and account before anything runs.
- Validation:
ParseAndValidate, a new import-only helper that uses main's validators. The daemon is untouched in v1.
Isolation is not optional
Historical transcripts are untrusted input
- Claude:
--safe-mode --tools '' --no-session-persistence, and nobypassPermissions. An older Claude that rejects the flags fails as "upgrade Claude Code" and is never retried with broader permissions. - Codex: read-only sandbox and ephemeral, plus
--ignore-user-config --ignore-rules --skip-git-repo-check. Every tool-bearing feature is switched off with--disable, and any tool event rejects the output. - Both: run in an empty temp directory with recording off, so the summarizer never becomes a session of its own. On one machine checked, about 98% of Claude session files were ox's own summarizer runs.
Two failure classes
Runner failures · held
Timeouts, crashes, unusable output
Up to three attempts. After that, nothing reaches the Ledger, staging is removed, and the report prints ox session import --session <id>, plus --summarizer <other> when the other CLI is usable. The run continues with the next session and exits 1.
Validation failures · decision 3
The validators reject ordinary ox vocabulary
Main's validators flag words like "permission" and "approve" in titles, and "mcp__", "tool_use" and "push-summary" in summaries. A session about those topics fails on every retry with either vendor, which would make whole topics impossible to import. Attempts 2 and 3 re-prompt with the rejected pattern named. If the third still fails, import uploads a deterministic fallback: the first prompt as the title, padded to pass the length rule, plus an echo of the user prompts. meta.json gets summary_status: ok like any finished session. Which validator rejected the LLM summary is recorded in summary.json, never in validation_error, so the daily re-arm (#1106, #1107) can never pick it up.
State this removes for imports
No .needs-summary, no summary_status=pending or failed_validation, no summary_attempts, no failure stubs, no upload-only re-finalize, and no separate summary commit. None of the daemon's retry loops or doctor's title checks ever see an import: the finalize detector skips pointer transcripts (since v0.7.0), the title autofix acts only on an empty title, and the re-arm only on a "title too short" failure.
Redaction and #999
Import converts every past tool call through RawWriter, the redaction chokepoint (step 03). Two parts of #999 make that pass work on native Claude Code and Codex history: its fix to command redaction (decoding plus call-ID carry-over) and a strict writer. Everything else in #999 is about live capture, which import doesn't use.
The gap on main
Credential-command outputs pass through
One RawWriter layer, CommandRedactor, replaces the entire output of known credential-printing commands with [REDACTED:credential-output:<name>]. Its rules cover aws sso login, aws sts assume-role, aws sts get-session-token, aws configure export-credentials, gh auth login|token, glab auth login|token, vault read auth/ and op item get. It's the primary protection for outputs that don't look like a token, such as a password from op item get; pattern detectors are only a backstop. On main it never fires for native history:
- The command is wrapped in JSON. The rule checks whether the tool input starts with the command. After conversion, a Claude call's input is
{"command":"gh auth token","description":"…"}, and a Codex call's input is its JSON arguments, sometimes an argv like["/bin/bash","-lc","gh auth token"]. Neither starts with the command. - The output is in a separate entry. The rule blanks output only on the entry whose input matched. A Claude tool result arrives as its own entry, linked to its call by ID, so even a match would leave it untouched.
What #999 adds
Decode the command, carry the match to the result
- Command decoding (
commandInputs,cmd_redaction.go): readscmdorcommandas text or as argv, and also checks the script insidesh|bash|zsh|dash|ksh -cor-lc. - Call-ID carry-over: a matched call's rule is remembered by its call ID, bounded at 4,096 pending calls, so the later result entry with that ID is blanked. Main already carries the call ID through conversion, since #1025.
- A strict writer for imports (
NewRawStreamWriter,raw_writer.go): anyREDACT.mdor team-rule error is fatal instead of silently skipped. It can also stream to nowhere, so the import preview inspects history without creating files. Import adds one check of its own: a configured team context whose checkout is missing.
Import runs one writer per session, so a call and its result are always matched within the same file.
How much of #999 import needs
| Part of #999 | Size | Import needs it? |
|---|---|---|
Command decoding and call-ID carry-over: cmd_redaction.go and its test | +107 / −3 | yes |
Strict writer: NewRawStreamWriter in raw_writer.go | ~13 | yes |
| Live-capture durability: redaction checkpoints across hook processes, append journals, and stop, drain and recovery locks | the other ~3,000 | no |
| All of #999 | +3,121 / −154 across 25 files |
Fast path
Merge #999 first
At 8ab0c0ea (09-30), which adds the journal fix below, checks are re-running and 0 of 11 earlier review threads are open. It also closes the same gap for live capture on main, which goes through the same adapters and writer. Re-trigger Greptile on the final head before merging.
If #999 stalls
Carry the subset in the import PR
Move the two needed pieces above (about 120 lines across 3 files) into the import PR, or into a tiny standalone PR. The real dependency is that these pieces are on main, not all of #999.
Without it
Imports would still get REDACT.md and team rules, pattern detectors (built-in plus gitleaks extras), the uncapped staged secret scan and the push-time gate. Those catch well-known token formats. What's lost is whole-output redaction for credential commands whose output doesn't look like a token. That matters more for an import than for one live session, because it replays months of history in bulk to a Ledger that can be public.
Proof in the import PR: fixture sessions for both vendors, with gh auth token and op item get calls, must upload with [REDACTED:credential-output:…] in place of the output. Red-first: remove the subset and watch the test fail on that assertion, then restore it and watch it pass.
#999 and the Ledger wedges
#999 changes local capture only. It doesn't touch the Ledger's pull, rebase, commit or push code, the meta.json bookkeeping fields, the title autofix, the summary re-arm or the finalize detector, so it neither causes nor fixes #1105–#1107. It adds one local file: an append journal, raw.jsonl.append.json, next to the transcript during each capture batch. The hook, stop, recover and tail-watcher paths clear a journal left by a crash. The daemon's finalize of an abandoned recording doesn't, and it copies every file in the cache folder into sessions/<name>/ and stages the whole folder. The journal would be committed to the shared Ledger, along with the unacknowledged batch that recovery would have dropped. Fixed in 8ab0c0ea: that path now runs the same recovery first, and the copy skips journal files.
Not through sessions/.gitignore. The daemon's finalize rewrites that shared file to its own version's text but commits only sessions/<name>/, so any change to the text leaves an uncommitted edit to a tracked file on machines running a different version: the ingredient #1105 traces. Import writes neither that file nor a journal, since its stream writer has no append batches.
Coworker experience
Preview by default, one confirmation, one line per session, and an honest final count. An AI coworker gets the same preview as JSON with a guidance field, and never adds --yes on its own.
$ ox session import
Destination SageOx · sageox/ox · PUBLIC: anyone can read it
Summaries Claude Code: claude · claude-haiku-4-5 · your login
Codex: codex · default model · your login
Ready to upload (6)
2026-09-02 claude 48 msgs 1.2 MB main 3f9a1c2b
2026-09-05 codex 22 msgs 410 KB fix/lfs 9c01d7e4
…
Skipped (5)
already imported (2) · recorded live by ox (2)
in progress (1) → finish it, then rerun
Ignored 31 other folders · 1,204 ox runs · 12 subagent threads
Upload 6 sessions to SageOx's Ledger (public)?
Summaries run on this computer with claude (~6 min). [y/N]
[1/6] 2026-09-02 claude 3f9a1c2b summarizing… uploaded
→ https://sageox.ai/c/ses_…
[2/6] 2026-09-05 codex 9c01d7e4 summarizing… uploaded
[3/6] 2026-09-07 claude 51be02aa summarizing… failed
summary (timeout) · retry:
ox session import --session 51be02aa
[4/6] …
6 selected · 5 uploaded · 1 failed · 5 skipped
exit 1
| Flag | Effect |
|---|---|
(none) | Preview, then one [y/N] on an interactive terminal. With no TTY or in agent context, it prints the preview and exits 0 without uploading. |
--yes | Uploads every ready session. Guidance tells an AI coworker to pass it only after the coworker confirms. |
--agent claude|codex, --since 7d | Narrows the default selection, by last activity for --since. |
--session <id> | Repeatable, and accepts a unique prefix of 8 or more characters. Selects exactly these sessions, for example to retry one that failed. A skipped session is never selectable, and the reason is printed. |
--summarizer claude|codex | Uses the other vendor's CLI. The preview discloses it before any content moves. |
--dry-run, --json | Never upload, and machine-readable output with sessions[], counts, next_command and guidance, respectively. |
Preflight refuses with a named error code before any LLM call or write: not_initialized, not_logged_in, no_ledger, recording_disabled, read_only, redaction_rules_invalid, destination_unverified, import_in_progress, ledger_wedged.
What we cut
The earlier plan split a broad effort into nine PRs across two repositories. This plan keeps only what past-session upload needs, and gets its correctness from deterministic identity rather than machinery. On 09-29 it was cut further: handling deleted sessions is out of scope, and four guards are deferred until usage shows they're needed.
Before · 2026-09-28 plan
Capture, import, streaming, server processing
9PRs across 2 repos~110files in C3 + C4yesserver release ordering
- Source receipts in a new Ledger directory, and contract wiring
- An import crash journal, a publication lock, and upload-verified / registration-pending states
- Remote verification that downloads LFS blobs, and fast-forward-only convergence
- Append-only extension of grown sessions, with content digests in names
- New meta fields and registration polling, which needed a server change
- Deferred daemon summaries for imports
- An "uncertain" status that made bulk import of pre-existing history impossible
After · this plan
One command that uploads past sessions
1PR behind #999~12filesnoneserver change
- Deterministic name and
ses_ID. The Ledger is the index. - Sessions run one at a time, so a crash costs at most one session. Rerunning is the recovery.
- Convergence comes from main's existing push rule, with no blob downloads.
- Import once per native session. Growth is reported, never re-uploaded.
- Existing
meta.jsonfields only, and the existing fire-and-forget notify - The summary is produced and validated before upload
- Explicit states with reasons. A skipped session is never uploaded.
- No change to live capture, and no durable local state.
Cut on 09-29: out of scope, deferred or replaced
| Guard | What it prevents | Without it in v1 |
|---|---|---|
| Deletion memory out of scope | Offering again a session a coworker removed from the Ledger, or whose live recording was aborted. It needed a walk through Ledger history and a local discard record written by every abort path. | The session reads as ready and is uploaded again only if the coworker confirms it (R2). |
| Pre-0.17 overlap check replaced | A second copy of a session ox recorded before it stored native IDs. It guessed from agent, user and time. | Not needed: an exact match on ox's own marker in the transcript replaces it (see Exactly once). Only recordings from before 2026-03-12 stay unmatched (R1). |
| Codex fork detection | A fork re-uploading its parent's history. | The fork is imported with the history it copied. |
capture-prior subtraction | A later live recording of an imported session carrying the imported part again. | That overlap can be uploaded twice. |
| Stale-view refusal | A wasted summary when another machine imported the session first. | Check 10 still converges to one copy. |
| Post-push tree check | Missing that the push-time secret gate amended a commit. | Rare, and the session still lands once. |
Each deferred guard can come back on its own if usage shows it's needed. None of them would change the name, the ses_ ID or the Ledger layout.
Where the earlier pieces stand
| Piece | Status | Role in this plan |
|---|---|---|
| S · shared contract | ✓ merged | #980 is merged and tagged pkg/sessionprovenance/v0.1.0. Import doesn't need it: its Codex scan checks IDs with a plain UUID rule, so there's no go.mod change. |
| C2 · restricted worker | ✓ merged | #998 is the base of the Codex isolation, which this plan extends with the flags above. |
| C1 · redaction | ◐ prerequisite | #999 is at 8ab0c0ea (09-30) with checks re-running, and 0 of 11 earlier threads are open. Import needs about 120 lines of it: command decoding and call-ID carry-over, so credential-command outputs get redacted in native history, plus a strict writer for imports. The rest is live-capture durability, which leaves the Ledger's git paths alone; its one journal issue is fixed in 8ab0c0ea (see Redaction and #999). Re-trigger Greptile on the final head. |
| C3 · durable capture | superseded | Not needed. Only its Codex history walk and repo scoping are reused, as ports. The validated patch stays in the archive. |
| C4 · reviewed import | superseded | Replaced. It handled Codex only, deferred summaries to the daemon, and couldn't bulk-select pre-existing history. |
| ox#959 · monolith | draft, open | Close it when the import PR opens. |
| Server side | ◇ not needed | Import writes only fields the server already accepts. The private owner should confirm one generic assumption (see Delivery). |
Delivery
Four steps. The only ordering constraint is that Ryan approves the name before code depends on it, because it becomes the permanent path of every imported session.
- Merge #999 (fast path). The journal fix landed in
8ab0c0ea. Re-trigger Greptile on the final head, resolve any new threads, and squash-merge. Import needs only about 120 lines of it: command decoding, call-ID carry-over and the strict writer. If #999 stalls, carry those in the import PR instead. See Redaction and #999. - Decisions 1–3. Ryan approves the naming and the staging path (a required review under CLAUDE.md), and Lau confirms decisions 2 and 3 or overrides the defaults.
- Import PR.
feat(session): ox session import uploads past Claude Code and Codex sessions. One coherent PR: discovery and scoping, the Ledger index and classification, the summary-first pipeline, pointer-first staging and the scoped commit, and the command with preview and JSON. It doesn't touch live capture. - Follow-ups, not required to ship: (a) the daemon's Claude summarizer adopts isolation, so ox stops leaving summarizer sessions in Claude's store; (b) doctor's uncommitted-session fix switches to
CommitLedgerSnapshot; (c) opt-ins for partial sessions, if decision 2 wants them; (d) stale summarization docs; (e) any guard deferred in What we cut, once usage shows it's needed.
Decisions
| # | Question | Proposed default | Why |
|---|---|---|---|
| 1 | Ryan: approve the name sessions/<start>-import-<agent>-<native session UUID> with no username, the persisted UUIDv5 ses_ ID, source = "import" as the only marker, and one local cache path, .sageox/cache/session-import/staging/, swept every run. | Approve as proposed. | A required review for storage paths. The name is the dedup key and becomes permanent. Import keeps no durable local state. |
| 2 | When the Ledger already holds part of a native session, upload the rest? Either (a) the beginning, before ox started recording late, or (b) activity added after an import. | Not in v1. Skip both and show the counts. | Uploading the rest works against never uploading twice and against keeping state simple. A live recording may already contain that beginning, and a refresh reintroduces replace-in-place logic. |
| 3 | When the validators still reject the summary after 3 attempts, upload with a deterministic fallback, or hold the session? | Upload with the fallback. Runner failures stay held. | Holding would make every session about permissions, MCP or tool parsing permanently impossible to import. |
Proof, before merge
-
End-to-end: a real bare Ledger remote, a fake LFS batch server, a fake API, and fake Claude and Codex stores containing this repo, another repo, ox's own runs, subagents and forks.
-
Crash injection at every step. Each rerun ends with exactly one directory and one
ses_ID. -
Two-clone race with interleaved pushes: one directory, one ID.
-
Credential outputs: Claude and Codex fixtures with
gh auth tokenandop item getcalls upload with[REDACTED:credential-output:…](red-first against the #999 subset). -
Skip matrix: every skipped state is never uploaded, even with
--session, including a"claude"-spelled draft that must still match. -
Duplicate copies: one Claude session filed under two project folders uploads once, from the longest copy.
-
Older recordings: fixture transcripts carrying ox's marker from each era (a
ses_URL, a name URL, an agent ID only) are recognized as recorded live, and the same marker quoted in ordinary tool output is not. -
Only artifacts: a stray file in staging, such as a journal or a lock, refuses the rename.
-
Daemon interplay: after an import, and after a post-rename crash, the finalize detector, the title autofix and the summary re-arm all find zero work, including on a fallback-summary session. A clone with a rebase in progress or unmerged paths is refused before any LLM call.
-
Large inputs: a 9 MiB converted file is actually scanned, and a ~100 MB rollout stays within budget.
-
Red-first BDD (
.claude/rules/bdd-authoring.md): "Devon imports past sessions and each appears once with a summary", and "Avery re-runs and nothing is uploaded twice". Break each one on purpose and report both results. -
Gates:
make lint,make test, the raw-writer and session-meta checks,check-no-git-lfs-shell, and/security-review.
Private-owner follow-up, stated generically: confirm the server ingests a pushed session idempotently by session_id without depending on the notification, and accepts an explicit UUIDv5 session_id on a new session.
Risks
Eight risks, placed by likelihood and impact. Select a dot to find its card.
HIGH MED LOW LOWMEDHIGH ↑ likelihood · impact → R1
Recordings older than ox's marker
L Low · I Med
Import recognizes a recording from an older ox by the marker ox wrote into the native transcript, which it has done since 2026-03-12. A recording from ox's first four weeks has no marker and can be uploaded again. Mitigation: Claude's 30-day default retention has already deleted those transcripts, so only a Codex rollout from then remains at risk.
R2
Removed or aborted sessions are offered again
L Low · I High
Deletion is out of scope, so import keeps no memory of a session a coworker removed from the Ledger or of a live recording that was aborted. Either reads as not uploaded. Mitigation: nothing uploads without the coworker's confirmation, and an AI coworker never passes --yes on its own. A discard record is the follow-up if this matters in practice.
R3
Import once
L High · I Med
A session idle but open for over 30 minutes is snapshotted, and later activity is only reported. A session ox started recording late keeps its beginning out of the Ledger. Mitigation: auto recording captures resumed activity live. Both gaps are counted in the preview, and decision 2 can add opt-ins later.
R4
Sessions from another account
L Low · I High
A shared or synced native store, such as a devcontainer or pairing machine, can hold another person's sessions for this repo, and import would attribute them to the current coworker. Mitigation: the interactive first-prompt hint and confirmation. Account attribution is a follow-up.
R5
CLI and format drift
L Med · I Med
A Claude without the isolation flags, a Codex that renames a disabled feature, or new native record types. Codex 0.154 also keeps sessions in a SQLite thread history and ships codex migrate-rollouts. It still writes the rollout files import reads, and every thread on the machine checked had one. Mitigation: fail closed. The run reports "upgrade Claude Code", a failed probe, or an unreadable/unrecognized row. It never retries with broader permissions and never guesses. Re-check Codex discovery against the current release before shipping.
R6
Cost and time
L High · I Low
Summaries run one at a time at 30–120 seconds each, on the coworker's own login. Mitigation: the preview states the CLI, model, account and an estimate before confirmation. --agent, --since and --session narrow a first run.
R7
Validator false positives
L Med · I Low
Sessions about permissions, MCP tools or tool parsing often end up with the deterministic fallback summary instead of an LLM summary. Mitigation: re-prompts name the rejected pattern first, and the fallback records which validator rejected it in summary.json, never in meta.json.
R8
Pushing into a clone with uncommitted daemon edits
L Low · I Med
Import's push runs the same pull --rebase --autostash as every ox push, so on a clone holding the daemon's uncommitted autofix edits it can hit the collision #1105 traces. Mitigation: import adds no uncommitted edits of its own, and batched pushes keep a bulk run to a few cycles, about what a few live sessions ending would cause.
Ledger wedges: #1105, #1106, #1107
Those issues trace a week of wedged clones to uncommitted daemon edits of shared meta.json lines colliding with peers' commits during git pull --rebase --autostash. Checked against main, import feeds none of it.
| Finding | Import |
|---|---|
Daemon autofixes leave meta.json edits uncommitted | Never matched. The title fix acts only on an empty title, the re-arm only on a "title too short" failure. Import writes a non-empty title and summary_status: ok, once, in staging. |
| Retry bookkeeping lines contended across machines | Written once, before the first commit, and never rewritten. Import's retries live in memory; no attempt counter is persisted. |
| Every daemon rescans and retries failed sessions | No work created. The finalize detector skips pointer transcripts (since v0.7.0), and ghost cleanup only looks at directories with .recording.json. Summaries run once, on the importing machine. |
| Empty transcripts re-armed forever (#1106) | Never uploaded: a transcript with no conversation is ineligible, the same rule v0.19.0 applies to live recordings. |
| Re-arm herd after daemon restarts (#1107) | Never eligible, so restarts and peers never re-arm an import. |
| Bare commits sweep staged files | CommitLedgerSnapshot commits a validated tree scoped to the new directory, with a compare-and-swap on the branch. It never sweeps in staged files or conflict markers. |
| Content committed over LFS pointers | Pointer-first: an upload failure holds the session, and CommitLedgerSnapshot refuses a transcript that isn't a pointer. |
A peer's finalize drops native_sessions | Dedup keys on the name, and recorded-live matching falls back to ox's marker (ses_, name, agent ID). |
| Wedged clones (rebase in progress, unmerged paths, markers) | Refused before any LLM call (ledger_wedged), and no commits are added to a clone whose push fails. |
| Pull, rebase and autostash on push | The same mechanism as every ox push, batched to a few cycles per run (R8). |
Machine-local files carried into sessions/ | Import renames in only known artifact files; anything else in staging refuses the rename. The daemon-side case, #999's journal, is fixed in #999 (8ab0c0ea). |
Implementation notes
Files (estimates from the reviewed design, re-cut on 09-29)
| Component | Prod | Test |
|---|---|---|
internal/session/nativeimport/claude.go: depth-2 walk, structural stream, largest-copy wins, ox markers from hook output | 160 | 150 |
internal/session/nativeimport/codex.go: roots, archived sessions, header checks, in-flight turns, ox markers from prime output | 185 | 165 |
internal/session/nativeimport/scope.go + name.go: per-working-directory repo scoping, deterministic name | 160 | 170 |
cmd/ox/session_import.go: command, preflight codes (including ledger_wedged), preview, selection, confirmation, JSON + guidance | 300 | 160 |
cmd/ox/session_import_index.go: Ledger index (HEAD tree, metas, capture carriers, recording states, marker matching for older recordings) | 160 | 140 |
cmd/ox/session_import_publish.go: staging, strict conversion, empty-transcript skip, summary, artifacts, gate, LFS, artifact allowlist, locked rename, commit, batched push, notify | 280 | 95 |
pkg/sessionsummary: import-only ParseAndValidate, validation fallback with a padded title, TrimEntriesForBudget | 105 | 170 |
internal/daemon/agentwork: RunRequest.Isolated for Claude and Codex, plus the CLAUDE_CONFIG_DIR usability fix | 150 | 180 |
internal/session: ValidateRedactPolicy (the missing-team-context check on top of #999’s strict writer) | 20 | 35 |
internal/session/adapters/external.go ReadWithTimeout; cmd/ox/prepush_scan.go cap parameter | 25 | 45 |
cmd/ox/session_import_e2e_test.go | 0 | 500 |
| Total | ~1,545 | ~1,810 |
Repo rules this design keeps
- Cache-only: the
raw.jsonlundersessions/<name>/is only ever an LFS pointer. The directory is built and pointerized in.sageox/cache/session-import/staging/, then renamed in under the repo lock. - Only known artifacts: staging must hold exactly the session's artifact files (
meta.json, theraw.jsonlpointer, summaries and renderings). Any other file refuses the rename, so journals, locks or markers never reach the Ledger. - Automatic Ledger commits go through
gitutil.CommitLedgerSnapshot, scoped to the newsessions/<name>/directory only, and never throughWriteSessionMeta, somake check-session-meta-rmwstays green. - No git-lfs binary: uploads use
internal/lfsonly. - Redaction chokepoint: every byte goes through
RawWriter. The staged gate auto-redacts through the same chokepoint, and native bytes are never copied. - Drafts (ADR-029): import never writes a draft. The index reads only the latest version of each session path, so a superseded draft never blocks a finished recording.
- Private-source boundary: the server is described only generically.
How this plan was made
Three workflows, run on 2026-09-29 against origin/main at cb7b41e1.
- Mapping: six read-only readers mapped the upload pipeline, summaries, native sources, dedup, safety, and the archived C3/C4.
- Design: three designers (minimal, correctness-first, experience-first) were scored by three judges on different lenses. A synthesizer built the result from the winner and grafted in ideas from the others.
- Attack: five critics (duplicates, missed uploads, code reality, simplicity, security) attacked the result. Every medium-or-higher finding went to an independent refuter. 29 of 32 findings survived and were applied, including the
"claude"/"claude-code"agent-name mismatch, validation holds that would have been permanent, Codex summarizer isolation, and a fail-closed redaction preflight. - Trim (09-29): Lau ruled handling deleted sessions out of scope and deferred four guards (see What we cut). The name now carries the full native ID instead of a 16-hex hash; a scan of 1,882 session files on one machine found no name shared by two different sessions. The pre-0.17 overlap heuristic was replaced by an exact match on ox's own marker, checked against the 7 recordings available locally.
Plan revised 2026-09-29 from live repository state. Server-side detail is tracked in the owning repository. enriched by

