Skip to content

fix(import): scope dedup by source kind, error on missing codex session - #28

Merged
takashi-matsuyama merged 1 commit into
mainfrom
fix/import-dedup-scope-and-session-miss
Jun 1, 2026
Merged

takashi-matsuyama merged 1 commit into
mainfrom
fix/import-dedup-scope-and-session-miss

Conversation

@takashi-matsuyama

Copy link
Copy Markdown
Member

What

Two refinements to the import adapters, surfaced by an adversarial review of the codex adapter (#27). Both are pre-release hardening of the just-landed basou import codex; neither changes the import data format.

1. Dedup scoped by source kind

loadExistingByExternalId previously indexed every existing session's source.external_id regardless of source.kind. With two adapters now sharing the re-import dedup, a Codex rollout whose id collided with a Claude transcript id could be skipped as "already imported" and, under --force, the unrelated Claude session would be deleted.

The dedup map is now scoped to the source.kind being imported (passed into the shared importDerivedSessions). Each adapter's id namespace stays separate, which matters more as further adapters are added. The collision is astronomically unlikely in practice (Claude UUIDv4 vs Codex UUIDv7), but the fix makes the isolation correct by construction rather than probabilistic.

2. import codex --session <id> errors on no match

The Codex --session path filtered the discovered rollouts and, on no match, reported a silent success ("No transcripts found to import"). The Claude path errors when a named --session transcript is absent. discoverCodexRollouts now throws Codex rollout not found for session id in project when --session matches nothing, so a mistyped id fails loudly and consistently.

Tests

  • Cross-kind isolation under --force: a Claude session sharing an external id survives a Codex import; the rollout still imports as a new session. (Fails before the fix.)
  • --session with a non-existent id rejects with the new error.

Verification

pnpm -r build && pnpm typecheck && pnpm test && pnpm lint all green. Tests: cli 388 (+2); core unchanged. Lint clean (only the 4 pre-existing unrelated warnings).

Not included (reviewed, intentionally deferred)

The same review raised two further items, left out by decision: event-level cwd in events.jsonl is not sanitized, but events.jsonl is gitignored (confirmed via git ls-files) and this matches the existing claude path, so it is not a tracked-artifact leak; and yielded/interactive exec_command exit codes delivered via later write_stdin records are recorded as null, which respects the agreed MVP scope (exec_command only).

🤖 Generated with Claude Code

Two refinements to the import adapters surfaced by an adversarial
review of the codex adapter (#27):

- Scope re-import dedup to the session source kind.
  loadExistingByExternalId now indexes only sessions whose source.kind
  matches the adapter being imported, so a Codex import can no longer
  dedup against (or, under --force, delete) a Claude-derived session
  that happens to share an id string. The id namespaces stay separate
  as more adapters are added.
- `basou import codex --session <id>` now errors when no rollout in the
  project matches the id, instead of reporting a silent success. This
  mirrors the Claude path, which fails on a missing --session transcript.

Adds tests for both: cross-kind isolation under --force, and the
missing --session error.
@takashi-matsuyama
takashi-matsuyama merged commit 5483b74 into main Jun 1, 2026
7 checks passed
@takashi-matsuyama
takashi-matsuyama deleted the fix/import-dedup-scope-and-session-miss branch June 1, 2026 10:04
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