@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
|
@@ -530,7 +530,7 @@ var init_terminating_infrastructure = __esm({
|
|
|
530
530
|
|
|
531
531
|
// src/review-submission.ts
|
|
532
532
|
import { Type as Type2 } from "typebox";
|
|
533
|
-
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewSubmissionSchema;
|
|
533
|
+
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewStatusField, reviewNarrativeFields, reviewSubmissionSchema, courtClauseItemSchema, courtClausesField, courtReviewSubmissionSchema;
|
|
534
534
|
var init_review_submission = __esm({
|
|
535
535
|
"src/review-submission.ts"() {
|
|
536
536
|
"use strict";
|
|
@@ -538,28 +538,62 @@ var init_review_submission = __esm({
|
|
|
538
538
|
REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
|
|
539
539
|
REVIEW_QUEUE_WORDS = ["converged", "continue", "escalate"];
|
|
540
540
|
REVIEW_QUEUE_STATUSES = new Set(REVIEW_QUEUE_WORDS);
|
|
541
|
+
reviewStatusField = Type2.Union(
|
|
542
|
+
[
|
|
543
|
+
Type2.Literal(REVIEW_QUEUE_WORDS[0]),
|
|
544
|
+
Type2.Literal(REVIEW_QUEUE_WORDS[1]),
|
|
545
|
+
Type2.Literal(REVIEW_QUEUE_WORDS[2])
|
|
546
|
+
],
|
|
547
|
+
{
|
|
548
|
+
description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
|
|
549
|
+
}
|
|
550
|
+
);
|
|
551
|
+
reviewNarrativeFields = {
|
|
552
|
+
findings: Type2.Optional(Type2.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
553
|
+
reason: Type2.Optional(Type2.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
|
|
554
|
+
violations: Type2.Optional(Type2.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
|
|
555
|
+
conflicts: Type2.Optional(Type2.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
|
|
556
|
+
fix: Type2.Optional(Type2.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
|
|
557
|
+
classes: Type2.Optional(Type2.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
558
|
+
note: Type2.Optional(Type2.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
|
|
559
|
+
evidence: Type2.Optional(Type2.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
560
|
+
decisionGate: Type2.Optional(Type2.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" }))
|
|
561
|
+
};
|
|
541
562
|
reviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
542
|
-
Type2.Object(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
+
Type2.Object(
|
|
564
|
+
{
|
|
565
|
+
status: reviewStatusField,
|
|
566
|
+
...reviewNarrativeFields
|
|
567
|
+
},
|
|
568
|
+
{ additionalProperties: true }
|
|
569
|
+
)
|
|
570
|
+
);
|
|
571
|
+
courtClauseItemSchema = Type2.Object(
|
|
572
|
+
{
|
|
573
|
+
clause: Type2.String({
|
|
574
|
+
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"
|
|
575
|
+
}),
|
|
576
|
+
ownerUuid: Type2.Union([Type2.String(), Type2.Null()], {
|
|
577
|
+
description: "\u63A8\u51FA\u8BE5\u6761\u7684\u965B\u4E0B\u539F\u8BDD uuid\uFF1B\u65E0\u539F\u8BDD\u5219 null"
|
|
578
|
+
}),
|
|
579
|
+
derivation: Type2.String({
|
|
580
|
+
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"
|
|
581
|
+
})
|
|
582
|
+
},
|
|
583
|
+
{ additionalProperties: true }
|
|
584
|
+
);
|
|
585
|
+
courtClausesField = Type2.Array(courtClauseItemSchema, {
|
|
586
|
+
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"
|
|
587
|
+
});
|
|
588
|
+
courtReviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
589
|
+
Type2.Object(
|
|
590
|
+
{
|
|
591
|
+
status: reviewStatusField,
|
|
592
|
+
...reviewNarrativeFields,
|
|
593
|
+
clauses: courtClausesField
|
|
594
|
+
},
|
|
595
|
+
{ additionalProperties: true }
|
|
596
|
+
)
|
|
563
597
|
);
|
|
564
598
|
}
|
|
565
599
|
});
|
|
@@ -1809,13 +1843,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
1809
1843
|
latest = { toolCallId: payload.toolCallId, role: payload.role, accepted: payload.accepted, at: row.timestamp };
|
|
1810
1844
|
}
|
|
1811
1845
|
}
|
|
1812
|
-
let officers = {};
|
|
1813
|
-
try {
|
|
1814
|
-
officers = latestOfficerPointersFromRecords(history);
|
|
1815
|
-
} catch (error) {
|
|
1816
|
-
if (!(error instanceof TypeError)) throw error;
|
|
1817
|
-
if (unreadable[RUN_HISTORY_FILE] === void 0) unreadable[RUN_HISTORY_FILE] = "malformed";
|
|
1818
|
-
}
|
|
1819
1846
|
const sessions = {};
|
|
1820
1847
|
for (const row of state) {
|
|
1821
1848
|
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
@@ -1833,7 +1860,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
1833
1860
|
if (typeof original === "string") original = join5(runDirectory, "session", basename5(original));
|
|
1834
1861
|
whole.host = { sessions, ...original === void 0 ? {} : { original } };
|
|
1835
1862
|
whole.submission = latest === void 0 ? {} : { latest };
|
|
1836
|
-
whole.officers = officers;
|
|
1837
1863
|
if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
|
|
1838
1864
|
return whole;
|
|
1839
1865
|
}
|
|
@@ -2158,7 +2184,7 @@ var init_diarist_contracts = __esm({
|
|
|
2158
2184
|
|
|
2159
2185
|
// src/secretariat-contracts.ts
|
|
2160
2186
|
import { Type as Type13 } from "typebox";
|
|
2161
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema
|
|
2187
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema;
|
|
2162
2188
|
var init_secretariat_contracts = __esm({
|
|
2163
2189
|
"src/secretariat-contracts.ts"() {
|
|
2164
2190
|
"use strict";
|
|
@@ -2183,8 +2209,6 @@ var init_secretariat_contracts = __esm({
|
|
|
2183
2209
|
)
|
|
2184
2210
|
);
|
|
2185
2211
|
secretariatVerdictSchema.required = [];
|
|
2186
|
-
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
2187
|
-
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
2188
2212
|
}
|
|
2189
2213
|
});
|
|
2190
2214
|
|
|
@@ -2217,7 +2241,6 @@ __export(packaged_role_registry_exports, {
|
|
|
2217
2241
|
packagedBaseIsRevision: () => packagedBaseIsRevision,
|
|
2218
2242
|
packagedBindsBoardTicket: () => packagedBindsBoardTicket,
|
|
2219
2243
|
packagedBoardPlacement: () => packagedBoardPlacement,
|
|
2220
|
-
packagedDurableOfficerEntry: () => packagedDurableOfficerEntry,
|
|
2221
2244
|
packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
|
|
2222
2245
|
packagedGateStageLabel: () => packagedGateStageLabel,
|
|
2223
2246
|
packagedGateSummon: () => packagedGateSummon,
|
|
@@ -2337,11 +2360,6 @@ function packagedAuditToolName(role) {
|
|
|
2337
2360
|
if (record === void 0 || !("auditTool" in record)) return void 0;
|
|
2338
2361
|
return record.auditTool;
|
|
2339
2362
|
}
|
|
2340
|
-
function packagedDurableOfficerEntry(officer) {
|
|
2341
|
-
return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
2342
|
-
(record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
|
|
2343
|
-
);
|
|
2344
|
-
}
|
|
2345
2363
|
function packagedPublicInstructionSubject(role) {
|
|
2346
2364
|
return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
2347
2365
|
(record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
|
|
@@ -2680,8 +2698,6 @@ var init_packaged_role_registry = __esm({
|
|
|
2680
2698
|
presentSettled: "always",
|
|
2681
2699
|
summonResume: false,
|
|
2682
2700
|
admission: "court-materials",
|
|
2683
|
-
/** Durable custom entry names this officer. */
|
|
2684
|
-
durableOfficerEntry: true,
|
|
2685
2701
|
sameParent: "none",
|
|
2686
2702
|
phases: [null],
|
|
2687
2703
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
@@ -2707,8 +2723,6 @@ var init_packaged_role_registry = __esm({
|
|
|
2707
2723
|
phases: [null],
|
|
2708
2724
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
2709
2725
|
settlement: "accepted",
|
|
2710
|
-
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
2711
|
-
projectCountersignTerminal: true,
|
|
2712
2726
|
activationFlags: [
|
|
2713
2727
|
{ field: "ticketNumber" }
|
|
2714
2728
|
],
|
|
@@ -4730,15 +4744,15 @@ var init_role_submission_declarations = __esm({
|
|
|
4730
4744
|
},
|
|
4731
4745
|
notary: {
|
|
4732
4746
|
label: "\u7B26\u5B9D\u90CE\u8F93\u51FA",
|
|
4733
|
-
description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\u3002",
|
|
4747
|
+
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",
|
|
4734
4748
|
promptSnippet: "\u63D0\u4EA4\u7B26\u5B9D\u90CE\u51B3\u8BAE",
|
|
4735
|
-
parameters:
|
|
4749
|
+
parameters: courtReviewSubmissionSchema
|
|
4736
4750
|
},
|
|
4737
4751
|
countersign: {
|
|
4738
4752
|
label: "\u7ED9\u4E8B\u4E2D\u8F93\u51FA",
|
|
4739
|
-
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\u3002",
|
|
4753
|
+
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
|
|
4740
4754
|
promptSnippet: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE",
|
|
4741
|
-
parameters:
|
|
4755
|
+
parameters: courtReviewSubmissionSchema
|
|
4742
4756
|
},
|
|
4743
4757
|
secretariat: {
|
|
4744
4758
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
@@ -4906,7 +4920,9 @@ var run_terminal_artifacts_exports = {};
|
|
|
4906
4920
|
__export(run_terminal_artifacts_exports, {
|
|
4907
4921
|
ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
|
|
4908
4922
|
TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
|
|
4923
|
+
isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
|
|
4909
4924
|
readRunTerminal: () => readRunTerminal,
|
|
4925
|
+
roleFromRunDirectory: () => roleFromRunDirectory,
|
|
4910
4926
|
runIdFromRunDirectory: () => runIdFromRunDirectory,
|
|
4911
4927
|
writeRunTerminal: () => writeRunTerminal
|
|
4912
4928
|
});
|
|
@@ -4962,6 +4978,12 @@ function withSubmittedPayloads(runDirectory, body) {
|
|
|
4962
4978
|
function runIdFromRunDirectory(runDirectory) {
|
|
4963
4979
|
return parseRunLeaf(basename6(runDirectory))?.runId;
|
|
4964
4980
|
}
|
|
4981
|
+
function roleFromRunDirectory(runDirectory) {
|
|
4982
|
+
return parseRunLeaf(basename6(runDirectory))?.role;
|
|
4983
|
+
}
|
|
4984
|
+
function isTicketCourtCountersignSource(runDirectory) {
|
|
4985
|
+
return roleFromRunDirectory(runDirectory) === "countersign";
|
|
4986
|
+
}
|
|
4965
4987
|
var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
|
|
4966
4988
|
var init_run_terminal_artifacts = __esm({
|
|
4967
4989
|
"src/run-terminal-artifacts.ts"() {
|
|
@@ -5072,6 +5094,18 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
5072
5094
|
);
|
|
5073
5095
|
}
|
|
5074
5096
|
if (outcome.kind === "accepted") {
|
|
5097
|
+
if (outcome.decisiveFacts?.directionUnsettled === true) {
|
|
5098
|
+
const receipt2 = thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome);
|
|
5099
|
+
return withOfficerRunId(
|
|
5100
|
+
{
|
|
5101
|
+
status: "needs_reask",
|
|
5102
|
+
officer,
|
|
5103
|
+
receipt: receipt2,
|
|
5104
|
+
receivedStatus: receivedDiscriminator(receipt2, "status")
|
|
5105
|
+
},
|
|
5106
|
+
summoned
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5075
5109
|
return withOfficerRunId(
|
|
5076
5110
|
projectOfficerPayloads(officer, thisCourt, outcome.status),
|
|
5077
5111
|
summoned
|
|
@@ -6411,12 +6445,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
6411
6445
|
const subjectDirectory = dirname8(dirname8(candidate));
|
|
6412
6446
|
const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname8(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve8(dirname8(subjectDirectory)) === resolve8(bookDirectory);
|
|
6413
6447
|
if (isLegacyUnboundLocator) {
|
|
6414
|
-
candidate = await
|
|
6415
|
-
options.home,
|
|
6416
|
-
identity2.runId,
|
|
6417
|
-
bookKey,
|
|
6418
|
-
identity2.role
|
|
6419
|
-
) ?? candidate;
|
|
6448
|
+
candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
|
|
6420
6449
|
}
|
|
6421
6450
|
}
|
|
6422
6451
|
const real = await requireRunDirectory(candidate, raw);
|
|
@@ -7560,6 +7589,11 @@ import {
|
|
|
7560
7589
|
writeFile as writeFile2
|
|
7561
7590
|
} from "node:fs/promises";
|
|
7562
7591
|
import { dirname as dirname9, isAbsolute as isAbsolute5, join as join12, resolve as resolve9 } from "node:path";
|
|
7592
|
+
function admittedSourceRunPath(admitted) {
|
|
7593
|
+
if (!isRecord(admitted)) return void 0;
|
|
7594
|
+
const path = admitted.sourceRunPath;
|
|
7595
|
+
return typeof path === "string" && path.trim() !== "" ? path : void 0;
|
|
7596
|
+
}
|
|
7563
7597
|
function normalizeAdmittedAttachment(raw) {
|
|
7564
7598
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
7565
7599
|
const record = raw;
|
|
@@ -7671,6 +7705,23 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubj
|
|
|
7671
7705
|
};
|
|
7672
7706
|
});
|
|
7673
7707
|
}
|
|
7708
|
+
function persistAdmittedAuditedSubmissionToolCallId(runDirectory, auditedSubmissionToolCallId) {
|
|
7709
|
+
const id = auditedSubmissionToolCallId.trim();
|
|
7710
|
+
if (id === "") {
|
|
7711
|
+
throw new Error("persistAdmittedAuditedSubmissionToolCallId requires a non-empty id");
|
|
7712
|
+
}
|
|
7713
|
+
if (readPageSync(runDirectory, "admitted") === void 0) return;
|
|
7714
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
7715
|
+
if (current.auditedSubmissionToolCallId === id) return void 0;
|
|
7716
|
+
return { ...current, auditedSubmissionToolCallId: id };
|
|
7717
|
+
});
|
|
7718
|
+
}
|
|
7719
|
+
function readAdmittedAuditedSubmissionToolCallId(runDirectory) {
|
|
7720
|
+
const page = readPageSync(runDirectory, "admitted");
|
|
7721
|
+
if (page === void 0) return void 0;
|
|
7722
|
+
const id = page.auditedSubmissionToolCallId;
|
|
7723
|
+
return typeof id === "string" && id.trim() !== "" ? id : void 0;
|
|
7724
|
+
}
|
|
7674
7725
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
7675
7726
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
7676
7727
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
@@ -9189,13 +9240,10 @@ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
|
9189
9240
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
9190
9241
|
return mapOwnedToSubmissionRows(owned);
|
|
9191
9242
|
}
|
|
9192
|
-
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId,
|
|
9243
|
+
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScope) {
|
|
9193
9244
|
if (attemptId.length === 0) return [];
|
|
9194
|
-
const
|
|
9195
|
-
|
|
9196
|
-
runId,
|
|
9197
|
-
home === void 0 ? {} : { home }
|
|
9198
|
-
);
|
|
9245
|
+
const scope = resolveReadScope(homeOrScope);
|
|
9246
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
9199
9247
|
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
9200
9248
|
}
|
|
9201
9249
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
@@ -9665,7 +9713,6 @@ __export(settlement_exports, {
|
|
|
9665
9713
|
LifecycleReadFailure: () => LifecycleReadFailure,
|
|
9666
9714
|
NAVIGATOR_POST_ROLE_GRACE_MS: () => NAVIGATOR_POST_ROLE_GRACE_MS,
|
|
9667
9715
|
appendRunAttemptHistory: () => appendRunAttemptHistory,
|
|
9668
|
-
attachPostAuditCountersignFact: () => attachPostAuditCountersignFact,
|
|
9669
9716
|
attachRecordedSubmissions: () => attachRecordedSubmissions,
|
|
9670
9717
|
classifyPostAdmissionFailure: () => classifyPostAdmissionFailure,
|
|
9671
9718
|
conciseChildDiagnostic: () => conciseChildDiagnostic,
|
|
@@ -9779,13 +9826,12 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
9779
9826
|
return { outcome: { kind: "accepted", role, payloads }, ...belonging };
|
|
9780
9827
|
}
|
|
9781
9828
|
async function sealedLedgerOutcome(admitted, role, scope) {
|
|
9782
|
-
const home = sealedLedgerHome(admitted);
|
|
9783
9829
|
if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
|
|
9784
9830
|
const thisCourt = await readAttemptScopedSubmissionRows(
|
|
9785
9831
|
admitted.projectRoot,
|
|
9786
9832
|
admitted.runId,
|
|
9787
9833
|
scope.courtAttemptId,
|
|
9788
|
-
|
|
9834
|
+
ledgerReadScope(admitted, scope)
|
|
9789
9835
|
);
|
|
9790
9836
|
return roleOutcomeFromRows(role, thisCourt);
|
|
9791
9837
|
}
|
|
@@ -10512,97 +10558,11 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
10512
10558
|
if (toolName === void 0) {
|
|
10513
10559
|
throw new Error(`accepted-seat settlement is not declared for ${admitted.role}`);
|
|
10514
10560
|
}
|
|
10515
|
-
|
|
10516
|
-
const record = packagedRoleMetadata(admitted.role);
|
|
10517
|
-
if (settled === void 0 || record === void 0 || !("projectCountersignTerminal" in record) || record.projectCountersignTerminal !== true) {
|
|
10518
|
-
return settled;
|
|
10519
|
-
}
|
|
10520
|
-
return applySecretariatCountersignTerminal(admitted, authority, settled, scope);
|
|
10561
|
+
return settleSealedSeat(admitted, authority, scope, { acceptedOnly: false });
|
|
10521
10562
|
}
|
|
10522
10563
|
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
10523
10564
|
return settleSeat(admitted, authority, scope);
|
|
10524
10565
|
}
|
|
10525
|
-
function countersignTerminalFromEntries(entries) {
|
|
10526
|
-
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
10527
|
-
const entry = entries[index];
|
|
10528
|
-
if (entry?.type !== "custom") continue;
|
|
10529
|
-
if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
|
|
10530
|
-
const data = isRecord(entry.data) ? entry.data : void 0;
|
|
10531
|
-
if (data === void 0 || !packagedDurableOfficerEntry(data.officer)) continue;
|
|
10532
|
-
if (data.receipt === void 0) continue;
|
|
10533
|
-
const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
|
|
10534
|
-
return {
|
|
10535
|
-
receipt: data.receipt,
|
|
10536
|
-
...runId === void 0 ? {} : { runId }
|
|
10537
|
-
};
|
|
10538
|
-
}
|
|
10539
|
-
return void 0;
|
|
10540
|
-
}
|
|
10541
|
-
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
10542
|
-
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
10543
|
-
return {
|
|
10544
|
-
...roleOutcome,
|
|
10545
|
-
decisiveFacts: {
|
|
10546
|
-
...prior,
|
|
10547
|
-
[SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY]: officer
|
|
10548
|
-
}
|
|
10549
|
-
};
|
|
10550
|
-
}
|
|
10551
|
-
function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
10552
|
-
const payloads = roleOutcome.payloads ?? [];
|
|
10553
|
-
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
10554
|
-
const payload = payloads[index];
|
|
10555
|
-
if (!isRecord(payload)) continue;
|
|
10556
|
-
const status = payload.secretariatStatus;
|
|
10557
|
-
if (typeof status !== "string") continue;
|
|
10558
|
-
return status === "converged";
|
|
10559
|
-
}
|
|
10560
|
-
return false;
|
|
10561
|
-
}
|
|
10562
|
-
async function applySecretariatCountersignTerminal(admitted, authority, settled, scope) {
|
|
10563
|
-
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
10564
|
-
let entries = [];
|
|
10565
|
-
try {
|
|
10566
|
-
entries = await readBoundSessionEntries(coordinates.sessionFile);
|
|
10567
|
-
} catch (error) {
|
|
10568
|
-
if (!isEnoent(error)) {
|
|
10569
|
-
await noteSettlementFault(
|
|
10570
|
-
admitted.runDirectory,
|
|
10571
|
-
scope,
|
|
10572
|
-
`secretariat officer read failed beside lawful terminal: ${describeErrorIdentity(error)}`
|
|
10573
|
-
);
|
|
10574
|
-
}
|
|
10575
|
-
return settled;
|
|
10576
|
-
}
|
|
10577
|
-
const officer = countersignTerminalFromEntries(entries);
|
|
10578
|
-
if (officer === void 0) return settled;
|
|
10579
|
-
if (settled.roleOutcome.kind === "audit_escalation") {
|
|
10580
|
-
return {
|
|
10581
|
-
...settled,
|
|
10582
|
-
roleOutcome: withCountersignTerminalFact(
|
|
10583
|
-
{
|
|
10584
|
-
...settled.roleOutcome,
|
|
10585
|
-
payloads: [officer.receipt]
|
|
10586
|
-
},
|
|
10587
|
-
officer
|
|
10588
|
-
)
|
|
10589
|
-
};
|
|
10590
|
-
}
|
|
10591
|
-
if (settled.roleOutcome.kind === "accepted") {
|
|
10592
|
-
if (!acceptedSecretariatDefinesOfficerProjection(settled.roleOutcome)) {
|
|
10593
|
-
return settled;
|
|
10594
|
-
}
|
|
10595
|
-
return {
|
|
10596
|
-
...settled,
|
|
10597
|
-
roleOutcome: withCountersignTerminalFact(settled.roleOutcome, officer)
|
|
10598
|
-
};
|
|
10599
|
-
}
|
|
10600
|
-
return settled;
|
|
10601
|
-
}
|
|
10602
|
-
async function attachPostAuditCountersignFact(admitted, authority, terminal, scope) {
|
|
10603
|
-
if (admitted.role !== "secretariat") return terminal;
|
|
10604
|
-
return applySecretariatCountersignTerminal(admitted, authority, terminal, scope);
|
|
10605
|
-
}
|
|
10606
10566
|
async function publishFailureTerminal(admitted, failure, coordinates, onErrorPublished, scope) {
|
|
10607
10567
|
let historyFailure;
|
|
10608
10568
|
let historyFailed = false;
|
|
@@ -10768,7 +10728,6 @@ var init_settlement = __esm({
|
|
|
10768
10728
|
init_engine_detour_usage();
|
|
10769
10729
|
init_dossier_resolution();
|
|
10770
10730
|
init_invocation();
|
|
10771
|
-
init_secretariat_contracts();
|
|
10772
10731
|
init_navigator_invocation_identity();
|
|
10773
10732
|
init_packaged_role_registry();
|
|
10774
10733
|
init_receipt_delivery_policy();
|
|
@@ -10794,18 +10753,6 @@ var init_settlement = __esm({
|
|
|
10794
10753
|
// src/external-host-turn-loop.ts
|
|
10795
10754
|
import { existsSync as existsSync6 } from "node:fs";
|
|
10796
10755
|
import { basename as basename8 } from "node:path";
|
|
10797
|
-
async function resolveLiveRunDirectoryPath(recordedPath, home) {
|
|
10798
|
-
if (existsSync6(recordedPath)) return recordedPath;
|
|
10799
|
-
const parsed = parseRunLeaf(basename8(recordedPath));
|
|
10800
|
-
const bookKey = tryBookKeyFromAkRolesPath(recordedPath);
|
|
10801
|
-
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
10802
|
-
return await findRunDirectoryById(
|
|
10803
|
-
home,
|
|
10804
|
-
parsed.runId,
|
|
10805
|
-
bookKey,
|
|
10806
|
-
parsed.role
|
|
10807
|
-
);
|
|
10808
|
-
}
|
|
10809
10756
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
10810
10757
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
10811
10758
|
if (live === void 0) {
|
|
@@ -11000,9 +10947,9 @@ function createSerializedRoleTurnHost(execute) {
|
|
|
11000
10947
|
var init_external_host_turn_loop = __esm({
|
|
11001
10948
|
"src/external-host-turn-loop.ts"() {
|
|
11002
10949
|
"use strict";
|
|
11003
|
-
init_activation_ledger_topology();
|
|
11004
10950
|
init_settlement();
|
|
11005
10951
|
init_run_lifecycle();
|
|
10952
|
+
init_run_lifecycle();
|
|
11006
10953
|
init_receipt_delivery_policy();
|
|
11007
10954
|
init_role_run_placement();
|
|
11008
10955
|
init_role_run_relocation();
|
|
@@ -11909,99 +11856,6 @@ var init_session_opening_materials = __esm({
|
|
|
11909
11856
|
}
|
|
11910
11857
|
});
|
|
11911
11858
|
|
|
11912
|
-
// src/archivist-record-pointer.ts
|
|
11913
|
-
import { basename as basename9, join as join19 } from "node:path";
|
|
11914
|
-
function bookDirectOfficerRunPointer(options) {
|
|
11915
|
-
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
11916
|
-
const pointer = {
|
|
11917
|
-
version: 1,
|
|
11918
|
-
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
11919
|
-
officer: options.officer,
|
|
11920
|
-
sessionFile: options.sessionFile,
|
|
11921
|
-
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {},
|
|
11922
|
-
...submissionToolCallId === "" ? {} : { submissionToolCallId }
|
|
11923
|
-
};
|
|
11924
|
-
reportRunRecord(runDirectoryOfSessionFile(options.parentSessionFile), OFFICER_POINTER_RECORD_KIND, pointer, "submission-gate");
|
|
11925
|
-
return pointer;
|
|
11926
|
-
}
|
|
11927
|
-
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
11928
|
-
const where = `${parentRunDirectory} officers`;
|
|
11929
|
-
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
11930
|
-
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
11931
|
-
}
|
|
11932
|
-
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
11933
|
-
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
11934
|
-
}
|
|
11935
|
-
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
11936
|
-
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
11937
|
-
let sessionFile = raw.sessionFile;
|
|
11938
|
-
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
11939
|
-
const leaf = parseRunLeaf(basename9(recordedRunDirectory));
|
|
11940
|
-
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
11941
|
-
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
11942
|
-
const currentRunDirectory = await findRunDirectoryById(
|
|
11943
|
-
homeFromRunDirectory(parentRunDirectory),
|
|
11944
|
-
leaf.runId,
|
|
11945
|
-
parentIdentity.bookKey,
|
|
11946
|
-
leaf.role
|
|
11947
|
-
);
|
|
11948
|
-
if (currentRunDirectory !== void 0) {
|
|
11949
|
-
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
11950
|
-
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
11951
|
-
}
|
|
11952
|
-
}
|
|
11953
|
-
const submissionToolCallId = typeof raw.submissionToolCallId === "string" && raw.submissionToolCallId.trim() !== "" ? raw.submissionToolCallId : void 0;
|
|
11954
|
-
return {
|
|
11955
|
-
sessionFile,
|
|
11956
|
-
...officer === void 0 ? {} : { officer },
|
|
11957
|
-
...runDirectory === void 0 ? {} : { runDirectory },
|
|
11958
|
-
...submissionToolCallId === void 0 ? {} : { submissionToolCallId }
|
|
11959
|
-
};
|
|
11960
|
-
}
|
|
11961
|
-
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
11962
|
-
const { records, diagnostics } = await readSitianRecords(join19(parentRunDirectory, RUN_HISTORY_FILE));
|
|
11963
|
-
if (diagnostics.length > 0) {
|
|
11964
|
-
throw new Error(
|
|
11965
|
-
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
11966
|
-
);
|
|
11967
|
-
}
|
|
11968
|
-
return latestOfficerPointersFromRecords(records);
|
|
11969
|
-
}
|
|
11970
|
-
async function readOfficerPointers(parentRunDirectory) {
|
|
11971
|
-
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
11972
|
-
return Promise.all(
|
|
11973
|
-
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
11974
|
-
);
|
|
11975
|
-
}
|
|
11976
|
-
async function readDirectOfficerRunPointer(parentSessionFile, officer) {
|
|
11977
|
-
try {
|
|
11978
|
-
const parentRunDirectory = runDirectoryOfSessionFile(parentSessionFile);
|
|
11979
|
-
const pointer = await resolveOfficerPointer(
|
|
11980
|
-
(await readBookedOfficerPointers(parentRunDirectory))[officer],
|
|
11981
|
-
parentRunDirectory
|
|
11982
|
-
);
|
|
11983
|
-
if (pointer.officer !== officer) return void 0;
|
|
11984
|
-
return { ...pointer, officer, version: 1, kind: DIRECT_OFFICER_RUN_POINTER_KIND };
|
|
11985
|
-
} catch {
|
|
11986
|
-
return void 0;
|
|
11987
|
-
}
|
|
11988
|
-
}
|
|
11989
|
-
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
11990
|
-
var init_archivist_record_pointer = __esm({
|
|
11991
|
-
"src/archivist-record-pointer.ts"() {
|
|
11992
|
-
"use strict";
|
|
11993
|
-
init_unknown_value();
|
|
11994
|
-
init_run_dossier();
|
|
11995
|
-
init_run_dossier_files();
|
|
11996
|
-
init_sitian_facade();
|
|
11997
|
-
init_activation_ledger_topology();
|
|
11998
|
-
init_run_lifecycle();
|
|
11999
|
-
init_role_run_relocation();
|
|
12000
|
-
init_role_run_placement();
|
|
12001
|
-
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
12002
|
-
}
|
|
12003
|
-
});
|
|
12004
|
-
|
|
12005
11859
|
// src/doctor-auditor.ts
|
|
12006
11860
|
function createPiDoctorAuditor() {
|
|
12007
11861
|
return async (options) => {
|
|
@@ -12147,6 +12001,20 @@ var init_worker_submission_contracts = __esm({
|
|
|
12147
12001
|
});
|
|
12148
12002
|
|
|
12149
12003
|
// src/submission-gate.ts
|
|
12004
|
+
async function directoryForSummonedOfficer(officer, summoned) {
|
|
12005
|
+
if (summoned.admitted?.role === officer) {
|
|
12006
|
+
return summoned.admitted.runDirectory;
|
|
12007
|
+
}
|
|
12008
|
+
let dir = typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? summoned.runDirectory : summoned.admitted?.runDirectory;
|
|
12009
|
+
for (let hop = 0; hop < 8 && dir !== void 0; hop += 1) {
|
|
12010
|
+
const identity = await readRoleRunIdentity(dir);
|
|
12011
|
+
if (identity?.role === officer) return dir;
|
|
12012
|
+
const parent = await readRunParentPath(dir);
|
|
12013
|
+
if (parent === void 0 || parent === dir) break;
|
|
12014
|
+
dir = parent;
|
|
12015
|
+
}
|
|
12016
|
+
return void 0;
|
|
12017
|
+
}
|
|
12150
12018
|
function latestQueueStatus(terminal) {
|
|
12151
12019
|
const outcome = terminal?.roleOutcome;
|
|
12152
12020
|
if (outcome === void 0) return void 0;
|
|
@@ -12184,24 +12052,6 @@ function createDefaultGateOfficerSummon(options) {
|
|
|
12184
12052
|
});
|
|
12185
12053
|
};
|
|
12186
12054
|
}
|
|
12187
|
-
function bookDirectOfficerPointer(context, officer, result, summoned, toolCallId) {
|
|
12188
|
-
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask" && result.status !== "transport_failure") {
|
|
12189
|
-
return;
|
|
12190
|
-
}
|
|
12191
|
-
const parentFile = context.sessionManager?.getSessionFile?.();
|
|
12192
|
-
if (typeof parentFile !== "string" || parentFile.trim() === "") return;
|
|
12193
|
-
const sessionFile = sessionFileFromPublicSummon(summoned);
|
|
12194
|
-
if (sessionFile === void 0) {
|
|
12195
|
-
return;
|
|
12196
|
-
}
|
|
12197
|
-
bookDirectOfficerRunPointer({
|
|
12198
|
-
parentSessionFile: parentFile,
|
|
12199
|
-
officer,
|
|
12200
|
-
sessionFile,
|
|
12201
|
-
...typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? { runDirectory: summoned.runDirectory } : {},
|
|
12202
|
-
...toolCallId.trim() === "" ? {} : { submissionToolCallId: toolCallId }
|
|
12203
|
-
});
|
|
12204
|
-
}
|
|
12205
12055
|
async function requireSubmissionGate(options) {
|
|
12206
12056
|
let reask;
|
|
12207
12057
|
let reasksSpent = 0;
|
|
@@ -12219,17 +12069,13 @@ async function requireSubmissionGate(options) {
|
|
|
12219
12069
|
...reask === void 0 ? {} : { reask }
|
|
12220
12070
|
});
|
|
12221
12071
|
const gatekeeper = projected.result;
|
|
12222
|
-
if (projected.summoned !== void 0) {
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
options.toolCallId
|
|
12230
|
-
);
|
|
12231
|
-
} catch (error) {
|
|
12232
|
-
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
12072
|
+
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")) {
|
|
12073
|
+
const officerRunDirectory = await directoryForSummonedOfficer(
|
|
12074
|
+
projected.officer,
|
|
12075
|
+
projected.summoned
|
|
12076
|
+
);
|
|
12077
|
+
if (officerRunDirectory !== void 0) {
|
|
12078
|
+
persistAdmittedAuditedSubmissionToolCallId(officerRunDirectory, options.toolCallId);
|
|
12233
12079
|
}
|
|
12234
12080
|
}
|
|
12235
12081
|
if (gatekeeper.status === "converged") {
|
|
@@ -12237,7 +12083,11 @@ async function requireSubmissionGate(options) {
|
|
|
12237
12083
|
status: "converged",
|
|
12238
12084
|
officer: projected.officer,
|
|
12239
12085
|
receipt: gatekeeper.receipt,
|
|
12240
|
-
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
|
|
12086
|
+
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
12087
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
12088
|
+
// Keep the officer terminal for escalate / unsettled surfaces; parent
|
|
12089
|
+
// finals do not project other-seat tables (#1195).
|
|
12090
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
12241
12091
|
};
|
|
12242
12092
|
}
|
|
12243
12093
|
if (gatekeeper.status === "continue") {
|
|
@@ -12249,7 +12099,8 @@ async function requireSubmissionGate(options) {
|
|
|
12249
12099
|
};
|
|
12250
12100
|
}
|
|
12251
12101
|
if (gatekeeper.status === "needs_reask") {
|
|
12252
|
-
|
|
12102
|
+
const nestedIncomplete = projected.summoned?.terminal?.roleOutcome.kind === "accepted" && projected.summoned.terminal.roleOutcome.decisiveFacts?.directionUnsettled === true;
|
|
12103
|
+
if (nestedIncomplete || reasksSpent >= reaskLimit) {
|
|
12253
12104
|
return {
|
|
12254
12105
|
status: "needs_reask",
|
|
12255
12106
|
officer: projected.officer,
|
|
@@ -12276,7 +12127,9 @@ async function requireSubmissionGate(options) {
|
|
|
12276
12127
|
officer: projected.officer,
|
|
12277
12128
|
receipt: gatekeeper.receipt,
|
|
12278
12129
|
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
12279
|
-
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {}
|
|
12130
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
12131
|
+
// Keep the actual officer terminal so callers resume that seat.
|
|
12132
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
12280
12133
|
};
|
|
12281
12134
|
}
|
|
12282
12135
|
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
@@ -12286,11 +12139,11 @@ async function requireSubmissionGate(options) {
|
|
|
12286
12139
|
var init_submission_gate = __esm({
|
|
12287
12140
|
"src/submission-gate.ts"() {
|
|
12288
12141
|
"use strict";
|
|
12289
|
-
|
|
12142
|
+
init_invocation();
|
|
12143
|
+
init_run_lifecycle();
|
|
12290
12144
|
init_gatekeeper_role();
|
|
12291
12145
|
init_submission_errors();
|
|
12292
12146
|
init_receipt_delivery_policy();
|
|
12293
|
-
init_session_assistant_usage();
|
|
12294
12147
|
init_unknown_value();
|
|
12295
12148
|
}
|
|
12296
12149
|
});
|
|
@@ -12310,7 +12163,7 @@ __export(auditor_soul_exports, {
|
|
|
12310
12163
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
12311
12164
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
12312
12165
|
});
|
|
12313
|
-
import { basename as
|
|
12166
|
+
import { basename as basename9 } from "node:path";
|
|
12314
12167
|
function auditorSoulRelativePath(role) {
|
|
12315
12168
|
return `souls/${role}-auditor.md`;
|
|
12316
12169
|
}
|
|
@@ -12346,22 +12199,24 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
12346
12199
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
12347
12200
|
}
|
|
12348
12201
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
12349
|
-
const role = parseRunLeaf(
|
|
12202
|
+
const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
|
|
12350
12203
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
12351
12204
|
}
|
|
12352
|
-
async function readAuditorResumeBinding(
|
|
12353
|
-
const record = readPageSync(runDirectory, "admitted");
|
|
12205
|
+
async function readAuditorResumeBinding(admitted) {
|
|
12206
|
+
const record = readPageSync(admitted.runDirectory, "admitted");
|
|
12354
12207
|
if (record === void 0) return void 0;
|
|
12355
|
-
|
|
12356
|
-
|
|
12208
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
12209
|
+
if (sourceRunPath === void 0) return void 0;
|
|
12210
|
+
const subject = isAuditorSoulRole(record.auditorSubject) ? record.auditorSubject : subjectFromSourceDirectory(sourceRunPath);
|
|
12357
12211
|
if (subject === void 0) return void 0;
|
|
12358
|
-
return { subject, sourceRunDirectory:
|
|
12212
|
+
return { subject, sourceRunDirectory: sourceRunPath };
|
|
12359
12213
|
}
|
|
12360
12214
|
var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
|
|
12361
12215
|
var init_auditor_soul = __esm({
|
|
12362
12216
|
"src/auditor-soul.ts"() {
|
|
12363
12217
|
"use strict";
|
|
12364
12218
|
init_run_dossier();
|
|
12219
|
+
init_invocation();
|
|
12365
12220
|
init_role_run_placement();
|
|
12366
12221
|
init_unknown_value();
|
|
12367
12222
|
init_session_opening_materials();
|
|
@@ -12387,16 +12242,16 @@ var init_auditor_soul = __esm({
|
|
|
12387
12242
|
// src/public-cli/machine-method-skills.ts
|
|
12388
12243
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
12389
12244
|
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12390
|
-
import { join as
|
|
12245
|
+
import { join as join20 } from "node:path";
|
|
12391
12246
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
12392
12247
|
function skillRoot(home) {
|
|
12393
|
-
return
|
|
12248
|
+
return join20(home, ".agents/skills");
|
|
12394
12249
|
}
|
|
12395
12250
|
function installedMethodSkillPath(home, name) {
|
|
12396
12251
|
return installedSkillPath(skillRoot(home), name);
|
|
12397
12252
|
}
|
|
12398
12253
|
function installedSkillPath(root, name) {
|
|
12399
|
-
const path =
|
|
12254
|
+
const path = join20(root, name, "SKILL.md");
|
|
12400
12255
|
try {
|
|
12401
12256
|
if (!statSync5(path).isFile()) return void 0;
|
|
12402
12257
|
accessSync(path, constants2.R_OK);
|
|
@@ -12409,9 +12264,9 @@ function installedSkillPath(root, name) {
|
|
|
12409
12264
|
}
|
|
12410
12265
|
function linkedSkillRoot(home, host) {
|
|
12411
12266
|
if (host === "claude" || host === "claude-code") {
|
|
12412
|
-
return
|
|
12267
|
+
return join20(process.env.CLAUDE_CONFIG_DIR?.trim() || join20(home, ".claude"), "skills");
|
|
12413
12268
|
}
|
|
12414
|
-
if (host === "hermes") return
|
|
12269
|
+
if (host === "hermes") return join20(home, ".hermes/skills");
|
|
12415
12270
|
return void 0;
|
|
12416
12271
|
}
|
|
12417
12272
|
async function occupied(path) {
|
|
@@ -12468,7 +12323,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12468
12323
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
12469
12324
|
let unsourced = false;
|
|
12470
12325
|
for (const name of packagedMethodSkillNames()) {
|
|
12471
|
-
const path =
|
|
12326
|
+
const path = join20(canonical, name);
|
|
12472
12327
|
if (await occupied(path)) {
|
|
12473
12328
|
warnOccupied(path, stdout);
|
|
12474
12329
|
continue;
|
|
@@ -12498,9 +12353,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12498
12353
|
throw error;
|
|
12499
12354
|
}
|
|
12500
12355
|
for (const name of packagedMethodSkillNames()) {
|
|
12501
|
-
const target =
|
|
12356
|
+
const target = join20(canonical, name);
|
|
12502
12357
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12503
|
-
const link =
|
|
12358
|
+
const link = join20(root, name);
|
|
12504
12359
|
if (await occupied(link)) {
|
|
12505
12360
|
warnOccupied(link, stdout);
|
|
12506
12361
|
continue;
|
|
@@ -12908,7 +12763,6 @@ var init_auto_resume = __esm({
|
|
|
12908
12763
|
|
|
12909
12764
|
// src/public-cli/post-admission.ts
|
|
12910
12765
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12911
|
-
import { existsSync as existsSync11 } from "node:fs";
|
|
12912
12766
|
function describeCaughtError(error) {
|
|
12913
12767
|
if (error instanceof Error) {
|
|
12914
12768
|
const code = error.code;
|
|
@@ -12943,14 +12797,14 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12943
12797
|
}
|
|
12944
12798
|
async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLease) {
|
|
12945
12799
|
const home = homeFromRunDirectory(admitted.runDirectory);
|
|
12946
|
-
const found = await
|
|
12947
|
-
if (found === void 0
|
|
12800
|
+
const found = await resolveLiveRunDirectoryPath(admitted.runDirectory, home);
|
|
12801
|
+
if (found === void 0) {
|
|
12948
12802
|
throw new Error(
|
|
12949
12803
|
`admitted run ${admitted.runId} missing after host turn; not found under ${home}`
|
|
12950
12804
|
);
|
|
12951
12805
|
}
|
|
12952
12806
|
let relocation;
|
|
12953
|
-
if (found !==
|
|
12807
|
+
if (found !== admitted.runDirectory) {
|
|
12954
12808
|
const oldRunDirectory = admitted.runDirectory;
|
|
12955
12809
|
const coords = { ...authority.decode(admitted.principal) };
|
|
12956
12810
|
rewritePrincipalSessionPaths(
|
|
@@ -12968,7 +12822,7 @@ async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLe
|
|
|
12968
12822
|
relocation = { oldRunDirectory, newRunDirectory: found };
|
|
12969
12823
|
}
|
|
12970
12824
|
if (admitted.ticketNumber === void 0) {
|
|
12971
|
-
const boardTicket = await readBoardTicketNumber(found
|
|
12825
|
+
const boardTicket = await readBoardTicketNumber(found);
|
|
12972
12826
|
if (boardTicket !== void 0) {
|
|
12973
12827
|
admitted.ticketNumber = boardTicket;
|
|
12974
12828
|
}
|
|
@@ -14005,10 +13859,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
14005
13859
|
return { exitCode: error instanceof CliUsageError ? 2 : 1 };
|
|
14006
13860
|
}
|
|
14007
13861
|
}
|
|
14008
|
-
async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
13862
|
+
async function pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
14009
13863
|
let foundRunDirectory;
|
|
14010
13864
|
try {
|
|
14011
|
-
foundRunDirectory = await findRunDirectoryById(home, runId);
|
|
13865
|
+
foundRunDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
14012
13866
|
} catch {
|
|
14013
13867
|
return false;
|
|
14014
13868
|
}
|
|
@@ -14033,8 +13887,8 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
14033
13887
|
);
|
|
14034
13888
|
return true;
|
|
14035
13889
|
}
|
|
14036
|
-
async function presentLocatedResumeFailure(home, runId, authority, io, thrown) {
|
|
14037
|
-
return await pointExistingRunFailure(home, runId, authority, io, thrown);
|
|
13890
|
+
async function presentLocatedResumeFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
13891
|
+
return await pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory);
|
|
14038
13892
|
}
|
|
14039
13893
|
function writeResumeFailurePointer(io, errorPath) {
|
|
14040
13894
|
io.stderr(formatCliDiagnostic(`\u7EED\u8DD1\u5931\u8D25\uFF0C\u5F53\u6B21\u9519\u8BEF\u8BB0\u5F55\uFF1A${errorPath}`));
|
|
@@ -14191,15 +14045,15 @@ var init_post_admission = __esm({
|
|
|
14191
14045
|
async function tryResumeSameTicketSeatRun(input) {
|
|
14192
14046
|
if (input.freshSummons === true) return void 0;
|
|
14193
14047
|
if (input.parentRunPath.trim() === "") return void 0;
|
|
14194
|
-
const
|
|
14048
|
+
const previous = await findLatestRunForSeatTicket({
|
|
14195
14049
|
home: input.home,
|
|
14196
14050
|
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
14197
14051
|
role: input.role,
|
|
14198
14052
|
parentRunPath: input.parentRunPath,
|
|
14199
14053
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
14200
14054
|
});
|
|
14201
|
-
if (
|
|
14202
|
-
return await input.resume(
|
|
14055
|
+
if (previous === void 0) return void 0;
|
|
14056
|
+
return await input.resume(previous.runId, input.summons, previous.runDirectory);
|
|
14203
14057
|
}
|
|
14204
14058
|
var init_seat_ticket_binding = __esm({
|
|
14205
14059
|
"src/public-cli/seat-ticket-binding.ts"() {
|
|
@@ -14342,11 +14196,9 @@ async function presentOriginalVolume(held, terminal, io, runDirectory) {
|
|
|
14342
14196
|
}
|
|
14343
14197
|
for (const value of held) io.stdout(value);
|
|
14344
14198
|
}
|
|
14345
|
-
function withUnsettledDirection(parent
|
|
14199
|
+
function withUnsettledDirection(parent) {
|
|
14346
14200
|
const outcome = parent.roleOutcome;
|
|
14347
14201
|
if (outcome.kind !== "accepted" && outcome.kind !== "audit_escalation") return parent;
|
|
14348
|
-
const officerOutcome = officer?.roleOutcome;
|
|
14349
|
-
const officerPayloads = officer?.submissions !== void 0 && officer.submissions.length > 0 ? officer.submissions : officerOutcome !== void 0 && officerOutcome.kind !== "no_receipt" ? officerOutcome.payloads ?? [] : [];
|
|
14350
14202
|
return {
|
|
14351
14203
|
...parent,
|
|
14352
14204
|
roleOutcome: {
|
|
@@ -14354,10 +14206,7 @@ function withUnsettledDirection(parent, officer) {
|
|
|
14354
14206
|
decisiveFacts: {
|
|
14355
14207
|
...outcome.decisiveFacts ?? {},
|
|
14356
14208
|
directionUnsettled: true,
|
|
14357
|
-
subsequentAudit: "incomplete"
|
|
14358
|
-
...officerOutcome === void 0 ? {} : { officerRole: officerOutcome.role },
|
|
14359
|
-
...officer?.runId === void 0 ? {} : { officerRunId: officer.runId },
|
|
14360
|
-
...officerPayloads.length === 0 ? {} : { officerPayloads }
|
|
14209
|
+
subsequentAudit: "incomplete"
|
|
14361
14210
|
}
|
|
14362
14211
|
}
|
|
14363
14212
|
};
|
|
@@ -14368,10 +14217,9 @@ function heldUnreadableTerminal(terminal) {
|
|
|
14368
14217
|
const status = latestQueueStatus(terminal);
|
|
14369
14218
|
return typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status);
|
|
14370
14219
|
}
|
|
14371
|
-
async function
|
|
14372
|
-
const terminal = withUnsettledDirection(
|
|
14220
|
+
async function presentUnsettledOfficer(officer, io, runDirectory) {
|
|
14221
|
+
const terminal = withUnsettledDirection(officer);
|
|
14373
14222
|
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
14374
|
-
if (officer !== void 0) await presentTerminal(officer, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
14375
14223
|
return terminal;
|
|
14376
14224
|
}
|
|
14377
14225
|
async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io, message = unreadablePostSubmissionStatus(admitted, terminal)) {
|
|
@@ -14379,7 +14227,11 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
|
|
|
14379
14227
|
const next = withUnreadableReask(env);
|
|
14380
14228
|
if (next === void 0) return UNREADABLE_REASK_EXHAUSTED;
|
|
14381
14229
|
return runPublicInstructionSeatResume(
|
|
14382
|
-
{
|
|
14230
|
+
{
|
|
14231
|
+
runId: admitted.runId,
|
|
14232
|
+
runDirectory: admitted.runDirectory,
|
|
14233
|
+
summons: { instruction: message }
|
|
14234
|
+
},
|
|
14383
14235
|
next,
|
|
14384
14236
|
io
|
|
14385
14237
|
);
|
|
@@ -14402,7 +14254,11 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
|
|
|
14402
14254
|
softTicketReaskOwnership
|
|
14403
14255
|
};
|
|
14404
14256
|
const result = await runPublicInstructionSeatResume(
|
|
14405
|
-
{
|
|
14257
|
+
{
|
|
14258
|
+
runId: admitted.runId,
|
|
14259
|
+
runDirectory: admitted.runDirectory,
|
|
14260
|
+
summons: { instruction }
|
|
14261
|
+
},
|
|
14406
14262
|
softReaskEnv,
|
|
14407
14263
|
io
|
|
14408
14264
|
);
|
|
@@ -14518,22 +14374,24 @@ async function resolveReviewSeatDialogueBody(input) {
|
|
|
14518
14374
|
if (reask !== void 0 && reask.length > 0) return reask;
|
|
14519
14375
|
const caller = input.callerInstruction ?? "";
|
|
14520
14376
|
if (caller.length > 0) return caller;
|
|
14521
|
-
const sourceRunPath = input
|
|
14522
|
-
if (sourceRunPath ===
|
|
14377
|
+
const sourceRunPath = admittedSourceRunPath(input)?.trim();
|
|
14378
|
+
if (sourceRunPath === void 0) return void 0;
|
|
14379
|
+
if (input.role === "notary") {
|
|
14380
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
14381
|
+
if (isTicketCourtCountersignSource2(sourceRunPath)) return void 0;
|
|
14382
|
+
}
|
|
14523
14383
|
return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
|
|
14524
14384
|
}
|
|
14525
|
-
function admittedSourceRunPath(admitted) {
|
|
14526
|
-
return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
|
|
14527
|
-
}
|
|
14528
14385
|
async function resolveInitialPrompt(admitted, env) {
|
|
14529
14386
|
const record = roleRecord(admitted.role);
|
|
14530
14387
|
if ("reaskPrompt" in record && record.reaskPrompt === true) {
|
|
14531
14388
|
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
14532
14389
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14533
14390
|
const body = await resolveReviewSeatDialogueBody({
|
|
14391
|
+
role: admitted.role,
|
|
14534
14392
|
...reask === void 0 ? {} : { reask },
|
|
14535
14393
|
callerInstruction: admitted.instruction,
|
|
14536
|
-
...sourceRunPath ===
|
|
14394
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
14537
14395
|
projectRoot: admitted.projectRoot,
|
|
14538
14396
|
home: env.home
|
|
14539
14397
|
});
|
|
@@ -14739,16 +14597,21 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
14739
14597
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
14740
14598
|
freshSummons: input.env.freshSummons,
|
|
14741
14599
|
summons: input.summons,
|
|
14742
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14743
|
-
{
|
|
14600
|
+
resume: (runId, materials, runDirectory) => runPublicInstructionSeatResume(
|
|
14601
|
+
{
|
|
14602
|
+
runId,
|
|
14603
|
+
runDirectory,
|
|
14604
|
+
...materials === void 0 ? {} : { summons: materials }
|
|
14605
|
+
},
|
|
14744
14606
|
input.env,
|
|
14745
14607
|
input.io
|
|
14746
14608
|
)
|
|
14747
14609
|
});
|
|
14748
14610
|
}
|
|
14749
|
-
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
|
|
14611
|
+
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
|
|
14750
14612
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14751
14613
|
const body = await resolveReviewSeatDialogueBody({
|
|
14614
|
+
role,
|
|
14752
14615
|
...reask === void 0 ? {} : { reask },
|
|
14753
14616
|
callerInstruction: fallback.instruction,
|
|
14754
14617
|
sourceRunPath,
|
|
@@ -14871,6 +14734,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14871
14734
|
let auditorSource;
|
|
14872
14735
|
let auditorTicket;
|
|
14873
14736
|
let resolvedNotarySource;
|
|
14737
|
+
let instructionSourceRunPath;
|
|
14874
14738
|
if (record.sameParent === "subject-source") {
|
|
14875
14739
|
if (parsed.subject === void 0) {
|
|
14876
14740
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
@@ -14900,7 +14764,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14900
14764
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14901
14765
|
},
|
|
14902
14766
|
sourceDirectory,
|
|
14903
|
-
projectRoot
|
|
14767
|
+
projectRoot,
|
|
14768
|
+
role
|
|
14904
14769
|
),
|
|
14905
14770
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14906
14771
|
};
|
|
@@ -14920,9 +14785,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14920
14785
|
}
|
|
14921
14786
|
if (record.sameParent === "source-run") {
|
|
14922
14787
|
if (parsed.sourceRun !== void 0) {
|
|
14923
|
-
let parentRunPath;
|
|
14924
14788
|
try {
|
|
14925
|
-
|
|
14789
|
+
instructionSourceRunPath = (await resolveNotarySourceRunLocator({
|
|
14926
14790
|
projectRoot,
|
|
14927
14791
|
sourceRun: parsed.sourceRun,
|
|
14928
14792
|
home: env.home
|
|
@@ -14934,6 +14798,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14934
14798
|
}
|
|
14935
14799
|
throw error;
|
|
14936
14800
|
}
|
|
14801
|
+
const parentRunPath = instructionSourceRunPath;
|
|
14937
14802
|
const summons = {
|
|
14938
14803
|
sourceRunPath: parentRunPath,
|
|
14939
14804
|
...await sameParentDialogue(
|
|
@@ -14943,7 +14808,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14943
14808
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14944
14809
|
},
|
|
14945
14810
|
parentRunPath,
|
|
14946
|
-
projectRoot
|
|
14811
|
+
projectRoot,
|
|
14812
|
+
role
|
|
14947
14813
|
),
|
|
14948
14814
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14949
14815
|
};
|
|
@@ -14980,7 +14846,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14980
14846
|
env,
|
|
14981
14847
|
{ instruction: "", instructionEmpty: true },
|
|
14982
14848
|
source.runDirectory,
|
|
14983
|
-
projectRoot
|
|
14849
|
+
projectRoot,
|
|
14850
|
+
role
|
|
14984
14851
|
)
|
|
14985
14852
|
};
|
|
14986
14853
|
resolvedNotarySource = source;
|
|
@@ -15011,14 +14878,9 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
15011
14878
|
if (rejected !== void 0) return rejected;
|
|
15012
14879
|
throw error;
|
|
15013
14880
|
}
|
|
15014
|
-
if (
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
sourceRun: parsed.sourceRun,
|
|
15018
|
-
home: env.home
|
|
15019
|
-
})).runDirectory;
|
|
15020
|
-
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
15021
|
-
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
14881
|
+
if (instructionSourceRunPath !== void 0) {
|
|
14882
|
+
await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
|
|
14883
|
+
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
15022
14884
|
}
|
|
15023
14885
|
if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
15024
14886
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
@@ -15087,6 +14949,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
15087
14949
|
return runAdmitted();
|
|
15088
14950
|
}
|
|
15089
14951
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
14952
|
+
let selectedRequest = request;
|
|
15090
14953
|
const resume = async () => {
|
|
15091
14954
|
const held = [];
|
|
15092
14955
|
const turnIo = {
|
|
@@ -15094,11 +14957,16 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
15094
14957
|
stderr: io.stderr
|
|
15095
14958
|
};
|
|
15096
14959
|
const result = await runPostAdmissionSeatResume({
|
|
15097
|
-
request,
|
|
14960
|
+
request: selectedRequest,
|
|
15098
14961
|
env,
|
|
15099
14962
|
io: turnIo,
|
|
15100
14963
|
load: async (effective) => {
|
|
15101
|
-
const loaded = await loadResumablePublicRole(
|
|
14964
|
+
const loaded = await loadResumablePublicRole(
|
|
14965
|
+
env.home,
|
|
14966
|
+
effective.runId,
|
|
14967
|
+
env.principalAuthority,
|
|
14968
|
+
effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
|
|
14969
|
+
);
|
|
15102
14970
|
if (packagedRebindSourceOnResume(loaded.admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
|
|
15103
14971
|
return {
|
|
15104
14972
|
...loaded,
|
|
@@ -15143,8 +15011,14 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
15143
15011
|
};
|
|
15144
15012
|
let binding;
|
|
15145
15013
|
try {
|
|
15146
|
-
const loaded = await loadResumablePublicRole(
|
|
15147
|
-
|
|
15014
|
+
const loaded = await loadResumablePublicRole(
|
|
15015
|
+
env.home,
|
|
15016
|
+
request.runId,
|
|
15017
|
+
env.principalAuthority,
|
|
15018
|
+
request.runDirectory === void 0 ? void 0 : { runDirectory: request.runDirectory }
|
|
15019
|
+
);
|
|
15020
|
+
selectedRequest = { ...request, runDirectory: loaded.admitted.runDirectory };
|
|
15021
|
+
binding = loaded.admitted.role === "auditor" ? await readAuditorResumeBinding(loaded.admitted) : void 0;
|
|
15148
15022
|
} catch (error) {
|
|
15149
15023
|
if (!(error instanceof CliUsageError)) throw error;
|
|
15150
15024
|
}
|
|
@@ -15206,24 +15080,34 @@ async function queueConclusionFromChild(child, env, io) {
|
|
|
15206
15080
|
}
|
|
15207
15081
|
}
|
|
15208
15082
|
async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
15209
|
-
const
|
|
15083
|
+
const knownParentDirectory = admittedSourceRunPath(child);
|
|
15084
|
+
const loaded = await loadResumablePublicRole(
|
|
15085
|
+
env.home,
|
|
15086
|
+
parentRunId,
|
|
15087
|
+
env.principalAuthority,
|
|
15088
|
+
knownParentDirectory === void 0 ? void 0 : { runDirectory: knownParentDirectory }
|
|
15089
|
+
);
|
|
15210
15090
|
if (loaded.run.state !== "admitted" && !AUDITED_ROLES.has(loaded.admitted.role)) {
|
|
15211
|
-
return runPublicInstructionSeatResume(
|
|
15091
|
+
return runPublicInstructionSeatResume(
|
|
15092
|
+
{
|
|
15093
|
+
runId: parentRunId,
|
|
15094
|
+
runDirectory: loaded.admitted.runDirectory
|
|
15095
|
+
},
|
|
15096
|
+
env,
|
|
15097
|
+
io
|
|
15098
|
+
);
|
|
15212
15099
|
}
|
|
15213
15100
|
const admitted = loaded.admitted;
|
|
15214
15101
|
const resolved = await queueConclusionFromChild(child, env, io);
|
|
15215
15102
|
if (resolved !== void 0 && "stop" in resolved) {
|
|
15216
15103
|
const stopped = resolved.stop;
|
|
15217
|
-
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0) {
|
|
15218
|
-
const
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15104
|
+
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0 && stopped.admitted !== void 0) {
|
|
15105
|
+
const terminal = await presentUnsettledOfficer(
|
|
15106
|
+
stopped.terminal,
|
|
15107
|
+
io,
|
|
15108
|
+
stopped.admitted.runDirectory
|
|
15222
15109
|
);
|
|
15223
|
-
|
|
15224
|
-
const terminal = await presentUnsettledAudit(parentTerminal, stopped.terminal, io, admitted.runDirectory);
|
|
15225
|
-
return { exitCode: 0, admitted, terminal };
|
|
15226
|
-
}
|
|
15110
|
+
return { exitCode: 0, admitted: stopped.admitted, terminal };
|
|
15227
15111
|
}
|
|
15228
15112
|
return stopped;
|
|
15229
15113
|
}
|
|
@@ -15238,10 +15122,22 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
15238
15122
|
{ ...await readCurrentCourt(admitted.runDirectory), ...packageFaultScope(admitted, env, io) }
|
|
15239
15123
|
);
|
|
15240
15124
|
if (terminal?.roleOutcome.kind !== "accepted") throw new Error("pending submission is not recorded");
|
|
15241
|
-
|
|
15125
|
+
const live = liveChildForCurrentParentSeal(
|
|
15126
|
+
terminal,
|
|
15127
|
+
resolved.admitted,
|
|
15128
|
+
latestQueuePayload(resolved.terminal)
|
|
15129
|
+
);
|
|
15130
|
+
return auditSubmittedRole(
|
|
15131
|
+
{ exitCode: 0, admitted, terminal },
|
|
15132
|
+
env,
|
|
15133
|
+
io,
|
|
15134
|
+
live?.officer,
|
|
15135
|
+
live?.receipt
|
|
15136
|
+
);
|
|
15242
15137
|
}
|
|
15243
15138
|
return runPublicInstructionSeatResume({
|
|
15244
15139
|
runId: parentRunId,
|
|
15140
|
+
runDirectory: admitted.runDirectory,
|
|
15245
15141
|
summons: { instruction: readableGateItem(latestQueuePayload(resolved.terminal)) }
|
|
15246
15142
|
}, envForCourtContinue(env), io);
|
|
15247
15143
|
}
|
|
@@ -15249,28 +15145,21 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
15249
15145
|
showResumeErrorPointer(io, result.exitCode, result.terminal);
|
|
15250
15146
|
return result;
|
|
15251
15147
|
}
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
const
|
|
15255
|
-
if (
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
} catch {
|
|
15268
|
-
return false;
|
|
15269
|
-
}
|
|
15270
|
-
if (admitted.role !== officer) return false;
|
|
15271
|
-
const court = await readCurrentCourt(admitted.runDirectory);
|
|
15272
|
-
const terminal = await trySettlePublicSeat(admitted, env.principalAuthority, court);
|
|
15273
|
-
return latestQueueStatus(terminal) === "converged";
|
|
15148
|
+
function liveChildForCurrentParentSeal(parentTerminal, child, receipt) {
|
|
15149
|
+
if (receipt === void 0) return void 0;
|
|
15150
|
+
const parentSealId = parentTerminal.submissionToolCallId?.trim() ?? "";
|
|
15151
|
+
if (parentSealId === "") return void 0;
|
|
15152
|
+
const childSealId = readAdmittedAuditedSubmissionToolCallId(child.runDirectory);
|
|
15153
|
+
if (childSealId !== parentSealId) return void 0;
|
|
15154
|
+
return { officer: child, receipt };
|
|
15155
|
+
}
|
|
15156
|
+
function officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder) {
|
|
15157
|
+
if (resumedOfficer === void 0 || passedReceipt === void 0) return false;
|
|
15158
|
+
if (resumedOfficer.role === officer) return true;
|
|
15159
|
+
if (chainOrder === void 0) return false;
|
|
15160
|
+
const childIndex = chainOrder.indexOf(resumedOfficer.role);
|
|
15161
|
+
const officerIndex = chainOrder.indexOf(officer);
|
|
15162
|
+
return childIndex >= 0 && officerIndex >= 0 && officerIndex < childIndex;
|
|
15274
15163
|
}
|
|
15275
15164
|
async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt) {
|
|
15276
15165
|
env = withoutSoftTicketReaskTurn(env);
|
|
@@ -15285,21 +15174,29 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15285
15174
|
if (gateOwnsStatusReask) return turn;
|
|
15286
15175
|
const next = withUnreadableReask(env);
|
|
15287
15176
|
if (next === void 0) {
|
|
15288
|
-
const
|
|
15289
|
-
await presentTerminal(
|
|
15290
|
-
return { ...turn, terminal
|
|
15177
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
15178
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15179
|
+
return { ...turn, terminal };
|
|
15291
15180
|
}
|
|
15292
|
-
return runPublicInstructionSeatResume({
|
|
15181
|
+
return runPublicInstructionSeatResume({
|
|
15182
|
+
runId: admitted.runId,
|
|
15183
|
+
runDirectory: admitted.runDirectory,
|
|
15184
|
+
summons: { instruction: SECRETARIAT_STATUS_REASK }
|
|
15185
|
+
}, next, io);
|
|
15293
15186
|
}
|
|
15294
15187
|
if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
|
|
15295
15188
|
if (gateOwnsStatusReask) return turn;
|
|
15296
15189
|
const next = withUnreadableReask(env);
|
|
15297
15190
|
if (next === void 0) {
|
|
15298
|
-
const
|
|
15299
|
-
await presentTerminal(
|
|
15300
|
-
return { ...turn, terminal
|
|
15191
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
15192
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15193
|
+
return { ...turn, terminal };
|
|
15301
15194
|
}
|
|
15302
|
-
return runPublicInstructionSeatResume({
|
|
15195
|
+
return runPublicInstructionSeatResume({
|
|
15196
|
+
runId: admitted.runId,
|
|
15197
|
+
runDirectory: admitted.runDirectory,
|
|
15198
|
+
summons: { instruction: officerConclusionReask(status) }
|
|
15199
|
+
}, next, io);
|
|
15303
15200
|
}
|
|
15304
15201
|
const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
|
|
15305
15202
|
const skipAudit = selfEscalationSkipsAudit || (admitted.role === "fixer" || admitted.role === "coder") && (typeof status !== "string" || !WORKER_DONE_STATUSES.has(status));
|
|
@@ -15329,14 +15226,9 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15329
15226
|
abort() {
|
|
15330
15227
|
}
|
|
15331
15228
|
};
|
|
15332
|
-
const
|
|
15333
|
-
env,
|
|
15334
|
-
parentSessionFile: sessionFile,
|
|
15335
|
-
officer,
|
|
15336
|
-
toolCallId
|
|
15337
|
-
});
|
|
15229
|
+
const gateSatisfied = (officer, chainOrder) => officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder);
|
|
15338
15230
|
if (admitted.role === "doctor") {
|
|
15339
|
-
if (!
|
|
15231
|
+
if (!gateSatisfied("auditor")) {
|
|
15340
15232
|
let lastSummon;
|
|
15341
15233
|
const decision = await createPiDoctorAuditor()({
|
|
15342
15234
|
context,
|
|
@@ -15358,23 +15250,18 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15358
15250
|
...reask === void 0 ? {} : { reviewReask: reask },
|
|
15359
15251
|
...submission === void 0 ? {} : { gateReviewInstruction: submission }
|
|
15360
15252
|
});
|
|
15361
|
-
const officerSession = sessionFileFromPublicSummon(summoned);
|
|
15362
|
-
if (officerSession !== void 0) {
|
|
15363
|
-
bookDirectOfficerRunPointer({
|
|
15364
|
-
parentSessionFile: sessionFile,
|
|
15365
|
-
officer: "auditor",
|
|
15366
|
-
sessionFile: officerSession,
|
|
15367
|
-
submissionToolCallId: toolCallId,
|
|
15368
|
-
...summoned.runDirectory === void 0 ? {} : { runDirectory: summoned.runDirectory }
|
|
15369
|
-
});
|
|
15370
|
-
}
|
|
15371
15253
|
lastSummon = summoned;
|
|
15254
|
+
const officerDir = summoned.runDirectory ?? summoned.admitted?.runDirectory;
|
|
15255
|
+
if (officerDir !== void 0 && toolCallId.length > 0) {
|
|
15256
|
+
persistAdmittedAuditedSubmissionToolCallId(officerDir, toolCallId);
|
|
15257
|
+
}
|
|
15372
15258
|
return summoned;
|
|
15373
15259
|
}
|
|
15374
15260
|
});
|
|
15375
15261
|
if (decision.status === "continue") {
|
|
15376
15262
|
return runPublicInstructionSeatResume({
|
|
15377
15263
|
runId: admitted.runId,
|
|
15264
|
+
runDirectory: admitted.runDirectory,
|
|
15378
15265
|
summons: { instruction: readableGateItem(decision.receipt ?? decision.violations) }
|
|
15379
15266
|
}, envForCourtContinue(env), io);
|
|
15380
15267
|
}
|
|
@@ -15382,9 +15269,14 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15382
15269
|
if (lastSummon?.terminal === void 0) {
|
|
15383
15270
|
throw new Error("doctor audit kept an unreadable reply with no terminal");
|
|
15384
15271
|
}
|
|
15385
|
-
|
|
15386
|
-
const
|
|
15387
|
-
|
|
15272
|
+
const officerAdmitted = lastSummon.admitted;
|
|
15273
|
+
const officerDir = officerAdmitted?.runDirectory ?? lastSummon.runDirectory ?? admitted.runDirectory;
|
|
15274
|
+
const terminal = await presentUnsettledOfficer(lastSummon.terminal, io, officerDir);
|
|
15275
|
+
return {
|
|
15276
|
+
exitCode: 0,
|
|
15277
|
+
...officerAdmitted === void 0 ? { admitted } : { admitted: officerAdmitted },
|
|
15278
|
+
terminal
|
|
15279
|
+
};
|
|
15388
15280
|
}
|
|
15389
15281
|
if (decision.status !== "converged") {
|
|
15390
15282
|
if (lastSummon?.terminal !== void 0) {
|
|
@@ -15407,7 +15299,6 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15407
15299
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
15408
15300
|
});
|
|
15409
15301
|
let chain;
|
|
15410
|
-
let officerRunId = resumedOfficer?.runId;
|
|
15411
15302
|
const runGate = (subject) => requireSubmissionGate({
|
|
15412
15303
|
context,
|
|
15413
15304
|
subject,
|
|
@@ -15425,19 +15316,19 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15425
15316
|
}
|
|
15426
15317
|
});
|
|
15427
15318
|
if (admitted.role === "judge") {
|
|
15319
|
+
const judgeGateOrder = JUDGE_GATES.map(gateOfficerForSubject);
|
|
15428
15320
|
chain = await runJudgeGates({
|
|
15429
|
-
gateAlreadyConverged: async (subject) =>
|
|
15321
|
+
gateAlreadyConverged: async (subject) => gateSatisfied(gateOfficerForSubject(subject), judgeGateOrder),
|
|
15430
15322
|
runGate
|
|
15431
15323
|
});
|
|
15432
15324
|
} else {
|
|
15433
15325
|
const subject = admitted.role === "fixer" || admitted.role === "coder" ? { kind: "worker_completion" } : admitted.role === "secretariat" ? { kind: "secretariat_verdict" } : { kind: "countersign_verdict" };
|
|
15434
15326
|
const officer = gateOfficerForSubject(subject);
|
|
15435
|
-
if (
|
|
15327
|
+
if (gateSatisfied(officer)) {
|
|
15436
15328
|
chain = { status: "converged", passes: [] };
|
|
15437
15329
|
} else {
|
|
15438
15330
|
const pass = await runGate(subject);
|
|
15439
15331
|
if (pass === void 0) throw new Error("audit gate returned no conclusion");
|
|
15440
|
-
officerRunId = pass.runId;
|
|
15441
15332
|
chain = {
|
|
15442
15333
|
status: pass.status,
|
|
15443
15334
|
passes: [{
|
|
@@ -15452,53 +15343,58 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15452
15343
|
}
|
|
15453
15344
|
}
|
|
15454
15345
|
if (chain.status === "needs_reask") {
|
|
15455
|
-
const
|
|
15346
|
+
const pass = chain.passes.at(-1);
|
|
15347
|
+
const officerTerminal = pass?.terminal;
|
|
15456
15348
|
if (officerTerminal === void 0) throw new Error("unreadable audit has no terminal result");
|
|
15457
|
-
|
|
15458
|
-
const
|
|
15459
|
-
|
|
15349
|
+
const officerRunDirectory = pass?.runDirectory;
|
|
15350
|
+
const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
|
|
15351
|
+
if (officerRunId === void 0) throw new Error("unreadable audit has no resumable run identity");
|
|
15352
|
+
const officer = await loadResumablePublicRole(
|
|
15353
|
+
env.home,
|
|
15354
|
+
officerRunId,
|
|
15355
|
+
env.principalAuthority,
|
|
15356
|
+
officerRunDirectory === void 0 ? void 0 : { runDirectory: officerRunDirectory }
|
|
15357
|
+
);
|
|
15358
|
+
const terminal = await presentUnsettledOfficer(
|
|
15359
|
+
officerTerminal,
|
|
15360
|
+
io,
|
|
15361
|
+
officer.admitted.runDirectory
|
|
15362
|
+
);
|
|
15363
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15460
15364
|
}
|
|
15461
15365
|
if (chain.status === "escalate") {
|
|
15462
15366
|
const escalation = chain.passes.at(-1);
|
|
15463
|
-
const
|
|
15367
|
+
const escalatedRunDirectory = escalation?.runDirectory;
|
|
15368
|
+
const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
|
|
15464
15369
|
if (escalatedRunId === void 0) throw new Error("escalated audit has no resumable run identity");
|
|
15465
|
-
const officer = await loadResumablePublicRole(
|
|
15466
|
-
|
|
15467
|
-
|
|
15370
|
+
const officer = await loadResumablePublicRole(
|
|
15371
|
+
env.home,
|
|
15372
|
+
escalatedRunId,
|
|
15468
15373
|
env.principalAuthority,
|
|
15469
|
-
|
|
15374
|
+
escalatedRunDirectory === void 0 ? void 0 : { runDirectory: escalatedRunDirectory }
|
|
15470
15375
|
);
|
|
15471
|
-
|
|
15472
|
-
|
|
15473
|
-
|
|
15376
|
+
let terminal = escalation?.terminal;
|
|
15377
|
+
if (terminal === void 0) {
|
|
15378
|
+
terminal = await trySettlePublicSeat(
|
|
15379
|
+
officer.admitted,
|
|
15380
|
+
env.principalAuthority,
|
|
15381
|
+
{ ...await readCurrentCourt(officer.admitted.runDirectory), ...packageFaultScope(officer.admitted, env, io) }
|
|
15382
|
+
);
|
|
15383
|
+
}
|
|
15384
|
+
if (terminal === void 0) throw new Error("escalated audit has no terminal result");
|
|
15385
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, officer.admitted.runDirectory);
|
|
15386
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15474
15387
|
}
|
|
15475
15388
|
if (chain.status === "continue") {
|
|
15476
15389
|
return runPublicInstructionSeatResume({
|
|
15477
15390
|
runId: admitted.runId,
|
|
15391
|
+
runDirectory: admitted.runDirectory,
|
|
15478
15392
|
summons: { instruction: readableGateItem(chain.passes.at(-1)?.receipt) }
|
|
15479
15393
|
}, envForCourtContinue(env), io);
|
|
15480
15394
|
}
|
|
15481
|
-
if (admitted.role === "secretariat") {
|
|
15482
|
-
const pass = chain.passes.at(-1);
|
|
15483
|
-
const receipt = pass?.receipt ?? passedReceipt;
|
|
15484
|
-
if (receipt !== void 0) {
|
|
15485
|
-
await env.sessionAppender(env.principalAuthority, admitted.principal, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, {
|
|
15486
|
-
officer: "countersign",
|
|
15487
|
-
receipt,
|
|
15488
|
-
...officerRunId === void 0 ? {} : { runId: officerRunId }
|
|
15489
|
-
});
|
|
15490
|
-
}
|
|
15491
|
-
}
|
|
15492
15395
|
}
|
|
15493
15396
|
if (turn.terminal === void 0) throw new Error(`audited ${admitted.role} submission did not settle`);
|
|
15494
|
-
|
|
15495
|
-
admitted,
|
|
15496
|
-
env.principalAuthority,
|
|
15497
|
-
turn.terminal,
|
|
15498
|
-
packageFaultScope(admitted, env, io)
|
|
15499
|
-
);
|
|
15500
|
-
turn = { ...turn, terminal };
|
|
15501
|
-
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15397
|
+
await presentTerminal(turn.terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15502
15398
|
return turn;
|
|
15503
15399
|
}
|
|
15504
15400
|
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;
|
|
@@ -15509,21 +15405,18 @@ var init_instruction_seat_run = __esm({
|
|
|
15509
15405
|
init_role_run_placement();
|
|
15510
15406
|
init_role_run_relocation();
|
|
15511
15407
|
init_session_opening_materials();
|
|
15512
|
-
init_archivist_record_pointer();
|
|
15513
15408
|
init_doctor_auditor();
|
|
15514
15409
|
init_gatekeeper_role();
|
|
15515
15410
|
init_submission_errors();
|
|
15516
15411
|
init_review_submission();
|
|
15517
15412
|
init_judge_role();
|
|
15518
15413
|
init_worker_submission_contracts();
|
|
15519
|
-
init_secretariat_contracts();
|
|
15520
15414
|
init_readable_gate_item();
|
|
15521
15415
|
init_receipt_delivery_policy();
|
|
15522
15416
|
init_run_terminal_artifacts();
|
|
15523
15417
|
init_submission_gate();
|
|
15524
15418
|
init_submission_ledger();
|
|
15525
15419
|
init_public_role_summons();
|
|
15526
|
-
init_session_assistant_usage();
|
|
15527
15420
|
init_submission_gate();
|
|
15528
15421
|
init_run_ticket_number();
|
|
15529
15422
|
init_notary_source_run();
|
|
@@ -15618,10 +15511,10 @@ var init_analyst_book_key = __esm({
|
|
|
15618
15511
|
// src/atomic-write.ts
|
|
15619
15512
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
15620
15513
|
import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
|
|
15621
|
-
import { dirname as dirname14, join as
|
|
15514
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
15622
15515
|
async function writeFileAtomically(destination, contents, options) {
|
|
15623
15516
|
const parent = dirname14(destination);
|
|
15624
|
-
const temporary =
|
|
15517
|
+
const temporary = join21(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
15625
15518
|
try {
|
|
15626
15519
|
await writeFile3(temporary, contents, options);
|
|
15627
15520
|
await rename2(temporary, destination);
|
|
@@ -15638,12 +15531,12 @@ var init_atomic_write = __esm({
|
|
|
15638
15531
|
|
|
15639
15532
|
// src/analyst-index.ts
|
|
15640
15533
|
import { open, readFile as readFile10, unlink } from "node:fs/promises";
|
|
15641
|
-
import { dirname as dirname15, join as
|
|
15534
|
+
import { dirname as dirname15, join as join22 } from "node:path";
|
|
15642
15535
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15643
15536
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15644
15537
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15645
15538
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
15646
|
-
const lockPath =
|
|
15539
|
+
const lockPath = join22(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15647
15540
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15648
15541
|
const startedAt = Date.now();
|
|
15649
15542
|
while (true) {
|
|
@@ -15670,7 +15563,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15670
15563
|
}
|
|
15671
15564
|
}
|
|
15672
15565
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15673
|
-
return
|
|
15566
|
+
return join22(ledgerHome, "analyst", "library-index.json");
|
|
15674
15567
|
}
|
|
15675
15568
|
function rowFromIssueMetricsPage(page) {
|
|
15676
15569
|
return {
|
|
@@ -15963,6 +15856,70 @@ var init_analyst_cohort = __esm({
|
|
|
15963
15856
|
}
|
|
15964
15857
|
});
|
|
15965
15858
|
|
|
15859
|
+
// src/archivist-record-pointer.ts
|
|
15860
|
+
import { basename as basename10, join as join23 } from "node:path";
|
|
15861
|
+
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
15862
|
+
const where = `${parentRunDirectory} officers`;
|
|
15863
|
+
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
15864
|
+
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
15865
|
+
}
|
|
15866
|
+
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
15867
|
+
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
15868
|
+
}
|
|
15869
|
+
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
15870
|
+
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
15871
|
+
let sessionFile = raw.sessionFile;
|
|
15872
|
+
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
15873
|
+
const leaf = parseRunLeaf(basename10(recordedRunDirectory));
|
|
15874
|
+
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
15875
|
+
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
15876
|
+
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
15877
|
+
recordedRunDirectory,
|
|
15878
|
+
homeFromRunDirectory(parentRunDirectory),
|
|
15879
|
+
parentIdentity.bookKey
|
|
15880
|
+
);
|
|
15881
|
+
if (currentRunDirectory !== void 0) {
|
|
15882
|
+
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
15883
|
+
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
15884
|
+
}
|
|
15885
|
+
}
|
|
15886
|
+
return {
|
|
15887
|
+
sessionFile,
|
|
15888
|
+
...officer === void 0 ? {} : { officer },
|
|
15889
|
+
...runDirectory === void 0 ? {} : { runDirectory }
|
|
15890
|
+
};
|
|
15891
|
+
}
|
|
15892
|
+
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
15893
|
+
const { records, diagnostics } = await readSitianRecords(join23(parentRunDirectory, RUN_HISTORY_FILE));
|
|
15894
|
+
if (diagnostics.length > 0) {
|
|
15895
|
+
throw new Error(
|
|
15896
|
+
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
15897
|
+
);
|
|
15898
|
+
}
|
|
15899
|
+
return latestOfficerPointersFromRecords(records);
|
|
15900
|
+
}
|
|
15901
|
+
async function readOfficerPointers(parentRunDirectory) {
|
|
15902
|
+
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
15903
|
+
return Promise.all(
|
|
15904
|
+
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
15905
|
+
);
|
|
15906
|
+
}
|
|
15907
|
+
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
15908
|
+
var init_archivist_record_pointer = __esm({
|
|
15909
|
+
"src/archivist-record-pointer.ts"() {
|
|
15910
|
+
"use strict";
|
|
15911
|
+
init_unknown_value();
|
|
15912
|
+
init_run_dossier();
|
|
15913
|
+
init_run_dossier_files();
|
|
15914
|
+
init_sitian_facade();
|
|
15915
|
+
init_activation_ledger_topology();
|
|
15916
|
+
init_run_lifecycle();
|
|
15917
|
+
init_role_run_relocation();
|
|
15918
|
+
init_role_run_placement();
|
|
15919
|
+
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
15920
|
+
}
|
|
15921
|
+
});
|
|
15922
|
+
|
|
15966
15923
|
// src/analyst-gate-cycles-read.ts
|
|
15967
15924
|
function isParentAttemptBindingRow(row) {
|
|
15968
15925
|
return row.type === "custom" && row.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
|
|
@@ -18691,14 +18648,19 @@ async function runAkRole(argv, env) {
|
|
|
18691
18648
|
env = { ...env, freshSummons: true };
|
|
18692
18649
|
}
|
|
18693
18650
|
if (parsed.command === "resume") {
|
|
18694
|
-
|
|
18651
|
+
let resumeRequest = parseResumeRequest(parsed.args);
|
|
18695
18652
|
resumeFailureContext = {
|
|
18696
18653
|
home,
|
|
18697
18654
|
runId: resumeRequest.runId,
|
|
18698
18655
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
18699
18656
|
};
|
|
18657
|
+
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
18658
|
+
if (runDirectory !== void 0) {
|
|
18659
|
+
resumeRequest = { ...resumeRequest, runDirectory };
|
|
18660
|
+
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
18661
|
+
}
|
|
18700
18662
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
18701
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
18663
|
+
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
18702
18664
|
const seatRole = resumeRole ?? "judge";
|
|
18703
18665
|
const seat = resolveEffectiveSeat(
|
|
18704
18666
|
parts.config,
|
|
@@ -18722,12 +18684,18 @@ async function runAkRole(argv, env) {
|
|
|
18722
18684
|
let current = result;
|
|
18723
18685
|
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true && !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
18724
18686
|
const parentRunId = current.admitted.correlationId;
|
|
18687
|
+
const parentSource = admittedSourceRunPath(current.admitted);
|
|
18725
18688
|
resumeFailureContext = {
|
|
18726
18689
|
home,
|
|
18727
18690
|
runId: parentRunId,
|
|
18691
|
+
...parentSource === void 0 ? {} : { runDirectory: parentSource },
|
|
18728
18692
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
18729
18693
|
};
|
|
18730
|
-
const parentRole = await peekRoleRunRole(
|
|
18694
|
+
const parentRole = await peekRoleRunRole(
|
|
18695
|
+
home,
|
|
18696
|
+
parentRunId,
|
|
18697
|
+
parentSource === void 0 ? void 0 : { runDirectory: parentSource }
|
|
18698
|
+
);
|
|
18731
18699
|
if (parentRole === void 0) break;
|
|
18732
18700
|
const parentSeat = resolveEffectiveSeat(
|
|
18733
18701
|
parts.config,
|
|
@@ -18779,7 +18747,8 @@ async function runAkRole(argv, env) {
|
|
|
18779
18747
|
resumeFailureContext.runId,
|
|
18780
18748
|
resumeFailureContext.authority,
|
|
18781
18749
|
io,
|
|
18782
|
-
error
|
|
18750
|
+
error,
|
|
18751
|
+
resumeFailureContext.runDirectory
|
|
18783
18752
|
)) {
|
|
18784
18753
|
return {
|
|
18785
18754
|
exitCode: error instanceof CliUsageError ? 2 : 1,
|
|
@@ -18860,7 +18829,7 @@ __export(public_role_summons_exports, {
|
|
|
18860
18829
|
summonPublicRole: () => summonPublicRole
|
|
18861
18830
|
});
|
|
18862
18831
|
import { execFile as execFile3 } from "node:child_process";
|
|
18863
|
-
import { existsSync as
|
|
18832
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
18864
18833
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18865
18834
|
import { join as join26 } from "node:path";
|
|
18866
18835
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -18886,7 +18855,7 @@ function parentDir(path) {
|
|
|
18886
18855
|
function walkPackageRoot(start) {
|
|
18887
18856
|
let dir = start;
|
|
18888
18857
|
for (let i = 0; i < 12; i += 1) {
|
|
18889
|
-
if (
|
|
18858
|
+
if (existsSync11(join26(dir, "package.json")) && existsSync11(join26(dir, "souls"))) {
|
|
18890
18859
|
return dir;
|
|
18891
18860
|
}
|
|
18892
18861
|
const parent = parentDir(dir);
|
|
@@ -19105,6 +19074,7 @@ async function summonPublicRole(options) {
|
|
|
19105
19074
|
const stepped = await runPrepared(parse, (env) => runPublicInstructionSeatResume2(
|
|
19106
19075
|
{
|
|
19107
19076
|
runId: resumeRunId,
|
|
19077
|
+
...options.resumeRunDirectory === void 0 ? {} : { runDirectory: options.resumeRunDirectory },
|
|
19108
19078
|
summons: {
|
|
19109
19079
|
instruction,
|
|
19110
19080
|
instructionEmpty: instruction.length === 0
|
|
@@ -19121,10 +19091,13 @@ async function summonPublicRole(options) {
|
|
|
19121
19091
|
result = stepped.ok;
|
|
19122
19092
|
}
|
|
19123
19093
|
const stderr = captured?.stderrText();
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19094
|
+
let runDirectory = result.admitted?.runDirectory;
|
|
19095
|
+
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
19096
|
+
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
19097
|
+
home,
|
|
19098
|
+
result.terminal.runId
|
|
19099
|
+
) ?? runDirectory;
|
|
19100
|
+
}
|
|
19128
19101
|
return {
|
|
19129
19102
|
exitCode: result.exitCode,
|
|
19130
19103
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -19205,8 +19178,12 @@ async function summonGateOfficer(options) {
|
|
|
19205
19178
|
}
|
|
19206
19179
|
let gateReviewInstruction;
|
|
19207
19180
|
if (options.reask === void 0 && options.submission !== void 0) {
|
|
19208
|
-
const {
|
|
19209
|
-
|
|
19181
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
19182
|
+
const blindTicketCourt = options.officer === "notary" && isTicketCourtCountersignSource2(options.sourceRunDirectory);
|
|
19183
|
+
if (!blindTicketCourt) {
|
|
19184
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
19185
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
19186
|
+
}
|
|
19210
19187
|
}
|
|
19211
19188
|
const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
19212
19189
|
const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
|
|
@@ -19446,8 +19423,7 @@ async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirect
|
|
|
19446
19423
|
if (rewriteRunDirectoryPathValue(recordedPathIdentity, unbound.runDirectory, runDirectory) !== currentPathIdentity) {
|
|
19447
19424
|
return false;
|
|
19448
19425
|
}
|
|
19449
|
-
|
|
19450
|
-
return placed !== void 0 && physicalPathIdentity(placed) === runDirectory;
|
|
19426
|
+
return true;
|
|
19451
19427
|
}
|
|
19452
19428
|
return false;
|
|
19453
19429
|
}
|
|
@@ -19476,6 +19452,7 @@ __export(run_lifecycle_exports, {
|
|
|
19476
19452
|
buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
|
|
19477
19453
|
clearCurrentCourt: () => clearCurrentCourt,
|
|
19478
19454
|
describeErrorIdentity: () => describeErrorIdentity,
|
|
19455
|
+
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
19479
19456
|
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
19480
19457
|
findRunDirectoryById: () => findRunDirectoryById,
|
|
19481
19458
|
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
@@ -19488,8 +19465,10 @@ __export(run_lifecycle_exports, {
|
|
|
19488
19465
|
readRoleRunState: () => readRoleRunState,
|
|
19489
19466
|
readRunParentPath: () => readRunParentPath,
|
|
19490
19467
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
19468
|
+
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
19491
19469
|
writeRoleRunState: () => writeRoleRunState
|
|
19492
19470
|
});
|
|
19471
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
19493
19472
|
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
|
|
19494
19473
|
import { basename as basename12, join as join28 } from "node:path";
|
|
19495
19474
|
function buildAutoResumeContinuationPrompt() {
|
|
@@ -19505,7 +19484,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
19505
19484
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
19506
19485
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
19507
19486
|
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
19508
|
-
const sourceRunPath =
|
|
19487
|
+
const sourceRunPath = admittedSourceRunPath(record);
|
|
19509
19488
|
let sourceRun;
|
|
19510
19489
|
if (isRecord(record.sourceRun)) {
|
|
19511
19490
|
const sr = record.sourceRun;
|
|
@@ -19884,7 +19863,16 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19884
19863
|
lastReclaimFailure === void 0 ? void 0 : errnoOf(lastReclaimFailure)
|
|
19885
19864
|
);
|
|
19886
19865
|
}
|
|
19887
|
-
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19866
|
+
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
19867
|
+
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
19868
|
+
const parsed = parseRunLeaf(basename12(knownRunDirectory));
|
|
19869
|
+
if (parsed === void 0 || parsed.runId !== runId) {
|
|
19870
|
+
throw new CliUsageError(
|
|
19871
|
+
`run directory does not match run id ${runId}: ${knownRunDirectory}`
|
|
19872
|
+
);
|
|
19873
|
+
}
|
|
19874
|
+
return knownRunDirectory;
|
|
19875
|
+
}
|
|
19888
19876
|
if (runId.trim() === "") return void 0;
|
|
19889
19877
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19890
19878
|
const booksRoot = join28(ledgerHome, "books");
|
|
@@ -19901,13 +19889,16 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
19901
19889
|
onlyRole
|
|
19902
19890
|
);
|
|
19903
19891
|
}
|
|
19892
|
+
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
19893
|
+
if (existsSync12(recordedPath)) return recordedPath;
|
|
19894
|
+
const parsed = parseRunLeaf(basename12(recordedPath));
|
|
19895
|
+
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
19896
|
+
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
19897
|
+
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
19898
|
+
}
|
|
19904
19899
|
async function readRunParentPath(runDirectory) {
|
|
19905
19900
|
const record = readPageSync(runDirectory, "admitted");
|
|
19906
|
-
|
|
19907
|
-
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
19908
|
-
return record.sourceRunPath;
|
|
19909
|
-
}
|
|
19910
|
-
return void 0;
|
|
19901
|
+
return admittedSourceRunPath(record);
|
|
19911
19902
|
}
|
|
19912
19903
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19913
19904
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
@@ -19922,6 +19913,10 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
19922
19913
|
}
|
|
19923
19914
|
}
|
|
19924
19915
|
async function findLatestRunIdForSeatTicket(input) {
|
|
19916
|
+
const found = await findLatestRunForSeatTicket(input);
|
|
19917
|
+
return found?.runId;
|
|
19918
|
+
}
|
|
19919
|
+
async function findLatestRunForSeatTicket(input) {
|
|
19925
19920
|
if (input.parentRunPath.trim() === "") {
|
|
19926
19921
|
return void 0;
|
|
19927
19922
|
}
|
|
@@ -19944,7 +19939,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19944
19939
|
const parentPath = await readRunParentPath(runDirectory);
|
|
19945
19940
|
if (!await retainedRunPathsMatch(parentPath, input.parentRunPath, input.parentRunPath)) continue;
|
|
19946
19941
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
19947
|
-
if (best === void 0 || runId > best) best = runId;
|
|
19942
|
+
if (best === void 0 || runId > best.runId) best = { runId, runDirectory };
|
|
19948
19943
|
}
|
|
19949
19944
|
return best;
|
|
19950
19945
|
}
|
|
@@ -19962,8 +19957,8 @@ function restoredTicketFields(fields) {
|
|
|
19962
19957
|
...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
|
|
19963
19958
|
};
|
|
19964
19959
|
}
|
|
19965
|
-
async function loadResumableRunRecord(home, runId, authority) {
|
|
19966
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
19960
|
+
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
19961
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
19967
19962
|
if (runDirectory === void 0) {
|
|
19968
19963
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
19969
19964
|
}
|
|
@@ -20055,9 +20050,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20055
20050
|
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
20056
20051
|
}
|
|
20057
20052
|
}
|
|
20058
|
-
|
|
20059
|
-
sourceRunPath = record.sourceRunPath;
|
|
20060
|
-
}
|
|
20053
|
+
sourceRunPath = admittedSourceRunPath(record);
|
|
20061
20054
|
if (isRecord(record.sourceRun)) {
|
|
20062
20055
|
const sr = record.sourceRun;
|
|
20063
20056
|
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
@@ -20133,16 +20126,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20133
20126
|
);
|
|
20134
20127
|
}
|
|
20135
20128
|
}
|
|
20136
|
-
const
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
20140
|
-
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
20141
|
-
home,
|
|
20142
|
-
referencedRunId,
|
|
20143
|
-
run.bookKey,
|
|
20144
|
-
referencedRole
|
|
20145
|
-
);
|
|
20129
|
+
const recordedSourceDirectory = sourceRunPath ?? sourceRun?.runDirectory;
|
|
20130
|
+
if (recordedSourceDirectory !== void 0) {
|
|
20131
|
+
const currentSourceRunDirectory = await resolveLiveRunDirectoryPath(recordedSourceDirectory, home, run.bookKey);
|
|
20146
20132
|
if (currentSourceRunDirectory !== void 0) {
|
|
20147
20133
|
sourceRunPath = currentSourceRunDirectory;
|
|
20148
20134
|
if (sourceRun !== void 0) {
|
|
@@ -20200,14 +20186,19 @@ function seatLoadedResult(loaded, admitted) {
|
|
|
20200
20186
|
run: loaded.run
|
|
20201
20187
|
};
|
|
20202
20188
|
}
|
|
20203
|
-
async function peekRoleRunRole(home, runId) {
|
|
20204
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
20189
|
+
async function peekRoleRunRole(home, runId, options) {
|
|
20190
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, options?.runDirectory);
|
|
20205
20191
|
if (runDirectory === void 0) return void 0;
|
|
20206
20192
|
const run = await readRoleRunIdentity(runDirectory);
|
|
20207
20193
|
return run?.role;
|
|
20208
20194
|
}
|
|
20209
|
-
async function loadResumablePublicRole(home, runId, authority) {
|
|
20210
|
-
const loaded = await loadResumableRunRecord(
|
|
20195
|
+
async function loadResumablePublicRole(home, runId, authority, options) {
|
|
20196
|
+
const loaded = await loadResumableRunRecord(
|
|
20197
|
+
home,
|
|
20198
|
+
runId,
|
|
20199
|
+
authority,
|
|
20200
|
+
options?.runDirectory
|
|
20201
|
+
);
|
|
20211
20202
|
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
20212
20203
|
}
|
|
20213
20204
|
function admitResumedRole(loaded) {
|
|
@@ -20221,23 +20212,24 @@ function admitResumedRole(loaded) {
|
|
|
20221
20212
|
const base = resumedBaseAdmitted(loaded);
|
|
20222
20213
|
switch (record.admission) {
|
|
20223
20214
|
case "instruction": {
|
|
20215
|
+
const withSource = fields.sourceRunPath === void 0 ? base : { ...base, sourceRunPath: fields.sourceRunPath };
|
|
20224
20216
|
if (packagedResumeSourcePath(role)) {
|
|
20225
20217
|
const admitted = {
|
|
20226
20218
|
role: "inspector",
|
|
20227
|
-
...
|
|
20228
|
-
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
20219
|
+
...withSource
|
|
20229
20220
|
};
|
|
20230
20221
|
return admitted;
|
|
20231
20222
|
}
|
|
20232
20223
|
return {
|
|
20233
20224
|
role,
|
|
20234
|
-
...
|
|
20225
|
+
...withSource
|
|
20235
20226
|
};
|
|
20236
20227
|
}
|
|
20237
20228
|
case "court-materials": {
|
|
20238
20229
|
const admitted = {
|
|
20239
20230
|
role: "countersign",
|
|
20240
|
-
...base
|
|
20231
|
+
...base,
|
|
20232
|
+
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
20241
20233
|
};
|
|
20242
20234
|
return admitted;
|
|
20243
20235
|
}
|
|
@@ -20673,11 +20665,16 @@ function runIdFromNavigatorDirectory(runDirectory) {
|
|
|
20673
20665
|
if (parsed === void 0 || parsed.role !== "navigator") return void 0;
|
|
20674
20666
|
return parsed.runId;
|
|
20675
20667
|
}
|
|
20676
|
-
async function navigatorHostRunResumable(home, runId) {
|
|
20668
|
+
async function navigatorHostRunResumable(home, runId, runDirectory) {
|
|
20677
20669
|
const { piDurablePrincipalAuthority: piDurablePrincipalAuthority2 } = await Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports));
|
|
20678
20670
|
const { loadResumablePublicRole: loadResumablePublicRole2 } = await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports));
|
|
20679
20671
|
try {
|
|
20680
|
-
const loaded = await loadResumablePublicRole2(
|
|
20672
|
+
const loaded = await loadResumablePublicRole2(
|
|
20673
|
+
home,
|
|
20674
|
+
runId,
|
|
20675
|
+
piDurablePrincipalAuthority2,
|
|
20676
|
+
runDirectory === void 0 ? void 0 : { runDirectory }
|
|
20677
|
+
);
|
|
20681
20678
|
return isNavigatorSeat(loaded.admitted.role);
|
|
20682
20679
|
} catch (error) {
|
|
20683
20680
|
if (error instanceof CliUsageError) return false;
|
|
@@ -20691,7 +20688,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20691
20688
|
let noReceipt;
|
|
20692
20689
|
let routePlaybookReadFailure;
|
|
20693
20690
|
let disposed = false;
|
|
20694
|
-
let
|
|
20691
|
+
let hostRun;
|
|
20695
20692
|
const summon = deps?.summonPublicRole ?? (async (options) => {
|
|
20696
20693
|
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20697
20694
|
return summonPublicRole2(options);
|
|
@@ -20708,7 +20705,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20708
20705
|
try {
|
|
20709
20706
|
const summonHome = await resolveNavigatorLedgerHome(context);
|
|
20710
20707
|
if (disposed) return;
|
|
20711
|
-
const resumeRunId =
|
|
20708
|
+
const resumeRunId = hostRun?.runId;
|
|
20712
20709
|
const baseSummon = {
|
|
20713
20710
|
role: "navigator",
|
|
20714
20711
|
argv: [text],
|
|
@@ -20725,12 +20722,16 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20725
20722
|
if (disposed) return;
|
|
20726
20723
|
summoned = await summon(baseSummon);
|
|
20727
20724
|
} else {
|
|
20728
|
-
const canResume = await resumable(summonHome, resumeRunId);
|
|
20725
|
+
const canResume = await resumable(summonHome, resumeRunId, hostRun?.runDirectory);
|
|
20729
20726
|
if (disposed) return;
|
|
20730
20727
|
if (canResume) {
|
|
20731
|
-
summoned = await summon({
|
|
20728
|
+
summoned = await summon({
|
|
20729
|
+
...baseSummon,
|
|
20730
|
+
resumeRunId,
|
|
20731
|
+
...hostRun === void 0 ? {} : { resumeRunDirectory: hostRun.runDirectory }
|
|
20732
|
+
});
|
|
20732
20733
|
} else {
|
|
20733
|
-
|
|
20734
|
+
hostRun = void 0;
|
|
20734
20735
|
summoned = await summon(baseSummon);
|
|
20735
20736
|
}
|
|
20736
20737
|
}
|
|
@@ -20768,7 +20769,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20768
20769
|
if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
|
|
20769
20770
|
const nextRunId = runIdFromNavigatorDirectory(runDirectory);
|
|
20770
20771
|
if (nextRunId !== void 0) {
|
|
20771
|
-
|
|
20772
|
+
hostRun = { runId: nextRunId, runDirectory };
|
|
20772
20773
|
}
|
|
20773
20774
|
}
|
|
20774
20775
|
if (outcome.kind !== "accepted") {
|
|
@@ -21295,6 +21296,7 @@ init_notary_source_run();
|
|
|
21295
21296
|
|
|
21296
21297
|
// src/role-runtime.ts
|
|
21297
21298
|
init_run_dossier();
|
|
21299
|
+
init_invocation();
|
|
21298
21300
|
init_host_contracts();
|
|
21299
21301
|
init_sitian_facade();
|
|
21300
21302
|
init_host_session_record();
|
|
@@ -22923,9 +22925,8 @@ function resolveAuditedSourceRunDirectory(roleHost, ctx, role) {
|
|
|
22923
22925
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
22924
22926
|
if (runDirectory !== void 0) {
|
|
22925
22927
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
}
|
|
22928
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
22929
|
+
if (sourceRunPath !== void 0) return sourceRunPath.trim();
|
|
22929
22930
|
}
|
|
22930
22931
|
if (role === "auditor") {
|
|
22931
22932
|
const auditor = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV].trim() : "";
|