@akagilnc/pi-workflow-roles 0.1.5714 → 0.1.5753
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 +517 -516
- package/dist/analyst-gate-cycles-read.js +7 -6
- package/dist/archivist-record-pointer.js +9 -45
- package/dist/auditor-soul.js +7 -5
- package/dist/external-host-turn-loop.js +2 -16
- package/dist/gatekeeper-role.js +14 -1
- package/dist/headless-host/production-host.js +517 -516
- package/dist/judge-role.js +1 -1
- package/dist/migrate-book-topology.js +61 -51
- package/dist/navigator-public-session.js +17 -8
- package/dist/notary-contracts.js +2 -2
- package/dist/notary-source-run.js +2 -2
- package/dist/packaged-role-registry.js +0 -10
- package/dist/public-cli/cli.js +13 -6
- package/dist/public-cli/instruction-seat-run.js +157 -138
- package/dist/public-cli/invocation.js +35 -0
- package/dist/public-cli/main.js +497 -505
- package/dist/public-cli/post-admission.js +11 -12
- package/dist/public-cli/run-lifecycle.js +56 -34
- package/dist/public-cli/seat-ticket-binding.js +8 -7
- package/dist/public-cli/settlement.js +4 -126
- package/dist/public-cli/terminal.js +3 -3
- package/dist/public-role-summons.js +14 -6
- package/dist/review-submission.js +47 -14
- package/dist/role-run-relocation.js +4 -3
- package/dist/role-submission-declarations.js +5 -5
- package/dist/run-dossier.js +6 -21
- package/dist/run-terminal-artifacts.js +11 -0
- package/dist/secretariat-contracts.js +0 -4
- package/dist/submission-gate.js +58 -42
- package/dist/submission-ledger.js +3 -2
- package/package.json +1 -1
- package/souls/notary.md +6 -5
- package/src/analyst-gate-cycles-read.ts +7 -6
- package/src/analyst-ledger.ts +2 -2
- package/src/archivist-record-pointer.ts +10 -64
- package/src/auditor-soul.ts +7 -5
- package/src/countersign-role.ts +5 -5
- package/src/external-host-turn-loop.ts +2 -23
- package/src/gatekeeper-role.ts +24 -3
- package/src/judge-role.ts +1 -1
- package/src/navigator-public-session.ts +22 -10
- package/src/notary-contracts.ts +3 -2
- package/src/notary-source-run.ts +2 -7
- package/src/packaged-role-registry.ts +0 -13
- package/src/public-cli/cli.ts +18 -4
- package/src/public-cli/instruction-seat-run.ts +213 -155
- package/src/public-cli/invocation.ts +39 -0
- package/src/public-cli/post-admission.ts +11 -9
- package/src/public-cli/run-lifecycle.ts +80 -33
- package/src/public-cli/seat-ticket-binding.ts +9 -7
- package/src/public-cli/settlement.ts +3 -167
- package/src/public-cli/terminal.ts +3 -3
- package/src/public-role-summons.ts +40 -12
- package/src/review-submission.ts +72 -21
- package/src/role-run-relocation.ts +4 -3
- package/src/role-runtime.ts +3 -3
- package/src/role-submission-declarations.ts +5 -5
- package/src/run-dossier.ts +7 -19
- package/src/run-terminal-artifacts.ts +13 -0
- package/src/secretariat-contracts.ts +0 -19
- package/src/submission-gate.ts +75 -62
- package/src/submission-ledger.ts +3 -6
package/dist/public-cli/main.js
CHANGED
|
@@ -1296,13 +1296,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
1296
1296
|
latest = { toolCallId: payload.toolCallId, role: payload.role, accepted: payload.accepted, at: row.timestamp };
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
-
let officers = {};
|
|
1300
|
-
try {
|
|
1301
|
-
officers = latestOfficerPointersFromRecords(history);
|
|
1302
|
-
} catch (error) {
|
|
1303
|
-
if (!(error instanceof TypeError)) throw error;
|
|
1304
|
-
if (unreadable[RUN_HISTORY_FILE] === void 0) unreadable[RUN_HISTORY_FILE] = "malformed";
|
|
1305
|
-
}
|
|
1306
1299
|
const sessions = {};
|
|
1307
1300
|
for (const row of state) {
|
|
1308
1301
|
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
@@ -1320,7 +1313,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
1320
1313
|
if (typeof original === "string") original = join3(runDirectory, "session", basename4(original));
|
|
1321
1314
|
whole.host = { sessions, ...original === void 0 ? {} : { original } };
|
|
1322
1315
|
whole.submission = latest === void 0 ? {} : { latest };
|
|
1323
|
-
whole.officers = officers;
|
|
1324
1316
|
if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
|
|
1325
1317
|
return whole;
|
|
1326
1318
|
}
|
|
@@ -9200,7 +9192,7 @@ var init_navigator_output = __esm({
|
|
|
9200
9192
|
});
|
|
9201
9193
|
|
|
9202
9194
|
// src/review-submission.ts
|
|
9203
|
-
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewSubmissionSchema;
|
|
9195
|
+
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewStatusField, reviewNarrativeFields, reviewSubmissionSchema, courtClauseItemSchema, courtClausesField, courtReviewSubmissionSchema;
|
|
9204
9196
|
var init_review_submission = __esm({
|
|
9205
9197
|
"src/review-submission.ts"() {
|
|
9206
9198
|
"use strict";
|
|
@@ -9209,28 +9201,62 @@ var init_review_submission = __esm({
|
|
|
9209
9201
|
REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
|
|
9210
9202
|
REVIEW_QUEUE_WORDS = ["converged", "continue", "escalate"];
|
|
9211
9203
|
REVIEW_QUEUE_STATUSES = new Set(REVIEW_QUEUE_WORDS);
|
|
9204
|
+
reviewStatusField = typebox_exports.Union(
|
|
9205
|
+
[
|
|
9206
|
+
typebox_exports.Literal(REVIEW_QUEUE_WORDS[0]),
|
|
9207
|
+
typebox_exports.Literal(REVIEW_QUEUE_WORDS[1]),
|
|
9208
|
+
typebox_exports.Literal(REVIEW_QUEUE_WORDS[2])
|
|
9209
|
+
],
|
|
9210
|
+
{
|
|
9211
|
+
description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
|
|
9212
|
+
}
|
|
9213
|
+
);
|
|
9214
|
+
reviewNarrativeFields = {
|
|
9215
|
+
findings: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
9216
|
+
reason: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
|
|
9217
|
+
violations: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
|
|
9218
|
+
conflicts: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
|
|
9219
|
+
fix: typebox_exports.Optional(typebox_exports.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
|
|
9220
|
+
classes: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
9221
|
+
note: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
|
|
9222
|
+
evidence: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
9223
|
+
decisionGate: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
|
|
9224
|
+
};
|
|
9212
9225
|
reviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
9213
|
-
typebox_exports.Object(
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9226
|
+
typebox_exports.Object(
|
|
9227
|
+
{
|
|
9228
|
+
status: reviewStatusField,
|
|
9229
|
+
...reviewNarrativeFields
|
|
9230
|
+
},
|
|
9231
|
+
{ additionalProperties: true }
|
|
9232
|
+
)
|
|
9233
|
+
);
|
|
9234
|
+
courtClauseItemSchema = typebox_exports.Object(
|
|
9235
|
+
{
|
|
9236
|
+
clause: typebox_exports.String({
|
|
9237
|
+
description: "\u7968\u9762\u6761\u6B3E\u539F\u6587\uFF08\u6539\u53D8\u5B9E\u9645\u884C\u4E3A\u7684\u6761\u6B3E\uFF1B\u4E0D\u5408\u5E76\u3001\u4E0D\u6539\u5199\uFF09"
|
|
9238
|
+
}),
|
|
9239
|
+
ownerUuid: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()], {
|
|
9240
|
+
description: "\u63A8\u51FA\u8BE5\u6761\u7684\u965B\u4E0B\u539F\u8BDD uuid\uFF1B\u65E0\u539F\u8BDD\u5219 null"
|
|
9241
|
+
}),
|
|
9242
|
+
derivation: typebox_exports.String({
|
|
9243
|
+
description: "\u4E00\u53E5\u63A8\u5BFC\uFF1A\u4ECE\u539F\u8BDD\u54EA\u4E2A\u610F\u601D\u5230\u8BE5\u6761\u6B3E\u3002\u7528\u4F5C\u4E0A\u4E0B\u6587\u7684 runner \u53E5\u5148\u5199\u81F3\u5C11\u4E24\u79CD\u8BFB\u6CD5\uFF0C\u518D\u5199\u7968\u9762\u53D6\u54EA\u79CD\uFF1B\u5199\u4E0D\u51FA\u7B2C\u4E8C\u79CD\u624D\u8BB0\u65E0\u6B67\u4E49"
|
|
9244
|
+
})
|
|
9245
|
+
},
|
|
9246
|
+
{ additionalProperties: true }
|
|
9247
|
+
);
|
|
9248
|
+
courtClausesField = typebox_exports.Array(courtClauseItemSchema, {
|
|
9249
|
+
description: "\u7968\u9762\u9010\u6761\u6838\u65E8\u8868\uFF1A\u6BCF\u6761\u6539\u53D8\u5B9E\u9645\u884C\u4E3A\u7684\u6761\u6B3E\u7684\u539F\u6587\u3001\u965B\u4E0B\u539F\u8BDD uuid\u3001\u63A8\u5BFC\u3002\u65E0\u539F\u8BDD\u5219 ownerUuid \u4E3A null\u3002"
|
|
9250
|
+
});
|
|
9251
|
+
courtReviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
9252
|
+
typebox_exports.Object(
|
|
9253
|
+
{
|
|
9254
|
+
status: reviewStatusField,
|
|
9255
|
+
...reviewNarrativeFields,
|
|
9256
|
+
clauses: courtClausesField
|
|
9257
|
+
},
|
|
9258
|
+
{ additionalProperties: true }
|
|
9259
|
+
)
|
|
9234
9260
|
);
|
|
9235
9261
|
}
|
|
9236
9262
|
});
|
|
@@ -9586,7 +9612,7 @@ var init_diarist_contracts = __esm({
|
|
|
9586
9612
|
});
|
|
9587
9613
|
|
|
9588
9614
|
// src/secretariat-contracts.ts
|
|
9589
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema
|
|
9615
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema;
|
|
9590
9616
|
var init_secretariat_contracts = __esm({
|
|
9591
9617
|
"src/secretariat-contracts.ts"() {
|
|
9592
9618
|
"use strict";
|
|
@@ -9612,8 +9638,6 @@ var init_secretariat_contracts = __esm({
|
|
|
9612
9638
|
)
|
|
9613
9639
|
);
|
|
9614
9640
|
secretariatVerdictSchema.required = [];
|
|
9615
|
-
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
9616
|
-
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
9617
9641
|
}
|
|
9618
9642
|
});
|
|
9619
9643
|
|
|
@@ -9646,7 +9670,6 @@ __export(packaged_role_registry_exports, {
|
|
|
9646
9670
|
packagedBaseIsRevision: () => packagedBaseIsRevision,
|
|
9647
9671
|
packagedBindsBoardTicket: () => packagedBindsBoardTicket,
|
|
9648
9672
|
packagedBoardPlacement: () => packagedBoardPlacement,
|
|
9649
|
-
packagedDurableOfficerEntry: () => packagedDurableOfficerEntry,
|
|
9650
9673
|
packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
|
|
9651
9674
|
packagedGateStageLabel: () => packagedGateStageLabel,
|
|
9652
9675
|
packagedGateSummon: () => packagedGateSummon,
|
|
@@ -9766,11 +9789,6 @@ function packagedAuditToolName(role) {
|
|
|
9766
9789
|
if (record === void 0 || !("auditTool" in record)) return void 0;
|
|
9767
9790
|
return record.auditTool;
|
|
9768
9791
|
}
|
|
9769
|
-
function packagedDurableOfficerEntry(officer) {
|
|
9770
|
-
return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
9771
|
-
(record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
|
|
9772
|
-
);
|
|
9773
|
-
}
|
|
9774
9792
|
function packagedPublicInstructionSubject(role) {
|
|
9775
9793
|
return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
9776
9794
|
(record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
|
|
@@ -10109,8 +10127,6 @@ var init_packaged_role_registry = __esm({
|
|
|
10109
10127
|
presentSettled: "always",
|
|
10110
10128
|
summonResume: false,
|
|
10111
10129
|
admission: "court-materials",
|
|
10112
|
-
/** Durable custom entry names this officer. */
|
|
10113
|
-
durableOfficerEntry: true,
|
|
10114
10130
|
sameParent: "none",
|
|
10115
10131
|
phases: [null],
|
|
10116
10132
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
@@ -10136,8 +10152,6 @@ var init_packaged_role_registry = __esm({
|
|
|
10136
10152
|
phases: [null],
|
|
10137
10153
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
10138
10154
|
settlement: "accepted",
|
|
10139
|
-
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
10140
|
-
projectCountersignTerminal: true,
|
|
10141
10155
|
activationFlags: [
|
|
10142
10156
|
{ field: "ticketNumber" }
|
|
10143
10157
|
],
|
|
@@ -11528,15 +11542,15 @@ var init_role_submission_declarations = __esm({
|
|
|
11528
11542
|
},
|
|
11529
11543
|
notary: {
|
|
11530
11544
|
label: "\u7B26\u5B9D\u90CE\u8F93\u51FA",
|
|
11531
|
-
description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\u3002",
|
|
11545
|
+
description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
|
|
11532
11546
|
promptSnippet: "\u63D0\u4EA4\u7B26\u5B9D\u90CE\u51B3\u8BAE",
|
|
11533
|
-
parameters:
|
|
11547
|
+
parameters: courtReviewSubmissionSchema
|
|
11534
11548
|
},
|
|
11535
11549
|
countersign: {
|
|
11536
11550
|
label: "\u7ED9\u4E8B\u4E2D\u8F93\u51FA",
|
|
11537
|
-
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\u3002",
|
|
11551
|
+
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
|
|
11538
11552
|
promptSnippet: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE",
|
|
11539
|
-
parameters:
|
|
11553
|
+
parameters: courtReviewSubmissionSchema
|
|
11540
11554
|
},
|
|
11541
11555
|
secretariat: {
|
|
11542
11556
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
@@ -11704,7 +11718,9 @@ var run_terminal_artifacts_exports = {};
|
|
|
11704
11718
|
__export(run_terminal_artifacts_exports, {
|
|
11705
11719
|
ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
|
|
11706
11720
|
TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
|
|
11721
|
+
isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
|
|
11707
11722
|
readRunTerminal: () => readRunTerminal,
|
|
11723
|
+
roleFromRunDirectory: () => roleFromRunDirectory,
|
|
11708
11724
|
runIdFromRunDirectory: () => runIdFromRunDirectory,
|
|
11709
11725
|
writeRunTerminal: () => writeRunTerminal
|
|
11710
11726
|
});
|
|
@@ -11760,6 +11776,12 @@ function withSubmittedPayloads(runDirectory, body) {
|
|
|
11760
11776
|
function runIdFromRunDirectory(runDirectory) {
|
|
11761
11777
|
return parseRunLeaf(basename6(runDirectory))?.runId;
|
|
11762
11778
|
}
|
|
11779
|
+
function roleFromRunDirectory(runDirectory) {
|
|
11780
|
+
return parseRunLeaf(basename6(runDirectory))?.role;
|
|
11781
|
+
}
|
|
11782
|
+
function isTicketCourtCountersignSource(runDirectory) {
|
|
11783
|
+
return roleFromRunDirectory(runDirectory) === "countersign";
|
|
11784
|
+
}
|
|
11763
11785
|
var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
|
|
11764
11786
|
var init_run_terminal_artifacts = __esm({
|
|
11765
11787
|
"src/run-terminal-artifacts.ts"() {
|
|
@@ -11870,6 +11892,18 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
11870
11892
|
);
|
|
11871
11893
|
}
|
|
11872
11894
|
if (outcome.kind === "accepted") {
|
|
11895
|
+
if (outcome.decisiveFacts?.directionUnsettled === true) {
|
|
11896
|
+
const receipt2 = thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome);
|
|
11897
|
+
return withOfficerRunId(
|
|
11898
|
+
{
|
|
11899
|
+
status: "needs_reask",
|
|
11900
|
+
officer,
|
|
11901
|
+
receipt: receipt2,
|
|
11902
|
+
receivedStatus: receivedDiscriminator(receipt2, "status")
|
|
11903
|
+
},
|
|
11904
|
+
summoned
|
|
11905
|
+
);
|
|
11906
|
+
}
|
|
11873
11907
|
return withOfficerRunId(
|
|
11874
11908
|
projectOfficerPayloads(officer, thisCourt, outcome.status),
|
|
11875
11909
|
summoned
|
|
@@ -13393,12 +13427,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
13393
13427
|
const subjectDirectory = dirname8(dirname8(candidate));
|
|
13394
13428
|
const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname8(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve7(dirname8(subjectDirectory)) === resolve7(bookDirectory);
|
|
13395
13429
|
if (isLegacyUnboundLocator) {
|
|
13396
|
-
candidate = await
|
|
13397
|
-
options.home,
|
|
13398
|
-
identity2.runId,
|
|
13399
|
-
bookKey,
|
|
13400
|
-
identity2.role
|
|
13401
|
-
) ?? candidate;
|
|
13430
|
+
candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
|
|
13402
13431
|
}
|
|
13403
13432
|
}
|
|
13404
13433
|
const real = await requireRunDirectory(candidate, raw);
|
|
@@ -14517,6 +14546,11 @@ import {
|
|
|
14517
14546
|
writeFile as writeFile2
|
|
14518
14547
|
} from "node:fs/promises";
|
|
14519
14548
|
import { dirname as dirname9, isAbsolute as isAbsolute5, join as join13, resolve as resolve8 } from "node:path";
|
|
14549
|
+
function admittedSourceRunPath(admitted) {
|
|
14550
|
+
if (!isRecord(admitted)) return void 0;
|
|
14551
|
+
const path = admitted.sourceRunPath;
|
|
14552
|
+
return typeof path === "string" && path.trim() !== "" ? path : void 0;
|
|
14553
|
+
}
|
|
14520
14554
|
function normalizeAdmittedAttachment(raw) {
|
|
14521
14555
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
14522
14556
|
const record = raw;
|
|
@@ -14628,6 +14662,23 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubj
|
|
|
14628
14662
|
};
|
|
14629
14663
|
});
|
|
14630
14664
|
}
|
|
14665
|
+
function persistAdmittedAuditedSubmissionToolCallId(runDirectory, auditedSubmissionToolCallId) {
|
|
14666
|
+
const id = auditedSubmissionToolCallId.trim();
|
|
14667
|
+
if (id === "") {
|
|
14668
|
+
throw new Error("persistAdmittedAuditedSubmissionToolCallId requires a non-empty id");
|
|
14669
|
+
}
|
|
14670
|
+
if (readPageSync(runDirectory, "admitted") === void 0) return;
|
|
14671
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
14672
|
+
if (current.auditedSubmissionToolCallId === id) return void 0;
|
|
14673
|
+
return { ...current, auditedSubmissionToolCallId: id };
|
|
14674
|
+
});
|
|
14675
|
+
}
|
|
14676
|
+
function readAdmittedAuditedSubmissionToolCallId(runDirectory) {
|
|
14677
|
+
const page = readPageSync(runDirectory, "admitted");
|
|
14678
|
+
if (page === void 0) return void 0;
|
|
14679
|
+
const id = page.auditedSubmissionToolCallId;
|
|
14680
|
+
return typeof id === "string" && id.trim() !== "" ? id : void 0;
|
|
14681
|
+
}
|
|
14631
14682
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
14632
14683
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
14633
14684
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
@@ -16028,13 +16079,10 @@ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
|
16028
16079
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
16029
16080
|
return mapOwnedToSubmissionRows(owned);
|
|
16030
16081
|
}
|
|
16031
|
-
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId,
|
|
16082
|
+
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScope) {
|
|
16032
16083
|
if (attemptId.length === 0) return [];
|
|
16033
|
-
const
|
|
16034
|
-
|
|
16035
|
-
runId,
|
|
16036
|
-
home === void 0 ? {} : { home }
|
|
16037
|
-
);
|
|
16084
|
+
const scope = resolveReadScope(homeOrScope);
|
|
16085
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
16038
16086
|
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
16039
16087
|
}
|
|
16040
16088
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
@@ -16408,7 +16456,6 @@ __export(settlement_exports, {
|
|
|
16408
16456
|
LifecycleReadFailure: () => LifecycleReadFailure,
|
|
16409
16457
|
NAVIGATOR_POST_ROLE_GRACE_MS: () => NAVIGATOR_POST_ROLE_GRACE_MS,
|
|
16410
16458
|
appendRunAttemptHistory: () => appendRunAttemptHistory,
|
|
16411
|
-
attachPostAuditCountersignFact: () => attachPostAuditCountersignFact,
|
|
16412
16459
|
attachRecordedSubmissions: () => attachRecordedSubmissions,
|
|
16413
16460
|
classifyPostAdmissionFailure: () => classifyPostAdmissionFailure,
|
|
16414
16461
|
conciseChildDiagnostic: () => conciseChildDiagnostic,
|
|
@@ -16522,13 +16569,12 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
16522
16569
|
return { outcome: { kind: "accepted", role, payloads }, ...belonging };
|
|
16523
16570
|
}
|
|
16524
16571
|
async function sealedLedgerOutcome(admitted, role, scope) {
|
|
16525
|
-
const home = sealedLedgerHome(admitted);
|
|
16526
16572
|
if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
|
|
16527
16573
|
const thisCourt = await readAttemptScopedSubmissionRows(
|
|
16528
16574
|
admitted.projectRoot,
|
|
16529
16575
|
admitted.runId,
|
|
16530
16576
|
scope.courtAttemptId,
|
|
16531
|
-
|
|
16577
|
+
ledgerReadScope(admitted, scope)
|
|
16532
16578
|
);
|
|
16533
16579
|
return roleOutcomeFromRows(role, thisCourt);
|
|
16534
16580
|
}
|
|
@@ -17255,97 +17301,11 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
17255
17301
|
if (toolName === void 0) {
|
|
17256
17302
|
throw new Error(`accepted-seat settlement is not declared for ${admitted.role}`);
|
|
17257
17303
|
}
|
|
17258
|
-
|
|
17259
|
-
const record = packagedRoleMetadata(admitted.role);
|
|
17260
|
-
if (settled === void 0 || record === void 0 || !("projectCountersignTerminal" in record) || record.projectCountersignTerminal !== true) {
|
|
17261
|
-
return settled;
|
|
17262
|
-
}
|
|
17263
|
-
return applySecretariatCountersignTerminal(admitted, authority, settled, scope);
|
|
17304
|
+
return settleSealedSeat(admitted, authority, scope, { acceptedOnly: false });
|
|
17264
17305
|
}
|
|
17265
17306
|
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
17266
17307
|
return settleSeat(admitted, authority, scope);
|
|
17267
17308
|
}
|
|
17268
|
-
function countersignTerminalFromEntries(entries) {
|
|
17269
|
-
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
17270
|
-
const entry = entries[index];
|
|
17271
|
-
if (entry?.type !== "custom") continue;
|
|
17272
|
-
if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
|
|
17273
|
-
const data = isRecord(entry.data) ? entry.data : void 0;
|
|
17274
|
-
if (data === void 0 || !packagedDurableOfficerEntry(data.officer)) continue;
|
|
17275
|
-
if (data.receipt === void 0) continue;
|
|
17276
|
-
const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
|
|
17277
|
-
return {
|
|
17278
|
-
receipt: data.receipt,
|
|
17279
|
-
...runId === void 0 ? {} : { runId }
|
|
17280
|
-
};
|
|
17281
|
-
}
|
|
17282
|
-
return void 0;
|
|
17283
|
-
}
|
|
17284
|
-
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
17285
|
-
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
17286
|
-
return {
|
|
17287
|
-
...roleOutcome,
|
|
17288
|
-
decisiveFacts: {
|
|
17289
|
-
...prior,
|
|
17290
|
-
[SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY]: officer
|
|
17291
|
-
}
|
|
17292
|
-
};
|
|
17293
|
-
}
|
|
17294
|
-
function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
17295
|
-
const payloads = roleOutcome.payloads ?? [];
|
|
17296
|
-
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
17297
|
-
const payload = payloads[index];
|
|
17298
|
-
if (!isRecord(payload)) continue;
|
|
17299
|
-
const status = payload.secretariatStatus;
|
|
17300
|
-
if (typeof status !== "string") continue;
|
|
17301
|
-
return status === "converged";
|
|
17302
|
-
}
|
|
17303
|
-
return false;
|
|
17304
|
-
}
|
|
17305
|
-
async function applySecretariatCountersignTerminal(admitted, authority, settled, scope) {
|
|
17306
|
-
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
17307
|
-
let entries = [];
|
|
17308
|
-
try {
|
|
17309
|
-
entries = await readBoundSessionEntries(coordinates.sessionFile);
|
|
17310
|
-
} catch (error) {
|
|
17311
|
-
if (!isEnoent(error)) {
|
|
17312
|
-
await noteSettlementFault(
|
|
17313
|
-
admitted.runDirectory,
|
|
17314
|
-
scope,
|
|
17315
|
-
`secretariat officer read failed beside lawful terminal: ${describeErrorIdentity(error)}`
|
|
17316
|
-
);
|
|
17317
|
-
}
|
|
17318
|
-
return settled;
|
|
17319
|
-
}
|
|
17320
|
-
const officer = countersignTerminalFromEntries(entries);
|
|
17321
|
-
if (officer === void 0) return settled;
|
|
17322
|
-
if (settled.roleOutcome.kind === "audit_escalation") {
|
|
17323
|
-
return {
|
|
17324
|
-
...settled,
|
|
17325
|
-
roleOutcome: withCountersignTerminalFact(
|
|
17326
|
-
{
|
|
17327
|
-
...settled.roleOutcome,
|
|
17328
|
-
payloads: [officer.receipt]
|
|
17329
|
-
},
|
|
17330
|
-
officer
|
|
17331
|
-
)
|
|
17332
|
-
};
|
|
17333
|
-
}
|
|
17334
|
-
if (settled.roleOutcome.kind === "accepted") {
|
|
17335
|
-
if (!acceptedSecretariatDefinesOfficerProjection(settled.roleOutcome)) {
|
|
17336
|
-
return settled;
|
|
17337
|
-
}
|
|
17338
|
-
return {
|
|
17339
|
-
...settled,
|
|
17340
|
-
roleOutcome: withCountersignTerminalFact(settled.roleOutcome, officer)
|
|
17341
|
-
};
|
|
17342
|
-
}
|
|
17343
|
-
return settled;
|
|
17344
|
-
}
|
|
17345
|
-
async function attachPostAuditCountersignFact(admitted, authority, terminal, scope) {
|
|
17346
|
-
if (admitted.role !== "secretariat") return terminal;
|
|
17347
|
-
return applySecretariatCountersignTerminal(admitted, authority, terminal, scope);
|
|
17348
|
-
}
|
|
17349
17309
|
async function publishFailureTerminal(admitted, failure, coordinates, onErrorPublished, scope) {
|
|
17350
17310
|
let historyFailure;
|
|
17351
17311
|
let historyFailed = false;
|
|
@@ -17511,7 +17471,6 @@ var init_settlement = __esm({
|
|
|
17511
17471
|
init_engine_detour_usage();
|
|
17512
17472
|
init_dossier_resolution();
|
|
17513
17473
|
init_invocation();
|
|
17514
|
-
init_secretariat_contracts();
|
|
17515
17474
|
init_navigator_invocation_identity();
|
|
17516
17475
|
init_packaged_role_registry();
|
|
17517
17476
|
init_receipt_delivery_policy();
|
|
@@ -17537,18 +17496,6 @@ var init_settlement = __esm({
|
|
|
17537
17496
|
// src/external-host-turn-loop.ts
|
|
17538
17497
|
import { existsSync as existsSync4 } from "node:fs";
|
|
17539
17498
|
import { basename as basename8 } from "node:path";
|
|
17540
|
-
async function resolveLiveRunDirectoryPath(recordedPath, home) {
|
|
17541
|
-
if (existsSync4(recordedPath)) return recordedPath;
|
|
17542
|
-
const parsed = parseRunLeaf(basename8(recordedPath));
|
|
17543
|
-
const bookKey = tryBookKeyFromAkRolesPath(recordedPath);
|
|
17544
|
-
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
17545
|
-
return await findRunDirectoryById(
|
|
17546
|
-
home,
|
|
17547
|
-
parsed.runId,
|
|
17548
|
-
bookKey,
|
|
17549
|
-
parsed.role
|
|
17550
|
-
);
|
|
17551
|
-
}
|
|
17552
17499
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
17553
17500
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
17554
17501
|
if (live === void 0) {
|
|
@@ -17600,9 +17547,9 @@ async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
|
17600
17547
|
var init_external_host_turn_loop = __esm({
|
|
17601
17548
|
"src/external-host-turn-loop.ts"() {
|
|
17602
17549
|
"use strict";
|
|
17603
|
-
init_activation_ledger_topology();
|
|
17604
17550
|
init_settlement();
|
|
17605
17551
|
init_run_lifecycle();
|
|
17552
|
+
init_run_lifecycle();
|
|
17606
17553
|
init_receipt_delivery_policy();
|
|
17607
17554
|
init_role_run_placement();
|
|
17608
17555
|
init_role_run_relocation();
|
|
@@ -18334,99 +18281,6 @@ var init_session_opening_materials = __esm({
|
|
|
18334
18281
|
}
|
|
18335
18282
|
});
|
|
18336
18283
|
|
|
18337
|
-
// src/archivist-record-pointer.ts
|
|
18338
|
-
import { basename as basename9, join as join19 } from "node:path";
|
|
18339
|
-
function bookDirectOfficerRunPointer(options) {
|
|
18340
|
-
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
18341
|
-
const pointer = {
|
|
18342
|
-
version: 1,
|
|
18343
|
-
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
18344
|
-
officer: options.officer,
|
|
18345
|
-
sessionFile: options.sessionFile,
|
|
18346
|
-
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {},
|
|
18347
|
-
...submissionToolCallId === "" ? {} : { submissionToolCallId }
|
|
18348
|
-
};
|
|
18349
|
-
reportRunRecord(runDirectoryOfSessionFile(options.parentSessionFile), OFFICER_POINTER_RECORD_KIND, pointer, "submission-gate");
|
|
18350
|
-
return pointer;
|
|
18351
|
-
}
|
|
18352
|
-
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
18353
|
-
const where = `${parentRunDirectory} officers`;
|
|
18354
|
-
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
18355
|
-
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
18356
|
-
}
|
|
18357
|
-
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
18358
|
-
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
18359
|
-
}
|
|
18360
|
-
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
18361
|
-
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
18362
|
-
let sessionFile = raw.sessionFile;
|
|
18363
|
-
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
18364
|
-
const leaf = parseRunLeaf(basename9(recordedRunDirectory));
|
|
18365
|
-
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
18366
|
-
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
18367
|
-
const currentRunDirectory = await findRunDirectoryById(
|
|
18368
|
-
homeFromRunDirectory(parentRunDirectory),
|
|
18369
|
-
leaf.runId,
|
|
18370
|
-
parentIdentity.bookKey,
|
|
18371
|
-
leaf.role
|
|
18372
|
-
);
|
|
18373
|
-
if (currentRunDirectory !== void 0) {
|
|
18374
|
-
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
18375
|
-
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
18376
|
-
}
|
|
18377
|
-
}
|
|
18378
|
-
const submissionToolCallId = typeof raw.submissionToolCallId === "string" && raw.submissionToolCallId.trim() !== "" ? raw.submissionToolCallId : void 0;
|
|
18379
|
-
return {
|
|
18380
|
-
sessionFile,
|
|
18381
|
-
...officer === void 0 ? {} : { officer },
|
|
18382
|
-
...runDirectory === void 0 ? {} : { runDirectory },
|
|
18383
|
-
...submissionToolCallId === void 0 ? {} : { submissionToolCallId }
|
|
18384
|
-
};
|
|
18385
|
-
}
|
|
18386
|
-
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
18387
|
-
const { records, diagnostics } = await readSitianRecords(join19(parentRunDirectory, RUN_HISTORY_FILE));
|
|
18388
|
-
if (diagnostics.length > 0) {
|
|
18389
|
-
throw new Error(
|
|
18390
|
-
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
18391
|
-
);
|
|
18392
|
-
}
|
|
18393
|
-
return latestOfficerPointersFromRecords(records);
|
|
18394
|
-
}
|
|
18395
|
-
async function readOfficerPointers(parentRunDirectory) {
|
|
18396
|
-
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
18397
|
-
return Promise.all(
|
|
18398
|
-
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
18399
|
-
);
|
|
18400
|
-
}
|
|
18401
|
-
async function readDirectOfficerRunPointer(parentSessionFile, officer) {
|
|
18402
|
-
try {
|
|
18403
|
-
const parentRunDirectory = runDirectoryOfSessionFile(parentSessionFile);
|
|
18404
|
-
const pointer = await resolveOfficerPointer(
|
|
18405
|
-
(await readBookedOfficerPointers(parentRunDirectory))[officer],
|
|
18406
|
-
parentRunDirectory
|
|
18407
|
-
);
|
|
18408
|
-
if (pointer.officer !== officer) return void 0;
|
|
18409
|
-
return { ...pointer, officer, version: 1, kind: DIRECT_OFFICER_RUN_POINTER_KIND };
|
|
18410
|
-
} catch {
|
|
18411
|
-
return void 0;
|
|
18412
|
-
}
|
|
18413
|
-
}
|
|
18414
|
-
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
18415
|
-
var init_archivist_record_pointer = __esm({
|
|
18416
|
-
"src/archivist-record-pointer.ts"() {
|
|
18417
|
-
"use strict";
|
|
18418
|
-
init_unknown_value();
|
|
18419
|
-
init_run_dossier();
|
|
18420
|
-
init_run_dossier_files();
|
|
18421
|
-
init_sitian_facade();
|
|
18422
|
-
init_activation_ledger_topology();
|
|
18423
|
-
init_run_lifecycle();
|
|
18424
|
-
init_role_run_relocation();
|
|
18425
|
-
init_role_run_placement();
|
|
18426
|
-
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
18427
|
-
}
|
|
18428
|
-
});
|
|
18429
|
-
|
|
18430
18284
|
// src/doctor-auditor.ts
|
|
18431
18285
|
function createPiDoctorAuditor() {
|
|
18432
18286
|
return async (options) => {
|
|
@@ -18527,6 +18381,20 @@ var init_worker_submission_contracts = __esm({
|
|
|
18527
18381
|
});
|
|
18528
18382
|
|
|
18529
18383
|
// src/submission-gate.ts
|
|
18384
|
+
async function directoryForSummonedOfficer(officer, summoned) {
|
|
18385
|
+
if (summoned.admitted?.role === officer) {
|
|
18386
|
+
return summoned.admitted.runDirectory;
|
|
18387
|
+
}
|
|
18388
|
+
let dir = typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? summoned.runDirectory : summoned.admitted?.runDirectory;
|
|
18389
|
+
for (let hop = 0; hop < 8 && dir !== void 0; hop += 1) {
|
|
18390
|
+
const identity = await readRoleRunIdentity(dir);
|
|
18391
|
+
if (identity?.role === officer) return dir;
|
|
18392
|
+
const parent = await readRunParentPath(dir);
|
|
18393
|
+
if (parent === void 0 || parent === dir) break;
|
|
18394
|
+
dir = parent;
|
|
18395
|
+
}
|
|
18396
|
+
return void 0;
|
|
18397
|
+
}
|
|
18530
18398
|
function latestQueueStatus(terminal) {
|
|
18531
18399
|
const outcome = terminal?.roleOutcome;
|
|
18532
18400
|
if (outcome === void 0) return void 0;
|
|
@@ -18564,24 +18432,6 @@ function createDefaultGateOfficerSummon(options) {
|
|
|
18564
18432
|
});
|
|
18565
18433
|
};
|
|
18566
18434
|
}
|
|
18567
|
-
function bookDirectOfficerPointer(context, officer, result, summoned, toolCallId) {
|
|
18568
|
-
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask" && result.status !== "transport_failure") {
|
|
18569
|
-
return;
|
|
18570
|
-
}
|
|
18571
|
-
const parentFile = context.sessionManager?.getSessionFile?.();
|
|
18572
|
-
if (typeof parentFile !== "string" || parentFile.trim() === "") return;
|
|
18573
|
-
const sessionFile = sessionFileFromPublicSummon(summoned);
|
|
18574
|
-
if (sessionFile === void 0) {
|
|
18575
|
-
return;
|
|
18576
|
-
}
|
|
18577
|
-
bookDirectOfficerRunPointer({
|
|
18578
|
-
parentSessionFile: parentFile,
|
|
18579
|
-
officer,
|
|
18580
|
-
sessionFile,
|
|
18581
|
-
...typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? { runDirectory: summoned.runDirectory } : {},
|
|
18582
|
-
...toolCallId.trim() === "" ? {} : { submissionToolCallId: toolCallId }
|
|
18583
|
-
});
|
|
18584
|
-
}
|
|
18585
18435
|
async function requireSubmissionGate(options) {
|
|
18586
18436
|
let reask;
|
|
18587
18437
|
let reasksSpent = 0;
|
|
@@ -18599,17 +18449,13 @@ async function requireSubmissionGate(options) {
|
|
|
18599
18449
|
...reask === void 0 ? {} : { reask }
|
|
18600
18450
|
});
|
|
18601
18451
|
const gatekeeper = projected.result;
|
|
18602
|
-
if (projected.summoned !== void 0) {
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
options.toolCallId
|
|
18610
|
-
);
|
|
18611
|
-
} catch (error) {
|
|
18612
|
-
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
18452
|
+
if (projected.summoned !== void 0 && options.toolCallId.trim() !== "" && (gatekeeper.status === "converged" || gatekeeper.status === "continue" || gatekeeper.status === "escalate" || gatekeeper.status === "needs_reask" || gatekeeper.status === "transport_failure")) {
|
|
18453
|
+
const officerRunDirectory = await directoryForSummonedOfficer(
|
|
18454
|
+
projected.officer,
|
|
18455
|
+
projected.summoned
|
|
18456
|
+
);
|
|
18457
|
+
if (officerRunDirectory !== void 0) {
|
|
18458
|
+
persistAdmittedAuditedSubmissionToolCallId(officerRunDirectory, options.toolCallId);
|
|
18613
18459
|
}
|
|
18614
18460
|
}
|
|
18615
18461
|
if (gatekeeper.status === "converged") {
|
|
@@ -18617,7 +18463,11 @@ async function requireSubmissionGate(options) {
|
|
|
18617
18463
|
status: "converged",
|
|
18618
18464
|
officer: projected.officer,
|
|
18619
18465
|
receipt: gatekeeper.receipt,
|
|
18620
|
-
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
|
|
18466
|
+
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
18467
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
18468
|
+
// Keep the officer terminal for escalate / unsettled surfaces; parent
|
|
18469
|
+
// finals do not project other-seat tables (#1195).
|
|
18470
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
18621
18471
|
};
|
|
18622
18472
|
}
|
|
18623
18473
|
if (gatekeeper.status === "continue") {
|
|
@@ -18629,7 +18479,8 @@ async function requireSubmissionGate(options) {
|
|
|
18629
18479
|
};
|
|
18630
18480
|
}
|
|
18631
18481
|
if (gatekeeper.status === "needs_reask") {
|
|
18632
|
-
|
|
18482
|
+
const nestedIncomplete = projected.summoned?.terminal?.roleOutcome.kind === "accepted" && projected.summoned.terminal.roleOutcome.decisiveFacts?.directionUnsettled === true;
|
|
18483
|
+
if (nestedIncomplete || reasksSpent >= reaskLimit) {
|
|
18633
18484
|
return {
|
|
18634
18485
|
status: "needs_reask",
|
|
18635
18486
|
officer: projected.officer,
|
|
@@ -18656,7 +18507,9 @@ async function requireSubmissionGate(options) {
|
|
|
18656
18507
|
officer: projected.officer,
|
|
18657
18508
|
receipt: gatekeeper.receipt,
|
|
18658
18509
|
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
18659
|
-
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {}
|
|
18510
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
18511
|
+
// Keep the actual officer terminal so callers resume that seat.
|
|
18512
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
18660
18513
|
};
|
|
18661
18514
|
}
|
|
18662
18515
|
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
@@ -18666,11 +18519,11 @@ async function requireSubmissionGate(options) {
|
|
|
18666
18519
|
var init_submission_gate = __esm({
|
|
18667
18520
|
"src/submission-gate.ts"() {
|
|
18668
18521
|
"use strict";
|
|
18669
|
-
|
|
18522
|
+
init_invocation();
|
|
18523
|
+
init_run_lifecycle();
|
|
18670
18524
|
init_gatekeeper_role();
|
|
18671
18525
|
init_submission_errors();
|
|
18672
18526
|
init_receipt_delivery_policy();
|
|
18673
|
-
init_session_assistant_usage();
|
|
18674
18527
|
init_unknown_value();
|
|
18675
18528
|
}
|
|
18676
18529
|
});
|
|
@@ -18690,7 +18543,7 @@ __export(auditor_soul_exports, {
|
|
|
18690
18543
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
18691
18544
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
18692
18545
|
});
|
|
18693
|
-
import { basename as
|
|
18546
|
+
import { basename as basename9 } from "node:path";
|
|
18694
18547
|
function auditorSoulRelativePath(role) {
|
|
18695
18548
|
return `souls/${role}-auditor.md`;
|
|
18696
18549
|
}
|
|
@@ -18726,22 +18579,24 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
18726
18579
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
18727
18580
|
}
|
|
18728
18581
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
18729
|
-
const role = parseRunLeaf(
|
|
18582
|
+
const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
|
|
18730
18583
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
18731
18584
|
}
|
|
18732
|
-
async function readAuditorResumeBinding(
|
|
18733
|
-
const record = readPageSync(runDirectory, "admitted");
|
|
18585
|
+
async function readAuditorResumeBinding(admitted) {
|
|
18586
|
+
const record = readPageSync(admitted.runDirectory, "admitted");
|
|
18734
18587
|
if (record === void 0) return void 0;
|
|
18735
|
-
|
|
18736
|
-
|
|
18588
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
18589
|
+
if (sourceRunPath === void 0) return void 0;
|
|
18590
|
+
const subject = isAuditorSoulRole(record.auditorSubject) ? record.auditorSubject : subjectFromSourceDirectory(sourceRunPath);
|
|
18737
18591
|
if (subject === void 0) return void 0;
|
|
18738
|
-
return { subject, sourceRunDirectory:
|
|
18592
|
+
return { subject, sourceRunDirectory: sourceRunPath };
|
|
18739
18593
|
}
|
|
18740
18594
|
var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
|
|
18741
18595
|
var init_auditor_soul = __esm({
|
|
18742
18596
|
"src/auditor-soul.ts"() {
|
|
18743
18597
|
"use strict";
|
|
18744
18598
|
init_run_dossier();
|
|
18599
|
+
init_invocation();
|
|
18745
18600
|
init_role_run_placement();
|
|
18746
18601
|
init_unknown_value();
|
|
18747
18602
|
init_session_opening_materials();
|
|
@@ -19043,15 +18898,15 @@ var init_auto_resume = __esm({
|
|
|
19043
18898
|
async function tryResumeSameTicketSeatRun(input) {
|
|
19044
18899
|
if (input.freshSummons === true) return void 0;
|
|
19045
18900
|
if (input.parentRunPath.trim() === "") return void 0;
|
|
19046
|
-
const
|
|
18901
|
+
const previous = await findLatestRunForSeatTicket({
|
|
19047
18902
|
home: input.home,
|
|
19048
18903
|
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
19049
18904
|
role: input.role,
|
|
19050
18905
|
parentRunPath: input.parentRunPath,
|
|
19051
18906
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
19052
18907
|
});
|
|
19053
|
-
if (
|
|
19054
|
-
return await input.resume(
|
|
18908
|
+
if (previous === void 0) return void 0;
|
|
18909
|
+
return await input.resume(previous.runId, input.summons, previous.runDirectory);
|
|
19055
18910
|
}
|
|
19056
18911
|
var init_seat_ticket_binding = __esm({
|
|
19057
18912
|
"src/public-cli/seat-ticket-binding.ts"() {
|
|
@@ -19297,11 +19152,9 @@ async function presentOriginalVolume(held, terminal, io, runDirectory) {
|
|
|
19297
19152
|
}
|
|
19298
19153
|
for (const value of held) io.stdout(value);
|
|
19299
19154
|
}
|
|
19300
|
-
function withUnsettledDirection(parent
|
|
19155
|
+
function withUnsettledDirection(parent) {
|
|
19301
19156
|
const outcome = parent.roleOutcome;
|
|
19302
19157
|
if (outcome.kind !== "accepted" && outcome.kind !== "audit_escalation") return parent;
|
|
19303
|
-
const officerOutcome = officer?.roleOutcome;
|
|
19304
|
-
const officerPayloads = officer?.submissions !== void 0 && officer.submissions.length > 0 ? officer.submissions : officerOutcome !== void 0 && officerOutcome.kind !== "no_receipt" ? officerOutcome.payloads ?? [] : [];
|
|
19305
19158
|
return {
|
|
19306
19159
|
...parent,
|
|
19307
19160
|
roleOutcome: {
|
|
@@ -19309,10 +19162,7 @@ function withUnsettledDirection(parent, officer) {
|
|
|
19309
19162
|
decisiveFacts: {
|
|
19310
19163
|
...outcome.decisiveFacts ?? {},
|
|
19311
19164
|
directionUnsettled: true,
|
|
19312
|
-
subsequentAudit: "incomplete"
|
|
19313
|
-
...officerOutcome === void 0 ? {} : { officerRole: officerOutcome.role },
|
|
19314
|
-
...officer?.runId === void 0 ? {} : { officerRunId: officer.runId },
|
|
19315
|
-
...officerPayloads.length === 0 ? {} : { officerPayloads }
|
|
19165
|
+
subsequentAudit: "incomplete"
|
|
19316
19166
|
}
|
|
19317
19167
|
}
|
|
19318
19168
|
};
|
|
@@ -19323,10 +19173,9 @@ function heldUnreadableTerminal(terminal) {
|
|
|
19323
19173
|
const status = latestQueueStatus(terminal);
|
|
19324
19174
|
return typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status);
|
|
19325
19175
|
}
|
|
19326
|
-
async function
|
|
19327
|
-
const terminal = withUnsettledDirection(
|
|
19176
|
+
async function presentUnsettledOfficer(officer, io, runDirectory) {
|
|
19177
|
+
const terminal = withUnsettledDirection(officer);
|
|
19328
19178
|
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
19329
|
-
if (officer !== void 0) await presentTerminal(officer, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
19330
19179
|
return terminal;
|
|
19331
19180
|
}
|
|
19332
19181
|
async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io, message = unreadablePostSubmissionStatus(admitted, terminal)) {
|
|
@@ -19334,7 +19183,11 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
|
|
|
19334
19183
|
const next = withUnreadableReask(env);
|
|
19335
19184
|
if (next === void 0) return UNREADABLE_REASK_EXHAUSTED;
|
|
19336
19185
|
return runPublicInstructionSeatResume(
|
|
19337
|
-
{
|
|
19186
|
+
{
|
|
19187
|
+
runId: admitted.runId,
|
|
19188
|
+
runDirectory: admitted.runDirectory,
|
|
19189
|
+
summons: { instruction: message }
|
|
19190
|
+
},
|
|
19338
19191
|
next,
|
|
19339
19192
|
io
|
|
19340
19193
|
);
|
|
@@ -19357,7 +19210,11 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
|
|
|
19357
19210
|
softTicketReaskOwnership
|
|
19358
19211
|
};
|
|
19359
19212
|
const result = await runPublicInstructionSeatResume(
|
|
19360
|
-
{
|
|
19213
|
+
{
|
|
19214
|
+
runId: admitted.runId,
|
|
19215
|
+
runDirectory: admitted.runDirectory,
|
|
19216
|
+
summons: { instruction }
|
|
19217
|
+
},
|
|
19361
19218
|
softReaskEnv,
|
|
19362
19219
|
io
|
|
19363
19220
|
);
|
|
@@ -19473,22 +19330,24 @@ async function resolveReviewSeatDialogueBody(input) {
|
|
|
19473
19330
|
if (reask !== void 0 && reask.length > 0) return reask;
|
|
19474
19331
|
const caller = input.callerInstruction ?? "";
|
|
19475
19332
|
if (caller.length > 0) return caller;
|
|
19476
|
-
const sourceRunPath = input
|
|
19477
|
-
if (sourceRunPath ===
|
|
19333
|
+
const sourceRunPath = admittedSourceRunPath(input)?.trim();
|
|
19334
|
+
if (sourceRunPath === void 0) return void 0;
|
|
19335
|
+
if (input.role === "notary") {
|
|
19336
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
19337
|
+
if (isTicketCourtCountersignSource2(sourceRunPath)) return void 0;
|
|
19338
|
+
}
|
|
19478
19339
|
return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
|
|
19479
19340
|
}
|
|
19480
|
-
function admittedSourceRunPath(admitted) {
|
|
19481
|
-
return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
|
|
19482
|
-
}
|
|
19483
19341
|
async function resolveInitialPrompt(admitted, env) {
|
|
19484
19342
|
const record = roleRecord(admitted.role);
|
|
19485
19343
|
if ("reaskPrompt" in record && record.reaskPrompt === true) {
|
|
19486
19344
|
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
19487
19345
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
19488
19346
|
const body = await resolveReviewSeatDialogueBody({
|
|
19347
|
+
role: admitted.role,
|
|
19489
19348
|
...reask === void 0 ? {} : { reask },
|
|
19490
19349
|
callerInstruction: admitted.instruction,
|
|
19491
|
-
...sourceRunPath ===
|
|
19350
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
19492
19351
|
projectRoot: admitted.projectRoot,
|
|
19493
19352
|
home: env.home
|
|
19494
19353
|
});
|
|
@@ -19694,16 +19553,21 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
19694
19553
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
19695
19554
|
freshSummons: input.env.freshSummons,
|
|
19696
19555
|
summons: input.summons,
|
|
19697
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
19698
|
-
{
|
|
19556
|
+
resume: (runId, materials, runDirectory) => runPublicInstructionSeatResume(
|
|
19557
|
+
{
|
|
19558
|
+
runId,
|
|
19559
|
+
runDirectory,
|
|
19560
|
+
...materials === void 0 ? {} : { summons: materials }
|
|
19561
|
+
},
|
|
19699
19562
|
input.env,
|
|
19700
19563
|
input.io
|
|
19701
19564
|
)
|
|
19702
19565
|
});
|
|
19703
19566
|
}
|
|
19704
|
-
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
|
|
19567
|
+
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
|
|
19705
19568
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
19706
19569
|
const body = await resolveReviewSeatDialogueBody({
|
|
19570
|
+
role,
|
|
19707
19571
|
...reask === void 0 ? {} : { reask },
|
|
19708
19572
|
callerInstruction: fallback.instruction,
|
|
19709
19573
|
sourceRunPath,
|
|
@@ -19826,6 +19690,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19826
19690
|
let auditorSource;
|
|
19827
19691
|
let auditorTicket;
|
|
19828
19692
|
let resolvedNotarySource;
|
|
19693
|
+
let instructionSourceRunPath;
|
|
19829
19694
|
if (record.sameParent === "subject-source") {
|
|
19830
19695
|
if (parsed.subject === void 0) {
|
|
19831
19696
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
@@ -19855,7 +19720,8 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19855
19720
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
19856
19721
|
},
|
|
19857
19722
|
sourceDirectory,
|
|
19858
|
-
projectRoot
|
|
19723
|
+
projectRoot,
|
|
19724
|
+
role
|
|
19859
19725
|
),
|
|
19860
19726
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
19861
19727
|
};
|
|
@@ -19875,9 +19741,8 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19875
19741
|
}
|
|
19876
19742
|
if (record.sameParent === "source-run") {
|
|
19877
19743
|
if (parsed.sourceRun !== void 0) {
|
|
19878
|
-
let parentRunPath;
|
|
19879
19744
|
try {
|
|
19880
|
-
|
|
19745
|
+
instructionSourceRunPath = (await resolveNotarySourceRunLocator({
|
|
19881
19746
|
projectRoot,
|
|
19882
19747
|
sourceRun: parsed.sourceRun,
|
|
19883
19748
|
home: env.home
|
|
@@ -19889,6 +19754,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19889
19754
|
}
|
|
19890
19755
|
throw error;
|
|
19891
19756
|
}
|
|
19757
|
+
const parentRunPath = instructionSourceRunPath;
|
|
19892
19758
|
const summons = {
|
|
19893
19759
|
sourceRunPath: parentRunPath,
|
|
19894
19760
|
...await sameParentDialogue(
|
|
@@ -19898,7 +19764,8 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19898
19764
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
19899
19765
|
},
|
|
19900
19766
|
parentRunPath,
|
|
19901
|
-
projectRoot
|
|
19767
|
+
projectRoot,
|
|
19768
|
+
role
|
|
19902
19769
|
),
|
|
19903
19770
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
19904
19771
|
};
|
|
@@ -19935,7 +19802,8 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19935
19802
|
env,
|
|
19936
19803
|
{ instruction: "", instructionEmpty: true },
|
|
19937
19804
|
source.runDirectory,
|
|
19938
|
-
projectRoot
|
|
19805
|
+
projectRoot,
|
|
19806
|
+
role
|
|
19939
19807
|
)
|
|
19940
19808
|
};
|
|
19941
19809
|
resolvedNotarySource = source;
|
|
@@ -19966,14 +19834,9 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
19966
19834
|
if (rejected !== void 0) return rejected;
|
|
19967
19835
|
throw error;
|
|
19968
19836
|
}
|
|
19969
|
-
if (
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
sourceRun: parsed.sourceRun,
|
|
19973
|
-
home: env.home
|
|
19974
|
-
})).runDirectory;
|
|
19975
|
-
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
19976
|
-
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
19837
|
+
if (instructionSourceRunPath !== void 0) {
|
|
19838
|
+
await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
|
|
19839
|
+
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
19977
19840
|
}
|
|
19978
19841
|
if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
19979
19842
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
@@ -20042,6 +19905,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
20042
19905
|
return runAdmitted();
|
|
20043
19906
|
}
|
|
20044
19907
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
19908
|
+
let selectedRequest = request;
|
|
20045
19909
|
const resume = async () => {
|
|
20046
19910
|
const held = [];
|
|
20047
19911
|
const turnIo = {
|
|
@@ -20049,11 +19913,16 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
20049
19913
|
stderr: io.stderr
|
|
20050
19914
|
};
|
|
20051
19915
|
const result = await runPostAdmissionSeatResume({
|
|
20052
|
-
request,
|
|
19916
|
+
request: selectedRequest,
|
|
20053
19917
|
env,
|
|
20054
19918
|
io: turnIo,
|
|
20055
19919
|
load: async (effective) => {
|
|
20056
|
-
const loaded = await loadResumablePublicRole(
|
|
19920
|
+
const loaded = await loadResumablePublicRole(
|
|
19921
|
+
env.home,
|
|
19922
|
+
effective.runId,
|
|
19923
|
+
env.principalAuthority,
|
|
19924
|
+
effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
|
|
19925
|
+
);
|
|
20057
19926
|
if (packagedRebindSourceOnResume(loaded.admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
|
|
20058
19927
|
return {
|
|
20059
19928
|
...loaded,
|
|
@@ -20098,8 +19967,14 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
20098
19967
|
};
|
|
20099
19968
|
let binding;
|
|
20100
19969
|
try {
|
|
20101
|
-
const loaded = await loadResumablePublicRole(
|
|
20102
|
-
|
|
19970
|
+
const loaded = await loadResumablePublicRole(
|
|
19971
|
+
env.home,
|
|
19972
|
+
request.runId,
|
|
19973
|
+
env.principalAuthority,
|
|
19974
|
+
request.runDirectory === void 0 ? void 0 : { runDirectory: request.runDirectory }
|
|
19975
|
+
);
|
|
19976
|
+
selectedRequest = { ...request, runDirectory: loaded.admitted.runDirectory };
|
|
19977
|
+
binding = loaded.admitted.role === "auditor" ? await readAuditorResumeBinding(loaded.admitted) : void 0;
|
|
20103
19978
|
} catch (error) {
|
|
20104
19979
|
if (!(error instanceof CliUsageError)) throw error;
|
|
20105
19980
|
}
|
|
@@ -20161,24 +20036,34 @@ async function queueConclusionFromChild(child, env, io) {
|
|
|
20161
20036
|
}
|
|
20162
20037
|
}
|
|
20163
20038
|
async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
20164
|
-
const
|
|
20039
|
+
const knownParentDirectory = admittedSourceRunPath(child);
|
|
20040
|
+
const loaded = await loadResumablePublicRole(
|
|
20041
|
+
env.home,
|
|
20042
|
+
parentRunId,
|
|
20043
|
+
env.principalAuthority,
|
|
20044
|
+
knownParentDirectory === void 0 ? void 0 : { runDirectory: knownParentDirectory }
|
|
20045
|
+
);
|
|
20165
20046
|
if (loaded.run.state !== "admitted" && !AUDITED_ROLES.has(loaded.admitted.role)) {
|
|
20166
|
-
return runPublicInstructionSeatResume(
|
|
20047
|
+
return runPublicInstructionSeatResume(
|
|
20048
|
+
{
|
|
20049
|
+
runId: parentRunId,
|
|
20050
|
+
runDirectory: loaded.admitted.runDirectory
|
|
20051
|
+
},
|
|
20052
|
+
env,
|
|
20053
|
+
io
|
|
20054
|
+
);
|
|
20167
20055
|
}
|
|
20168
20056
|
const admitted = loaded.admitted;
|
|
20169
20057
|
const resolved = await queueConclusionFromChild(child, env, io);
|
|
20170
20058
|
if (resolved !== void 0 && "stop" in resolved) {
|
|
20171
20059
|
const stopped = resolved.stop;
|
|
20172
|
-
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0) {
|
|
20173
|
-
const
|
|
20174
|
-
|
|
20175
|
-
|
|
20176
|
-
|
|
20060
|
+
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0 && stopped.admitted !== void 0) {
|
|
20061
|
+
const terminal = await presentUnsettledOfficer(
|
|
20062
|
+
stopped.terminal,
|
|
20063
|
+
io,
|
|
20064
|
+
stopped.admitted.runDirectory
|
|
20177
20065
|
);
|
|
20178
|
-
|
|
20179
|
-
const terminal = await presentUnsettledAudit(parentTerminal, stopped.terminal, io, admitted.runDirectory);
|
|
20180
|
-
return { exitCode: 0, admitted, terminal };
|
|
20181
|
-
}
|
|
20066
|
+
return { exitCode: 0, admitted: stopped.admitted, terminal };
|
|
20182
20067
|
}
|
|
20183
20068
|
return stopped;
|
|
20184
20069
|
}
|
|
@@ -20193,10 +20078,22 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
20193
20078
|
{ ...await readCurrentCourt(admitted.runDirectory), ...packageFaultScope(admitted, env, io) }
|
|
20194
20079
|
);
|
|
20195
20080
|
if (terminal?.roleOutcome.kind !== "accepted") throw new Error("pending submission is not recorded");
|
|
20196
|
-
|
|
20081
|
+
const live = liveChildForCurrentParentSeal(
|
|
20082
|
+
terminal,
|
|
20083
|
+
resolved.admitted,
|
|
20084
|
+
latestQueuePayload(resolved.terminal)
|
|
20085
|
+
);
|
|
20086
|
+
return auditSubmittedRole(
|
|
20087
|
+
{ exitCode: 0, admitted, terminal },
|
|
20088
|
+
env,
|
|
20089
|
+
io,
|
|
20090
|
+
live?.officer,
|
|
20091
|
+
live?.receipt
|
|
20092
|
+
);
|
|
20197
20093
|
}
|
|
20198
20094
|
return runPublicInstructionSeatResume({
|
|
20199
20095
|
runId: parentRunId,
|
|
20096
|
+
runDirectory: admitted.runDirectory,
|
|
20200
20097
|
summons: { instruction: readableGateItem(latestQueuePayload(resolved.terminal)) }
|
|
20201
20098
|
}, envForCourtContinue(env), io);
|
|
20202
20099
|
}
|
|
@@ -20204,28 +20101,21 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
20204
20101
|
showResumeErrorPointer(io, result.exitCode, result.terminal);
|
|
20205
20102
|
return result;
|
|
20206
20103
|
}
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
const
|
|
20210
|
-
if (
|
|
20211
|
-
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
|
|
20215
|
-
|
|
20216
|
-
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
} catch {
|
|
20223
|
-
return false;
|
|
20224
|
-
}
|
|
20225
|
-
if (admitted.role !== officer) return false;
|
|
20226
|
-
const court = await readCurrentCourt(admitted.runDirectory);
|
|
20227
|
-
const terminal = await trySettlePublicSeat(admitted, env.principalAuthority, court);
|
|
20228
|
-
return latestQueueStatus(terminal) === "converged";
|
|
20104
|
+
function liveChildForCurrentParentSeal(parentTerminal, child, receipt) {
|
|
20105
|
+
if (receipt === void 0) return void 0;
|
|
20106
|
+
const parentSealId = parentTerminal.submissionToolCallId?.trim() ?? "";
|
|
20107
|
+
if (parentSealId === "") return void 0;
|
|
20108
|
+
const childSealId = readAdmittedAuditedSubmissionToolCallId(child.runDirectory);
|
|
20109
|
+
if (childSealId !== parentSealId) return void 0;
|
|
20110
|
+
return { officer: child, receipt };
|
|
20111
|
+
}
|
|
20112
|
+
function officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder) {
|
|
20113
|
+
if (resumedOfficer === void 0 || passedReceipt === void 0) return false;
|
|
20114
|
+
if (resumedOfficer.role === officer) return true;
|
|
20115
|
+
if (chainOrder === void 0) return false;
|
|
20116
|
+
const childIndex = chainOrder.indexOf(resumedOfficer.role);
|
|
20117
|
+
const officerIndex = chainOrder.indexOf(officer);
|
|
20118
|
+
return childIndex >= 0 && officerIndex >= 0 && officerIndex < childIndex;
|
|
20229
20119
|
}
|
|
20230
20120
|
async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt) {
|
|
20231
20121
|
env = withoutSoftTicketReaskTurn(env);
|
|
@@ -20240,21 +20130,29 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20240
20130
|
if (gateOwnsStatusReask) return turn;
|
|
20241
20131
|
const next = withUnreadableReask(env);
|
|
20242
20132
|
if (next === void 0) {
|
|
20243
|
-
const
|
|
20244
|
-
await presentTerminal(
|
|
20245
|
-
return { ...turn, terminal
|
|
20133
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
20134
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
20135
|
+
return { ...turn, terminal };
|
|
20246
20136
|
}
|
|
20247
|
-
return runPublicInstructionSeatResume({
|
|
20137
|
+
return runPublicInstructionSeatResume({
|
|
20138
|
+
runId: admitted.runId,
|
|
20139
|
+
runDirectory: admitted.runDirectory,
|
|
20140
|
+
summons: { instruction: SECRETARIAT_STATUS_REASK }
|
|
20141
|
+
}, next, io);
|
|
20248
20142
|
}
|
|
20249
20143
|
if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
|
|
20250
20144
|
if (gateOwnsStatusReask) return turn;
|
|
20251
20145
|
const next = withUnreadableReask(env);
|
|
20252
20146
|
if (next === void 0) {
|
|
20253
|
-
const
|
|
20254
|
-
await presentTerminal(
|
|
20255
|
-
return { ...turn, terminal
|
|
20147
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
20148
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
20149
|
+
return { ...turn, terminal };
|
|
20256
20150
|
}
|
|
20257
|
-
return runPublicInstructionSeatResume({
|
|
20151
|
+
return runPublicInstructionSeatResume({
|
|
20152
|
+
runId: admitted.runId,
|
|
20153
|
+
runDirectory: admitted.runDirectory,
|
|
20154
|
+
summons: { instruction: officerConclusionReask(status) }
|
|
20155
|
+
}, next, io);
|
|
20258
20156
|
}
|
|
20259
20157
|
const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
|
|
20260
20158
|
const skipAudit = selfEscalationSkipsAudit || (admitted.role === "fixer" || admitted.role === "coder") && (typeof status !== "string" || !WORKER_DONE_STATUSES.has(status));
|
|
@@ -20284,14 +20182,9 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20284
20182
|
abort() {
|
|
20285
20183
|
}
|
|
20286
20184
|
};
|
|
20287
|
-
const
|
|
20288
|
-
env,
|
|
20289
|
-
parentSessionFile: sessionFile,
|
|
20290
|
-
officer,
|
|
20291
|
-
toolCallId
|
|
20292
|
-
});
|
|
20185
|
+
const gateSatisfied = (officer, chainOrder) => officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder);
|
|
20293
20186
|
if (admitted.role === "doctor") {
|
|
20294
|
-
if (!
|
|
20187
|
+
if (!gateSatisfied("auditor")) {
|
|
20295
20188
|
let lastSummon;
|
|
20296
20189
|
const decision = await createPiDoctorAuditor()({
|
|
20297
20190
|
context,
|
|
@@ -20313,23 +20206,18 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20313
20206
|
...reask === void 0 ? {} : { reviewReask: reask },
|
|
20314
20207
|
...submission === void 0 ? {} : { gateReviewInstruction: submission }
|
|
20315
20208
|
});
|
|
20316
|
-
const officerSession = sessionFileFromPublicSummon(summoned);
|
|
20317
|
-
if (officerSession !== void 0) {
|
|
20318
|
-
bookDirectOfficerRunPointer({
|
|
20319
|
-
parentSessionFile: sessionFile,
|
|
20320
|
-
officer: "auditor",
|
|
20321
|
-
sessionFile: officerSession,
|
|
20322
|
-
submissionToolCallId: toolCallId,
|
|
20323
|
-
...summoned.runDirectory === void 0 ? {} : { runDirectory: summoned.runDirectory }
|
|
20324
|
-
});
|
|
20325
|
-
}
|
|
20326
20209
|
lastSummon = summoned;
|
|
20210
|
+
const officerDir = summoned.runDirectory ?? summoned.admitted?.runDirectory;
|
|
20211
|
+
if (officerDir !== void 0 && toolCallId.length > 0) {
|
|
20212
|
+
persistAdmittedAuditedSubmissionToolCallId(officerDir, toolCallId);
|
|
20213
|
+
}
|
|
20327
20214
|
return summoned;
|
|
20328
20215
|
}
|
|
20329
20216
|
});
|
|
20330
20217
|
if (decision.status === "continue") {
|
|
20331
20218
|
return runPublicInstructionSeatResume({
|
|
20332
20219
|
runId: admitted.runId,
|
|
20220
|
+
runDirectory: admitted.runDirectory,
|
|
20333
20221
|
summons: { instruction: readableGateItem(decision.receipt ?? decision.violations) }
|
|
20334
20222
|
}, envForCourtContinue(env), io);
|
|
20335
20223
|
}
|
|
@@ -20337,9 +20225,14 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20337
20225
|
if (lastSummon?.terminal === void 0) {
|
|
20338
20226
|
throw new Error("doctor audit kept an unreadable reply with no terminal");
|
|
20339
20227
|
}
|
|
20340
|
-
|
|
20341
|
-
const
|
|
20342
|
-
|
|
20228
|
+
const officerAdmitted = lastSummon.admitted;
|
|
20229
|
+
const officerDir = officerAdmitted?.runDirectory ?? lastSummon.runDirectory ?? admitted.runDirectory;
|
|
20230
|
+
const terminal = await presentUnsettledOfficer(lastSummon.terminal, io, officerDir);
|
|
20231
|
+
return {
|
|
20232
|
+
exitCode: 0,
|
|
20233
|
+
...officerAdmitted === void 0 ? { admitted } : { admitted: officerAdmitted },
|
|
20234
|
+
terminal
|
|
20235
|
+
};
|
|
20343
20236
|
}
|
|
20344
20237
|
if (decision.status !== "converged") {
|
|
20345
20238
|
if (lastSummon?.terminal !== void 0) {
|
|
@@ -20362,7 +20255,6 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20362
20255
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
20363
20256
|
});
|
|
20364
20257
|
let chain;
|
|
20365
|
-
let officerRunId = resumedOfficer?.runId;
|
|
20366
20258
|
const runGate = (subject) => requireSubmissionGate({
|
|
20367
20259
|
context,
|
|
20368
20260
|
subject,
|
|
@@ -20380,19 +20272,19 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20380
20272
|
}
|
|
20381
20273
|
});
|
|
20382
20274
|
if (admitted.role === "judge") {
|
|
20275
|
+
const judgeGateOrder = JUDGE_GATES.map(gateOfficerForSubject);
|
|
20383
20276
|
chain = await runJudgeGates({
|
|
20384
|
-
gateAlreadyConverged: async (subject) =>
|
|
20277
|
+
gateAlreadyConverged: async (subject) => gateSatisfied(gateOfficerForSubject(subject), judgeGateOrder),
|
|
20385
20278
|
runGate
|
|
20386
20279
|
});
|
|
20387
20280
|
} else {
|
|
20388
20281
|
const subject = admitted.role === "fixer" || admitted.role === "coder" ? { kind: "worker_completion" } : admitted.role === "secretariat" ? { kind: "secretariat_verdict" } : { kind: "countersign_verdict" };
|
|
20389
20282
|
const officer = gateOfficerForSubject(subject);
|
|
20390
|
-
if (
|
|
20283
|
+
if (gateSatisfied(officer)) {
|
|
20391
20284
|
chain = { status: "converged", passes: [] };
|
|
20392
20285
|
} else {
|
|
20393
20286
|
const pass = await runGate(subject);
|
|
20394
20287
|
if (pass === void 0) throw new Error("audit gate returned no conclusion");
|
|
20395
|
-
officerRunId = pass.runId;
|
|
20396
20288
|
chain = {
|
|
20397
20289
|
status: pass.status,
|
|
20398
20290
|
passes: [{
|
|
@@ -20407,53 +20299,58 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
20407
20299
|
}
|
|
20408
20300
|
}
|
|
20409
20301
|
if (chain.status === "needs_reask") {
|
|
20410
|
-
const
|
|
20302
|
+
const pass = chain.passes.at(-1);
|
|
20303
|
+
const officerTerminal = pass?.terminal;
|
|
20411
20304
|
if (officerTerminal === void 0) throw new Error("unreadable audit has no terminal result");
|
|
20412
|
-
|
|
20413
|
-
const
|
|
20414
|
-
|
|
20305
|
+
const officerRunDirectory = pass?.runDirectory;
|
|
20306
|
+
const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
|
|
20307
|
+
if (officerRunId === void 0) throw new Error("unreadable audit has no resumable run identity");
|
|
20308
|
+
const officer = await loadResumablePublicRole(
|
|
20309
|
+
env.home,
|
|
20310
|
+
officerRunId,
|
|
20311
|
+
env.principalAuthority,
|
|
20312
|
+
officerRunDirectory === void 0 ? void 0 : { runDirectory: officerRunDirectory }
|
|
20313
|
+
);
|
|
20314
|
+
const terminal = await presentUnsettledOfficer(
|
|
20315
|
+
officerTerminal,
|
|
20316
|
+
io,
|
|
20317
|
+
officer.admitted.runDirectory
|
|
20318
|
+
);
|
|
20319
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
20415
20320
|
}
|
|
20416
20321
|
if (chain.status === "escalate") {
|
|
20417
20322
|
const escalation = chain.passes.at(-1);
|
|
20418
|
-
const
|
|
20323
|
+
const escalatedRunDirectory = escalation?.runDirectory;
|
|
20324
|
+
const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
|
|
20419
20325
|
if (escalatedRunId === void 0) throw new Error("escalated audit has no resumable run identity");
|
|
20420
|
-
const officer = await loadResumablePublicRole(
|
|
20421
|
-
|
|
20422
|
-
|
|
20326
|
+
const officer = await loadResumablePublicRole(
|
|
20327
|
+
env.home,
|
|
20328
|
+
escalatedRunId,
|
|
20423
20329
|
env.principalAuthority,
|
|
20424
|
-
|
|
20330
|
+
escalatedRunDirectory === void 0 ? void 0 : { runDirectory: escalatedRunDirectory }
|
|
20425
20331
|
);
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20332
|
+
let terminal = escalation?.terminal;
|
|
20333
|
+
if (terminal === void 0) {
|
|
20334
|
+
terminal = await trySettlePublicSeat(
|
|
20335
|
+
officer.admitted,
|
|
20336
|
+
env.principalAuthority,
|
|
20337
|
+
{ ...await readCurrentCourt(officer.admitted.runDirectory), ...packageFaultScope(officer.admitted, env, io) }
|
|
20338
|
+
);
|
|
20339
|
+
}
|
|
20340
|
+
if (terminal === void 0) throw new Error("escalated audit has no terminal result");
|
|
20341
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, officer.admitted.runDirectory);
|
|
20342
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
20429
20343
|
}
|
|
20430
20344
|
if (chain.status === "continue") {
|
|
20431
20345
|
return runPublicInstructionSeatResume({
|
|
20432
20346
|
runId: admitted.runId,
|
|
20347
|
+
runDirectory: admitted.runDirectory,
|
|
20433
20348
|
summons: { instruction: readableGateItem(chain.passes.at(-1)?.receipt) }
|
|
20434
20349
|
}, envForCourtContinue(env), io);
|
|
20435
20350
|
}
|
|
20436
|
-
if (admitted.role === "secretariat") {
|
|
20437
|
-
const pass = chain.passes.at(-1);
|
|
20438
|
-
const receipt = pass?.receipt ?? passedReceipt;
|
|
20439
|
-
if (receipt !== void 0) {
|
|
20440
|
-
await env.sessionAppender(env.principalAuthority, admitted.principal, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, {
|
|
20441
|
-
officer: "countersign",
|
|
20442
|
-
receipt,
|
|
20443
|
-
...officerRunId === void 0 ? {} : { runId: officerRunId }
|
|
20444
|
-
});
|
|
20445
|
-
}
|
|
20446
|
-
}
|
|
20447
20351
|
}
|
|
20448
20352
|
if (turn.terminal === void 0) throw new Error(`audited ${admitted.role} submission did not settle`);
|
|
20449
|
-
|
|
20450
|
-
admitted,
|
|
20451
|
-
env.principalAuthority,
|
|
20452
|
-
turn.terminal,
|
|
20453
|
-
packageFaultScope(admitted, env, io)
|
|
20454
|
-
);
|
|
20455
|
-
turn = { ...turn, terminal };
|
|
20456
|
-
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
20353
|
+
await presentTerminal(turn.terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
20457
20354
|
return turn;
|
|
20458
20355
|
}
|
|
20459
20356
|
var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, WORKER_ROUTING_STATUSES, WORKER_STATUS_REASK, DOCTOR_ROUTING_STATUSES, DOCTOR_STATUS_REASK, POST_SUBMISSION_ROUTING, UNREADABLE_REASK_EXHAUSTED, GATE_CHILD_ROLES;
|
|
@@ -20464,21 +20361,18 @@ var init_instruction_seat_run = __esm({
|
|
|
20464
20361
|
init_role_run_placement();
|
|
20465
20362
|
init_role_run_relocation();
|
|
20466
20363
|
init_session_opening_materials();
|
|
20467
|
-
init_archivist_record_pointer();
|
|
20468
20364
|
init_doctor_auditor();
|
|
20469
20365
|
init_gatekeeper_role();
|
|
20470
20366
|
init_submission_errors();
|
|
20471
20367
|
init_review_submission();
|
|
20472
20368
|
init_judge_role();
|
|
20473
20369
|
init_worker_submission_contracts();
|
|
20474
|
-
init_secretariat_contracts();
|
|
20475
20370
|
init_readable_gate_item();
|
|
20476
20371
|
init_receipt_delivery_policy();
|
|
20477
20372
|
init_run_terminal_artifacts();
|
|
20478
20373
|
init_submission_gate();
|
|
20479
20374
|
init_submission_ledger();
|
|
20480
20375
|
init_public_role_summons();
|
|
20481
|
-
init_session_assistant_usage();
|
|
20482
20376
|
init_submission_gate();
|
|
20483
20377
|
init_run_ticket_number();
|
|
20484
20378
|
init_notary_source_run();
|
|
@@ -20548,7 +20442,7 @@ __export(public_role_summons_exports, {
|
|
|
20548
20442
|
import { execFile as execFile3 } from "node:child_process";
|
|
20549
20443
|
import { existsSync as existsSync9 } from "node:fs";
|
|
20550
20444
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
20551
|
-
import { join as
|
|
20445
|
+
import { join as join20 } from "node:path";
|
|
20552
20446
|
import { promisify as promisify3 } from "node:util";
|
|
20553
20447
|
function createCapturingIo() {
|
|
20554
20448
|
const chunks = [];
|
|
@@ -20572,7 +20466,7 @@ function parentDir(path) {
|
|
|
20572
20466
|
function walkPackageRoot(start) {
|
|
20573
20467
|
let dir = start;
|
|
20574
20468
|
for (let i = 0; i < 12; i += 1) {
|
|
20575
|
-
if (existsSync9(
|
|
20469
|
+
if (existsSync9(join20(dir, "package.json")) && existsSync9(join20(dir, "souls"))) {
|
|
20576
20470
|
return dir;
|
|
20577
20471
|
}
|
|
20578
20472
|
const parent = parentDir(dir);
|
|
@@ -20791,6 +20685,7 @@ async function summonPublicRole(options) {
|
|
|
20791
20685
|
const stepped = await runPrepared(parse, (env) => runPublicInstructionSeatResume2(
|
|
20792
20686
|
{
|
|
20793
20687
|
runId: resumeRunId,
|
|
20688
|
+
...options.resumeRunDirectory === void 0 ? {} : { runDirectory: options.resumeRunDirectory },
|
|
20794
20689
|
summons: {
|
|
20795
20690
|
instruction,
|
|
20796
20691
|
instructionEmpty: instruction.length === 0
|
|
@@ -20807,10 +20702,13 @@ async function summonPublicRole(options) {
|
|
|
20807
20702
|
result = stepped.ok;
|
|
20808
20703
|
}
|
|
20809
20704
|
const stderr = captured?.stderrText();
|
|
20810
|
-
|
|
20811
|
-
|
|
20812
|
-
|
|
20813
|
-
|
|
20705
|
+
let runDirectory = result.admitted?.runDirectory;
|
|
20706
|
+
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
20707
|
+
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
20708
|
+
home,
|
|
20709
|
+
result.terminal.runId
|
|
20710
|
+
) ?? runDirectory;
|
|
20711
|
+
}
|
|
20814
20712
|
return {
|
|
20815
20713
|
exitCode: result.exitCode,
|
|
20816
20714
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -20891,8 +20789,12 @@ async function summonGateOfficer(options) {
|
|
|
20891
20789
|
}
|
|
20892
20790
|
let gateReviewInstruction;
|
|
20893
20791
|
if (options.reask === void 0 && options.submission !== void 0) {
|
|
20894
|
-
const {
|
|
20895
|
-
|
|
20792
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
20793
|
+
const blindTicketCourt = options.officer === "notary" && isTicketCourtCountersignSource2(options.sourceRunDirectory);
|
|
20794
|
+
if (!blindTicketCourt) {
|
|
20795
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
20796
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
20797
|
+
}
|
|
20896
20798
|
}
|
|
20897
20799
|
const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
20898
20800
|
const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
|
|
@@ -21103,7 +21005,7 @@ var init_compliance_transport = __esm({
|
|
|
21103
21005
|
});
|
|
21104
21006
|
|
|
21105
21007
|
// src/role-run-relocation.ts
|
|
21106
|
-
import { dirname as dirname14, join as
|
|
21008
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
21107
21009
|
async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
|
|
21108
21010
|
if (recordedPath === currentPath) return true;
|
|
21109
21011
|
if (typeof recordedPath !== "string") return false;
|
|
@@ -21126,8 +21028,7 @@ async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirect
|
|
|
21126
21028
|
if (rewriteRunDirectoryPathValue(recordedPathIdentity, unbound.runDirectory, runDirectory) !== currentPathIdentity) {
|
|
21127
21029
|
return false;
|
|
21128
21030
|
}
|
|
21129
|
-
|
|
21130
|
-
return placed !== void 0 && physicalPathIdentity(placed) === runDirectory;
|
|
21031
|
+
return true;
|
|
21131
21032
|
}
|
|
21132
21033
|
return false;
|
|
21133
21034
|
}
|
|
@@ -21156,6 +21057,7 @@ __export(run_lifecycle_exports, {
|
|
|
21156
21057
|
buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
|
|
21157
21058
|
clearCurrentCourt: () => clearCurrentCourt,
|
|
21158
21059
|
describeErrorIdentity: () => describeErrorIdentity,
|
|
21060
|
+
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
21159
21061
|
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
21160
21062
|
findRunDirectoryById: () => findRunDirectoryById,
|
|
21161
21063
|
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
@@ -21168,10 +21070,12 @@ __export(run_lifecycle_exports, {
|
|
|
21168
21070
|
readRoleRunState: () => readRoleRunState,
|
|
21169
21071
|
readRunParentPath: () => readRunParentPath,
|
|
21170
21072
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
21073
|
+
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
21171
21074
|
writeRoleRunState: () => writeRoleRunState
|
|
21172
21075
|
});
|
|
21076
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
21173
21077
|
import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
|
|
21174
|
-
import { basename as
|
|
21078
|
+
import { basename as basename10, join as join22 } from "node:path";
|
|
21175
21079
|
function buildAutoResumeContinuationPrompt() {
|
|
21176
21080
|
return RESUME_TRANSPORT_ENVELOPE;
|
|
21177
21081
|
}
|
|
@@ -21185,7 +21089,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
21185
21089
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
21186
21090
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
21187
21091
|
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
21188
|
-
const sourceRunPath =
|
|
21092
|
+
const sourceRunPath = admittedSourceRunPath(record);
|
|
21189
21093
|
let sourceRun;
|
|
21190
21094
|
if (isRecord(record.sourceRun)) {
|
|
21191
21095
|
const sr = record.sourceRun;
|
|
@@ -21468,7 +21372,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
21468
21372
|
},
|
|
21469
21373
|
relocate(nextRunDirectory) {
|
|
21470
21374
|
currentRunDirectory = nextRunDirectory;
|
|
21471
|
-
currentLockPath =
|
|
21375
|
+
currentLockPath = join22(nextRunDirectory, WRITER_LOCK_FILE);
|
|
21472
21376
|
},
|
|
21473
21377
|
async release() {
|
|
21474
21378
|
if (released) return;
|
|
@@ -21507,10 +21411,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21507
21411
|
};
|
|
21508
21412
|
const reportReadFailure = (error) => {
|
|
21509
21413
|
reportDiagnostic(
|
|
21510
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
21414
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join22(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
21511
21415
|
);
|
|
21512
21416
|
};
|
|
21513
|
-
const lockPath =
|
|
21417
|
+
const lockPath = join22(runDirectory, WRITER_LOCK_FILE);
|
|
21514
21418
|
let lastAutopsy = { verdict: "absent" };
|
|
21515
21419
|
let lastReclaimFailure;
|
|
21516
21420
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -21564,10 +21468,19 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21564
21468
|
lastReclaimFailure === void 0 ? void 0 : errnoOf(lastReclaimFailure)
|
|
21565
21469
|
);
|
|
21566
21470
|
}
|
|
21567
|
-
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
21471
|
+
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
21472
|
+
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
21473
|
+
const parsed = parseRunLeaf(basename10(knownRunDirectory));
|
|
21474
|
+
if (parsed === void 0 || parsed.runId !== runId) {
|
|
21475
|
+
throw new CliUsageError(
|
|
21476
|
+
`run directory does not match run id ${runId}: ${knownRunDirectory}`
|
|
21477
|
+
);
|
|
21478
|
+
}
|
|
21479
|
+
return knownRunDirectory;
|
|
21480
|
+
}
|
|
21568
21481
|
if (runId.trim() === "") return void 0;
|
|
21569
21482
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
21570
|
-
const booksRoot =
|
|
21483
|
+
const booksRoot = join22(ledgerHome, "books");
|
|
21571
21484
|
let bookKeys;
|
|
21572
21485
|
try {
|
|
21573
21486
|
bookKeys = await readdir3(booksRoot);
|
|
@@ -21581,13 +21494,16 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
21581
21494
|
onlyRole
|
|
21582
21495
|
);
|
|
21583
21496
|
}
|
|
21497
|
+
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
21498
|
+
if (existsSync10(recordedPath)) return recordedPath;
|
|
21499
|
+
const parsed = parseRunLeaf(basename10(recordedPath));
|
|
21500
|
+
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
21501
|
+
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
21502
|
+
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
21503
|
+
}
|
|
21584
21504
|
async function readRunParentPath(runDirectory) {
|
|
21585
21505
|
const record = readPageSync(runDirectory, "admitted");
|
|
21586
|
-
|
|
21587
|
-
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
21588
|
-
return record.sourceRunPath;
|
|
21589
|
-
}
|
|
21590
|
-
return void 0;
|
|
21506
|
+
return admittedSourceRunPath(record);
|
|
21591
21507
|
}
|
|
21592
21508
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
21593
21509
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
@@ -21602,6 +21518,10 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
21602
21518
|
}
|
|
21603
21519
|
}
|
|
21604
21520
|
async function findLatestRunIdForSeatTicket(input) {
|
|
21521
|
+
const found = await findLatestRunForSeatTicket(input);
|
|
21522
|
+
return found?.runId;
|
|
21523
|
+
}
|
|
21524
|
+
async function findLatestRunForSeatTicket(input) {
|
|
21605
21525
|
if (input.parentRunPath.trim() === "") {
|
|
21606
21526
|
return void 0;
|
|
21607
21527
|
}
|
|
@@ -21610,7 +21530,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
21610
21530
|
let runDirectories;
|
|
21611
21531
|
try {
|
|
21612
21532
|
runDirectories = await listBookRunDirectories(
|
|
21613
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
21533
|
+
input.ticketNumber === void 0 ? bookDir : join22(bookDir, String(input.ticketNumber))
|
|
21614
21534
|
);
|
|
21615
21535
|
} catch (error) {
|
|
21616
21536
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -21618,13 +21538,13 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
21618
21538
|
}
|
|
21619
21539
|
let best;
|
|
21620
21540
|
for (const runDirectory of runDirectories) {
|
|
21621
|
-
const parsed = parseRunLeaf(
|
|
21541
|
+
const parsed = parseRunLeaf(basename10(runDirectory));
|
|
21622
21542
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
21623
21543
|
const runId = parsed.runId;
|
|
21624
21544
|
const parentPath = await readRunParentPath(runDirectory);
|
|
21625
21545
|
if (!await retainedRunPathsMatch(parentPath, input.parentRunPath, input.parentRunPath)) continue;
|
|
21626
21546
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
21627
|
-
if (best === void 0 || runId > best) best = runId;
|
|
21547
|
+
if (best === void 0 || runId > best.runId) best = { runId, runDirectory };
|
|
21628
21548
|
}
|
|
21629
21549
|
return best;
|
|
21630
21550
|
}
|
|
@@ -21642,8 +21562,8 @@ function restoredTicketFields(fields) {
|
|
|
21642
21562
|
...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
|
|
21643
21563
|
};
|
|
21644
21564
|
}
|
|
21645
|
-
async function loadResumableRunRecord(home, runId, authority) {
|
|
21646
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
21565
|
+
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
21566
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
21647
21567
|
if (runDirectory === void 0) {
|
|
21648
21568
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
21649
21569
|
}
|
|
@@ -21735,9 +21655,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
21735
21655
|
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
21736
21656
|
}
|
|
21737
21657
|
}
|
|
21738
|
-
|
|
21739
|
-
sourceRunPath = record.sourceRunPath;
|
|
21740
|
-
}
|
|
21658
|
+
sourceRunPath = admittedSourceRunPath(record);
|
|
21741
21659
|
if (isRecord(record.sourceRun)) {
|
|
21742
21660
|
const sr = record.sourceRun;
|
|
21743
21661
|
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
@@ -21813,16 +21731,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
21813
21731
|
);
|
|
21814
21732
|
}
|
|
21815
21733
|
}
|
|
21816
|
-
const
|
|
21817
|
-
|
|
21818
|
-
|
|
21819
|
-
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
21820
|
-
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
21821
|
-
home,
|
|
21822
|
-
referencedRunId,
|
|
21823
|
-
run.bookKey,
|
|
21824
|
-
referencedRole
|
|
21825
|
-
);
|
|
21734
|
+
const recordedSourceDirectory = sourceRunPath ?? sourceRun?.runDirectory;
|
|
21735
|
+
if (recordedSourceDirectory !== void 0) {
|
|
21736
|
+
const currentSourceRunDirectory = await resolveLiveRunDirectoryPath(recordedSourceDirectory, home, run.bookKey);
|
|
21826
21737
|
if (currentSourceRunDirectory !== void 0) {
|
|
21827
21738
|
sourceRunPath = currentSourceRunDirectory;
|
|
21828
21739
|
if (sourceRun !== void 0) {
|
|
@@ -21880,14 +21791,19 @@ function seatLoadedResult(loaded, admitted) {
|
|
|
21880
21791
|
run: loaded.run
|
|
21881
21792
|
};
|
|
21882
21793
|
}
|
|
21883
|
-
async function peekRoleRunRole(home, runId) {
|
|
21884
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
21794
|
+
async function peekRoleRunRole(home, runId, options) {
|
|
21795
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, options?.runDirectory);
|
|
21885
21796
|
if (runDirectory === void 0) return void 0;
|
|
21886
21797
|
const run = await readRoleRunIdentity(runDirectory);
|
|
21887
21798
|
return run?.role;
|
|
21888
21799
|
}
|
|
21889
|
-
async function loadResumablePublicRole(home, runId, authority) {
|
|
21890
|
-
const loaded = await loadResumableRunRecord(
|
|
21800
|
+
async function loadResumablePublicRole(home, runId, authority, options) {
|
|
21801
|
+
const loaded = await loadResumableRunRecord(
|
|
21802
|
+
home,
|
|
21803
|
+
runId,
|
|
21804
|
+
authority,
|
|
21805
|
+
options?.runDirectory
|
|
21806
|
+
);
|
|
21891
21807
|
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
21892
21808
|
}
|
|
21893
21809
|
function admitResumedRole(loaded) {
|
|
@@ -21901,23 +21817,24 @@ function admitResumedRole(loaded) {
|
|
|
21901
21817
|
const base = resumedBaseAdmitted(loaded);
|
|
21902
21818
|
switch (record.admission) {
|
|
21903
21819
|
case "instruction": {
|
|
21820
|
+
const withSource = fields.sourceRunPath === void 0 ? base : { ...base, sourceRunPath: fields.sourceRunPath };
|
|
21904
21821
|
if (packagedResumeSourcePath(role)) {
|
|
21905
21822
|
const admitted = {
|
|
21906
21823
|
role: "inspector",
|
|
21907
|
-
...
|
|
21908
|
-
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
21824
|
+
...withSource
|
|
21909
21825
|
};
|
|
21910
21826
|
return admitted;
|
|
21911
21827
|
}
|
|
21912
21828
|
return {
|
|
21913
21829
|
role,
|
|
21914
|
-
...
|
|
21830
|
+
...withSource
|
|
21915
21831
|
};
|
|
21916
21832
|
}
|
|
21917
21833
|
case "court-materials": {
|
|
21918
21834
|
const admitted = {
|
|
21919
21835
|
role: "countersign",
|
|
21920
|
-
...base
|
|
21836
|
+
...base,
|
|
21837
|
+
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
21921
21838
|
};
|
|
21922
21839
|
return admitted;
|
|
21923
21840
|
}
|
|
@@ -22130,7 +22047,6 @@ var init_run_lifecycle = __esm({
|
|
|
22130
22047
|
|
|
22131
22048
|
// src/public-cli/post-admission.ts
|
|
22132
22049
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
22133
|
-
import { existsSync as existsSync10 } from "node:fs";
|
|
22134
22050
|
function describeCaughtError(error) {
|
|
22135
22051
|
if (error instanceof Error) {
|
|
22136
22052
|
const code = error.code;
|
|
@@ -22165,14 +22081,14 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
22165
22081
|
}
|
|
22166
22082
|
async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLease) {
|
|
22167
22083
|
const home = homeFromRunDirectory(admitted.runDirectory);
|
|
22168
|
-
const found = await
|
|
22169
|
-
if (found === void 0
|
|
22084
|
+
const found = await resolveLiveRunDirectoryPath(admitted.runDirectory, home);
|
|
22085
|
+
if (found === void 0) {
|
|
22170
22086
|
throw new Error(
|
|
22171
22087
|
`admitted run ${admitted.runId} missing after host turn; not found under ${home}`
|
|
22172
22088
|
);
|
|
22173
22089
|
}
|
|
22174
22090
|
let relocation;
|
|
22175
|
-
if (found !==
|
|
22091
|
+
if (found !== admitted.runDirectory) {
|
|
22176
22092
|
const oldRunDirectory = admitted.runDirectory;
|
|
22177
22093
|
const coords = { ...authority.decode(admitted.principal) };
|
|
22178
22094
|
rewritePrincipalSessionPaths(
|
|
@@ -22190,7 +22106,7 @@ async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLe
|
|
|
22190
22106
|
relocation = { oldRunDirectory, newRunDirectory: found };
|
|
22191
22107
|
}
|
|
22192
22108
|
if (admitted.ticketNumber === void 0) {
|
|
22193
|
-
const boardTicket = await readBoardTicketNumber(found
|
|
22109
|
+
const boardTicket = await readBoardTicketNumber(found);
|
|
22194
22110
|
if (boardTicket !== void 0) {
|
|
22195
22111
|
admitted.ticketNumber = boardTicket;
|
|
22196
22112
|
}
|
|
@@ -23227,10 +23143,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
23227
23143
|
return { exitCode: error instanceof CliUsageError ? 2 : 1 };
|
|
23228
23144
|
}
|
|
23229
23145
|
}
|
|
23230
|
-
async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
23146
|
+
async function pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
23231
23147
|
let foundRunDirectory;
|
|
23232
23148
|
try {
|
|
23233
|
-
foundRunDirectory = await findRunDirectoryById(home, runId);
|
|
23149
|
+
foundRunDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
23234
23150
|
} catch {
|
|
23235
23151
|
return false;
|
|
23236
23152
|
}
|
|
@@ -23255,8 +23171,8 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
23255
23171
|
);
|
|
23256
23172
|
return true;
|
|
23257
23173
|
}
|
|
23258
|
-
async function presentLocatedResumeFailure(home, runId, authority, io, thrown) {
|
|
23259
|
-
return await pointExistingRunFailure(home, runId, authority, io, thrown);
|
|
23174
|
+
async function presentLocatedResumeFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
23175
|
+
return await pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory);
|
|
23260
23176
|
}
|
|
23261
23177
|
function writeResumeFailurePointer(io, errorPath) {
|
|
23262
23178
|
io.stderr(formatCliDiagnostic(`\u7EED\u8DD1\u5931\u8D25\uFF0C\u5F53\u6B21\u9519\u8BEF\u8BB0\u5F55\uFF1A${errorPath}`));
|
|
@@ -29357,10 +29273,10 @@ var init_analyst_book_key = __esm({
|
|
|
29357
29273
|
// src/atomic-write.ts
|
|
29358
29274
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
29359
29275
|
import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
|
|
29360
|
-
import { dirname as dirname15, join as
|
|
29276
|
+
import { dirname as dirname15, join as join23 } from "node:path";
|
|
29361
29277
|
async function writeFileAtomically(destination, contents, options) {
|
|
29362
29278
|
const parent = dirname15(destination);
|
|
29363
|
-
const temporary =
|
|
29279
|
+
const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
29364
29280
|
try {
|
|
29365
29281
|
await writeFile4(temporary, contents, options);
|
|
29366
29282
|
await rename2(temporary, destination);
|
|
@@ -29377,12 +29293,12 @@ var init_atomic_write = __esm({
|
|
|
29377
29293
|
|
|
29378
29294
|
// src/analyst-index.ts
|
|
29379
29295
|
import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
29380
|
-
import { dirname as dirname16, join as
|
|
29296
|
+
import { dirname as dirname16, join as join24 } from "node:path";
|
|
29381
29297
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
29382
29298
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
29383
29299
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
29384
29300
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
29385
|
-
const lockPath =
|
|
29301
|
+
const lockPath = join24(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
29386
29302
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
29387
29303
|
const startedAt = Date.now();
|
|
29388
29304
|
while (true) {
|
|
@@ -29409,7 +29325,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
29409
29325
|
}
|
|
29410
29326
|
}
|
|
29411
29327
|
function analystLibraryIndexPath(ledgerHome) {
|
|
29412
|
-
return
|
|
29328
|
+
return join24(ledgerHome, "analyst", "library-index.json");
|
|
29413
29329
|
}
|
|
29414
29330
|
function rowFromIssueMetricsPage(page) {
|
|
29415
29331
|
return {
|
|
@@ -29702,6 +29618,70 @@ var init_analyst_cohort = __esm({
|
|
|
29702
29618
|
}
|
|
29703
29619
|
});
|
|
29704
29620
|
|
|
29621
|
+
// src/archivist-record-pointer.ts
|
|
29622
|
+
import { basename as basename11, join as join25 } from "node:path";
|
|
29623
|
+
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
29624
|
+
const where = `${parentRunDirectory} officers`;
|
|
29625
|
+
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
29626
|
+
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
29627
|
+
}
|
|
29628
|
+
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
29629
|
+
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
29630
|
+
}
|
|
29631
|
+
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
29632
|
+
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
29633
|
+
let sessionFile = raw.sessionFile;
|
|
29634
|
+
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
29635
|
+
const leaf = parseRunLeaf(basename11(recordedRunDirectory));
|
|
29636
|
+
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
29637
|
+
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
29638
|
+
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
29639
|
+
recordedRunDirectory,
|
|
29640
|
+
homeFromRunDirectory(parentRunDirectory),
|
|
29641
|
+
parentIdentity.bookKey
|
|
29642
|
+
);
|
|
29643
|
+
if (currentRunDirectory !== void 0) {
|
|
29644
|
+
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
29645
|
+
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
29646
|
+
}
|
|
29647
|
+
}
|
|
29648
|
+
return {
|
|
29649
|
+
sessionFile,
|
|
29650
|
+
...officer === void 0 ? {} : { officer },
|
|
29651
|
+
...runDirectory === void 0 ? {} : { runDirectory }
|
|
29652
|
+
};
|
|
29653
|
+
}
|
|
29654
|
+
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
29655
|
+
const { records, diagnostics } = await readSitianRecords(join25(parentRunDirectory, RUN_HISTORY_FILE));
|
|
29656
|
+
if (diagnostics.length > 0) {
|
|
29657
|
+
throw new Error(
|
|
29658
|
+
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
29659
|
+
);
|
|
29660
|
+
}
|
|
29661
|
+
return latestOfficerPointersFromRecords(records);
|
|
29662
|
+
}
|
|
29663
|
+
async function readOfficerPointers(parentRunDirectory) {
|
|
29664
|
+
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
29665
|
+
return Promise.all(
|
|
29666
|
+
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
29667
|
+
);
|
|
29668
|
+
}
|
|
29669
|
+
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
29670
|
+
var init_archivist_record_pointer = __esm({
|
|
29671
|
+
"src/archivist-record-pointer.ts"() {
|
|
29672
|
+
"use strict";
|
|
29673
|
+
init_unknown_value();
|
|
29674
|
+
init_run_dossier();
|
|
29675
|
+
init_run_dossier_files();
|
|
29676
|
+
init_sitian_facade();
|
|
29677
|
+
init_activation_ledger_topology();
|
|
29678
|
+
init_run_lifecycle();
|
|
29679
|
+
init_role_run_relocation();
|
|
29680
|
+
init_role_run_placement();
|
|
29681
|
+
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
29682
|
+
}
|
|
29683
|
+
});
|
|
29684
|
+
|
|
29705
29685
|
// src/analyst-gate-cycles-read.ts
|
|
29706
29686
|
function isParentAttemptBindingRow(row) {
|
|
29707
29687
|
return row.type === "custom" && row.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
|
|
@@ -32430,14 +32410,19 @@ async function runAkRole(argv2, env) {
|
|
|
32430
32410
|
env = { ...env, freshSummons: true };
|
|
32431
32411
|
}
|
|
32432
32412
|
if (parsed.command === "resume") {
|
|
32433
|
-
|
|
32413
|
+
let resumeRequest = parseResumeRequest(parsed.args);
|
|
32434
32414
|
resumeFailureContext = {
|
|
32435
32415
|
home,
|
|
32436
32416
|
runId: resumeRequest.runId,
|
|
32437
32417
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
32438
32418
|
};
|
|
32419
|
+
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
32420
|
+
if (runDirectory !== void 0) {
|
|
32421
|
+
resumeRequest = { ...resumeRequest, runDirectory };
|
|
32422
|
+
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
32423
|
+
}
|
|
32439
32424
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
32440
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
32425
|
+
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
32441
32426
|
const seatRole = resumeRole ?? "judge";
|
|
32442
32427
|
const seat = resolveEffectiveSeat(
|
|
32443
32428
|
parts.config,
|
|
@@ -32461,12 +32446,18 @@ async function runAkRole(argv2, env) {
|
|
|
32461
32446
|
let current = result;
|
|
32462
32447
|
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true && !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
32463
32448
|
const parentRunId = current.admitted.correlationId;
|
|
32449
|
+
const parentSource = admittedSourceRunPath(current.admitted);
|
|
32464
32450
|
resumeFailureContext = {
|
|
32465
32451
|
home,
|
|
32466
32452
|
runId: parentRunId,
|
|
32453
|
+
...parentSource === void 0 ? {} : { runDirectory: parentSource },
|
|
32467
32454
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
32468
32455
|
};
|
|
32469
|
-
const parentRole = await peekRoleRunRole(
|
|
32456
|
+
const parentRole = await peekRoleRunRole(
|
|
32457
|
+
home,
|
|
32458
|
+
parentRunId,
|
|
32459
|
+
parentSource === void 0 ? void 0 : { runDirectory: parentSource }
|
|
32460
|
+
);
|
|
32470
32461
|
if (parentRole === void 0) break;
|
|
32471
32462
|
const parentSeat = resolveEffectiveSeat(
|
|
32472
32463
|
parts.config,
|
|
@@ -32518,7 +32509,8 @@ async function runAkRole(argv2, env) {
|
|
|
32518
32509
|
resumeFailureContext.runId,
|
|
32519
32510
|
resumeFailureContext.authority,
|
|
32520
32511
|
io,
|
|
32521
|
-
error
|
|
32512
|
+
error,
|
|
32513
|
+
resumeFailureContext.runDirectory
|
|
32522
32514
|
)) {
|
|
32523
32515
|
return {
|
|
32524
32516
|
exitCode: error instanceof CliUsageError ? 2 : 1,
|