Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
acd7a81
Integrate Codex app-server support
juliusmarminge Apr 18, 2026
ae1e48e
nit
juliusmarminge Apr 18, 2026
e7a97c7
revert more
juliusmarminge Apr 18, 2026
cb5187e
resynclock
juliusmarminge Apr 18, 2026
5243f88
Delay Codex provider availability until checked
juliusmarminge Apr 18, 2026
90c6a96
Return Cursor ACP runtime with explicit scope
juliusmarminge Apr 18, 2026
0c54daf
Normalize Codex IDs and preserve streamed stdout decoding
juliusmarminge Apr 18, 2026
9ad00d4
Scope Codex session runtime lifetimes
juliusmarminge Apr 18, 2026
5a48939
decoders
juliusmarminge Apr 18, 2026
f12cec4
Flush native logs on adapter shutdown
juliusmarminge Apr 18, 2026
04c3a63
Switch Codex provider checks to app-server probe
juliusmarminge Apr 18, 2026
ba24ae6
Address Codex review feedback
juliusmarminge Apr 18, 2026
7501812
Fix Codex provider status test expectations
juliusmarminge Apr 18, 2026
ee3e516
Add orchestration v2 docs and probe fixtures
juliusmarminge Apr 20, 2026
af240b6
Add orchestration v2 replay and service contracts
juliusmarminge Apr 21, 2026
90f0867
Map Codex turns into orchestration v2
juliusmarminge Apr 21, 2026
f07662f
Implement orchestration v2 runtime
juliusmarminge Apr 24, 2026
43cb7fb
Add thread fork lineage and lazy context transfer
juliusmarminge Apr 29, 2026
eb7002a
Add orchestration V2 backend checklist
juliusmarminge Apr 29, 2026
ce30ceb
Add merge-back context handoff support
juliusmarminge May 2, 2026
6034957
Add V2 command capability policy
juliusmarminge May 4, 2026
3e59956
Add Claude replay fixture recorder
juliusmarminge May 6, 2026
87b9c7f
Extract Claude SDK query runner from provider adapter
juliusmarminge May 6, 2026
3f215af
Add model selection to orchestration runs
juliusmarminge May 6, 2026
7354000
Map Claude replay fixtures to multi-turn turns
juliusmarminge May 7, 2026
843e1ba
Map Claude turns to runtime query policies
juliusmarminge May 7, 2026
e44fd48
Support active Claude steering and turn replay mapping
juliusmarminge May 7, 2026
9ad9d83
Add turn-interrupt replay coverage and protocol logging
juliusmarminge May 7, 2026
2db49b4
Document Cursor SDK MCP projection for V2
juliusmarminge May 7, 2026
45e93c3
feat(orchestration-v2): wire claude adapter primitives
juliusmarminge May 27, 2026
ed3fc37
feat(orchestration-v2): support cross-provider handoff
juliusmarminge Jun 8, 2026
6e84e4f
fix(orchestration-v2): resolve cross-provider forks
juliusmarminge Jun 8, 2026
2bfb728
feat(orchestration-v2): add merge-back replay coverage
juliusmarminge Jun 9, 2026
b686a60
fix(orchestration-v2): compose provider switch merge context
juliusmarminge Jun 9, 2026
3c33fd5
fix(orchestration-v2): preserve source history on merged switch
juliusmarminge Jun 9, 2026
e139891
Map orchestration v2 WS methods to auth scopes
juliusmarminge Jun 9, 2026
f780a4e
feat(orchestration-v2): model native subagents
juliusmarminge Jun 9, 2026
29ae291
wip
juliusmarminge Jun 14, 2026
bdd3ff9
refactor(orchestration-v2): adopt host process spawn policy
juliusmarminge Jun 14, 2026
7fcf5cb
Add orchestration MCP toolkit
juliusmarminge Jun 17, 2026
708d622
Add Cursor SDK orchestration replay support
juliusmarminge Jun 17, 2026
bfe0804
Handle segmented Cursor turns and stable visible timelines
juliusmarminge Jun 18, 2026
b883f4f
Add ACP replay harness and session lifecycle support
juliusmarminge Jun 19, 2026
ac8a220
Add MCP thread management and Codex turn mapping
Jun 19, 2026
37deb90
Add Orchestration V2 application integration plan
Jun 20, 2026
42505da
Map orchestration turns to provider instances
Jun 20, 2026
e1604dc
Share Codex sessions across orchestration threads
Jun 21, 2026
f074049
Align orchestration V2 with Effect service conventions
Jun 21, 2026
540f190
Start orchestration V2 application services
Jun 21, 2026
0c5ba3f
Complete orchestration V2 application services
Jun 21, 2026
1d1b4cd
Require MCP registry for V2 provider sessions
Jun 21, 2026
de98238
Remove MCP credential expiration
Jun 21, 2026
aa0fd62
Guarantee MCP revocation during session release
Jun 21, 2026
56f9a4b
Integrate orchestration v2 with the application runtime
Jun 21, 2026
f3876e6
Split the V2 frontend plan into parity and enrichment phases
Jun 21, 2026
79c36e6
Complete orchestration V2 frontend cutover
Jun 22, 2026
34a64a3
Integrate orchestration V2 controls and process recovery
Jun 22, 2026
f7844d5
Handle preparing turns across provider orchestration
juliusmarminge Jun 23, 2026
991401f
Record created threads and subagent progress
juliusmarminge Jun 23, 2026
d1d6d4a
Map thread panel into title bar and sidebar
juliusmarminge Jun 24, 2026
77bc453
Reserve space for inline thread details panel
juliusmarminge Jun 25, 2026
786f5c5
Split open-in editor controls into panel and toolbar variants
juliusmarminge Jun 25, 2026
b5aa400
Hide subagent threads and simplify thread controls
juliusmarminge Jun 25, 2026
58d0d67
Render mobile timelines from V2 turn items
juliusmarminge Jun 25, 2026
634f529
Enrich mobile V2 execution items
juliusmarminge Jun 25, 2026
cdc52b9
Expose V2 thread workflows on mobile
juliusmarminge Jun 25, 2026
d454b38
Retire V1 client orchestration parity
juliusmarminge Jun 25, 2026
f7d11f3
Add iOS associated domains for Clerk
juliusmarminge Jun 25, 2026
dfef777
Map Grok task envelopes to subagent lineage
juliusmarminge Jun 26, 2026
5c0c393
Adopt userdata-v2 and subagent activity mapping
juliusmarminge Jun 29, 2026
f452af4
Map nested Codex subagent threads correctly
juliusmarminge Jun 29, 2026
8bd306e
Clarify thread relationship icons and ordering
juliusmarminge Jun 29, 2026
2d6e2f7
Keep persistent cards visible in folded turns
juliusmarminge Jun 29, 2026
3967f8b
Require Cursor API key for provider checks
juliusmarminge Jun 29, 2026
5973fd0
fix(web): align thread details panel controls and menus (#3606)
maria-rcks Jun 30, 2026
25ac7bc
Switch Cursor provider to the official SDK
juliusmarminge Jun 30, 2026
e80883a
Remove early access badges from Cursor and Grok
juliusmarminge Jun 30, 2026
69b4484
Allow provider switching via handoff in chat threads
juliusmarminge Jul 1, 2026
8ad1825
Fix Claude task turn mapping
juliusmarminge Jul 1, 2026
6e9f7fb
feat: scheduled tasks (automations) (#3638)
juliusmarminge Jul 1, 2026
822cf00
feat(orchestrator): Add shared provider continuation and background i…
mwolson Jul 9, 2026
e6165a0
[orchestrator-v2] fix(orchestrator): Restore Claude session continuit…
mwolson Jul 12, 2026
14ff168
[orchestrator-v2] fix(orchestrator): Codex background command complet…
mwolson Jul 12, 2026
5e7461a
fix(orchestrator): scope Claude MCP tool pre-approval (#3862)
PixPMusic Jul 20, 2026
11a8079
feat(orchestrator): pass model options through MCP thread targets (#3…
PixPMusic Jul 20, 2026
ed33650
fix(orchestrator): align Claude permission replay with SDK
juliusmarminge Jul 20, 2026
97c3e86
fix(ci): restore Claude permission request identity
juliusmarminge Jul 20, 2026
10131aa
test(desktop): expect orchestrator v2 state directory
juliusmarminge Jul 20, 2026
ebf788f
fix(claude): redact launch arguments from protocol logs
juliusmarminge Jul 20, 2026
bce048e
fix(claude): preserve approvals with full-access sandbox
juliusmarminge Jul 20, 2026
413411d
fix(claude): allow questions during plan mode
juliusmarminge Jul 20, 2026
923d6d6
fix(claude): honor never-approval runtime policies
juliusmarminge Jul 20, 2026
5db2f79
fix(claude): enforce read-only tool availability
juliusmarminge Jul 20, 2026
b9b1447
fix(claude): reopen queries after MCP credential rotation
juliusmarminge Jul 20, 2026
8780742
fix(acp): release turns after interrupt timeout
juliusmarminge Jul 20, 2026
7e5a2f0
fix(acp): bind MCP credentials to activated threads
juliusmarminge Jul 20, 2026
c83bf8a
fix(orchestrator): harden Grok v2 lifecycle (#3578)
mwolson Jul 20, 2026
1c60ecf
fix(orchestrator): dedupe Grok continuation dispatch
juliusmarminge Jul 20, 2026
729fe48
fix(orchestrator): Harden Grok v2 runtime lifecycle
mwolson Jul 20, 2026
7e3a578
test(orchestrator): align integration fixtures
juliusmarminge Jul 20, 2026
0856224
fix(mobile): support Hermes collection sorting
juliusmarminge Jul 20, 2026
d0fb74b
fix(grok): align ACP extensions with open source runtime
juliusmarminge Jul 20, 2026
c949898
Render T3 MCP tools with branded timeline labels
juliusmarminge Jul 21, 2026
92da633
Unify T3 MCP tool presentation across clients
juliusmarminge Jul 21, 2026
843b5b0
fix(orchestration): clarify agent delegation and scheduling
juliusmarminge Jul 22, 2026
149819d
fix(server): preserve released migration ordering
juliusmarminge Jul 24, 2026
6d7ff51
fix(web): restore v2 composer chrome
juliusmarminge Jul 24, 2026
059020a
fix(web): remove stacked composer shadows
juliusmarminge Jul 24, 2026
fd83e0b
refactor(web): use shared glass surfaces
juliusmarminge Jul 24, 2026
7c1b6b9
fix(web): layer nested panel popups correctly
juliusmarminge Jul 24, 2026
d4e6428
fix(web): contain thread details panel effects
juliusmarminge Jul 24, 2026
6236fc0
test(orchestrator): Align post-merge CTM fixtures (#4193)
mwolson Jul 24, 2026
87a65e1
fix(orchestrator): Preserve claude/codex post-interrupt recovery stat…
mwolson Jul 24, 2026
7c95eeb
test(orchestrator): align Codex approval reviewer replays (#4457)
juliusmarminge Jul 24, 2026
2169ce5
fix(orchestrator): hydrate shell cache and group multi-environment pr…
mwolson Jul 24, 2026
a81424f
feat(subagents): disclose projected results consistently (#3866)
PixPMusic Jul 24, 2026
0fa673a
Add worktree handoff and status tools to the t3-code MCP server (#3754)
nsxdavid Jul 24, 2026
1ae39f9
fix(mobile): wait for fork shell before navigation
juliusmarminge Jul 24, 2026
393db0b
fix(server): keep derived threads awake
juliusmarminge Jul 24, 2026
08dcb58
fix(server): enforce ACP auth and preserve fork provenance
juliusmarminge Jul 24, 2026
4c7fffd
fix(server): clean up Claude replay failures
juliusmarminge Jul 24, 2026
3af2b9c
test(orchestrator): align merged V2 compatibility checks
juliusmarminge Jul 27, 2026
c16526f
fix(grok): Prevent spurious wake run after in-turn monitors
mwolson Jul 21, 2026
eaafd5a
fix(acp): Preserve wake evidence across an app-owned wake
mwolson Jul 25, 2026
443a657
fix(orchestrator): Wake settled parents when delegated children finish
mwolson Jul 25, 2026
e5ce8b8
fix(claude): Settle positive task-notification results
mwolson Jul 27, 2026
55359ba
fix: hide subagent threads from v2 lists
Yusuf007R Jul 25, 2026
ff3121b
fix: ignore subagents when sorting sidebar projects
Yusuf007R Jul 25, 2026
d373c00
fix(web): restore checked-in project scripts
juliusmarminge Jul 27, 2026
31fdee1
chore(orchestrator): refresh checks after main sync
juliusmarminge Jul 27, 2026
fba7279
feat: migrate v1 state into orchestrator v2 (#4400)
juliusmarminge Jul 27, 2026
6c78689
fix(orchestrator): schedule effects from durable deadlines (#4656)
juliusmarminge Jul 28, 2026
6f7e808
fix(orchestration): harden scheduled task startup
juliusmarminge Jul 28, 2026
374193e
fix(mobile): preserve active thread state
juliusmarminge Jul 28, 2026
6758c72
fix(orchestration): preserve legacy schedule compatibility
juliusmarminge Jul 28, 2026
ee174d0
fix(contracts): reject invalid legacy intervals
juliusmarminge Jul 28, 2026
71708c2
fix(acp): make xai cancellation reliable
juliusmarminge Jul 28, 2026
3e7c9f8
fix(orchestration): handle checkpoint-wait runs
juliusmarminge Jul 28, 2026
e788e72
fix(orchestration): cancel queued work on archive
juliusmarminge Jul 28, 2026
6035400
fix(mobile): allow archiving post-provider work
juliusmarminge Jul 28, 2026
f55f252
fix(mobile): distinguish queued and waiting archive states
juliusmarminge Jul 28, 2026
2419608
fix(cursor): log close attempts before execution
juliusmarminge Jul 28, 2026
45ea220
fix(acp): discover final teardown descendants
juliusmarminge Jul 28, 2026
ee4e1a2
fix(checkpoints): preserve valid run history
juliusmarminge Jul 28, 2026
1537240
fix(orchestration): preserve imported conversation state
juliusmarminge Jul 28, 2026
e939f46
fix(acp): enforce task and permission invariants
juliusmarminge Jul 28, 2026
95c669c
fix(testkit): harden provider replay recording
juliusmarminge Jul 28, 2026
3e68bcd
fix(server): isolate deterministic attachment ids
juliusmarminge Jul 28, 2026
e55b16b
fix(claude): preserve explicit model options
juliusmarminge Jul 28, 2026
67afce2
fix(web): enforce secure provider field defaults
juliusmarminge Jul 28, 2026
e010b9a
fix(client): preserve live thread relationships
juliusmarminge Jul 28, 2026
79084cb
fix(checkpoints): retain thread-start baseline after failed runs
juliusmarminge Jul 29, 2026
4ed97bb
fix(mobile): gate thread controls on live runs
juliusmarminge Jul 29, 2026
32b069d
fix(orchestrator): address late review findings
juliusmarminge Jul 29, 2026
81c315a
fix(orchestrator): handle fresh review edge cases
juliusmarminge Jul 29, 2026
484060d
fix(orchestrator): harden provider edge cases
juliusmarminge Jul 29, 2026
96d057c
fix(orchestrator): execute resolved runtime responses
juliusmarminge Jul 29, 2026
127a4f7
fix(orchestrator): release stranded effect claims
juliusmarminge Jul 29, 2026
33305f1
fix(worktrees): make handoff rollback atomic
juliusmarminge Jul 29, 2026
25249ef
fix(orchestrator): avoid replaying settled effects
juliusmarminge Jul 29, 2026
627416a
fix(orchestrator): preserve retryable effect failures
juliusmarminge Jul 29, 2026
e4083c2
fix(orchestrator): preserve terminal effect outcomes
juliusmarminge Jul 29, 2026
e31e4b7
fix(orchestrator): validate replay edge cases
juliusmarminge Jul 29, 2026
c97f60c
fix(orchestrator): decode direct Claude result blocks
juliusmarminge Jul 29, 2026
0c06caf
fix(orchestrator): close cancellation edge cases
juliusmarminge Jul 29, 2026
c276a4e
fix(orchestrator): validate rollback and search links
juliusmarminge Jul 29, 2026
80f6d8c
fix(server): preserve project mutation client errors
juliusmarminge Jul 29, 2026
daf2e6f
fix(orchestrator): preserve migrated and nested history
juliusmarminge Jul 29, 2026
eb7a694
fix: address orchestration review findings
juliusmarminge Jul 29, 2026
481a87c
fix(mobile): label queued message intent
juliusmarminge Jul 29, 2026
a77af2d
fix: address orchestration review findings
juliusmarminge Jul 29, 2026
6090470
fix: preserve orchestration task identity
juliusmarminge Jul 29, 2026
711df00
fix: address latest orchestration review findings
juliusmarminge Jul 29, 2026
e626789
fix: preserve thread management failure semantics
juliusmarminge Jul 29, 2026
142e698
fix: close failed provider adapter scopes
juliusmarminge Jul 29, 2026
02378ec
feat(server): surface legacy thread migration progress
juliusmarminge Jul 29, 2026
f6d00cb
feat(orchestration): track provider retries and thread visits
juliusmarminge Jul 29, 2026
fdbeeaa
[codex] feat(web): show git progress in the commit button (#4963)
juliusmarminge Jul 30, 2026
ec708bb
perf(orchestration): per-thread shell deltas, visit throttling, event…
juliusmarminge Jul 30, 2026
27a232c
fix(chat): prevent stale timeline scroll and rerenders
juliusmarminge Jul 30, 2026
420dd78
fix(relay): stop replaying the whole event store into the awareness r…
juliusmarminge Jul 30, 2026
c4f226b
perf(web): keep timeline minimap animations off the main thread
juliusmarminge Jul 30, 2026
fc7a8bd
feat(orchestration): port thread title regeneration to the v2 runtime
juliusmarminge Jul 30, 2026
ed41011
fix(orchestration): thread visits no longer create activity loops (#5…
Yusuf007R Jul 30, 2026
f43b737
fix(orchestration): promoted queued messages keep the queued_turn intent
juliusmarminge Jul 30, 2026
f8b6e33
refactor(orchestration): split thread-not-sendable into typed errors
juliusmarminge Jul 30, 2026
1831fed
fix(web): remove elevated thread details panel styling
juliusmarminge Jul 30, 2026
0dd44cb
fix(web): keep Git progress title anchored
juliusmarminge Jul 30, 2026
0c15987
fix: reconcile rebase with latest main
maria-rcks Aug 3, 2026
f4a60d7
fix(orchestration-v2): restore generated thread titles (#5176)
Yusuf007R Aug 4, 2026
0f2c760
fix(orchestrator): Order thread lineage by creation time (#5310)
mwolson Aug 4, 2026
4c0d444
fix(server): restore worktree branch naming in the v2 orchestrator (#…
juliusmarminge Aug 4, 2026
94b8b66
feat(chat): refine V2 conversation UI (#5307)
maria-rcks Aug 4, 2026
7fb2a33
fix: adopt effect beta.103 APIs in rebased v2 code
juliusmarminge Aug 4, 2026
4ee82af
fix: send mcp-protocol-version header in worktree registration test
juliusmarminge Aug 4, 2026
72a757a
fix(web): restore compact header sizing for project script controls
juliusmarminge Aug 4, 2026
094ce5a
test(server): cover v2 thread title regeneration
juliusmarminge Aug 4, 2026
19bd2a5
chore: resolve lint warnings across v2 code
juliusmarminge Aug 4, 2026
2e204f5
fix(test): keep codex replay recovery off the repo checkout
juliusmarminge Aug 4, 2026
1662e4c
fix(orchestrator): Prevent redundant delegated completion turns (#5311)
mwolson Aug 5, 2026
a92cb7c
fix(server): stop tying codex text-generation temp files to the calle…
juliusmarminge Aug 5, 2026
444fc22
fix(web): remove open PR actions from git controls
juliusmarminge Aug 5, 2026
7816dd2
fix(server): renumber v2 migrations after main's 036_ProjectionThread…
juliusmarminge Aug 5, 2026
6efd13e
fix: port main fixes stranded by the v2 rewrite
juliusmarminge Aug 5, 2026
4213ac5
test(server): align migration expectations with renumbered ids
juliusmarminge Aug 5, 2026
f0e1196
feat(orchestrator): Surface waiting background work (#4378)
mwolson Aug 5, 2026
c92c468
feat(orchestrator): Add OpenCode 2 provider support
mwolson Aug 2, 2026
c77a7dd
fix(testkit): Honor scenario deadlines for subagent waits
mwolson Aug 5, 2026
2f1c37e
fix(opencode2): Recover stalled SSE and force-finalize Stop
mwolson Aug 6, 2026
0d963cd
feat(opencode2): Pin sdk-next beta and dual-normalize wire
mwolson Aug 6, 2026
23d992d
refactor(opencode2): Drop pre-beta session wire dialect
mwolson Aug 6, 2026
2c1fbb7
fix(opencode2): Boot beta lildax without shared state collisions
mwolson Aug 6, 2026
37ff24d
fix(opencode2): Bridge host auth and send next-16916 flat prompts
mwolson Aug 6, 2026
04eefae
fix(opencode2): Map next-16916 tool ids and short step events
mwolson Aug 6, 2026
e98b4fe
fix(opencode2): Gate step finish, absorb streams, and harden auth seed
mwolson Aug 6, 2026
8763ab3
chore(opencode2): Retrigger CI after missing Actions runs
mwolson Aug 6, 2026
244392b
chore(deps): Exclude OpenCode sdk beta from minimumReleaseAge
mwolson Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ jobs:
!/.repos/
sparse-checkout-cone-mode: false

# Blacksmith boots GitHub's Ubuntu runner image (gcc is usually present),
# but ACP process-tree live tests compile a small pthread fixture with `cc`
# and soft-skip when it is missing. Install build-essential so that path
# always runs in CI instead of silently no-oping.
- name: Install C toolchain for process-tree fixtures
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential
command -v cc
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
Expand Down
246 changes: 246 additions & 0 deletions .plans/19-thread-lineage-context-transfer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# Plan: Thread Lineage And Lazy Context Transfer

## Summary

Implement the shared backend foundation for forking, provider handoff, merge-back, and future subagents without forcing provider selection at fork time. The first slice should create cheap app-level fork lineage and defer expensive context materialization until a run starts and the target provider is known.

Architecture reference: `docs/orchestration-v2/thread-lineage-and-context-transfer.md`.

## Goals

- Support user-created fork threads for exploration.
- Keep fork creation provider-neutral and cheap.
- Reuse the same source-point/context-transfer model for provider switching, merge-back, and future subagents.
- Prefer native same-provider fork at first dispatch when available.
- Fall back to portable context only when native transfer is unavailable or target provider differs.
- Keep all behavior replayable through V2 events/projections.

## Non-Goals For First Slice

- Full portable context generation quality.
- Cross-provider adapter implementation beyond the data/runtime hook.
- Merge-back UI.
- Native or custom subagent orchestration.
- Forking from actively streaming provider state.
- Backward compatibility with old dev databases.

## Core Data Model

Add schema/contracts for:

```ts
type ContextTransferType =
| "fork"
| "provider_handoff"
| "merge_back"
| "subagent_spawn"
| "subagent_result";

type ContextSourcePoint = {
threadId: ThreadId;
runId?: RunId;
checkpointId?: CheckpointId;
turnItemId?: TurnItemId;
providerThreadRef?: NativeThreadRef;
providerTurnRef?: NativeTurnRef;
};

type ContextTransferStatus =
| "pending"
| "resolved_native"
| "resolved_portable"
| "failed"
| "consumed"
| "superseded";
```

Persist:

- `orchestration_v2_projection_context_transfers`
- optional later portable handoff payload columns/table if the existing context handoff projection is not enough

For the first slice, `ContextTransfer` is required. Materialized `ContextHandoff` payloads can be deferred until portable context is implemented.

## Events

Add V2 events:

- `context-transfer.created`
- `context-transfer.updated`
- possibly `context-handoff.created` later

Do not emit provider-native fork details as app identity. Native fork refs belong in the transfer resolution payload and provider thread refs.

## Commands

Add:

```ts
type ThreadForkCommand = {
type: "thread.fork";
commandId: CommandId;
sourceThreadId: ThreadId;
targetThreadId: ThreadId;
sourcePoint:
| { type: "latest_stable" }
| { type: "run"; runId: RunId }
| { type: "checkpoint"; checkpointId: CheckpointId };
title?: string;
createdAt: string;
};
```

First-slice policy:

- `latest_stable` resolves to latest completed run checkpoint.
- explicit completed run/checkpoint is accepted.
- active run source is rejected or resolved to latest stable checkpoint; choose one policy and test it.
- target thread starts idle.
- no provider session/thread is created by `thread.fork`.

## Runtime Hook

Add a provider-neutral start-context resolver used by run startup:

```ts
resolveStartContext({
threadId,
runId,
provider,
modelSelection,
userMessage,
}): Effect<StartContextResolution, StartContextResolutionError>
```

Resolution order:

1. No pending transfer targeting the thread/run: normal run start.
2. Pending fork transfer and same provider with native fork support: resolve native fork.
3. Pending transfer requiring portable context: return explicit unsupported/stub result in first slice, or build minimal portable context if cheap.
4. Failed resolution: fail command before provider side effects.

The resolver should be called before provider thread creation/startTurn so the adapter can decide whether to create, resume, or native-fork provider state.

## Codex Native Fork Path

Investigate the app-server native fork API in `effect-codex-app-server` and Codex docs/probes.

Implementation target:

- use native fork only when source provider is Codex and source native refs are strong;
- create or bind a new `ProviderThread` for the forked native thread;
- when the source point is an earlier completed Codex provider turn, fork the latest native thread first and then rollback the forked native thread by later terminal provider turns;
- mark `ContextTransfer.status = resolved_native` and then `consumed` when the first run starts;
- preserve source app thread lineage separately from native thread refs.

If native API details are not clean, land the data model and resolver first with native fork marked unsupported, then add Codex native fork in a follow-up.

## Portable Context Fallback

The first slice should define the fallback boundary even if it does not fully implement high-quality summarization.

Minimum viable fallback:

- detect cross-provider fork/handoff need;
- create failed/unsupported transfer resolution with a clear command error, or
- generate a deterministic minimal context handoff from app projection if we want a usable MVP.

Do not silently concatenate hidden summaries into the user message without a `ContextTransfer`/`ContextHandoff` record.

## Merge-Back Preparation

Do not implement merge-back in the first slice, but keep model support:

- `ContextTransfer.type = "merge_back"`
- `basePoint` on transfer
- source thread may differ from target thread

The later merge-back command should create a transfer from fork latest stable point back to source thread and consume it with the next user message.

## Subagent Preparation

Do not implement subagents in this slice, but keep model support:

- `createdBy: "agent"`
- `type: "subagent_spawn"` and `"subagent_result"`
- source/target thread relationship fields

Native subagent ingestion can later map provider-native child refs into the same graph. Cross-provider app-owned subagents can later create child app threads using the same transfer primitive.

## Projection And Debugger

Backend projection first:

- expose thread lineage in thread projection;
- expose context transfers in debug projection;
- expose transfer status and resolution strategy.

Debugger after backend:

- fork button/control from stable source point;
- show thread lineage/source point;
- show pending/resolved/failed transfers;
- show native vs portable resolution.

Do not build debugger controls before the backend projection is authoritative.

## Tests

Use `bun run test`, not `bun test`.

Required backend tests:

- `thread.fork` from latest completed checkpoint creates target thread and pending transfer.
- fork command is idempotent through command receipts.
- fork does not create provider session/thread eagerly.
- first run on same-provider fork invokes native resolution path when capability exists.
- unsupported native fork falls back or fails according to explicit policy.
- active-run fork policy is deterministic.
- replay/recovery preserves target thread lineage and pending transfer.

Add test provider layers only at external service boundaries. Do not mock core orchestration policy.

## Implementation Order

1. Add contract schemas and ids for context transfers/source points.
2. Add migration/projection table for context transfers.
3. Add event store/projection handling for transfer events.
4. Add `thread.fork` command policy and orchestrator path.
5. Add tests for cheap idle fork creation and recovery.
6. Add start-context resolver interface.
7. Wire resolver into run startup with no-op behavior.
8. Add Codex native fork capability investigation and adapter path.
9. Add tests for same-provider native fork resolution.
10. Add debug projection surface after backend behavior is stable.

## Validation

Before considering the slice complete:

- `bun fmt`
- `bun lint`
- `bun typecheck`
- targeted backend tests with `bun run test`

If backend code changes are included, tests must cover the new orchestration behavior before the task is considered done.

## Implementation Status

Implemented in this slice:

- context transfer ids, schemas, JSON codecs, events, and projection storage
- app-thread lineage on thread creation and fork creation
- `thread.fork` command using `latest_stable`, explicit run, or explicit checkpoint source points
- cheap idle fork creation with no eager provider session/thread/run
- Codex same-provider native `thread/fork` resolution on first target dispatch
- Codex native fork-from-earlier-run resolution with `thread/fork` plus fork-local `thread/rollback`
- transfer status progression through `pending`, `resolved_native`, and `consumed`
- command receipt idempotency for duplicate fork commands
- replay-backed integration coverage for lazy fork creation and native Codex fork consumption

Explicitly deferred:

- portable `ContextHandoff` materialization for cross-provider forks/provider handoff
- merge-back command/runtime
- subagent spawn/result runtime
- debugger controls for creating/inspecting transfers
Loading
Loading