Skip to content

Commit fdfab8d

Browse files
authored
fix(server): reject incompatible callback routes before admission (#21)
* fix(server): reject incompatible callback routes before admission * fix(server): preserve retained sessions on route rejection * fix(provider): guard cross-driver continuations only when resuming * fix(server): preflight effective callback route * fix(server): reconcile legacy callback session identity --------- Co-authored-by: nullStack65 <nullStack65@users.noreply.github.com>
1 parent 23467c5 commit fdfab8d

17 files changed

Lines changed: 1625 additions & 197 deletions

‎apps/server/integration/OrchestrationEngineHarness.integration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ export const makeOrchestrationIntegrationHarness = (
312312
orchestrationLayer.pipe(Layer.provide(projectionSnapshotQueryLayer)),
313313
ProjectionPendingApprovalRepositoryLive,
314314
checkpointStoreLayer,
315-
providerLayer,
316315
RuntimeReceiptBusTest,
317316
).pipe(
318317
Layer.provideMerge(ThreadBackgroundLiveness.layer),
319318
Layer.provideMerge(ThreadPlanProgress.layer),
319+
Layer.provideMerge(providerLayer),
320320
);
321321
const serverSettingsLayer = ServerSettingsService.layerTest();
322322
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(

‎apps/server/integration/orchestrationEngine.integration.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { assert, it } from "@effect/vitest";
2121
import * as Clock from "effect/Clock";
2222
import * as Effect from "effect/Effect";
23+
import * as Option from "effect/Option";
2324
import * as Schema from "effect/Schema";
2425

2526
import type { TestTurnResponse } from "./TestProviderAdapter.integration.ts";
@@ -181,6 +182,63 @@ const startTurn = (input: {
181182
createdAt: input.createdAt ?? nowIso(),
182183
});
183184

185+
it.live("uses the runtime ProviderService during serialized resume admission", () =>
186+
withHarness((harness) =>
187+
Effect.gen(function* () {
188+
yield* seedProjectAndThread(harness);
189+
yield* harness.engine.dispatch({
190+
type: "thread.session.set",
191+
commandId: CommandId.make("cmd-resume-admission-session"),
192+
threadId: THREAD_ID,
193+
session: {
194+
threadId: THREAD_ID,
195+
status: "ready",
196+
providerName: CODEX_PROVIDER,
197+
providerInstanceId: defaultInstanceIdForDriver(CODEX_PROVIDER),
198+
runtimeMode: "approval-required",
199+
activeTurnId: null,
200+
lastError: null,
201+
updatedAt: nowIso(),
202+
},
203+
createdAt: nowIso(),
204+
});
205+
const beforeSequence = yield* harness.engine.latestSequence;
206+
const error = yield* harness.engine
207+
.dispatch({
208+
type: "thread.turn.start",
209+
commandId: CommandId.make("cmd-resume-admission-incompatible-route"),
210+
threadId: THREAD_ID,
211+
message: {
212+
messageId: asMessageId("msg-resume-admission-incompatible-route"),
213+
role: "user",
214+
text: "This route must be rejected before message ingestion",
215+
attachments: [],
216+
},
217+
modelSelection: {
218+
instanceId: defaultInstanceIdForDriver(CLAUDE_AGENT_PROVIDER),
219+
model: DEFAULT_MODEL_BY_PROVIDER[CLAUDE_AGENT_PROVIDER] ?? DEFAULT_MODEL,
220+
},
221+
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
222+
runtimeMode: "approval-required",
223+
createdAt: nowIso(),
224+
})
225+
.pipe(Effect.flip);
226+
227+
assert.equal(error._tag, "OrchestrationCommandInvariantError");
228+
assert.match(error.message, /No message was ingested/);
229+
assert.equal(yield* harness.engine.latestSequence, beforeSequence);
230+
const thread = Option.getOrNull(yield* harness.snapshotQuery.getThreadDetailById(THREAD_ID));
231+
assert.equal(thread?.session?.status, "ready");
232+
assert.equal(
233+
thread?.messages.some(
234+
(message) => message.id === "msg-resume-admission-incompatible-route",
235+
),
236+
false,
237+
);
238+
}),
239+
),
240+
);
241+
184242
it.live("runs a single turn end-to-end and persists checkpoint state in sqlite + git", () =>
185243
withHarness((harness) =>
186244
Effect.gen(function* () {

0 commit comments

Comments
 (0)