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
|
|
@ -17,7 +17,7 @@ import { scoreQuestionText, detectSlots, isScopeQuestion, countDirectionCards, p
|
|||
export const QUESTION_TOOLS = new Set(["AskUserQuestion", "request_user_input", "ask_user", "askQuestions"]);
|
||||
export const WRITE_TOOLS = new Set(["Write", "Edit", "MultiEdit", "NotebookEdit", "file_change", "apply_patch"]);
|
||||
// 셸 명령 중 파일을 만들거나 바꾸는 것. 판정은 스냅샷(filesChanged)이 주 근거이고 이것은 순서 보조용이다.
|
||||
const SHELL_WRITE_RE = /(?:^|[\s;&|])(?:>|>>|tee\b|Set-Content|Add-Content|Out-File|New-Item|mkdir\b|md\b|touch\b|cp\b|copy\b|mv\b|Move-Item|Copy-Item|apply_patch|npm\s+(?:i|install|init)\b|pnpm\s+(?:add|install|i)\b|npx\b|git\s+(?:commit|add)\b)/i;
|
||||
const SHELL_WRITE_RE = /(?:^|[\s;&|])(?:>|>>|tee\b|Set-Content|Add-Content|Out-File|New-Item|mkdir\b|md\b|touch\b|cp\b|copy\b|mv\b|Move-Item|Copy-Item|apply_patch|npm\s+(?:i|install|add|init)\b|pnpm\s+(?:add|install|i)\b|yarn\s+add\b|bun\s+add\b|pip3?\s+install\b|npx\b|git\s+(?:commit|add)\b)/i;
|
||||
// 방향 체크포인트 전에 쓰면 안 되는 구현 파일
|
||||
export const IMPL_EXT = /\.(?:html?|css|scss|sass|less|m?js|jsx|tsx?|vue|svelte|astro)$/i;
|
||||
// 방향 체크포인트 전에 바꾸면 안 되는 설정·토큰 파일. brief-interview.md §16-4: 답을 받기 전에 3단계 토큰 확정,
|
||||
|
|
@ -30,6 +30,18 @@ export const TEMP_DIR_RE = /(?:^|[\s"'=(:])\/tmp\/|\$\{?TMPDIR\b|%TE?MP%|\$env:T
|
|||
const SHELL_FILE_WRITE_RE = /(?:^|[\s;&|])(?:>|>>|tee\b|Set-Content|Add-Content|Out-File|New-Item|mkdir\b|md\b|touch\b|cp\b|copy\b|mv\b|Move-Item|Copy-Item|apply_patch|git\s+(?:commit|add)\b)/i;
|
||||
const SHELL_LOCAL_INSTALL_RE = /(?:^|[\s;&|])(?:npm\s+(?:i|install|add|init)\b(?![^;&|\n]*\s(?:-g|--global)\b)|pnpm\s+(?:add|install|i)\b(?![^;&|\n]*\s(?:-g|--global)\b)|yarn\s+add\b|bun\s+add\b|pip\s+install\b)/i;
|
||||
|
||||
/**
|
||||
* 쓰기가 아닌 `>` 를 지운 명령 문자열. 정규식 판정 전에 거친다(감사 F028).
|
||||
* - 널 장치·파일 기술자로 가는 리다이렉트: `> /dev/null`, `2>&1`, `> nul`, `> $null`
|
||||
* - 피연산자 뒤의 숫자 비교: `if (1 > 0)`, `print(1 > 0)`
|
||||
* 따옴표 안을 통째로 지우지는 않는다 — `powershell -Command "Set-Content …"` 처럼 명령 전체가 따옴표 안에 오기 때문이다.
|
||||
*/
|
||||
export function stripNonWriteRedirects(cmd) {
|
||||
return String(cmd || "")
|
||||
.replace(/\d?>>?\s*(?:\/dev\/null|nul|\$null|&\d)(?![\w./\\-])/gi, " ")
|
||||
.replace(/(?<=[\w)\]])\s>=?\s*-?\d+(?:\.\d+)?(?![\w./\\-])/g, " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 읽기 전용 경로(expectNoWrites)에서 셸 쓰기 명령을 분류한다.
|
||||
* "write" — 작업 디렉터리를 바꿀 수 있는 쓰기(임시 디렉터리 언급 없음) 또는 로컬 패키지 설치 → FAIL 근거
|
||||
|
|
@ -39,7 +51,7 @@ const SHELL_LOCAL_INSTALL_RE = /(?:^|[\s;&|])(?:npm\s+(?:i|install|add|init)\b(?
|
|||
* `GetTempPath()` 아래 디렉터리 생성을 작업 디렉터리 쓰기로 셌다(스냅샷 변경 0건).
|
||||
*/
|
||||
export function classifyShellWrite(cmd) {
|
||||
const c = String(cmd || "");
|
||||
const c = stripNonWriteRedirects(cmd);
|
||||
if (SHELL_LOCAL_INSTALL_RE.test(c)) return "write";
|
||||
if (SHELL_FILE_WRITE_RE.test(c)) return TEMP_DIR_RE.test(c) ? "temp" : "write";
|
||||
if (SHELL_INSTALL_RE.test(c)) return "install";
|
||||
|
|
@ -102,7 +114,7 @@ function toolEvent(name, input) {
|
|||
name,
|
||||
input,
|
||||
question: QUESTION_TOOLS.has(name),
|
||||
write: WRITE_TOOLS.has(name) || (isShell && SHELL_WRITE_RE.test(cmd)),
|
||||
write: WRITE_TOOLS.has(name) || (isShell && SHELL_WRITE_RE.test(stripNonWriteRedirects(cmd))),
|
||||
paths: toolPaths(input),
|
||||
};
|
||||
}
|
||||
|
|
@ -583,6 +595,24 @@ export function judge(scenario, events, extra = {}) {
|
|||
}
|
||||
|
||||
function judgeCore(scenario, events) {
|
||||
// 텍스트·도구 이벤트가 하나도 없는 실행(로그인 만료, CLI 오류, 타임아웃)은 아무것도 보여주지 않았다.
|
||||
// 이것을 no-trigger 시나리오의 PASS 로 세면 통과율이 부풀려진다.
|
||||
if (!events.some((e) => e.kind === "text" || e.kind === "tool")) {
|
||||
return {
|
||||
skillInvoked: false,
|
||||
asked: false,
|
||||
askChannel: null,
|
||||
questionText: null,
|
||||
slots: [],
|
||||
endedTurnAfterQuestion: null,
|
||||
toolsAfterQuestion: [],
|
||||
wroteBeforeQuestion: [],
|
||||
wroteBeforeAnswer: 0,
|
||||
turnCount: 0,
|
||||
verdict: "ERROR",
|
||||
note: "빈 스트림 — 모델의 텍스트·도구 이벤트가 하나도 없다(로그인 만료·CLI 오류·타임아웃 가능성)",
|
||||
};
|
||||
}
|
||||
const skillInvoked = detectSkillInvoked(events);
|
||||
const turns = splitTurns(events);
|
||||
const t1 = analyzeTurn(turns[0]);
|
||||
|
|
|
|||
102
build/eval/interview/lib/verdict.mjs
Normal file
102
build/eval/interview/lib/verdict.mjs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// 실행 기록 하나의 최종 판정. run.mjs(실행 직후)와 rejudge.mjs(기존 기록 재판정)가 같은 함수를 쓴다.
|
||||
// 둘의 판정이 갈리면 같은 원본에서 한쪽은 ERROR, 한쪽은 PASS 가 나온다(감사 F003).
|
||||
//
|
||||
// 러너가 정상으로 끝나지 못한 실행(spawn 실패, 타임아웃, 비정상 종료, 빈 스트림)은 PASS 도 NO-TRIGGER 도 아니라
|
||||
// ERROR 다. 로그인 만료·CLI 오류·네트워크 장애로 이벤트가 없는 실행이 no-trigger 시나리오의 통과율에 들어가면 안 된다.
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { judge, normalizeClaude, normalizeCodex } from "./judge.mjs";
|
||||
|
||||
/**
|
||||
* 평가 세션이 저장소 지침(AGENTS.md·CLAUDE.md)을 읽었다는 표지. 평가 대상은 스킬이어야 하는데
|
||||
* "게이트를 약화하지 말라"는 저장소 지침을 함께 읽으면 ask/direction 통과율이 부풀려진다(감사 F001).
|
||||
* 스킬 본문에는 이 문자열이 없다(lint 대상 아님 — 평가 사본 기준으로 확인했다).
|
||||
*/
|
||||
export const REPO_CONTEXT_MARKERS = ["designpaca monorepo", "Never soften the step-0 interview gate"];
|
||||
|
||||
/** 파일들에서 저장소 지침 표지를 찾는다. 찾은 파일 경로(중복 없이)를 돌려준다. */
|
||||
export function findRepoContext(files) {
|
||||
const hits = [];
|
||||
for (const f of files) {
|
||||
let text;
|
||||
try {
|
||||
text = fs.readFileSync(f, "utf8");
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (REPO_CONTEXT_MARKERS.some((m) => text.includes(m))) hits.push(f);
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
/** 디렉터리 아래의 .jsonl 파일을 모두 모은다(Codex 롤아웃 등). 없으면 빈 배열. */
|
||||
export function listJsonl(dir) {
|
||||
const out = [];
|
||||
function walk(d) {
|
||||
let entries;
|
||||
try {
|
||||
entries = fs.readdirSync(d, { withFileTypes: true });
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
for (const e of entries) {
|
||||
const full = path.join(d, e.name);
|
||||
if (e.isDirectory()) walk(full);
|
||||
else if (e.isFile() && e.name.endsWith(".jsonl")) out.push(full);
|
||||
}
|
||||
}
|
||||
walk(dir);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 시작 디렉터리의 상위 경로에 프로젝트 지침(AGENTS.md·CLAUDE.md)이나 .git 이 있으면 그 경로를 돌려준다.
|
||||
* Codex·Claude Code 는 작업 디렉터리에서 위로 올라가며 프로젝트 문서를 찾으므로, 평가 작업 디렉터리의 조상에
|
||||
* 이런 파일이 있으면 격리가 깨진다.
|
||||
*/
|
||||
export function findProjectDocsAbove(dir) {
|
||||
let cur = path.resolve(dir);
|
||||
for (;;) {
|
||||
for (const name of ["AGENTS.md", "CLAUDE.md", ".git"]) {
|
||||
if (fs.existsSync(path.join(cur, name))) return path.join(cur, name);
|
||||
}
|
||||
const parent = path.dirname(cur);
|
||||
if (parent === cur) return null;
|
||||
cur = parent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} scenario scenarios.json 의 한 항목
|
||||
* @param {object} record 러너가 쓴 result.json 내용(없으면 {})
|
||||
* @param {string} rawLogPath 원본 스트림 경로
|
||||
* @param {string} runner "codex" 이면 Codex 스트림, 그 밖에는 Claude 스트림으로 읽는다
|
||||
* @param {object} [extra] judge 에 넘기는 러너 밖 측정값
|
||||
* @param {{contextFiles?: string[]}} [opts] contextFiles: 저장소 지침 표지를 찾아볼 추가 파일(Codex 롤아웃 등)
|
||||
*/
|
||||
export function computeVerdict(scenario, record, rawLogPath, runner, extra, opts = {}) {
|
||||
record = record || {};
|
||||
if (record.error) return { verdict: "ERROR", note: String(record.error) };
|
||||
if (record.killedReason) {
|
||||
return { verdict: "ERROR", note: `러너가 정상 종료하지 못했다(${record.killedReason}) — 결과를 판정하지 않는다` };
|
||||
}
|
||||
if (record.exitCode !== undefined && record.exitCode !== null && record.exitCode !== 0) {
|
||||
const tail = record.stderrTail ? `: ${String(record.stderrTail).trim().slice(-200)}` : "";
|
||||
return { verdict: "ERROR", note: `러너가 비정상 종료했다(exit ${record.exitCode})${tail}` };
|
||||
}
|
||||
let raw = "";
|
||||
try {
|
||||
raw = fs.readFileSync(rawLogPath, "utf8");
|
||||
} catch {
|
||||
return { verdict: "ERROR", note: `원본 스트림이 없다: ${rawLogPath}` };
|
||||
}
|
||||
const contaminated = findRepoContext([rawLogPath, ...(opts.contextFiles || [])]);
|
||||
if (contaminated.length) {
|
||||
return {
|
||||
verdict: "ERROR",
|
||||
note: `평가 세션이 저장소 지침(AGENTS.md)을 읽었다 — 격리가 깨져 판정하지 않는다: ${contaminated.map((f) => path.basename(f)).join(", ")}`,
|
||||
};
|
||||
}
|
||||
const events = runner === "codex" ? normalizeCodex(raw) : normalizeClaude(raw);
|
||||
return judge(scenario, events, extra);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue