- Run eval sessions in a temp dir outside the repo so Codex no longer reads the root AGENTS.md; empty streams, timeouts and crashes judge as ERROR instead of PASS - Close interview-gate lint gaps: softening phrases hidden on allowed lines, reordered phrasing, sibling-anchor bypass - design-gate: bold threshold 700, axe incomplete reported as manual checks, follow @import with query strings, report unverified color literals; keep site copy in sync via test - publish-npm.sh fails without NPM_TOKEN; CI requires Node 22.6+; ignore outputs/
88 lines
4.1 KiB
JavaScript
88 lines
4.1 KiB
JavaScript
// lib/verdict.mjs 단위 테스트. 러너가 정상 종료하지 못한 실행은 PASS 가 아니라 ERROR 여야 한다(감사 F003).
|
|
//
|
|
// node --test build/eval/interview/test/verdict.test.mjs
|
|
import { test, before, after } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { computeVerdict, findRepoContext, findProjectDocsAbove } from "../lib/verdict.mjs";
|
|
|
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
const SCENARIOS = Object.fromEntries(JSON.parse(fs.readFileSync(path.join(HERE, "..", "scenarios.json"), "utf8")).map((s) => [s.id, s]));
|
|
const NO_TRIGGER = Object.values(SCENARIOS).find((s) => s.expect === "no-trigger");
|
|
|
|
let tmp;
|
|
before(() => {
|
|
tmp = fs.mkdtempSync(path.join(os.tmpdir(), "dp-verdict-"));
|
|
});
|
|
after(() => {
|
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
});
|
|
|
|
function raw(name, lines) {
|
|
const p = path.join(tmp, name);
|
|
fs.writeFileSync(p, lines.map((l) => JSON.stringify(l)).join("\n"));
|
|
return p;
|
|
}
|
|
// 스킬을 부르지 않고 평범하게 답한 Claude 스트림(no-trigger 시나리오에서는 PASS 여야 한다)
|
|
const okStream = () =>
|
|
raw("ok.ndjson", [
|
|
{ type: "system", subtype: "init", tools: [], session_id: "s" },
|
|
{ type: "assistant", message: { content: [{ type: "text", text: "정규식은 이렇게 씁니다." }] } },
|
|
]);
|
|
|
|
test("정상 종료한 no-trigger 실행은 PASS", () => {
|
|
assert.ok(NO_TRIGGER, "no-trigger 시나리오가 있어야 한다");
|
|
const v = computeVerdict(NO_TRIGGER, { exitCode: 0 }, okStream(), "claude");
|
|
assert.equal(v.verdict, "PASS", v.note);
|
|
});
|
|
|
|
test("빈 원본 스트림 → ERROR (no-trigger 라도 PASS 가 아니다)", () => {
|
|
const p = path.join(tmp, "empty.ndjson");
|
|
fs.writeFileSync(p, "");
|
|
const v = computeVerdict(NO_TRIGGER, { exitCode: 0 }, p, "claude");
|
|
assert.equal(v.verdict, "ERROR");
|
|
assert.match(v.note, /빈 스트림/);
|
|
});
|
|
|
|
test("타임아웃·비0 종료·record.error → ERROR", () => {
|
|
const p = okStream();
|
|
assert.equal(computeVerdict(NO_TRIGGER, { killedReason: "timeout" }, p, "claude").verdict, "ERROR");
|
|
const bad = computeVerdict(NO_TRIGGER, { exitCode: 1, stderrTail: "login expired" }, p, "claude");
|
|
assert.equal(bad.verdict, "ERROR");
|
|
assert.match(bad.note, /exit 1.*login expired/);
|
|
assert.equal(computeVerdict(NO_TRIGGER, { error: "spawn ENOENT" }, p, "claude").verdict, "ERROR");
|
|
});
|
|
|
|
test("원본 스트림 파일이 없으면 ERROR", () => {
|
|
assert.equal(computeVerdict(NO_TRIGGER, {}, path.join(tmp, "missing.ndjson"), "claude").verdict, "ERROR");
|
|
});
|
|
|
|
test("스트림이나 롤아웃에 저장소 AGENTS.md 가 들어 있으면 ERROR (F001 가드)", () => {
|
|
const polluted = raw("polluted.ndjson", [
|
|
{ type: "system", subtype: "init", tools: [], session_id: "s" },
|
|
{ type: "assistant", message: { content: [{ type: "text", text: "# AGENTS.md — designpaca monorepo" }] } },
|
|
]);
|
|
const v = computeVerdict(NO_TRIGGER, { exitCode: 0 }, polluted, "claude");
|
|
assert.equal(v.verdict, "ERROR");
|
|
assert.match(v.note, /격리/);
|
|
|
|
const rollout = path.join(tmp, "rollout.jsonl");
|
|
fs.writeFileSync(rollout, '{"text":"Never soften the step-0 interview gate"}\n');
|
|
const v2 = computeVerdict(NO_TRIGGER, { exitCode: 0 }, okStream(), "claude", {}, { contextFiles: [rollout] });
|
|
assert.equal(v2.verdict, "ERROR");
|
|
assert.deepEqual(findRepoContext([okStream(), rollout]), [rollout]);
|
|
});
|
|
|
|
test("findProjectDocsAbove: 조상에 AGENTS.md 가 있으면 경로를, 없으면 null", () => {
|
|
const root = fs.mkdtempSync(path.join(tmp, "anc-"));
|
|
const deep = path.join(root, "a", "b");
|
|
fs.mkdirSync(deep, { recursive: true });
|
|
fs.writeFileSync(path.join(root, "AGENTS.md"), "x");
|
|
assert.equal(findProjectDocsAbove(deep), path.join(root, "AGENTS.md"));
|
|
// 이 시험의 조상(시스템 임시 디렉터리 위)에는 지침이 없다고 가정하지 않고, 반환형만 확인한다
|
|
const none = findProjectDocsAbove(path.join(os.tmpdir()));
|
|
assert.ok(none === null || typeof none === "string");
|
|
});
|