fix: structure codex steer confirmation

Fixes #144.
This commit is contained in:
Lyon
2026-05-23 22:04:35 +08:00
committed by GitHub
parent 59776aa5d2
commit 12fdc9e238
2 changed files with 120 additions and 7 deletions
+45 -2
View File
@@ -113,6 +113,13 @@ export function runCodeQueueCliSteerContract(): JsonRecord {
const usage = stringArray(nestedRecord(help.json?.data, []).usage);
assertCondition(usage.some((line) => line.includes("codex steer <taskId>")), "codex help should list steer", { usage });
const advertisedConfirm = runCli(["codex", "steer-confirm", "codex_test_task", "--steer-id", "steer_direct_12345"]);
assertCondition(advertisedConfirm.json !== null, "advertised steer-confirm command should return JSON", { stdout: advertisedConfirm.stdout, stderr: advertisedConfirm.stderr });
assertCondition(!("error" in (advertisedConfirm.json ?? {})), "advertised steer-confirm command must not fall through to top-level error", advertisedConfirm.json ?? {});
const advertisedDeliveryStatus = String(nestedRecord(advertisedConfirm.json?.data, ["delivery"]).status || "");
assertCondition(["confirmed", "pending", "unknown", "not-supported"].includes(advertisedDeliveryStatus), "advertised steer-confirm command should return structured delivery status", { advertisedDeliveryStatus, json: advertisedConfirm.json });
assertCondition(!String(JSON.stringify(advertisedConfirm.json)).includes("\"message\":\"not found\""), "advertised steer-confirm command must not return top-level not found", advertisedConfirm.json ?? {});
let dryRunFetchCount = 0;
const dryRunDirect = codexSteerTaskForTest("direct_task", ["do not send", "--dry-run"], () => {
dryRunFetchCount += 1;
@@ -375,10 +382,45 @@ export function runCodeQueueCliSteerContract(): JsonRecord {
};
}) as JsonRecord;
assertCondition(confirmLookup.ok === true, "trace confirmation lookup should succeed when accepted", confirmLookup);
assertCondition(nestedRecord(confirmLookup, ["delivery"]).status === "accepted", "trace confirmation output should expose accepted status", confirmLookup);
assertCondition(nestedRecord(confirmLookup, ["delivery"]).status === "confirmed", "trace confirmation output should expose confirmed status", confirmLookup);
assertCondition(nestedRecord(confirmLookup, ["traceConfirmation"]).status === "confirmed", "trace confirmation payload should expose confirmed status", confirmLookup);
assertCondition(nestedRecord(confirmLookup, ["traceConfirmation", "trace"]).seq === 88, "trace confirmation output should expose bounded trace seq", confirmLookup);
assertCondition(!JSON.stringify(confirmLookup).includes("same prompt"), "trace confirmation lookup must not echo prompt", confirmLookup);
const pendingLookup = codexSteerTraceConfirmForTest("direct_task", ["--steer-id", explicitSteerId], () => ({
ok: true,
status: 200,
body: {
ok: true,
confirmation: {
taskId: "direct_task",
steerId: explicitSteerId,
found: false,
accepted: false,
deliveryState: "unknown",
matchCount: 0,
trace: null,
duplicateSuppressionKey: explicitSteerId,
promptOmitted: true,
},
},
})) as JsonRecord;
assertCondition(pendingLookup.ok === false, "pending trace confirmation should not report ok=true", pendingLookup);
assertCondition(nestedRecord(pendingLookup, ["delivery"]).status === "pending", "unmatched supported trace confirmation should be pending", pendingLookup);
const unsupportedLookup = codexSteerTraceConfirmForTest("direct_task", ["--steer-id", explicitSteerId], (path) => {
assertCondition(path.includes("/api/microservices/code-queue/proxy/api/tasks/direct_task/steer-confirmation"), "unsupported lookup should still call advertised route", { path });
return {
ok: false,
status: 404,
body: { ok: false, error: "not found", path: "/api/tasks/direct_task/steer-confirmation" },
};
}) as JsonRecord;
assertCondition(unsupportedLookup.ok === false, "unsupported trace confirmation should be structured ok=false", unsupportedLookup);
assertCondition(nestedRecord(unsupportedLookup, ["delivery"]).status === "not-supported", "unsupported trace confirmation should expose not-supported status", unsupportedLookup);
assertCondition(nestedRecord(unsupportedLookup, ["traceConfirmation"]).status === "not-supported", "unsupported trace confirmation payload should expose not-supported status", unsupportedLookup);
assertCondition(!JSON.stringify(unsupportedLookup).includes("promptPreview"), "unsupported trace confirmation must not echo prompt previews", unsupportedLookup);
const terminalPrompt = `${"do not leak ".repeat(40)}tail-secret-marker`;
const terminalRejection = codexSteerTaskForTest("completed_task", [terminalPrompt], () => ({
ok: false,
@@ -465,6 +507,7 @@ export function runCodeQueueCliSteerContract(): JsonRecord {
"duplicate prompt source failure",
"unsupported option failure",
"codex help lists steer",
"advertised steer-confirm CLI command returns structured status",
"outer command redacts positional steer prompt",
"dry-run does not call stable proxy helper",
"dry-run prompt preview is bounded",
@@ -473,7 +516,7 @@ export function runCodeQueueCliSteerContract(): JsonRecord {
"steer failure classification is JSON-consumable",
"retryable tunnel aborts are retried with bounded diagnostics",
"retry reuses steerId and trace confirmation distinguishes accepted_response_timeout from unknown",
"duplicate suppression and trace confirmation lookup expose bounded output shape",
"duplicate suppression and trace confirmation lookup expose bounded confirmed/pending/not-supported statuses",
"terminal steer rejection is compact and actionable",
"terminal steer rejection full/raw disclosure is explicit",
],