Showing the changes to docs (1 of 18 files). Show all
Unified · Split
| @@ -1,40 +0,0 @@ | |||
| 1 | # ADR 0001: Provider Runtime Lifecycle Ownership | ||
| 2 | |||
| 3 | ## Status | ||
| 4 | Accepted | ||
| 5 | |||
| 6 | ## Context | ||
| 7 | Provider runtime streams can include auxiliary work (for example collab/child-agent turns) under the same provider session as a user-visible primary turn. | ||
| 8 | |||
| 9 | The previous orchestration ingestion and checkpoint flows keyed lifecycle updates by `providerSessionId` alone. This allowed auxiliary `turn.completed` events to: | ||
| 10 | |||
| 11 | - mark thread sessions as `ready` before the primary turn completed | ||
| 12 | - clear `activeTurnId` for a still-running primary turn | ||
| 13 | - emit checkpoint turn-diff summaries for auxiliary turns in the main thread timeline | ||
| 14 | |||
| 15 | ## Decision | ||
| 16 | Define and enforce a lifecycle ownership invariant: | ||
| 17 | |||
| 18 | - Only events in the primary thread/turn lane may mutate thread session lifecycle state (`status`, `activeTurnId`, `providerThreadId`) and checkpoint turn completion. | ||
| 19 | - Auxiliary events may still append messages and activities. | ||
| 20 | |||
| 21 | Current enforcement is implemented with scope guards: | ||
| 22 | |||
| 23 | - Runtime ingestion only applies lifecycle transitions when the event targets the active primary scope (provider thread and active turn checks). | ||
| 24 | - Checkpoint capture ignores `turn.completed` events from non-primary provider thread scope, and ignores non-active turn completions while a primary turn is active. | ||
| 25 | |||
| 26 | ## Consequences | ||
| 27 | |||
| 28 | ### Positive | ||
| 29 | - Prevents premature loss of "working" state from auxiliary turn completion. | ||
| 30 | - Prevents auxiliary changed-files/checkpoint cards from appearing as if they were primary turn completion. | ||
| 31 | - Keeps useful auxiliary activity/message visibility. | ||
| 32 | |||
| 33 | ### Negative | ||
| 34 | - Runtime events that omit thread/turn identifiers are treated conservatively in lifecycle transitions. | ||
| 35 | - Full explicit lane modeling is still desirable in contracts for long-term clarity. | ||
| 36 | |||
| 37 | ## Follow-up | ||
| 38 | 1. Add explicit runtime lane metadata (`primary` vs `auxiliary`) to canonical provider runtime events. | ||
| 39 | 2. Persist orchestration-to-provider turn binding (`TurnId` <-> `ProviderTurnId`) for stronger reconciliation and replay safety. | ||
| 40 | 3. Promote lifecycle ownership checks from heuristic guards to schema-level invariants once lane metadata is available. | ||