effect-durable-agent 0.1.0-alpha.1 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -136
- package/dist/{command-queues-CQ9cwRP7.d.ts → command-queues-CQi4Xc7u.d.ts} +109 -21
- package/dist/{commands-Ce1ec6kH.d.ts → commands-p8venTWs.d.ts} +10 -2
- package/dist/compaction-0k8zCJgB.js +473 -0
- package/dist/compaction-0k8zCJgB.js.map +1 -0
- package/dist/{compaction-YayFKo_1.d.ts → compaction-BhLSSXJ-.d.ts} +28 -7
- package/dist/context-projection-mCuvcO2W.d.ts +140 -0
- package/dist/{core-Hv3cFydL.d.ts → core-C-6xHzRx.d.ts} +6 -3
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/command-queues.js +1 -1
- package/dist/domain/command-queues.js.map +1 -1
- package/dist/domain/context-projection.d.ts +2 -0
- package/dist/domain/context-projection.js +32 -0
- package/dist/domain/context-projection.js.map +1 -0
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/model-usage.d.ts +2 -0
- package/dist/domain/model-usage.js +59 -0
- package/dist/domain/model-usage.js.map +1 -0
- package/dist/domain/reduced-state-schema.d.ts +14 -18
- package/dist/domain/reduced-state-schema.js +7 -11
- package/dist/domain/reduced-state-schema.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +3 -2
- package/dist/domain/reduced-state.js +3 -2
- package/dist/domain/run-scheduling.d.ts +2 -0
- package/dist/domain/run-scheduling.js +127 -0
- package/dist/domain/run-scheduling.js.map +1 -0
- package/dist/{durable-C3Rz7kg3.js → durable-BPHVFVvV.js} +74 -83
- package/dist/durable-BPHVFVvV.js.map +1 -0
- package/dist/{durable-DlScwmCy.d.ts → durable-DeLCAvbw.d.ts} +1256 -104
- package/dist/envelope-DkZyMIgp.d.ts +191 -0
- package/dist/envelope-DxQzo5rN.js +82 -0
- package/dist/envelope-DxQzo5rN.js.map +1 -0
- package/dist/{keep-alive-DYDsH6qN.d.ts → event-factory-KaeDSfeP.d.ts} +11 -31
- package/dist/{keep-alive-p8dIcSVy.js → event-factory-QuC_UvyP.js} +8 -10
- package/dist/event-factory-QuC_UvyP.js.map +1 -0
- package/dist/{events-Bb9-Cu-7.d.ts → events-LZFNoESe.d.ts} +2 -188
- package/dist/{id-generator-C2Q15uZM.d.ts → id-generator--x6itQZ2.d.ts} +3 -2
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/keep-alive-Chl5SJxy.d.ts +29 -0
- package/dist/{message-transcript-BCHdHAe2.d.ts → message-transcript-6PEzaEGn.d.ts} +4 -4
- package/dist/model-resolver-BPPJAsuh.d.ts +18 -0
- package/dist/model-usage-CdBEkTwU.d.ts +55 -0
- package/dist/{prompt-projector-9_02lk5-.d.ts → prompt-projector-CNhqUsEr.d.ts} +15 -16
- package/dist/{reduced-state-C4nVVzz9.js → reduced-state-Bz68V2H8.js} +65 -32
- package/dist/reduced-state-Bz68V2H8.js.map +1 -0
- package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-CCSzc4h8.d.ts} +16 -6
- package/dist/run-scheduler-DcS_okUH.d.ts +43 -0
- package/dist/run-scheduling-wakeup-CeHrvXie.d.ts +25 -0
- package/dist/{runtime-C56FQxiL.d.ts → runtime-WL_gKqxn.d.ts} +16 -7
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -425
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/id-generator.js +2 -1
- package/dist/services/id-generator.js.map +1 -1
- package/dist/services/keep-alive.d.ts +2 -0
- package/dist/services/keep-alive.js +13 -0
- package/dist/services/keep-alive.js.map +1 -0
- package/dist/services/model-resolver.d.ts +2 -0
- package/dist/services/model-resolver.js +17 -0
- package/dist/services/model-resolver.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +2 -2
- package/dist/services/prompt-projector.js +20 -10
- package/dist/services/prompt-projector.js.map +1 -1
- package/dist/services/reducer-registry.d.ts +2 -2
- package/dist/services/reducer-registry.js +7 -3
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/run-scheduler.d.ts +3 -0
- package/dist/services/run-scheduler.js +25 -0
- package/dist/services/run-scheduler.js.map +1 -0
- package/dist/services/run-scheduling-wakeup.d.ts +2 -0
- package/dist/services/run-scheduling-wakeup.js +13 -0
- package/dist/services/run-scheduling-wakeup.js.map +1 -0
- package/dist/services/runtime-layer.d.ts +67 -0
- package/dist/services/runtime-layer.js +47 -0
- package/dist/services/runtime-layer.js.map +1 -0
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +21 -14
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +2 -0
- package/dist/services/session-event-observer.js +13 -0
- package/dist/services/session-event-observer.js.map +1 -0
- package/dist/services/session-query.d.ts +2 -2
- package/dist/services/session-query.js +140 -1
- package/dist/services/session-query.js.map +1 -0
- package/dist/services/session-state.d.ts +2 -0
- package/dist/services/session-state.js +2 -0
- package/dist/services/session-store.d.ts +2 -2
- package/dist/services/session-store.js +182 -2
- package/dist/services/session-store.js.map +1 -0
- package/dist/services/sink-checkpoint-store.d.ts +2 -0
- package/dist/services/sink-checkpoint-store.js +49 -0
- package/dist/services/sink-checkpoint-store.js.map +1 -0
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/span-names.d.ts +1 -1
- package/dist/services/span-names.js +3 -0
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tracing.d.ts +1 -1
- package/dist/services/tracing.js +23 -2
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-event-observer-DaFMKKNc.d.ts +24 -0
- package/dist/session-query-DfW_4KC0.d.ts +47 -0
- package/dist/{session-query-DOc1KanA.js → session-state-BIZ2SYaP.js} +350 -183
- package/dist/session-state-BIZ2SYaP.js.map +1 -0
- package/dist/{session-query-DlRo5Ufc.d.ts → session-state-BeR2rZRR.d.ts} +144 -46
- package/dist/{session-store-D2Ore1QC.d.ts → session-store-J_Un45kW.d.ts} +7 -96
- package/dist/sink-checkpoint-store-C9hUxfH0.d.ts +40 -0
- package/dist/{sink-registry-CFC6xjsN.js → sink-registry-Bbqhtdnx.js} +27 -67
- package/dist/sink-registry-Bbqhtdnx.js.map +1 -0
- package/dist/{sink-registry-CIU0LD3m.d.ts → sink-registry-DuDkNXjZ.d.ts} +24 -49
- package/dist/testkit/layers.d.ts +24 -14
- package/dist/testkit/layers.js +18 -11
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-BDmJe_Wr.d.ts} +4 -4
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/commands.js +7 -2
- package/dist/types/commands.js.map +1 -1
- package/dist/types/core.d.ts +2 -2
- package/dist/types/core.js +4 -2
- package/dist/types/core.js.map +1 -1
- package/dist/types/events/durable.d.ts +2 -2
- package/dist/types/events/durable.js +2 -2
- package/dist/types/events.d.ts +4 -3
- package/dist/types/events.js +3 -2
- package/dist/types/events.js.map +1 -1
- package/dist/websocket.d.ts +2776 -0
- package/dist/websocket.js +498 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +68 -43
- package/testing/offline-trace/README.md +2 -1
- package/CHANGELOG.md +0 -10
- package/CONTRIBUTING.md +0 -26
- package/SECURITY.md +0 -8
- package/dist/durable-C3Rz7kg3.js.map +0 -1
- package/dist/durable-object-runtime-B7jwBY2R.js +0 -1494
- package/dist/durable-object-runtime-B7jwBY2R.js.map +0 -1
- package/dist/durable-object-runtime-pWv0ohlz.d.ts +0 -257
- package/dist/durable-object-storage-Czy7IPrh.d.ts +0 -41
- package/dist/host/durable-object-runtime.d.ts +0 -2
- package/dist/host/durable-object-runtime.js +0 -2
- package/dist/host/durable-object-storage.d.ts +0 -2
- package/dist/host/durable-object-storage.js +0 -0
- package/dist/host/durable-object.d.ts +0 -83
- package/dist/host/durable-object.js +0 -191
- package/dist/host/durable-object.js.map +0 -1
- package/dist/host/websocket-wire.d.ts +0 -2
- package/dist/host/websocket-wire.js +0 -88
- package/dist/host/websocket-wire.js.map +0 -1
- package/dist/keep-alive-p8dIcSVy.js.map +0 -1
- package/dist/reduced-state-C4nVVzz9.js.map +0 -1
- package/dist/services/compaction.js.map +0 -1
- package/dist/session-query-DOc1KanA.js.map +0 -1
- package/dist/session-store-pYxQW9qh.js +0 -214
- package/dist/session-store-pYxQW9qh.js.map +0 -1
- package/dist/sink-registry-CFC6xjsN.js.map +0 -1
- package/dist/websocket-wire-DvOu_6BJ.d.ts +0 -16773
- package/docs/assets/architecture.svg +0 -106
- package/docs/assets/event-sequence.svg +0 -143
- package/docs/assets/gcp-trace.png +0 -0
- package/docs/message-steering.md +0 -831
- package/docs/releasing.md +0 -57
- package/docs/spec.md +0 -774
- package/docs/subagents.md +0 -725
- package/docs/testing.md +0 -64
- package/docs/ui-projection.md +0 -742
- package/docs/websocket-protocol.md +0 -613
- package/examples/001-no-tools/README.md +0 -65
- package/examples/001-no-tools/worker.ts +0 -79
- package/examples/002-slack-bridge/README.md +0 -134
- package/examples/002-slack-bridge/events.ts +0 -115
- package/examples/002-slack-bridge/reducer.ts +0 -216
- package/examples/002-slack-bridge/scenario.test.ts +0 -223
- package/examples/002-slack-bridge/sinks.ts +0 -109
- package/examples/002-slack-bridge/worker.ts +0 -140
- package/examples/003-sandbox-lifecycle/README.md +0 -78
- package/examples/003-sandbox-lifecycle/events.ts +0 -203
- package/examples/003-sandbox-lifecycle/reducer.ts +0 -305
- package/examples/003-sandbox-lifecycle/scenario.test.ts +0 -202
- package/examples/_shared/event-id.ts +0 -12
- package/examples/_shared/http.ts +0 -27
- package/examples/_shared/openai.ts +0 -33
package/docs/message-steering.md
DELETED
|
@@ -1,831 +0,0 @@
|
|
|
1
|
-
# effect-durable-agent message steering
|
|
2
|
-
|
|
3
|
-
Status: implemented
|
|
4
|
-
Runtime: `EDAGiaAgent`
|
|
5
|
-
Last reviewed: 2026-07-10
|
|
6
|
-
|
|
7
|
-
This document specifies durable pending user messages, queue and steer
|
|
8
|
-
dispositions, cancellation, promotion, and queue pausing for
|
|
9
|
-
`effect-durable-agent` (EDA). It also defines the Gia browser and Slack
|
|
10
|
-
integration contracts built on those framework semantics.
|
|
11
|
-
|
|
12
|
-
The implementation exposes one durable pending-message entity from admission
|
|
13
|
-
through consumption, cancellation, or promotion. It batches eligible steers at
|
|
14
|
-
turn boundaries, preserves them across unexpected failures, and pauses queued
|
|
15
|
-
work after an explicit stop or interrupt.
|
|
16
|
-
|
|
17
|
-
## 1. One-page decision summary
|
|
18
|
-
|
|
19
|
-
- Every submitted user message has an explicit `queue` or `steer` disposition.
|
|
20
|
-
- EDA mints a durable `messageId` when it admits the submission.
|
|
21
|
-
- The message becomes visible immediately after durable admission, before it
|
|
22
|
-
enters model context.
|
|
23
|
-
- `queue` starts a run when the session is idle and otherwise waits for a later
|
|
24
|
-
run.
|
|
25
|
-
- `steer` joins the active run at its next turn boundary. If no run is active,
|
|
26
|
-
it starts a new run.
|
|
27
|
-
- All steers pending at one turn boundary are consumed together in FIFO order.
|
|
28
|
-
- Pending queue and steer messages can be cancelled. Queue messages can be
|
|
29
|
-
promoted to steer without changing message identity.
|
|
30
|
-
- A pending steer can explicitly interrupt the active run and start immediately
|
|
31
|
-
through an atomic Stop-plus-Resume control action.
|
|
32
|
-
- Editing is cancel-then-compose. The composer is populated only after the
|
|
33
|
-
durable cancellation succeeds.
|
|
34
|
-
- An explicit Stop terminalizes the run and pauses all remaining queued work.
|
|
35
|
-
Unconsumed steers become paused queue messages rather than disappearing.
|
|
36
|
-
- A promoted paused message starts or steers a run; other paused messages stay
|
|
37
|
-
paused.
|
|
38
|
-
- Clearing a paused queue and sending a replacement is one conditional atomic
|
|
39
|
-
command.
|
|
40
|
-
- Browser mutations use authenticated HTTP. The existing WebSocket remains the
|
|
41
|
-
durable and ephemeral observation channel.
|
|
42
|
-
- Slack submits one steer command per inbound Slack message. Slack does not
|
|
43
|
-
expose queue behavior.
|
|
44
|
-
|
|
45
|
-
## 2. Goals
|
|
46
|
-
|
|
47
|
-
1. Preserve user intent across client/server state races.
|
|
48
|
-
2. Never silently discard an admitted user message because a run ended,
|
|
49
|
-
failed, or changed state unexpectedly.
|
|
50
|
-
3. Give every pending message a stable durable identity and renderable state.
|
|
51
|
-
4. Make cancellation, promotion, consumption, and pause behavior deterministic
|
|
52
|
-
under concurrent ingress.
|
|
53
|
-
5. Keep scheduling semantics in EDA core and product presentation in Gia.
|
|
54
|
-
6. Preserve exact message authorship and attachments across every lifecycle
|
|
55
|
-
transition.
|
|
56
|
-
7. Use one transport-neutral state machine for browser and Slack ingress.
|
|
57
|
-
|
|
58
|
-
## 3. Non-goals
|
|
59
|
-
|
|
60
|
-
- Injecting content into an in-flight model request. Steering waits for a turn
|
|
61
|
-
boundary.
|
|
62
|
-
- Promoting a message to interrupt. Interrupt remains a separate run-level
|
|
63
|
-
affordance.
|
|
64
|
-
- Supporting browser writes from adjacent users. Gia web writes remain
|
|
65
|
-
owner-only; adjacent users are read-only.
|
|
66
|
-
- Sending browser mutations over the live-event WebSocket.
|
|
67
|
-
- Restoring a cancelled edit automatically when a local composer draft is
|
|
68
|
-
discarded.
|
|
69
|
-
- Deleting workspace files when a message referencing them is cancelled.
|
|
70
|
-
- Defining final visual styling. The view model owns presentation details.
|
|
71
|
-
|
|
72
|
-
## 4. Terms
|
|
73
|
-
|
|
74
|
-
**Pending message**
|
|
75
|
-
: A durably admitted user message that has not been consumed by a `TurnStarted`
|
|
76
|
-
boundary or cancelled.
|
|
77
|
-
|
|
78
|
-
**Queue message**
|
|
79
|
-
: A pending message intended to start separate work after active work no longer
|
|
80
|
-
blocks it.
|
|
81
|
-
|
|
82
|
-
**Steer message**
|
|
83
|
-
: A pending message eligible to join an active run at its next turn boundary.
|
|
84
|
-
In an idle session it starts a new run.
|
|
85
|
-
|
|
86
|
-
**Consumed message**
|
|
87
|
-
: A user message referenced by `TurnStarted.inputMessageIds`. Consumption is
|
|
88
|
-
the boundary after which cancellation and promotion cannot succeed.
|
|
89
|
-
|
|
90
|
-
**Queue paused**
|
|
91
|
-
: A durable scheduling gate created by explicit user interruption. It holds a
|
|
92
|
-
specific set of queue messages until each is cancelled, cleared, or promoted.
|
|
93
|
-
|
|
94
|
-
**Requested disposition**
|
|
95
|
-
: The immutable disposition on the original submission command.
|
|
96
|
-
|
|
97
|
-
**Current disposition**
|
|
98
|
-
: The reducer-derived disposition after any promotion. Scheduling uses this
|
|
99
|
-
value.
|
|
100
|
-
|
|
101
|
-
## 5. Non-negotiable invariants
|
|
102
|
-
|
|
103
|
-
1. Durable events are the source of truth. Reducers derive all current state.
|
|
104
|
-
2. EDA is the sole minter of `commandId`, `messageId`, `runId`, and `turnId`.
|
|
105
|
-
3. One logical user message keeps one `messageId` through promotion,
|
|
106
|
-
cancellation, pause, and consumption.
|
|
107
|
-
4. A message is consumed at most once.
|
|
108
|
-
5. A cancelled message is never consumed.
|
|
109
|
-
6. A consumed message cannot be cancelled or promoted.
|
|
110
|
-
7. Promotion changes only a pending queue message into a pending steer message.
|
|
111
|
-
8. A queue pause blocks only its remaining member messages. It does not become
|
|
112
|
-
an invisible permanent session latch.
|
|
113
|
-
9. Scheduling and conditional message transitions execute inside the serialized
|
|
114
|
-
`SessionState` boundary.
|
|
115
|
-
10. HTTP success means durable command admission or a terminal conditional
|
|
116
|
-
outcome; model completion remains observable through events.
|
|
117
|
-
11. A client-generated idempotency key is reused across ambiguous HTTP retries.
|
|
118
|
-
12. Gia metadata remains app-owned and joins framework state through
|
|
119
|
-
`relatedCommandIdempotencyKey`.
|
|
120
|
-
|
|
121
|
-
## 6. State model
|
|
122
|
-
|
|
123
|
-
### 6.1 Pending message record
|
|
124
|
-
|
|
125
|
-
EDA reducer state gains a first-class message record at command admission:
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
interface PendingUserMessage {
|
|
129
|
-
readonly messageId: MessageId;
|
|
130
|
-
readonly originCommandId: CommandId;
|
|
131
|
-
readonly content: UserMessageContent;
|
|
132
|
-
readonly requestedDisposition: "queue" | "steer";
|
|
133
|
-
readonly disposition: "queue" | "steer";
|
|
134
|
-
readonly submittedSeq: SequenceNumber;
|
|
135
|
-
readonly submittedAtMs: UnixEpochMillis;
|
|
136
|
-
readonly promotedSeq?: SequenceNumber;
|
|
137
|
-
readonly pausedByCommandId?: CommandId;
|
|
138
|
-
readonly consumedSeq?: SequenceNumber;
|
|
139
|
-
readonly consumedTurnId?: TurnId;
|
|
140
|
-
readonly cancelledSeq?: SequenceNumber;
|
|
141
|
-
readonly cancelledByCommandId?: CommandId;
|
|
142
|
-
readonly cancellationReason?: PendingMessageCancellationReason;
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
The type name is illustrative. The implementation may keep one union for
|
|
147
|
-
pending, consumed, and cancelled records so impossible field combinations are
|
|
148
|
-
not representable.
|
|
149
|
-
|
|
150
|
-
Message content must be persisted at admission in framework-owned message
|
|
151
|
-
storage. It must not remain available only through the originating command
|
|
152
|
-
input because the message becomes the stable lifecycle entity.
|
|
153
|
-
|
|
154
|
-
### 6.2 Derived collections
|
|
155
|
-
|
|
156
|
-
The framework reducer derives:
|
|
157
|
-
|
|
158
|
-
- `pendingQueue`: non-paused queue messages in submission order;
|
|
159
|
-
- `pendingSteers`: steer messages in effective-steer order;
|
|
160
|
-
- `pausedQueue`: queue messages held by the active pause marker;
|
|
161
|
-
- `consumedMessages`: context-visible user messages;
|
|
162
|
-
- `cancelledMessages`: durable audit state excluded from the normal transcript.
|
|
163
|
-
|
|
164
|
-
Reducers never mutate these collections directly. They fold durable facts and
|
|
165
|
-
derive the collections from message records.
|
|
166
|
-
|
|
167
|
-
### 6.3 Ordering
|
|
168
|
-
|
|
169
|
-
- Queue FIFO uses `submittedSeq`.
|
|
170
|
-
- A promotion leaves the normal queue and enters the steer sequence at
|
|
171
|
-
`promotedSeq`.
|
|
172
|
-
- Native steers use `submittedSeq` as their effective-steer sequence.
|
|
173
|
-
- At a turn boundary, eligible steers are ordered by effective-steer sequence.
|
|
174
|
-
- Promoting queue item `C` does not reorder remaining queue items `A` and `B`.
|
|
175
|
-
|
|
176
|
-
## 7. Commands
|
|
177
|
-
|
|
178
|
-
### 7.1 `SubmitMessage`
|
|
179
|
-
|
|
180
|
-
The browser-facing dispositions are narrowed to `queue | steer`. Interrupt is
|
|
181
|
-
not a message disposition in the Gia composer.
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
interface SubmitMessageCommand {
|
|
185
|
-
readonly _tag: "SubmitMessage";
|
|
186
|
-
readonly commandId?: CommandId;
|
|
187
|
-
readonly idempotencyKey?: CommandIdempotencyKey;
|
|
188
|
-
readonly disposition: "queue" | "steer";
|
|
189
|
-
readonly content: UserMessageContent;
|
|
190
|
-
readonly expectedPausedMessageIdsToCancel?: ReadonlyArray<MessageId>;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
`expectedPausedMessageIdsToCancel` is absent for an ordinary submission. When present, it
|
|
195
|
-
is the exact paused-queue set approved by the user in the confirmation modal.
|
|
196
|
-
EDA atomically verifies the set, cancels those messages, and admits the new
|
|
197
|
-
message. A mismatch returns a typed conflict and changes nothing.
|
|
198
|
-
|
|
199
|
-
### 7.2 `CancelPendingMessage`
|
|
200
|
-
|
|
201
|
-
```ts
|
|
202
|
-
interface CancelPendingMessageCommand {
|
|
203
|
-
readonly _tag: "CancelPendingMessage";
|
|
204
|
-
readonly commandId?: CommandId;
|
|
205
|
-
readonly idempotencyKey?: CommandIdempotencyKey;
|
|
206
|
-
readonly messageId: MessageId;
|
|
207
|
-
readonly reason: "edit" | "user-cancel";
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Cancellation is a priority control command. It succeeds only while the target
|
|
212
|
-
is pending. If consumption wins the serialized race, cancellation returns a
|
|
213
|
-
typed `message_not_pending` outcome and emits no cancellation fact.
|
|
214
|
-
|
|
215
|
-
### 7.3 `PromotePendingMessage`
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
interface PromotePendingMessageCommand {
|
|
219
|
-
readonly _tag: "PromotePendingMessage";
|
|
220
|
-
readonly commandId?: CommandId;
|
|
221
|
-
readonly idempotencyKey?: CommandIdempotencyKey;
|
|
222
|
-
readonly messageId: MessageId;
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
Promotion is a priority control command. It succeeds only for a pending queue
|
|
227
|
-
message and transitions that same message to steer. It never creates a new
|
|
228
|
-
message and cannot target a consumed, cancelled, or already-steering message.
|
|
229
|
-
|
|
230
|
-
If no run is active when promotion is applied, the promoted steer starts a new
|
|
231
|
-
run. If a run is active, it joins that run at the next boundary.
|
|
232
|
-
|
|
233
|
-
### 7.4 `StopTurn`
|
|
234
|
-
|
|
235
|
-
`StopTurn` remains a separate run-level control command. In addition to its
|
|
236
|
-
current run and turn terminalization, explicit user stop creates a queue pause
|
|
237
|
-
covering:
|
|
238
|
-
|
|
239
|
-
- queue messages already waiting behind the active run; and
|
|
240
|
-
- steers not consumed by the stopped run.
|
|
241
|
-
|
|
242
|
-
Those steers transition to queue disposition and remain durable. They do not
|
|
243
|
-
enter model context and do not disappear.
|
|
244
|
-
|
|
245
|
-
### 7.5 Command priority
|
|
246
|
-
|
|
247
|
-
The external event loop inevitably orders incoming requests. Once admitted,
|
|
248
|
-
control dispatch priority is:
|
|
249
|
-
|
|
250
|
-
1. stop;
|
|
251
|
-
2. cancel and conditional clear;
|
|
252
|
-
3. promotion;
|
|
253
|
-
4. steer consumption at a boundary;
|
|
254
|
-
5. ordinary queue dispatch.
|
|
255
|
-
|
|
256
|
-
The exact ordering between control commands is the order of durable admission
|
|
257
|
-
when two commands of equal priority target the same message. First valid state
|
|
258
|
-
transition wins; later incompatible commands receive a typed conflict.
|
|
259
|
-
|
|
260
|
-
### 7.6 Interrupt with a pending steer
|
|
261
|
-
|
|
262
|
-
Interrupt remains a separate affordance rather than a steer promotion. Gia
|
|
263
|
-
atomically admits a `StopTurn` command followed by a `ResumePendingMessages`
|
|
264
|
-
command targeting the selected pending steer. Existing interruption semantics
|
|
265
|
-
pause all pending work; the resume command immediately starts only the selected
|
|
266
|
-
message. Other paused messages remain held.
|
|
267
|
-
|
|
268
|
-
## 8. Durable events
|
|
269
|
-
|
|
270
|
-
Names below are normative unless implementation review finds an established EDA
|
|
271
|
-
naming convention that is clearer.
|
|
272
|
-
|
|
273
|
-
### 8.1 `UserMessageSubmitted`
|
|
274
|
-
|
|
275
|
-
Committed atomically with command admission and contains:
|
|
276
|
-
|
|
277
|
-
```ts
|
|
278
|
-
{
|
|
279
|
-
commandId: CommandId;
|
|
280
|
-
messageId: MessageId;
|
|
281
|
-
disposition: "queue" | "steer";
|
|
282
|
-
content: UserMessageContent;
|
|
283
|
-
}
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
This is the durable visibility boundary. The UI can render the message after
|
|
287
|
-
this event even though it is not yet model context.
|
|
288
|
-
|
|
289
|
-
### 8.2 `UserMessagePromoted`
|
|
290
|
-
|
|
291
|
-
```ts
|
|
292
|
-
{
|
|
293
|
-
commandId: CommandId;
|
|
294
|
-
messageId: MessageId;
|
|
295
|
-
from: "queue";
|
|
296
|
-
to: "steer";
|
|
297
|
-
}
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### 8.3 `UserMessageCancelled`
|
|
301
|
-
|
|
302
|
-
```ts
|
|
303
|
-
{
|
|
304
|
-
commandId: CommandId;
|
|
305
|
-
messageId: MessageId;
|
|
306
|
-
reason: "edit" | "user-cancel" | "clear-paused-queue";
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
Cancelled records remain in reducer state and the event log but are filtered
|
|
311
|
-
from the normal transcript projection.
|
|
312
|
-
|
|
313
|
-
### 8.4 `PendingMessagesPaused`
|
|
314
|
-
|
|
315
|
-
```ts
|
|
316
|
-
{
|
|
317
|
-
interruptionCommandId: CommandId;
|
|
318
|
-
runId: RunId;
|
|
319
|
-
messageIds: readonly [MessageId, ...MessageId[]];
|
|
320
|
-
reason: "user-interrupted";
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
The event captures the exact held set. Cancellation and promotion remove
|
|
325
|
-
members through their own events. Queue-paused state clears automatically when
|
|
326
|
-
no members remain; a separate clear event is unnecessary unless required for
|
|
327
|
-
observability.
|
|
328
|
-
|
|
329
|
-
### 8.5 Consumption
|
|
330
|
-
|
|
331
|
-
`TurnStarted.inputMessageIds` remains the authoritative consumption fact. A
|
|
332
|
-
new turn may reference multiple pending steer message IDs. Folding
|
|
333
|
-
`TurnStarted` marks all referenced messages consumed at the same sequence and
|
|
334
|
-
turn.
|
|
335
|
-
|
|
336
|
-
Legacy `UserMessageCommitted` and `SteeringMessageQueued` facts remain
|
|
337
|
-
replayable. The reducer projects legacy and current records into one pending
|
|
338
|
-
message view without inventing migration events or rewriting historical facts.
|
|
339
|
-
There must be one user message in UI projection, not a second record created at
|
|
340
|
-
consumption.
|
|
341
|
-
|
|
342
|
-
## 9. Dispatch semantics
|
|
343
|
-
|
|
344
|
-
### 9.1 Truth table
|
|
345
|
-
|
|
346
|
-
| Input | No active run | Active turn | Completed turn boundary | Queue paused |
|
|
347
|
-
|---|---|---|---|---|
|
|
348
|
-
| Submit queue | Start new run | Wait in queue | Wait until run terminalizes | Conflict |
|
|
349
|
-
| Submit steer | Start new run | Wait as steer | Join next continuation | Start new run; held messages stay paused |
|
|
350
|
-
| Promote queue | Start new run | Wait as steer | Join next continuation | Release selected message and start/steer |
|
|
351
|
-
| Cancel pending | Cancel | Cancel if boundary has not consumed it | First serialized transition wins | Cancel selected message |
|
|
352
|
-
|
|
353
|
-
The server evaluates this table against authoritative reducer state. It does
|
|
354
|
-
not validate a browser claim that a run was or was not active when the user
|
|
355
|
-
clicked Send.
|
|
356
|
-
|
|
357
|
-
### 9.2 Active turn steering
|
|
358
|
-
|
|
359
|
-
Steering does not interrupt inference, tool execution, or the run. The current
|
|
360
|
-
turn completes normally. At the next continuation decision, EDA snapshots all
|
|
361
|
-
eligible steers already admitted and starts one continuation turn whose
|
|
362
|
-
`inputMessageIds` contains that ordered batch.
|
|
363
|
-
|
|
364
|
-
Steers admitted after `TurnStarted` commits wait for the following turn
|
|
365
|
-
boundary. The durable sequence establishes the cutoff; wall-clock arrival time
|
|
366
|
-
does not.
|
|
367
|
-
|
|
368
|
-
### 9.3 Normal run completion
|
|
369
|
-
|
|
370
|
-
At a completed turn boundary:
|
|
371
|
-
|
|
372
|
-
1. apply higher-priority stop/cancel/promotion commands;
|
|
373
|
-
2. snapshot all eligible pending steers;
|
|
374
|
-
3. if the snapshot is non-empty, start one continuation turn in the same run;
|
|
375
|
-
4. otherwise terminalize the run and active command;
|
|
376
|
-
5. if the queue is not paused, start the next queue message as a new run.
|
|
377
|
-
|
|
378
|
-
### 9.4 Unexpected run failure
|
|
379
|
-
|
|
380
|
-
Unconsumed steers survive an unexpected run failure. After the failed run
|
|
381
|
-
terminalizes, they remain eligible work and start a new run. They are not
|
|
382
|
-
cancelled merely because their original target run failed.
|
|
383
|
-
|
|
384
|
-
If multiple steers survive, the new run consumes the pending steer batch in
|
|
385
|
-
order as its initial input boundary.
|
|
386
|
-
|
|
387
|
-
### 9.5 Explicit stop
|
|
388
|
-
|
|
389
|
-
Explicit Stop differs from failure:
|
|
390
|
-
|
|
391
|
-
1. stop the current turn and terminalize the run under existing EDA rules;
|
|
392
|
-
2. transition unconsumed steers to queue;
|
|
393
|
-
3. collect those messages and all already-waiting queue messages;
|
|
394
|
-
4. commit `PendingMessagesPaused` for that exact set;
|
|
395
|
-
5. do not dispatch any held message automatically.
|
|
396
|
-
|
|
397
|
-
The UI can derive copy such as:
|
|
398
|
-
|
|
399
|
-
- `You stopped after 4s`
|
|
400
|
-
- `Queue paused because you interrupted`
|
|
401
|
-
|
|
402
|
-
The first is a run terminal presentation; the second is a queue state
|
|
403
|
-
presentation.
|
|
404
|
-
|
|
405
|
-
### 9.6 Selective release
|
|
406
|
-
|
|
407
|
-
Promoting one paused message releases only that message. Other pause members
|
|
408
|
-
remain held even while the promoted message runs. Users may promote additional
|
|
409
|
-
messages separately; promotions arriving during the new run become steers for
|
|
410
|
-
that run.
|
|
411
|
-
|
|
412
|
-
When the final paused member is promoted or cancelled, the pause is empty and
|
|
413
|
-
future ordinary queue submissions behave normally.
|
|
414
|
-
|
|
415
|
-
## 10. Cancellation and editing UX
|
|
416
|
-
|
|
417
|
-
### 10.1 Cancel
|
|
418
|
-
|
|
419
|
-
Queue and steer messages expose cancellation while pending. The UI sends an
|
|
420
|
-
HTTP cancellation command and shows the action as pending. It removes the
|
|
421
|
-
message only after the durable cancellation outcome arrives through the HTTP
|
|
422
|
-
response or event stream.
|
|
423
|
-
|
|
424
|
-
### 10.2 Edit
|
|
425
|
-
|
|
426
|
-
Edit uses cancellation reason `edit`:
|
|
427
|
-
|
|
428
|
-
1. user clicks Edit;
|
|
429
|
-
2. UI sends `CancelPendingMessage`;
|
|
430
|
-
3. server conditionally cancels the pending message;
|
|
431
|
-
4. after success, UI removes it through reducer projection and places its text
|
|
432
|
-
and attachment references into the composer;
|
|
433
|
-
5. composer local storage owns the draft from that point;
|
|
434
|
-
6. resubmission creates a new message identity.
|
|
435
|
-
|
|
436
|
-
If consumption wins the race, the edit fails, the message stays in the
|
|
437
|
-
transcript, and the composer is not populated. That message is already part of
|
|
438
|
-
the running turn context.
|
|
439
|
-
|
|
440
|
-
Discarding an edited local draft does not restore the cancelled message.
|
|
441
|
-
|
|
442
|
-
### 10.3 Attachments
|
|
443
|
-
|
|
444
|
-
Edit restores attachment references along with text. Existing uploaded files
|
|
445
|
-
are reused. Cancellation changes message lifecycle only and never deletes
|
|
446
|
-
workspace files.
|
|
447
|
-
|
|
448
|
-
## 11. Promotion UX
|
|
449
|
-
|
|
450
|
-
Only pending queue messages expose Promote. Promotion:
|
|
451
|
-
|
|
452
|
-
- keeps the same message identity, author, content, and attachments;
|
|
453
|
-
- updates the reducer-derived disposition to steer;
|
|
454
|
-
- starts a run if idle or joins the next active-run boundary;
|
|
455
|
-
- never offers an interrupt transition.
|
|
456
|
-
|
|
457
|
-
The UI waits for the durable promotion result before presenting the message as
|
|
458
|
-
steering. Concurrent cancel/promote operations use first-transition-wins
|
|
459
|
-
semantics and return typed conflicts to the loser.
|
|
460
|
-
|
|
461
|
-
## 12. Paused queue confirmation
|
|
462
|
-
|
|
463
|
-
An ordinary queue submission while paused returns `queue_paused` and includes
|
|
464
|
-
the current held message IDs. The UI should normally detect the projected pause
|
|
465
|
-
before sending and show a confirmation modal.
|
|
466
|
-
|
|
467
|
-
On confirmation, it retries submission with `expectedPausedMessageIdsToCancel` equal to
|
|
468
|
-
the exact IDs shown. EDA atomically:
|
|
469
|
-
|
|
470
|
-
1. verifies that the current paused set exactly matches the approved set;
|
|
471
|
-
2. emits cancellation facts with reason `clear-paused-queue`;
|
|
472
|
-
3. admits the replacement message;
|
|
473
|
-
4. begins normal dispatch.
|
|
474
|
-
|
|
475
|
-
If another client or ingress changes the paused set before application, the
|
|
476
|
-
operation conflicts and changes nothing. The UI refreshes the modal rather than
|
|
477
|
-
deleting unseen work.
|
|
478
|
-
|
|
479
|
-
## 13. HTTP API
|
|
480
|
-
|
|
481
|
-
### 13.1 Transport decision
|
|
482
|
-
|
|
483
|
-
Browser mutations use regular authenticated HTTP. The WebSocket remains
|
|
484
|
-
server-to-client except for its existing flow-control ACK frames.
|
|
485
|
-
|
|
486
|
-
This preserves the current route authentication, authorization, validation,
|
|
487
|
-
attachment handling, status codes, and Durable Object submission path. HTTP/2
|
|
488
|
-
or HTTP/3 connection reuse may reduce transport overhead, but correctness does
|
|
489
|
-
not depend on a particular negotiated protocol.
|
|
490
|
-
|
|
491
|
-
### 13.2 Endpoints
|
|
492
|
-
|
|
493
|
-
The exact route layout should follow existing React Router conventions. The
|
|
494
|
-
required operations are:
|
|
495
|
-
|
|
496
|
-
```text
|
|
497
|
-
POST /api/eda-agent/sessions/:sessionId/messages
|
|
498
|
-
POST /api/eda-agent/sessions/:sessionId/stop
|
|
499
|
-
POST /api/eda-agent/sessions/:sessionId/messages/:messageId/cancel
|
|
500
|
-
POST /api/eda-agent/sessions/:sessionId/messages/:messageId/promote
|
|
501
|
-
POST /api/eda-agent/sessions/:sessionId/messages/:messageId/interrupt
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
Submission accepts:
|
|
505
|
-
|
|
506
|
-
```ts
|
|
507
|
-
{
|
|
508
|
-
text: string;
|
|
509
|
-
attachments?: WorkspaceAttachmentRef[];
|
|
510
|
-
disposition: "queue" | "steer";
|
|
511
|
-
idempotencyKey: string;
|
|
512
|
-
expectedPausedMessageIdsToCancel?: string[];
|
|
513
|
-
}
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
Disposition and idempotency key are required for the new client. During rollout
|
|
517
|
-
the server may temporarily default missing disposition to queue for older
|
|
518
|
-
deployed clients, with telemetry and a defined deletion point.
|
|
519
|
-
|
|
520
|
-
### 13.3 Outcomes
|
|
521
|
-
|
|
522
|
-
HTTP responses distinguish:
|
|
523
|
-
|
|
524
|
-
- durable success with `commandId`, `messageId`, and admitted sequence;
|
|
525
|
-
- idempotent replay of an earlier success;
|
|
526
|
-
- `queue_paused` with current held IDs;
|
|
527
|
-
- `message_not_pending`;
|
|
528
|
-
- `message_not_queue` for invalid promotion;
|
|
529
|
-
- `paused_queue_changed` for a stale clear precondition;
|
|
530
|
-
- authorization and validation failures.
|
|
531
|
-
|
|
532
|
-
Events can arrive over the WebSocket before the HTTP response. The browser must
|
|
533
|
-
apply both idempotently and correlate optimistic/pending submission state using
|
|
534
|
-
the client-generated command idempotency key.
|
|
535
|
-
|
|
536
|
-
### 13.4 Retry
|
|
537
|
-
|
|
538
|
-
The browser stores an in-flight mutation until it receives a terminal HTTP
|
|
539
|
-
outcome. After an ambiguous network failure it may retry the same request with
|
|
540
|
-
the same idempotency key. It must not retry the same mutation through a second
|
|
541
|
-
transport.
|
|
542
|
-
|
|
543
|
-
## 14. WebSocket projection
|
|
544
|
-
|
|
545
|
-
No new client command frame is added to
|
|
546
|
-
`docs/websocket-protocol.md`. The existing stream delivers the new
|
|
547
|
-
durable lifecycle events and ephemeral active-turn events.
|
|
548
|
-
|
|
549
|
-
The browser reducer must render, without a fresh snapshot:
|
|
550
|
-
|
|
551
|
-
- newly submitted queue and steer messages;
|
|
552
|
-
- promotion from queue to steer;
|
|
553
|
-
- successful cancellation removal;
|
|
554
|
-
- batched consumption at `TurnStarted`;
|
|
555
|
-
- queue pause membership and selective release;
|
|
556
|
-
- run failure fallback;
|
|
557
|
-
- exact command terminal/conflict outcomes where exposed durably.
|
|
558
|
-
|
|
559
|
-
Reconnect resumes by durable sequence exactly as it does today. Pending message
|
|
560
|
-
state must reconstruct entirely from the snapshot and replay tail.
|
|
561
|
-
|
|
562
|
-
## 15. UI projection
|
|
563
|
-
|
|
564
|
-
### 15.1 Visible message states
|
|
565
|
-
|
|
566
|
-
The normal transcript projection includes:
|
|
567
|
-
|
|
568
|
-
- pending queue messages;
|
|
569
|
-
- pending steer messages;
|
|
570
|
-
- consumed user messages.
|
|
571
|
-
|
|
572
|
-
It excludes cancelled messages even though reducer state retains them.
|
|
573
|
-
|
|
574
|
-
The view model may choose final labels and affordances, but it must receive
|
|
575
|
-
enough state to distinguish queue, steer, paused queue, action pending, and
|
|
576
|
-
consumed. Rendering differences between message author and action actor are a
|
|
577
|
-
view-model concern.
|
|
578
|
-
|
|
579
|
-
### 15.2 Composer
|
|
580
|
-
|
|
581
|
-
- The composer always sends an explicit queue or steer disposition.
|
|
582
|
-
- Projected run state may choose the default but never rewrites a frozen
|
|
583
|
-
submission during retry.
|
|
584
|
-
- While a run is active, an empty composer renders Stop in place of Send and
|
|
585
|
-
submits `StopTurn`. Text or attachments keep the normal Send action.
|
|
586
|
-
- Pressing Enter in an empty composer does not stop the run; interruption
|
|
587
|
-
requires the explicit Stop button.
|
|
588
|
-
- Edit populates the composer only after cancellation success.
|
|
589
|
-
- Composer local storage persists edit drafts.
|
|
590
|
-
|
|
591
|
-
Pending queue overflow actions are Send now (steer), Edit, Copy, and Delete.
|
|
592
|
-
Pending steer overflow actions are Interrupt and send now, Edit, Copy, and
|
|
593
|
-
Delete. Edit cancels durably before restoring the message to the composer;
|
|
594
|
-
Delete uses the normal user-cancellation path.
|
|
595
|
-
|
|
596
|
-
### 15.3 Queue pause
|
|
597
|
-
|
|
598
|
-
The UI renders the interrupted run terminal separately from the paused queue.
|
|
599
|
-
Each paused message offers Cancel/Edit and Promote. A new ordinary send opens
|
|
600
|
-
the destructive confirmation flow described above.
|
|
601
|
-
|
|
602
|
-
## 16. Gia metadata and authorization
|
|
603
|
-
|
|
604
|
-
### 16.1 Correlation
|
|
605
|
-
|
|
606
|
-
Gia continues to atomically submit app facts alongside the framework command:
|
|
607
|
-
|
|
608
|
-
```text
|
|
609
|
-
GiaUserMessageAuthorCommitted(relatedCommandIdempotencyKey)
|
|
610
|
-
GiaFileAttachmentCreated(relatedCommandIdempotencyKey)
|
|
611
|
-
SubmitMessage(idempotencyKey)
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
EDA mints `commandId` and `messageId`. Reducers join:
|
|
615
|
-
|
|
616
|
-
```text
|
|
617
|
-
messageId
|
|
618
|
-
-> originCommandId
|
|
619
|
-
-> command idempotency key
|
|
620
|
-
-> Gia author and attachment facts
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
Promotion, cancellation, and consumption never copy metadata because the
|
|
624
|
-
message identity and origin command do not change.
|
|
625
|
-
|
|
626
|
-
### 16.2 Author and actor
|
|
627
|
-
|
|
628
|
-
Gia distinguishes:
|
|
629
|
-
|
|
630
|
-
- session owner;
|
|
631
|
-
- message author;
|
|
632
|
-
- actor responsible for cancel, promote, stop, or clear actions.
|
|
633
|
-
|
|
634
|
-
Control-action actor facts correlate through their command idempotency keys.
|
|
635
|
-
Queue pause derives its stopping actor from the Stop command. Gia may render
|
|
636
|
-
primarily the author because collaborative web writes are not supported.
|
|
637
|
-
|
|
638
|
-
### 16.3 Existing sessions
|
|
639
|
-
|
|
640
|
-
Hundreds of existing sessions require compatibility:
|
|
641
|
-
|
|
642
|
-
- exact idempotency-key author mapping is primary;
|
|
643
|
-
- new pending-message events must always resolve exact attribution;
|
|
644
|
-
- existing author span state and checkpoint decoding remain supported;
|
|
645
|
-
- span fallback is used only for historical messages without exact correlation;
|
|
646
|
-
- session owner remains the final fallback;
|
|
647
|
-
- fallback usage is instrumented before any future span removal;
|
|
648
|
-
- reducer schema versions are incremented when checkpoint state changes, causing
|
|
649
|
-
replay from durable events rather than event-log rewriting.
|
|
650
|
-
|
|
651
|
-
### 16.4 Authorization
|
|
652
|
-
|
|
653
|
-
Gia browser mutation routes remain owner-only. Adjacent users can read the
|
|
654
|
-
session and live events but cannot submit, cancel, promote, clear, or stop.
|
|
655
|
-
Slack-backed session ingress is authorized through the Slack transport path.
|
|
656
|
-
|
|
657
|
-
## 17. Slack integration
|
|
658
|
-
|
|
659
|
-
Slack submits exactly one steer command per inbound Slack message. It does not
|
|
660
|
-
batch multiple people or messages into one EDA user message and does not submit
|
|
661
|
-
queue messages.
|
|
662
|
-
|
|
663
|
-
For every inbound Slack message, one atomic batch contains:
|
|
664
|
-
|
|
665
|
-
1. first-session metadata and system prompt facts when required;
|
|
666
|
-
2. exact author metadata;
|
|
667
|
-
3. attachment facts;
|
|
668
|
-
4. one `SubmitMessage{disposition: "steer"}`;
|
|
669
|
-
5. one Slack receipt/correlation fact.
|
|
670
|
-
|
|
671
|
-
The Slack message/event identity supplies the stable command idempotency key.
|
|
672
|
-
|
|
673
|
-
Because steer starts work when idle, the same command works for initial and
|
|
674
|
-
subsequent ingress. Concurrent Slack messages are independently admitted in
|
|
675
|
-
Durable Object order and are batched by EDA, not Slack, at the next turn
|
|
676
|
-
boundary. Their transcript rows, authors, attachments, and cancellation audit
|
|
677
|
-
identities remain separate.
|
|
678
|
-
|
|
679
|
-
Slack does not expose queue, promotion, paused-queue confirmation, or browser
|
|
680
|
-
edit behavior. A Slack steer can start a run while unrelated browser-created
|
|
681
|
-
queue messages remain paused.
|
|
682
|
-
|
|
683
|
-
## 18. Recovery and compaction
|
|
684
|
-
|
|
685
|
-
- Pending messages and queue pause membership are durable reducer state.
|
|
686
|
-
- Startup has one recovery entrypoint. It hydrates state, calls the pure
|
|
687
|
-
`planSessionRecovery` domain policy once, and interprets the complete plan as
|
|
688
|
-
one atomic durable event batch before starting the live control loop.
|
|
689
|
-
- The recovery plan covers unfinished commands, runs, turns, inferences, tool
|
|
690
|
-
calls, stop requests, compactions, and ownerless steers. Open compaction
|
|
691
|
-
repair is not a separate startup pass.
|
|
692
|
-
- Recovery admits one framework-owned `ResumePendingMessages` command for an
|
|
693
|
-
ownerless steer batch. It does not synthesize user-message history.
|
|
694
|
-
- After the recovery batch is folded, the shell verifies that a second pure
|
|
695
|
-
plan is empty. Failure to reach this fixed point is fatal.
|
|
696
|
-
- The live runtime does not perform defensive recovery. It assumes startup
|
|
697
|
-
recovery succeeded and fails loudly if durable active work has no in-memory
|
|
698
|
-
owner.
|
|
699
|
-
- Expected model, tool, and run failures while a live owner exists are ordinary
|
|
700
|
-
domain transitions. They may preserve steers and schedule follow-up work,
|
|
701
|
-
but they are not startup recovery.
|
|
702
|
-
- Framework checkpoint schema changes must replay correctly from sequence zero
|
|
703
|
-
when the old checkpoint version is incompatible.
|
|
704
|
-
- Command input compaction must not delete content still owned by a pending
|
|
705
|
-
message.
|
|
706
|
-
- Prompt/context compaction applies only after consumption. Pending and
|
|
707
|
-
cancelled messages are not model context.
|
|
708
|
-
- An orphaned active run is terminalized only by the startup recovery plan.
|
|
709
|
-
- A crash after durable command admission but before dispatch reconstructs the
|
|
710
|
-
same pending message and resumes scheduling.
|
|
711
|
-
- A crash after `TurnStarted` commits reconstructs the message as consumed;
|
|
712
|
-
cancellation cannot subsequently win.
|
|
713
|
-
|
|
714
|
-
## 19. Observability
|
|
715
|
-
|
|
716
|
-
Add structured fields and counters for:
|
|
717
|
-
|
|
718
|
-
- submitted disposition and applied path (`new-run`, `queued`, `steered`);
|
|
719
|
-
- pending queue, steer, and paused depths;
|
|
720
|
-
- number of steers consumed per turn boundary;
|
|
721
|
-
- pending-message age at consumption;
|
|
722
|
-
- cancellation and promotion outcomes;
|
|
723
|
-
- conditional conflicts by code;
|
|
724
|
-
- queue pause creation, depth, duration, and final resolution;
|
|
725
|
-
- unexpected failure fallback to a new run;
|
|
726
|
-
- HTTP idempotent replay;
|
|
727
|
-
- exact versus span/owner author attribution;
|
|
728
|
-
- Slack messages submitted and steered individually.
|
|
729
|
-
|
|
730
|
-
Logs must include `sessionId`, `commandId`, `messageId`, and applicable `runId`
|
|
731
|
-
and `turnId` without logging message content.
|
|
732
|
-
|
|
733
|
-
## 20. Test plan
|
|
734
|
-
|
|
735
|
-
### 20.1 Pure reducer tests
|
|
736
|
-
|
|
737
|
-
- submission creates one pending message with framework-minted identity;
|
|
738
|
-
- promotion preserves identity and origin metadata correlation;
|
|
739
|
-
- cancellation removes only from renderable state;
|
|
740
|
-
- `TurnStarted` consumes several steers atomically in FIFO order;
|
|
741
|
-
- pause membership derives and clears correctly;
|
|
742
|
-
- replay and checkpoint hydration reproduce identical state;
|
|
743
|
-
- legacy author spans remain readable while new messages use exact mapping.
|
|
744
|
-
|
|
745
|
-
Property tests should generate interleavings of submit, promote, cancel, stop,
|
|
746
|
-
turn start, turn terminal, and run failure and assert the invariants in section
|
|
747
|
-
5.
|
|
748
|
-
|
|
749
|
-
### 20.2 Session control tests
|
|
750
|
-
|
|
751
|
-
- queue while active waits and later starts a separate run;
|
|
752
|
-
- steer while active waits for the boundary without terminalizing the run;
|
|
753
|
-
- steer arriving idle starts a run;
|
|
754
|
-
- all pre-boundary steers enter one continuation turn;
|
|
755
|
-
- post-boundary steer waits for the next boundary;
|
|
756
|
-
- cancellation and consumption races are first-transition-wins;
|
|
757
|
-
- promotion idle fallback starts a run;
|
|
758
|
-
- failed run preserves unconsumed steers;
|
|
759
|
-
- explicit stop demotes steers and pauses all waiting work;
|
|
760
|
-
- selective promotion leaves other pause members held;
|
|
761
|
-
- ordinary queue submission conflicts while paused;
|
|
762
|
-
- conditional clear-and-submit is atomic and detects stale sets.
|
|
763
|
-
- interrupting with a pending steer stops the active run and resumes exactly
|
|
764
|
-
that message while other paused messages remain held.
|
|
765
|
-
|
|
766
|
-
### 20.3 Host and API tests
|
|
767
|
-
|
|
768
|
-
- HTTP auth remains owner-only;
|
|
769
|
-
- duplicate idempotency keys return the original outcome;
|
|
770
|
-
- event arrival before HTTP completion does not duplicate UI state;
|
|
771
|
-
- attachment and author batches remain atomic with message admission;
|
|
772
|
-
- typed conflicts map to stable HTTP response codes and bodies;
|
|
773
|
-
- restored WebSockets replay every new lifecycle event.
|
|
774
|
-
|
|
775
|
-
### 20.4 UI tests
|
|
776
|
-
|
|
777
|
-
- queue and steer messages render immediately after admission;
|
|
778
|
-
- Edit waits for cancellation success before filling the composer;
|
|
779
|
-
- failed Edit does not alter the composer;
|
|
780
|
-
- promotion updates one existing row without flicker or duplication;
|
|
781
|
-
- cancelled messages disappear from the normal transcript;
|
|
782
|
-
- Stop renders run and queue-paused notices separately;
|
|
783
|
-
- stale clear confirmation refreshes rather than deleting unseen work;
|
|
784
|
-
- reload and reconnect preserve every pending state and affordance.
|
|
785
|
-
- queued and steering overflow menus expose the correct ordered actions.
|
|
786
|
-
|
|
787
|
-
### 20.5 Slack tests
|
|
788
|
-
|
|
789
|
-
- one inbound Slack message produces one steer command;
|
|
790
|
-
- multiple inbound events remain separate messages and authors;
|
|
791
|
-
- idle Slack steer starts a run;
|
|
792
|
-
- active Slack steers batch only at the EDA boundary;
|
|
793
|
-
- Slack retries deduplicate without losing metadata;
|
|
794
|
-
- first message seeds session state atomically with its steer.
|
|
795
|
-
|
|
796
|
-
## 21. Implementation map
|
|
797
|
-
|
|
798
|
-
Primary framework areas:
|
|
799
|
-
|
|
800
|
-
- `src/types/commands.ts`
|
|
801
|
-
- `src/types/events/durable.ts`
|
|
802
|
-
- `src/domain/reduced-state.ts`
|
|
803
|
-
- `src/domain/command-queues.ts`
|
|
804
|
-
- `src/domain/dispatch-policy.ts`
|
|
805
|
-
- `src/domain/run-continuation-policy.ts`
|
|
806
|
-
- `src/services/session-state.ts`
|
|
807
|
-
- `src/host/durable-object-store.ts`
|
|
808
|
-
|
|
809
|
-
Primary Gia areas:
|
|
810
|
-
|
|
811
|
-
- `workers/eda-agent/api.ts`
|
|
812
|
-
- `workers/eda-agent/slack-ingress.ts`
|
|
813
|
-
- `workers/eda-agent/user-message-authors.ts`
|
|
814
|
-
- `workers/eda-agent/attachments.ts`
|
|
815
|
-
- `app/routes/api.eda-agent.sessions.$sessionId.messages.ts`
|
|
816
|
-
- `app/lib/eda-session-api-client.ts`
|
|
817
|
-
- `app/hooks/use-eda-session-live.ts`
|
|
818
|
-
- `app/components/screens/eda-session-page-model.ts`
|
|
819
|
-
- `app/components/organisms/eda-session-thread-panel.tsx`
|
|
820
|
-
|
|
821
|
-
## 22. Summary
|
|
822
|
-
|
|
823
|
-
EDA should treat a submitted user message as a durable entity before it becomes
|
|
824
|
-
model context. Queue and steer are user intent, resolved against authoritative
|
|
825
|
-
server state. Steering waits for a turn boundary and batches all eligible
|
|
826
|
-
messages. Cancellation and promotion are conditional control commands over the
|
|
827
|
-
same message identity. Explicit Stop preserves user work by pausing it rather
|
|
828
|
-
than dropping or immediately executing it. Gia sends mutations over HTTP,
|
|
829
|
-
observes state over WebSocket, correlates metadata through command idempotency,
|
|
830
|
-
and retains historical author compatibility. Slack contributes one steer per
|
|
831
|
-
human message and delegates batching entirely to EDA.
|