@akagilnc/pi-workflow-roles 0.1.4802 → 0.1.4870
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/acp-host/production-host.js +19434 -18218
- package/dist/analyst-book-key.js +63 -0
- package/dist/analyst-cohort.js +167 -0
- package/dist/analyst-entry.js +320 -0
- package/dist/analyst-index.js +247 -0
- package/dist/analyst-ledger.js +561 -0
- package/dist/analyst-median.js +16 -0
- package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
- package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
- package/dist/analyst-metric-families/gate-cycles.js +77 -0
- package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
- package/dist/analyst-metric-families/round-timeline.js +126 -0
- package/dist/analyst-metric-families.js +23 -0
- package/dist/analyst-metric-family.js +11 -0
- package/dist/analyst-model-groups.js +135 -0
- package/dist/analyst-page.js +182 -0
- package/dist/atomic-write.js +23 -0
- package/dist/auditor-soul.js +1 -1
- package/dist/countersign-contracts.js +0 -2
- package/dist/diarist-contracts.js +0 -1
- package/dist/doctor-contracts.js +2 -2
- package/dist/gatekeeper-role.js +15 -16
- package/dist/gleaner-left-contracts.js +0 -2
- package/dist/headless-host/production-host.js +16967 -15749
- package/dist/host-contracts.js +0 -4
- package/dist/inspector-contracts.js +0 -2
- package/dist/institutional-resolution.js +4 -2
- package/dist/merger-contracts.js +0 -2
- package/dist/migrate-book-topology.js +3908 -3089
- package/dist/navigator-public-session.js +4 -3
- package/dist/notary-contracts.js +0 -2
- package/dist/package-contracts/auditor-output.js +0 -1
- package/dist/package-contracts/collector-output.js +0 -2
- package/dist/package-contracts/fixer-output.js +0 -2
- package/dist/package-contracts/gatekeeper-output.js +0 -2
- package/dist/package-contracts/judge-output.js +0 -2
- package/dist/package-contracts/navigator-output.js +0 -2
- package/dist/package-contracts/reviewer-output.js +0 -2
- package/dist/package-contracts/terminating-tools.js +32 -92
- package/dist/package-contracts/worker-output.js +0 -4
- package/dist/packaged-role-registry.js +518 -36
- package/dist/pi/role-turn-host.js +2 -1
- package/dist/public-cli/analyst-run.js +185 -0
- package/dist/public-cli/cli.js +885 -0
- package/dist/public-cli/config.js +12 -9
- package/dist/public-cli/countersign-run.js +4 -311
- package/dist/public-cli/instruction-seat-run.js +628 -158
- package/dist/public-cli/invocation.js +806 -1550
- package/dist/public-cli/main.js +6962 -9882
- package/dist/public-cli/option-definitions.js +51 -99
- package/dist/public-cli/post-admission.js +30 -2
- package/dist/public-cli/run-lifecycle.js +234 -353
- package/dist/public-cli/seat-ticket-binding.js +6 -0
- package/dist/public-cli/settlement.js +261 -675
- package/dist/public-cli/turn-request.js +76 -0
- package/dist/public-role-summons.js +38 -112
- package/dist/role-activation-flags.js +23 -45
- package/dist/secretariat-contracts.js +0 -2
- package/dist/session-identity.js +17 -8
- package/dist/session-opening-materials.js +3 -2
- package/extensions/role-runtime.ts +6 -80
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +4 -1
- package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
- package/src/auditor-role.ts +1 -2
- package/src/auditor-soul.ts +1 -1
- package/src/collector-role.ts +2 -2
- package/src/countersign-contracts.ts +0 -1
- package/src/countersign-role.ts +1 -1
- package/src/diarist-contracts.ts +0 -1
- package/src/diarist-role.ts +0 -1
- package/src/doctor-auditor.ts +1 -2
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-role.ts +3 -2
- package/src/external-host-turn-loop.ts +1 -1
- package/src/factory-board.ts +10 -7
- package/src/gatekeeper-role.ts +16 -10
- package/src/gleaner-left-contracts.ts +0 -1
- package/src/gleaner-left-role.ts +0 -1
- package/src/headless-host/role-turn-host.ts +7 -1
- package/src/host-contracts.ts +10 -6
- package/src/inspector-contracts.ts +0 -1
- package/src/inspector-role.ts +0 -2
- package/src/institutional-resolution.ts +6 -4
- package/src/judge-role.ts +3 -3
- package/src/merger-contracts.ts +0 -1
- package/src/merger-role.ts +2 -2
- package/src/navigator-public-session.ts +7 -6
- package/src/navigator-work-context.ts +6 -8
- package/src/notary-contracts.ts +0 -1
- package/src/notary-role.ts +2 -3
- package/src/package-contracts/auditor-output.ts +0 -1
- package/src/package-contracts/collector-output.ts +0 -1
- package/src/package-contracts/fixer-output.ts +0 -1
- package/src/package-contracts/gatekeeper-output.ts +0 -1
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/navigator-output.ts +0 -1
- package/src/package-contracts/reviewer-output.ts +0 -1
- package/src/package-contracts/terminating-tools.ts +27 -99
- package/src/package-contracts/worker-output.ts +0 -2
- package/src/packaged-role-registry.ts +604 -35
- package/src/pi/role-turn-host.ts +2 -1
- package/src/public-cli/cli.ts +64 -259
- package/src/public-cli/config.ts +18 -10
- package/src/public-cli/countersign-run.ts +14 -449
- package/src/public-cli/instruction-seat-run.ts +758 -277
- package/src/public-cli/invocation.ts +1097 -2051
- package/src/public-cli/option-definitions.ts +62 -127
- package/src/public-cli/post-admission.ts +47 -2
- package/src/public-cli/run-lifecycle.ts +303 -613
- package/src/public-cli/seat-ticket-binding.ts +6 -0
- package/src/public-cli/settlement.ts +399 -1185
- package/src/public-cli/turn-request.ts +92 -1
- package/src/public-role-summons.ts +44 -128
- package/src/reviewer-role.ts +3 -2
- package/src/role-activation-flags.ts +20 -41
- package/src/role-runtime-dependencies.ts +25 -26
- package/src/role-runtime.ts +121 -232
- package/src/secretariat-contracts.ts +0 -1
- package/src/secretariat-role.ts +0 -2
- package/src/session-identity.ts +23 -8
- package/src/session-opening-materials.ts +2 -1
- package/src/worker-role.ts +3 -4
- package/dist/doctor-auditor.js +0 -25
- package/dist/public-cli/diarist-run.js +0 -130
- package/dist/public-cli/doctor-run.js +0 -87
- package/dist/public-cli/inspector-run.js +0 -151
- package/dist/public-cli/judge-run.js +0 -114
- package/dist/public-cli/notary-run.js +0 -174
- package/dist/public-cli/reviewer-run.js +0 -339
- package/src/public-cli/coder-run.ts +0 -255
- package/src/public-cli/collector-run.ts +0 -189
- package/src/public-cli/diarist-run.ts +0 -233
- package/src/public-cli/doctor-run.ts +0 -167
- package/src/public-cli/fixer-run.ts +0 -265
- package/src/public-cli/gleaner-left-run.ts +0 -167
- package/src/public-cli/inspector-run.ts +0 -261
- package/src/public-cli/judge-run.ts +0 -196
- package/src/public-cli/merger-run.ts +0 -294
- package/src/public-cli/notary-run.ts +0 -279
- package/src/public-cli/reviewer-run.ts +0 -480
- package/src/public-cli/secretariat-run.ts +0 -265
|
@@ -17,6 +17,7 @@ import { parseCollectorRepository } from "../collector-config.js";
|
|
|
17
17
|
import { interpretDurableCourtTicketNumbers, sameCourtTicketNumbers, } from "../diarist-contracts.js";
|
|
18
18
|
import { rewriteAdmittedRoleRunPage, rewriteRunDirectoryPathValue, } from "../role-run-relocation.js";
|
|
19
19
|
import { appendEngineSessionMaterial, engineSessionMaterialFromOptions, pickEngineAxis, } from "../package-resources/engine-material.js";
|
|
20
|
+
import { packagedResumeSourcePath, packagedRoleMetadata, } from "../packaged-role-registry.js";
|
|
20
21
|
import { recordEffectiveInvocationModel, requireAuthorityRef, isReviewerLens, } from "./invocation.js";
|
|
21
22
|
/** Providers eligible for v1 typed-429 resume (Codex / xAI only).
|
|
22
23
|
* @deprecated v1 429-only gate removed by #416 (owner 2026-08-22: "根本不要有限制"). Kept for compatibility; do not use for new branching.
|
|
@@ -154,22 +155,8 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
154
155
|
if (typeof record.runId !== "string" || record.runId.trim() === "") {
|
|
155
156
|
return undefined;
|
|
156
157
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
record.role !== "fixer" &&
|
|
160
|
-
record.role !== "collector" &&
|
|
161
|
-
record.role !== "doctor" &&
|
|
162
|
-
record.role !== "reviewer" &&
|
|
163
|
-
record.role !== "merger" &&
|
|
164
|
-
record.role !== "notary" &&
|
|
165
|
-
record.role !== "countersign" &&
|
|
166
|
-
record.role !== "gleaner-left" &&
|
|
167
|
-
record.role !== "inspector" &&
|
|
168
|
-
record.role !== "gatekeeper" &&
|
|
169
|
-
record.role !== "navigator" &&
|
|
170
|
-
record.role !== "auditor" &&
|
|
171
|
-
record.role !== "diarist" &&
|
|
172
|
-
record.role !== "secretariat") {
|
|
158
|
+
const role = typeof record.role === "string" ? packagedRoleMetadata(record.role)?.role : undefined;
|
|
159
|
+
if (role === undefined) {
|
|
173
160
|
return undefined;
|
|
174
161
|
}
|
|
175
162
|
if (record.state !== "admitted" &&
|
|
@@ -215,7 +202,7 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
215
202
|
const currentCourt = parseCurrentCourtState(record.currentCourt);
|
|
216
203
|
return {
|
|
217
204
|
runId: record.runId,
|
|
218
|
-
role
|
|
205
|
+
role,
|
|
219
206
|
state: record.state,
|
|
220
207
|
bookKey: record.bookKey,
|
|
221
208
|
projectRoot: record.projectRoot,
|
|
@@ -299,6 +286,10 @@ export async function readRoleRunIdentity(runDirectory) {
|
|
|
299
286
|
}
|
|
300
287
|
export async function markRunAdmitted(admitted, authority) {
|
|
301
288
|
const { sessionDirectory, sessionFile } = authority.decode(admitted.principal);
|
|
289
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
290
|
+
const workerPhase = record !== undefined && "worker" in record && record.worker === true && "phase" in admitted
|
|
291
|
+
? admitted.phase
|
|
292
|
+
: undefined;
|
|
302
293
|
await writeRoleRunState(admitted.runDirectory, {
|
|
303
294
|
runId: admitted.runId,
|
|
304
295
|
role: admitted.role,
|
|
@@ -308,9 +299,7 @@ export async function markRunAdmitted(admitted, authority) {
|
|
|
308
299
|
sessionDirectory,
|
|
309
300
|
sessionFile,
|
|
310
301
|
admittedRequestPath: admitted.admittedRequestPath,
|
|
311
|
-
...(
|
|
312
|
-
? { phase: admitted.phase }
|
|
313
|
-
: {}),
|
|
302
|
+
...(workerPhase === undefined ? {} : { phase: workerPhase }),
|
|
314
303
|
});
|
|
315
304
|
}
|
|
316
305
|
/**
|
|
@@ -818,10 +807,11 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
818
807
|
/**
|
|
819
808
|
* Locate the latest retained run for one seat under a book (#637 / #747).
|
|
820
809
|
* Same walk surface as findRunDirectoryById (listBookRunDirectories). Match by
|
|
821
|
-
* parent run path (officer / gate seats, #747 / #987).
|
|
822
|
-
*
|
|
823
|
-
* parallel index. Public ticket-number
|
|
824
|
-
* (#987 Result 7); callers use explicit
|
|
810
|
+
* parent run path (officer / gate seats, #747 / #987). A typed ticket number
|
|
811
|
+
* does not select a run. runId is UUIDv7 — lexicographic max is latest among
|
|
812
|
+
* runs that formed a session principal. No parallel index. Public ticket-number
|
|
813
|
+
* selection of a prior run was deleted (#987 Result 7); callers use explicit
|
|
814
|
+
* `ak-role resume <runId>`.
|
|
825
815
|
* Only a truly missing book directory means no history; damage/permission errors propagate.
|
|
826
816
|
*/
|
|
827
817
|
export async function findLatestRunIdForSeatTicket(input) {
|
|
@@ -1230,9 +1220,8 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
1230
1220
|
};
|
|
1231
1221
|
}
|
|
1232
1222
|
/**
|
|
1233
|
-
* Base admitted projection
|
|
1234
|
-
*
|
|
1235
|
-
* Seat loaders add only their seat-specific fields on top.
|
|
1223
|
+
* Base admitted projection: durable identity, instruction, attachments, principal, ticket, and model.
|
|
1224
|
+
* Seat restore adds only that seat's fields.
|
|
1236
1225
|
*/
|
|
1237
1226
|
function resumedBaseAdmitted(loaded) {
|
|
1238
1227
|
return {
|
|
@@ -1249,7 +1238,7 @@ function resumedBaseAdmitted(loaded) {
|
|
|
1249
1238
|
...restoredTicketFields(loaded.admittedFields),
|
|
1250
1239
|
};
|
|
1251
1240
|
}
|
|
1252
|
-
/** Loaded-run envelope
|
|
1241
|
+
/** Loaded-run envelope. */
|
|
1253
1242
|
function seatLoadedResult(loaded, admitted) {
|
|
1254
1243
|
return {
|
|
1255
1244
|
admitted,
|
|
@@ -1257,340 +1246,232 @@ function seatLoadedResult(loaded, admitted) {
|
|
|
1257
1246
|
...(loaded.observation === undefined ? {} : { observation: loaded.observation }),
|
|
1258
1247
|
};
|
|
1259
1248
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
if (loaded.run.role !== "judge") {
|
|
1267
|
-
throw new CliUsageError(`role run ${runId} belongs to ${loaded.run.role}, not judge`);
|
|
1268
|
-
}
|
|
1269
|
-
const admitted = {
|
|
1270
|
-
role: "judge",
|
|
1271
|
-
...resumedBaseAdmitted(loaded),
|
|
1272
|
-
};
|
|
1273
|
-
return seatLoadedResult(loaded, admitted);
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Load a resumable Coder run for resume. Phase and task path are restored from
|
|
1277
|
-
* the admitted request so continuation stays role-correct (#109).
|
|
1278
|
-
*/
|
|
1279
|
-
export async function loadResumableCoderRun(home, runId, authority) {
|
|
1280
|
-
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
1281
|
-
if (loaded.run.role !== "coder") {
|
|
1282
|
-
throw new CliUsageError(`role run ${runId} belongs to ${loaded.run.role}, not coder`);
|
|
1283
|
-
}
|
|
1284
|
-
const phase = loaded.admittedFields.phase ?? loaded.run.phase;
|
|
1285
|
-
if (phase !== "plan" && phase !== "apply") {
|
|
1286
|
-
throw new CliUsageError(`role run admitted coder phase is missing: ${runId}`);
|
|
1287
|
-
}
|
|
1288
|
-
const taskPath = loaded.admittedFields.taskPath;
|
|
1289
|
-
if (taskPath === undefined) {
|
|
1290
|
-
throw new CliUsageError(`role run admitted coder task path is missing: ${runId}`);
|
|
1291
|
-
}
|
|
1292
|
-
if (loaded.admittedFields.instruction.trim() === "") {
|
|
1293
|
-
throw new CliUsageError(`role run admitted coder task is blank: ${runId}`);
|
|
1294
|
-
}
|
|
1295
|
-
const admitted = {
|
|
1296
|
-
role: "coder",
|
|
1297
|
-
phase,
|
|
1298
|
-
...resumedBaseAdmitted(loaded),
|
|
1299
|
-
instructionEmpty: false,
|
|
1300
|
-
taskPath,
|
|
1301
|
-
};
|
|
1302
|
-
return seatLoadedResult(loaded, admitted);
|
|
1249
|
+
export async function peekRoleRunRole(home, runId) {
|
|
1250
|
+
const runDirectory = await findRunDirectoryById(home, runId);
|
|
1251
|
+
if (runDirectory === undefined)
|
|
1252
|
+
return undefined;
|
|
1253
|
+
const run = await readRoleRunIdentity(runDirectory);
|
|
1254
|
+
return run?.role;
|
|
1303
1255
|
}
|
|
1304
1256
|
/**
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1257
|
+
* One resume load. The caller supplies the package run id; the disk role
|
|
1258
|
+
* selects the existing restore checks. The stored native host session id is
|
|
1259
|
+
* read on the public explicit resume seam, not from this load.
|
|
1307
1260
|
*/
|
|
1308
|
-
export async function
|
|
1261
|
+
export async function loadResumablePublicRole(home, runId, authority) {
|
|
1309
1262
|
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
1310
|
-
|
|
1311
|
-
throw new CliUsageError(`role run ${runId} belongs to ${loaded.run.role}, not fixer`);
|
|
1312
|
-
}
|
|
1313
|
-
const phase = loaded.admittedFields.phase ?? loaded.run.phase;
|
|
1314
|
-
if (phase !== "plan" && phase !== "apply") {
|
|
1315
|
-
throw new CliUsageError(`role run admitted fixer phase is missing: ${runId}`);
|
|
1316
|
-
}
|
|
1317
|
-
const packetPath = loaded.admittedFields.packetPath;
|
|
1318
|
-
if (packetPath === undefined) {
|
|
1319
|
-
throw new CliUsageError(`role run admitted fixer packet path is missing: ${runId}`);
|
|
1320
|
-
}
|
|
1321
|
-
if (loaded.admittedFields.instruction.trim() === "") {
|
|
1322
|
-
throw new CliUsageError(`role run admitted fixer instruction is blank: ${runId}`);
|
|
1323
|
-
}
|
|
1324
|
-
const prerequisites = loaded.admittedFields.prerequisites ?? Object.freeze([]);
|
|
1325
|
-
const admitted = {
|
|
1326
|
-
role: "fixer",
|
|
1327
|
-
phase,
|
|
1328
|
-
...resumedBaseAdmitted(loaded),
|
|
1329
|
-
instructionEmpty: false,
|
|
1330
|
-
packetPath,
|
|
1331
|
-
...(loaded.admittedFields.prerequisitesPath === undefined
|
|
1332
|
-
? {}
|
|
1333
|
-
: { prerequisitesPath: loaded.admittedFields.prerequisitesPath }),
|
|
1334
|
-
prerequisites,
|
|
1335
|
-
};
|
|
1336
|
-
return seatLoadedResult(loaded, admitted);
|
|
1263
|
+
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
1337
1264
|
}
|
|
1338
1265
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
*
|
|
1341
|
-
*/
|
|
1342
|
-
/**
|
|
1343
|
-
* Load a resumable Reviewer run for resume. Fixed base is restored from the
|
|
1344
|
-
* admitted request; caller instruction remains optional provenance only.
|
|
1266
|
+
* One resume restore. Admission kind comes from the composition-root record;
|
|
1267
|
+
* seat-only required fields stay on that kind. Instruction seats share one face.
|
|
1345
1268
|
*/
|
|
1346
|
-
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
throw new CliUsageError(`role run admitted reviewer base revision is missing: ${runId}`);
|
|
1355
|
-
}
|
|
1356
|
-
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
1357
|
-
throw new CliUsageError(`role run admitted reviewer base revision is damaged: ${runId}`);
|
|
1358
|
-
}
|
|
1359
|
-
const baseRevision = rawBase;
|
|
1360
|
-
const lens = loaded.admittedFields.lens;
|
|
1361
|
-
if (!isReviewerLens(lens)) {
|
|
1362
|
-
throw new CliUsageError(`role run admitted reviewer lens is missing: ${runId}`);
|
|
1363
|
-
}
|
|
1364
|
-
const authorityRefs = Object.freeze([
|
|
1365
|
-
...(loaded.admittedFields.authorityRefs ?? []),
|
|
1366
|
-
]);
|
|
1367
|
-
if (authorityRefs.length === 0) {
|
|
1368
|
-
throw new CliUsageError(`role run admitted reviewer authority refs are missing: ${runId}`);
|
|
1369
|
-
}
|
|
1370
|
-
const admitted = {
|
|
1371
|
-
role: "reviewer",
|
|
1372
|
-
...resumedBaseAdmitted(loaded),
|
|
1373
|
-
baseRevision,
|
|
1374
|
-
lens,
|
|
1375
|
-
authorityRefs,
|
|
1376
|
-
};
|
|
1377
|
-
return seatLoadedResult(loaded, admitted);
|
|
1378
|
-
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Load a resumable Countersign run for resume (#599). Ticket binding and
|
|
1381
|
-
* attachments restore from the admitted request.
|
|
1382
|
-
*/
|
|
1383
|
-
export async function loadResumableCountersignRun(home, runId, authority) {
|
|
1384
|
-
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
1385
|
-
if (loaded.run.role !== "countersign") {
|
|
1386
|
-
throw new CliUsageError(`role run ${runId} belongs to ${loaded.run.role}, not countersign`);
|
|
1387
|
-
}
|
|
1269
|
+
function admitResumedRole(loaded) {
|
|
1270
|
+
const role = loaded.run.role;
|
|
1271
|
+
const runId = loaded.run.runId;
|
|
1272
|
+
const record = packagedRoleMetadata(role);
|
|
1273
|
+
if (record === undefined) {
|
|
1274
|
+
throw new CliUsageError(`unknown role: ${role}`);
|
|
1275
|
+
}
|
|
1276
|
+
const fields = loaded.admittedFields;
|
|
1388
1277
|
const base = resumedBaseAdmitted(loaded);
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
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
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1278
|
+
switch (record.admission) {
|
|
1279
|
+
case "instruction": {
|
|
1280
|
+
if (packagedResumeSourcePath(role)) {
|
|
1281
|
+
const admitted = {
|
|
1282
|
+
role: "inspector",
|
|
1283
|
+
...base,
|
|
1284
|
+
...(fields.sourceRunPath === undefined
|
|
1285
|
+
? {}
|
|
1286
|
+
: { sourceRunPath: fields.sourceRunPath }),
|
|
1287
|
+
};
|
|
1288
|
+
return admitted;
|
|
1289
|
+
}
|
|
1290
|
+
return {
|
|
1291
|
+
role,
|
|
1292
|
+
...base,
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
case "court-materials": {
|
|
1296
|
+
const admitted = {
|
|
1297
|
+
role: "countersign",
|
|
1298
|
+
...base,
|
|
1299
|
+
...(base.courtTicketNumbers === undefined
|
|
1300
|
+
? {}
|
|
1301
|
+
: { courtTicketNumbers: base.courtTicketNumbers }),
|
|
1302
|
+
...(fields.courtTicketNumbersDamage === undefined
|
|
1303
|
+
? {}
|
|
1304
|
+
: { courtTicketNumbersDamage: fields.courtTicketNumbersDamage }),
|
|
1305
|
+
};
|
|
1306
|
+
return admitted;
|
|
1307
|
+
}
|
|
1308
|
+
case "worker-task": {
|
|
1309
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
1310
|
+
const taskPath = fields.taskPath;
|
|
1311
|
+
if (taskPath === undefined) {
|
|
1312
|
+
throw new CliUsageError(`role run admitted coder task path is missing: ${runId}`);
|
|
1313
|
+
}
|
|
1314
|
+
if (fields.instruction.trim() === "") {
|
|
1315
|
+
throw new CliUsageError(`role run admitted coder task is blank: ${runId}`);
|
|
1316
|
+
}
|
|
1317
|
+
const admitted = {
|
|
1318
|
+
role: "coder",
|
|
1319
|
+
phase,
|
|
1320
|
+
...base,
|
|
1321
|
+
instructionEmpty: false,
|
|
1322
|
+
taskPath,
|
|
1323
|
+
};
|
|
1324
|
+
return admitted;
|
|
1325
|
+
}
|
|
1326
|
+
case "worker-packet": {
|
|
1327
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
1328
|
+
const packetPath = fields.packetPath;
|
|
1329
|
+
if (packetPath === undefined) {
|
|
1330
|
+
throw new CliUsageError(`role run admitted fixer packet path is missing: ${runId}`);
|
|
1331
|
+
}
|
|
1332
|
+
if (fields.instruction.trim() === "") {
|
|
1333
|
+
throw new CliUsageError(`role run admitted fixer instruction is blank: ${runId}`);
|
|
1334
|
+
}
|
|
1335
|
+
const prerequisites = fields.prerequisites ?? Object.freeze([]);
|
|
1336
|
+
const admitted = {
|
|
1337
|
+
role: "fixer",
|
|
1338
|
+
phase,
|
|
1339
|
+
...base,
|
|
1340
|
+
instructionEmpty: false,
|
|
1341
|
+
packetPath,
|
|
1342
|
+
...(fields.prerequisitesPath === undefined
|
|
1343
|
+
? {}
|
|
1344
|
+
: { prerequisitesPath: fields.prerequisitesPath }),
|
|
1345
|
+
prerequisites,
|
|
1346
|
+
};
|
|
1347
|
+
return admitted;
|
|
1348
|
+
}
|
|
1349
|
+
case "review-basis": {
|
|
1350
|
+
const rawBase = fields.baseRevision;
|
|
1351
|
+
if (rawBase === undefined || rawBase.trim() === "") {
|
|
1352
|
+
throw new CliUsageError(`role run admitted reviewer base revision is missing: ${runId}`);
|
|
1353
|
+
}
|
|
1354
|
+
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
1355
|
+
throw new CliUsageError(`role run admitted reviewer base revision is damaged: ${runId}`);
|
|
1356
|
+
}
|
|
1357
|
+
const lens = fields.lens;
|
|
1358
|
+
if (!isReviewerLens(lens)) {
|
|
1359
|
+
throw new CliUsageError(`role run admitted reviewer lens is missing: ${runId}`);
|
|
1360
|
+
}
|
|
1361
|
+
const authorityRefs = Object.freeze([...(fields.authorityRefs ?? [])]);
|
|
1362
|
+
if (authorityRefs.length === 0) {
|
|
1363
|
+
throw new CliUsageError(`role run admitted reviewer authority refs are missing: ${runId}`);
|
|
1364
|
+
}
|
|
1365
|
+
const admitted = {
|
|
1366
|
+
role: "reviewer",
|
|
1367
|
+
...base,
|
|
1368
|
+
baseRevision: rawBase,
|
|
1369
|
+
lens,
|
|
1370
|
+
authorityRefs,
|
|
1371
|
+
};
|
|
1372
|
+
return admitted;
|
|
1373
|
+
}
|
|
1374
|
+
case "gleaner": {
|
|
1375
|
+
const baseRevision = fields.baseRevision;
|
|
1376
|
+
if (baseRevision === undefined || baseRevision.trim() === "") {
|
|
1377
|
+
throw new CliUsageError(`role run admitted gleaner-left base revision is missing: ${runId}`);
|
|
1378
|
+
}
|
|
1379
|
+
const admitted = {
|
|
1380
|
+
role: "gleaner-left",
|
|
1381
|
+
...base,
|
|
1382
|
+
baseRevision,
|
|
1383
|
+
};
|
|
1384
|
+
return admitted;
|
|
1385
|
+
}
|
|
1386
|
+
case "merge-envelope": {
|
|
1387
|
+
const mergerInputPath = fields.mergerInputPath;
|
|
1388
|
+
if (mergerInputPath === undefined) {
|
|
1389
|
+
throw new CliUsageError(`role run admitted merger input path is missing: ${runId}`);
|
|
1390
|
+
}
|
|
1391
|
+
const derived = fields.derived;
|
|
1392
|
+
if (derived === undefined) {
|
|
1393
|
+
throw new CliUsageError(`role run admitted merger envelope is missing: ${runId}`);
|
|
1394
|
+
}
|
|
1395
|
+
if (fields.instruction.trim() === "") {
|
|
1396
|
+
throw new CliUsageError(`role run admitted merger task is blank: ${runId}`);
|
|
1397
|
+
}
|
|
1398
|
+
const admitted = {
|
|
1399
|
+
role: "merger",
|
|
1400
|
+
...base,
|
|
1401
|
+
instructionEmpty: false,
|
|
1402
|
+
mergerInputPath,
|
|
1403
|
+
derived,
|
|
1404
|
+
};
|
|
1405
|
+
return admitted;
|
|
1406
|
+
}
|
|
1407
|
+
case "collect-target": {
|
|
1408
|
+
const { prNumber, repository, repositoryDisplay, manifestDigest } = fields;
|
|
1409
|
+
if (repository === undefined ||
|
|
1410
|
+
repositoryDisplay === undefined ||
|
|
1411
|
+
manifestDigest === undefined) {
|
|
1412
|
+
throw new CliUsageError(`role run admitted collector repository identity is missing: ${runId}`);
|
|
1413
|
+
}
|
|
1414
|
+
let parsedRepository;
|
|
1415
|
+
try {
|
|
1416
|
+
parsedRepository = parseCollectorRepository(repositoryDisplay);
|
|
1417
|
+
}
|
|
1418
|
+
catch (error) {
|
|
1419
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1420
|
+
throw new CliUsageError(detail, { cause: error });
|
|
1421
|
+
}
|
|
1422
|
+
if (parsedRepository.canonical !== repository) {
|
|
1423
|
+
throw new CliUsageError(`role run admitted collector repository does not match its canonical form: ${runId}`);
|
|
1424
|
+
}
|
|
1425
|
+
const admitted = {
|
|
1426
|
+
role: "collector",
|
|
1427
|
+
...base,
|
|
1428
|
+
...(prNumber === undefined ? {} : { prNumber }),
|
|
1429
|
+
repository: parsedRepository,
|
|
1430
|
+
...(fields.requestManifestPath === undefined
|
|
1431
|
+
? {}
|
|
1432
|
+
: { requestManifestPath: fields.requestManifestPath }),
|
|
1433
|
+
...(fields.waitWindowMs === undefined ? {} : { waitWindowMs: fields.waitWindowMs }),
|
|
1434
|
+
manifestDigest,
|
|
1435
|
+
};
|
|
1436
|
+
return admitted;
|
|
1437
|
+
}
|
|
1438
|
+
case "case-identity": {
|
|
1439
|
+
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
1440
|
+
if (issueNumber === undefined ||
|
|
1441
|
+
caseRunsPath === undefined ||
|
|
1442
|
+
caseIdentity === undefined) {
|
|
1443
|
+
throw new CliUsageError(`role run admitted doctor case identity is missing: ${runId}`);
|
|
1444
|
+
}
|
|
1445
|
+
const admitted = {
|
|
1446
|
+
role: "doctor",
|
|
1447
|
+
...base,
|
|
1448
|
+
issueNumber,
|
|
1449
|
+
caseRunsPath,
|
|
1450
|
+
caseIdentity,
|
|
1451
|
+
};
|
|
1452
|
+
return admitted;
|
|
1453
|
+
}
|
|
1454
|
+
case "source-locator": {
|
|
1455
|
+
const { sourceRunPath, sourceRun } = fields;
|
|
1456
|
+
if (sourceRunPath === undefined || sourceRun === undefined) {
|
|
1457
|
+
throw new CliUsageError(`role run admitted notary source-run locator is missing: ${runId}`);
|
|
1458
|
+
}
|
|
1459
|
+
const admitted = {
|
|
1460
|
+
role: "notary",
|
|
1461
|
+
...base,
|
|
1462
|
+
sourceRunPath,
|
|
1463
|
+
sourceRun,
|
|
1464
|
+
};
|
|
1465
|
+
return admitted;
|
|
1466
|
+
}
|
|
1566
1467
|
}
|
|
1567
|
-
const admitted = {
|
|
1568
|
-
role: "notary",
|
|
1569
|
-
...resumedBaseAdmitted(loaded),
|
|
1570
|
-
sourceRunPath,
|
|
1571
|
-
sourceRun,
|
|
1572
|
-
};
|
|
1573
|
-
return seatLoadedResult(loaded, admitted);
|
|
1574
1468
|
}
|
|
1575
|
-
/**
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1469
|
+
/** Worker phase on resume: value must belong to the registry phase set. */
|
|
1470
|
+
function resumedWorkerPhase(phase, phases, role, runId) {
|
|
1471
|
+
if (phase === "plan" || phase === "apply") {
|
|
1472
|
+
if (phases.some((item) => item === phase)) {
|
|
1473
|
+
return phase;
|
|
1474
|
+
}
|
|
1580
1475
|
}
|
|
1581
|
-
|
|
1582
|
-
role: "inspector",
|
|
1583
|
-
...resumedBaseAdmitted(loaded),
|
|
1584
|
-
...(loaded.admittedFields.sourceRunPath === undefined
|
|
1585
|
-
? {}
|
|
1586
|
-
: { sourceRunPath: loaded.admittedFields.sourceRunPath }),
|
|
1587
|
-
};
|
|
1588
|
-
return seatLoadedResult(loaded, admitted);
|
|
1589
|
-
}
|
|
1590
|
-
export async function peekRoleRunRole(home, runId) {
|
|
1591
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
1592
|
-
if (runDirectory === undefined)
|
|
1593
|
-
return undefined;
|
|
1594
|
-
const run = await readRoleRunIdentity(runDirectory);
|
|
1595
|
-
return run?.role;
|
|
1476
|
+
throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
|
|
1596
1477
|
}
|