fix(orchestrator): address late review findings
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
936a798d9d
commit
dbc836d591
27 files changed
+473
-60
No files matched your search
@@ -0,0 +1,73 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodeChildProcess from "node:child_process";
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodeOS from "node:os";
|
||||
import * as NodePath from "node:path";
|
||||
import * as NodeURL from "node:url";
|
||||
|
||||
import { expect, it } from "vite-plus/test";
|
||||
|
||||
const replayAgentPath = NodeURL.fileURLToPath(new URL("./acp-replay-agent.ts", import.meta.url));
|
||||
|
||||
async function runRuntimeExit(status: "success" | "error" | "cancelled") {
|
||||
const scratch = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-acp-replay-agent-"));
|
||||
const statusPath = NodePath.join(scratch, "status.json");
|
||||
const transcript = {
|
||||
scenario: `${status}-runtime-exit`,
|
||||
entries: [{ type: "runtime_exit", status }],
|
||||
};
|
||||
const child = NodeChildProcess.spawn(process.execPath, [replayAgentPath], {
|
||||
env: {
|
||||
...process.env,
|
||||
T3_ACP_REPLAY_STATUS_PATH: statusPath,
|
||||
T3_ACP_REPLAY_TRANSCRIPT: Buffer.from(JSON.stringify(transcript), "utf8").toString("base64"),
|
||||
T3_ACP_REPLAY_WORKSPACE: scratch,
|
||||
},
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
let stderr = "";
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stderr.on("data", (chunk: string) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
child.stdin.end();
|
||||
|
||||
try {
|
||||
const code = await new Promise<number | null>((resolve, reject) => {
|
||||
child.once("error", reject);
|
||||
child.once("exit", resolve);
|
||||
});
|
||||
return {
|
||||
code,
|
||||
status: JSON.parse(NodeFS.readFileSync(statusPath, "utf8")) as unknown,
|
||||
stderr,
|
||||
transcript,
|
||||
};
|
||||
} finally {
|
||||
NodeFS.rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
it("accepts a recorded cancelled runtime exit", async () => {
|
||||
const result = await runRuntimeExit("cancelled");
|
||||
expect(result.code, result.stderr).toBe(0);
|
||||
expect(result.status).toEqual({
|
||||
scenario: result.transcript.scenario,
|
||||
cursor: 1,
|
||||
total: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("still rejects a recorded error runtime exit", async () => {
|
||||
const result = await runRuntimeExit("error");
|
||||
expect(result.code).toBe(1);
|
||||
expect(result.status).toMatchObject({
|
||||
scenario: result.transcript.scenario,
|
||||
cursor: 0,
|
||||
total: 1,
|
||||
failure: {
|
||||
detail: "Recorded runtime exit was error",
|
||||
cursor: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -214,7 +214,7 @@ function flushInbound(): void {
|
||||
const entry = transcript.entries[cursor];
|
||||
if (entry === undefined || entry.type === "expect_outbound") return;
|
||||
if (entry.type === "runtime_exit") {
|
||||
if (entry.status !== "success") {
|
||||
if (entry.status !== "success" && entry.status !== "cancelled") {
|
||||
stopWithFailure(`Recorded runtime exit was ${entry.status ?? "unknown"}`, entry.error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { assert, it } from "@effect/vitest";
|
||||
|
||||
import {
|
||||
cursorReplayPromptsForWorkspace,
|
||||
cursorReplayTranscriptCwd,
|
||||
shouldSeedCursorReplayWorkspace,
|
||||
} from "./cursorReplayRecordingWorkspace.ts";
|
||||
|
||||
@@ -33,3 +34,11 @@ it("never seeds files into an externally supplied workspace", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("canonicalizes read-only tool paths to the stable fixture workspace", () => {
|
||||
assert.equal(
|
||||
cursorReplayTranscriptCwd("tool_call_read_only"),
|
||||
"/tmp/claude-replay-tool_call_read_only",
|
||||
);
|
||||
assert.equal(cursorReplayTranscriptCwd("simple"), undefined);
|
||||
});
|
||||
@@ -1,3 +1,5 @@
|
||||
import { TOOL_CALL_READ_ONLY_WORKSPACE_ROOT } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
|
||||
|
||||
const SEEDED_CURSOR_REPLAY_SCENARIOS = new Set(["subagent", "tool_call_read_only", "todo_list"]);
|
||||
|
||||
export function cursorReplayPromptsForWorkspace(input: {
|
||||
@@ -21,3 +23,7 @@ export function shouldSeedCursorReplayWorkspace(input: {
|
||||
}): boolean {
|
||||
return input.owned && SEEDED_CURSOR_REPLAY_SCENARIOS.has(input.scenario);
|
||||
}
|
||||
|
||||
export function cursorReplayTranscriptCwd(scenario: string): string | undefined {
|
||||
return scenario === "tool_call_read_only" ? TOOL_CALL_READ_ONLY_WORKSPACE_ROOT : undefined;
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
} from "../src/orchestration-v2/testkit/fixtures/shared.ts";
|
||||
import {
|
||||
cursorReplayPromptsForWorkspace,
|
||||
cursorReplayTranscriptCwd,
|
||||
shouldSeedCursorReplayWorkspace,
|
||||
} from "./cursorReplayRecordingWorkspace.ts";
|
||||
|
||||
@@ -158,6 +159,7 @@ if (!apiKey) {
|
||||
|
||||
const recording = RECORDINGS[scenario];
|
||||
const workspace = await prepareWorkspace(scenario);
|
||||
const transcriptCwd = cursorReplayTranscriptCwd(scenario);
|
||||
const outputPath = readArgValue("--out") ?? new URL(recording.output, import.meta.url).pathname;
|
||||
|
||||
try {
|
||||
@@ -184,6 +186,7 @@ try {
|
||||
model: process.env.T3_CURSOR_REPLAY_MODEL ?? CURSOR_MODEL_SELECTION.model,
|
||||
},
|
||||
cwd: workspace.cwd,
|
||||
...(transcriptCwd === undefined ? {} : { transcriptCwd }),
|
||||
apiKey,
|
||||
...("interactionMode" in recording ? { interactionMode: recording.interactionMode } : {}),
|
||||
...("interruptAfterToolStart" in recording
|
||||
|
||||
Reference in new issue
Block a user