@akagilnc/pi-workflow-roles 0.1.4802 → 0.1.4874
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
|
@@ -7,6 +7,11 @@ import {
|
|
|
7
7
|
pickEngineAxis
|
|
8
8
|
} from "../package-resources/engine-material.js";
|
|
9
9
|
import { resolveConfiguredProvinceOfficer } from "../institutional-resolution.js";
|
|
10
|
+
import {
|
|
11
|
+
PUBLIC_ROLE_RECORDS,
|
|
12
|
+
packagedModelParent,
|
|
13
|
+
packagedProvinceConfig
|
|
14
|
+
} from "../packaged-role-registry.js";
|
|
10
15
|
import {
|
|
11
16
|
PUBLIC_CALLABLE_ROLES,
|
|
12
17
|
PUBLIC_CONFIGURABLE_SEATS,
|
|
@@ -14,13 +19,11 @@ import {
|
|
|
14
19
|
isPublicConfigurableSeat,
|
|
15
20
|
seatModelOnly
|
|
16
21
|
} from "./registry.js";
|
|
17
|
-
const GATE_OFFICER_SEATS =
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"notary"
|
|
21
|
-
];
|
|
22
|
+
const GATE_OFFICER_SEATS = PUBLIC_ROLE_RECORDS.flatMap(
|
|
23
|
+
(record) => "provinceConfig" in record && record.provinceConfig === true ? [record.role] : []
|
|
24
|
+
);
|
|
22
25
|
function isGateOfficerSeat(value) {
|
|
23
|
-
return
|
|
26
|
+
return packagedProvinceConfig(value);
|
|
24
27
|
}
|
|
25
28
|
function publicCliConfigPath(home) {
|
|
26
29
|
if (typeof home !== "string" || home.trim() === "") {
|
|
@@ -71,7 +74,7 @@ function setPersistentSeatConfig(config, seat, selection) {
|
|
|
71
74
|
function clearPersistentSeatConfig(config, seat) {
|
|
72
75
|
const previous = config.seats[seat];
|
|
73
76
|
if (previous === void 0) return config;
|
|
74
|
-
if ((seat
|
|
77
|
+
if (packagedModelParent(seat) !== void 0 && (previous.engine !== void 0 || previous.host !== void 0)) {
|
|
75
78
|
return {
|
|
76
79
|
...config,
|
|
77
80
|
seats: {
|
|
@@ -315,7 +318,7 @@ function parseSeatModelConfig(value, seat) {
|
|
|
315
318
|
throw new Error(`config seat ${seat} engineModel must be a string`);
|
|
316
319
|
}
|
|
317
320
|
if (!hasProvider) {
|
|
318
|
-
if ((seat
|
|
321
|
+
if (packagedModelParent(seat) !== void 0 && (typeof raw.engine === "string" || typeof raw.host === "string")) {
|
|
319
322
|
if (raw.thinking !== void 0) {
|
|
320
323
|
throw new Error(`config seat ${seat} thinking requires provider/model`);
|
|
321
324
|
}
|
|
@@ -412,7 +415,7 @@ function attachEngineAxis(seat, config, invocation) {
|
|
|
412
415
|
};
|
|
413
416
|
}
|
|
414
417
|
function resolveBaseSeat(config, seat) {
|
|
415
|
-
if (seat
|
|
418
|
+
if (packagedModelParent(seat) !== void 0) {
|
|
416
419
|
const resolved = resolveConfiguredProvinceOfficer(config, seat);
|
|
417
420
|
return {
|
|
418
421
|
seat,
|
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public Countersign Role run: admit ticket materials → court-pipeline prior
|
|
3
|
-
* station (起居郎) → shared post-admission coordinator → settle Terminal result
|
|
4
|
-
* (#572 / ADR 0074 / ADR 0075 / #742 / #771). #599: manual resume continues the
|
|
5
|
-
* exact session via explicit package runId. #987 Result 7: public entry no longer
|
|
6
|
-
* selects a prior run by ticket number; gate same-parent re-summons keep
|
|
7
|
-
* parentRunPath resume (#747 / ADR 0079 gate face). Explicit `ak-role new` mints
|
|
8
|
-
* fresh; explicit `ak-role resume <runId>` continues a named run.
|
|
9
|
-
*
|
|
10
|
-
* Court admission auto-runs 起居郎 so the 起居郎 LLM asserts the court target;
|
|
11
|
-
* mechanical layer only verifies; countersign reuses that typed identity for bind
|
|
12
|
-
* (ADR 0075 / 0081). Code never matches instruction text against book-known
|
|
13
|
-
* numbers. Who may call 起居郎 and in what order is not written into law
|
|
14
|
-
* (ADR 0075 不规定谁调用起居郎、顺序归调用者); the present admission effect is what this
|
|
15
|
-
* seat currently does. 起居录 path delivery is owned once by post-admission
|
|
16
|
-
* (#709 / ADR 0081). Court refresh may run on resume; it is not a resume
|
|
17
|
-
* precondition and does not rewrite or reject host resume (#987).
|
|
18
|
-
*
|
|
19
|
-
* Wiring (#771 / #863 / #987): gate parentRunPath resume (when present) runs
|
|
20
|
-
* before identity mint; public path without parentRunPath always materializes a
|
|
21
|
-
* new run after identity. 起居郎 escalate (认不出) and typed failure terminals
|
|
22
|
-
* (incl. verification failure) settle as countersign controlled failure — never
|
|
23
|
-
* wash into 真无票. Only a true missing lawful typed terminal stays unbound and
|
|
24
|
-
* continues the body (r5 unbound-continue). Bound refresh hands the typed key to
|
|
25
|
-
* 起居郎 so freeze loads issue face (ADR 0075: 每次过庭都跑是调用者用法 / typed handoff).
|
|
26
|
-
*/
|
|
27
|
-
import { resolve } from "node:path";
|
|
28
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis, } from "../package-resources/engine-material.js";
|
|
29
|
-
import { CliUsageError } from "./cli-errors.js";
|
|
30
1
|
import { projectCourtTicketNumbers } from "../diarist-contracts.js";
|
|
31
2
|
import { readableGateItem } from "../readable-gate-item.js";
|
|
32
3
|
import { isSafePositiveTicketNumber } from "../run-ticket-number.js";
|
|
33
|
-
import {
|
|
34
|
-
import { prepareSummonsResumeMaterials, presentControlledFailure, runPostAdmissionOneShot, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, StationChildExhaustedError, } from "./post-admission.js";
|
|
35
|
-
import { loadResumableCountersignRun, markRunAdmitted, } from "./run-lifecycle.js";
|
|
36
|
-
import { tryResumeSameTicketSeatRun } from "./seat-ticket-binding.js";
|
|
37
|
-
import { presentStructuralRejection, trySettleCountersignTerminalResult, } from "./settlement.js";
|
|
38
|
-
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
39
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
40
|
-
export function buildCountersignTurnRequest(admitted, options) {
|
|
41
|
-
return projectRoleTurnRequest(admitted, {
|
|
42
|
-
activation: {
|
|
43
|
-
role: "countersign",
|
|
44
|
-
// Admitted typed binding rides the turn activation seam to the Notary gate.
|
|
45
|
-
...(admitted.ticketNumber === undefined
|
|
46
|
-
? {}
|
|
47
|
-
: { ticketNumber: admitted.ticketNumber }),
|
|
48
|
-
},
|
|
49
|
-
}, options);
|
|
50
|
-
}
|
|
4
|
+
import { StationChildExhaustedError, } from "./post-admission.js";
|
|
51
5
|
function isRecord(value) {
|
|
52
6
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
7
|
}
|
|
@@ -245,8 +199,8 @@ export async function invokeCourtDiarist(input, env, io) {
|
|
|
245
199
|
*
|
|
246
200
|
* Missing ticketNumber (true-unbound / identity deferred) skips the refresh
|
|
247
201
|
* station — no diary is minted for a true-unbound run. First-entry identity
|
|
248
|
-
* lives on
|
|
249
|
-
*
|
|
202
|
+
* lives on the shared countersign entry (typed 起居郎 key for bind). Bound refresh:
|
|
203
|
+
* 起居郎 failure propagates (失败诚实).
|
|
250
204
|
* Path delivery onto materials is not this station's job — post-admission owns it.
|
|
251
205
|
*/
|
|
252
206
|
export async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
@@ -255,7 +209,7 @@ export async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
255
209
|
return;
|
|
256
210
|
}
|
|
257
211
|
// Production court refresh (ADR 0075: 每次过庭都跑是调用者用法) only under a known ticket identity.
|
|
258
|
-
// First-entry unbound identity is owned by
|
|
212
|
+
// First-entry unbound identity is owned by the shared countersign entry.
|
|
259
213
|
if (admitted.ticketNumber === undefined)
|
|
260
214
|
return;
|
|
261
215
|
// #871: refresh every member of the typed co-review set; single-ticket face
|
|
@@ -289,264 +243,3 @@ export async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
289
243
|
}
|
|
290
244
|
}
|
|
291
245
|
}
|
|
292
|
-
export async function runPublicCountersign(argv, env, io, parseCountersignArgv) {
|
|
293
|
-
let parsed;
|
|
294
|
-
try {
|
|
295
|
-
parsed = parseCountersignArgv(argv);
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
if (error instanceof CliUsageError) {
|
|
299
|
-
presentStructuralRejection(error, io);
|
|
300
|
-
return { exitCode: 2 };
|
|
301
|
-
}
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
304
|
-
let admitted;
|
|
305
|
-
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== ""
|
|
306
|
-
? env.parentRunPath
|
|
307
|
-
: undefined;
|
|
308
|
-
if (gateParentRunPath !== undefined) {
|
|
309
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction;
|
|
310
|
-
const resumed = await tryResumeSameTicketSeatRun({
|
|
311
|
-
home: env.home,
|
|
312
|
-
projectRoot: resolve(parsed.project ?? env.cwd),
|
|
313
|
-
role: "countersign",
|
|
314
|
-
parentRunPath: gateParentRunPath,
|
|
315
|
-
freshSummons: env.freshSummons,
|
|
316
|
-
summons: {
|
|
317
|
-
sourceRunPath: gateParentRunPath,
|
|
318
|
-
instruction: resumeInstruction,
|
|
319
|
-
instructionEmpty: resumeInstruction.trim() === "",
|
|
320
|
-
},
|
|
321
|
-
resume: (runId, materials) => runPublicCountersignResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
|
|
322
|
-
});
|
|
323
|
-
if (resumed !== undefined)
|
|
324
|
-
return resumed;
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
admitted = await admitCountersignInvocation({
|
|
328
|
-
home: env.home,
|
|
329
|
-
principalAuthority: env.principalAuthority,
|
|
330
|
-
cwd: env.cwd,
|
|
331
|
-
instruction: parsed.instruction,
|
|
332
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
333
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
334
|
-
...(env.createRunId === undefined
|
|
335
|
-
? {}
|
|
336
|
-
: { createRunId: env.createRunId }),
|
|
337
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
338
|
-
...(env.correlationId === undefined
|
|
339
|
-
? {}
|
|
340
|
-
: { correlationId: env.correlationId }),
|
|
341
|
-
deferPersistence: true,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
catch (error) {
|
|
345
|
-
if (error instanceof CliUsageError) {
|
|
346
|
-
presentStructuralRejection(error, io);
|
|
347
|
-
return { exitCode: 2 };
|
|
348
|
-
}
|
|
349
|
-
throw error;
|
|
350
|
-
}
|
|
351
|
-
// One owner spans prepare, lookup/load/resume or new-run materialization.
|
|
352
|
-
// It preserves both causes when its final cleanup also fails.
|
|
353
|
-
try {
|
|
354
|
-
return await withPreparedAttachments(parsed.attachmentPaths, async (preparedAttachments) => {
|
|
355
|
-
const materializeAdmission = async () => {
|
|
356
|
-
await materializeCountersignInvocation(admitted, {
|
|
357
|
-
home: env.home,
|
|
358
|
-
principalAuthority: env.principalAuthority,
|
|
359
|
-
preparedAttachments,
|
|
360
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
// #747 / #987: gate same-parent resume before identity mint. Public entry
|
|
364
|
-
// without parentRunPath never selects a prior run by ticket number.
|
|
365
|
-
// #637 / #771: ticket identity is the 起居郎 LLM typed assertion (never
|
|
366
|
-
// mechanical matching of summons text). Resolve that typed key before
|
|
367
|
-
// materializing a first-mint run. Controlled failures materialize below so
|
|
368
|
-
// they still have a durable page. The test seam `runCourtDiaristStation`
|
|
369
|
-
// defers identity to beforeDispatch; generic hook failures stay on the
|
|
370
|
-
// parent call-local budget, exhausted nested station children still skip
|
|
371
|
-
// parent auto-resume (#840 父子不层叠).
|
|
372
|
-
let typedTicket;
|
|
373
|
-
let typedCourtTicketNumbers;
|
|
374
|
-
let identityDiaristRan = false;
|
|
375
|
-
if (env.runCourtDiaristStation === undefined) {
|
|
376
|
-
let outcome;
|
|
377
|
-
try {
|
|
378
|
-
outcome = await invokeCourtDiarist({
|
|
379
|
-
instruction: parsed.instruction,
|
|
380
|
-
projectRoot: admitted.projectRoot,
|
|
381
|
-
failureLabel: "unbound summons",
|
|
382
|
-
// #969: parent durable ticket is the bind key (not a resume lookup).
|
|
383
|
-
...(env.boundTicketNumber === undefined
|
|
384
|
-
? {}
|
|
385
|
-
: { boundTicketNumber: env.boundTicketNumber }),
|
|
386
|
-
}, env, io);
|
|
387
|
-
}
|
|
388
|
-
catch (error) {
|
|
389
|
-
await materializeAdmission();
|
|
390
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
391
|
-
return await presentControlledFailure(admitted, { timedOut: false, code: null, stderr: "", thrown: error }, countersignAdapters(), env.principalAuthority, io);
|
|
392
|
-
}
|
|
393
|
-
identityDiaristRan = true;
|
|
394
|
-
if (outcome.identity.kind === "escalate") {
|
|
395
|
-
// 御批: 识别不了就上抛 — materialize and settle this countersign run.
|
|
396
|
-
// Diagnostic relays diarist escalate payload facts (#953).
|
|
397
|
-
await materializeAdmission();
|
|
398
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
399
|
-
return await presentControlledFailure(admitted, {
|
|
400
|
-
timedOut: false,
|
|
401
|
-
code: null,
|
|
402
|
-
stderr: "",
|
|
403
|
-
thrown: new Error(outcome.identity.diagnostic),
|
|
404
|
-
}, countersignAdapters(), env.principalAuthority, io);
|
|
405
|
-
}
|
|
406
|
-
// Typed failure terminal (verification / infra / non-zero without escalate)
|
|
407
|
-
// is not 真无票 — settle controlled failure on the admitted run (失败诚实).
|
|
408
|
-
// Only a true missing lawful typed terminal keeps the r5 unbound-continue.
|
|
409
|
-
if (outcome.failedWithoutEscalate !== undefined) {
|
|
410
|
-
await materializeAdmission();
|
|
411
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
412
|
-
return await presentControlledFailure(admitted, {
|
|
413
|
-
timedOut: false,
|
|
414
|
-
code: null,
|
|
415
|
-
stderr: "",
|
|
416
|
-
thrown: new Error(outcome.failedWithoutEscalate.diagnostic),
|
|
417
|
-
}, countersignAdapters(), env.principalAuthority, io);
|
|
418
|
-
}
|
|
419
|
-
// Missing lawful 起居郎 terminal is not countersign body failure: leave
|
|
420
|
-
// unbound and continue (true-unbound face) — unless parent gate handoff
|
|
421
|
-
// already carries the durable board ticket (#969). Escalate / typed
|
|
422
|
-
// failure above; bound refresh still fails honest via station.
|
|
423
|
-
if (outcome.identity.kind === "ticket") {
|
|
424
|
-
// #969: parent durable handoff wins over 起居郎 re-assert when both
|
|
425
|
-
// present (receipt/assert mismatch → parent bind key).
|
|
426
|
-
typedTicket = isSafePositiveTicketNumber(env.boundTicketNumber)
|
|
427
|
-
? env.boundTicketNumber
|
|
428
|
-
: outcome.identity.ticketNumber;
|
|
429
|
-
// #871: identity may hand a co-review set; absent field defaults to [main].
|
|
430
|
-
typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
|
|
431
|
-
}
|
|
432
|
-
else if (isSafePositiveTicketNumber(env.boundTicketNumber)) {
|
|
433
|
-
// Parent board handoff present; 起居郎 returned true-unbound — still
|
|
434
|
-
// bind under the parent key (omitted receipt ticketNumber path).
|
|
435
|
-
typedTicket = env.boundTicketNumber;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
// No prior same-parent run was selected. Materialize this invocation now;
|
|
439
|
-
// true-unbound, first-ticket and deferred test-seam paths all retain their
|
|
440
|
-
// own durable page. Public re-summons without parentRunPath always mint.
|
|
441
|
-
await materializeAdmission();
|
|
442
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
443
|
-
if (gateParentRunPath !== undefined) {
|
|
444
|
-
await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
|
|
445
|
-
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
446
|
-
}
|
|
447
|
-
if (identityDiaristRan && typedTicket !== undefined) {
|
|
448
|
-
try {
|
|
449
|
-
await bindAdmittedTicketNumber(admitted, typedTicket);
|
|
450
|
-
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
451
|
-
// First court: explicit set wins; omitted field → single-ticket face [main].
|
|
452
|
-
// Set persistence is outside beforeDispatch — route write failures into the
|
|
453
|
-
// same controlled-failure settlement as station children (#871 B7).
|
|
454
|
-
await bindCourtTicketNumbersOnAdmitted(admitted, typedCourtTicketNumbers ?? [typedTicket]);
|
|
455
|
-
}
|
|
456
|
-
catch (error) {
|
|
457
|
-
return await presentControlledFailure(admitted, {
|
|
458
|
-
timedOut: false,
|
|
459
|
-
code: null,
|
|
460
|
-
stderr: "",
|
|
461
|
-
thrown: error,
|
|
462
|
-
}, countersignAdapters(), env.principalAuthority, io);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
const turnProjection = {
|
|
466
|
-
packageRoot: env.packageRoot,
|
|
467
|
-
home: env.home,
|
|
468
|
-
agentDir: env.agentDir,
|
|
469
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
470
|
-
...pickEngineAxis(env),
|
|
471
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
472
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
473
|
-
? {}
|
|
474
|
-
: { correlationId: env.correlationId }),
|
|
475
|
-
continuation: {
|
|
476
|
-
kind: "initial",
|
|
477
|
-
// #969/#879: gate path first mint carries parent payload as dialogue content;
|
|
478
|
-
// ordinary public entry keeps package transport prompt.
|
|
479
|
-
prompt: (env.reviewReask ?? env.gateReviewInstruction)
|
|
480
|
-
?? buildCountersignTransportPrompt(admitted, engineSessionMaterialFromOptions({
|
|
481
|
-
...pickEngineAxis(env),
|
|
482
|
-
packageRoot: env.packageRoot,
|
|
483
|
-
})),
|
|
484
|
-
},
|
|
485
|
-
};
|
|
486
|
-
// Mutable shell: ticket bind re-projects activation before executeTurn.
|
|
487
|
-
const turnRequest = buildCountersignTurnRequest(admitted, turnProjection);
|
|
488
|
-
const result = await runPostAdmissionOneShot({
|
|
489
|
-
admitted,
|
|
490
|
-
env,
|
|
491
|
-
io,
|
|
492
|
-
request: turnRequest,
|
|
493
|
-
adapters: countersignAdapters({
|
|
494
|
-
beforeDispatch: async (admittedSeat, lease) => {
|
|
495
|
-
// Dossier pointer delivery rides post-admission after this hook (#709).
|
|
496
|
-
if (!identityDiaristRan) {
|
|
497
|
-
// Test seam (or any deferred identity): station owns assert + bind.
|
|
498
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
499
|
-
}
|
|
500
|
-
else if (typedTicket !== undefined) {
|
|
501
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
502
|
-
}
|
|
503
|
-
await relocateAdmittedRunToTicket(admittedSeat, env.principalAuthority, lease);
|
|
504
|
-
Object.assign(turnRequest, buildCountersignTurnRequest(admittedSeat, turnProjection));
|
|
505
|
-
},
|
|
506
|
-
}),
|
|
507
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
508
|
-
});
|
|
509
|
-
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
510
|
-
return result;
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
catch (error) {
|
|
514
|
-
if (error instanceof CliUsageError) {
|
|
515
|
-
presentStructuralRejection(error, io);
|
|
516
|
-
return { exitCode: 2 };
|
|
517
|
-
}
|
|
518
|
-
throw error;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
function countersignAdapters(options) {
|
|
522
|
-
return {
|
|
523
|
-
trySettle: (admitted, authority, scope) => trySettleCountersignTerminalResult(admitted, authority, scope),
|
|
524
|
-
// Accepted receipts and failure terminals both present via shared path.
|
|
525
|
-
shouldPresentSettled: () => true,
|
|
526
|
-
...(options?.beforeDispatch === undefined
|
|
527
|
-
? {}
|
|
528
|
-
: { beforeDispatch: options.beforeDispatch }),
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Resume a previously admitted Countersign run (#599 / DK-3 / #637 / #987).
|
|
533
|
-
* Restores role/ticket/session identity. Gate
|
|
534
|
-
* same-parent and explicit `ak-role resume <runId>` share this entry; summons
|
|
535
|
-
* may carry this turn's instruction. Manual resume forwards only the caller's
|
|
536
|
-
* message bytes. 起居录 path delivery remains
|
|
537
|
-
* post-admission's single mount (#709).
|
|
538
|
-
*/
|
|
539
|
-
export async function runPublicCountersignResume(request, env, io) {
|
|
540
|
-
return await runPostAdmissionSeatResume({
|
|
541
|
-
request,
|
|
542
|
-
env,
|
|
543
|
-
io,
|
|
544
|
-
load: (effective) => loadResumableCountersignRun(env.home, effective.runId, env.principalAuthority),
|
|
545
|
-
buildTurnRequest: async (admitted, effective) => {
|
|
546
|
-
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
547
|
-
return buildCountersignTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared));
|
|
548
|
-
},
|
|
549
|
-
adapters: countersignAdapters(),
|
|
550
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
551
|
-
});
|
|
552
|
-
}
|