t3-code-android-nightly/docs/internals/legacy-orchestration-migration.md
Julius Marminge de34391427
feat(orchestrator): introduce new orchestrator (#2829)
Co-authored-by: maria-rcks <maria@kuuro.net>
Co-authored-by: Bilal Bakr <62337003+Bil0000@users.noreply.github.com>
Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>
Co-authored-by: Vitalii Yehorov <vitalyiegorov@gmail.com>
Co-authored-by: Jake Leventhal <jakeleventhal@me.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Alex Southwell <saphid@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nicholas Wasmiller <derped@mineperial.com>
Co-authored-by: PB <poilmb@gmail.com>
Co-authored-by: Exotic <118054752+extoci@users.noreply.github.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Theo Browne <me@t3.gg>
Co-authored-by: Gabriel De Andrade <30420087+gabrielelpidio@users.noreply.github.com>
Co-authored-by: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com>
Co-authored-by: scratchyone <scratchywon@gmail.com>
Co-authored-by: Dominic Roy <dominic@sdko.org>
Co-authored-by: chukfinley <chuk@chuk.dev>
Co-authored-by: Primož Ajdišek <bigpod@bigpod.si>
Co-authored-by: benthecarman <benthecarman@live.com>
Co-authored-by: NaveDanan <nave0712@gmail.com>
Co-authored-by: aaditagrawal <103925638+aaditagrawal@users.noreply.github.com>
Co-authored-by: Aditya Garud <153842990+yashranaway@users.noreply.github.com>
Co-authored-by: Nick Anisimov <n.anisimov.23@gmail.com>
Co-authored-by: MacKinley Smith <smithmackinley@gmail.com>
Co-authored-by: Yordis Prieto <yordis.prieto@gmail.com>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: AKolenda <akole779@mtroyal.ca>
Co-authored-by: Guillermo Casanova <75276669+Gigioxx@users.noreply.github.com>
Co-authored-by: Otavio Salvador <otavio@ossystems.com.br>
Co-authored-by: Shirish Pothi <183252392+shirishpothi@users.noreply.github.com>
Co-authored-by: Ishaan Kothari <ishaanko.mail@gmail.com>
Co-authored-by: Bob Fowler <bob@rjf.ca>
Co-authored-by: Anton Bezdenezhnykh <gamer392@yandex.ru>
Co-authored-by: ValeraZSD <48602572+ValeraZSD@users.noreply.github.com>
Co-authored-by: Ephraim <ephraim39hr14m@gmail.com>
Co-authored-by: Ryan Ilano <ryanilano@users.noreply.github.com>
Co-authored-by: Alex <me@pixp.cc>
Co-authored-by: maco <gosarmarcel7@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Tristan Knight <admin@snappeh.com>
Co-authored-by: PR Batch Tester <agent@local.test>
Co-authored-by: oliver <97427849+flamboh@users.noreply.github.com>
Co-authored-by: kamkm <99585688+Kamkmgamer@users.noreply.github.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
2026-10-02 12:22:22 -07:00

3.6 KiB

Legacy orchestration migration

Orchestration v2 snapshots state.sqlite into statev2.sqlite before opening writable persistence on its first launch. Only the copy receives v2 migrations; the original remains available to v1. Subsequent launches reuse the copy without refreshing it from v1. It creates v2 thread shell events first and imports the complete user and assistant transcript lazily when a client reads or continues the thread. The v1 projection tables remain the import source and provide a read-only recovery source if an import needs investigation.

Imported data

The shell import preserves the project and thread identifiers, title, provider and model selection, runtime and interaction modes, branch, worktree path, creation and update times, archive and delete times, settlement override and timestamps, snooze timestamps, pin timestamp and order, and linked pull request. The metadata repair path fills snooze, pin order, unsettledAt, and linked pull request fields for threads imported before those fields were covered.

Transcript import reads user and assistant rows from projection_thread_messages. It preserves message identifiers, text, supported attachments, timestamps, role, and ordering. A message that was still streaming becomes an interrupted turn item.

The importer does not translate provider session identity, native provider runs, checkpoints and diffs, activities and tool calls, approvals, or proposed plans. V2 therefore must not present those records as migrated history.

First continuation

A migrated thread has no active provider thread. Its first continuation creates a fresh provider session and sends a legacy handoff built only from user and assistant messages. The handoff selects the newest transcript suffix within a 32,000-character budget, including section labels and the import notice. This budget is separate from portable provider handoffs.

Client and server cutover

Clients and servers must agree on ORCHESTRATION_PROTOCOL_VERSION (currently 2). The client runtime appends orchestrationProtocol=2 to the socket URL, and the /ws route rejects a missing or mismatched version with HTTP 426 (orchestration_protocol_incompatible) before any RPC or auth work runs. The client checks the environment descriptor the same way: a missing version means the host predates protocol 2, and a different version means both sides need updating. Either direction blocks the connection as unsupported with a message naming the machine to update rather than running half-upgraded. See packages/client-runtime/src/connection/compatibility.ts and apps/server/src/ws.ts.

Divergent migration ids

effect_sql_migrations records migration_id and name, but the migrator compares ids only: rows at or below the recorded maximum are skipped without checking names. A database that ran a local or fork migration under an id this build later assigns to a different migration therefore never receives this build's migration at that id. runMigrations logs each recorded id whose name differs from the manifest so the skipped schema change is diagnosable. There is no safe id range for a fork inside this ledger: any id at or below a future upstream id masks it forever, so fork schema changes belong in a separate migration table or outside the migrator entirely.

Recovery

There is no supported whole-thread export API. Recovery uses an untouched copy of the environment's userdata directory and opens that copy with SQLite's read-only mode. The user guide documents the queries against projection_threads and projection_thread_messages. Never start a server against the recovery copy because startup can run migrations and write new state.