fix: split github contracts from script check
This commit is contained in:
@@ -45,6 +45,21 @@ function stringArray(value: unknown): string[] {
|
||||
return Array.isArray(value) ? value.map((item) => String(item)) : [];
|
||||
}
|
||||
|
||||
function assertLegacyFrozenWrite(result: { status: number | null; stdout: string; stderr: string; json: JsonRecord | null }, command: string): void {
|
||||
assertCondition(result.status !== 0 && result.json?.ok === false, `${command} should be frozen`, result.json ?? { stdout: result.stdout, stderr: result.stderr });
|
||||
const data = nestedRecord(result.json?.data, []);
|
||||
assertCondition(data.ok === false, `${command} frozen payload should be ok=false`, data);
|
||||
assertCondition(data.frozen === true, `${command} frozen payload should expose frozen=true`, data);
|
||||
assertCondition(data.mutation === false, `${command} frozen payload should be non-mutating`, data);
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
assertCondition(data.command === command, `${command} frozen payload should identify the command`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun v01 queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun v01 sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
const legacy = nestedRecord(data, ["legacy"]);
|
||||
assertCondition(legacy.noDoubleWrite === true, `${command} should document no double-write`, legacy);
|
||||
}
|
||||
|
||||
function assertDryRunPrompt(response: JsonRecord, expectedText: string): void {
|
||||
assertCondition(response.ok === true, "submit dry-run should succeed", response);
|
||||
const data = nestedRecord(response.data, []);
|
||||
@@ -66,8 +81,8 @@ export function runCodeQueueCliSubmitPromptContract(): JsonRecord {
|
||||
].join("\n");
|
||||
|
||||
const stdin = runCli(["codex", "submit", "--prompt-stdin", "--queue", "prompt-contract", "--dry-run"], multilinePrompt);
|
||||
assertDryRunPrompt(stdin.json ?? {}, multilinePrompt);
|
||||
assertCondition(String(stdin.json?.command || "") === "codex submit --prompt-stdin --queue prompt-contract --dry-run", "stdin command should list flags without echoing prompt", stdin.json ?? {});
|
||||
assertLegacyFrozenWrite(stdin, "codex submit");
|
||||
assertCondition(!stdin.stdout.includes(multilinePrompt), "frozen submit must not echo stdin prompt", { stdout: stdin.stdout });
|
||||
|
||||
const tmp = mkdtempSync(join(tmpdir(), "unidesk-code-queue-submit-"));
|
||||
const promptFile = join(tmp, "prompt.md");
|
||||
@@ -75,22 +90,19 @@ export function runCodeQueueCliSubmitPromptContract(): JsonRecord {
|
||||
writeFileSync(promptFile, filePrompt, "utf8");
|
||||
try {
|
||||
const fromFile = runCli(["codex", "submit", "--prompt-file", promptFile, "--queue", "prompt-contract", "--dry-run"]);
|
||||
assertDryRunPrompt(fromFile.json ?? {}, filePrompt);
|
||||
assertCondition(String(fromFile.json?.command || "").includes(`--prompt-file ${promptFile}`), "prompt-file command should retain file path for review", fromFile.json ?? {});
|
||||
assertCondition(!String(fromFile.json?.command || "").includes("file prompt tail"), "prompt-file command must not echo file prompt text", fromFile.json ?? {});
|
||||
assertLegacyFrozenWrite(fromFile, "codex submit");
|
||||
assertCondition(!fromFile.stdout.includes("file prompt tail"), "frozen submit must not echo file prompt text", { stdout: fromFile.stdout });
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
const positional = runCli(["codex", "submit", "short smoke prompt", "--dry-run"]);
|
||||
assertDryRunPrompt(positional.json ?? {}, "short smoke prompt");
|
||||
assertLegacyFrozenWrite(positional, "codex submit");
|
||||
assertCondition(String(positional.json?.command || "").includes("<prompt:redacted>"), "outer command should redact positional submit prompt", positional.json ?? {});
|
||||
assertCondition(!String(positional.json?.command || "").includes("short smoke prompt"), "outer command must not echo positional submit prompt", positional.json ?? {});
|
||||
|
||||
const duplicateSource = runCli(["codex", "submit", "positional", "--prompt-stdin", "--dry-run"], "stdin\n");
|
||||
assertCondition(duplicateSource.status !== 0, "duplicate prompt source should fail", duplicateSource.json ?? { stdout: duplicateSource.stdout });
|
||||
const duplicateMessage = String(nestedRecord(duplicateSource.json, ["error"]).message || "");
|
||||
assertCondition(duplicateMessage.includes("exactly one prompt source"), "duplicate prompt source error should be explicit", { duplicateMessage });
|
||||
assertLegacyFrozenWrite(duplicateSource, "codex submit");
|
||||
|
||||
const longSubmittedPrompt = `${multilinePrompt}${"submitted prompt body must not be echoed\n".repeat(80)}`;
|
||||
const submitSuccess = compactSubmitSuccessResponseForTest({
|
||||
@@ -128,23 +140,23 @@ export function runCodeQueueCliSubmitPromptContract(): JsonRecord {
|
||||
const promptInput = nestedRecord(data, ["promptInput"]);
|
||||
const recommended = stringArray(promptInput.recommended);
|
||||
const examples = nestedRecord(data, ["examples"]);
|
||||
assertCondition(usage.some((line) => line.includes("--prompt-stdin")), "help usage should include --prompt-stdin", { usage });
|
||||
assertCondition(usage.some((line) => line.includes("--prompt-file")), "help usage should include --prompt-file", { usage });
|
||||
assertCondition(usage.some((line) => line.includes("cat <<'PROMPT'")), "help usage should include a quoted heredoc example", { usage });
|
||||
const submitSummary = nestedRecord(data, ["submitSummary"]);
|
||||
assertCondition(usage.some((line) => line.includes("codex submit # frozen legacy write entry")), "help usage should document frozen legacy submit", { usage });
|
||||
assertCondition(recommended.includes("--prompt-stdin") && recommended.includes("--prompt-file"), "help should recommend stdin and file prompt sources", promptInput);
|
||||
assertCondition(String(promptInput.sourceRule || "").includes("Exactly one prompt source"), "help should document exact prompt source rule", promptInput);
|
||||
assertCondition(stringArray(examples.stdin).some((line) => line.includes("--prompt-stdin")), "help examples should include stdin command", examples);
|
||||
assertCondition(String(examples.file || "").includes("--prompt-file"), "help examples should include file command", examples);
|
||||
assertCondition(String(submitSummary.default || "").includes("legacy-code-queue-frozen"), "help submit summary should document frozen reason", submitSummary);
|
||||
assertCondition(String(submitSummary.replacement || "").includes("agentrun v01 queue submit"), "help should point new submissions at AgentRun", submitSummary);
|
||||
assertCondition(String(examples.agentRunSubmit || "").includes("agentrun v01 queue submit"), "help examples should include AgentRun submit", examples);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
checks: [
|
||||
"submit --prompt-stdin preserves multiline quotes and newlines",
|
||||
"submit --prompt-file preserves reviewed file contents",
|
||||
"legacy submit --prompt-stdin is frozen and does not echo prompt text",
|
||||
"legacy submit --prompt-file is frozen and does not echo prompt text",
|
||||
"submit positional prompt is redacted from the outer command envelope",
|
||||
"duplicate submit prompt source fails explicitly",
|
||||
"legacy submit duplicate prompt sources still fail at the frozen boundary",
|
||||
"submit success confirms write without echoing prompt",
|
||||
"codex submit help documents stdin/file recommendations and copyable examples",
|
||||
"codex submit help documents frozen legacy submit and AgentRun replacement",
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user