fix(eval,ci): isolate interview eval and harden skill lint and design gate
- 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/
This commit is contained in:
parent
bc914eafc5
commit
97f2c241e4
19 changed files with 767 additions and 139 deletions
|
|
@ -116,11 +116,32 @@ test("녹화된 트랜스크립트가 전부 판정 케이스에 쓰인다", ()
|
|||
|
||||
test("모든 시나리오의 expect 를 판정기가 안다", () => {
|
||||
for (const s of Object.values(SCENARIOS)) {
|
||||
const r = judge(s, []);
|
||||
const r = judge(s, [{ kind: "text", text: "안녕하세요" }]);
|
||||
assert.notEqual(r.verdict, "ERROR", `${s.id}: ${r.note}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("빈 스트림·init 만 있는 스트림은 어떤 시나리오에서도 ERROR 다(no-trigger 의 가짜 PASS 방지, F003)", () => {
|
||||
for (const s of Object.values(SCENARIOS)) {
|
||||
for (const events of [[], [{ kind: "init", tools: [], skills: [], sessionId: "x" }]]) {
|
||||
const r = judge(s, events);
|
||||
assert.equal(r.verdict, "ERROR", `${s.id}: ${r.verdict} ${r.note}`);
|
||||
assert.match(r.note, /빈 스트림/);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("셸 쓰기 판정: 널 장치 리다이렉트·숫자 비교는 쓰기가 아니고, 실제 쓰기와 yarn/pip/npm add 설치는 쓰기다(F028)", () => {
|
||||
const isWrite = (command) =>
|
||||
normalizeClaude(JSON.stringify({ type: "assistant", message: { content: [{ type: "tool_use", name: "Bash", input: { command } }] } })).find((e) => e.kind === "tool").write;
|
||||
for (const c of ["cat a.md > /dev/null", "echo done > nul", "ls > $null", "ls 2>&1", "cmd 2>/dev/null", 'node -e "if (1 > 0) console.log(1)"', 'python -c "print(1 > 0)"']) {
|
||||
assert.equal(isWrite(c), false, c);
|
||||
}
|
||||
for (const c of ["echo hi > out.txt", "echo hi >out.txt", "yarn add left-pad", "pip install x", "npm add x", "bun add x"]) {
|
||||
assert.equal(isWrite(c), true, c);
|
||||
}
|
||||
});
|
||||
|
||||
test("판정 레코드 필드: 스킬 호출·채널·슬롯·턴 종료", () => {
|
||||
const r = run("sdk-s1-tool-question.ndjson", "S1");
|
||||
assert.equal(r.skillInvoked, true);
|
||||
|
|
|
|||
88
build/eval/interview/test/verdict.test.mjs
Normal file
88
build/eval/interview/test/verdict.test.mjs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
// 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");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue