cuelo 0.10.95 → 0.10.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +32 -32
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +2 -2
- package/.next/required-server-files.json +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/updates/apply/route.js +2 -2
- package/.next/server/app/api/updates/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +4 -4
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recover/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recover.html +1 -1
- package/.next/server/app/recover.rsc +2 -2
- package/.next/server/app/recover.segments/_full.segment.rsc +2 -2
- package/.next/server/app/recover.segments/_head.segment.rsc +1 -1
- package/.next/server/app/recover.segments/_index.segment.rsc +2 -2
- package/.next/server/app/recover.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/recover.segments/recover/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/recover.segments/recover.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +32 -32
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/app/{layout-cf209ec1ffc50146.js → layout-e946c4e8f6b1554d.js} +1 -1
- package/.next/static/chunks/app/{page-248f0f6ee3f5b6ee.js → page-0b878506cec78452.js} +2 -2
- package/.next/trace +108 -108
- package/.next/trace-build +1 -1
- package/README.md +1 -9
- package/Tools/CUELO_Setup/files/native-runtime-patch.js +3 -3
- package/Tools/OMP_Global_Config/agent/agents/maker.md +3 -3
- package/Tools/OMP_Global_Config/agent/extensions/command-guard/index.ts +174 -31
- package/Tools/OMP_Global_Config/agent/extensions/command-guard/matcher.ts +417 -54
- package/Tools/OMP_Global_Config/agent/extensions/command-guard/task-guard.ts +206 -48
- package/Tools/OMP_Global_Config/agent/extensions/cross-review.ts +1 -1
- package/Tools/OMP_Global_Config/agent/extensions/jev-runtime.ts +39 -59
- package/Tools/OMP_Global_Config/agent/extensions/lib/cross-review.ts +214 -43
- package/Tools/OMP_Global_Config/agent/extensions/lib/draft-coverage.ts +7 -2
- package/Tools/OMP_Global_Config/agent/extensions/lib/job-observation.ts +6 -5
- package/Tools/OMP_Global_Config/agent/extensions/lib/maker-routing.ts +35 -7
- package/Tools/OMP_Global_Config/agent/extensions/lib/prepared-task.ts +7 -5
- package/Tools/OMP_Global_Config/agent/extensions/lib/slop-gate.ts +31 -6
- package/Tools/OMP_Global_Config/agent/extensions/report-chart-guard.ts +21 -4
- package/Tools/OMP_Global_Config/agent/extensions/slop-gate/review.ts +67 -16
- package/Tools/OMP_Global_Config/agent/extensions/slop-gate.ts +2 -2
- package/Tools/OMP_Global_Config/agent/extensions/todo-nudge.ts +14 -4
- package/Tools/OMP_Global_Config/agent/rules/deploy-ops.md +1 -0
- package/Tools/OMP_Global_Config/agent/rules/harness-policy.json +14 -10
- package/Tools/OMP_Global_Config/agent/rules/subagent.md +17 -12
- package/Tools/OMP_Global_Config/agent/rules/task-guard.md +5 -3
- package/Tools/OMP_Global_Config/agent/sop/_writer.md +1 -1
- package/Tools/OMP_Global_Config/agent/sop/maker.md +1 -1
- package/Tools/OMP_Global_Config/agent/tools/ci-chain/index.ts +166 -4
- package/Tools/OMP_Global_Config/agent/tools/ci-chain/paths-filter.ts +130 -0
- package/Tools/OMP_Global_Config/agent/tools/git-finalizer/index.ts +20 -1
- package/Tools/OMP_Global_Config/patches/apply-core-patch.mjs +176 -0
- package/bin/self-update.js +2 -1
- package/package.json +7 -7
- /package/.next/static/{njFeZPW-f3RTy2-iTWbzY → VSLxmLHaJ0rBK71SMfdbr}/_buildManifest.js +0 -0
- /package/.next/static/{njFeZPW-f3RTy2-iTWbzY → VSLxmLHaJ0rBK71SMfdbr}/_ssgManifest.js +0 -0
|
@@ -310,7 +310,8 @@ export function commentOnlyEdit(path: string, before: string, after: string, lin
|
|
|
310
310
|
|
|
311
311
|
export type TriggerId = "process-termination" | "deletion" | "destructive-sql" | "deploy-release-migration" | "credentials-auth" | "encoding" | "device-io";
|
|
312
312
|
|
|
313
|
-
|
|
313
|
+
// marker는 바뀐 줄에서만 맞는다. 경로 이름만으로는 걸지 않는다(2026-10-28 사용자 결정: `agent/tools/deploy-verify/index.ts`의 설명 문자열 한 줄 수정이 경로의 deploy만으로 걸렸다).
|
|
314
|
+
interface Marker { id: TriggerId; line: RegExp }
|
|
314
315
|
|
|
315
316
|
// device-io 중 실제 연결을 여는 호출 모양. 브라우저 HTML에서는 이것만 센다(아래 BROWSER_MARKUP_FILE).
|
|
316
317
|
const DEVICE_IO_CALL_SOURCE = String.raw`\bnet\.(?:Socket|connect|createServer)\b|\bnew\s+(?:WebSocket|WebSocketServer|Socket)\s*\(|\bBun\.(?:listen|connect)\s*\(|\.createConnection\s*\(|\bsocket\.(?:write|send|connect|bind)\s*\(`;
|
|
@@ -322,12 +323,10 @@ export const MARKERS: readonly Marker[] = [
|
|
|
322
323
|
{
|
|
323
324
|
id: "deploy-release-migration",
|
|
324
325
|
line: /\b(?:wrangler\s+(?:deploy|publish)|npm\s+publish|gh\s+release|kubectl\s+(?:apply|delete)|terraform\s+apply|alembic\s+(?:upgrade|downgrade)|systemd-run|deploy-live|docker\s+push)\b/i,
|
|
325
|
-
path: /(?:^|\/)(?:deploy|deployment|release|releases|migrations?|alembic)(?:[/._-]|$)|(?:^|\/)[^/]*(?:deploy|release|migrat)[^/]*\.(?:ps1|sh|mjs|js|ts|py|ya?ml)$/i,
|
|
326
326
|
},
|
|
327
327
|
{
|
|
328
328
|
id: "credentials-auth",
|
|
329
329
|
line: /\b(?:password|passwd|api[_-]?key|private[_-]?key|oauth|bearer|(?:access|refresh|id|auth|session)[_-]?token|auth\.json|agent\.db|\.netrc)\b/i,
|
|
330
|
-
path: /(?:^|\/)(?:auth|login|credentials?|oauth|secrets?)[^/]*\.[a-z]+$/i,
|
|
331
330
|
},
|
|
332
331
|
{ id: "encoding", line: /\bBOM\b|\\uFEFF|\bEF\s?BB\s?BF\b|\bcp\d{3,4}\b|\bcode\s?page\b|\bcodepage\b|\beuc-?kr\b|Encoding\.(?:Default|GetEncoding)|\biconv\b|\blatin1\b|\butf-?16\b|\bchcp\b|\bTextDecoder\s*\(\s*["'](?!utf-?8)/i },
|
|
333
332
|
{ id: "device-io", line: new RegExp(String.raw`\b(?:SerialPort|serialport|MSComm|Winsock|modbus|NI-?DAQ|dgram)\b|\bPLC\b|\bCOM\d{1,2}\b|\/dev\/tty|` + DEVICE_IO_CALL_SOURCE) },
|
|
@@ -478,18 +477,17 @@ export interface ChangedLine { line: number; text: string; removed?: boolean }
|
|
|
478
477
|
export interface MarkerHit { trigger: TriggerId; line?: number; text: string; removed?: boolean }
|
|
479
478
|
|
|
480
479
|
/**
|
|
481
|
-
* 변경 줄(추가·삭제 모두)
|
|
480
|
+
* 변경 줄(추가·삭제 모두)에서 marker를 찾는다. 경로 이름은 보지 않는다. 주석만 있는 줄(VB 계열은 `'`·REM 줄도)은 코드가 아니므로 보지 않는다.
|
|
482
481
|
* device-io는 문자열 리터럴 내용을 지운 줄에서 다시 맞아야 센다: 화면 문구("PLC Communication")만으로는 장치 입출력이 아니다.
|
|
483
482
|
*/
|
|
484
483
|
export function detectMarkers(path: string, lines: readonly ChangedLine[]): MarkerHit[] {
|
|
485
484
|
const hits: MarkerHit[] = [];
|
|
486
485
|
const normalized = path.replaceAll("\\", "/");
|
|
487
486
|
const vb = VB_FILE.test(normalized);
|
|
488
|
-
for (const marker of MARKERS) if (marker.path?.test(normalized)) hits.push({ trigger: marker.id, text: `path ${normalized}` });
|
|
489
487
|
for (const { line, text, removed } of lines) {
|
|
490
488
|
if (COMMENT_LINE.test(text) || (vb && VB_COMMENT_LINE.test(text))) continue;
|
|
491
489
|
for (const marker of MARKERS) {
|
|
492
|
-
if (!marker.line
|
|
490
|
+
if (!marker.line.test(text)) continue;
|
|
493
491
|
if (marker.id === "device-io" && !(BROWSER_MARKUP_FILE.test(normalized) ? DEVICE_IO_CALL : marker.line).test(stripStringLiterals(text, vb))) continue;
|
|
494
492
|
hits.push({ trigger: marker.id, line, removed, text: text.trim().slice(0, 100) });
|
|
495
493
|
}
|
|
@@ -928,12 +926,44 @@ const SAMPLE_EXCLUDED = /\.(?:sln|slnx|csproj|vbproj|vcxproj|props|targets|resx|
|
|
|
928
926
|
/** 표본에 뽑힌 커밋에서 표본 이유로 요구하는 최대 파일 수(바뀐 줄이 많은 순, 같으면 경로 순). */
|
|
929
927
|
export const SAMPLE_MAX_FILES = 5;
|
|
930
928
|
|
|
931
|
-
/**
|
|
932
|
-
|
|
929
|
+
/**
|
|
930
|
+
* 통과한 옛 내용에 사소한 수정만 더한 지금 내용을 덮는 통과. kind는 그 수정이다: version은 버전 문자열만(2026-10-27 사용자 결정), comment는
|
|
931
|
+
* TypeScript 파서로 증명한 주석·공백만(2026-10-28 사용자 결정) 바뀐 것이다. 게이트가 HEAD에 대해 면제하는 수정과 같은 범위다.
|
|
932
|
+
*/
|
|
933
|
+
export interface CarriedPass { path: string; blob: string; fromBlob: string; reviewId: string; kind: "version" | "comment" }
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* 두 내용에서 글자가 달라진 줄(줄 다중집합의 차이). 순서만 바뀐 줄은 나오지 않는다. 통과한 옛 내용과 지금 내용을 비교할 때 commentOnlyEdit이
|
|
937
|
+
* 지시 주석 줄을 찾는 데 쓴다. 옛 내용 쪽 줄은 removed다.
|
|
938
|
+
*/
|
|
939
|
+
export function changedLinesBetween(before: string, after: string): ChangedLine[] {
|
|
940
|
+
const side = (from: readonly string[], against: readonly string[], removed: boolean): ChangedLine[] => {
|
|
941
|
+
const left = new Map<string, number>();
|
|
942
|
+
for (const text of against) left.set(text, (left.get(text) ?? 0) + 1);
|
|
943
|
+
return from.flatMap((text, index) => {
|
|
944
|
+
const count = left.get(text) ?? 0;
|
|
945
|
+
if (count > 0) { left.set(text, count - 1); return []; }
|
|
946
|
+
return [{ line: index + 1, text: text.replace(/\r$/, ""), ...(removed ? { removed: true } : {}) }];
|
|
947
|
+
});
|
|
948
|
+
};
|
|
949
|
+
const old = before.split("\n");
|
|
950
|
+
const now = after.split("\n");
|
|
951
|
+
return [...side(old, now, true), ...side(now, old, false)];
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* 통과한 옛 내용 → 지금 내용이 게이트가 HEAD에 대해 면제하는 사소한 수정인가: 버전 문자열만 바뀜(versionOnlyChange), 또는 TS/JS에서 주석·공백만
|
|
956
|
+
* 바뀜(commentOnlyEdit). 둘이 섞였거나 다른 언어의 주석 수정, 순서만 바꾼 수정은 코드로 본다(undefined).
|
|
957
|
+
*/
|
|
958
|
+
export function trivialSincePass(path: string, before: string, after: string, parser: TsParser | null = loadTypeScript()): CarriedPass["kind"] | undefined {
|
|
959
|
+
if (versionOnlyChange(before, after)) return "version";
|
|
960
|
+
if (/\.[cm]?[jt]sx?$/i.test(path) && commentOnlyEdit(path, before, after, changedLinesBetween(before, after), parser)) return "comment";
|
|
961
|
+
return undefined;
|
|
962
|
+
}
|
|
933
963
|
|
|
934
964
|
/**
|
|
935
965
|
* 검토가 필요한 파일과 덮이지 않은 파일을 정한다. highRisk는 high-risk로 선언한 저장소 상대 경로다. passedContent는 `${path}\0${blob}` → 그 경로의
|
|
936
|
-
* 통과한 옛 내용이며, 지금 내용이 그
|
|
966
|
+
* 통과한 옛 내용이며, 지금 내용이 그 내용에서 사소한 수정(trivialSincePass)만 다르고 그 통과에 묶인 입력이 그대로면 그 통과가 지금 내용을 덮는다(carried).
|
|
937
967
|
*/
|
|
938
968
|
export function decideGate(changes: readonly ChangedFile[], highRisk: Iterable<string>, records: readonly CrossReviewLedgerRecord[], inputBlobs: ReadonlyMap<string, string> = new Map(), passedContent: ReadonlyMap<string, string> = new Map()): GateDecision & { carried?: CarriedPass[] } {
|
|
939
969
|
// 표본은 지금처럼 커밋의 코드 경로 전체(path+blob)로 뽑는다. 뽑힌 뒤 표본 이유로 요구하는 것은 게이트 대상(주석·버전만 바뀐 수정·바이너리 자산 제외) 중
|
|
@@ -976,18 +1006,19 @@ export function decideGate(changes: readonly ChangedFile[], highRisk: Iterable<s
|
|
|
976
1006
|
const text = now.toString("utf8");
|
|
977
1007
|
for (const [fromBlob, older] of blobs) {
|
|
978
1008
|
const content = passedContent.get(`${file.path}\0${fromBlob}`);
|
|
979
|
-
const
|
|
980
|
-
|
|
1009
|
+
const kind = content === undefined ? undefined : trivialSincePass(file.path, content, text);
|
|
1010
|
+
const pass = kind ? older.find((item) => changedInputs(item.inputs, inputBlobs).length === 0) : undefined;
|
|
1011
|
+
if (pass && kind) { carried.push({ path: file.path, blob: file.blob, fromBlob, reviewId: pass.reviewId, kind }); return []; }
|
|
981
1012
|
}
|
|
982
1013
|
}
|
|
983
|
-
return [{ ...file, note: blobs ? "a passed review exists for an older version of this file; the content changed after the pass" : undefined }];
|
|
1014
|
+
return [{ ...file, note: blobs ? "a passed review exists for an older version of this file; the content changed after the pass by more than version strings or TS/JS comments and whitespace, so the new code needs a review (a later round of the same chain shows only the delta)" : undefined }];
|
|
984
1015
|
});
|
|
985
1016
|
return { required, uncovered, ...(carried.length > 0 ? { carried } : {}) };
|
|
986
1017
|
}
|
|
987
1018
|
|
|
988
1019
|
/**
|
|
989
1020
|
* 통과한 옛 blob의 내용. git 객체(`git cat-file blob`)에 있으면 그것을, 없으면 그 blob을 기록한 검토 라운드의 사본(manifest)에서 읽는다.
|
|
990
|
-
* 둘 다 없으면 undefined이며 그 통과는
|
|
1021
|
+
* 둘 다 없으면 undefined이며 그 통과는 사소한 수정(trivialSincePass)만 더한 지금 내용을 덮지 못한다.
|
|
991
1022
|
*/
|
|
992
1023
|
async function passedBlobContent(exec: Exec, git: string, root: string, path: string, blob: string, records: readonly CrossReviewLedgerRecord[]): Promise<string | undefined> {
|
|
993
1024
|
const shown = await exec(git, ["cat-file", "blob", blob], { cwd: root });
|
|
@@ -1075,7 +1106,7 @@ export async function runGate(options: GateOptions): Promise<GateOutcome> {
|
|
|
1075
1106
|
// 통과에 묶인 의존 입력은 그 통과가 이 변경을 덮을 때만 지금 blob을 읽는다. 입력 없는 통과만 있으면 아무것도 읽지 않는다.
|
|
1076
1107
|
let inputBlobs = await currentInputBlobs(exec, git, resolved.root, boundInputPaths(changed, records));
|
|
1077
1108
|
let decision = decideGate(changed, highRiskPaths, records, inputBlobs);
|
|
1078
|
-
// 옛 내용에만 통과가 있는 파일은 그 옛 내용을 찾아(git 객체, 없으면 검토 사본) 버전
|
|
1109
|
+
// 옛 내용에만 통과가 있는 파일은 그 옛 내용을 찾아(git 객체, 없으면 검토 사본) 버전 문자열·주석만 바뀌었는지 본다. 찾지 못하면 이어받지 않는다.
|
|
1079
1110
|
const older = decision.uncovered.filter((file) => file.note?.startsWith("a passed review exists for an older version"));
|
|
1080
1111
|
if (older.length > 0) {
|
|
1081
1112
|
const covered = coveredBlobs(records);
|
|
@@ -1126,7 +1157,8 @@ export async function runGate(options: GateOptions): Promise<GateOutcome> {
|
|
|
1126
1157
|
|
|
1127
1158
|
export const REVIEW_SYSTEM = "You are a careful independent code reviewer. You have no tools; answer only from the material in the user message.";
|
|
1128
1159
|
|
|
1129
|
-
|
|
1160
|
+
/** part: 한 파일을 여러 조각으로 나눠 심사할 때만 `k/m`(m 조각 중 k번째). */
|
|
1161
|
+
export interface ReviewPart { path: string; kind: "diff" | "new-file" | "delta" | "new-since-last-round" | "deleted"; text: string; part?: string }
|
|
1130
1162
|
|
|
1131
1163
|
const CHECKLIST = [
|
|
1132
1164
|
"1. Safety first: any path where the change touches something it must not (wrong process/file/record/user killed, deleted, overwritten or exposed; secret leaked; auth bypassed)? Quote the code.",
|
|
@@ -1151,8 +1183,8 @@ const PROBE_ROUND_RULES = [
|
|
|
1151
1183
|
|
|
1152
1184
|
const MAX_HIDING_LEADS_SHOWN = 20;
|
|
1153
1185
|
|
|
1154
|
-
export function buildReviewPrompt(input: { acceptance: string; round: number; parts: ReviewPart[]; previousFindings?: CrossReviewFinding[]; inputs?: { path: string; text: string }[]; references?: { path: string; text: string }[]; probeResults?: PreparedProbeResult[]; probeAvailable?: boolean; hidingLeads?: readonly HidingLead[] }): string {
|
|
1155
|
-
const blocks = input.parts.map((part) => `<${part.kind} path="${part.path}">\n${part.text}\n</${part.kind}>`);
|
|
1186
|
+
export function buildReviewPrompt(input: { acceptance: string; round: number; parts: ReviewPart[]; previousFindings?: CrossReviewFinding[]; inputs?: { path: string; text: string }[]; references?: { path: string; text: string }[]; probeResults?: PreparedProbeResult[]; probeAvailable?: boolean; hidingLeads?: readonly HidingLead[]; batch?: { index: number; count: number } }): string {
|
|
1187
|
+
const blocks = input.parts.map((part) => `<${part.kind} path="${part.path}"${part.part ? ` part="${part.part}"` : ""}>\n${part.text}\n</${part.kind}>`);
|
|
1156
1188
|
const references = input.references ?? [];
|
|
1157
1189
|
const inputs = input.inputs ?? [];
|
|
1158
1190
|
const inputBlocks = inputs.length > 0
|
|
@@ -1212,6 +1244,7 @@ export function buildReviewPrompt(input: { acceptance: string; round: number; pa
|
|
|
1212
1244
|
input.acceptance.trim(),
|
|
1213
1245
|
"",
|
|
1214
1246
|
scope,
|
|
1247
|
+
...(input.batch ? [`SPLIT REVIEW: this change is larger than one call can hold, so it is reviewed in ${input.batch.count} separate calls with the same criteria and the same earlier findings. This call shows part ${input.batch.index} of ${input.batch.count}. Files or hunks not shown here are reviewed in the other parts: do not report anything as missing or broken only because it is not in this part. A block with part="k/m" is piece k of a file cut into m pieces.`] : []),
|
|
1215
1248
|
"",
|
|
1216
1249
|
...previous,
|
|
1217
1250
|
"CHECKLIST (apply each; report only real problems you can support with a quote from the code):",
|
|
@@ -1236,6 +1269,91 @@ export function buildReviewPrompt(input: { acceptance: string; round: number; pa
|
|
|
1236
1269
|
].join("\n");
|
|
1237
1270
|
}
|
|
1238
1271
|
|
|
1272
|
+
/** 한 라운드를 나눠 심사할 때 reviewer 자리마다 부르는 최대 호출 수(2026-10-28 사용자 결정). 넘으면 나누지 않고 거절한다. */
|
|
1273
|
+
export const MAX_REVIEW_BATCHES = 8;
|
|
1274
|
+
/** 나눈 호출마다 변경에 남아야 하는 최소 바이트. 공통 부분(기준·앞 지적·입력·참고·probe 결과)이 이보다 적게 남기면 나눠도 심사가 되지 않아 거절한다. */
|
|
1275
|
+
const MIN_BATCH_CHANGE_BYTES = 16 * 1024;
|
|
1276
|
+
/** 조각 머리표·구분 줄을 어림한 값과 실제 프롬프트의 차이를 덮는 여유. */
|
|
1277
|
+
const BATCH_MARGIN_BYTES = 2 * 1024;
|
|
1278
|
+
|
|
1279
|
+
/** 한 줄을 limit 바이트 이하 조각으로 자른다(UTF-8 최대 4바이트로 어림해 글자 수로 자른다). 보통의 줄은 그대로다. */
|
|
1280
|
+
function cutLine(line: string, limit: number): string[] {
|
|
1281
|
+
if (utf8(line) < limit) return [line];
|
|
1282
|
+
const chars = Math.max(1, Math.floor((limit - 1) / 4));
|
|
1283
|
+
const out: string[] = [];
|
|
1284
|
+
for (let start = 0; start < line.length; start += chars) out.push(line.slice(start, start + chars));
|
|
1285
|
+
return out;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* 변경 조각 하나를 budget 바이트 이하 조각으로 자른다. diff·delta는 hunk(`@@`) 단위로 묶고(머리말은 첫 hunk와 함께), 새 파일 전체는 줄 단위로 묶는다.
|
|
1290
|
+
* 한 단위가 budget보다 크면 줄 경계에서, 한 줄이 그보다 크면 줄 안에서 자른다. 나눈 조각에는 part="k/m"이 붙는다. budget 안이면 그대로 돌려준다.
|
|
1291
|
+
*/
|
|
1292
|
+
export function splitPart(part: ReviewPart, budget: number): ReviewPart[] {
|
|
1293
|
+
if (utf8(part.text) <= budget) return [part];
|
|
1294
|
+
const diffLike = part.kind === "diff" || part.kind === "delta";
|
|
1295
|
+
const units: string[][] = [];
|
|
1296
|
+
let current: string[] = [];
|
|
1297
|
+
let hunk = false;
|
|
1298
|
+
for (const line of part.text.split("\n")) {
|
|
1299
|
+
if (current.length > 0 && (diffLike ? line.startsWith("@@") && hunk : true)) { units.push(current); current = []; hunk = false; }
|
|
1300
|
+
current.push(line);
|
|
1301
|
+
if (line.startsWith("@@")) hunk = true;
|
|
1302
|
+
}
|
|
1303
|
+
units.push(current);
|
|
1304
|
+
const chunks: string[][] = [];
|
|
1305
|
+
let chunk: string[] = [];
|
|
1306
|
+
let used = 0;
|
|
1307
|
+
const close = () => { if (chunk.length > 0) { chunks.push(chunk); chunk = []; used = 0; } };
|
|
1308
|
+
for (const unit of units) {
|
|
1309
|
+
const size = unit.reduce((sum, line) => sum + utf8(line) + 1, 0);
|
|
1310
|
+
if (used + size > budget && size <= budget) close();
|
|
1311
|
+
for (const line of unit) {
|
|
1312
|
+
for (const piece of cutLine(line, budget)) {
|
|
1313
|
+
const bytes = utf8(piece) + 1;
|
|
1314
|
+
if (used + bytes > budget) close();
|
|
1315
|
+
chunk.push(piece);
|
|
1316
|
+
used += bytes;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
close();
|
|
1321
|
+
return chunks.map((lines, index) => ({ ...part, text: lines.join("\n"), part: `${index + 1}/${chunks.length}` }));
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
export type ReviewPlan = { prompts: string[] } | { refused: "shared-context" } | { refused: "too-many-batches"; batches: number };
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* 한 라운드의 reviewer 프롬프트. 한 번에 MAX_INPUT_BYTES 안에 들면 하나다. 넘으면 거절하지 않고(2026-10-28 사용자 결정) 변경 조각을 순서대로 묶어 나눈다:
|
|
1328
|
+
* 큰 파일은 splitPart로 자르고, 공통 부분(기준·앞 지적·입력·참고·probe 결과)은 모든 호출에 싣고, 숨김 단서는 그 호출에 실린 파일 것만 붙인다.
|
|
1329
|
+
* 공통 부분만으로 상한에 가까우면 shared-context, 나눈 호출이 MAX_REVIEW_BATCHES를 넘으면 too-many-batches로 거절 이유를 돌려준다.
|
|
1330
|
+
* build는 조각·단서·나눈 번호로 프롬프트 한 개를 만든다(buildReviewPrompt에 나머지 인자를 묶은 것).
|
|
1331
|
+
*/
|
|
1332
|
+
export function planReviewPrompts(parts: readonly ReviewPart[], leads: readonly HidingLead[], build: (parts: ReviewPart[], leads: readonly HidingLead[], batch?: { index: number; count: number }) => string): ReviewPlan {
|
|
1333
|
+
const single = build([...parts], leads);
|
|
1334
|
+
if (utf8(single) <= MAX_INPUT_BYTES) return { prompts: [single] };
|
|
1335
|
+
const leadBytes = leads.slice(0, MAX_HIDING_LEADS_SHOWN).reduce((sum, lead) => sum + utf8(lead.path) + utf8(lead.text) + 48, 1024);
|
|
1336
|
+
const budget = MAX_INPUT_BYTES - utf8(build([], [], { index: MAX_REVIEW_BATCHES, count: MAX_REVIEW_BATCHES })) - leadBytes - BATCH_MARGIN_BYTES;
|
|
1337
|
+
if (budget < MIN_BATCH_CHANGE_BYTES) return { refused: "shared-context" };
|
|
1338
|
+
const tag = (part: ReviewPart) => 2 * part.kind.length + utf8(part.path) + 48;
|
|
1339
|
+
const groups: ReviewPart[][] = [];
|
|
1340
|
+
let group: ReviewPart[] = [];
|
|
1341
|
+
let used = 0;
|
|
1342
|
+
for (const piece of parts.flatMap((part) => splitPart(part, budget - tag(part)))) {
|
|
1343
|
+
const size = utf8(piece.text) + tag(piece);
|
|
1344
|
+
if (group.length > 0 && used + size > budget) { groups.push(group); group = []; used = 0; }
|
|
1345
|
+
group.push(piece);
|
|
1346
|
+
used += size;
|
|
1347
|
+
}
|
|
1348
|
+
if (group.length > 0) groups.push(group);
|
|
1349
|
+
if (groups.length > MAX_REVIEW_BATCHES) return { refused: "too-many-batches", batches: groups.length };
|
|
1350
|
+
const prompts = groups.map((batch, index) => {
|
|
1351
|
+
const shown = new Set(batch.map((part) => part.path));
|
|
1352
|
+
return build(batch, leads.filter((lead) => shown.has(lead.path)), groups.length > 1 ? { index: index + 1, count: groups.length } : undefined);
|
|
1353
|
+
});
|
|
1354
|
+
return prompts.some((prompt) => utf8(prompt) > MAX_INPUT_BYTES) ? { refused: "shared-context" } : { prompts };
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1239
1357
|
export interface ParsedFinding { severity: CrossReviewFinding["severity"]; file: string; line?: number; claim: string; why: string; probe?: CrossReviewProbe }
|
|
1240
1358
|
export interface ParsedVerdict { id: string; verdict: CrossReviewVerdict["verdict"]; why: string }
|
|
1241
1359
|
|
|
@@ -1511,6 +1629,10 @@ export interface ReviewResult {
|
|
|
1511
1629
|
probeResults?: CrossReviewProbeResultMeta[];
|
|
1512
1630
|
/** probe 라운드에서만: 결과를 받은 finding마다 reviewer의 판단(자문). 어떤 finding도 자동으로 닫지 않는다. */
|
|
1513
1631
|
verdicts?: CrossReviewVerdict[];
|
|
1632
|
+
/** 이어지는 라운드에서 files·acceptance를 생략해 체인에서 이어받았을 때만: 이어받은 인자 이름. */
|
|
1633
|
+
carriedOver?: ("files" | "acceptance")[];
|
|
1634
|
+
/** 변경이 한 번의 호출 상한을 넘어 나눠 심사했을 때만: reviewer 자리마다 부른 호출 수(모두 같은 기준·같은 라운드). */
|
|
1635
|
+
batches?: number;
|
|
1514
1636
|
}
|
|
1515
1637
|
|
|
1516
1638
|
interface ReferenceEntry { path: string; blob: string; bytes: number; redacted?: number; text: string; content: Buffer }
|
|
@@ -1803,8 +1925,8 @@ function writeContextFiles(dir: string, entries: readonly ReferenceEntry[], pref
|
|
|
1803
1925
|
writeFileSync(join(dir, manifestName), JSON.stringify(manifest), { mode: 0o600 });
|
|
1804
1926
|
}
|
|
1805
1927
|
|
|
1806
|
-
/** reviewer 한 명의 호출 결과. error가 있으면 실패(text는 부분 답일 수 있다). */
|
|
1807
|
-
interface ReviewerOutcome { family: Lane; model: string; text: string; elapsedMs: number; error?: string }
|
|
1928
|
+
/** reviewer 한 명의 호출 결과. error가 있으면 실패(text는 부분 답일 수 있다). batches는 나눠 심사한 라운드에서 호출마다의 답이고, text는 그 답을 이어 붙인 원문이다. */
|
|
1929
|
+
interface ReviewerOutcome { family: Lane; model: string; text: string; elapsedMs: number; error?: string; batches?: string[] }
|
|
1808
1930
|
|
|
1809
1931
|
/**
|
|
1810
1932
|
* reviewer 결과를 원장 모양으로 읽는다. 답 전문은 사본 디렉터리의 raw-<자리>.txt에 쓰고 원장에는 앞 20 KB 발췌를 남긴다.
|
|
@@ -1820,12 +1942,14 @@ function readReviewerOutcome(item: ReviewerOutcome, round: number, snapshotDir:
|
|
|
1820
1942
|
if (item.error !== undefined) {
|
|
1821
1943
|
return { reviewer: { family: item.family, model: item.model, status: "error", elapsedMs: item.elapsedMs, error: item.error, ...(item.text ? keepRaw() : {}), ...advisory }, findings: [], ...(item.text ? { rawChars: item.text.length } : {}) };
|
|
1822
1944
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1945
|
+
// 나눠 심사했으면 호출마다의 답을 따로 읽고, 하나라도 해석할 수 없으면 그 자리 전체가 해석 불가다(나머지 답만으로 깨끗하다고 볼 수 없다).
|
|
1946
|
+
const answers = (item.batches ?? [item.text]).map((text) => parseReviewerOutput(text));
|
|
1947
|
+
const usable = answers.flatMap((answer) => (answer.ok ? [answer] : []));
|
|
1948
|
+
if (usable.length !== answers.length) return { reviewer: { family: item.family, model: item.model, status: "unparsable", elapsedMs: item.elapsedMs, ...keepRaw(), ...advisory }, findings: [], rawChars: item.text.length };
|
|
1825
1949
|
return {
|
|
1826
1950
|
reviewer: { family: item.family, model: item.model, status: "ok", elapsedMs: item.elapsedMs, ...advisory },
|
|
1827
|
-
findings:
|
|
1828
|
-
verdicts:
|
|
1951
|
+
findings: usable.flatMap((answer) => answer.findings).map((finding, index) => ({ id: `R${round}-${LANE_TAG[item.family]}-${index + 1}`, reviewer: item.model, ...finding })),
|
|
1952
|
+
verdicts: usable.flatMap((answer) => answer.verdicts ?? []),
|
|
1829
1953
|
};
|
|
1830
1954
|
}
|
|
1831
1955
|
|
|
@@ -1858,17 +1982,19 @@ function recordLateAdvisory(outcome: ReviewerOutcome, review: CrossReviewRecord,
|
|
|
1858
1982
|
return undefined;
|
|
1859
1983
|
}
|
|
1860
1984
|
|
|
1985
|
+
/** 라운드 사본 디렉터리에 남기는 그 라운드의 acceptance. 이어지는 라운드가 acceptance를 생략하면 바로 앞 라운드의 것만 이어받는다(원장에는 싣지 않는다). */
|
|
1986
|
+
const ACCEPTANCE_FILE = "acceptance.txt";
|
|
1987
|
+
|
|
1861
1988
|
export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: AbortSignal): Promise<ReviewResult> {
|
|
1862
1989
|
const now = deps.now ?? (() => new Date());
|
|
1863
|
-
const
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
throw new Error(`${missing.join(" ")}${later}`);
|
|
1990
|
+
const given = [...new Set(input.files.map((file) => file.trim()).filter(Boolean))];
|
|
1991
|
+
if (!input.previousReviewId) {
|
|
1992
|
+
// 둘을 따로 알리면 한 번에 하나씩 두 번 거절됐다(10-24 01:36).
|
|
1993
|
+
const missing = [
|
|
1994
|
+
...(given.length === 0 ? ["files must list at least one cwd-relative path."] : []),
|
|
1995
|
+
...(!input.acceptance.trim() ? ["acceptance must state the criteria the change is reviewed against."] : []),
|
|
1996
|
+
];
|
|
1997
|
+
if (missing.length > 0) throw new Error(missing.join(" "));
|
|
1872
1998
|
}
|
|
1873
1999
|
|
|
1874
2000
|
const records = deps.readAll();
|
|
@@ -1900,6 +2026,28 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
1900
2026
|
} else {
|
|
1901
2027
|
families = reviewerLanes(input.authors, deps.mainModel, deps.advisoryModel);
|
|
1902
2028
|
}
|
|
2029
|
+
// 이어지는 라운드가 files·acceptance를 생략하면 체인에서 이어받는다(2026-10-28 사용자 결정: 이어받지 않아 거절된 호출 4건). files는 체인의 모든
|
|
2030
|
+
// 라운드가 본 파일, acceptance는 바로 앞 라운드가 사본에 남긴 기준이다. 주면 준 값이 그대로 쓰인다(files는 앞 라운드 파일에 더해진다).
|
|
2031
|
+
const carriedOver: ("files" | "acceptance")[] = [];
|
|
2032
|
+
let files = given;
|
|
2033
|
+
let acceptance = input.acceptance;
|
|
2034
|
+
if (previous) {
|
|
2035
|
+
if (files.length === 0) {
|
|
2036
|
+
const from = previous.root;
|
|
2037
|
+
files = [...new Set(chain.flatMap((record) => record.files.map((file) => file.path)))].map((path) => relative(deps.cwd, join(from, ...path.split("/"))).split(sep).join("/"));
|
|
2038
|
+
if (files.length > 0) carriedOver.push("files");
|
|
2039
|
+
}
|
|
2040
|
+
if (!acceptance.trim()) {
|
|
2041
|
+
// 바로 앞 라운드의 기준만 쓴다. 그것을 읽지 못하면 더 앞 라운드의 기준으로 바꾸지 않는다(라운드마다 기준이 달라질 수 있다).
|
|
2042
|
+
try { acceptance = readFileSync(join(previous.snapshotDir, ACCEPTANCE_FILE), "utf8"); } catch { /* 2026-10-28 전 라운드는 남기지 않았다 */ }
|
|
2043
|
+
if (acceptance.trim()) carriedOver.push("acceptance");
|
|
2044
|
+
}
|
|
2045
|
+
const missing = [
|
|
2046
|
+
...(files.length === 0 ? [`files must list at least one cwd-relative path: the chain of ${previous.reviewId} has no reviewed file to carry over.`] : []),
|
|
2047
|
+
...(!acceptance.trim() ? [`acceptance must state the criteria the change is reviewed against: round ${previous.round} (${previous.reviewId}) has no stored acceptance to carry over (rounds recorded before 2026-10-28 did not keep it), so send it again.`] : []),
|
|
2048
|
+
];
|
|
2049
|
+
if (missing.length > 0) throw new Error(missing.join(" "));
|
|
2050
|
+
}
|
|
1903
2051
|
// 앞 라운드에 늦게 붙은 자문 finding도 체인의 지적이다(프롬프트의 앞 지적·probe 대상·resolve 모두 같은 목록을 쓴다).
|
|
1904
2052
|
const chainFindings = chainFindingsOf(records, chain);
|
|
1905
2053
|
// probe 결과는 코드를 읽기 전에 거른다: 잘못된 입력이 git 수집과 사본 쓰기 뒤에야 드러나지 않게 한다.
|
|
@@ -2021,28 +2169,35 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
2021
2169
|
const safeText = redactSecrets(lead.text);
|
|
2022
2170
|
return { ...lead, text: safeText.blocked ? "" : safeText.text.slice(0, 100) };
|
|
2023
2171
|
});
|
|
2024
|
-
const
|
|
2025
|
-
acceptance
|
|
2172
|
+
const plan = planReviewPrompts(parts, hidingLeads, (shownParts, shownLeads, batch) => buildReviewPrompt({
|
|
2173
|
+
acceptance, round, parts: shownParts,
|
|
2026
2174
|
inputs: inputEntries.map(({ path, text }) => ({ path, text })),
|
|
2027
2175
|
previousFindings: previous ? chainFindings : undefined,
|
|
2028
2176
|
references: references.map(({ path, text }) => ({ path, text })),
|
|
2029
2177
|
probeResults: preparedProbes,
|
|
2030
2178
|
probeAvailable: round < MAX_ROUNDS && !probeRound && probesBefore < MAX_PROBE_ROUNDS,
|
|
2031
|
-
hidingLeads,
|
|
2032
|
-
});
|
|
2033
|
-
|
|
2034
|
-
if (promptBytes > MAX_INPUT_BYTES) {
|
|
2179
|
+
hidingLeads: shownLeads, batch,
|
|
2180
|
+
}));
|
|
2181
|
+
if ("refused" in plan) {
|
|
2035
2182
|
// 전체 바이트만 알리면 작은 파일을 빼도 줄지 않는 이유를 Main이 직접 재야 했다(10-23, 13→6→5개 파일에 490KB→472KB).
|
|
2036
2183
|
const pieces = [
|
|
2037
2184
|
...parts.map((part) => ({ label: `${part.path} (${part.kind})`, bytes: utf8(part.text) })),
|
|
2038
2185
|
...inputEntries.map((entry) => ({ label: `${entry.path} (input)`, bytes: utf8(entry.text) })),
|
|
2039
2186
|
...references.map((reference) => ({ label: `${reference.path} (reference)`, bytes: utf8(reference.text) })),
|
|
2040
|
-
{ label: "acceptance", bytes: utf8(
|
|
2187
|
+
{ label: "acceptance", bytes: utf8(acceptance) },
|
|
2188
|
+
// 앞 지적·probe 결과도 모든 호출에 실린다. 공통 부분 때문에 거절될 때 무엇을 줄일지 보이게 함께 센다.
|
|
2189
|
+
...(previous && chainFindings.length > 0 ? [{ label: `earlier findings (${chainFindings.length})`, bytes: utf8(chainFindings.map((finding) => `${finding.id} ${finding.file} ${finding.claim}`).join("\n")) }] : []),
|
|
2190
|
+
...(preparedProbes.length > 0 ? [{ label: `probe results (${preparedProbes.length})`, bytes: preparedProbes.reduce((sum, result) => sum + utf8(result.command) + utf8(result.output), 0) }] : []),
|
|
2041
2191
|
].sort((a, b) => b.bytes - a.bytes);
|
|
2042
2192
|
const largest = pieces.slice(0, 5).map((piece) => `${piece.label} ${piece.bytes} bytes`).join(", ");
|
|
2043
2193
|
const more = pieces.length > 5 ? `, and ${pieces.length - 5} more` : "";
|
|
2044
|
-
|
|
2194
|
+
const total = pieces.reduce((sum, piece) => sum + piece.bytes, 0);
|
|
2195
|
+
const why = plan.refused === "too-many-batches"
|
|
2196
|
+
? `the change would need ${plan.batches} calls per reviewer, above the limit of ${MAX_REVIEW_BATCHES} (each call holds at most ${MAX_INPUT_BYTES} bytes, about 75k-100k tokens, so one model call finishes within the ${REVIEW_TIMEOUT_MS / 60000} minute timeout)`
|
|
2197
|
+
: `the part shared by every call (acceptance, earlier findings, inputs, references, probe results) leaves less than ${MIN_BATCH_CHANGE_BYTES} of the ${MAX_INPUT_BYTES} bytes one call can hold for the change, so splitting the change cannot help`;
|
|
2198
|
+
throw new Error(`Review input is about ${total} bytes and cannot be reviewed: ${why}. Nothing was sent. Split the change into separate reviews by file or topic, or trim the inputs and references. Largest pieces: ${largest}${more}.`);
|
|
2045
2199
|
}
|
|
2200
|
+
const { prompts } = plan;
|
|
2046
2201
|
// 검토 본문을 모은 뒤 파일이 바뀌었으면 reviewer가 본 내용과 사본이 어긋나므로 쓰지 않고 다시 하게 한다.
|
|
2047
2202
|
const settledBlobs = await currentBlobs(deps.exec, git, root, reviewedFiles.map((file) => file.path));
|
|
2048
2203
|
const moved = reviewedFiles.filter((file) => settledBlobs.get(file.path) !== file.blob).map((file) => file.path);
|
|
@@ -2050,6 +2205,7 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
2050
2205
|
const reviewId = deps.newId?.() ?? `xr-${now().toISOString().replace(/\D/g, "").slice(0, 14)}-${randomBytes(3).toString("hex")}`;
|
|
2051
2206
|
const snapshotDir = join(deps.snapshotRoot, reviewId);
|
|
2052
2207
|
writeSnapshot(snapshotDir, snapshot);
|
|
2208
|
+
writeFileSync(join(snapshotDir, ACCEPTANCE_FILE), acceptance, { mode: 0o600 });
|
|
2053
2209
|
writeContextFiles(snapshotDir, references, "ref", "references.json");
|
|
2054
2210
|
writeContextFiles(snapshotDir, inputEntries, "in", "inputs.json");
|
|
2055
2211
|
if (probeRound) {
|
|
@@ -2067,6 +2223,20 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
2067
2223
|
const advisoryCancel = new AbortController();
|
|
2068
2224
|
const forwardAbort = () => advisoryCancel.abort();
|
|
2069
2225
|
if (signal.aborted) advisoryCancel.abort(); else signal.addEventListener("abort", forwardAbort, { once: true });
|
|
2226
|
+
// 나눈 라운드는 한 자리의 호출을 함께 시작하고, 하나가 실패하면 나머지를 끊는다(그 자리는 어차피 쓸 수 있는 답을 낼 수 없다).
|
|
2227
|
+
const askLane = async (family: Lane, attempt: AbortSignal): Promise<ReviewerCompletion & { batches?: string[] }> => {
|
|
2228
|
+
if (prompts.length === 1) return deps.complete(family, prompts[0]!, attempt);
|
|
2229
|
+
const lane = new AbortController();
|
|
2230
|
+
const stop = () => lane.abort();
|
|
2231
|
+
if (attempt.aborted) lane.abort(); else attempt.addEventListener("abort", stop, { once: true });
|
|
2232
|
+
try {
|
|
2233
|
+
const answers = await Promise.all(prompts.map((prompt) => deps.complete(family, prompt, lane.signal).catch((error: unknown) => { lane.abort(); throw error; })));
|
|
2234
|
+
const texts = answers.map((answer) => answer.text);
|
|
2235
|
+
return { model: answers[0]!.model, text: texts.map((text, index) => `===== part ${index + 1}/${texts.length} =====\n${text}`).join("\n\n"), batches: texts };
|
|
2236
|
+
} finally {
|
|
2237
|
+
attempt.removeEventListener("abort", stop);
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2070
2240
|
const runs = families.map(async (family, index): Promise<ReviewerOutcome> => {
|
|
2071
2241
|
const started = Date.now();
|
|
2072
2242
|
const finish = (state: ReviewerProgressState) => {
|
|
@@ -2075,10 +2245,10 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
2075
2245
|
};
|
|
2076
2246
|
try {
|
|
2077
2247
|
const completion = family === ADVISORY_LANE
|
|
2078
|
-
? await withAdvisoryDeadline((attempt) =>
|
|
2079
|
-
: await
|
|
2248
|
+
? await withAdvisoryDeadline((attempt) => askLane(family, attempt), advisoryMs, advisoryCancel.signal, `@${SLOT[family]}`)
|
|
2249
|
+
: await askLane(family, signal);
|
|
2080
2250
|
finish("answered");
|
|
2081
|
-
return { family, model: completion.model, text: completion.text, elapsedMs: Date.now() - started };
|
|
2251
|
+
return { family, model: completion.model, text: completion.text, elapsedMs: Date.now() - started, ...(completion.batches ? { batches: completion.batches } : {}) };
|
|
2082
2252
|
} catch (error) {
|
|
2083
2253
|
// 자문은 멈춘 이유를 그대로, 필수는 review가 취소됐으면 취소로 알린다. 필수의 600 s 제한 초과는 오류 문구로만 구분된다.
|
|
2084
2254
|
finish(error instanceof AdvisoryStopError ? error.reason : signal.aborted ? "cancelled" : "failed");
|
|
@@ -2166,6 +2336,7 @@ export async function runReview(input: ReviewInput, deps: ReviewDeps, signal: Ab
|
|
|
2166
2336
|
references: references.map(({ path, bytes, blob, redacted: matches }) => ({ path, bytes, blob, ...(matches ? { redacted: matches } : {}) })),
|
|
2167
2337
|
...(inputEntries.length > 0 || skippedInputs.length > 0 ? { inputs: inputEntries.map(({ path, bytes, blob, redacted: matches }) => ({ path, bytes, blob, ...(matches ? { redacted: matches } : {}) })), skippedInputs } : {}),
|
|
2168
2338
|
skippedReferences, passable, snapshotDir, ...(resolvedBase ? { base: resolvedBase } : {}), ...(probeRound ? { probeResults: probeMeta, verdicts } : {}), ...(hidingLeads.length > 0 ? { hidingLeads } : {}),
|
|
2339
|
+
...(carriedOver.length > 0 ? { carriedOver } : {}), ...(prompts.length > 1 ? { batches: prompts.length } : {}),
|
|
2169
2340
|
nextStep: [withInputWarning(describeNext({
|
|
2170
2341
|
round, passable, findings: findings.length, probeFindings: findings.filter((finding) => finding.probe).length, probeRound, verdicts,
|
|
2171
2342
|
probeUsed: probesBefore + (probeRound ? 1 : 0), plainUsed: chain.length - probesBefore + (probeRound ? 0 : 1),
|
|
@@ -19,8 +19,10 @@ const GRAM = 4;
|
|
|
19
19
|
|
|
20
20
|
const PROSE_FILE = /\.(?:md|mdx|markdown|html?|xhtml)$/i;
|
|
21
21
|
const MARKUP_FILE = /\.(?:html?|xhtml)$/i;
|
|
22
|
-
// 규칙·프롬프트·스킬은 draft 대상이 아니다(RULES: code, configuration, rule files 제외).
|
|
23
|
-
|
|
22
|
+
// 규칙·프롬프트·스킬은 draft 대상이 아니다(RULES: code, configuration, rule files 제외). 슬롭 게이트가 면제하는 내부 기록
|
|
23
|
+
// (HANDOFF.md, doc/history/**, doc/README.md)도 이 확인에서 뺀다: 2026-10-28 감사에서 26회 차단 중 20회가 내부 기록이었고
|
|
24
|
+
// 12회는 예외 사유를 적고 같은 호출을 다시 보냈다(doc/history/2026/10/28-guard-audit). 사용자 승인 2026-10-28.
|
|
25
|
+
const RULE_NAME = /^(?:AGENTS|RULES|CLAUDE|SKILL|APPEND_SYSTEM|TITLE_SYSTEM|WATCHDOG|HANDOFF)(?:\.[a-z]{2}(?:-[A-Za-z]+)?)?\.md$/i;
|
|
24
26
|
const SKIP_SEGMENT: Record<string, true> = {
|
|
25
27
|
rules: true, "prompt-copies": true, prompts: true, sop: true, skills: true, agents: true, commands: true, generated: true,
|
|
26
28
|
test: true, tests: true, __tests__: true, fixtures: true, fixture: true, __fixtures__: true, testdata: true,
|
|
@@ -40,6 +42,9 @@ export function inScope(abs: string, cwd: string): boolean {
|
|
|
40
42
|
if (!inside && (p.startsWith(`${slash(tmpdir())}/`) || p.startsWith("/tmp/") || p.startsWith(`${slash(homedir())}/.omp/`))) return false;
|
|
41
43
|
const segments = p.split("/");
|
|
42
44
|
if (RULE_NAME.test(segments.at(-1) ?? "")) return false;
|
|
45
|
+
// slop-gate internalRecord와 같은 기준: `doc` 바로 아래 history 폴더 안, 또는 `doc/README.md`.
|
|
46
|
+
const doc = segments.indexOf("doc");
|
|
47
|
+
if (doc >= 0 && ((segments[doc + 1] === "history" && segments.length > doc + 2) || (segments[doc + 1] === "README.md" && segments.length === doc + 2))) return false;
|
|
43
48
|
return !segments.slice(0, -1).some((segment) => SKIP_SEGMENT[segment]);
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// 2026-10-15 실측: Main이 공개 CI watch job 하나에 `wait`로 약 8분을 막힌 채 중간 관측 없이 지냈다. `wait`는 job 정산·메시지·
|
|
3
3
|
// service 종료·30분 상한에만 깨고, 기존 SubagentActivityWatch(core patch)는 task child만 본다. 이 원장은 jev-runtime이
|
|
4
4
|
// wait 진입 차단과 대기 중 aside 깨우기를 결정론적으로 판단하도록 job incarnation(id+startTime)별 관측 근거만 기록한다.
|
|
5
|
-
// 기대 실행 시간을 받는 API가 없으므로(bash `timeout`은 마감이지 예상 시간이 아니다) 첫 관측은
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// 기대 실행 시간을 받는 API가 없으므로(bash `timeout`은 마감이지 예상 시간이 아니다) 첫 관측은 10분 fallback을 쓴다. 측정한
|
|
6
|
+
// 예상 실행 시간이 아니다. 2026-10-28 감사(doc/history/2026/10/28-guard-trim/advisory): 5분 기한 알림을 받은 job 중 끝난 시각을
|
|
7
|
+
// 찾은 90개의 61개(68%)가 10분 전에, 78개(87%)가 15분 전에 끝났고 알림 151건 중 137건의 확인은 아직 실행 중이었다. 출력이
|
|
8
|
+
// 바뀐 확인 뒤에만 15·30분으로 넓히고, 바뀌지 않은 확인은 첫 주기로 되돌려 원인 조사를 요구한다. 경과 시간은 실패 근거가 아니다.
|
|
8
9
|
|
|
9
10
|
export interface JobObservationClock {
|
|
10
11
|
now(): number;
|
|
11
12
|
schedule(callback: () => void, delayMs: number): () => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const JOB_OBSERVATION_INTERVALS_MS: readonly number[] = [
|
|
15
|
+
export const JOB_OBSERVATION_INTERVALS_MS: readonly number[] = [10 * 60_000, 15 * 60_000, 30 * 60_000];
|
|
15
16
|
|
|
16
17
|
// 출력 비교용으로 보관하는 꼬리 길이. core가 이미 진행 출력을 꼬리로 잘라 주므로 비교만을 위한 상한이다.
|
|
17
18
|
const OUTPUT_COMPARE_CHARS = 16_000;
|
|
@@ -118,7 +119,7 @@ export class JobObservationLedger {
|
|
|
118
119
|
/**
|
|
119
120
|
* 같은 incarnation의 성공한 `read proc://<id>`를 확인 근거로 기록한다. 호출 시점에 묶은 incarnation이 지금도 running이
|
|
120
121
|
* 아니면(정산·같은 id 재사용) 기록하지 않는다.
|
|
121
|
-
* snapshot 확인은 관측을 증명할 뿐 진행을 증명하지 않는다: 출력 변화는 주기만 넓히고, 같은 출력은
|
|
122
|
+
* snapshot 확인은 관측을 증명할 뿐 진행을 증명하지 않는다: 출력 변화는 주기만 넓히고, 같은 출력은 첫 주기로 되돌린다.
|
|
122
123
|
*/
|
|
123
124
|
inspect(running: readonly unknown[], incarnation: JobIncarnation, output: string, now: number): ObservedJob | undefined {
|
|
124
125
|
const job = this.sync(running).find((candidate) => candidate.id === incarnation.id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext, ToolDefinition } from "@oh-my-pi/pi-coding-agent";
|
|
3
|
-
import { extractGuardBlock, isPathOwned, isSummonCall, normalizeDeliverable, parseOwnedPaths, readGuardField, taskGuardLockOf, WORK_CLASSES } from "../command-guard/task-guard";
|
|
3
|
+
import { admitsUserRequestedDeliverable, extractGuardBlock, isPathOwned, isSummonCall, normalizeDeliverable, parseOwnedPaths, readGuardField, taskGuardLockOf, USER_REQUEST_HINT, WORK_CLASSES } from "../command-guard/task-guard";
|
|
4
4
|
import { parseCharacterSummonMarker } from "../character-voice";
|
|
5
5
|
import { resolvePreparedTaskInput, storePreparedTaskBatch } from "./prepared-task";
|
|
6
6
|
import { assignmentsByName, summarizeHistory, type AttemptIdentity, type DispatchOwnership, type DispatchRecord, type RoutingHistory, type RoutingLedger } from "./routing-ledger";
|
|
@@ -378,16 +378,42 @@ export function contractGapReason(task: string, lock: DispatchContractLock | und
|
|
|
378
378
|
return `task ${label}: ${detail} ${GUARD_TEMPLATE}`;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
function sameContractLock(lock: DispatchContractLock, contract: DispatchContractLock): boolean {
|
|
382
|
+
return contract.workClass === lock.workClass && normalizeDeliverable(contract.primaryDeliverable) === normalizeDeliverable(lock.primaryDeliverable);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 같은 요청에서 lock과 다른 완료물을 받아들이는 판정을 TaskGuard와 맞춘다: 이 batch에서 이미 받아들인 완료물이거나,
|
|
387
|
+
* TaskGuard가 받아들였거나 USER_REQUEST 인용이 이번 사용자 입력에 그대로 있다. 받아들인 완료물은 batchAdmitted에 더한다.
|
|
388
|
+
*/
|
|
389
|
+
function userRequestAdmission(sessionId: string): (task: string, contract: DispatchContract) => boolean {
|
|
390
|
+
const batchAdmitted: DispatchContractLock[] = [];
|
|
391
|
+
return (task, contract) => {
|
|
392
|
+
if (batchAdmitted.some((lock) => sameContractLock(lock, contract))) return true;
|
|
393
|
+
const quote = guardFields(task)?.("USER_REQUEST") || undefined;
|
|
394
|
+
if (!admitsUserRequestedDeliverable(sessionId, contract.workClass, contract.primaryDeliverable, quote)) return false;
|
|
395
|
+
batchAdmitted.push(contract);
|
|
396
|
+
return true;
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
381
400
|
/**
|
|
382
401
|
* TaskGuard(SideQuestGuard)와 같은 비교로, 이 child의 WORK_CLASS·PRIMARY_DELIVERABLE이 요청 lock(없으면 같은 batch에서 먼저 계약을
|
|
383
|
-
* 정한 child)과 다르면 거절 사유를 돌려준다.
|
|
402
|
+
* 정한 child)과 다르면 거절 사유를 돌려준다. 사용자가 이번 요청에서 직접 요구한 완료물(admits)은 받아들인다. 준비와 발주가 같은
|
|
403
|
+
* 함수를 써서 Jev 판단이나 spawn 전에 같은 결론을 낸다.
|
|
384
404
|
*/
|
|
385
|
-
export function contractLockConflict(
|
|
405
|
+
export function contractLockConflict(
|
|
406
|
+
name: string,
|
|
407
|
+
contract: DispatchContract,
|
|
408
|
+
lock: DispatchContractLock | undefined,
|
|
409
|
+
lockSource: "request" | "batch",
|
|
410
|
+
admits: () => boolean = () => false,
|
|
411
|
+
): string | null {
|
|
386
412
|
if (!lock) return null;
|
|
387
|
-
if (
|
|
413
|
+
if (sameContractLock(lock, contract) || admits()) return null;
|
|
388
414
|
const label = name.trim() ? `'${name.trim().slice(0, 60)}'` : "(이름 없음)";
|
|
389
415
|
const source = lockSource === "request" ? "이 요청의 TaskGuard lock" : "같은 batch에서 먼저 계약을 정한 child";
|
|
390
|
-
return `[SideQuestGuard] task ${label}: 한 사용자 요청의 모든 child는 같은 WORK_CLASS·PRIMARY_DELIVERABLE을 씁니다. 기준=${lock.workClass}:${lock.primaryDeliverable}(${source}), 이 child=${contract.workClass}:${contract.primaryDeliverable}. 이대로 발주하면 task 전체가 거절됩니다.
|
|
416
|
+
return `[SideQuestGuard] task ${label}: 한 사용자 요청의 모든 child는 같은 WORK_CLASS·PRIMARY_DELIVERABLE을 씁니다. 기준=${lock.workClass}:${lock.primaryDeliverable}(${source}), 이 child=${contract.workClass}:${contract.primaryDeliverable}. 이대로 발주하면 task 전체가 거절됩니다. ${USER_REQUEST_HINT} 같은 완료물의 조각이라면 이 child의 두 줄을 기준 값 그대로 적거나 지우고(같은 batch 안이거나 lock이 있을 때만 상속), 조각마다 다른 일은 TASK_TITLE·TODO_TASKS·# Acceptance로 구분하세요.`;
|
|
391
417
|
}
|
|
392
418
|
|
|
393
419
|
/**
|
|
@@ -880,12 +906,13 @@ export function registerMakerRouting(pi: ExtensionAPI, deps: RoutingDeps) {
|
|
|
880
906
|
// 파생한다. 준비 도구도 같은 batch와 이미 연결된 task에서 그 두 필드만 상속한다.
|
|
881
907
|
let candidateLock = lockFor(sessionIdOf(ctx));
|
|
882
908
|
const lockSource = candidateLock ? "request" : "batch";
|
|
909
|
+
const admission = userRequestAdmission(sessionIdOf(ctx));
|
|
883
910
|
const conflicts: string[] = [];
|
|
884
911
|
const contracts = tasks.map((task) => {
|
|
885
912
|
const contract = dispatchContract(task.task, candidateLock);
|
|
886
913
|
if (!contract) throw new Error(`maker_route는 TaskGuard lock으로 완성 가능한 WORK_CLASS·PRIMARY_DELIVERABLE 및 명시 OWNED_PATHS가 필요합니다. ${contractGapReason(task.task, candidateLock, task.name)}`);
|
|
887
914
|
// TaskGuard는 lock과 다른 child가 하나라도 있으면 batch 전체를 거절한다. Jev를 부르기 전에 같은 비교로 모두 알린다.
|
|
888
|
-
const conflict = contractLockConflict(task.name, contract, candidateLock, lockSource);
|
|
915
|
+
const conflict = contractLockConflict(task.name, contract, candidateLock, lockSource, () => admission(task.task, contract));
|
|
889
916
|
if (conflict) conflicts.push(conflict);
|
|
890
917
|
candidateLock ??= { workClass: contract.workClass, primaryDeliverable: contract.primaryDeliverable };
|
|
891
918
|
return contract;
|
|
@@ -1143,6 +1170,7 @@ export function registerMakerRouting(pi: ExtensionAPI, deps: RoutingDeps) {
|
|
|
1143
1170
|
const refreshAttempts: RefreshAttempts = new Map();
|
|
1144
1171
|
let candidateLock = lockFor(sessionIdOf(ctx));
|
|
1145
1172
|
const lockSource = candidateLock ? "request" : "batch";
|
|
1173
|
+
const admission = userRequestAdmission(sessionIdOf(ctx));
|
|
1146
1174
|
const locksBefore: (DispatchContractLock | undefined)[] = [];
|
|
1147
1175
|
const contracts = tasks.map((item) => {
|
|
1148
1176
|
const task = typeof item.task === "string" ? item.task : "";
|
|
@@ -1165,7 +1193,7 @@ export function registerMakerRouting(pi: ExtensionAPI, deps: RoutingDeps) {
|
|
|
1165
1193
|
if (parseCharacterSummonMarker(task) !== undefined || isSummonCall(sessionIdOf(ctx), callId)) continue;
|
|
1166
1194
|
const contract = contracts[itemIndex];
|
|
1167
1195
|
if (!contract) return { block: true, reason: `task는 TaskGuard lock으로 완성 가능한 WORK_CLASS·PRIMARY_DELIVERABLE 및 명시 OWNED_PATHS가 필요합니다. ${contractGapReason(task, locksBefore[itemIndex], String(item.name ?? ""))}` };
|
|
1168
|
-
const conflict = contractLockConflict(String(item.name ?? ""), contract, locksBefore[itemIndex], lockSource);
|
|
1196
|
+
const conflict = contractLockConflict(String(item.name ?? ""), contract, locksBefore[itemIndex], lockSource, () => admission(task, contract));
|
|
1169
1197
|
if (conflict) return { block: true, reason: conflict };
|
|
1170
1198
|
const name = String(item.name ?? "").trim();
|
|
1171
1199
|
const key = briefKey(String(item.name ?? ""), contract);
|