fix: address orchestration review findings
Use shared cache schemas, close the OpenCode abort race, and assert fixture collection sizes correctly. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
3a4ebebc02
commit
ec48d78fa5
6 files changed
+221
-41
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
import { OPENCODE_PROVIDER } from "./OpenCodeAdapterV2.ts";
|
||||
import {
|
||||
OPENCODE_SDK_REPLAY_PROTOCOL,
|
||||
OpenCodeReplayController,
|
||||
} from "./OpenCodeAdapterV2.testkit.ts";
|
||||
|
||||
describe("OpenCodeAdapterV2 replay testkit", () => {
|
||||
it.effect("stops an event stream when abort races with listener registration", () =>
|
||||
Effect.gen(function* () {
|
||||
let aborted = false;
|
||||
const signal = {
|
||||
get aborted() {
|
||||
return aborted;
|
||||
},
|
||||
addEventListener: () => {
|
||||
aborted = true;
|
||||
},
|
||||
removeEventListener: () => {},
|
||||
} as unknown as AbortSignal;
|
||||
const controller = new OpenCodeReplayController({
|
||||
provider: OPENCODE_PROVIDER,
|
||||
protocol: OPENCODE_SDK_REPLAY_PROTOCOL,
|
||||
version: "test",
|
||||
scenario: "abort-during-listener-registration",
|
||||
entries: [],
|
||||
});
|
||||
const iterator = controller.events(signal)[Symbol.asyncIterator]();
|
||||
|
||||
const result = yield* Effect.promise(() => iterator.next()).pipe(
|
||||
Effect.timeout("100 millis"),
|
||||
);
|
||||
|
||||
assert.isTrue(result.done);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -120,7 +120,7 @@ function frameRecord(frame: unknown): Record<string, unknown> | null {
|
||||
return typeof frame === "object" && frame !== null ? (frame as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
class OpenCodeReplayController {
|
||||
export class OpenCodeReplayController {
|
||||
private cursor = 0;
|
||||
private readonly waiters = new Set<() => void>();
|
||||
private failure: unknown = null;
|
||||
@@ -243,15 +243,18 @@ class OpenCodeReplayController {
|
||||
}
|
||||
|
||||
private changed(signal?: AbortSignal): Promise<void> {
|
||||
if (signal?.aborted === true) return Promise.resolve();
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const done = () => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
signal?.removeEventListener("abort", done);
|
||||
this.waiters.delete(done);
|
||||
resolve();
|
||||
};
|
||||
this.waiters.add(done);
|
||||
signal?.addEventListener("abort", done, { once: true });
|
||||
if (signal?.aborted === true) done();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ export function assertClaudeLocalBashTaskOutput(
|
||||
) {
|
||||
assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] });
|
||||
|
||||
assert.lengthOf(
|
||||
result.projections,
|
||||
assert.equal(
|
||||
result.projections.size,
|
||||
1,
|
||||
"Claude local_bash task lifecycle events must not create child app threads",
|
||||
);
|
||||
|
||||
@@ -35,8 +35,9 @@ export function assertTodoListGrokOutput(
|
||||
|
||||
const planEvents = result.domainEvents.filter((event) => event.type === "plan.updated");
|
||||
assert.lengthOf(planEvents, 2);
|
||||
assert.lengthOf(
|
||||
new Set(planEvents.map((event) => (event.type === "plan.updated" ? event.payload.id : null))),
|
||||
assert.equal(
|
||||
new Set(planEvents.map((event) => (event.type === "plan.updated" ? event.payload.id : null)))
|
||||
.size,
|
||||
1,
|
||||
"ACP plan updates must preserve one plan identity",
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user