Skip to content

Commit 1349883

Browse files
test(server): keep the fewest #29898 tests and name the queued-run refusal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c99dfcd commit 1349883

2 files changed

Lines changed: 1 addition & 99 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13084,7 +13084,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
1308413084
return yield* new OrchestratorDispatchError({
1308513085
commandId: command.commandId,
1308613086
commandType: command.type,
13087-
cause: `Thread ${command.threadId} changed before automatic settlement.`,
13087+
cause: `Thread ${command.threadId} has a queued run that may still start.`,
1308813088
});
1308913089
}
1309013090
yield* dispatchThreadMutation(

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,58 +3185,6 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
31853185
return { threadId, activeRun, wakeRun };
31863186
});
31873187

3188-
const failRun = (run: OrchestrationV2Run) =>
3189-
Effect.gen(function* () {
3190-
const eventSink = yield* EventSink.EventSinkV2;
3191-
const now = yield* DateTime.now;
3192-
yield* eventSink.write({
3193-
events: [
3194-
{
3195-
id: EventId.make(`${run.id}:error`),
3196-
type: "turn-item.updated",
3197-
threadId: run.threadId,
3198-
runId: run.id,
3199-
...(run.rootNodeId === null ? {} : { nodeId: run.rootNodeId }),
3200-
providerInstanceId: run.providerInstanceId,
3201-
occurredAt: now,
3202-
payload: {
3203-
id: TurnItemId.make(`${run.id}:error`),
3204-
type: "error",
3205-
threadId: run.threadId,
3206-
runId: run.id,
3207-
nodeId: run.rootNodeId,
3208-
providerThreadId: run.providerThreadId,
3209-
providerTurnId: null,
3210-
nativeItemRef: null,
3211-
parentItemId: null,
3212-
ordinal: 2,
3213-
status: "failed",
3214-
title: "Provider failure",
3215-
startedAt: now,
3216-
completedAt: now,
3217-
updatedAt: now,
3218-
failure: {
3219-
class: "provider_error",
3220-
message: "Provider failed.",
3221-
code: "provider_failed",
3222-
retryable: null,
3223-
},
3224-
},
3225-
},
3226-
{
3227-
id: EventId.make(`${run.id}:failed`),
3228-
type: "run.updated",
3229-
threadId: run.threadId,
3230-
runId: run.id,
3231-
...(run.rootNodeId === null ? {} : { nodeId: run.rootNodeId }),
3232-
providerInstanceId: run.providerInstanceId,
3233-
occurredAt: now,
3234-
payload: { ...run, status: "failed", completedAt: now },
3235-
},
3236-
],
3237-
});
3238-
});
3239-
32403188
// Completes `run`, then dispatches automatic settlement while the completion reaction waits
32413189
// before releasing and starting the queue: the window the settlement sweep races.
32423190
const autoSettleBeforeCompletionReaction = (run: OrchestrationV2Run, commandId: CommandId) =>
@@ -3331,52 +3279,6 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
33313279
}),
33323280
);
33333281

3334-
it.effect("automatic settlement waits for a held wake that a completed run releases", () =>
3335-
Effect.gen(function* () {
3336-
const orchestrator = yield* Orchestrator.OrchestratorV2;
3337-
const eventSink = yield* EventSink.EventSinkV2;
3338-
const { threadId, activeRun, wakeRun } = yield* queuedWatchWake("pr-watch-released-wake");
3339-
const beforeFailure = yield* orchestrator.getThreadEventSequence(threadId);
3340-
yield* failRun(activeRun);
3341-
yield* eventSink
3342-
.stream({ threadId, afterSequence: beforeFailure, eventType: "run.updated" })
3343-
.pipe(
3344-
Stream.filter(
3345-
(stored) =>
3346-
stored.event.type === "run.updated" &&
3347-
stored.event.payload.id === wakeRun.id &&
3348-
stored.event.payload.queueHeld === true,
3349-
),
3350-
Stream.runHead,
3351-
);
3352-
// The server's own message: a later completion releases the wake's hold.
3353-
yield* orchestrator.dispatch({
3354-
type: "message.dispatch",
3355-
createdBy: "agent",
3356-
creationSource: "server",
3357-
commandId: CommandId.make("pr-watch-released-wake-tick"),
3358-
threadId,
3359-
messageId: MessageId.make("pr-watch-released-wake-tick"),
3360-
text: "Scheduled tick",
3361-
attachments: [],
3362-
modelSelection,
3363-
dispatchMode: { type: "start_immediately" },
3364-
});
3365-
const tickRun = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
3366-
(run) => run.status === "starting",
3367-
);
3368-
assert.isDefined(tickRun);
3369-
3370-
const { window, afterSettle, after } = yield* autoSettleBeforeCompletionReaction(
3371-
tickRun,
3372-
CommandId.make("pr-watch-released-wake-auto-settle"),
3373-
);
3374-
assert.equal(window.runs.find((run) => run.id === wakeRun.id)?.queueHeld, true);
3375-
assert.isNull(afterSettle.thread.settledAt);
3376-
assert.equal(after.runs.find((run) => run.id === wakeRun.id)?.status, "starting");
3377-
}),
3378-
);
3379-
33803282
it.effect("automatic settlement refuses a held wake only within the queued-turn grace", () =>
33813283
Effect.gen(function* () {
33823284
const orchestrator = yield* Orchestrator.OrchestratorV2;

0 commit comments

Comments
 (0)