Implement orchestration v2 runtime
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
8a6d895830
commit
1671e1f046
114 files changed
+25973
-3153
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
This document set describes the target architecture for the next orchestration model. It is not a patch plan for the current implementation and it intentionally ignores migration/backward compatibility. Those concerns should be handled after the target model is coherent.
|
||||
|
||||
V2 is an orchestrator rewrite, not a rewrite of the whole app domain platform. Existing non-orchestration domains, persistence/migration infrastructure, websocket/RPC infrastructure, and projection streaming semantics should be retained unless V2 exposes a concrete orchestration-specific gap.
|
||||
|
||||
V2 is designed around the real provider behavior observed in the Codex app-server probes, but it is not Codex-specific. Codex is treated as the richest protocol we currently have; weaker providers are adapted into the same model with app-owned ids and explicit capability flags.
|
||||
|
||||
## Documents
|
||||
@@ -39,14 +41,19 @@ V2 is designed around the real provider behavior observed in the Codex app-serve
|
||||
|
||||
```text
|
||||
Native provider protocol
|
||||
-> Raw event log
|
||||
-> Rotating raw provider diagnostics
|
||||
-> Provider adapter / normalizer
|
||||
-> V2 orchestration event store using existing persistence patterns
|
||||
-> Runtime execution graph
|
||||
-> Conversation projection
|
||||
-> UI / API views
|
||||
```
|
||||
|
||||
The raw event log stores what happened. The runtime graph stores what it means. The conversation projection stores what users see.
|
||||
Raw provider diagnostics store what the provider actually sent or received for debugging and replay capture. The durable app state is the normalized orchestration state: events/entities, correlation refs, projections, and command receipts. The runtime graph stores what provider behavior means. The conversation projection stores what users see.
|
||||
|
||||
V2 should integrate with the existing orchestration command/event/projection infrastructure patterns rather than creating an unrelated event system. The V2-specific work is the graph model, provider lifecycle semantics, adapter contracts, normalizers, policies, and projections.
|
||||
|
||||
While V1 is still present, V2 should own a V2 event schema and V2 event table. It should not force V2 semantics through the old `OrchestrationEvent` TypeScript union. The old union is a V1 semantic model, not the target V2 event vocabulary. A later migration can replace V1 with V2, but the target model should stay V2-native.
|
||||
|
||||
## Minimal Mental Model
|
||||
|
||||
@@ -79,3 +86,75 @@ The Codex app-server probes showed several protocol realities that the V2 model
|
||||
- Child provider turns are real provider turns and must not be remapped onto the parent provider turn id.
|
||||
|
||||
These observations are why V2 separates app runs, provider turns, and execution nodes.
|
||||
|
||||
## Existing Platform Boundaries
|
||||
|
||||
V2 should reuse existing app infrastructure where that infrastructure is not the source of the orchestration bug class:
|
||||
|
||||
- Command dispatch should keep the existing serialized/idempotent command handling and command receipt pattern.
|
||||
- Projection streams should keep the existing snapshot-plus-cursor semantics used by the current API.
|
||||
- Persistence should keep the existing SQLite/migration/repository infrastructure and projection-stream semantics.
|
||||
- Raw provider frames should continue to be diagnostic log data, with bounded retention through rotating logs.
|
||||
- Replay tests should replace only the provider transport/process boundary.
|
||||
|
||||
V2 may add V2-native orchestration events, projection tables, command policies, and provider execution services. It should not add a durable raw-provider-event database or a separate generic event bus unless the existing infrastructure cannot satisfy a documented V2 requirement.
|
||||
|
||||
V2 command dispatch returns the last committed stored-event sequence for accepted commands. Duplicate command ids must return the same receipt-backed result without re-running provider side effects. This is the API-level boundary the frontend uses for reconnect/recovery cursors.
|
||||
|
||||
## Tracked Follow-Up: Durable Effect Outbox
|
||||
|
||||
The current app pipeline uses domain events plus reactors to trigger provider side effects:
|
||||
|
||||
```text
|
||||
command
|
||||
-> domain event(s)
|
||||
-> projection
|
||||
-> reactor observes event
|
||||
-> provider side effect
|
||||
-> provider output ingestion
|
||||
-> domain event(s)
|
||||
```
|
||||
|
||||
This is valid, but it can become hard to trace because the provider side effect is implicit in a live subscription. If V2 needs stronger restart/recovery/debuggability, introduce a durable effect outbox for orchestration side effects:
|
||||
|
||||
```text
|
||||
command
|
||||
-> transaction:
|
||||
append domain event(s)
|
||||
append provider effect request(s)
|
||||
-> projection
|
||||
-> stream to UI
|
||||
|
||||
effect worker
|
||||
-> claim effect request
|
||||
-> call provider
|
||||
-> ingest provider output
|
||||
-> append domain event(s)
|
||||
-> mark effect request completed/failed
|
||||
```
|
||||
|
||||
Example effect request:
|
||||
|
||||
```ts
|
||||
type ProviderEffectRequest = {
|
||||
id: ProviderEffectRequestId;
|
||||
kind:
|
||||
| "provider.turn.start"
|
||||
| "provider.turn.interrupt"
|
||||
| "provider.runtime-request.respond"
|
||||
| "provider.thread.rollback"
|
||||
| "provider.thread.fork";
|
||||
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
||||
threadId: ThreadId;
|
||||
runId: RunId | null;
|
||||
nodeId: NodeId | null;
|
||||
provider: ProviderKind;
|
||||
payload: unknown;
|
||||
causationEventId: EventId;
|
||||
commandId: CommandId | null;
|
||||
attempts: number;
|
||||
lastError: string | null;
|
||||
};
|
||||
```
|
||||
|
||||
This should be treated as an infrastructure improvement, not a prerequisite for the first V2 slice. The first V2 implementation can use the existing reactor pattern, but it should keep the provider side-effect boundary clear enough that moving to an outbox later does not require redesigning the graph or provider adapters.
|
||||
@@ -23,7 +23,18 @@ The central separation is:
|
||||
- `ProviderSession`: a live or resumable provider process/runtime.
|
||||
- `ContextHandoff`: a provider-switch summary that bridges runs into another provider thread.
|
||||
|
||||
Provider-specific lifecycle is preserved in provider refs and raw events. App behavior is driven by app-owned ids and graph relationships.
|
||||
Provider-specific lifecycle is preserved in provider refs and diagnostic raw-provider logs. App behavior is driven by app-owned ids, V2-native orchestration events, and graph relationships.
|
||||
|
||||
V2 events are durable because they are the app state transition log. Raw provider frames are not durable app state. They may be attached by optional correlation ids such as `rawEventId`, but the canonical durable row is the normalized V2 event.
|
||||
|
||||
Every committed V2 event has a store-assigned monotonically increasing `sequence`. Projection snapshots and websocket streams use that sequence as the cursor boundary:
|
||||
|
||||
```text
|
||||
read snapshot at sequence N
|
||||
-> stream committed V2 events where sequence > N
|
||||
```
|
||||
|
||||
The sequence belongs to the stored event envelope, not the provider event and not the domain payload. Provider-native ordering is preserved separately through provider refs and diagnostic logs. Clients should treat the snapshot's `snapshotSequence` as the authoritative cursor and apply only subsequent events with a greater sequence.
|
||||
|
||||
## Entity Summary
|
||||
|
||||
@@ -105,13 +116,6 @@ ProviderTurn
|
||||
runAttemptId?
|
||||
status
|
||||
|
||||
RuntimeItem
|
||||
id: RuntimeItemId
|
||||
nodeId
|
||||
providerItemRef?
|
||||
kind
|
||||
status
|
||||
|
||||
RuntimeRequest
|
||||
id: RuntimeRequestId
|
||||
nodeId
|
||||
@@ -254,7 +258,7 @@ type ExecutionNode = {
|
||||
countsForRun: boolean;
|
||||
providerThreadId: ProviderThreadId | null;
|
||||
providerTurnId: ProviderTurnId | null;
|
||||
runtimeItemId: RuntimeItemId | null;
|
||||
nativeItemRef: ProviderRef | null;
|
||||
runtimeRequestId: RuntimeRequestId | null;
|
||||
checkpointScopeId: CheckpointScopeId | null;
|
||||
startedAt: string | null;
|
||||
@@ -306,6 +310,10 @@ type ProviderSession = {
|
||||
|
||||
A provider session may host one or more provider threads if the provider supports it. If a provider only supports one active conversation per process, V2 still models that as one provider thread attached to the session.
|
||||
|
||||
The session entity is durable metadata for a live-or-recoverable runtime, not the runtime handle itself. The in-memory process/client handle may disappear because the server restarted, an idle reaper released it, or the provider process crashed. In all cases, the app keeps the `ProviderSession`, `ProviderThread`, and native resume refs in durable state, then recreates the live runtime through the normal provider session manager path.
|
||||
|
||||
Provider runtime ids and ordinals must not depend on adapter process memory. If a value is persisted or must survive recovery, it is allocated by the orchestrator/correlation/id services or derived from durable provider refs.
|
||||
|
||||
## ProviderThread
|
||||
|
||||
A `ProviderThread` is a provider-native conversation handle. It is addressable even when it is nested under a subagent execution node.
|
||||
@@ -385,37 +393,6 @@ type ProviderTurn = {
|
||||
|
||||
Codex has strong native turn ids. Weaker providers may only have ordinals. Both map into `ProviderTurnId`.
|
||||
|
||||
## RuntimeItem
|
||||
|
||||
Items are provider-visible work units inside a turn or node.
|
||||
|
||||
```ts
|
||||
type RuntimeItem = {
|
||||
id: RuntimeItemId;
|
||||
nodeId: NodeId;
|
||||
providerTurnId: ProviderTurnId | null;
|
||||
nativeItemRef: string | null;
|
||||
ordinal: number;
|
||||
kind:
|
||||
| "assistant_message"
|
||||
| "reasoning"
|
||||
| "plan"
|
||||
| "todo_list"
|
||||
| "command_execution"
|
||||
| "file_change"
|
||||
| "mcp_tool_call"
|
||||
| "dynamic_tool_call"
|
||||
| "collab_agent_tool_call"
|
||||
| "web_search"
|
||||
| "unknown";
|
||||
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
||||
title: string | null;
|
||||
detail: string | null;
|
||||
};
|
||||
```
|
||||
|
||||
The item id is app-owned. Provider-native item ids are refs.
|
||||
|
||||
## RuntimeRequest
|
||||
|
||||
Requests represent provider-originated callbacks that require app/user response.
|
||||
@@ -425,12 +402,11 @@ type RuntimeRequest = {
|
||||
id: RuntimeRequestId;
|
||||
nodeId: NodeId;
|
||||
providerTurnId: ProviderTurnId | null;
|
||||
runtimeItemId: RuntimeItemId | null;
|
||||
nativeRequestRef: string | null;
|
||||
kind:
|
||||
| "command_approval"
|
||||
| "file_read_approval"
|
||||
| "file_change_approval"
|
||||
| "command"
|
||||
| "file-read"
|
||||
| "file-change"
|
||||
| "dynamic_tool_call"
|
||||
| "user_input"
|
||||
| "auth_refresh";
|
||||
@@ -443,6 +419,10 @@ type RuntimeRequest = {
|
||||
};
|
||||
```
|
||||
|
||||
The permission kinds are the same canonical domain values used by V1 `ProviderRequestKind`.
|
||||
Adapters map provider-native callback names such as Codex `item/commandExecution/requestApproval`
|
||||
and Claude tool permission names into these app-level values.
|
||||
|
||||
Requests may remain visible after restart, but they are only respondable if their `responseCapability` is live.
|
||||
|
||||
## Messages
|
||||
@@ -468,7 +448,7 @@ Provider message chunks are collected through items/content events and projected
|
||||
|
||||
## Plans, Questions, And Todo Lists
|
||||
|
||||
V2 treats these as structured runtime items or nodes.
|
||||
V2 treats these as structured turn items or execution nodes.
|
||||
|
||||
```ts
|
||||
type PlanArtifact = {
|
||||
@@ -501,7 +481,7 @@ type Checkpoint = {
|
||||
ordinalWithinScope: number;
|
||||
appRunOrdinal: number | null;
|
||||
ref: string;
|
||||
status: "ready" | "missing" | "error";
|
||||
status: "ready" | "missing" | "error" | "stale";
|
||||
files: CheckpointFileSummary[];
|
||||
capturedAt: string;
|
||||
};
|
||||
@@ -509,9 +489,9 @@ type Checkpoint = {
|
||||
|
||||
A child/subagent provider turn can create a child checkpoint. It does not create an app-run checkpoint unless it is running as a first-class app run in a forked/promoted thread.
|
||||
|
||||
## Raw Event Log
|
||||
## Raw Provider Diagnostics
|
||||
|
||||
The raw event log is append-only evidence.
|
||||
Raw provider diagnostics are append-only evidence for debugging, support, and replay fixture generation. They should be written to bounded rotating log files, not treated as canonical durable SQLite state.
|
||||
|
||||
```ts
|
||||
type RawProviderEvent = {
|
||||
@@ -528,7 +508,17 @@ type RawProviderEvent = {
|
||||
};
|
||||
```
|
||||
|
||||
No domain behavior should depend on parsing historic UI events if raw provider events are available.
|
||||
No domain behavior should depend on parsing historic UI events if raw provider diagnostics are available. Production behavior should depend on normalized orchestration events/entities and provider refs. Raw provider frames are evidence and replay input, not the source of truth for normal app state.
|
||||
|
||||
Normalized V2 entities should preserve enough correlation metadata to explain and route behavior:
|
||||
|
||||
- provider kind.
|
||||
- provider session/thread/turn refs.
|
||||
- provider item/request refs when available.
|
||||
- native id strength.
|
||||
- diagnostic log location or raw frame reference when useful.
|
||||
|
||||
The replay framework can use raw provider transcripts as input without requiring production SQLite to store every raw frame.
|
||||
|
||||
## Projections
|
||||
|
||||
@@ -542,11 +532,13 @@ V2 should expose separate projections:
|
||||
|
||||
The UI can remain simple while the graph remains precise.
|
||||
|
||||
Projection streaming should use the existing app snapshot-plus-cursor contract. A thread-detail subscription should return a projection snapshot at sequence `N`, then stream only events after `N`. The frontend should not receive events already reflected in the snapshot. Reconnects may reset from a fresh snapshot instead of replaying local client state; the fresh snapshot and its `snapshotSequence` become the new cursor boundary.
|
||||
|
||||
## Turn Item Projection
|
||||
|
||||
The frontend should not reconstruct display order by merging `messages`, `runtimeItems`, `plans`, checkpoints, approvals, and activities itself. V2 should expose an ordered `turnItems` projection for thread detail rendering.
|
||||
The frontend should not reconstruct display order by merging `messages`, `plans`, checkpoints, approvals, and activities itself. V2 exposes an ordered `turnItems` projection for thread detail rendering.
|
||||
|
||||
`turnItems` are projection records, not the canonical source of truth. The canonical graph remains normalized in runs, attempts, nodes, runtime items, requests, messages, plans, and checkpoints. The projection reducer is responsible for turning that graph into a deterministic display stream.
|
||||
`turnItems` are projection records, not the canonical source of truth. The canonical graph remains normalized in runs, attempts, nodes, requests, messages, plans, and checkpoints. Provider-native item refs live directly on nodes and turn items where correlation is needed.
|
||||
|
||||
Known common tools should have structured item variants so the frontend can render stable custom components without parsing provider text:
|
||||
|
||||
@@ -603,4 +595,4 @@ Compaction, handoff, and fork are orchestration lifecycle items, not dynamic too
|
||||
- `handoff`: records the context bridge from one or more source provider threads/providers to a target provider thread/provider.
|
||||
- `fork`: records that the user or system created a new app thread from a run, node, or provider thread.
|
||||
|
||||
The UI can render known variants with deterministic components and render `dynamic_tool` as expandable JSON input/output. Each turn item keeps refs back to `runId`, `nodeId`, `providerTurnId`, and `runtimeItemId` so debug views can jump from the display stream back into the graph.
|
||||
The UI can render known variants with deterministic components and render `dynamic_tool` as expandable JSON input/output. Each turn item keeps refs back to `runId`, `nodeId`, `providerTurnId`, and `nativeItemRef` so debug views can jump from the display stream back into the graph and provider logs.
|
||||
@@ -15,9 +15,8 @@ NodeId execution graph node
|
||||
ProviderSessionId live/resumable provider runtime session
|
||||
ProviderThreadId app handle for provider-native conversation
|
||||
ProviderTurnId app handle for provider-native turn
|
||||
RuntimeItemId app handle for provider item/tool/message artifact
|
||||
RuntimeRequestId app handle for provider callback/request
|
||||
RawEventId raw provider event log id
|
||||
RawEventId optional raw provider diagnostic frame id
|
||||
CheckpointId app checkpoint id
|
||||
PlanId app plan/todo/question artifact id
|
||||
```
|
||||
@@ -57,7 +56,7 @@ ProviderTurn:
|
||||
providerThreadId + nativeTurnRef
|
||||
or providerThreadId + turnOrdinal
|
||||
|
||||
RuntimeItem:
|
||||
Node / TurnItem:
|
||||
providerTurnId + nativeItemRef
|
||||
or providerTurnId + itemOrdinal
|
||||
|
||||
@@ -89,14 +88,14 @@ type IdentityBinding = {
|
||||
providerTurnId: ProviderTurnId | null;
|
||||
};
|
||||
correlation: "native_exact" | "native_scoped" | "ordinal" | "fingerprint" | "synthetic";
|
||||
firstRawEventId: RawEventId;
|
||||
lastRawEventId: RawEventId;
|
||||
firstRawEventId?: RawEventId;
|
||||
lastRawEventId?: RawEventId;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
```
|
||||
|
||||
This is not meant to be a large identity subsystem. It is the minimal durable place that says, "this native thing corresponds to this app thing."
|
||||
This is not meant to be a large identity subsystem. It is the minimal durable place that says, "this native thing corresponds to this app thing." Raw event references are optional diagnostic pointers; the binding itself must not require production SQLite to retain raw provider frames forever.
|
||||
|
||||
## ID Allocation Rules
|
||||
|
||||
@@ -119,7 +118,7 @@ requestOrdinalWithinProviderTurn
|
||||
messageOrdinalWithinNode
|
||||
```
|
||||
|
||||
Ordinals are assigned by the normalizer when events are processed. They must be replay-deterministic for a given raw event log.
|
||||
Ordinals are assigned by the normalizer when provider frames are processed. They must be replay-deterministic for a given provider transcript.
|
||||
|
||||
## Fingerprints
|
||||
|
||||
@@ -131,11 +130,11 @@ Examples:
|
||||
ProviderTurn fingerprint:
|
||||
providerThreadId + runId + providerTurnOrdinalWithinProviderThread
|
||||
|
||||
RuntimeItem fingerprint:
|
||||
Node / TurnItem fingerprint:
|
||||
providerTurnId + itemKind + itemOrdinalWithinProviderTurn + toolName?
|
||||
|
||||
RuntimeRequest fingerprint:
|
||||
providerTurnId + requestKind + itemId? + requestOrdinalWithinProviderTurn
|
||||
providerTurnId + requestKind + nativeItemRef? + requestOrdinalWithinProviderTurn
|
||||
```
|
||||
|
||||
Do not use complete assistant text as a primary fingerprint. Text is mutable, can stream in chunks, and can be duplicated.
|
||||
@@ -155,7 +154,7 @@ type RuntimeEvent = {
|
||||
providerSessionId: ProviderSessionId | null;
|
||||
providerThreadId: ProviderThreadId | null;
|
||||
providerTurnId: ProviderTurnId | null;
|
||||
itemId: RuntimeItemId | null;
|
||||
nativeItemRef: string | null;
|
||||
requestId: RuntimeRequestId | null;
|
||||
providerRefs: ProviderRefs;
|
||||
payload: unknown;
|
||||
@@ -209,7 +208,6 @@ For Codex:
|
||||
|
||||
```text
|
||||
collabAgentToolCall item
|
||||
-> RuntimeItem
|
||||
-> ExecutionNode(kind="subagent" or "tool_call")
|
||||
receiverThreadIds[]
|
||||
-> ProviderThread records
|
||||
@@ -223,11 +221,11 @@ For weak providers, the adapter may create a child node by ordinal under the act
|
||||
|
||||
## Replay Determinism
|
||||
|
||||
Given the same raw event log and same initial app state, normalization must produce the same ids.
|
||||
Given the same provider transcript and same initial app state, normalization must produce the same ids.
|
||||
|
||||
Requirements:
|
||||
|
||||
- Identity bindings are persisted as events or durable rows.
|
||||
- Generated ids can be random if the binding is persisted before downstream projection.
|
||||
- Fixture replay may use deterministic id generation to make assertions easier.
|
||||
- Reprocessing the same raw event should find the existing binding, not allocate another entity.
|
||||
- Reprocessing the same provider frame should find the existing binding, not allocate another entity.
|
||||
@@ -210,13 +210,20 @@ If the provider does not support interruption:
|
||||
|
||||
## Resumption
|
||||
|
||||
Resumption has two meanings:
|
||||
Resumption has three related meanings:
|
||||
|
||||
1. Resume an app thread in the UI from persisted projection.
|
||||
2. Resume a provider-native conversation/session.
|
||||
3. Recover or recreate a live provider runtime process while preserving app and provider-thread continuity.
|
||||
|
||||
V2 always supports app-thread resumption from stored events/projections. Provider-thread resumption is a required provider adapter primitive. Every provider harness must expose a cursor/session/thread handle that can be used to resume prior provider state.
|
||||
|
||||
Provider runtime recovery is also a core primitive, not a test-only hook. The same recovery path is used when:
|
||||
|
||||
- the user restarts the app/server and all provider processes are gone,
|
||||
- an idle-session reaper intentionally releases provider processes,
|
||||
- a provider process crashes or loses network and policy allows retry.
|
||||
|
||||
```text
|
||||
open app thread
|
||||
-> load AppThread, Runs, Messages, ExecutionGraph summary
|
||||
@@ -233,6 +240,19 @@ provider resume
|
||||
bind new ProviderSessionId to ProviderThread
|
||||
```
|
||||
|
||||
Provider runtime recovery flow:
|
||||
|
||||
```text
|
||||
provider runtime unavailable
|
||||
-> mark ProviderSession stopped/error with reason
|
||||
-> remove live runtime handle from ProviderSessionManager
|
||||
-> keep ProviderThread and nativeThreadRef durable
|
||||
-> on next work, open a new provider runtime
|
||||
-> resume the active ProviderThread before starting/retrying work
|
||||
```
|
||||
|
||||
Idle cleanup and crash recovery must use production lifecycle APIs. Tests may recreate the outermost layer/runtime or drive the same reaper/recovery service with deterministic clock and replayed provider transport, but they must not use test-only session restart methods.
|
||||
|
||||
If provider resume fails:
|
||||
|
||||
- preserve historical graph.
|
||||
|
||||
@@ -103,7 +103,7 @@ type ToolCapabilities = {
|
||||
};
|
||||
```
|
||||
|
||||
Weak providers may produce only textual tool summaries. The adapter can still create `RuntimeItem` records by scoped ordinal.
|
||||
Weak providers may produce only textual tool summaries. The adapter can still create ordered `turnItems` and execution nodes by scoped ordinal.
|
||||
|
||||
## Approval Capabilities
|
||||
|
||||
@@ -263,12 +263,14 @@ type ProviderAdapter = {
|
||||
readThreadSnapshot?(input): ProviderThreadSnapshot;
|
||||
rollbackThread?(input): ProviderThreadSnapshot | void;
|
||||
forkThread?(input): ProviderThread;
|
||||
streamRawEvents(): Stream<RawProviderEvent>;
|
||||
streamEvents(): Stream<ProviderAdapterEvent>;
|
||||
};
|
||||
```
|
||||
|
||||
Optional methods are guarded by capabilities. The orchestration layer should not call optional methods without checking capability or going through a policy wrapper.
|
||||
|
||||
Raw provider frames should be logged by the provider transport/runtime as bounded diagnostics. Adapter streams should expose normalized provider events that the V2 normalizer can turn into app orchestration events.
|
||||
|
||||
## Capability-Driven UI
|
||||
|
||||
The UI should receive capability-informed affordances:
|
||||
|
||||
@@ -14,13 +14,15 @@ command dispatch
|
||||
-> real ProviderAdapter
|
||||
-> replayed ProviderRuntime transport
|
||||
-> real adapter normalizer
|
||||
-> real EventLog
|
||||
-> real Projection
|
||||
-> real V2 event store/sink using production persistence semantics
|
||||
-> real V2 projection/projector
|
||||
-> real Checkpoint policy
|
||||
-> assertions
|
||||
```
|
||||
|
||||
The replay framework replaces the external provider process or network stream. It does not replace the adapter, normalizer, event log, projection, command router, checkpoint policy, or business logic.
|
||||
The replay framework replaces the external provider process or network stream. It does not replace the adapter, normalizer, command/event infrastructure, projection reducers/projectors, checkpoint policy, or business logic.
|
||||
|
||||
Raw provider frames in replay transcripts are realistic transport evidence. In production, equivalent raw frames are diagnostic log data with bounded retention. Integration tests should still use real normalized orchestration persistence/projections so replay input exercises the same adapter and orchestration paths as live provider output.
|
||||
|
||||
## Allowed Test Substitutes
|
||||
|
||||
@@ -38,7 +40,7 @@ Not allowed in integration tests:
|
||||
- mocked orchestrator.
|
||||
- mocked provider adapter.
|
||||
- mocked provider event normalizer.
|
||||
- mocked event log.
|
||||
- mocked command/event infrastructure or V2 event sink.
|
||||
- mocked projection reducer.
|
||||
- mocked checkpoint service behavior.
|
||||
- mocked provider capability policy.
|
||||
@@ -100,6 +102,8 @@ The replay runtime owns deterministic transport semantics:
|
||||
|
||||
The replay runtime must not know what a turn, plan, approval, subagent, or checkpoint means. Provider adapters interpret provider-specific frames.
|
||||
|
||||
Recovery tests use replay only at the provider transport boundary. App restart is tested by tearing down and recreating the outermost orchestrator/server layer against durable persistence. Idle cleanup and crash recovery are tested through production lifecycle services such as the session reaper or runtime recovery policy. Tests must not add adapter or orchestrator methods whose only purpose is to restart sessions for assertions.
|
||||
|
||||
## Provider Transcript Formats
|
||||
|
||||
Each provider can have its own raw frame format inside the generic replay envelope.
|
||||
@@ -152,15 +156,19 @@ Additional tests should be added only when they protect a new invariant or repro
|
||||
- Fixtures should include enough outbound expectations to prove the app sent the correct provider commands.
|
||||
- Fixtures should include protocol metadata, provider version, model, cwd policy, and capture timestamp.
|
||||
- Fixture playback must be deterministic under Effect `TestClock` and deterministic `Random` layers.
|
||||
- When a provider transcript is generated from a real run, keep the original raw event ordering.
|
||||
- When a provider transcript is generated from a real run, keep the original provider frame ordering.
|
||||
- Redaction should preserve ids, method names, lifecycle ordering, and correlation structure.
|
||||
- Fixture transcripts are test input and diagnostic evidence. They do not imply production stores all raw provider frames in SQLite.
|
||||
|
||||
## Assertions
|
||||
|
||||
Assertions should prefer final projections and durable event logs over incidental implementation calls.
|
||||
Assertions should prefer final projections and durable normalized orchestration events over incidental implementation calls.
|
||||
|
||||
Good assertions:
|
||||
|
||||
- duplicate command dispatch returns the original receipt sequence without replaying provider transport.
|
||||
- stored-event sequence monotonicity.
|
||||
- snapshot sequence plus stream-after-sequence behavior.
|
||||
- run status and ordinal.
|
||||
- active/final run attempt.
|
||||
- execution node parent/child structure.
|
||||
@@ -168,7 +176,7 @@ Good assertions:
|
||||
- checkpoint scope hierarchy.
|
||||
- pending/resolved runtime requests.
|
||||
- handoff coverage and strategy.
|
||||
- raw event count and normalized event count when relevant.
|
||||
- replay transcript frame count and normalized event count when relevant.
|
||||
|
||||
Weak assertions:
|
||||
|
||||
|
||||
Reference in new issue
Block a user