Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): skip native sessions during bulk import #15634

Mergedmaria-rcksmerged 7 commits intomain fromrefs/pull/15634/headmerged by juliusmarminge View on GitHub

maria-rckscommented

Bulk import could create a second T3 thread for a native Codex or Claude session already owned by another thread. The event sink now checks ownership inside the publication transaction, scoped to the provider instance and including archived/deleted owners. An owned session publishes no history or imported runtime and counts as neither imported nor failed. Normal imports persist runtime metadata after history commits; retries recover missing runtime metadata without replaying history.

Maintainer takeover of #15634, preserving and crediting @maria-rcks’s implementation. Main was merged without rewriting contributor commits. Independent implementation review retained the focused transaction guard, instance-scoped IDs and runtime recovery. The merge introduced a duplicate type import; that compilation error is fixed. Existing duplicate threads and cross-environment deduplication remain outside this change. Owned transcripts are re-read on later imports and still consume the scanner’s bounded read budget.

Verification: AgentSessionImporter.test.ts is reduced from nine matrix cases to three integrated SQLite behaviors: mixed ownership, a native claim arriving at the transaction boundary, and failed-write/runtime recovery. All three fail on main and pass on this head. The importer and FoundationPersistence suites pass 47 tests; server-scoped typecheck, targeted lint, formatting and diff checks pass. The original nine cases passed with a temporary workaround for the merge’s duplicate import; the final checks need no workaround. Both first-round reviewers found no production blocker. The review caught a fixture mismatch with real native owner IDs; the existing test now matches the adapters and fails if importer ID scoping is removed. Both reviewers found no production blockers in the second full-diff round; the suite remains three cases. The parent independently reran all 47 tests on the final head.

A headless Linux run used copies of four real native Codex/Claude JSONL transcripts, rewriting only their workspace paths into isolated state. It exercised the production scanner, importer, event sink, SQLite projections and runtime repository, with fixture adapters for project/orchestrator queries. Main output imports all four and creates duplicate history for both owned sessions. Head output imports only the two unowned sessions, creates zero owned-session duplicate events, and preserves both original native ownership bindings, and leaves imported history counts unchanged after retry. Only aggregate counts were published; transcript contents stay private.

The client import wizard and resuming imported sessions through actual provider CLIs were not verified. macOS, Windows, iOS, Android, Electron desktop and relay/tunnel connections were not verified. This is a server behavior change without a visual change; proof is persisted output rather than screenshots. Human approval remains required before landing.

Closes #10933.

GPT-6.1 Sol (high), Codex harness in T3 Code; tests by GPT-6-Astra (high), reviews by Claude Opus 5.5 and GPT-6-Sol.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 9 seconds.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 8560755f-4dbc-481f-b658-9ff3686ffbef
      📥 Commits

      Reviewing files that changed from the base of the PR and between ab6be13d438abeace7617e8d789d59cf2e880f42 and f385bf066e469b82117e41514c8d35dee978518f.

      📒 Files selected for processing: 3
      • apps/server/src/orchestration-v2/EventSink.ts
      • apps/server/src/project/AgentSessionImporter.test.ts
      • apps/server/src/project/AgentSessionImporter.ts
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at f385bf0

      Macroscope's review found this PR approvable — This is a focused bug fix that prevents duplicate native-session history during bulk import using a transaction-scoped ownership check, while preserving existing callers and retrying missing runtime metadata without replaying history. The production change is small and supported by targeted integrated tests, with no schema, default, deployment, or static-analysis configuration changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one. I’ll trim the tests, rebuild the ownership check against current main, and verify native-session imports and retries before pushing to this branch.

    7. juliusmarminge merged this2b4a806

    8. juliusmarminge closed this

Sign in to join this conversation.