@attalabs/vinaya 0.42.1 → 0.43.0
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/dist/checks/bin/check-evidence-fresh.js +177 -152
- package/dist/checks/bin/check-registry-gates.js +10 -3
- package/dist/index.js +300 -173
- package/dist/lib/pre-push-cache-test-run.js +145 -144
- package/dist/lib/pre-push-changed-files.js +10 -3
- package/dist/lib/pre-push-progress-dir.js +169 -147
- package/dist/lib/pre-push-select-tests.js +16 -4
- package/dist/lib/push-progress-observer.js +169 -147
- package/dist/programs/archive.js +172 -148
- package/dist/programs/audit.js +169 -147
- package/dist/programs/check.js +172 -148
- package/dist/programs/commit-msg.js +172 -148
- package/dist/programs/dev-review-loop.js +300 -176
- package/dist/programs/dispatch.js +1905 -1877
- package/dist/programs/log-emit.js +172 -148
- package/dist/programs/log-selftest.js +172 -148
- package/dist/programs/log-send.js +172 -148
- package/dist/programs/pr-report.js +177 -152
- package/dist/programs/pr-snapshot.js +172 -148
- package/dist/programs/pr-verify-evidence.js +177 -152
- package/dist/programs/pr.js +172 -148
- package/dist/programs/review-post.js +172 -148
- package/dist/programs/review-status.js +180 -148
- package/dist/programs/run-engine.js +110594 -0
- package/dist/programs/supervised-command.js +67 -0
- package/dist/programs/sync.js +63 -39
- package/dist/programs/task-brief.js +174 -150
- package/dist/programs/task-sweep.js +244 -151
- package/dist/programs/task-tools-serve.js +260 -163
- package/dist/programs/tokens.js +172 -148
- package/dist/programs/waiver.js +172 -148
- package/dist/vinaya-strict/checks/registry.ts +1085 -0
- package/dist/vinaya-strict/executing/code-reviewer/README.md +3 -0
- package/dist/vinaya-strict/executing/code-reviewer/doctrine.md +185 -0
- package/dist/vinaya-strict/executing/code-reviewer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/code-reviewer/evals/code-reviewer-cases.json +280 -0
- package/dist/vinaya-strict/executing/code-reviewer/grants.yaml +22 -0
- package/dist/vinaya-strict/executing/code-reviewer/output.schema.json +93 -0
- package/dist/vinaya-strict/executing/code-reviewer/review-result.ts +347 -0
- package/dist/vinaya-strict/executing/dev-review.flow.yaml +103 -0
- package/dist/vinaya-strict/executing/developer/README.md +3 -0
- package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +69 -0
- package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +286 -0
- package/dist/vinaya-strict/executing/developer/doctrine.md +111 -0
- package/dist/vinaya-strict/executing/developer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-cases.json +6275 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-held-out.json +11526 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +498 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +1407 -0
- package/dist/vinaya-strict/executing/developer/grants.yaml +25 -0
- package/dist/vinaya-strict/executing/developer/output.schema.json +148 -0
- package/dist/vinaya-strict/executing/developer/reference.md +376 -0
- package/dist/vinaya-strict/executing/operator/doctrine.md +209 -0
- package/dist/vinaya-strict/executing/security-reviewer/README.md +3 -0
- package/dist/vinaya-strict/executing/security-reviewer/doctrine.md +171 -0
- package/dist/vinaya-strict/executing/security-reviewer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/security-reviewer/evals/security-reviewer-cases.json +141 -0
- package/dist/vinaya-strict/executing/security-reviewer/grants.yaml +22 -0
- package/dist/vinaya-strict/executing/security-reviewer/output.schema.json +93 -0
- package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +1278 -0
- package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +52 -0
- package/dist/vinaya-strict/integration/process/process-integration.ts +57 -0
- package/dist/vinaya-strict/loops/dev-review/v2/dev-review-v2.flow.yaml +136 -0
- package/dist/vinaya-strict/process.yaml +43 -0
- package/dist/vinaya-strict/retrospecting/archivist/doctrine.md +174 -0
- package/dist/vinaya-strict/retrospecting/tranche-archivist/doctrine.md +270 -0
- package/dist/vinaya-strict/thinking/architect/doctrine.md +110 -0
- package/dist/vinaya-strict/thinking/planner/doctrine.md +105 -0
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +128 -0
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +169 -0
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +701 -0
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +1035 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +359 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +815 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +200 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +458 -0
- package/package.json +4 -2
- package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
- /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
|
@@ -48,1944 +48,1977 @@ var __esm = (fn, res, err) => () => {
|
|
|
48
48
|
return res;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// ../../harness/kernel/log/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
51
|
+
// ../../harness/kernel/log/roles.ts
|
|
52
|
+
function registerRole(name, role) {
|
|
53
|
+
roles.set(name, role);
|
|
54
|
+
}
|
|
55
|
+
function registerTitle(name, title) {
|
|
56
|
+
titles.set(name, title);
|
|
57
|
+
}
|
|
58
|
+
function isRole(value) {
|
|
59
|
+
return value !== undefined && roles.has(value);
|
|
60
|
+
}
|
|
61
|
+
function lookupRole(name) {
|
|
62
|
+
return roles.get(name);
|
|
63
|
+
}
|
|
64
|
+
function lookupTitle(name) {
|
|
65
|
+
return roles.get(name)?.title ?? titles.get(name);
|
|
66
|
+
}
|
|
67
|
+
var roles, titles;
|
|
68
|
+
var init_roles = __esm(() => {
|
|
69
|
+
roles = new Map;
|
|
70
|
+
titles = new Map;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// ../../harness/processes/vinaya-strict/integration/log/log-roles.ts
|
|
74
|
+
function registerVinayaLogRoles() {
|
|
75
|
+
for (const { name, reading, title, reviews } of VINAYA_LOG_ROLES)
|
|
76
|
+
registerRole(name, { reading, title, reviews });
|
|
77
|
+
registerTitle("dev-review-loop", "Loop");
|
|
78
|
+
}
|
|
79
|
+
var VINAYA_LOG_ROLES, VINAYA_LOG_ROLE_NAMES;
|
|
80
|
+
var init_log_roles = __esm(() => {
|
|
81
|
+
init_roles();
|
|
82
|
+
VINAYA_LOG_ROLES = [
|
|
83
|
+
{ name: "planner", reading: "planner", title: "Planner", reviews: false },
|
|
84
|
+
{ name: "developer", reading: "developer", title: "Developer", reviews: false },
|
|
85
|
+
{ name: "code-reviewer", reading: "code reviewer", title: "Code review", reviews: true },
|
|
86
|
+
{ name: "security", reading: "security reviewer", title: "Security", reviews: true },
|
|
87
|
+
{ name: "principal", reading: "principal", title: "Principal", reviews: false },
|
|
88
|
+
{ name: "archivist", reading: "archivist", title: "Archivist", reviews: false },
|
|
89
|
+
{ name: "architect", reading: "architect", title: "Architect", reviews: false }
|
|
90
|
+
];
|
|
91
|
+
VINAYA_LOG_ROLE_NAMES = VINAYA_LOG_ROLES.map((role) => role.name);
|
|
92
|
+
registerVinayaLogRoles();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// ../../harness/kernel/issue-documentation.ts
|
|
96
|
+
function topLevelSectionText(body, headingName) {
|
|
97
|
+
const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
|
|
98
|
+
const heading = headingRe.exec(body);
|
|
99
|
+
if (!heading)
|
|
100
|
+
return null;
|
|
101
|
+
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
102
|
+
const next = /^##[ \t]/m.exec(afterHeading);
|
|
103
|
+
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
104
|
+
}
|
|
105
|
+
function parseIssueDocumentation(body) {
|
|
106
|
+
const section = topLevelSectionText(body, "Documentation");
|
|
107
|
+
if (section === null)
|
|
108
|
+
return { ok: false, errors: ["no `## Documentation` heading found in the body."] };
|
|
109
|
+
const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
110
|
+
if (lines.length > 0 && lines.every((l) => NO_DOCUMENTATION_SENTINEL_RE.test(l))) {
|
|
111
|
+
return { ok: true, value: { kind: "none" } };
|
|
112
|
+
}
|
|
113
|
+
const sources = [];
|
|
114
|
+
const errors = [];
|
|
115
|
+
for (const line of lines) {
|
|
116
|
+
const m = ISSUE_DOCUMENTATION_LINE_RE.exec(line);
|
|
117
|
+
if (!m) {
|
|
118
|
+
errors.push(`"${line}" is not a well-formed Documentation line — expected \`- <source> — <mechanism it governs>\` (or the \`None\` sentinel).`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const source = m[1].trim();
|
|
122
|
+
const mechanism = m[2].trim();
|
|
123
|
+
if (source.length === 0 || mechanism.length === 0) {
|
|
124
|
+
errors.push(`"${line}" is missing a source or a mechanism — a Documentation line needs both.`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const objectiveIds = m[3] ? [...m[3].matchAll(/O(\d+)/gi)].map((r) => Number.parseInt(r[1], 10)) : [];
|
|
128
|
+
sources.push({ source, mechanism, objectiveIds });
|
|
129
|
+
}
|
|
130
|
+
if (sources.length === 0 && errors.length === 0) {
|
|
131
|
+
errors.push("the `## Documentation` section has no well-formed `- <source> — <mechanism>` lines, and no `None` sentinel.");
|
|
132
|
+
}
|
|
133
|
+
if (errors.length > 0)
|
|
134
|
+
return { ok: false, errors };
|
|
135
|
+
return { ok: true, value: { kind: "sources", sources } };
|
|
136
|
+
}
|
|
137
|
+
var NO_DOCUMENTATION_SENTINEL_RE, ISSUE_DOCUMENTATION_LINE_RE;
|
|
138
|
+
var init_issue_documentation = __esm(() => {
|
|
139
|
+
NO_DOCUMENTATION_SENTINEL_RE = /^none\b/i;
|
|
140
|
+
ISSUE_DOCUMENTATION_LINE_RE = /^[-*]\s+(.+?)(?:\s+-\s+|\s*[—–]\s*)(.+?)(?:\s*\((O\d+(?:\s*,\s*O\d+)*)\))?$/i;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// ../../harness/kernel/conformance/unit/process-registry.ts
|
|
144
|
+
import { execFileSync } from "node:child_process";
|
|
145
|
+
import {
|
|
146
|
+
closeSync,
|
|
147
|
+
fsyncSync,
|
|
148
|
+
mkdirSync,
|
|
149
|
+
openSync,
|
|
150
|
+
readdirSync,
|
|
151
|
+
readFileSync,
|
|
152
|
+
renameSync,
|
|
153
|
+
rmSync,
|
|
154
|
+
writeSync
|
|
155
|
+
} from "node:fs";
|
|
156
|
+
import { homedir } from "node:os";
|
|
157
|
+
import { join } from "node:path";
|
|
158
|
+
function registryDir() {
|
|
159
|
+
return process.env.VINAYA_PROCESS_REGISTRY_DIR || join(homedir(), ".vinaya", "process-registry");
|
|
160
|
+
}
|
|
161
|
+
async function registerProcess(entry, opts = {}) {
|
|
162
|
+
if (entry.processGroup && isSameProcessAlive(entry))
|
|
163
|
+
entry = { ...entry, members: observedGroupMembers(entry) };
|
|
164
|
+
const folder = runFolder(opts.dir ?? registryDir(), entry.runToken);
|
|
165
|
+
mkdirSync(folder, { recursive: true });
|
|
166
|
+
const final = join(folder, `${entry.pid}.json`);
|
|
167
|
+
const temp = `${final}.${process.pid}.tmp`;
|
|
168
|
+
const fd = openSync(temp, "w", 384);
|
|
169
|
+
try {
|
|
170
|
+
writeSync(fd, `${JSON.stringify(entry)}
|
|
171
|
+
`);
|
|
172
|
+
fsyncSync(fd);
|
|
173
|
+
} finally {
|
|
174
|
+
closeSync(fd);
|
|
175
|
+
}
|
|
176
|
+
renameSync(temp, final);
|
|
177
|
+
}
|
|
178
|
+
function registeredProcesses(runToken, opts = {}) {
|
|
179
|
+
const folder = runFolder(opts.dir ?? registryDir(), runToken);
|
|
180
|
+
let names;
|
|
181
|
+
try {
|
|
182
|
+
names = readdirSync(folder);
|
|
183
|
+
} catch {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const entries = [];
|
|
187
|
+
for (const name of names) {
|
|
188
|
+
if (!name.endsWith(".json"))
|
|
189
|
+
continue;
|
|
190
|
+
try {
|
|
191
|
+
const value = JSON.parse(readFileSync(join(folder, name), "utf8"));
|
|
192
|
+
if (Number.isInteger(value.pid) && typeof value.startTime === "string")
|
|
193
|
+
entries.push(value);
|
|
194
|
+
} catch {}
|
|
195
|
+
}
|
|
196
|
+
return entries;
|
|
197
|
+
}
|
|
198
|
+
function linuxStartTime(pid) {
|
|
199
|
+
try {
|
|
200
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
201
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
202
|
+
return fields[19] ?? null;
|
|
203
|
+
} catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function psStartTime(pid) {
|
|
208
|
+
try {
|
|
209
|
+
const out = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
210
|
+
encoding: "utf8",
|
|
211
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
212
|
+
}).trim();
|
|
213
|
+
return out === "" ? null : out;
|
|
214
|
+
} catch {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function identityOf(pid) {
|
|
219
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
220
|
+
return null;
|
|
221
|
+
const startTime = linuxStartTime(pid) ?? psStartTime(pid);
|
|
222
|
+
return startTime === null ? null : { pid, startTime };
|
|
223
|
+
}
|
|
224
|
+
function isSameProcessAlive(identity) {
|
|
225
|
+
return identityOf(identity.pid)?.startTime === identity.startTime;
|
|
226
|
+
}
|
|
227
|
+
function groupExists(pgid) {
|
|
228
|
+
try {
|
|
229
|
+
process.kill(-pgid, 0);
|
|
230
|
+
return true;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
return error.code === "EPERM";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function observedGroupMembers(entry) {
|
|
236
|
+
if (!isSameProcessAlive(entry))
|
|
237
|
+
return entry.members ?? [];
|
|
238
|
+
try {
|
|
239
|
+
const rows = execFileSync("ps", ["-axo", "pid=,pgid="], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
240
|
+
const members = rows.trim().split(`
|
|
241
|
+
`).flatMap((line) => {
|
|
242
|
+
const [pid, group] = line.trim().split(/\s+/).map(Number);
|
|
243
|
+
if (group !== entry.pid || pid === undefined || pid === entry.pid)
|
|
244
|
+
return [];
|
|
245
|
+
const member = identityOf(pid);
|
|
246
|
+
return member ? [member] : [];
|
|
247
|
+
});
|
|
248
|
+
return isSameProcessAlive(entry) ? members : entry.members ?? [];
|
|
249
|
+
} catch {
|
|
250
|
+
return entry.members ?? [];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function registeredProcessOwned(entry, inspect = {
|
|
254
|
+
identity: identityOf,
|
|
255
|
+
groupExists,
|
|
256
|
+
groupOf: (pid) => {
|
|
257
|
+
try {
|
|
258
|
+
return Number(execFileSync("ps", ["-o", "pgid=", "-p", String(pid)], {
|
|
259
|
+
encoding: "utf8",
|
|
260
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
261
|
+
}).trim()) || null;
|
|
262
|
+
} catch {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}) {
|
|
267
|
+
const now = inspect.identity(entry.pid);
|
|
268
|
+
if (now !== null)
|
|
269
|
+
return now.startTime === entry.startTime;
|
|
270
|
+
return entry.processGroup === true && (entry.members ?? []).some((member) => inspect.identity(member.pid)?.startTime === member.startTime && inspect.groupOf(member.pid) === entry.pid);
|
|
271
|
+
}
|
|
272
|
+
function signal(entry, sig) {
|
|
273
|
+
if (!registeredProcessOwned(entry))
|
|
274
|
+
return;
|
|
275
|
+
try {
|
|
276
|
+
process.kill(entry.processGroup ? -entry.pid : entry.pid, sig);
|
|
277
|
+
} catch {}
|
|
278
|
+
}
|
|
279
|
+
async function stopRegistered(runToken, opts) {
|
|
280
|
+
const dir = opts.dir ?? registryDir();
|
|
281
|
+
const entries = registeredProcesses(runToken, { dir });
|
|
282
|
+
const identity = (entry) => ({ pid: entry.pid, startTime: entry.startTime });
|
|
283
|
+
const report = { backend: "registry", terminated: [], killed: [], alreadyGone: [] };
|
|
284
|
+
const live = [];
|
|
285
|
+
for (const entry of entries) {
|
|
286
|
+
if (entry.processGroup && isSameProcessAlive(entry)) {
|
|
287
|
+
entry.members = observedGroupMembers(entry);
|
|
288
|
+
await registerProcess(entry, { dir });
|
|
289
|
+
}
|
|
290
|
+
if (registeredProcessOwned(entry)) {
|
|
291
|
+
live.push(entry);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (entry.processGroup && identityOf(entry.pid) === null && groupExists(entry.pid))
|
|
295
|
+
throw new Error(`process registry: group ${entry.pid} has no verifiable recorded member; refusing to signal an unowned group`);
|
|
296
|
+
report.alreadyGone.push(identity(entry));
|
|
297
|
+
}
|
|
298
|
+
for (const entry of live)
|
|
299
|
+
signal(entry, "SIGTERM");
|
|
300
|
+
const deadline = Date.now() + Math.max(0, opts.graceMs);
|
|
301
|
+
let remaining = live;
|
|
302
|
+
while (remaining.length > 0 && Date.now() < deadline) {
|
|
303
|
+
await sleep(Math.min(50, Math.max(1, deadline - Date.now())));
|
|
304
|
+
remaining = remaining.filter((entry) => registeredProcessOwned(entry));
|
|
305
|
+
}
|
|
306
|
+
for (const entry of live)
|
|
307
|
+
if (!remaining.includes(entry))
|
|
308
|
+
report.terminated.push(identity(entry));
|
|
309
|
+
for (const entry of remaining) {
|
|
310
|
+
signal(entry, "SIGKILL");
|
|
311
|
+
report.killed.push(identity(entry));
|
|
312
|
+
}
|
|
313
|
+
const killDeadline = Date.now() + 2000;
|
|
314
|
+
while (remaining.length > 0 && Date.now() < killDeadline) {
|
|
315
|
+
await sleep(20);
|
|
316
|
+
remaining = remaining.filter((entry) => registeredProcessOwned(entry));
|
|
317
|
+
}
|
|
318
|
+
rmSync(runFolder(dir, runToken), { recursive: true, force: true });
|
|
319
|
+
return report;
|
|
320
|
+
}
|
|
321
|
+
var runFolder = (dir, runToken) => join(dir, encodeURIComponent(runToken)), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
322
|
+
var init_process_registry = () => {};
|
|
323
|
+
|
|
324
|
+
// ../../harness/kernel/conformance/unit/test-temp.ts
|
|
325
|
+
import { spawnSync } from "node:child_process";
|
|
326
|
+
import {
|
|
327
|
+
chmodSync,
|
|
328
|
+
existsSync,
|
|
329
|
+
lstatSync,
|
|
330
|
+
mkdirSync as mkdirSync2,
|
|
331
|
+
readdirSync as readdirSync2,
|
|
332
|
+
readFileSync as readFileSync2,
|
|
333
|
+
renameSync as renameSync2,
|
|
334
|
+
rmSync as rmSync2,
|
|
335
|
+
writeFileSync
|
|
336
|
+
} from "node:fs";
|
|
337
|
+
import { homedir as homedir2, hostname, tmpdir } from "node:os";
|
|
338
|
+
import { basename as basename2, dirname, join as join2 } from "node:path";
|
|
339
|
+
function processStartTime(pid) {
|
|
340
|
+
let stat = null;
|
|
341
|
+
try {
|
|
342
|
+
stat = readFileSync2(`/proc/${pid}/stat`, "utf8");
|
|
343
|
+
} catch {
|
|
344
|
+
if (existsSync("/proc/self/stat"))
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
if (stat !== null) {
|
|
348
|
+
const ticks = stat.slice(stat.lastIndexOf(")") + 2).split(" ").at(22 - 3);
|
|
349
|
+
return ticks === undefined ? null : `ticks:${ticks}`;
|
|
350
|
+
}
|
|
351
|
+
const result = spawnSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
352
|
+
encoding: "utf8",
|
|
353
|
+
env: { PATH: process.env.PATH ?? "/bin:/usr/bin", LC_ALL: "C" }
|
|
354
|
+
});
|
|
355
|
+
if (result.status !== 0 || typeof result.stdout !== "string")
|
|
356
|
+
return null;
|
|
357
|
+
const text = result.stdout.trim();
|
|
358
|
+
return text === "" ? null : text;
|
|
359
|
+
}
|
|
360
|
+
function currentOwner(runToken) {
|
|
361
|
+
ownStartTime ??= processStartTime(process.pid) ?? "unknown";
|
|
362
|
+
return { host: hostname(), pid: process.pid, startTime: ownStartTime, runToken };
|
|
363
|
+
}
|
|
364
|
+
function writeOwnerMarker(dir, owner) {
|
|
365
|
+
const marker = { owner, createdAt: new Date().toISOString() };
|
|
366
|
+
writeFileSync(join2(dir, OWNER_MARKER_FILE), `${JSON.stringify(marker)}
|
|
367
|
+
`);
|
|
368
|
+
return marker;
|
|
369
|
+
}
|
|
370
|
+
function readOwnerMarker(dir) {
|
|
371
|
+
try {
|
|
372
|
+
const parsed = JSON.parse(readFileSync2(join2(dir, OWNER_MARKER_FILE), "utf8"));
|
|
373
|
+
const o = parsed?.owner;
|
|
374
|
+
if (typeof o?.host !== "string" || typeof o.pid !== "number" || typeof o.startTime !== "string" || typeof o.runToken !== "string")
|
|
375
|
+
return null;
|
|
376
|
+
return parsed;
|
|
377
|
+
} catch {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function describeError(error) {
|
|
382
|
+
return error instanceof Error ? error.message : String(error);
|
|
383
|
+
}
|
|
384
|
+
function isOwnerAlive(owner) {
|
|
385
|
+
if (owner.host !== hostname())
|
|
386
|
+
return true;
|
|
387
|
+
try {
|
|
388
|
+
process.kill(owner.pid, 0);
|
|
389
|
+
} catch (error) {
|
|
390
|
+
if (error.code !== "EPERM")
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
const now = processStartTime(owner.pid);
|
|
394
|
+
if (now === null || owner.startTime === "unknown")
|
|
395
|
+
return true;
|
|
396
|
+
return now === owner.startTime;
|
|
397
|
+
}
|
|
398
|
+
function makeTreeWritable(dir) {
|
|
399
|
+
try {
|
|
400
|
+
if (!lstatSync(dir).isDirectory())
|
|
401
|
+
return;
|
|
402
|
+
chmodSync(dir, 448);
|
|
403
|
+
for (const entry of readdirSync2(dir))
|
|
404
|
+
makeTreeWritable(join2(dir, entry));
|
|
405
|
+
} catch {}
|
|
406
|
+
}
|
|
407
|
+
function removeTree(dir) {
|
|
408
|
+
try {
|
|
409
|
+
rmSync2(dir, { recursive: true, force: true });
|
|
410
|
+
return null;
|
|
411
|
+
} catch (first) {
|
|
412
|
+
const code = first.code;
|
|
413
|
+
if (code !== "EACCES" && code !== "EPERM" && code !== "ENOTEMPTY")
|
|
414
|
+
return describeError(first);
|
|
415
|
+
}
|
|
416
|
+
makeTreeWritable(dir);
|
|
417
|
+
try {
|
|
418
|
+
rmSync2(dir, { recursive: true, force: true });
|
|
419
|
+
return null;
|
|
420
|
+
} catch (second) {
|
|
421
|
+
return describeError(second);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function releaseAndRemove(dir, report) {
|
|
425
|
+
const marker = readOwnerMarker(dir);
|
|
426
|
+
if (marker === null) {
|
|
427
|
+
report.failed.push({ dir, error: "ownership marker missing; refusing removal" });
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const result = claimTestTempRun({ dir, marker });
|
|
431
|
+
if ("error" in result) {
|
|
432
|
+
report.failed.push({ dir, error: result.error });
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const released = result.claimed;
|
|
436
|
+
const error = removeTree(released);
|
|
437
|
+
if (error === null) {
|
|
438
|
+
rmSync2(`${released}.owner.json`, { force: true });
|
|
439
|
+
report.removed.push(dir);
|
|
440
|
+
} else
|
|
441
|
+
report.failed.push({ dir, error });
|
|
442
|
+
}
|
|
443
|
+
function claimTestTempRun(run) {
|
|
444
|
+
const claimed = join2(dirname(run.dir), `${REMOVING_PREFIX}${basename2(run.dir)}`);
|
|
445
|
+
try {
|
|
446
|
+
writeFileSync(`${claimed}.owner.json`, JSON.stringify({ original: basename2(run.dir), marker: run.marker }), {
|
|
447
|
+
flag: "wx",
|
|
448
|
+
mode: 384
|
|
449
|
+
});
|
|
450
|
+
renameSync2(run.dir, claimed);
|
|
451
|
+
return { claimed };
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return { error: describeError(error) };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async function sweepOwnedDirs(parent, deps = {}) {
|
|
457
|
+
const { stop, graceMs, select } = { ...DEFAULT_SWEEP, ...deps };
|
|
458
|
+
const report = { removed: [], kept: [], failed: [] };
|
|
459
|
+
let names;
|
|
460
|
+
try {
|
|
461
|
+
names = readdirSync2(parent);
|
|
462
|
+
} catch (error) {
|
|
463
|
+
if (error.code === "ENOENT")
|
|
464
|
+
return report;
|
|
465
|
+
report.failed.push({ dir: parent, error: describeError(error) });
|
|
466
|
+
return report;
|
|
467
|
+
}
|
|
468
|
+
for (const name of names) {
|
|
469
|
+
const dir = join2(parent, name);
|
|
470
|
+
if (name.endsWith(".owner.json"))
|
|
471
|
+
continue;
|
|
472
|
+
if (name.startsWith(REMOVING_PREFIX)) {
|
|
473
|
+
const original = name.slice(REMOVING_PREFIX.length);
|
|
474
|
+
if (!select(original))
|
|
475
|
+
continue;
|
|
476
|
+
let marker = readOwnerMarker(dir);
|
|
477
|
+
const receipt = `${dir}.owner.json`;
|
|
478
|
+
try {
|
|
479
|
+
const stat = lstatSync(receipt);
|
|
480
|
+
if (stat.isFile() && stat.uid === process.getuid?.() && (stat.mode & 18) === 0) {
|
|
481
|
+
const released = JSON.parse(readFileSync2(receipt, "utf8"));
|
|
482
|
+
if (released.original === original && released.marker?.owner?.host === hostname()) {
|
|
483
|
+
marker = released.marker;
|
|
484
|
+
if (typeof released.cleanupError === "string")
|
|
485
|
+
report.failed.push({ dir, error: released.cleanupError });
|
|
486
|
+
}
|
|
100
487
|
}
|
|
488
|
+
} catch {}
|
|
489
|
+
if (marker === null || marker.owner.host !== hostname()) {
|
|
490
|
+
report.kept.push(dir);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
await stop(marker.owner.runToken, { graceMs }, dir);
|
|
495
|
+
const error = removeTree(dir);
|
|
496
|
+
if (error !== null)
|
|
497
|
+
throw new Error(error);
|
|
498
|
+
rmSync2(receipt, { force: true });
|
|
499
|
+
report.removed.push(dir);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
report.failed.push({ dir, error: describeError(error) });
|
|
101
502
|
}
|
|
503
|
+
continue;
|
|
102
504
|
}
|
|
103
|
-
|
|
505
|
+
if (!select(name))
|
|
506
|
+
continue;
|
|
507
|
+
const marker = readOwnerMarker(dir);
|
|
508
|
+
if (marker === null || isOwnerAlive(marker.owner)) {
|
|
509
|
+
report.kept.push(dir);
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
await stop(marker.owner.runToken, { graceMs }, dir);
|
|
514
|
+
} catch (error) {
|
|
515
|
+
report.failed.push({ dir, error: `stopping the owner's processes failed: ${describeError(error)}` });
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
releaseAndRemove(dir, report);
|
|
519
|
+
}
|
|
520
|
+
return report;
|
|
521
|
+
}
|
|
522
|
+
var OWNER_MARKER_FILE = ".vinaya-owner.json", REMOVING_PREFIX = ".removing-", ownStartTime, DEFAULT_SWEEP;
|
|
523
|
+
var init_test_temp = __esm(() => {
|
|
524
|
+
init_process_registry();
|
|
525
|
+
DEFAULT_SWEEP = { stop: stopRegistered, graceMs: 2000, select: () => true };
|
|
104
526
|
});
|
|
105
527
|
|
|
106
|
-
// ../../harness/kernel/
|
|
107
|
-
import {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
528
|
+
// ../../harness/kernel/adapters/code-host/github/resolve-repo.ts
|
|
529
|
+
import { execFile } from "node:child_process";
|
|
530
|
+
import { promisify } from "node:util";
|
|
531
|
+
async function resolveRepo(exec = defaultExec) {
|
|
532
|
+
if (cached !== undefined)
|
|
533
|
+
return cached;
|
|
534
|
+
const fromEnv = process.env.VINAYA_REPO;
|
|
535
|
+
if (fromEnv) {
|
|
536
|
+
const parsed = parseOwnerRepo(fromEnv);
|
|
537
|
+
if (parsed) {
|
|
538
|
+
cached = parsed;
|
|
539
|
+
return cached;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (inflight)
|
|
543
|
+
return inflight;
|
|
544
|
+
inflight = (async () => {
|
|
545
|
+
try {
|
|
546
|
+
const { stdout } = await exec();
|
|
547
|
+
cached = parseGitRemoteUrl(stdout.trim());
|
|
548
|
+
return cached;
|
|
549
|
+
} catch (err) {
|
|
550
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
551
|
+
console.warn(`[resolve-repo] resolveRepo: git remote lookup failed (will retry): ${message}`);
|
|
552
|
+
return null;
|
|
553
|
+
} finally {
|
|
554
|
+
inflight = undefined;
|
|
555
|
+
}
|
|
556
|
+
})();
|
|
557
|
+
return inflight;
|
|
558
|
+
}
|
|
559
|
+
function parseGitRemoteUrl(url) {
|
|
560
|
+
const ssh = url.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
561
|
+
if (ssh?.[1] && ssh[2])
|
|
562
|
+
return { owner: ssh[1], repo: ssh[2] };
|
|
563
|
+
const https = url.match(/^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
564
|
+
if (https?.[1] && https[2])
|
|
565
|
+
return { owner: https[1], repo: https[2] };
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
function parseOwnerRepo(value) {
|
|
569
|
+
const match = value.match(/^([^/]+)\/(.+)$/);
|
|
570
|
+
if (!match?.[1] || !match[2])
|
|
571
|
+
return null;
|
|
572
|
+
return { owner: match[1], repo: match[2] };
|
|
573
|
+
}
|
|
574
|
+
var execFileAsync, systemEnv, defaultExec = () => execFileAsync("git", ["remote", "get-url", "origin"], { env: systemEnv, timeout: 5000 }), cached, inflight;
|
|
575
|
+
var init_resolve_repo = __esm(() => {
|
|
576
|
+
execFileAsync = promisify(execFile);
|
|
577
|
+
systemEnv = {
|
|
578
|
+
...process.env,
|
|
579
|
+
PATH: [process.env.PATH, "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"].filter(Boolean).join(":")
|
|
133
580
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// ../../harness/kernel/adapters/agents/claude-code/claude-code-transcript.ts
|
|
584
|
+
function summarizeTranscript(jsonl) {
|
|
585
|
+
const seen = new Set;
|
|
586
|
+
const components = {
|
|
587
|
+
inputTokens: 0,
|
|
588
|
+
outputTokens: 0,
|
|
589
|
+
cacheCreationInputTokens: 0,
|
|
590
|
+
cacheReadInputTokens: 0
|
|
591
|
+
};
|
|
592
|
+
let model = null;
|
|
593
|
+
let messageCount = 0;
|
|
594
|
+
for (const rawLine of jsonl.split(/\r?\n/)) {
|
|
595
|
+
const line = rawLine.trim();
|
|
596
|
+
if (!line)
|
|
597
|
+
continue;
|
|
598
|
+
let entry;
|
|
599
|
+
try {
|
|
600
|
+
entry = JSON.parse(line);
|
|
601
|
+
} catch {
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (!entry || typeof entry !== "object")
|
|
605
|
+
continue;
|
|
606
|
+
const obj = entry;
|
|
607
|
+
if (obj.type !== "assistant")
|
|
608
|
+
continue;
|
|
609
|
+
const message = obj.message;
|
|
610
|
+
const id = message?.id;
|
|
611
|
+
const usage = message?.usage;
|
|
612
|
+
if (typeof id !== "string" || !id || !usage || seen.has(id))
|
|
613
|
+
continue;
|
|
614
|
+
seen.add(id);
|
|
615
|
+
messageCount++;
|
|
616
|
+
components.inputTokens += numberOr(usage.input_tokens, 0);
|
|
617
|
+
components.outputTokens += numberOr(usage.output_tokens, 0);
|
|
618
|
+
components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
|
|
619
|
+
components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
|
|
620
|
+
const messageModel = message?.model;
|
|
621
|
+
if (typeof messageModel === "string" && messageModel)
|
|
622
|
+
model = messageModel;
|
|
623
|
+
}
|
|
624
|
+
return { components, model, messageCount };
|
|
625
|
+
}
|
|
626
|
+
function numberOr(value, fallback) {
|
|
627
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
628
|
+
}
|
|
629
|
+
var init_claude_code_transcript = () => {};
|
|
630
|
+
|
|
631
|
+
// ../../harness/kernel/log/redact.ts
|
|
632
|
+
function redactString(value, home) {
|
|
633
|
+
let out = value.replace(GITHUB_TOKEN_PATTERN, "<redacted>").replace(CLASSIC_GITHUB_PAT_PATTERN, "$1<redacted>").replace(BEARER_TOKEN_PATTERN, "<redacted>").replace(AWS_ACCESS_KEY_PATTERN, "<redacted>").replace(SLACK_TOKEN_PATTERN, "<redacted>").replace(STRIPE_KEY_PATTERN, "<redacted>").replace(ANTHROPIC_KEY_PATTERN, "<redacted>").replace(OPENAI_KEY_PATTERN, "<redacted>").replace(NPM_TOKEN_PATTERN, "<redacted>").replace(JWT_PATTERN, "<redacted>").replace(PEM_BLOCK_PATTERN, "<redacted>").replace(BASIC_AUTH_URL_PATTERN, "$1<redacted>@").replace(GENERIC_SECRET_ASSIGNMENT_PATTERN, "$1<redacted>");
|
|
634
|
+
if (home.length > 0 && out.startsWith(home)) {
|
|
635
|
+
const rest = out.slice(home.length);
|
|
636
|
+
if (rest === "" || rest.startsWith("/"))
|
|
637
|
+
out = `~${rest}`;
|
|
638
|
+
}
|
|
639
|
+
return out;
|
|
640
|
+
}
|
|
641
|
+
function redact(value, home) {
|
|
642
|
+
if (typeof value === "string")
|
|
643
|
+
return redactString(value, home);
|
|
644
|
+
if (Array.isArray(value))
|
|
645
|
+
return value.map((v) => redact(v, home));
|
|
646
|
+
if (value !== null && typeof value === "object") {
|
|
647
|
+
const out = {};
|
|
648
|
+
for (const [k, v] of Object.entries(value)) {
|
|
649
|
+
out[k] = redact(v, home);
|
|
650
|
+
}
|
|
651
|
+
return out;
|
|
652
|
+
}
|
|
653
|
+
return value;
|
|
654
|
+
}
|
|
655
|
+
var GITHUB_TOKEN_PATTERN, CLASSIC_GITHUB_PAT_PATTERN, BEARER_TOKEN_PATTERN, AWS_ACCESS_KEY_PATTERN, SLACK_TOKEN_PATTERN, STRIPE_KEY_PATTERN, ANTHROPIC_KEY_PATTERN, OPENAI_KEY_PATTERN, NPM_TOKEN_PATTERN, JWT_PATTERN, PEM_BLOCK_PATTERN, BASIC_AUTH_URL_PATTERN, GENERIC_SECRET_ASSIGNMENT_PATTERN;
|
|
656
|
+
var init_redact = __esm(() => {
|
|
657
|
+
GITHUB_TOKEN_PATTERN = /\b(?:gho_|ghp_|ghs_|ghu_|ghr_|github_pat_)[A-Za-z0-9_]+\b/g;
|
|
658
|
+
CLASSIC_GITHUB_PAT_PATTERN = /\b((?:token|GITHUB_TOKEN|PAT|api[_-]?key|api[_-]?token)\s*[:=]\s*)[a-f0-9]{40}\b/gi;
|
|
659
|
+
BEARER_TOKEN_PATTERN = /\bBearer\s+\S+/g;
|
|
660
|
+
AWS_ACCESS_KEY_PATTERN = /\bAKIA[0-9A-Z]{16}\b/g;
|
|
661
|
+
SLACK_TOKEN_PATTERN = /\bxox[baprs]-[0-9A-Za-z-]+\b/g;
|
|
662
|
+
STRIPE_KEY_PATTERN = /\b(?:sk|pk|rk)_(?:live|test)_[0-9A-Za-z]{10,}\b/g;
|
|
663
|
+
ANTHROPIC_KEY_PATTERN = /\bsk-ant-[A-Za-z0-9_-]{20,}\b/g;
|
|
664
|
+
OPENAI_KEY_PATTERN = /\bsk-(?!ant-)[A-Za-z0-9]{20,}\b/g;
|
|
665
|
+
NPM_TOKEN_PATTERN = /\bnpm_[A-Za-z0-9]{36}\b/g;
|
|
666
|
+
JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g;
|
|
667
|
+
PEM_BLOCK_PATTERN = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;
|
|
668
|
+
BASIC_AUTH_URL_PATTERN = /(https?:\/\/)[^/\s:@]+:[^/\s@]+@/g;
|
|
669
|
+
GENERIC_SECRET_ASSIGNMENT_PATTERN = /\b((?:secret|password|passwd|api[_-]?key|access[_-]?key|client[_-]?secret|private[_-]?key)\s*[:=]\s*)[A-Za-z0-9+/_=-]{16,}\b/gi;
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// ../../harness/kernel/connectors/checkpoint/control-store/records.ts
|
|
673
|
+
import { z } from "zod";
|
|
674
|
+
var isoTimestamp, taskId, epochNumber, RunRecordSchema, InputRecordSchema, OwnershipRecordSchema, TransitionRecordSchema, ManifestRecordSchema, roundHeadIdentity, LoopBudgetsSchema, LoopStateRecordSchema, EffectRecordSchema, EscalationRecordSchema, ResolutionRecordSchema, ExecutionRoundMirrorRecordSchema;
|
|
675
|
+
var init_records = __esm(() => {
|
|
676
|
+
isoTimestamp = z.string().min(1);
|
|
677
|
+
taskId = z.number().int().positive();
|
|
678
|
+
epochNumber = z.number().int().nonnegative();
|
|
679
|
+
RunRecordSchema = z.object({
|
|
680
|
+
version: z.literal(1),
|
|
681
|
+
kind: z.literal("run"),
|
|
682
|
+
task: taskId,
|
|
683
|
+
runId: z.string().min(1),
|
|
684
|
+
pid: z.number().int().positive(),
|
|
685
|
+
host: z.string().min(1),
|
|
686
|
+
startedAt: isoTimestamp,
|
|
687
|
+
childStartedAt: z.string().min(1).nullable().optional(),
|
|
688
|
+
childCommand: z.string().min(1).nullable().optional()
|
|
167
689
|
}).strict();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
690
|
+
InputRecordSchema = z.object({
|
|
691
|
+
version: z.literal(1),
|
|
692
|
+
kind: z.literal("input"),
|
|
693
|
+
task: taskId,
|
|
694
|
+
runId: z.string().min(1),
|
|
695
|
+
source: z.union([z.literal("fresh"), z.literal("resume")]),
|
|
696
|
+
pr: z.number().int().positive().nullable(),
|
|
697
|
+
round: z.number().int().nonnegative(),
|
|
698
|
+
recordedAt: isoTimestamp
|
|
171
699
|
}).strict();
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
work: WorkSchema,
|
|
182
|
-
flow: FlowSchema,
|
|
183
|
-
runtime: z2.string().nullable(),
|
|
184
|
-
source: z2.string().nullable()
|
|
700
|
+
OwnershipRecordSchema = z.object({
|
|
701
|
+
version: z.literal(1),
|
|
702
|
+
kind: z.literal("ownership"),
|
|
703
|
+
task: taskId,
|
|
704
|
+
epoch: epochNumber,
|
|
705
|
+
ownerId: z.string().min(1),
|
|
706
|
+
pid: z.number().int().positive(),
|
|
707
|
+
host: z.string().min(1),
|
|
708
|
+
acquiredAt: isoTimestamp
|
|
185
709
|
}).strict();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
710
|
+
TransitionRecordSchema = z.object({
|
|
711
|
+
version: z.literal(1),
|
|
712
|
+
kind: z.literal("transition"),
|
|
713
|
+
task: taskId,
|
|
714
|
+
epoch: epochNumber,
|
|
715
|
+
seq: z.number().int().nonnegative(),
|
|
716
|
+
from: z.string().min(1),
|
|
717
|
+
to: z.string().min(1),
|
|
718
|
+
detail: z.string().optional(),
|
|
719
|
+
at: isoTimestamp
|
|
190
720
|
}).strict();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
721
|
+
ManifestRecordSchema = z.object({
|
|
722
|
+
version: z.literal(1),
|
|
723
|
+
kind: z.literal("manifest"),
|
|
724
|
+
task: taskId,
|
|
725
|
+
round: epochNumber,
|
|
726
|
+
repository: z.string().min(1),
|
|
727
|
+
pr: z.number().int().positive(),
|
|
728
|
+
branch: z.string().min(1),
|
|
729
|
+
baseSha: z.string().min(1).nullable(),
|
|
730
|
+
headSha: z.string().min(1),
|
|
731
|
+
briefHash: z.string().min(1).nullable(),
|
|
732
|
+
objectivesVersion: z.string().min(1).nullable(),
|
|
733
|
+
rulingOrdinal: epochNumber,
|
|
734
|
+
manifestVersion: z.literal(2).optional(),
|
|
735
|
+
pauseBoundRuling: z.object({
|
|
736
|
+
rulingId: z.string().min(1),
|
|
737
|
+
pauseId: z.string().min(1),
|
|
738
|
+
contentDigest: z.string().min(1)
|
|
739
|
+
}).strict().nullable().optional(),
|
|
740
|
+
policyDigest: z.string().min(1),
|
|
741
|
+
recordedAt: isoTimestamp
|
|
204
742
|
}).strict();
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
743
|
+
roundHeadIdentity = z.object({ round: z.number().int().positive(), head: z.string().min(1) }).strict();
|
|
744
|
+
LoopBudgetsSchema = z.object({
|
|
745
|
+
mechanicalRetries: z.number().int().nonnegative(),
|
|
746
|
+
reviewRounds: z.number().int().nonnegative(),
|
|
747
|
+
infrastructureRetries: z.number().int().nonnegative()
|
|
208
748
|
}).strict();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
749
|
+
LoopStateRecordSchema = z.object({
|
|
750
|
+
version: z.literal(1),
|
|
751
|
+
kind: z.literal("loop_state"),
|
|
752
|
+
task: taskId,
|
|
753
|
+
round: z.number().int().positive(),
|
|
754
|
+
phase: z.string().min(1),
|
|
755
|
+
pauseReason: z.string().min(1).nullable(),
|
|
756
|
+
budgets: LoopBudgetsSchema,
|
|
757
|
+
heldResult: roundHeadIdentity.nullable(),
|
|
758
|
+
deliveredFindings: roundHeadIdentity.nullable(),
|
|
759
|
+
repeatMemory: z.object({
|
|
760
|
+
blockingFindings: z.array(z.string()),
|
|
761
|
+
lastFailure: z.object({ signature: z.string(), message: z.string(), developerAttemptedSince: z.boolean().optional() }).nullable()
|
|
762
|
+
}).strict().optional(),
|
|
763
|
+
developerHandoff: z.object({
|
|
764
|
+
findings: z.array(z.object({ id: z.string().min(1), description: z.string().min(1) }).strict()),
|
|
765
|
+
failingChecks: z.array(z.string().min(1))
|
|
766
|
+
}).strict().optional(),
|
|
767
|
+
publicationExpectedBase: z.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
768
|
+
taskStartedAt: isoTimestamp.optional(),
|
|
769
|
+
phaseMs: z.record(z.string(), z.number().nonnegative()).optional(),
|
|
770
|
+
recordedAt: isoTimestamp
|
|
225
771
|
}).strict();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
comment_id: z2.number().int(),
|
|
239
|
-
objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
|
|
240
|
-
findings: z2.array(ReviewFindingSchema)
|
|
241
|
-
}).strict(),
|
|
242
|
-
z2.object({
|
|
243
|
-
type: z2.literal("escalation"),
|
|
244
|
-
class: z2.enum(["authority", "strategy", "product"]),
|
|
245
|
-
comment_id: z2.number().int()
|
|
246
|
-
}).strict(),
|
|
247
|
-
z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
|
|
248
|
-
z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
|
|
249
|
-
z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
|
|
250
|
-
z2.object({ type: z2.literal("completed") }).strict()
|
|
251
|
-
]);
|
|
252
|
-
dispatchShared = {
|
|
253
|
-
meta: HeaderMetaSchema,
|
|
254
|
-
subject: SubjectSchema,
|
|
255
|
-
kind: z2.literal("dispatch"),
|
|
256
|
-
...envelopeTail,
|
|
257
|
-
target_role: RoleSchema,
|
|
258
|
-
model: z2.string(),
|
|
259
|
-
round: z2.number().int().optional(),
|
|
260
|
-
effect_id: z2.string()
|
|
261
|
-
};
|
|
262
|
-
dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
|
|
263
|
-
DispatchEventSchema = z2.discriminatedUnion("event", [
|
|
264
|
-
z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
|
|
265
|
-
z2.object({
|
|
266
|
-
...dispatchShared,
|
|
267
|
-
event: z2.literal("outcome_received"),
|
|
268
|
-
outcome: DispatchOutcomeSchema,
|
|
269
|
-
usage: dispatchUsageField
|
|
270
|
-
}).strict(),
|
|
271
|
-
z2.object({
|
|
272
|
-
...dispatchShared,
|
|
273
|
-
event: z2.literal("dispatch_failed"),
|
|
274
|
-
reason: z2.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
|
|
275
|
-
usage_limit: z2.object({ agent: z2.string().min(1), reset_at: z2.string().nullable() }).strict().optional(),
|
|
276
|
-
usage: dispatchUsageField
|
|
277
|
-
}).strict()
|
|
278
|
-
]);
|
|
279
|
-
CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
280
|
-
CodeTokenSchema = z2.string().regex(CODE_TOKEN_PATTERN);
|
|
281
|
-
ReviewerVerdictSchema = z2.object({
|
|
282
|
-
role: RoleSchema,
|
|
283
|
-
outcome: z2.enum(["approve", "changes_requested", "not_reviewed"]),
|
|
284
|
-
blockers: z2.number().int().nonnegative()
|
|
772
|
+
EffectRecordSchema = z.object({
|
|
773
|
+
version: z.literal(1),
|
|
774
|
+
kind: z.literal("effect"),
|
|
775
|
+
task: taskId,
|
|
776
|
+
key: z.string().min(1),
|
|
777
|
+
operation: z.string().min(1),
|
|
778
|
+
target: z.string().min(1),
|
|
779
|
+
inputVersion: z.number().int().nonnegative(),
|
|
780
|
+
payloadDigest: z.string().min(1),
|
|
781
|
+
status: z.union([z.literal("started"), z.literal("verified"), z.literal("uncertain")]),
|
|
782
|
+
url: z.string().optional(),
|
|
783
|
+
recordedAt: isoTimestamp
|
|
285
784
|
}).strict();
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
head: z2.string(),
|
|
311
|
-
green: z2.boolean(),
|
|
312
|
-
confidence_value: z2.number().int().min(0).max(100).optional(),
|
|
313
|
-
confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
|
|
314
|
-
confidence_unavailable: z2.boolean().optional(),
|
|
315
|
-
extra_turn_spent: z2.boolean().optional()
|
|
316
|
-
}).strict(),
|
|
317
|
-
z2.object({
|
|
318
|
-
...loopShared,
|
|
319
|
-
event: z2.literal("verdicts_read"),
|
|
320
|
-
round: z2.number().int(),
|
|
321
|
-
head: z2.string(),
|
|
322
|
-
all_approve: z2.boolean(),
|
|
323
|
-
blockers: z2.number().int().nonnegative(),
|
|
324
|
-
findings: z2.array(ReviewFindingSchema).optional(),
|
|
325
|
-
reviewers: z2.array(ReviewerVerdictSchema).optional()
|
|
326
|
-
}).strict(),
|
|
327
|
-
z2.object({
|
|
328
|
-
...loopShared,
|
|
329
|
-
event: z2.literal("findings_compared"),
|
|
330
|
-
round: z2.number().int(),
|
|
331
|
-
open: z2.array(z2.string()),
|
|
332
|
-
resolved: z2.array(z2.string()),
|
|
333
|
-
new: z2.array(z2.string()),
|
|
334
|
-
recurring: z2.array(z2.string())
|
|
335
|
-
}).strict(),
|
|
336
|
-
z2.object({
|
|
337
|
-
...loopShared,
|
|
338
|
-
event: z2.literal("stop_condition_met"),
|
|
339
|
-
round: z2.number().int(),
|
|
340
|
-
condition: z2.enum([
|
|
341
|
-
"green",
|
|
342
|
-
"max_rounds",
|
|
343
|
-
"no_progress",
|
|
344
|
-
"escalated",
|
|
345
|
-
"principal_stop",
|
|
346
|
-
"confidence",
|
|
347
|
-
"reappearance",
|
|
348
|
-
"repeat_finding",
|
|
349
|
-
"repeat_failure",
|
|
350
|
-
"time_budget"
|
|
351
|
-
])
|
|
352
|
-
}).strict(),
|
|
353
|
-
z2.object({
|
|
354
|
-
...loopShared,
|
|
355
|
-
event: z2.literal("paused"),
|
|
356
|
-
round: z2.number().int(),
|
|
357
|
-
reason: z2.enum(["escalation", "principal_item", "refreeze_needed"]),
|
|
358
|
-
reason_code: CodeTokenSchema.optional()
|
|
359
|
-
}).strict(),
|
|
360
|
-
z2.object({
|
|
361
|
-
...loopShared,
|
|
362
|
-
event: z2.literal("resumed"),
|
|
363
|
-
round: z2.number().int(),
|
|
364
|
-
by: z2.enum(["principal", "driver"])
|
|
365
|
-
}).strict(),
|
|
366
|
-
z2.object({
|
|
367
|
-
...loopShared,
|
|
368
|
-
event: z2.literal("cancelled"),
|
|
369
|
-
round: z2.number().int(),
|
|
370
|
-
by: z2.literal("principal")
|
|
371
|
-
}).strict(),
|
|
372
|
-
z2.object({
|
|
373
|
-
...loopShared,
|
|
374
|
-
event: z2.literal("unpushed_work_resume"),
|
|
375
|
-
round: z2.number().int(),
|
|
376
|
-
branch: z2.string(),
|
|
377
|
-
detail: z2.string()
|
|
378
|
-
}).strict(),
|
|
379
|
-
z2.object({
|
|
380
|
-
...loopShared,
|
|
381
|
-
event: z2.literal("round_ended"),
|
|
382
|
-
round: z2.number().int(),
|
|
383
|
-
base_head: z2.string(),
|
|
384
|
-
head: z2.string(),
|
|
385
|
-
files_changed: z2.number().int().nonnegative(),
|
|
386
|
-
insertions: z2.number().int().nonnegative(),
|
|
387
|
-
deletions: z2.number().int().nonnegative(),
|
|
388
|
-
wall_ms: z2.number().nonnegative(),
|
|
389
|
-
outcome: z2.enum(["green", "changes_requested", "escalated"])
|
|
390
|
-
}).strict(),
|
|
391
|
-
z2.object({
|
|
392
|
-
...loopShared,
|
|
393
|
-
event: z2.literal("journal_finalized"),
|
|
394
|
-
rounds: z2.number().int().nonnegative(),
|
|
395
|
-
total_wall_ms: z2.number().nonnegative(),
|
|
396
|
-
time_to_green_ms: z2.number().nonnegative().nullable(),
|
|
397
|
-
files_changed_total: z2.number().int().nonnegative(),
|
|
398
|
-
final_head: z2.string(),
|
|
399
|
-
result: z2.enum(["merged_ready", "stopped"])
|
|
400
|
-
}).strict(),
|
|
401
|
-
z2.object({
|
|
402
|
-
...loopShared,
|
|
403
|
-
event: z2.literal("infrastructure_retry"),
|
|
404
|
-
round: z2.number().int(),
|
|
405
|
-
failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
|
|
406
|
-
attempts: z2.number().int().positive(),
|
|
407
|
-
outcome: z2.enum(["recovered", "exhausted"])
|
|
408
|
-
}).strict(),
|
|
409
|
-
z2.object({
|
|
410
|
-
...loopShared,
|
|
411
|
-
event: z2.literal("driver_heartbeat"),
|
|
412
|
-
task: z2.number().int(),
|
|
413
|
-
pr: z2.number().int().positive().optional(),
|
|
414
|
-
round: z2.number().int(),
|
|
415
|
-
phase: z2.string()
|
|
416
|
-
}).strict(),
|
|
417
|
-
z2.object({
|
|
418
|
-
...loopShared,
|
|
419
|
-
event: z2.literal("conflict_reentry"),
|
|
420
|
-
task: z2.number().int(),
|
|
421
|
-
pr: z2.number().int().positive(),
|
|
422
|
-
attempt: z2.number().int().positive(),
|
|
423
|
-
bound: z2.number().int().positive()
|
|
424
|
-
}).strict(),
|
|
425
|
-
z2.object({
|
|
426
|
-
...loopShared,
|
|
427
|
-
event: z2.literal("storage_push"),
|
|
428
|
-
round: z2.number().int(),
|
|
429
|
-
branch: z2.string(),
|
|
430
|
-
head: z2.string()
|
|
431
|
-
}).strict(),
|
|
432
|
-
z2.object({
|
|
433
|
-
...loopShared,
|
|
434
|
-
event: z2.literal("local_checks_run"),
|
|
435
|
-
round: z2.number().int(),
|
|
436
|
-
head: z2.string().nullable(),
|
|
437
|
-
passed: z2.boolean(),
|
|
438
|
-
wall_ms: z2.number().nonnegative()
|
|
439
|
-
}).strict(),
|
|
440
|
-
z2.object({
|
|
441
|
-
...loopShared,
|
|
442
|
-
event: z2.literal("ready_push"),
|
|
443
|
-
round: z2.number().int(),
|
|
444
|
-
head: z2.string(),
|
|
445
|
-
outcome: z2.enum(["passed", "refused"]),
|
|
446
|
-
selected: z2.number().int().nonnegative(),
|
|
447
|
-
failed: z2.number().int().nonnegative(),
|
|
448
|
-
rerun: z2.boolean(),
|
|
449
|
-
wall_ms: z2.number().nonnegative()
|
|
450
|
-
}).strict(),
|
|
451
|
-
z2.object({
|
|
452
|
-
...loopShared,
|
|
453
|
-
event: z2.literal("failed_tests_rerun"),
|
|
454
|
-
round: z2.number().int(),
|
|
455
|
-
head: z2.string(),
|
|
456
|
-
rerun_of: z2.string(),
|
|
457
|
-
failed_files: z2.number().int().nonnegative(),
|
|
458
|
-
affected_files: z2.number().int().nonnegative(),
|
|
459
|
-
full_count: z2.number().int().nonnegative()
|
|
460
|
-
}).strict(),
|
|
461
|
-
z2.object({
|
|
462
|
-
...loopShared,
|
|
463
|
-
event: z2.literal("pr_opened"),
|
|
464
|
-
round: z2.number().int(),
|
|
465
|
-
pr: z2.number().int().positive(),
|
|
466
|
-
head: z2.string()
|
|
467
|
-
}).strict(),
|
|
468
|
-
z2.object({
|
|
469
|
-
...loopShared,
|
|
470
|
-
event: z2.literal("ci_result_read"),
|
|
471
|
-
round: z2.number().int(),
|
|
472
|
-
pr: z2.number().int().positive(),
|
|
473
|
-
head: z2.string(),
|
|
474
|
-
conclusion: z2.enum(["green", "red", "pending", "skipped"]),
|
|
475
|
-
failing_checks: z2.array(z2.string()),
|
|
476
|
-
wait_ms: z2.number().nonnegative()
|
|
477
|
-
}).strict(),
|
|
478
|
-
z2.object({
|
|
479
|
-
...loopShared,
|
|
480
|
-
event: z2.literal("phase_time"),
|
|
481
|
-
round: z2.number().int(),
|
|
482
|
-
phase: z2.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
|
|
483
|
-
step: z2.string(),
|
|
484
|
-
wall_ms: z2.number().nonnegative()
|
|
485
|
-
}).strict(),
|
|
486
|
-
z2.object({
|
|
487
|
-
...loopShared,
|
|
488
|
-
event: z2.literal("driver_exited"),
|
|
489
|
-
task: z2.number().int(),
|
|
490
|
-
reason: z2.enum(["finished", "paused", "reexec", "error", "signal"]),
|
|
491
|
-
last_decision: z2.string(),
|
|
492
|
-
exit_code: z2.number().int().optional(),
|
|
493
|
-
error_class: CodeTokenSchema.optional()
|
|
494
|
-
}).strict()
|
|
495
|
-
]);
|
|
496
|
-
ForgeOpSchema = z2.enum([
|
|
497
|
-
"pr.create",
|
|
498
|
-
"pr.comment",
|
|
499
|
-
"pr.body.replace",
|
|
500
|
-
"pr.refreeze",
|
|
501
|
-
"issue.create",
|
|
502
|
-
"issue.edit",
|
|
503
|
-
"issue.comment",
|
|
504
|
-
"milestone.create",
|
|
505
|
-
"milestone.edit",
|
|
506
|
-
"milestone.close",
|
|
507
|
-
"label.add",
|
|
508
|
-
"label.remove"
|
|
509
|
-
]);
|
|
510
|
-
ForgeWriteTargetSchema = z2.object({
|
|
511
|
-
issue: z2.number().int().optional(),
|
|
512
|
-
pr: z2.number().int().optional()
|
|
785
|
+
EscalationRecordSchema = z.object({
|
|
786
|
+
version: z.literal(1),
|
|
787
|
+
kind: z.literal("escalation"),
|
|
788
|
+
task: taskId,
|
|
789
|
+
escalationId: z.string().min(1),
|
|
790
|
+
round: epochNumber,
|
|
791
|
+
head: z.string().min(1),
|
|
792
|
+
branch: z.string().min(1),
|
|
793
|
+
pr: z.number().int().positive().nullable(),
|
|
794
|
+
runId: z.string().min(1),
|
|
795
|
+
pid: z.number().int().positive(),
|
|
796
|
+
host: z.string().min(1),
|
|
797
|
+
agent: z.string().min(1).optional(),
|
|
798
|
+
reason: z.string().min(1),
|
|
799
|
+
detail: z.string().optional(),
|
|
800
|
+
evidence: z.string().optional(),
|
|
801
|
+
attemptedRecovery: z.string().min(1),
|
|
802
|
+
requestedDecision: z.string().min(1),
|
|
803
|
+
recipient: z.string().min(1),
|
|
804
|
+
briefHash: z.string().min(1).nullable(),
|
|
805
|
+
objectivesVersion: z.string().min(1).nullable(),
|
|
806
|
+
rulingOrdinal: epochNumber,
|
|
807
|
+
policyDigest: z.string().min(1),
|
|
808
|
+
recordedAt: isoTimestamp
|
|
513
809
|
}).strict();
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
|
|
524
|
-
z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
|
|
525
|
-
z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
|
|
526
|
-
]);
|
|
527
|
-
GateOutcomeSchema = z2.enum([
|
|
528
|
-
"pass",
|
|
529
|
-
"fail",
|
|
530
|
-
"wait",
|
|
531
|
-
"skip",
|
|
532
|
-
"invalid_input",
|
|
533
|
-
"unavailable_dependency",
|
|
534
|
-
"timeout",
|
|
535
|
-
"cancelled"
|
|
536
|
-
]);
|
|
537
|
-
gateShared = {
|
|
538
|
-
meta: HeaderMetaSchema,
|
|
539
|
-
subject: SubjectSchema,
|
|
540
|
-
kind: z2.literal("gate"),
|
|
541
|
-
...envelopeTail,
|
|
542
|
-
check: z2.string(),
|
|
543
|
-
check_version: z2.string().nullable(),
|
|
544
|
-
policy_version: z2.string().nullable(),
|
|
545
|
-
input_fingerprint: z2.string().nullable()
|
|
546
|
-
};
|
|
547
|
-
GateEventSchema = z2.discriminatedUnion("event", [
|
|
548
|
-
z2.object({
|
|
549
|
-
...gateShared,
|
|
550
|
-
event: z2.literal("checked"),
|
|
551
|
-
outcome: GateOutcomeSchema,
|
|
552
|
-
reason: z2.string().optional()
|
|
553
|
-
}).strict(),
|
|
554
|
-
z2.object({
|
|
555
|
-
meta: HeaderMetaSchema,
|
|
556
|
-
subject: SubjectSchema,
|
|
557
|
-
kind: z2.literal("gate"),
|
|
558
|
-
...envelopeTail,
|
|
559
|
-
event: z2.literal("summary"),
|
|
560
|
-
ran: z2.number().int().nonnegative(),
|
|
561
|
-
passed: z2.number().int().nonnegative(),
|
|
562
|
-
failed: z2.number().int().nonnegative(),
|
|
563
|
-
skipped: z2.number().int().nonnegative(),
|
|
564
|
-
failed_checks: z2.array(z2.string())
|
|
565
|
-
}).strict()
|
|
566
|
-
]);
|
|
567
|
-
OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
|
|
568
|
-
operationShared = {
|
|
569
|
-
meta: HeaderMetaSchema,
|
|
570
|
-
subject: SubjectSchema,
|
|
571
|
-
kind: z2.literal("operation"),
|
|
572
|
-
...envelopeTail,
|
|
573
|
-
operation: z2.string(),
|
|
574
|
-
target: z2.string().nullable()
|
|
575
|
-
};
|
|
576
|
-
OperationEventSchema = z2.discriminatedUnion("event", [
|
|
577
|
-
z2.object({
|
|
578
|
-
...operationShared,
|
|
579
|
-
event: z2.literal("completed"),
|
|
580
|
-
result: OperationResultSchema,
|
|
581
|
-
error_class: z2.string().nullable(),
|
|
582
|
-
field_names: z2.array(z2.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
|
|
583
|
-
}).strict()
|
|
584
|
-
]);
|
|
585
|
-
UsageUnitsSchema = z2.object({
|
|
586
|
-
input: z2.number().nonnegative().nullable(),
|
|
587
|
-
output: z2.number().nonnegative().nullable(),
|
|
588
|
-
cache: z2.number().nonnegative().nullable()
|
|
810
|
+
ResolutionRecordSchema = z.object({
|
|
811
|
+
version: z.literal(1),
|
|
812
|
+
kind: z.literal("resolution"),
|
|
813
|
+
task: taskId,
|
|
814
|
+
escalationId: z.string().min(1),
|
|
815
|
+
decision: z.union([z.literal("resume"), z.literal("cancel")]),
|
|
816
|
+
authenticatedBy: z.string().min(1),
|
|
817
|
+
authenticatedFrom: z.string().min(1),
|
|
818
|
+
consumedAt: isoTimestamp
|
|
589
819
|
}).strict();
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
UsageEventSchema = z2.discriminatedUnion("event", [
|
|
600
|
-
z2.object({
|
|
601
|
-
...usageShared,
|
|
602
|
-
event: z2.literal("observed"),
|
|
603
|
-
units: UsageUnitsSchema,
|
|
604
|
-
unknown_reason: z2.string().nullable()
|
|
605
|
-
}).strict()
|
|
606
|
-
]);
|
|
607
|
-
RoleAttemptOutcomeSchema = z2.enum([
|
|
608
|
-
"completed",
|
|
609
|
-
"incomplete",
|
|
610
|
-
"infrastructure_failed",
|
|
611
|
-
"cancelled",
|
|
612
|
-
"timed_out",
|
|
613
|
-
"capability_refused"
|
|
614
|
-
]);
|
|
615
|
-
roleAttemptShared = {
|
|
616
|
-
meta: HeaderMetaSchema,
|
|
617
|
-
subject: SubjectSchema,
|
|
618
|
-
kind: z2.literal("role_attempt"),
|
|
619
|
-
...envelopeTail,
|
|
620
|
-
actor: z2.string().nullable(),
|
|
621
|
-
attempt: z2.number().int().nullable(),
|
|
622
|
-
effect_id: z2.string(),
|
|
623
|
-
model: z2.string().nullable()
|
|
624
|
-
};
|
|
625
|
-
RoleAttemptEventSchema = z2.discriminatedUnion("event", [
|
|
626
|
-
z2.object({
|
|
627
|
-
...roleAttemptShared,
|
|
628
|
-
event: z2.literal("attempted"),
|
|
629
|
-
outcome: RoleAttemptOutcomeSchema,
|
|
630
|
-
usage: dispatchUsageField
|
|
631
|
-
}).strict()
|
|
632
|
-
]);
|
|
633
|
-
handoffShared = {
|
|
634
|
-
meta: HeaderMetaSchema,
|
|
635
|
-
subject: SubjectSchema,
|
|
636
|
-
kind: z2.literal("handoff"),
|
|
637
|
-
...envelopeTail,
|
|
638
|
-
class: z2.enum(["authority", "strategy", "product"]),
|
|
639
|
-
reason: z2.string()
|
|
640
|
-
};
|
|
641
|
-
HandoffEventSchema = z2.discriminatedUnion("event", [
|
|
642
|
-
z2.object({
|
|
643
|
-
...handoffShared,
|
|
644
|
-
event: z2.literal("raised"),
|
|
645
|
-
requested_decision: z2.string().nullable()
|
|
646
|
-
}).strict(),
|
|
647
|
-
z2.object({
|
|
648
|
-
...handoffShared,
|
|
649
|
-
event: z2.literal("resolved"),
|
|
650
|
-
resolution: z2.string().nullable(),
|
|
651
|
-
resolved_by: z2.string().nullable()
|
|
652
|
-
}).strict()
|
|
653
|
-
]);
|
|
654
|
-
EffectTargetSchema = z2.object({
|
|
655
|
-
kind: z2.string(),
|
|
656
|
-
ref: z2.string()
|
|
820
|
+
ExecutionRoundMirrorRecordSchema = z.object({
|
|
821
|
+
version: z.literal(1),
|
|
822
|
+
kind: z.literal("execution_round"),
|
|
823
|
+
task: taskId,
|
|
824
|
+
repository: z.string().min(1),
|
|
825
|
+
threadId: z.string().min(1),
|
|
826
|
+
checkpointId: z.string().min(1),
|
|
827
|
+
round: z.number().int().positive(),
|
|
828
|
+
recordedAt: isoTimestamp
|
|
657
829
|
}).strict();
|
|
658
|
-
effectShared = {
|
|
659
|
-
meta: HeaderMetaSchema,
|
|
660
|
-
subject: SubjectSchema,
|
|
661
|
-
kind: z2.literal("effect"),
|
|
662
|
-
...envelopeTail,
|
|
663
|
-
effect_id: z2.string(),
|
|
664
|
-
target: EffectTargetSchema
|
|
665
|
-
};
|
|
666
|
-
EffectEventSchema = z2.discriminatedUnion("event", [
|
|
667
|
-
z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
|
|
668
|
-
z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
|
|
669
|
-
z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
|
|
670
|
-
]);
|
|
671
|
-
CustomFieldValueSchema = z2.union([z2.string().max(CUSTOM_TEXT_MAX_LENGTH), z2.number().finite(), z2.boolean()]);
|
|
672
|
-
customShared = {
|
|
673
|
-
meta: HeaderMetaSchema,
|
|
674
|
-
subject: SubjectSchema,
|
|
675
|
-
kind: z2.literal("custom"),
|
|
676
|
-
...envelopeTail
|
|
677
|
-
};
|
|
678
|
-
CustomEventSchema = z2.discriminatedUnion("event", [
|
|
679
|
-
z2.object({
|
|
680
|
-
...customShared,
|
|
681
|
-
event: z2.literal("recorded"),
|
|
682
|
-
name: z2.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
|
|
683
|
-
fields: z2.record(z2.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH).regex(CUSTOM_FIELD_NAME_PATTERN), CustomFieldValueSchema).refine((f) => Object.keys(f).length <= CUSTOM_EVENT_MAX_FIELDS, {
|
|
684
|
-
message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
|
|
685
|
-
})
|
|
686
|
-
}).strict()
|
|
687
|
-
]);
|
|
688
|
-
LogEventSchema = z2.union([
|
|
689
|
-
DispatchEventSchema,
|
|
690
|
-
DevReviewLoopEventSchema,
|
|
691
|
-
ForgeWriteEventSchema,
|
|
692
|
-
GateEventSchema,
|
|
693
|
-
OperationEventSchema,
|
|
694
|
-
UsageEventSchema,
|
|
695
|
-
RoleAttemptEventSchema,
|
|
696
|
-
HandoffEventSchema,
|
|
697
|
-
EffectEventSchema,
|
|
698
|
-
CustomEventSchema
|
|
699
|
-
]);
|
|
700
830
|
});
|
|
701
831
|
|
|
702
|
-
// ../../harness/kernel/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
if (lines.length > 0 && lines.every((l) => NO_DOCUMENTATION_SENTINEL_RE.test(l))) {
|
|
718
|
-
return { ok: true, value: { kind: "none" } };
|
|
719
|
-
}
|
|
720
|
-
const sources = [];
|
|
721
|
-
const errors = [];
|
|
722
|
-
for (const line of lines) {
|
|
723
|
-
const m = ISSUE_DOCUMENTATION_LINE_RE.exec(line);
|
|
724
|
-
if (!m) {
|
|
725
|
-
errors.push(`"${line}" is not a well-formed Documentation line — expected \`- <source> — <mechanism it governs>\` (or the \`None\` sentinel).`);
|
|
726
|
-
continue;
|
|
727
|
-
}
|
|
728
|
-
const source = m[1].trim();
|
|
729
|
-
const mechanism = m[2].trim();
|
|
730
|
-
if (source.length === 0 || mechanism.length === 0) {
|
|
731
|
-
errors.push(`"${line}" is missing a source or a mechanism — a Documentation line needs both.`);
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
const objectiveIds = m[3] ? [...m[3].matchAll(/O(\d+)/gi)].map((r) => Number.parseInt(r[1], 10)) : [];
|
|
735
|
-
sources.push({ source, mechanism, objectiveIds });
|
|
736
|
-
}
|
|
737
|
-
if (sources.length === 0 && errors.length === 0) {
|
|
738
|
-
errors.push("the `## Documentation` section has no well-formed `- <source> — <mechanism>` lines, and no `None` sentinel.");
|
|
739
|
-
}
|
|
740
|
-
if (errors.length > 0)
|
|
741
|
-
return { ok: false, errors };
|
|
742
|
-
return { ok: true, value: { kind: "sources", sources } };
|
|
743
|
-
}
|
|
744
|
-
var NO_DOCUMENTATION_SENTINEL_RE, ISSUE_DOCUMENTATION_LINE_RE;
|
|
745
|
-
var init_issue_documentation = __esm(() => {
|
|
746
|
-
NO_DOCUMENTATION_SENTINEL_RE = /^none\b/i;
|
|
747
|
-
ISSUE_DOCUMENTATION_LINE_RE = /^[-*]\s+(.+?)(?:\s+-\s+|\s*[—–]\s*)(.+?)(?:\s*\((O\d+(?:\s*,\s*O\d+)*)\))?$/i;
|
|
832
|
+
// ../../harness/kernel/connectors/checkpoint/control-store/local.ts
|
|
833
|
+
var CONTROL_AREA_DIRNAME = "control";
|
|
834
|
+
var init_local = __esm(() => {
|
|
835
|
+
init_records();
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// ../../harness/kernel/connectors/checkpoint/control-store/migration.ts
|
|
839
|
+
var init_migration = __esm(() => {
|
|
840
|
+
init_local();
|
|
841
|
+
});
|
|
842
|
+
// ../../harness/kernel/connectors/checkpoint/control-store/index.ts
|
|
843
|
+
var init_control_store = __esm(() => {
|
|
844
|
+
init_records();
|
|
845
|
+
init_local();
|
|
846
|
+
init_migration();
|
|
748
847
|
});
|
|
749
848
|
|
|
750
|
-
// ../../harness/kernel/
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
closeSync,
|
|
754
|
-
fsyncSync,
|
|
755
|
-
mkdirSync,
|
|
756
|
-
openSync,
|
|
757
|
-
readdirSync,
|
|
758
|
-
readFileSync,
|
|
759
|
-
renameSync,
|
|
760
|
-
rmSync,
|
|
761
|
-
writeSync
|
|
762
|
-
} from "node:fs";
|
|
763
|
-
import { homedir } from "node:os";
|
|
764
|
-
import { join } from "node:path";
|
|
765
|
-
function registryDir() {
|
|
766
|
-
return process.env.VINAYA_PROCESS_REGISTRY_DIR || join(homedir(), ".vinaya", "process-registry");
|
|
849
|
+
// ../../harness/kernel/config/loader/config-provider.ts
|
|
850
|
+
function installConfigProvider(provider) {
|
|
851
|
+
installed = provider;
|
|
767
852
|
}
|
|
768
|
-
|
|
769
|
-
if (
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
mkdirSync(folder, { recursive: true });
|
|
773
|
-
const final = join(folder, `${entry.pid}.json`);
|
|
774
|
-
const temp = `${final}.${process.pid}.tmp`;
|
|
775
|
-
const fd = openSync(temp, "w", 384);
|
|
776
|
-
try {
|
|
777
|
-
writeSync(fd, `${JSON.stringify(entry)}
|
|
778
|
-
`);
|
|
779
|
-
fsyncSync(fd);
|
|
780
|
-
} finally {
|
|
781
|
-
closeSync(fd);
|
|
782
|
-
}
|
|
783
|
-
renameSync(temp, final);
|
|
853
|
+
function configProvider() {
|
|
854
|
+
if (!installed)
|
|
855
|
+
throw new Error(NO_CONFIG_PROVIDER_MESSAGE);
|
|
856
|
+
return installed;
|
|
784
857
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
858
|
+
var installed = null, NO_CONFIG_PROVIDER_MESSAGE = "no configuration provider is installed — a composition root must call installConfigProvider() before any configuration read";
|
|
859
|
+
|
|
860
|
+
// ../../harness/kernel/config/schema/config-schema.ts
|
|
861
|
+
import { isAbsolute } from "node:path";
|
|
862
|
+
import { z as z2 } from "zod";
|
|
863
|
+
function checkEntrySchema(fields) {
|
|
864
|
+
return z2.object(fields).superRefine((entry, ctx) => {
|
|
865
|
+
const env = entry.env;
|
|
866
|
+
if (!env)
|
|
867
|
+
return;
|
|
868
|
+
for (const [key, value] of Object.entries(env)) {
|
|
869
|
+
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
870
|
+
continue;
|
|
871
|
+
const members = value.anyOf;
|
|
872
|
+
if (new Set(members).size !== members.length) {
|
|
873
|
+
ctx.addIssue({
|
|
874
|
+
code: z2.ZodIssueCode.custom,
|
|
875
|
+
message: `env.${key}.anyOf has duplicate members`,
|
|
876
|
+
path: ["env", key, "anyOf"]
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
if (!members.includes(key)) {
|
|
880
|
+
ctx.addIssue({
|
|
881
|
+
code: z2.ZodIssueCode.custom,
|
|
882
|
+
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
883
|
+
path: ["env", key, "anyOf"]
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
});
|
|
804
888
|
}
|
|
805
|
-
function
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
return
|
|
810
|
-
|
|
811
|
-
return null;
|
|
812
|
-
}
|
|
889
|
+
function isSafeRepoRelPath(p) {
|
|
890
|
+
if (p.length === 0)
|
|
891
|
+
return false;
|
|
892
|
+
if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
|
|
893
|
+
return false;
|
|
894
|
+
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
813
895
|
}
|
|
814
|
-
function
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
return out === "" ? null : out;
|
|
821
|
-
} catch {
|
|
822
|
-
return null;
|
|
823
|
-
}
|
|
896
|
+
function hookBlockPathRule(prefixes) {
|
|
897
|
+
const isCanonical = (p) => prefixes.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
|
|
898
|
+
const schema = SafeRepoRelPath.refine(isCanonical, {
|
|
899
|
+
message: `must start with one of ${prefixes.join(", ")} (byte-exact, case-sensitive)`
|
|
900
|
+
});
|
|
901
|
+
return { isCanonical, schema };
|
|
824
902
|
}
|
|
825
|
-
function
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
903
|
+
function managedManifestSchemas(agentVendors, hookBlockPrefixes) {
|
|
904
|
+
const block = z2.object({
|
|
905
|
+
path: hookBlockPathRule(hookBlockPrefixes).schema,
|
|
906
|
+
marker: z2.string(),
|
|
907
|
+
comment: z2.enum(["hash", "html"])
|
|
908
|
+
});
|
|
909
|
+
const manifest = z2.object({
|
|
910
|
+
version: z2.number().int().positive(),
|
|
911
|
+
files: z2.array(SafeRepoRelPath),
|
|
912
|
+
blocks: z2.array(block),
|
|
913
|
+
labels: z2.array(z2.string()),
|
|
914
|
+
agents: z2.array(z2.enum(agentVendors)).optional()
|
|
915
|
+
});
|
|
916
|
+
return { block, manifest };
|
|
830
917
|
}
|
|
831
|
-
function
|
|
832
|
-
return
|
|
918
|
+
function logsSchema(events) {
|
|
919
|
+
return z2.object({
|
|
920
|
+
folder: z2.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
921
|
+
url: z2.string().url().optional(),
|
|
922
|
+
headers: z2.record(z2.string()).optional(),
|
|
923
|
+
readHeaders: z2.record(z2.string()).optional(),
|
|
924
|
+
events: events.optional()
|
|
925
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
926
|
+
message: "logs: set at most one of folder/url"
|
|
927
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
928
|
+
message: "logs: headers requires url"
|
|
929
|
+
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
930
|
+
message: "logs: readHeaders requires url"
|
|
931
|
+
}).or(z2.literal(false)).optional();
|
|
833
932
|
}
|
|
834
|
-
function
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
933
|
+
function kernelConfigFragment(leaves) {
|
|
934
|
+
return {
|
|
935
|
+
rings: z2.object({
|
|
936
|
+
ring1_forgeWriteInterception: z2.boolean(),
|
|
937
|
+
ring2_asyncAudits: z2.boolean()
|
|
938
|
+
}).optional(),
|
|
939
|
+
checks: z2.record(z2.string(), checkEntrySchema(leaves.checkEntryFields)).optional(),
|
|
940
|
+
managed: managedManifestSchemas(leaves.agentVendors, leaves.hookBlockPrefixes).manifest.optional(),
|
|
941
|
+
ci: z2.object({ setup: z2.string().min(1) }).optional(),
|
|
942
|
+
logPublish: z2.unknown().refine((v) => v === undefined, {
|
|
943
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
944
|
+
}),
|
|
945
|
+
runtimeDir: z2.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
946
|
+
runner: z2.enum(["standalone", "atta-engine"]).optional(),
|
|
947
|
+
logs: logsSchema(leaves.logEvents)
|
|
948
|
+
};
|
|
841
949
|
}
|
|
842
|
-
function
|
|
843
|
-
|
|
844
|
-
return entry.members ?? [];
|
|
845
|
-
try {
|
|
846
|
-
const rows = execFileSync("ps", ["-axo", "pid=,pgid="], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
847
|
-
const members = rows.trim().split(`
|
|
848
|
-
`).flatMap((line) => {
|
|
849
|
-
const [pid, group] = line.trim().split(/\s+/).map(Number);
|
|
850
|
-
if (group !== entry.pid || pid === undefined || pid === entry.pid)
|
|
851
|
-
return [];
|
|
852
|
-
const member = identityOf(pid);
|
|
853
|
-
return member ? [member] : [];
|
|
854
|
-
});
|
|
855
|
-
return isSameProcessAlive(entry) ? members : entry.members ?? [];
|
|
856
|
-
} catch {
|
|
857
|
-
return entry.members ?? [];
|
|
858
|
-
}
|
|
950
|
+
function resolveRuntimeDirSetting(config) {
|
|
951
|
+
return config?.runtimeDir ?? null;
|
|
859
952
|
}
|
|
860
|
-
function
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
}) {
|
|
874
|
-
const now = inspect.identity(entry.pid);
|
|
875
|
-
if (now !== null)
|
|
876
|
-
return now.startTime === entry.startTime;
|
|
877
|
-
return entry.processGroup === true && (entry.members ?? []).some((member) => inspect.identity(member.pid)?.startTime === member.startTime && inspect.groupOf(member.pid) === entry.pid);
|
|
953
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
954
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
955
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
956
|
+
}
|
|
957
|
+
function resolveLogsSetting(config) {
|
|
958
|
+
const raw = config?.logs;
|
|
959
|
+
if (!raw)
|
|
960
|
+
return null;
|
|
961
|
+
if (raw.url !== undefined)
|
|
962
|
+
return { url: raw.url, headers: raw.headers };
|
|
963
|
+
if (raw.folder !== undefined)
|
|
964
|
+
return { folder: raw.folder };
|
|
965
|
+
return null;
|
|
878
966
|
}
|
|
879
|
-
function
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
967
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
968
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
969
|
+
if (!anchored)
|
|
970
|
+
return null;
|
|
971
|
+
if ("url" in local)
|
|
972
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
973
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
885
974
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
const
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
for (const entry of entries) {
|
|
893
|
-
if (entry.processGroup && isSameProcessAlive(entry)) {
|
|
894
|
-
entry.members = observedGroupMembers(entry);
|
|
895
|
-
await registerProcess(entry, { dir });
|
|
896
|
-
}
|
|
897
|
-
if (registeredProcessOwned(entry)) {
|
|
898
|
-
live.push(entry);
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
if (entry.processGroup && identityOf(entry.pid) === null && groupExists(entry.pid))
|
|
902
|
-
throw new Error(`process registry: group ${entry.pid} has no verifiable recorded member; refusing to signal an unowned group`);
|
|
903
|
-
report.alreadyGone.push(identity(entry));
|
|
904
|
-
}
|
|
905
|
-
for (const entry of live)
|
|
906
|
-
signal(entry, "SIGTERM");
|
|
907
|
-
const deadline = Date.now() + Math.max(0, opts.graceMs);
|
|
908
|
-
let remaining = live;
|
|
909
|
-
while (remaining.length > 0 && Date.now() < deadline) {
|
|
910
|
-
await sleep(Math.min(50, Math.max(1, deadline - Date.now())));
|
|
911
|
-
remaining = remaining.filter((entry) => registeredProcessOwned(entry));
|
|
912
|
-
}
|
|
913
|
-
for (const entry of live)
|
|
914
|
-
if (!remaining.includes(entry))
|
|
915
|
-
report.terminated.push(identity(entry));
|
|
916
|
-
for (const entry of remaining) {
|
|
917
|
-
signal(entry, "SIGKILL");
|
|
918
|
-
report.killed.push(identity(entry));
|
|
919
|
-
}
|
|
920
|
-
const killDeadline = Date.now() + 2000;
|
|
921
|
-
while (remaining.length > 0 && Date.now() < killDeadline) {
|
|
922
|
-
await sleep(20);
|
|
923
|
-
remaining = remaining.filter((entry) => registeredProcessOwned(entry));
|
|
975
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
976
|
+
if (!headers)
|
|
977
|
+
return;
|
|
978
|
+
const resolved = {};
|
|
979
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
980
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
924
981
|
}
|
|
925
|
-
|
|
926
|
-
return report;
|
|
982
|
+
return resolved;
|
|
927
983
|
}
|
|
928
|
-
var
|
|
929
|
-
var
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
} catch {
|
|
951
|
-
if (existsSync("/proc/self/stat"))
|
|
952
|
-
return null;
|
|
953
|
-
}
|
|
954
|
-
if (stat !== null) {
|
|
955
|
-
const ticks = stat.slice(stat.lastIndexOf(")") + 2).split(" ").at(22 - 3);
|
|
956
|
-
return ticks === undefined ? null : `ticks:${ticks}`;
|
|
957
|
-
}
|
|
958
|
-
const result = spawnSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
959
|
-
encoding: "utf8",
|
|
960
|
-
env: { PATH: process.env.PATH ?? "/bin:/usr/bin", LC_ALL: "C" }
|
|
984
|
+
var EnvEntrySchema, KERNEL_CHECK_ENTRY_FIELDS, SafeRepoRelPath, KERNEL_CONFIG_REFINEMENTS;
|
|
985
|
+
var init_config_schema = __esm(() => {
|
|
986
|
+
EnvEntrySchema = z2.union([
|
|
987
|
+
z2.literal(true),
|
|
988
|
+
z2.object({ optional: z2.literal(true) }),
|
|
989
|
+
z2.object({ anyOf: z2.array(z2.string()).min(2) }),
|
|
990
|
+
z2.string()
|
|
991
|
+
]);
|
|
992
|
+
KERNEL_CHECK_ENTRY_FIELDS = {
|
|
993
|
+
run: z2.string(),
|
|
994
|
+
scope: z2.enum(["diff", "full"]),
|
|
995
|
+
include: z2.array(z2.string()).optional(),
|
|
996
|
+
args: z2.array(z2.string()).optional(),
|
|
997
|
+
timeoutMs: z2.number().optional(),
|
|
998
|
+
env: z2.record(z2.string(), EnvEntrySchema).optional(),
|
|
999
|
+
requiresOpenPr: z2.boolean().optional(),
|
|
1000
|
+
ownWorkflow: z2.boolean().optional(),
|
|
1001
|
+
validates: z2.enum(["body", "issue"]).optional(),
|
|
1002
|
+
advisory: z2.literal(true).optional()
|
|
1003
|
+
};
|
|
1004
|
+
SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
|
|
1005
|
+
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
961
1006
|
});
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1007
|
+
KERNEL_CONFIG_REFINEMENTS = [];
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
// ../../harness/kernel/run-paths.ts
|
|
1011
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
1012
|
+
import { chmodSync as chmodSync2, existsSync as existsSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
1013
|
+
import { dirname as dirname2, join as join3, resolve as resolvePath } from "node:path";
|
|
1014
|
+
function isSafeRepoSegment(segment) {
|
|
1015
|
+
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
966
1016
|
}
|
|
967
|
-
function
|
|
968
|
-
|
|
969
|
-
|
|
1017
|
+
function repoSegment(repo) {
|
|
1018
|
+
if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
|
|
1019
|
+
return "unresolved";
|
|
1020
|
+
return `${repo.owner}-${repo.repo}`;
|
|
970
1021
|
}
|
|
971
|
-
function
|
|
972
|
-
|
|
973
|
-
writeFileSync(join2(dir, OWNER_MARKER_FILE), `${JSON.stringify(marker)}
|
|
974
|
-
`);
|
|
975
|
-
return marker;
|
|
1022
|
+
function defaultRuntimeDir(repo, home = configProvider().homeDir) {
|
|
1023
|
+
return join3(home, "runtime", repoSegment(repo));
|
|
976
1024
|
}
|
|
977
|
-
function
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1025
|
+
function resolveRuntimeDir(input) {
|
|
1026
|
+
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
1027
|
+
if (local === null)
|
|
1028
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
1029
|
+
if (isInsideRepo(local, input.repoRoot))
|
|
1030
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
1031
|
+
if (!input.unattended)
|
|
1032
|
+
return local;
|
|
1033
|
+
const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
|
|
1034
|
+
return anchored ?? defaultRuntimeDir(input.repo, input.home);
|
|
987
1035
|
}
|
|
988
|
-
function
|
|
989
|
-
|
|
1036
|
+
function isInsideRepo(candidate, repoRoot) {
|
|
1037
|
+
if (!repoRoot)
|
|
1038
|
+
return false;
|
|
1039
|
+
const root = resolvePath(repoRoot);
|
|
1040
|
+
const target = resolvePath(candidate);
|
|
1041
|
+
return target === root || target.startsWith(`${root}/`);
|
|
990
1042
|
}
|
|
991
|
-
function
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
return
|
|
1043
|
+
function tasksExecutionRoot(runtimeDir) {
|
|
1044
|
+
return join3(runtimeDir, TASKS_EXECUTION_DIRNAME);
|
|
1045
|
+
}
|
|
1046
|
+
function runPath(runtimeDir, scope, location) {
|
|
1047
|
+
const dir = join3(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
1048
|
+
switch (location.area) {
|
|
1049
|
+
case "task":
|
|
1050
|
+
return location.file ? join3(dir, location.file) : dir;
|
|
1051
|
+
case "control": {
|
|
1052
|
+
const controlDir = join3(dir, RUN_AREA_DIRNAMES.control);
|
|
1053
|
+
return location.file ? join3(controlDir, location.file) : controlDir;
|
|
1054
|
+
}
|
|
1055
|
+
case "rounds":
|
|
1056
|
+
return join3(dir, RUN_AREA_DIRNAMES.rounds);
|
|
1057
|
+
case "round": {
|
|
1058
|
+
const roundDir = join3(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
1059
|
+
return location.file ? join3(roundDir, location.file) : roundDir;
|
|
1060
|
+
}
|
|
1061
|
+
case "developer": {
|
|
1062
|
+
const developerDir = join3(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
1063
|
+
return location.file ? join3(developerDir, location.file) : developerDir;
|
|
1064
|
+
}
|
|
1065
|
+
default: {
|
|
1066
|
+
const areaDir = join3(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
1067
|
+
return location.file ? join3(areaDir, location.file) : areaDir;
|
|
1068
|
+
}
|
|
999
1069
|
}
|
|
1000
|
-
const now = processStartTime(owner.pid);
|
|
1001
|
-
if (now === null || owner.startTime === "unknown")
|
|
1002
|
-
return true;
|
|
1003
|
-
return now === owner.startTime;
|
|
1004
1070
|
}
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
makeTreeWritable(join2(dir, entry));
|
|
1012
|
-
} catch {}
|
|
1071
|
+
function scopeSegment(scope) {
|
|
1072
|
+
if (scope === "unscoped")
|
|
1073
|
+
return "unscoped";
|
|
1074
|
+
if (typeof scope === "number")
|
|
1075
|
+
return String(scope);
|
|
1076
|
+
return `pr-${scope.pr}`;
|
|
1013
1077
|
}
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
return
|
|
1029
|
-
|
|
1078
|
+
function scopeFromSegment(segment) {
|
|
1079
|
+
if (/^\d+$/.test(segment))
|
|
1080
|
+
return Number(segment);
|
|
1081
|
+
const pr = /^pr-(\d+)$/.exec(segment);
|
|
1082
|
+
if (pr)
|
|
1083
|
+
return { pr: Number(pr[1]) };
|
|
1084
|
+
return "unscoped";
|
|
1085
|
+
}
|
|
1086
|
+
function isUnattendedProcess(env = process.env) {
|
|
1087
|
+
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
1088
|
+
}
|
|
1089
|
+
function runtimeDirForRepo(repo) {
|
|
1090
|
+
const key = repoSegment(repo);
|
|
1091
|
+
if (memoized?.key === key)
|
|
1092
|
+
return memoized.value;
|
|
1093
|
+
const value = resolveRuntimeDirUncached(repo);
|
|
1094
|
+
memoized = { key, value };
|
|
1095
|
+
return value;
|
|
1096
|
+
}
|
|
1097
|
+
async function runtimeDirForRepoAsync(repo) {
|
|
1098
|
+
const key = repoSegment(repo);
|
|
1099
|
+
if (memoized?.key === key)
|
|
1100
|
+
return memoized.value;
|
|
1101
|
+
const inputs = runtimeDirInputs();
|
|
1102
|
+
if (typeof inputs === "string")
|
|
1103
|
+
return inputs;
|
|
1104
|
+
const value = resolveRuntimeDir({
|
|
1105
|
+
repo,
|
|
1106
|
+
...inputs.base,
|
|
1107
|
+
trustAnchorConfig: inputs.needsAnchor ? await configProvider().loadTrustAnchorConfigAsync() : null
|
|
1108
|
+
});
|
|
1109
|
+
memoized = { key, value };
|
|
1110
|
+
return value;
|
|
1030
1111
|
}
|
|
1031
|
-
function
|
|
1032
|
-
const
|
|
1033
|
-
if (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
const released = result.claimed;
|
|
1043
|
-
const error = removeTree(released);
|
|
1044
|
-
if (error === null) {
|
|
1045
|
-
rmSync2(`${released}.owner.json`, { force: true });
|
|
1046
|
-
report.removed.push(dir);
|
|
1047
|
-
} else
|
|
1048
|
-
report.failed.push({ dir, error });
|
|
1112
|
+
function resolveRuntimeDirUncached(repo) {
|
|
1113
|
+
const inputs = runtimeDirInputs();
|
|
1114
|
+
if (typeof inputs === "string")
|
|
1115
|
+
return inputs;
|
|
1116
|
+
return resolveRuntimeDir({
|
|
1117
|
+
repo,
|
|
1118
|
+
...inputs.base,
|
|
1119
|
+
trustAnchorConfig: inputs.needsAnchor ? configProvider().loadTrustAnchorConfig() : null
|
|
1120
|
+
});
|
|
1049
1121
|
}
|
|
1050
|
-
function
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}
|
|
1060
|
-
return { error: describeError(error) };
|
|
1061
|
-
}
|
|
1122
|
+
function runtimeDirInputs() {
|
|
1123
|
+
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
1124
|
+
if (handedDown)
|
|
1125
|
+
return handedDown;
|
|
1126
|
+
const localConfig = configProvider().loadConfig();
|
|
1127
|
+
const unattended = isUnattendedProcess();
|
|
1128
|
+
return {
|
|
1129
|
+
base: { localConfig, unattended, repoRoot: repoRootSync() },
|
|
1130
|
+
needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
|
|
1131
|
+
};
|
|
1062
1132
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const report = { removed: [], kept: [], failed: [] };
|
|
1066
|
-
let names;
|
|
1133
|
+
function repoRootSync(start = process.cwd()) {
|
|
1134
|
+
let dir;
|
|
1067
1135
|
try {
|
|
1068
|
-
|
|
1069
|
-
} catch
|
|
1070
|
-
|
|
1071
|
-
return report;
|
|
1072
|
-
report.failed.push({ dir: parent, error: describeError(error) });
|
|
1073
|
-
return report;
|
|
1136
|
+
dir = realpathSync2(start);
|
|
1137
|
+
} catch {
|
|
1138
|
+
return null;
|
|
1074
1139
|
}
|
|
1075
|
-
for (
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
if (
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
continue;
|
|
1083
|
-
let marker = readOwnerMarker(dir);
|
|
1084
|
-
const receipt = `${dir}.owner.json`;
|
|
1085
|
-
try {
|
|
1086
|
-
const stat = lstatSync(receipt);
|
|
1087
|
-
if (stat.isFile() && stat.uid === process.getuid?.() && (stat.mode & 18) === 0) {
|
|
1088
|
-
const released = JSON.parse(readFileSync2(receipt, "utf8"));
|
|
1089
|
-
if (released.original === original && released.marker?.owner?.host === hostname()) {
|
|
1090
|
-
marker = released.marker;
|
|
1091
|
-
if (typeof released.cleanupError === "string")
|
|
1092
|
-
report.failed.push({ dir, error: released.cleanupError });
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
} catch {}
|
|
1096
|
-
if (marker === null || marker.owner.host !== hostname()) {
|
|
1097
|
-
report.kept.push(dir);
|
|
1098
|
-
continue;
|
|
1099
|
-
}
|
|
1100
|
-
try {
|
|
1101
|
-
await stop(marker.owner.runToken, { graceMs }, dir);
|
|
1102
|
-
const error = removeTree(dir);
|
|
1103
|
-
if (error !== null)
|
|
1104
|
-
throw new Error(error);
|
|
1105
|
-
rmSync2(receipt, { force: true });
|
|
1106
|
-
report.removed.push(dir);
|
|
1107
|
-
} catch (error) {
|
|
1108
|
-
report.failed.push({ dir, error: describeError(error) });
|
|
1109
|
-
}
|
|
1110
|
-
continue;
|
|
1111
|
-
}
|
|
1112
|
-
if (!select(name))
|
|
1113
|
-
continue;
|
|
1114
|
-
const marker = readOwnerMarker(dir);
|
|
1115
|
-
if (marker === null || isOwnerAlive(marker.owner)) {
|
|
1116
|
-
report.kept.push(dir);
|
|
1117
|
-
continue;
|
|
1118
|
-
}
|
|
1119
|
-
try {
|
|
1120
|
-
await stop(marker.owner.runToken, { graceMs }, dir);
|
|
1121
|
-
} catch (error) {
|
|
1122
|
-
report.failed.push({ dir, error: `stopping the owner's processes failed: ${describeError(error)}` });
|
|
1123
|
-
continue;
|
|
1124
|
-
}
|
|
1125
|
-
releaseAndRemove(dir, report);
|
|
1140
|
+
for (;; ) {
|
|
1141
|
+
if (existsSync2(join3(dir, ".git")))
|
|
1142
|
+
return dir;
|
|
1143
|
+
const parent = dirname2(dir);
|
|
1144
|
+
if (parent === dir)
|
|
1145
|
+
return null;
|
|
1146
|
+
dir = parent;
|
|
1126
1147
|
}
|
|
1127
|
-
return report;
|
|
1128
1148
|
}
|
|
1129
|
-
|
|
1130
|
-
var init_test_temp = __esm(() => {
|
|
1131
|
-
init_process_registry();
|
|
1132
|
-
DEFAULT_SWEEP = { stop: stopRegistered, graceMs: 2000, select: () => true };
|
|
1133
|
-
});
|
|
1134
|
-
|
|
1135
|
-
// ../../harness/kernel/adapters/code-host/github/resolve-repo.ts
|
|
1136
|
-
import { execFile } from "node:child_process";
|
|
1137
|
-
import { promisify } from "node:util";
|
|
1138
|
-
async function resolveRepo(exec = defaultExec) {
|
|
1139
|
-
if (cached !== undefined)
|
|
1140
|
-
return cached;
|
|
1149
|
+
function resolveRepoSync() {
|
|
1141
1150
|
const fromEnv = process.env.VINAYA_REPO;
|
|
1142
1151
|
if (fromEnv) {
|
|
1143
|
-
const
|
|
1144
|
-
if (
|
|
1145
|
-
|
|
1146
|
-
return cached;
|
|
1147
|
-
}
|
|
1152
|
+
const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
|
|
1153
|
+
if (m?.[1] && m[2])
|
|
1154
|
+
return { owner: m[1], repo: m[2] };
|
|
1148
1155
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return null;
|
|
1160
|
-
} finally {
|
|
1161
|
-
inflight = undefined;
|
|
1162
|
-
}
|
|
1163
|
-
})();
|
|
1164
|
-
return inflight;
|
|
1165
|
-
}
|
|
1166
|
-
function parseGitRemoteUrl(url) {
|
|
1167
|
-
const ssh = url.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
1156
|
+
let url;
|
|
1157
|
+
try {
|
|
1158
|
+
url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
1159
|
+
encoding: "utf-8",
|
|
1160
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1161
|
+
}).trim();
|
|
1162
|
+
} catch {
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
|
|
1168
1166
|
if (ssh?.[1] && ssh[2])
|
|
1169
1167
|
return { owner: ssh[1], repo: ssh[2] };
|
|
1170
|
-
const https =
|
|
1168
|
+
const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
|
|
1171
1169
|
if (https?.[1] && https[2])
|
|
1172
1170
|
return { owner: https[1], repo: https[2] };
|
|
1173
1171
|
return null;
|
|
1174
1172
|
}
|
|
1175
|
-
function
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
return
|
|
1173
|
+
function runtimeDirForThisRepo() {
|
|
1174
|
+
if (memoizedThisRepo !== null)
|
|
1175
|
+
return memoizedThisRepo;
|
|
1176
|
+
memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
|
|
1177
|
+
return memoizedThisRepo;
|
|
1180
1178
|
}
|
|
1181
|
-
var
|
|
1182
|
-
var
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1179
|
+
var TASKS_EXECUTION_DIRNAME = "tasks-execution", RUN_AREA_DIRNAMES, SAFE_PATH_SEGMENT, UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED", RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR", memoized = null, memoizedThisRepo = null;
|
|
1180
|
+
var init_run_paths = __esm(() => {
|
|
1181
|
+
init_control_store();
|
|
1182
|
+
init_config_schema();
|
|
1183
|
+
RUN_AREA_DIRNAMES = {
|
|
1184
|
+
control: CONTROL_AREA_DIRNAME,
|
|
1185
|
+
sessions: "sessions",
|
|
1186
|
+
hooks: "hooks",
|
|
1187
|
+
output: "output",
|
|
1188
|
+
rounds: "rounds"
|
|
1187
1189
|
};
|
|
1190
|
+
SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
1188
1191
|
});
|
|
1189
1192
|
|
|
1190
|
-
// ../../harness/kernel/
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1193
|
+
// ../../harness/kernel/source-manifest.ts
|
|
1194
|
+
import { createHash } from "node:crypto";
|
|
1195
|
+
import { appendFileSync, chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1196
|
+
import { dirname as dirname3, join as join4 } from "node:path";
|
|
1197
|
+
function sha256Digest(content) {
|
|
1198
|
+
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
1199
|
+
}
|
|
1200
|
+
function sourceStoreDir(runtimeDir, scope) {
|
|
1201
|
+
return runPath(runtimeDir, scope, { area: "control", file: SOURCE_STORE_DIRNAME });
|
|
1202
|
+
}
|
|
1203
|
+
function sourceManifestPath(storeDir) {
|
|
1204
|
+
return join4(storeDir, SOURCE_MANIFEST_FILE);
|
|
1205
|
+
}
|
|
1206
|
+
function sourceReceiptsPath(storeDir) {
|
|
1207
|
+
return join4(storeDir, SOURCE_RECEIPTS_FILE);
|
|
1208
|
+
}
|
|
1209
|
+
function manifestDigest(manifest) {
|
|
1210
|
+
const { schemaVersion, round, base, briefDigest, preparedAt, sources } = manifest;
|
|
1211
|
+
return sha256Digest(JSON.stringify({ schemaVersion, round, base, briefDigest, preparedAt, sources }));
|
|
1212
|
+
}
|
|
1213
|
+
function isPreparedSource(value) {
|
|
1214
|
+
if (value === null || typeof value !== "object")
|
|
1215
|
+
return false;
|
|
1216
|
+
const s = value;
|
|
1217
|
+
return typeof s.sourceId === "string" && typeof s.canonicalUri === "string" && typeof s.requirementText === "string" && typeof s.governs === "string" && (s.deliveryMode === "injected" || s.deliveryMode === "retrieval_tool" || s.deliveryMode === "unavailable") && (s.freshnessPolicy === "pinned" || s.freshnessPolicy === "volatile") && (s.contentDigest === null || typeof s.contentDigest === "string");
|
|
1218
|
+
}
|
|
1219
|
+
function readRequiredSourceManifest(storeDir) {
|
|
1220
|
+
let parsed;
|
|
1221
|
+
try {
|
|
1222
|
+
parsed = JSON.parse(readFileSync3(sourceManifestPath(storeDir), "utf8"));
|
|
1223
|
+
} catch {
|
|
1224
|
+
return null;
|
|
1225
|
+
}
|
|
1226
|
+
if (parsed === null || typeof parsed !== "object")
|
|
1227
|
+
return null;
|
|
1228
|
+
const m = parsed;
|
|
1229
|
+
if (m.schemaVersion !== 1 || !Array.isArray(m.sources) || !m.sources.every(isPreparedSource))
|
|
1230
|
+
return null;
|
|
1231
|
+
if (typeof m.digest !== "string" || manifestDigest(m) !== m.digest)
|
|
1232
|
+
return null;
|
|
1233
|
+
return m;
|
|
1234
|
+
}
|
|
1235
|
+
function readSourceDeliveryReceipts(receiptsPath) {
|
|
1236
|
+
let text;
|
|
1237
|
+
try {
|
|
1238
|
+
text = readFileSync3(receiptsPath, "utf8");
|
|
1239
|
+
} catch {
|
|
1240
|
+
return [];
|
|
1241
|
+
}
|
|
1242
|
+
const receipts = [];
|
|
1243
|
+
for (const line of text.split(`
|
|
1244
|
+
`)) {
|
|
1203
1245
|
if (!line)
|
|
1204
1246
|
continue;
|
|
1205
|
-
let entry;
|
|
1206
1247
|
try {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1211
|
-
if (!entry || typeof entry !== "object")
|
|
1212
|
-
continue;
|
|
1213
|
-
const obj = entry;
|
|
1214
|
-
if (obj.type !== "assistant")
|
|
1215
|
-
continue;
|
|
1216
|
-
const message = obj.message;
|
|
1217
|
-
const id = message?.id;
|
|
1218
|
-
const usage = message?.usage;
|
|
1219
|
-
if (typeof id !== "string" || !id || !usage || seen.has(id))
|
|
1220
|
-
continue;
|
|
1221
|
-
seen.add(id);
|
|
1222
|
-
messageCount++;
|
|
1223
|
-
components.inputTokens += numberOr(usage.input_tokens, 0);
|
|
1224
|
-
components.outputTokens += numberOr(usage.output_tokens, 0);
|
|
1225
|
-
components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
|
|
1226
|
-
components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
|
|
1227
|
-
const messageModel = message?.model;
|
|
1228
|
-
if (typeof messageModel === "string" && messageModel)
|
|
1229
|
-
model = messageModel;
|
|
1248
|
+
const r = JSON.parse(line);
|
|
1249
|
+
if (r && typeof r.sourceId === "string" && (r.decision === "counted" || r.decision === "refused"))
|
|
1250
|
+
receipts.push(r);
|
|
1251
|
+
} catch {}
|
|
1230
1252
|
}
|
|
1231
|
-
return
|
|
1253
|
+
return receipts;
|
|
1232
1254
|
}
|
|
1233
|
-
function
|
|
1234
|
-
return
|
|
1255
|
+
function countedSourceIds(receipts) {
|
|
1256
|
+
return [...new Set(receipts.filter((r) => r.decision === "counted").map((r) => r.sourceId))];
|
|
1235
1257
|
}
|
|
1236
|
-
var
|
|
1258
|
+
var SOURCE_STORE_DIRNAME = "sources", SOURCE_MANIFEST_FILE = "manifest.json", SOURCE_RECEIPTS_FILE = "receipts.jsonl";
|
|
1259
|
+
var init_source_manifest = __esm(() => {
|
|
1260
|
+
init_run_paths();
|
|
1261
|
+
});
|
|
1237
1262
|
|
|
1238
|
-
// ../../harness/kernel/
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1263
|
+
// ../../harness/kernel/tools/fetch-documentation.ts
|
|
1264
|
+
var FETCH_DOCUMENTATION_TOOL = "fetch_documentation", DOCUMENTATION_READ_MIN_SIZE = 1000, FETCH_DOCUMENTATION_MAX_BYTES, REQUEST_HEADER_ALLOWANCE;
|
|
1265
|
+
var init_fetch_documentation = __esm(() => {
|
|
1266
|
+
init_source_manifest();
|
|
1267
|
+
FETCH_DOCUMENTATION_MAX_BYTES = 5 * 1024 * 1024;
|
|
1268
|
+
REQUEST_HEADER_ALLOWANCE = 64 * 1024;
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
// ../../harness/kernel/log/envelope.ts
|
|
1272
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
1273
|
+
function actorIdFromEnv(role) {
|
|
1274
|
+
return role === undefined || role === "" ? null : role;
|
|
1247
1275
|
}
|
|
1248
|
-
function
|
|
1249
|
-
|
|
1250
|
-
return redactString(value, home);
|
|
1251
|
-
if (Array.isArray(value))
|
|
1252
|
-
return value.map((v) => redact(v, home));
|
|
1253
|
-
if (value !== null && typeof value === "object") {
|
|
1254
|
-
const out = {};
|
|
1255
|
-
for (const [k, v] of Object.entries(value)) {
|
|
1256
|
-
out[k] = redact(v, home);
|
|
1257
|
-
}
|
|
1258
|
-
return out;
|
|
1259
|
-
}
|
|
1260
|
-
return value;
|
|
1276
|
+
function lineageFieldFromEnv(value) {
|
|
1277
|
+
return value === undefined || value === "" ? null : value;
|
|
1261
1278
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1279
|
+
function attemptFromEnv(value) {
|
|
1280
|
+
if (value === undefined || value === "")
|
|
1281
|
+
return null;
|
|
1282
|
+
const n = Number(value);
|
|
1283
|
+
return Number.isInteger(n) ? n : null;
|
|
1284
|
+
}
|
|
1285
|
+
function provenanceFor(input) {
|
|
1286
|
+
if (input.provenance)
|
|
1287
|
+
return input.provenance;
|
|
1288
|
+
if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
|
|
1289
|
+
return "unavailable";
|
|
1290
|
+
if (input.env.role || input.env.task)
|
|
1291
|
+
return "env_correlated";
|
|
1292
|
+
return "unavailable";
|
|
1293
|
+
}
|
|
1294
|
+
function issueFromTask(task) {
|
|
1295
|
+
if (task === undefined || task === "")
|
|
1296
|
+
return null;
|
|
1297
|
+
const n = Number(task);
|
|
1298
|
+
return Number.isInteger(n) ? n : null;
|
|
1299
|
+
}
|
|
1300
|
+
function roundFromEnv(round) {
|
|
1301
|
+
if (round === undefined || round === "")
|
|
1302
|
+
return;
|
|
1303
|
+
const n = Number(round);
|
|
1304
|
+
return Number.isInteger(n) ? n : undefined;
|
|
1305
|
+
}
|
|
1306
|
+
function prFromEnv(pr) {
|
|
1307
|
+
if (pr === undefined || pr === "")
|
|
1308
|
+
return;
|
|
1309
|
+
const n = Number(pr);
|
|
1310
|
+
return Number.isInteger(n) && n > 0 ? n : undefined;
|
|
1311
|
+
}
|
|
1312
|
+
function buildHeader(input) {
|
|
1313
|
+
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
1314
|
+
const round = roundFromEnv(input.env.round);
|
|
1315
|
+
const pr = prFromEnv(input.env.pr);
|
|
1316
|
+
const subject = {
|
|
1317
|
+
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
1318
|
+
role,
|
|
1319
|
+
...round !== undefined ? { round } : {},
|
|
1320
|
+
...pr !== undefined ? { pr } : {},
|
|
1321
|
+
...input.subject ?? {}
|
|
1322
|
+
};
|
|
1323
|
+
const issue = subject.issue;
|
|
1324
|
+
return {
|
|
1325
|
+
meta: {
|
|
1326
|
+
schema: 4,
|
|
1327
|
+
ts: input.now.toISOString(),
|
|
1328
|
+
run_id: input.runId,
|
|
1329
|
+
seq: input.seq,
|
|
1330
|
+
repo: input.repo,
|
|
1331
|
+
vinaya: input.vinaya,
|
|
1332
|
+
doctrine: input.doctrine,
|
|
1333
|
+
host: input.host,
|
|
1334
|
+
machine: createHash2("sha256").update(input.hostname).digest("hex"),
|
|
1335
|
+
event_id: input.eventId,
|
|
1336
|
+
process_id: input.processId,
|
|
1337
|
+
actor_id: actorIdFromEnv(input.env.role),
|
|
1338
|
+
lineage: {
|
|
1339
|
+
run: lineageFieldFromEnv(input.env.run),
|
|
1340
|
+
attempt: attemptFromEnv(input.env.attempt),
|
|
1341
|
+
parent: lineageFieldFromEnv(input.env.parent)
|
|
1342
|
+
},
|
|
1343
|
+
input_versions: {
|
|
1344
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
1345
|
+
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
1346
|
+
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
1347
|
+
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
1348
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
1349
|
+
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
1350
|
+
},
|
|
1351
|
+
provenance: provenanceFor(input),
|
|
1352
|
+
work: {
|
|
1353
|
+
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
1354
|
+
repo: input.repo,
|
|
1355
|
+
change: pr === undefined ? null : String(pr),
|
|
1356
|
+
revision: input.revision ?? null
|
|
1357
|
+
},
|
|
1358
|
+
flow: {
|
|
1359
|
+
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
1360
|
+
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
1361
|
+
},
|
|
1362
|
+
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
1363
|
+
process: {
|
|
1364
|
+
id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
|
|
1365
|
+
version: lineageFieldFromEnv(input.env.processVersion),
|
|
1366
|
+
digest: lineageFieldFromEnv(input.env.processDigest)
|
|
1367
|
+
},
|
|
1368
|
+
runner: {
|
|
1369
|
+
id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
|
|
1370
|
+
version: lineageFieldFromEnv(input.env.runnerVersion)
|
|
1371
|
+
},
|
|
1372
|
+
source: lineageFieldFromEnv(input.env.source)
|
|
1373
|
+
},
|
|
1374
|
+
subject
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
var init_envelope = __esm(() => {
|
|
1378
|
+
init_roles();
|
|
1277
1379
|
});
|
|
1278
1380
|
|
|
1279
|
-
// ../../harness/kernel/
|
|
1381
|
+
// ../../harness/kernel/log/custom.ts
|
|
1280
1382
|
import { z as z3 } from "zod";
|
|
1281
|
-
var
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1383
|
+
var CUSTOM_EVENT_NAME_PATTERN, CUSTOM_EVENT_NAME_MAX_LENGTH = 64, CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya", CUSTOM_EVENT_MAX_FIELDS = 20, CUSTOM_FIELD_NAME_PATTERN, CUSTOM_FIELD_NAME_MAX_LENGTH = 64, CUSTOM_TEXT_MAX_LENGTH = 500, CUSTOM_WORD_PATTERN, CUSTOM_WORD_MAX_LENGTH = 64, CUSTOM_FIELD_MAX_WORDS = 50, CustomFieldTypeSchema, CustomEventDeclarationsSchema;
|
|
1384
|
+
var init_custom = __esm(() => {
|
|
1385
|
+
CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
|
|
1386
|
+
CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
1387
|
+
CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
1388
|
+
CustomFieldTypeSchema = z3.union([z3.enum(["text", "number", "boolean"]), z3.array(z3.string())]);
|
|
1389
|
+
CustomEventDeclarationsSchema = z3.record(z3.string(), z3.object({
|
|
1390
|
+
fields: z3.record(z3.string(), CustomFieldTypeSchema)
|
|
1391
|
+
}).strict()).superRefine((events, ctx) => {
|
|
1392
|
+
for (const [name, declaration] of Object.entries(events)) {
|
|
1393
|
+
const refuse = (message, path = []) => {
|
|
1394
|
+
ctx.addIssue({
|
|
1395
|
+
code: z3.ZodIssueCode.custom,
|
|
1396
|
+
path: [name, ...path],
|
|
1397
|
+
message: `logs.events "${name}": ${message}`
|
|
1398
|
+
});
|
|
1399
|
+
};
|
|
1400
|
+
if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
|
|
1401
|
+
refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
|
|
1402
|
+
}
|
|
1403
|
+
if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
|
|
1404
|
+
refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
|
|
1405
|
+
} else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
|
|
1406
|
+
refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
|
|
1407
|
+
}
|
|
1408
|
+
const fieldEntries = Object.entries(declaration.fields);
|
|
1409
|
+
if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
|
|
1410
|
+
refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
|
|
1411
|
+
}
|
|
1412
|
+
for (const [field, type] of fieldEntries) {
|
|
1413
|
+
if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
|
|
1414
|
+
refuse(`field "${field}": a field name is lowercase letters, digits and \`_\`, starting with a letter, at most ${CUSTOM_FIELD_NAME_MAX_LENGTH} characters`, ["fields", field]);
|
|
1415
|
+
}
|
|
1416
|
+
if (typeof type === "string")
|
|
1417
|
+
continue;
|
|
1418
|
+
if (type.length === 0) {
|
|
1419
|
+
refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
|
|
1420
|
+
}
|
|
1421
|
+
if (type.length > CUSTOM_FIELD_MAX_WORDS) {
|
|
1422
|
+
refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
|
|
1423
|
+
}
|
|
1424
|
+
const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
|
|
1425
|
+
if (bad.length > 0) {
|
|
1426
|
+
refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
|
|
1427
|
+
}
|
|
1428
|
+
if (new Set(type).size !== type.length) {
|
|
1429
|
+
refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
|
|
1436
|
+
// ../../harness/kernel/log/schema.ts
|
|
1437
|
+
import { z as z4 } from "zod";
|
|
1438
|
+
var CONFIDENCE_REASON_MAX_LENGTH = 280, REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000, ROLE_NAME_PATTERN, RoleSchema, HOST_VALUES, HostSchema, RUN_ID_PATTERN, headerMetaCore, HeaderMetaV1Schema, LineageSchema, InputVersionsSchema, ProvenanceSchema, HeaderMetaV2Schema, WorkSchema, FlowSchema, HeaderMetaV3Schema, HeaderMetaV4Schema, HeaderMetaSchema, SubjectSchema, HeaderSchema, envelopeTail, ReviewFindingSchema, DispatchOutcomeSchema, dispatchShared, dispatchUsageField, DispatchEventSchema, CODE_TOKEN_PATTERN, CodeTokenSchema, ReviewerVerdictSchema, loopShared, DevReviewLoopEventSchema, ForgeOpSchema, ForgeWriteTargetSchema, forgeWriteShared, ForgeWriteEventSchema, GateOutcomeSchema, gateShared, GateEventSchema, OperationResultSchema, operationShared, OperationEventSchema, UsageUnitsSchema, usageShared, UsageEventSchema, RoleAttemptOutcomeSchema, roleAttemptShared, RoleAttemptEventSchema, handoffShared, HandoffEventSchema, EffectTargetSchema, effectShared, EffectEventSchema, CustomFieldValueSchema, customShared, CustomEventSchema, LogEventSchema;
|
|
1439
|
+
var init_schema = __esm(() => {
|
|
1440
|
+
init_custom();
|
|
1441
|
+
ROLE_NAME_PATTERN = /^[a-z0-9-]+$/;
|
|
1442
|
+
RoleSchema = z4.string().regex(ROLE_NAME_PATTERN);
|
|
1443
|
+
HOST_VALUES = ["hook", "ci", "cli", "loop"];
|
|
1444
|
+
HostSchema = z4.enum(HOST_VALUES);
|
|
1445
|
+
RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
1446
|
+
headerMetaCore = {
|
|
1447
|
+
ts: z4.string(),
|
|
1448
|
+
run_id: z4.string().regex(RUN_ID_PATTERN),
|
|
1449
|
+
seq: z4.number().int().nonnegative(),
|
|
1450
|
+
repo: z4.string().nullable(),
|
|
1451
|
+
vinaya: z4.string(),
|
|
1452
|
+
doctrine: z4.string(),
|
|
1453
|
+
host: HostSchema,
|
|
1454
|
+
machine: z4.string()
|
|
1455
|
+
};
|
|
1456
|
+
HeaderMetaV1Schema = z4.object({
|
|
1457
|
+
schema: z4.literal(1),
|
|
1458
|
+
...headerMetaCore
|
|
1296
1459
|
}).strict();
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
runId: z3.string().min(1),
|
|
1302
|
-
source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
|
|
1303
|
-
pr: z3.number().int().positive().nullable(),
|
|
1304
|
-
round: z3.number().int().nonnegative(),
|
|
1305
|
-
recordedAt: isoTimestamp
|
|
1460
|
+
LineageSchema = z4.object({
|
|
1461
|
+
run: z4.string().nullable(),
|
|
1462
|
+
attempt: z4.number().int().nullable(),
|
|
1463
|
+
parent: z4.string().nullable()
|
|
1306
1464
|
}).strict();
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
host: z3.string().min(1),
|
|
1315
|
-
acquiredAt: isoTimestamp
|
|
1465
|
+
InputVersionsSchema = z4.object({
|
|
1466
|
+
manifest_version: z4.literal(2).nullable().optional(),
|
|
1467
|
+
objectives_version: z4.string().nullable(),
|
|
1468
|
+
brief_hash: z4.string().nullable(),
|
|
1469
|
+
ruling_ordinal: z4.number().int().nullable(),
|
|
1470
|
+
pause_bound_ruling: z4.object({ rulingId: z4.string().min(1), pauseId: z4.string().min(1), contentDigest: z4.string().min(1) }).strict().nullable().optional(),
|
|
1471
|
+
policy_digest: z4.string().nullable()
|
|
1316
1472
|
}).strict();
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1473
|
+
ProvenanceSchema = z4.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
1474
|
+
HeaderMetaV2Schema = z4.object({
|
|
1475
|
+
schema: z4.literal(2),
|
|
1476
|
+
...headerMetaCore,
|
|
1477
|
+
event_id: z4.string().min(1),
|
|
1478
|
+
process_id: z4.string().min(1),
|
|
1479
|
+
actor_id: z4.string().nullable(),
|
|
1480
|
+
lineage: LineageSchema,
|
|
1481
|
+
input_versions: InputVersionsSchema,
|
|
1482
|
+
provenance: ProvenanceSchema
|
|
1327
1483
|
}).strict();
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
repository: z3.string().min(1),
|
|
1334
|
-
pr: z3.number().int().positive(),
|
|
1335
|
-
branch: z3.string().min(1),
|
|
1336
|
-
baseSha: z3.string().min(1).nullable(),
|
|
1337
|
-
headSha: z3.string().min(1),
|
|
1338
|
-
briefHash: z3.string().min(1).nullable(),
|
|
1339
|
-
objectivesVersion: z3.string().min(1).nullable(),
|
|
1340
|
-
rulingOrdinal: epochNumber,
|
|
1341
|
-
manifestVersion: z3.literal(2).optional(),
|
|
1342
|
-
pauseBoundRuling: z3.object({
|
|
1343
|
-
rulingId: z3.string().min(1),
|
|
1344
|
-
pauseId: z3.string().min(1),
|
|
1345
|
-
contentDigest: z3.string().min(1)
|
|
1346
|
-
}).strict().nullable().optional(),
|
|
1347
|
-
policyDigest: z3.string().min(1),
|
|
1348
|
-
recordedAt: isoTimestamp
|
|
1484
|
+
WorkSchema = z4.object({
|
|
1485
|
+
ref: z4.string().nullable(),
|
|
1486
|
+
repo: z4.string().nullable(),
|
|
1487
|
+
change: z4.string().nullable(),
|
|
1488
|
+
revision: z4.string().nullable()
|
|
1349
1489
|
}).strict();
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
reviewRounds: z3.number().int().nonnegative(),
|
|
1354
|
-
infrastructureRetries: z3.number().int().nonnegative()
|
|
1490
|
+
FlowSchema = z4.object({
|
|
1491
|
+
id: z4.string().nullable(),
|
|
1492
|
+
version: z4.string().nullable()
|
|
1355
1493
|
}).strict();
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
}).strict().optional(),
|
|
1370
|
-
developerHandoff: z3.object({
|
|
1371
|
-
findings: z3.array(z3.object({ id: z3.string().min(1), description: z3.string().min(1) }).strict()),
|
|
1372
|
-
failingChecks: z3.array(z3.string().min(1))
|
|
1373
|
-
}).strict().optional(),
|
|
1374
|
-
publicationExpectedBase: z3.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
1375
|
-
taskStartedAt: isoTimestamp.optional(),
|
|
1376
|
-
phaseMs: z3.record(z3.string(), z3.number().nonnegative()).optional(),
|
|
1377
|
-
recordedAt: isoTimestamp
|
|
1494
|
+
HeaderMetaV3Schema = z4.object({
|
|
1495
|
+
schema: z4.literal(3),
|
|
1496
|
+
...headerMetaCore,
|
|
1497
|
+
event_id: z4.string().min(1),
|
|
1498
|
+
process_id: z4.string().min(1),
|
|
1499
|
+
actor_id: z4.string().nullable(),
|
|
1500
|
+
lineage: LineageSchema,
|
|
1501
|
+
input_versions: InputVersionsSchema,
|
|
1502
|
+
provenance: ProvenanceSchema,
|
|
1503
|
+
work: WorkSchema,
|
|
1504
|
+
flow: FlowSchema,
|
|
1505
|
+
runtime: z4.string().nullable(),
|
|
1506
|
+
source: z4.string().nullable()
|
|
1378
1507
|
}).strict();
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
key: z3.string().min(1),
|
|
1384
|
-
operation: z3.string().min(1),
|
|
1385
|
-
target: z3.string().min(1),
|
|
1386
|
-
inputVersion: z3.number().int().nonnegative(),
|
|
1387
|
-
payloadDigest: z3.string().min(1),
|
|
1388
|
-
status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
|
|
1389
|
-
url: z3.string().optional(),
|
|
1390
|
-
recordedAt: isoTimestamp
|
|
1508
|
+
HeaderMetaV4Schema = HeaderMetaV3Schema.extend({
|
|
1509
|
+
schema: z4.literal(4),
|
|
1510
|
+
process: z4.object({ id: z4.string(), version: z4.string().nullable(), digest: z4.string().nullable() }).strict(),
|
|
1511
|
+
runner: z4.object({ id: z4.string(), version: z4.string().nullable() }).strict()
|
|
1391
1512
|
}).strict();
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
pr:
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
reason: z3.string().min(1),
|
|
1406
|
-
detail: z3.string().optional(),
|
|
1407
|
-
evidence: z3.string().optional(),
|
|
1408
|
-
attemptedRecovery: z3.string().min(1),
|
|
1409
|
-
requestedDecision: z3.string().min(1),
|
|
1410
|
-
recipient: z3.string().min(1),
|
|
1411
|
-
briefHash: z3.string().min(1).nullable(),
|
|
1412
|
-
objectivesVersion: z3.string().min(1).nullable(),
|
|
1413
|
-
rulingOrdinal: epochNumber,
|
|
1414
|
-
policyDigest: z3.string().min(1),
|
|
1415
|
-
recordedAt: isoTimestamp
|
|
1513
|
+
HeaderMetaSchema = z4.discriminatedUnion("schema", [
|
|
1514
|
+
HeaderMetaV1Schema,
|
|
1515
|
+
HeaderMetaV2Schema,
|
|
1516
|
+
HeaderMetaV3Schema,
|
|
1517
|
+
HeaderMetaV4Schema
|
|
1518
|
+
]);
|
|
1519
|
+
SubjectSchema = z4.object({
|
|
1520
|
+
issue: z4.number().int().nullable(),
|
|
1521
|
+
pr: z4.number().int().optional(),
|
|
1522
|
+
sha: z4.string().optional(),
|
|
1523
|
+
role: z4.union([RoleSchema, z4.literal("unattributed")]),
|
|
1524
|
+
round: z4.number().int().optional(),
|
|
1525
|
+
objectives_version: z4.string().optional()
|
|
1416
1526
|
}).strict();
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
task: taskId,
|
|
1421
|
-
escalationId: z3.string().min(1),
|
|
1422
|
-
decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
|
|
1423
|
-
authenticatedBy: z3.string().min(1),
|
|
1424
|
-
authenticatedFrom: z3.string().min(1),
|
|
1425
|
-
consumedAt: isoTimestamp
|
|
1527
|
+
HeaderSchema = z4.object({
|
|
1528
|
+
meta: HeaderMetaSchema,
|
|
1529
|
+
subject: SubjectSchema
|
|
1426
1530
|
}).strict();
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1531
|
+
envelopeTail = {
|
|
1532
|
+
duration_ms: z4.number().nonnegative().optional(),
|
|
1533
|
+
payload: z4.object({}).strict()
|
|
1534
|
+
};
|
|
1535
|
+
ReviewFindingSchema = z4.object({
|
|
1536
|
+
id: z4.string(),
|
|
1537
|
+
severity: z4.string(),
|
|
1538
|
+
location: z4.string().optional(),
|
|
1539
|
+
deferral_reason: z4.enum(["outside-surface", "unchanged-line"]).optional(),
|
|
1540
|
+
description: z4.string().max(REVIEW_FINDING_DESCRIPTION_MAX_LENGTH).optional(),
|
|
1541
|
+
state: z4.string().optional(),
|
|
1542
|
+
severity_scale: z4.string().optional(),
|
|
1543
|
+
policy_treatment: z4.enum(["blocking", "non_blocking", "unavailable"]).optional(),
|
|
1544
|
+
confidence: z4.number().min(0).max(1).optional(),
|
|
1545
|
+
confidence_scale: z4.string().optional(),
|
|
1546
|
+
confidence_source: z4.string().optional()
|
|
1436
1547
|
}).strict();
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1548
|
+
DispatchOutcomeSchema = z4.discriminatedUnion("type", [
|
|
1549
|
+
z4.object({ type: z4.literal("pr_opened"), pr: z4.number().int(), head: z4.string() }).strict(),
|
|
1550
|
+
z4.object({
|
|
1551
|
+
type: z4.literal("round_pushed"),
|
|
1552
|
+
pr: z4.number().int(),
|
|
1553
|
+
head: z4.string(),
|
|
1554
|
+
comment_id: z4.number().int()
|
|
1555
|
+
}).strict(),
|
|
1556
|
+
z4.object({
|
|
1557
|
+
type: z4.literal("verdict"),
|
|
1558
|
+
verdict: z4.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
|
|
1559
|
+
head: z4.string(),
|
|
1560
|
+
comment_id: z4.number().int(),
|
|
1561
|
+
objectives: z4.array(z4.object({ id: z4.string(), met: z4.boolean() }).strict()),
|
|
1562
|
+
findings: z4.array(ReviewFindingSchema)
|
|
1563
|
+
}).strict(),
|
|
1564
|
+
z4.object({
|
|
1565
|
+
type: z4.literal("escalation"),
|
|
1566
|
+
class: z4.enum(["authority", "strategy", "product"]),
|
|
1567
|
+
comment_id: z4.number().int()
|
|
1568
|
+
}).strict(),
|
|
1569
|
+
z4.object({ type: z4.literal("brief"), comment_id: z4.number().int(), hash: z4.string() }).strict(),
|
|
1570
|
+
z4.object({ type: z4.literal("plan"), issues: z4.array(z4.number().int()) }).strict(),
|
|
1571
|
+
z4.object({ type: z4.literal("archive"), provenance_comment_id: z4.number().int() }).strict(),
|
|
1572
|
+
z4.object({ type: z4.literal("completed") }).strict()
|
|
1573
|
+
]);
|
|
1574
|
+
dispatchShared = {
|
|
1575
|
+
meta: HeaderMetaSchema,
|
|
1576
|
+
subject: SubjectSchema,
|
|
1577
|
+
kind: z4.literal("dispatch"),
|
|
1578
|
+
...envelopeTail,
|
|
1579
|
+
target_role: RoleSchema,
|
|
1580
|
+
model: z4.string(),
|
|
1581
|
+
round: z4.number().int().optional(),
|
|
1582
|
+
effect_id: z4.string()
|
|
1583
|
+
};
|
|
1584
|
+
dispatchUsageField = z4.object({ input: z4.number().nonnegative(), output: z4.number().nonnegative() }).strict().nullable();
|
|
1585
|
+
DispatchEventSchema = z4.discriminatedUnion("event", [
|
|
1586
|
+
z4.object({ ...dispatchShared, event: z4.literal("dispatched"), prompt_hash: z4.string() }).strict(),
|
|
1587
|
+
z4.object({
|
|
1588
|
+
...dispatchShared,
|
|
1589
|
+
event: z4.literal("outcome_received"),
|
|
1590
|
+
outcome: DispatchOutcomeSchema,
|
|
1591
|
+
usage: dispatchUsageField
|
|
1592
|
+
}).strict(),
|
|
1593
|
+
z4.object({
|
|
1594
|
+
...dispatchShared,
|
|
1595
|
+
event: z4.literal("dispatch_failed"),
|
|
1596
|
+
reason: z4.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
|
|
1597
|
+
usage_limit: z4.object({ agent: z4.string().min(1), reset_at: z4.string().nullable() }).strict().optional(),
|
|
1598
|
+
usage: dispatchUsageField
|
|
1599
|
+
}).strict()
|
|
1600
|
+
]);
|
|
1601
|
+
CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
1602
|
+
CodeTokenSchema = z4.string().regex(CODE_TOKEN_PATTERN);
|
|
1603
|
+
ReviewerVerdictSchema = z4.object({
|
|
1604
|
+
role: RoleSchema,
|
|
1605
|
+
outcome: z4.enum(["approve", "changes_requested", "not_reviewed"]),
|
|
1606
|
+
blockers: z4.number().int().nonnegative()
|
|
1607
|
+
}).strict();
|
|
1608
|
+
loopShared = {
|
|
1609
|
+
meta: HeaderMetaSchema,
|
|
1610
|
+
subject: SubjectSchema,
|
|
1611
|
+
kind: z4.literal("dev_review_loop"),
|
|
1612
|
+
...envelopeTail,
|
|
1613
|
+
loop_id: z4.string()
|
|
1614
|
+
};
|
|
1615
|
+
DevReviewLoopEventSchema = z4.discriminatedUnion("event", [
|
|
1616
|
+
z4.object({
|
|
1617
|
+
...loopShared,
|
|
1618
|
+
event: z4.literal("loop_started"),
|
|
1619
|
+
task: z4.number().int(),
|
|
1620
|
+
title: z4.string().optional(),
|
|
1621
|
+
policy: z4.object({
|
|
1622
|
+
max_rounds: z4.number().int().nonnegative(),
|
|
1623
|
+
reviewers: z4.array(RoleSchema),
|
|
1624
|
+
models: z4.record(RoleSchema, z4.string())
|
|
1625
|
+
}).strict()
|
|
1626
|
+
}).strict(),
|
|
1627
|
+
z4.object({ ...loopShared, event: z4.literal("round_started"), round: z4.number().int(), base_head: z4.string() }).strict(),
|
|
1628
|
+
z4.object({
|
|
1629
|
+
...loopShared,
|
|
1630
|
+
event: z4.literal("gate_result_read"),
|
|
1631
|
+
round: z4.number().int(),
|
|
1632
|
+
head: z4.string(),
|
|
1633
|
+
green: z4.boolean(),
|
|
1634
|
+
confidence_value: z4.number().int().min(0).max(100).optional(),
|
|
1635
|
+
confidence_reason: z4.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
|
|
1636
|
+
confidence_unavailable: z4.boolean().optional(),
|
|
1637
|
+
extra_turn_spent: z4.boolean().optional()
|
|
1638
|
+
}).strict(),
|
|
1639
|
+
z4.object({
|
|
1640
|
+
...loopShared,
|
|
1641
|
+
event: z4.literal("verdicts_read"),
|
|
1642
|
+
round: z4.number().int(),
|
|
1643
|
+
head: z4.string(),
|
|
1644
|
+
all_approve: z4.boolean(),
|
|
1645
|
+
blockers: z4.number().int().nonnegative(),
|
|
1646
|
+
findings: z4.array(ReviewFindingSchema).optional(),
|
|
1647
|
+
reviewers: z4.array(ReviewerVerdictSchema).optional()
|
|
1648
|
+
}).strict(),
|
|
1649
|
+
z4.object({
|
|
1650
|
+
...loopShared,
|
|
1651
|
+
event: z4.literal("findings_compared"),
|
|
1652
|
+
round: z4.number().int(),
|
|
1653
|
+
open: z4.array(z4.string()),
|
|
1654
|
+
resolved: z4.array(z4.string()),
|
|
1655
|
+
new: z4.array(z4.string()),
|
|
1656
|
+
recurring: z4.array(z4.string())
|
|
1657
|
+
}).strict(),
|
|
1658
|
+
z4.object({
|
|
1659
|
+
...loopShared,
|
|
1660
|
+
event: z4.literal("stop_condition_met"),
|
|
1661
|
+
round: z4.number().int(),
|
|
1662
|
+
condition: z4.enum([
|
|
1663
|
+
"green",
|
|
1664
|
+
"max_rounds",
|
|
1665
|
+
"no_progress",
|
|
1666
|
+
"escalated",
|
|
1667
|
+
"principal_stop",
|
|
1668
|
+
"confidence",
|
|
1669
|
+
"reappearance",
|
|
1670
|
+
"repeat_finding",
|
|
1671
|
+
"repeat_failure",
|
|
1672
|
+
"time_budget"
|
|
1673
|
+
])
|
|
1674
|
+
}).strict(),
|
|
1675
|
+
z4.object({
|
|
1676
|
+
...loopShared,
|
|
1677
|
+
event: z4.literal("paused"),
|
|
1678
|
+
round: z4.number().int(),
|
|
1679
|
+
reason: z4.enum(["escalation", "principal_item", "refreeze_needed"]),
|
|
1680
|
+
reason_code: CodeTokenSchema.optional()
|
|
1681
|
+
}).strict(),
|
|
1682
|
+
z4.object({
|
|
1683
|
+
...loopShared,
|
|
1684
|
+
event: z4.literal("resumed"),
|
|
1685
|
+
round: z4.number().int(),
|
|
1686
|
+
by: z4.enum(["principal", "driver"])
|
|
1687
|
+
}).strict(),
|
|
1688
|
+
z4.object({
|
|
1689
|
+
...loopShared,
|
|
1690
|
+
event: z4.literal("cancelled"),
|
|
1691
|
+
round: z4.number().int(),
|
|
1692
|
+
by: z4.literal("principal")
|
|
1693
|
+
}).strict(),
|
|
1694
|
+
z4.object({
|
|
1695
|
+
...loopShared,
|
|
1696
|
+
event: z4.literal("unpushed_work_resume"),
|
|
1697
|
+
round: z4.number().int(),
|
|
1698
|
+
branch: z4.string(),
|
|
1699
|
+
detail: z4.string()
|
|
1700
|
+
}).strict(),
|
|
1701
|
+
z4.object({
|
|
1702
|
+
...loopShared,
|
|
1703
|
+
event: z4.literal("round_ended"),
|
|
1704
|
+
round: z4.number().int(),
|
|
1705
|
+
base_head: z4.string(),
|
|
1706
|
+
head: z4.string(),
|
|
1707
|
+
files_changed: z4.number().int().nonnegative(),
|
|
1708
|
+
insertions: z4.number().int().nonnegative(),
|
|
1709
|
+
deletions: z4.number().int().nonnegative(),
|
|
1710
|
+
wall_ms: z4.number().nonnegative(),
|
|
1711
|
+
outcome: z4.enum(["green", "changes_requested", "escalated"])
|
|
1712
|
+
}).strict(),
|
|
1713
|
+
z4.object({
|
|
1714
|
+
...loopShared,
|
|
1715
|
+
event: z4.literal("journal_finalized"),
|
|
1716
|
+
rounds: z4.number().int().nonnegative(),
|
|
1717
|
+
total_wall_ms: z4.number().nonnegative(),
|
|
1718
|
+
time_to_green_ms: z4.number().nonnegative().nullable(),
|
|
1719
|
+
files_changed_total: z4.number().int().nonnegative(),
|
|
1720
|
+
final_head: z4.string(),
|
|
1721
|
+
result: z4.enum(["merged_ready", "stopped"])
|
|
1722
|
+
}).strict(),
|
|
1723
|
+
z4.object({
|
|
1724
|
+
...loopShared,
|
|
1725
|
+
event: z4.literal("infrastructure_retry"),
|
|
1726
|
+
round: z4.number().int(),
|
|
1727
|
+
failure_kind: z4.enum(["pause_comment_post", "developer_connection"]),
|
|
1728
|
+
attempts: z4.number().int().positive(),
|
|
1729
|
+
outcome: z4.enum(["recovered", "exhausted"])
|
|
1730
|
+
}).strict(),
|
|
1731
|
+
z4.object({
|
|
1732
|
+
...loopShared,
|
|
1733
|
+
event: z4.literal("driver_heartbeat"),
|
|
1734
|
+
task: z4.number().int(),
|
|
1735
|
+
pr: z4.number().int().positive().optional(),
|
|
1736
|
+
round: z4.number().int(),
|
|
1737
|
+
phase: z4.string()
|
|
1738
|
+
}).strict(),
|
|
1739
|
+
z4.object({
|
|
1740
|
+
...loopShared,
|
|
1741
|
+
event: z4.literal("conflict_reentry"),
|
|
1742
|
+
task: z4.number().int(),
|
|
1743
|
+
pr: z4.number().int().positive(),
|
|
1744
|
+
attempt: z4.number().int().positive(),
|
|
1745
|
+
bound: z4.number().int().positive()
|
|
1746
|
+
}).strict(),
|
|
1747
|
+
z4.object({
|
|
1748
|
+
...loopShared,
|
|
1749
|
+
event: z4.literal("storage_push"),
|
|
1750
|
+
round: z4.number().int(),
|
|
1751
|
+
branch: z4.string(),
|
|
1752
|
+
head: z4.string()
|
|
1753
|
+
}).strict(),
|
|
1754
|
+
z4.object({
|
|
1755
|
+
...loopShared,
|
|
1756
|
+
event: z4.literal("local_checks_run"),
|
|
1757
|
+
round: z4.number().int(),
|
|
1758
|
+
head: z4.string().nullable(),
|
|
1759
|
+
passed: z4.boolean(),
|
|
1760
|
+
wall_ms: z4.number().nonnegative()
|
|
1761
|
+
}).strict(),
|
|
1762
|
+
z4.object({
|
|
1763
|
+
...loopShared,
|
|
1764
|
+
event: z4.literal("ready_push"),
|
|
1765
|
+
round: z4.number().int(),
|
|
1766
|
+
head: z4.string(),
|
|
1767
|
+
outcome: z4.enum(["passed", "refused"]),
|
|
1768
|
+
selected: z4.number().int().nonnegative(),
|
|
1769
|
+
failed: z4.number().int().nonnegative(),
|
|
1770
|
+
rerun: z4.boolean(),
|
|
1771
|
+
wall_ms: z4.number().nonnegative()
|
|
1772
|
+
}).strict(),
|
|
1773
|
+
z4.object({
|
|
1774
|
+
...loopShared,
|
|
1775
|
+
event: z4.literal("failed_tests_rerun"),
|
|
1776
|
+
round: z4.number().int(),
|
|
1777
|
+
head: z4.string(),
|
|
1778
|
+
rerun_of: z4.string(),
|
|
1779
|
+
failed_files: z4.number().int().nonnegative(),
|
|
1780
|
+
affected_files: z4.number().int().nonnegative(),
|
|
1781
|
+
full_count: z4.number().int().nonnegative()
|
|
1782
|
+
}).strict(),
|
|
1783
|
+
z4.object({
|
|
1784
|
+
...loopShared,
|
|
1785
|
+
event: z4.literal("pr_opened"),
|
|
1786
|
+
round: z4.number().int(),
|
|
1787
|
+
pr: z4.number().int().positive(),
|
|
1788
|
+
head: z4.string()
|
|
1789
|
+
}).strict(),
|
|
1790
|
+
z4.object({
|
|
1791
|
+
...loopShared,
|
|
1792
|
+
event: z4.literal("ci_result_read"),
|
|
1793
|
+
round: z4.number().int(),
|
|
1794
|
+
pr: z4.number().int().positive(),
|
|
1795
|
+
head: z4.string(),
|
|
1796
|
+
conclusion: z4.enum(["green", "red", "pending", "skipped"]),
|
|
1797
|
+
failing_checks: z4.array(z4.string()),
|
|
1798
|
+
wait_ms: z4.number().nonnegative()
|
|
1799
|
+
}).strict(),
|
|
1800
|
+
z4.object({
|
|
1801
|
+
...loopShared,
|
|
1802
|
+
event: z4.literal("phase_time"),
|
|
1803
|
+
round: z4.number().int(),
|
|
1804
|
+
phase: z4.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
|
|
1805
|
+
step: z4.string(),
|
|
1806
|
+
wall_ms: z4.number().nonnegative()
|
|
1807
|
+
}).strict(),
|
|
1808
|
+
z4.object({
|
|
1809
|
+
...loopShared,
|
|
1810
|
+
event: z4.literal("driver_exited"),
|
|
1811
|
+
task: z4.number().int(),
|
|
1812
|
+
reason: z4.enum(["finished", "paused", "reexec", "error", "signal"]),
|
|
1813
|
+
last_decision: z4.string(),
|
|
1814
|
+
exit_code: z4.number().int().optional(),
|
|
1815
|
+
error_class: CodeTokenSchema.optional()
|
|
1816
|
+
}).strict()
|
|
1817
|
+
]);
|
|
1818
|
+
ForgeOpSchema = z4.enum([
|
|
1819
|
+
"pr.create",
|
|
1820
|
+
"pr.comment",
|
|
1821
|
+
"pr.body.replace",
|
|
1822
|
+
"pr.refreeze",
|
|
1823
|
+
"issue.create",
|
|
1824
|
+
"issue.edit",
|
|
1825
|
+
"issue.comment",
|
|
1826
|
+
"milestone.create",
|
|
1827
|
+
"milestone.edit",
|
|
1828
|
+
"milestone.close",
|
|
1829
|
+
"label.add",
|
|
1830
|
+
"label.remove"
|
|
1831
|
+
]);
|
|
1832
|
+
ForgeWriteTargetSchema = z4.object({
|
|
1833
|
+
issue: z4.number().int().optional(),
|
|
1834
|
+
pr: z4.number().int().optional()
|
|
1835
|
+
}).strict();
|
|
1836
|
+
forgeWriteShared = {
|
|
1837
|
+
meta: HeaderMetaSchema,
|
|
1838
|
+
subject: SubjectSchema,
|
|
1839
|
+
kind: z4.literal("forge_write"),
|
|
1840
|
+
...envelopeTail,
|
|
1841
|
+
op: ForgeOpSchema,
|
|
1842
|
+
target: ForgeWriteTargetSchema
|
|
1555
1843
|
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
}
|
|
1560
|
-
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
1561
|
-
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
1562
|
-
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
1563
|
-
}
|
|
1564
|
-
function resolveLogsSetting(config) {
|
|
1565
|
-
const raw = config?.logs;
|
|
1566
|
-
if (!raw)
|
|
1567
|
-
return null;
|
|
1568
|
-
if (raw.url !== undefined)
|
|
1569
|
-
return { url: raw.url, headers: raw.headers };
|
|
1570
|
-
if (raw.folder !== undefined)
|
|
1571
|
-
return { folder: raw.folder };
|
|
1572
|
-
return null;
|
|
1573
|
-
}
|
|
1574
|
-
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
1575
|
-
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
1576
|
-
if (!anchored)
|
|
1577
|
-
return null;
|
|
1578
|
-
if ("url" in local)
|
|
1579
|
-
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
1580
|
-
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
1581
|
-
}
|
|
1582
|
-
function resolveLogsHeaderValues(headers, env) {
|
|
1583
|
-
if (!headers)
|
|
1584
|
-
return;
|
|
1585
|
-
const resolved = {};
|
|
1586
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
1587
|
-
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
1588
|
-
}
|
|
1589
|
-
return resolved;
|
|
1590
|
-
}
|
|
1591
|
-
var EnvEntrySchema, KERNEL_CHECK_ENTRY_FIELDS, SafeRepoRelPath, KERNEL_CONFIG_REFINEMENTS;
|
|
1592
|
-
var init_config_schema = __esm(() => {
|
|
1593
|
-
EnvEntrySchema = z4.union([
|
|
1594
|
-
z4.literal(true),
|
|
1595
|
-
z4.object({ optional: z4.literal(true) }),
|
|
1596
|
-
z4.object({ anyOf: z4.array(z4.string()).min(2) }),
|
|
1597
|
-
z4.string()
|
|
1844
|
+
ForgeWriteEventSchema = z4.discriminatedUnion("event", [
|
|
1845
|
+
z4.object({ ...forgeWriteShared, event: z4.literal("validated") }).strict(),
|
|
1846
|
+
z4.object({ ...forgeWriteShared, event: z4.literal("refused"), reason: z4.string() }).strict(),
|
|
1847
|
+
z4.object({ ...forgeWriteShared, event: z4.literal("written"), comment_ids: z4.array(z4.string()) }).strict()
|
|
1598
1848
|
]);
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1849
|
+
GateOutcomeSchema = z4.enum([
|
|
1850
|
+
"pass",
|
|
1851
|
+
"fail",
|
|
1852
|
+
"wait",
|
|
1853
|
+
"skip",
|
|
1854
|
+
"invalid_input",
|
|
1855
|
+
"unavailable_dependency",
|
|
1856
|
+
"timeout",
|
|
1857
|
+
"cancelled"
|
|
1858
|
+
]);
|
|
1859
|
+
gateShared = {
|
|
1860
|
+
meta: HeaderMetaSchema,
|
|
1861
|
+
subject: SubjectSchema,
|
|
1862
|
+
kind: z4.literal("gate"),
|
|
1863
|
+
...envelopeTail,
|
|
1864
|
+
check: z4.string(),
|
|
1865
|
+
check_version: z4.string().nullable(),
|
|
1866
|
+
policy_version: z4.string().nullable(),
|
|
1867
|
+
input_fingerprint: z4.string().nullable()
|
|
1610
1868
|
};
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
return local;
|
|
1640
|
-
const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
|
|
1641
|
-
return anchored ?? defaultRuntimeDir(input.repo, input.home);
|
|
1642
|
-
}
|
|
1643
|
-
function isInsideRepo(candidate, repoRoot) {
|
|
1644
|
-
if (!repoRoot)
|
|
1645
|
-
return false;
|
|
1646
|
-
const root = resolvePath(repoRoot);
|
|
1647
|
-
const target = resolvePath(candidate);
|
|
1648
|
-
return target === root || target.startsWith(`${root}/`);
|
|
1649
|
-
}
|
|
1650
|
-
function tasksExecutionRoot(runtimeDir) {
|
|
1651
|
-
return join3(runtimeDir, TASKS_EXECUTION_DIRNAME);
|
|
1652
|
-
}
|
|
1653
|
-
function runPath(runtimeDir, scope, location) {
|
|
1654
|
-
const dir = join3(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
1655
|
-
switch (location.area) {
|
|
1656
|
-
case "task":
|
|
1657
|
-
return location.file ? join3(dir, location.file) : dir;
|
|
1658
|
-
case "control": {
|
|
1659
|
-
const controlDir = join3(dir, RUN_AREA_DIRNAMES.control);
|
|
1660
|
-
return location.file ? join3(controlDir, location.file) : controlDir;
|
|
1661
|
-
}
|
|
1662
|
-
case "rounds":
|
|
1663
|
-
return join3(dir, RUN_AREA_DIRNAMES.rounds);
|
|
1664
|
-
case "round": {
|
|
1665
|
-
const roundDir = join3(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
1666
|
-
return location.file ? join3(roundDir, location.file) : roundDir;
|
|
1667
|
-
}
|
|
1668
|
-
case "developer": {
|
|
1669
|
-
const developerDir = join3(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
1670
|
-
return location.file ? join3(developerDir, location.file) : developerDir;
|
|
1671
|
-
}
|
|
1672
|
-
default: {
|
|
1673
|
-
const areaDir = join3(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
1674
|
-
return location.file ? join3(areaDir, location.file) : areaDir;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
function scopeSegment(scope) {
|
|
1679
|
-
if (scope === "unscoped")
|
|
1680
|
-
return "unscoped";
|
|
1681
|
-
if (typeof scope === "number")
|
|
1682
|
-
return String(scope);
|
|
1683
|
-
return `pr-${scope.pr}`;
|
|
1684
|
-
}
|
|
1685
|
-
function scopeFromSegment(segment) {
|
|
1686
|
-
if (/^\d+$/.test(segment))
|
|
1687
|
-
return Number(segment);
|
|
1688
|
-
const pr = /^pr-(\d+)$/.exec(segment);
|
|
1689
|
-
if (pr)
|
|
1690
|
-
return { pr: Number(pr[1]) };
|
|
1691
|
-
return "unscoped";
|
|
1692
|
-
}
|
|
1693
|
-
function isUnattendedProcess(env = process.env) {
|
|
1694
|
-
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
1695
|
-
}
|
|
1696
|
-
function runtimeDirForRepo(repo) {
|
|
1697
|
-
const key = repoSegment(repo);
|
|
1698
|
-
if (memoized?.key === key)
|
|
1699
|
-
return memoized.value;
|
|
1700
|
-
const value = resolveRuntimeDirUncached(repo);
|
|
1701
|
-
memoized = { key, value };
|
|
1702
|
-
return value;
|
|
1703
|
-
}
|
|
1704
|
-
async function runtimeDirForRepoAsync(repo) {
|
|
1705
|
-
const key = repoSegment(repo);
|
|
1706
|
-
if (memoized?.key === key)
|
|
1707
|
-
return memoized.value;
|
|
1708
|
-
const inputs = runtimeDirInputs();
|
|
1709
|
-
if (typeof inputs === "string")
|
|
1710
|
-
return inputs;
|
|
1711
|
-
const value = resolveRuntimeDir({
|
|
1712
|
-
repo,
|
|
1713
|
-
...inputs.base,
|
|
1714
|
-
trustAnchorConfig: inputs.needsAnchor ? await configProvider().loadTrustAnchorConfigAsync() : null
|
|
1715
|
-
});
|
|
1716
|
-
memoized = { key, value };
|
|
1717
|
-
return value;
|
|
1718
|
-
}
|
|
1719
|
-
function resolveRuntimeDirUncached(repo) {
|
|
1720
|
-
const inputs = runtimeDirInputs();
|
|
1721
|
-
if (typeof inputs === "string")
|
|
1722
|
-
return inputs;
|
|
1723
|
-
return resolveRuntimeDir({
|
|
1724
|
-
repo,
|
|
1725
|
-
...inputs.base,
|
|
1726
|
-
trustAnchorConfig: inputs.needsAnchor ? configProvider().loadTrustAnchorConfig() : null
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
function runtimeDirInputs() {
|
|
1730
|
-
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
1731
|
-
if (handedDown)
|
|
1732
|
-
return handedDown;
|
|
1733
|
-
const localConfig = configProvider().loadConfig();
|
|
1734
|
-
const unattended = isUnattendedProcess();
|
|
1735
|
-
return {
|
|
1736
|
-
base: { localConfig, unattended, repoRoot: repoRootSync() },
|
|
1737
|
-
needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
|
|
1869
|
+
GateEventSchema = z4.discriminatedUnion("event", [
|
|
1870
|
+
z4.object({
|
|
1871
|
+
...gateShared,
|
|
1872
|
+
event: z4.literal("checked"),
|
|
1873
|
+
outcome: GateOutcomeSchema,
|
|
1874
|
+
reason: z4.string().optional()
|
|
1875
|
+
}).strict(),
|
|
1876
|
+
z4.object({
|
|
1877
|
+
meta: HeaderMetaSchema,
|
|
1878
|
+
subject: SubjectSchema,
|
|
1879
|
+
kind: z4.literal("gate"),
|
|
1880
|
+
...envelopeTail,
|
|
1881
|
+
event: z4.literal("summary"),
|
|
1882
|
+
ran: z4.number().int().nonnegative(),
|
|
1883
|
+
passed: z4.number().int().nonnegative(),
|
|
1884
|
+
failed: z4.number().int().nonnegative(),
|
|
1885
|
+
skipped: z4.number().int().nonnegative(),
|
|
1886
|
+
failed_checks: z4.array(z4.string())
|
|
1887
|
+
}).strict()
|
|
1888
|
+
]);
|
|
1889
|
+
OperationResultSchema = z4.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
|
|
1890
|
+
operationShared = {
|
|
1891
|
+
meta: HeaderMetaSchema,
|
|
1892
|
+
subject: SubjectSchema,
|
|
1893
|
+
kind: z4.literal("operation"),
|
|
1894
|
+
...envelopeTail,
|
|
1895
|
+
operation: z4.string(),
|
|
1896
|
+
target: z4.string().nullable()
|
|
1738
1897
|
};
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return { owner: m[1], repo: m[2] };
|
|
1762
|
-
}
|
|
1763
|
-
let url;
|
|
1764
|
-
try {
|
|
1765
|
-
url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
1766
|
-
encoding: "utf-8",
|
|
1767
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
1768
|
-
}).trim();
|
|
1769
|
-
} catch {
|
|
1770
|
-
return null;
|
|
1771
|
-
}
|
|
1772
|
-
const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
|
|
1773
|
-
if (ssh?.[1] && ssh[2])
|
|
1774
|
-
return { owner: ssh[1], repo: ssh[2] };
|
|
1775
|
-
const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
|
|
1776
|
-
if (https?.[1] && https[2])
|
|
1777
|
-
return { owner: https[1], repo: https[2] };
|
|
1778
|
-
return null;
|
|
1779
|
-
}
|
|
1780
|
-
function runtimeDirForThisRepo() {
|
|
1781
|
-
if (memoizedThisRepo !== null)
|
|
1782
|
-
return memoizedThisRepo;
|
|
1783
|
-
memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
|
|
1784
|
-
return memoizedThisRepo;
|
|
1785
|
-
}
|
|
1786
|
-
var TASKS_EXECUTION_DIRNAME = "tasks-execution", RUN_AREA_DIRNAMES, SAFE_PATH_SEGMENT, UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED", RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR", memoized = null, memoizedThisRepo = null;
|
|
1787
|
-
var init_run_paths = __esm(() => {
|
|
1788
|
-
init_control_store();
|
|
1789
|
-
init_config_schema();
|
|
1790
|
-
RUN_AREA_DIRNAMES = {
|
|
1791
|
-
control: CONTROL_AREA_DIRNAME,
|
|
1792
|
-
sessions: "sessions",
|
|
1793
|
-
hooks: "hooks",
|
|
1794
|
-
output: "output",
|
|
1795
|
-
rounds: "rounds"
|
|
1898
|
+
OperationEventSchema = z4.discriminatedUnion("event", [
|
|
1899
|
+
z4.object({
|
|
1900
|
+
...operationShared,
|
|
1901
|
+
event: z4.literal("completed"),
|
|
1902
|
+
result: OperationResultSchema,
|
|
1903
|
+
error_class: z4.string().nullable(),
|
|
1904
|
+
field_names: z4.array(z4.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
|
|
1905
|
+
}).strict()
|
|
1906
|
+
]);
|
|
1907
|
+
UsageUnitsSchema = z4.object({
|
|
1908
|
+
input: z4.number().nonnegative().nullable(),
|
|
1909
|
+
output: z4.number().nonnegative().nullable(),
|
|
1910
|
+
cache: z4.number().nonnegative().nullable()
|
|
1911
|
+
}).strict();
|
|
1912
|
+
usageShared = {
|
|
1913
|
+
meta: HeaderMetaSchema,
|
|
1914
|
+
subject: SubjectSchema,
|
|
1915
|
+
kind: z4.literal("usage"),
|
|
1916
|
+
...envelopeTail,
|
|
1917
|
+
model: z4.string().nullable(),
|
|
1918
|
+
source: z4.string(),
|
|
1919
|
+
semantics: z4.enum(["cumulative", "delta"])
|
|
1796
1920
|
};
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
return false;
|
|
1823
|
-
const s = value;
|
|
1824
|
-
return typeof s.sourceId === "string" && typeof s.canonicalUri === "string" && typeof s.requirementText === "string" && typeof s.governs === "string" && (s.deliveryMode === "injected" || s.deliveryMode === "retrieval_tool" || s.deliveryMode === "unavailable") && (s.freshnessPolicy === "pinned" || s.freshnessPolicy === "volatile") && (s.contentDigest === null || typeof s.contentDigest === "string");
|
|
1825
|
-
}
|
|
1826
|
-
function readRequiredSourceManifest(storeDir) {
|
|
1827
|
-
let parsed;
|
|
1828
|
-
try {
|
|
1829
|
-
parsed = JSON.parse(readFileSync3(sourceManifestPath(storeDir), "utf8"));
|
|
1830
|
-
} catch {
|
|
1831
|
-
return null;
|
|
1832
|
-
}
|
|
1833
|
-
if (parsed === null || typeof parsed !== "object")
|
|
1834
|
-
return null;
|
|
1835
|
-
const m = parsed;
|
|
1836
|
-
if (m.schemaVersion !== 1 || !Array.isArray(m.sources) || !m.sources.every(isPreparedSource))
|
|
1837
|
-
return null;
|
|
1838
|
-
if (typeof m.digest !== "string" || manifestDigest(m) !== m.digest)
|
|
1839
|
-
return null;
|
|
1840
|
-
return m;
|
|
1841
|
-
}
|
|
1842
|
-
function readSourceDeliveryReceipts(receiptsPath) {
|
|
1843
|
-
let text;
|
|
1844
|
-
try {
|
|
1845
|
-
text = readFileSync3(receiptsPath, "utf8");
|
|
1846
|
-
} catch {
|
|
1847
|
-
return [];
|
|
1848
|
-
}
|
|
1849
|
-
const receipts = [];
|
|
1850
|
-
for (const line of text.split(`
|
|
1851
|
-
`)) {
|
|
1852
|
-
if (!line)
|
|
1853
|
-
continue;
|
|
1854
|
-
try {
|
|
1855
|
-
const r = JSON.parse(line);
|
|
1856
|
-
if (r && typeof r.sourceId === "string" && (r.decision === "counted" || r.decision === "refused"))
|
|
1857
|
-
receipts.push(r);
|
|
1858
|
-
} catch {}
|
|
1859
|
-
}
|
|
1860
|
-
return receipts;
|
|
1861
|
-
}
|
|
1862
|
-
function countedSourceIds(receipts) {
|
|
1863
|
-
return [...new Set(receipts.filter((r) => r.decision === "counted").map((r) => r.sourceId))];
|
|
1864
|
-
}
|
|
1865
|
-
var SOURCE_STORE_DIRNAME = "sources", SOURCE_MANIFEST_FILE = "manifest.json", SOURCE_RECEIPTS_FILE = "receipts.jsonl";
|
|
1866
|
-
var init_source_manifest = __esm(() => {
|
|
1867
|
-
init_run_paths();
|
|
1868
|
-
});
|
|
1869
|
-
|
|
1870
|
-
// ../../harness/kernel/tools/fetch-documentation.ts
|
|
1871
|
-
var FETCH_DOCUMENTATION_TOOL = "fetch_documentation", DOCUMENTATION_READ_MIN_SIZE = 1000, FETCH_DOCUMENTATION_MAX_BYTES, REQUEST_HEADER_ALLOWANCE;
|
|
1872
|
-
var init_fetch_documentation = __esm(() => {
|
|
1873
|
-
init_source_manifest();
|
|
1874
|
-
FETCH_DOCUMENTATION_MAX_BYTES = 5 * 1024 * 1024;
|
|
1875
|
-
REQUEST_HEADER_ALLOWANCE = 64 * 1024;
|
|
1876
|
-
});
|
|
1877
|
-
|
|
1878
|
-
// ../../harness/kernel/log/envelope.ts
|
|
1879
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
1880
|
-
function isRole(value) {
|
|
1881
|
-
return value !== undefined && ROLE_VALUES.includes(value);
|
|
1882
|
-
}
|
|
1883
|
-
function actorIdFromEnv(role) {
|
|
1884
|
-
return role === undefined || role === "" ? null : role;
|
|
1885
|
-
}
|
|
1886
|
-
function lineageFieldFromEnv(value) {
|
|
1887
|
-
return value === undefined || value === "" ? null : value;
|
|
1888
|
-
}
|
|
1889
|
-
function attemptFromEnv(value) {
|
|
1890
|
-
if (value === undefined || value === "")
|
|
1891
|
-
return null;
|
|
1892
|
-
const n = Number(value);
|
|
1893
|
-
return Number.isInteger(n) ? n : null;
|
|
1894
|
-
}
|
|
1895
|
-
function provenanceFor(input) {
|
|
1896
|
-
if (input.provenance)
|
|
1897
|
-
return input.provenance;
|
|
1898
|
-
if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
|
|
1899
|
-
return "unavailable";
|
|
1900
|
-
if (input.env.role || input.env.task)
|
|
1901
|
-
return "env_correlated";
|
|
1902
|
-
return "unavailable";
|
|
1903
|
-
}
|
|
1904
|
-
function issueFromTask(task) {
|
|
1905
|
-
if (task === undefined || task === "")
|
|
1906
|
-
return null;
|
|
1907
|
-
const n = Number(task);
|
|
1908
|
-
return Number.isInteger(n) ? n : null;
|
|
1909
|
-
}
|
|
1910
|
-
function roundFromEnv(round) {
|
|
1911
|
-
if (round === undefined || round === "")
|
|
1912
|
-
return;
|
|
1913
|
-
const n = Number(round);
|
|
1914
|
-
return Number.isInteger(n) ? n : undefined;
|
|
1915
|
-
}
|
|
1916
|
-
function prFromEnv(pr) {
|
|
1917
|
-
if (pr === undefined || pr === "")
|
|
1918
|
-
return;
|
|
1919
|
-
const n = Number(pr);
|
|
1920
|
-
return Number.isInteger(n) && n > 0 ? n : undefined;
|
|
1921
|
-
}
|
|
1922
|
-
function buildHeader(input) {
|
|
1923
|
-
const role = isRole(input.env.role) ? input.env.role : "unattributed";
|
|
1924
|
-
const round = roundFromEnv(input.env.round);
|
|
1925
|
-
const pr = prFromEnv(input.env.pr);
|
|
1926
|
-
const subject = {
|
|
1927
|
-
issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
|
|
1928
|
-
role,
|
|
1929
|
-
...round !== undefined ? { round } : {},
|
|
1930
|
-
...pr !== undefined ? { pr } : {},
|
|
1931
|
-
...input.subject ?? {}
|
|
1921
|
+
UsageEventSchema = z4.discriminatedUnion("event", [
|
|
1922
|
+
z4.object({
|
|
1923
|
+
...usageShared,
|
|
1924
|
+
event: z4.literal("observed"),
|
|
1925
|
+
units: UsageUnitsSchema,
|
|
1926
|
+
unknown_reason: z4.string().nullable()
|
|
1927
|
+
}).strict()
|
|
1928
|
+
]);
|
|
1929
|
+
RoleAttemptOutcomeSchema = z4.enum([
|
|
1930
|
+
"completed",
|
|
1931
|
+
"incomplete",
|
|
1932
|
+
"infrastructure_failed",
|
|
1933
|
+
"cancelled",
|
|
1934
|
+
"timed_out",
|
|
1935
|
+
"capability_refused"
|
|
1936
|
+
]);
|
|
1937
|
+
roleAttemptShared = {
|
|
1938
|
+
meta: HeaderMetaSchema,
|
|
1939
|
+
subject: SubjectSchema,
|
|
1940
|
+
kind: z4.literal("role_attempt"),
|
|
1941
|
+
...envelopeTail,
|
|
1942
|
+
actor: z4.string().nullable(),
|
|
1943
|
+
attempt: z4.number().int().nullable(),
|
|
1944
|
+
effect_id: z4.string(),
|
|
1945
|
+
model: z4.string().nullable()
|
|
1932
1946
|
};
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
lineage: {
|
|
1949
|
-
run: lineageFieldFromEnv(input.env.run),
|
|
1950
|
-
attempt: attemptFromEnv(input.env.attempt),
|
|
1951
|
-
parent: lineageFieldFromEnv(input.env.parent)
|
|
1952
|
-
},
|
|
1953
|
-
input_versions: {
|
|
1954
|
-
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
1955
|
-
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
1956
|
-
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
1957
|
-
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
1958
|
-
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
1959
|
-
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
1960
|
-
},
|
|
1961
|
-
provenance: provenanceFor(input),
|
|
1962
|
-
work: {
|
|
1963
|
-
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
1964
|
-
repo: input.repo,
|
|
1965
|
-
change: pr === undefined ? null : String(pr),
|
|
1966
|
-
revision: input.revision ?? null
|
|
1967
|
-
},
|
|
1968
|
-
flow: {
|
|
1969
|
-
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
1970
|
-
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
1971
|
-
},
|
|
1972
|
-
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
1973
|
-
process: {
|
|
1974
|
-
id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
|
|
1975
|
-
version: lineageFieldFromEnv(input.env.processVersion),
|
|
1976
|
-
digest: lineageFieldFromEnv(input.env.processDigest)
|
|
1977
|
-
},
|
|
1978
|
-
runner: {
|
|
1979
|
-
id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
|
|
1980
|
-
version: lineageFieldFromEnv(input.env.runnerVersion)
|
|
1981
|
-
},
|
|
1982
|
-
source: lineageFieldFromEnv(input.env.source)
|
|
1983
|
-
},
|
|
1984
|
-
subject
|
|
1947
|
+
RoleAttemptEventSchema = z4.discriminatedUnion("event", [
|
|
1948
|
+
z4.object({
|
|
1949
|
+
...roleAttemptShared,
|
|
1950
|
+
event: z4.literal("attempted"),
|
|
1951
|
+
outcome: RoleAttemptOutcomeSchema,
|
|
1952
|
+
usage: dispatchUsageField
|
|
1953
|
+
}).strict()
|
|
1954
|
+
]);
|
|
1955
|
+
handoffShared = {
|
|
1956
|
+
meta: HeaderMetaSchema,
|
|
1957
|
+
subject: SubjectSchema,
|
|
1958
|
+
kind: z4.literal("handoff"),
|
|
1959
|
+
...envelopeTail,
|
|
1960
|
+
class: z4.enum(["authority", "strategy", "product"]),
|
|
1961
|
+
reason: z4.string()
|
|
1985
1962
|
};
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1963
|
+
HandoffEventSchema = z4.discriminatedUnion("event", [
|
|
1964
|
+
z4.object({
|
|
1965
|
+
...handoffShared,
|
|
1966
|
+
event: z4.literal("raised"),
|
|
1967
|
+
requested_decision: z4.string().nullable()
|
|
1968
|
+
}).strict(),
|
|
1969
|
+
z4.object({
|
|
1970
|
+
...handoffShared,
|
|
1971
|
+
event: z4.literal("resolved"),
|
|
1972
|
+
resolution: z4.string().nullable(),
|
|
1973
|
+
resolved_by: z4.string().nullable()
|
|
1974
|
+
}).strict()
|
|
1975
|
+
]);
|
|
1976
|
+
EffectTargetSchema = z4.object({
|
|
1977
|
+
kind: z4.string(),
|
|
1978
|
+
ref: z4.string()
|
|
1979
|
+
}).strict();
|
|
1980
|
+
effectShared = {
|
|
1981
|
+
meta: HeaderMetaSchema,
|
|
1982
|
+
subject: SubjectSchema,
|
|
1983
|
+
kind: z4.literal("effect"),
|
|
1984
|
+
...envelopeTail,
|
|
1985
|
+
effect_id: z4.string(),
|
|
1986
|
+
target: EffectTargetSchema
|
|
1987
|
+
};
|
|
1988
|
+
EffectEventSchema = z4.discriminatedUnion("event", [
|
|
1989
|
+
z4.object({ ...effectShared, event: z4.literal("attempted") }).strict(),
|
|
1990
|
+
z4.object({ ...effectShared, event: z4.literal("observed"), outcome: z4.enum(["success", "failure", "uncertain"]) }).strict(),
|
|
1991
|
+
z4.object({ ...effectShared, event: z4.literal("verified"), outcome: z4.enum(["success", "failure", "uncertain"]) }).strict()
|
|
1992
|
+
]);
|
|
1993
|
+
CustomFieldValueSchema = z4.union([z4.string().max(CUSTOM_TEXT_MAX_LENGTH), z4.number().finite(), z4.boolean()]);
|
|
1994
|
+
customShared = {
|
|
1995
|
+
meta: HeaderMetaSchema,
|
|
1996
|
+
subject: SubjectSchema,
|
|
1997
|
+
kind: z4.literal("custom"),
|
|
1998
|
+
...envelopeTail
|
|
1999
|
+
};
|
|
2000
|
+
CustomEventSchema = z4.discriminatedUnion("event", [
|
|
2001
|
+
z4.object({
|
|
2002
|
+
...customShared,
|
|
2003
|
+
event: z4.literal("recorded"),
|
|
2004
|
+
name: z4.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
|
|
2005
|
+
fields: z4.record(z4.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH).regex(CUSTOM_FIELD_NAME_PATTERN), CustomFieldValueSchema).refine((f) => Object.keys(f).length <= CUSTOM_EVENT_MAX_FIELDS, {
|
|
2006
|
+
message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
|
|
2007
|
+
})
|
|
2008
|
+
}).strict()
|
|
2009
|
+
]);
|
|
2010
|
+
LogEventSchema = z4.union([
|
|
2011
|
+
DispatchEventSchema,
|
|
2012
|
+
DevReviewLoopEventSchema,
|
|
2013
|
+
ForgeWriteEventSchema,
|
|
2014
|
+
GateEventSchema,
|
|
2015
|
+
OperationEventSchema,
|
|
2016
|
+
UsageEventSchema,
|
|
2017
|
+
RoleAttemptEventSchema,
|
|
2018
|
+
HandoffEventSchema,
|
|
2019
|
+
EffectEventSchema,
|
|
2020
|
+
CustomEventSchema
|
|
2021
|
+
]);
|
|
1989
2022
|
});
|
|
1990
2023
|
|
|
1991
2024
|
// ../../harness/kernel/log/store.ts
|
|
@@ -2093,7 +2126,8 @@ function code(value) {
|
|
|
2093
2126
|
return typeof value === "string" && CODE_TOKEN_PATTERN.test(value) ? value : null;
|
|
2094
2127
|
}
|
|
2095
2128
|
function roleSubject(value, sentenceStart = true) {
|
|
2096
|
-
const
|
|
2129
|
+
const known = typeof value === "string" ? lookupRole(value) : undefined;
|
|
2130
|
+
const name = known ? `the ${known.reading}` : "a role";
|
|
2097
2131
|
return sentenceStart ? `${name[0]?.toUpperCase()}${name.slice(1)}` : name;
|
|
2098
2132
|
}
|
|
2099
2133
|
function roundLabel(record) {
|
|
@@ -2212,7 +2246,7 @@ function conflictReentry(record) {
|
|
|
2212
2246
|
function dispatched(record) {
|
|
2213
2247
|
const role = text(record.target_role);
|
|
2214
2248
|
const who = roleSubject(role);
|
|
2215
|
-
const reviewing = role
|
|
2249
|
+
const reviewing = role !== null && (lookupRole(role)?.reviews ?? false);
|
|
2216
2250
|
const round = whole(record.round);
|
|
2217
2251
|
return {
|
|
2218
2252
|
kind: "working",
|
|
@@ -2271,6 +2305,7 @@ function narrate(record, earlier = []) {
|
|
|
2271
2305
|
}
|
|
2272
2306
|
var REASONS, PAUSE_WITHOUT_CODE;
|
|
2273
2307
|
var init_narration = __esm(() => {
|
|
2308
|
+
init_roles();
|
|
2274
2309
|
init_schema();
|
|
2275
2310
|
REASONS = {
|
|
2276
2311
|
escalation: { words: "a role escalated a question", person: true },
|
|
@@ -2303,13 +2338,7 @@ var init_narration = __esm(() => {
|
|
|
2303
2338
|
|
|
2304
2339
|
// ../../harness/kernel/adapters/agents/agent-line.ts
|
|
2305
2340
|
function roleLabel(role) {
|
|
2306
|
-
|
|
2307
|
-
return roleLabels[role];
|
|
2308
|
-
if (role === "dev-review-loop")
|
|
2309
|
-
return "Loop";
|
|
2310
|
-
if (role === "operator")
|
|
2311
|
-
return "Operator";
|
|
2312
|
-
return role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
2341
|
+
return lookupTitle(role) ?? role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
2313
2342
|
}
|
|
2314
2343
|
function logQuiet(env = process.env) {
|
|
2315
2344
|
return env.VINAYA_LOG_QUIET === "1" || env.VINAYA_LOG_QUIET === "true";
|
|
@@ -2377,17 +2406,9 @@ function renderNarratedUpdate(update) {
|
|
|
2377
2406
|
...call
|
|
2378
2407
|
};
|
|
2379
2408
|
}
|
|
2380
|
-
var
|
|
2409
|
+
var unicodeMarks, asciiMarks, META_KEY, META_VALUE, actionVerbs, resultVerbs;
|
|
2381
2410
|
var init_agent_line = __esm(() => {
|
|
2382
|
-
|
|
2383
|
-
planner: "Planner",
|
|
2384
|
-
developer: "Developer",
|
|
2385
|
-
"code-reviewer": "Code review",
|
|
2386
|
-
security: "Security",
|
|
2387
|
-
principal: "Principal",
|
|
2388
|
-
archivist: "Archivist",
|
|
2389
|
-
architect: "Architect"
|
|
2390
|
-
};
|
|
2411
|
+
init_roles();
|
|
2391
2412
|
unicodeMarks = { working: "▸", done: "✓", failed: "✕", waiting: "◌", round: "◆" };
|
|
2392
2413
|
asciiMarks = { working: ">", done: "+", failed: "x", waiting: "~", round: "#" };
|
|
2393
2414
|
META_KEY = /^[a-z]+$/;
|
|
@@ -4273,6 +4294,7 @@ function installVinayaLogSinkFactory() {
|
|
|
4273
4294
|
var init_log_sink_factory = __esm(() => {
|
|
4274
4295
|
init_log_sink();
|
|
4275
4296
|
init_package_root();
|
|
4297
|
+
init_log_roles();
|
|
4276
4298
|
init_branch_issue();
|
|
4277
4299
|
init_doctrine_version();
|
|
4278
4300
|
});
|
|
@@ -8702,6 +8724,10 @@ function colourAgentLine(role, line, stream, mark = "working") {
|
|
|
8702
8724
|
function isAgentVendor(value) {
|
|
8703
8725
|
return AGENT_VENDOR_NAMES.includes(value);
|
|
8704
8726
|
}
|
|
8727
|
+
function realCeilingTimer(fire, timeoutMs) {
|
|
8728
|
+
const timer = setTimeout(fire, timeoutMs);
|
|
8729
|
+
return () => clearTimeout(timer);
|
|
8730
|
+
}
|
|
8705
8731
|
function addCodexWritableDirs(args, extraWritableDirs, resumed, developerFiles = []) {
|
|
8706
8732
|
const requestedDirs = [...extraWritableDirs, ...developerFiles.map((file) => dirname11(file))];
|
|
8707
8733
|
if (requestedDirs.length === 0)
|
|
@@ -9862,14 +9888,14 @@ function sleepSyncMs(ms) {
|
|
|
9862
9888
|
return;
|
|
9863
9889
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
9864
9890
|
}
|
|
9865
|
-
function captureSettledChildSnapshot(pid) {
|
|
9866
|
-
let snapshot =
|
|
9891
|
+
function captureSettledChildSnapshot(pid, readSnapshot = getProcessSnapshot) {
|
|
9892
|
+
let snapshot = readSnapshot(pid);
|
|
9867
9893
|
if (snapshot === null)
|
|
9868
9894
|
return null;
|
|
9869
9895
|
const deadline = Date.now() + IDENTITY_SETTLE_BUDGET_MS;
|
|
9870
9896
|
while (Date.now() < deadline) {
|
|
9871
9897
|
sleepSyncMs(IDENTITY_SETTLE_POLL_MS);
|
|
9872
|
-
const next =
|
|
9898
|
+
const next = readSnapshot(pid);
|
|
9873
9899
|
if (next === null)
|
|
9874
9900
|
return snapshot;
|
|
9875
9901
|
if (next.command === snapshot.command)
|
|
@@ -10796,7 +10822,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
|
|
|
10796
10822
|
const warnTimer = setTimeout(() => {
|
|
10797
10823
|
writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: approaching timeout — SIGTERM in ~${Math.round(warnLeadMs / 1000)}s unless it finishes first`);
|
|
10798
10824
|
}, Math.max(timeoutMs - warnLeadMs, 0));
|
|
10799
|
-
const
|
|
10825
|
+
const disarmCeiling = (opts.armCeiling ?? realCeilingTimer)(() => {
|
|
10800
10826
|
timedOut = true;
|
|
10801
10827
|
writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: ceiling reached — sending SIGTERM`);
|
|
10802
10828
|
child.kill("SIGTERM");
|
|
@@ -10832,7 +10858,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
|
|
|
10832
10858
|
if (settled)
|
|
10833
10859
|
return;
|
|
10834
10860
|
settled = true;
|
|
10835
|
-
|
|
10861
|
+
disarmCeiling();
|
|
10836
10862
|
if (killTimer)
|
|
10837
10863
|
clearTimeout(killTimer);
|
|
10838
10864
|
clearTimeout(firstWaitTimer);
|
|
@@ -11341,8 +11367,8 @@ var init_protected_paths2 = __esm(() => {
|
|
|
11341
11367
|
|
|
11342
11368
|
// ../../harness/processes/vinaya-strict/integration/policies/roles.ts
|
|
11343
11369
|
var GRANTED_ROLES, ROLE_TOOL_GRANTS, VINAYA_TOOL_GRANTS, VINAYA_BROKER_ROLES, VINAYA_BOUNDARY_ROLES, OPERATOR_TOOL_GRANT, VINAYA_ROUTER_ROLES;
|
|
11344
|
-
var
|
|
11345
|
-
|
|
11370
|
+
var init_roles2 = __esm(() => {
|
|
11371
|
+
init_log_roles();
|
|
11346
11372
|
GRANTED_ROLES = ["developer", "code-reviewer", "security", "controller"];
|
|
11347
11373
|
ROLE_TOOL_GRANTS = {
|
|
11348
11374
|
developer: [
|
|
@@ -11361,7 +11387,7 @@ var init_roles = __esm(() => {
|
|
|
11361
11387
|
};
|
|
11362
11388
|
VINAYA_TOOL_GRANTS = { roles: GRANTED_ROLES, grants: ROLE_TOOL_GRANTS };
|
|
11363
11389
|
VINAYA_BROKER_ROLES = {
|
|
11364
|
-
recognizedRoles:
|
|
11390
|
+
recognizedRoles: VINAYA_LOG_ROLE_NAMES,
|
|
11365
11391
|
workerRoles: ["developer"],
|
|
11366
11392
|
surfaceOwner: "the Planner"
|
|
11367
11393
|
};
|
|
@@ -11445,7 +11471,7 @@ function vinayaRouterPolicies() {
|
|
|
11445
11471
|
var init_vinaya_policies = __esm(() => {
|
|
11446
11472
|
init_launch_records();
|
|
11447
11473
|
init_protected_paths2();
|
|
11448
|
-
|
|
11474
|
+
init_roles2();
|
|
11449
11475
|
init_scratch_names();
|
|
11450
11476
|
});
|
|
11451
11477
|
|
|
@@ -11532,7 +11558,9 @@ var init_programs = __esm(() => {
|
|
|
11532
11558
|
program("log-selftest", `${P}/integration/bin/log-selftest.ts`, "dist/programs/log-selftest.js", [
|
|
11533
11559
|
words("log", "selftest")
|
|
11534
11560
|
]),
|
|
11535
|
-
program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")])
|
|
11561
|
+
program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")]),
|
|
11562
|
+
program("run-engine", `${P}/bin/run-engine.ts`, "dist/programs/run-engine.js"),
|
|
11563
|
+
program("supervised-command", `${P}/loops/dev-review/v2/supervised-command.ts`, "dist/programs/supervised-command.js")
|
|
11536
11564
|
]);
|
|
11537
11565
|
SOURCE_ROOT = join17(dirname12(fileURLToPath4(import.meta.url)), "..", "..", "..", "..");
|
|
11538
11566
|
FROM_SOURCE = fileURLToPath4(import.meta.url).endsWith(".ts");
|
|
@@ -11675,7 +11703,7 @@ function isEntryPoint(moduleUrl, scriptName, startedOn = process.argv[1]) {
|
|
|
11675
11703
|
}
|
|
11676
11704
|
|
|
11677
11705
|
// ../../harness/processes/vinaya-strict/loops/dev-review/dispatch/bin/dispatch.ts
|
|
11678
|
-
|
|
11706
|
+
init_log_roles();
|
|
11679
11707
|
init_dispatch();
|
|
11680
11708
|
init_compose();
|
|
11681
11709
|
import { readFileSync as readFileSync14 } from "node:fs";
|
|
@@ -11750,8 +11778,8 @@ async function dispatchCommand(args) {
|
|
|
11750
11778
|
`);
|
|
11751
11779
|
process.exit(1);
|
|
11752
11780
|
}
|
|
11753
|
-
if (!parsed.role || !
|
|
11754
|
-
process.stderr.write(`vinaya dispatch: invalid role '${parsed.role ?? "(none)"}' — expected one of ${
|
|
11781
|
+
if (!parsed.role || !VINAYA_LOG_ROLE_NAMES.includes(parsed.role)) {
|
|
11782
|
+
process.stderr.write(`vinaya dispatch: invalid role '${parsed.role ?? "(none)"}' — expected one of ${VINAYA_LOG_ROLE_NAMES.join(", ")}
|
|
11755
11783
|
`);
|
|
11756
11784
|
process.exit(1);
|
|
11757
11785
|
}
|