@akagilnc/pi-workflow-roles 0.1.5712 → 0.1.5751
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 +519 -590
- 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 +519 -590
- 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 +499 -579
- 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 +16 -80
- 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 +49 -93
- 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
|
@@ -962,13 +962,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
962
962
|
latest = { toolCallId: payload.toolCallId, role: payload.role, accepted: payload.accepted, at: row.timestamp };
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
let officers = {};
|
|
966
|
-
try {
|
|
967
|
-
officers = latestOfficerPointersFromRecords(history);
|
|
968
|
-
} catch (error) {
|
|
969
|
-
if (!(error instanceof TypeError)) throw error;
|
|
970
|
-
if (unreadable[RUN_HISTORY_FILE] === void 0) unreadable[RUN_HISTORY_FILE] = "malformed";
|
|
971
|
-
}
|
|
972
965
|
const sessions = {};
|
|
973
966
|
for (const row of state) {
|
|
974
967
|
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
@@ -986,7 +979,6 @@ function render(runDirectory, history, state, log, unreadable) {
|
|
|
986
979
|
if (typeof original === "string") original = join4(runDirectory, "session", basename4(original));
|
|
987
980
|
whole.host = { sessions, ...original === void 0 ? {} : { original } };
|
|
988
981
|
whole.submission = latest === void 0 ? {} : { latest };
|
|
989
|
-
whole.officers = officers;
|
|
990
982
|
if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
|
|
991
983
|
return whole;
|
|
992
984
|
}
|
|
@@ -1751,7 +1743,7 @@ var init_navigator_output = __esm({
|
|
|
1751
1743
|
|
|
1752
1744
|
// src/review-submission.ts
|
|
1753
1745
|
import { Type as Type5 } from "typebox";
|
|
1754
|
-
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewSubmissionSchema;
|
|
1746
|
+
var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewStatusField, reviewNarrativeFields, reviewSubmissionSchema, courtClauseItemSchema, courtClausesField, courtReviewSubmissionSchema;
|
|
1755
1747
|
var init_review_submission = __esm({
|
|
1756
1748
|
"src/review-submission.ts"() {
|
|
1757
1749
|
"use strict";
|
|
@@ -1759,28 +1751,62 @@ var init_review_submission = __esm({
|
|
|
1759
1751
|
REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
|
|
1760
1752
|
REVIEW_QUEUE_WORDS = ["converged", "continue", "escalate"];
|
|
1761
1753
|
REVIEW_QUEUE_STATUSES = new Set(REVIEW_QUEUE_WORDS);
|
|
1754
|
+
reviewStatusField = Type5.Union(
|
|
1755
|
+
[
|
|
1756
|
+
Type5.Literal(REVIEW_QUEUE_WORDS[0]),
|
|
1757
|
+
Type5.Literal(REVIEW_QUEUE_WORDS[1]),
|
|
1758
|
+
Type5.Literal(REVIEW_QUEUE_WORDS[2])
|
|
1759
|
+
],
|
|
1760
|
+
{
|
|
1761
|
+
description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
|
|
1762
|
+
}
|
|
1763
|
+
);
|
|
1764
|
+
reviewNarrativeFields = {
|
|
1765
|
+
findings: Type5.Optional(Type5.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
1766
|
+
reason: Type5.Optional(Type5.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
|
|
1767
|
+
violations: Type5.Optional(Type5.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
|
|
1768
|
+
conflicts: Type5.Optional(Type5.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
|
|
1769
|
+
fix: Type5.Optional(Type5.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
|
|
1770
|
+
classes: Type5.Optional(Type5.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
1771
|
+
note: Type5.Optional(Type5.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
|
|
1772
|
+
evidence: Type5.Optional(Type5.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
1773
|
+
decisionGate: Type5.Optional(Type5.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" }))
|
|
1774
|
+
};
|
|
1762
1775
|
reviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
1763
|
-
Type5.Object(
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1776
|
+
Type5.Object(
|
|
1777
|
+
{
|
|
1778
|
+
status: reviewStatusField,
|
|
1779
|
+
...reviewNarrativeFields
|
|
1780
|
+
},
|
|
1781
|
+
{ additionalProperties: true }
|
|
1782
|
+
)
|
|
1783
|
+
);
|
|
1784
|
+
courtClauseItemSchema = Type5.Object(
|
|
1785
|
+
{
|
|
1786
|
+
clause: Type5.String({
|
|
1787
|
+
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"
|
|
1788
|
+
}),
|
|
1789
|
+
ownerUuid: Type5.Union([Type5.String(), Type5.Null()], {
|
|
1790
|
+
description: "\u63A8\u51FA\u8BE5\u6761\u7684\u965B\u4E0B\u539F\u8BDD uuid\uFF1B\u65E0\u539F\u8BDD\u5219 null"
|
|
1791
|
+
}),
|
|
1792
|
+
derivation: Type5.String({
|
|
1793
|
+
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"
|
|
1794
|
+
})
|
|
1795
|
+
},
|
|
1796
|
+
{ additionalProperties: true }
|
|
1797
|
+
);
|
|
1798
|
+
courtClausesField = Type5.Array(courtClauseItemSchema, {
|
|
1799
|
+
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"
|
|
1800
|
+
});
|
|
1801
|
+
courtReviewSubmissionSchema = withTerminatingOutputDeclarations(
|
|
1802
|
+
Type5.Object(
|
|
1803
|
+
{
|
|
1804
|
+
status: reviewStatusField,
|
|
1805
|
+
...reviewNarrativeFields,
|
|
1806
|
+
clauses: courtClausesField
|
|
1807
|
+
},
|
|
1808
|
+
{ additionalProperties: true }
|
|
1809
|
+
)
|
|
1784
1810
|
);
|
|
1785
1811
|
}
|
|
1786
1812
|
});
|
|
@@ -2277,7 +2303,7 @@ var init_diarist_contracts = __esm({
|
|
|
2277
2303
|
|
|
2278
2304
|
// src/secretariat-contracts.ts
|
|
2279
2305
|
import { Type as Type13 } from "typebox";
|
|
2280
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema
|
|
2306
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema;
|
|
2281
2307
|
var init_secretariat_contracts = __esm({
|
|
2282
2308
|
"src/secretariat-contracts.ts"() {
|
|
2283
2309
|
"use strict";
|
|
@@ -2302,8 +2328,6 @@ var init_secretariat_contracts = __esm({
|
|
|
2302
2328
|
)
|
|
2303
2329
|
);
|
|
2304
2330
|
secretariatVerdictSchema.required = [];
|
|
2305
|
-
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
2306
|
-
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
2307
2331
|
}
|
|
2308
2332
|
});
|
|
2309
2333
|
|
|
@@ -2336,7 +2360,6 @@ __export(packaged_role_registry_exports, {
|
|
|
2336
2360
|
packagedBaseIsRevision: () => packagedBaseIsRevision,
|
|
2337
2361
|
packagedBindsBoardTicket: () => packagedBindsBoardTicket,
|
|
2338
2362
|
packagedBoardPlacement: () => packagedBoardPlacement,
|
|
2339
|
-
packagedDurableOfficerEntry: () => packagedDurableOfficerEntry,
|
|
2340
2363
|
packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
|
|
2341
2364
|
packagedGateStageLabel: () => packagedGateStageLabel,
|
|
2342
2365
|
packagedGateSummon: () => packagedGateSummon,
|
|
@@ -2456,11 +2479,6 @@ function packagedAuditToolName(role) {
|
|
|
2456
2479
|
if (record === void 0 || !("auditTool" in record)) return void 0;
|
|
2457
2480
|
return record.auditTool;
|
|
2458
2481
|
}
|
|
2459
|
-
function packagedDurableOfficerEntry(officer) {
|
|
2460
|
-
return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
2461
|
-
(record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
|
|
2462
|
-
);
|
|
2463
|
-
}
|
|
2464
2482
|
function packagedPublicInstructionSubject(role) {
|
|
2465
2483
|
return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
2466
2484
|
(record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
|
|
@@ -2799,8 +2817,6 @@ var init_packaged_role_registry = __esm({
|
|
|
2799
2817
|
presentSettled: "always",
|
|
2800
2818
|
summonResume: false,
|
|
2801
2819
|
admission: "court-materials",
|
|
2802
|
-
/** Durable custom entry names this officer. */
|
|
2803
|
-
durableOfficerEntry: true,
|
|
2804
2820
|
sameParent: "none",
|
|
2805
2821
|
phases: [null],
|
|
2806
2822
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
@@ -2826,8 +2842,6 @@ var init_packaged_role_registry = __esm({
|
|
|
2826
2842
|
phases: [null],
|
|
2827
2843
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
2828
2844
|
settlement: "accepted",
|
|
2829
|
-
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
2830
|
-
projectCountersignTerminal: true,
|
|
2831
2845
|
activationFlags: [
|
|
2832
2846
|
{ field: "ticketNumber" }
|
|
2833
2847
|
],
|
|
@@ -3231,15 +3245,15 @@ var init_role_submission_declarations = __esm({
|
|
|
3231
3245
|
},
|
|
3232
3246
|
notary: {
|
|
3233
3247
|
label: "\u7B26\u5B9D\u90CE\u8F93\u51FA",
|
|
3234
|
-
description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\u3002",
|
|
3248
|
+
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",
|
|
3235
3249
|
promptSnippet: "\u63D0\u4EA4\u7B26\u5B9D\u90CE\u51B3\u8BAE",
|
|
3236
|
-
parameters:
|
|
3250
|
+
parameters: courtReviewSubmissionSchema
|
|
3237
3251
|
},
|
|
3238
3252
|
countersign: {
|
|
3239
3253
|
label: "\u7ED9\u4E8B\u4E2D\u8F93\u51FA",
|
|
3240
|
-
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\u3002",
|
|
3254
|
+
description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
|
|
3241
3255
|
promptSnippet: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE",
|
|
3242
|
-
parameters:
|
|
3256
|
+
parameters: courtReviewSubmissionSchema
|
|
3243
3257
|
},
|
|
3244
3258
|
secretariat: {
|
|
3245
3259
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
@@ -3407,7 +3421,9 @@ var run_terminal_artifacts_exports = {};
|
|
|
3407
3421
|
__export(run_terminal_artifacts_exports, {
|
|
3408
3422
|
ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
|
|
3409
3423
|
TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
|
|
3424
|
+
isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
|
|
3410
3425
|
readRunTerminal: () => readRunTerminal,
|
|
3426
|
+
roleFromRunDirectory: () => roleFromRunDirectory,
|
|
3411
3427
|
runIdFromRunDirectory: () => runIdFromRunDirectory,
|
|
3412
3428
|
writeRunTerminal: () => writeRunTerminal
|
|
3413
3429
|
});
|
|
@@ -3463,6 +3479,12 @@ function withSubmittedPayloads(runDirectory, body) {
|
|
|
3463
3479
|
function runIdFromRunDirectory(runDirectory) {
|
|
3464
3480
|
return parseRunLeaf(basename6(runDirectory))?.runId;
|
|
3465
3481
|
}
|
|
3482
|
+
function roleFromRunDirectory(runDirectory) {
|
|
3483
|
+
return parseRunLeaf(basename6(runDirectory))?.role;
|
|
3484
|
+
}
|
|
3485
|
+
function isTicketCourtCountersignSource(runDirectory) {
|
|
3486
|
+
return roleFromRunDirectory(runDirectory) === "countersign";
|
|
3487
|
+
}
|
|
3466
3488
|
var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
|
|
3467
3489
|
var init_run_terminal_artifacts = __esm({
|
|
3468
3490
|
"src/run-terminal-artifacts.ts"() {
|
|
@@ -3573,6 +3595,18 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
3573
3595
|
);
|
|
3574
3596
|
}
|
|
3575
3597
|
if (outcome.kind === "accepted") {
|
|
3598
|
+
if (outcome.decisiveFacts?.directionUnsettled === true) {
|
|
3599
|
+
const receipt2 = thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome);
|
|
3600
|
+
return withOfficerRunId(
|
|
3601
|
+
{
|
|
3602
|
+
status: "needs_reask",
|
|
3603
|
+
officer,
|
|
3604
|
+
receipt: receipt2,
|
|
3605
|
+
receivedStatus: receivedDiscriminator(receipt2, "status")
|
|
3606
|
+
},
|
|
3607
|
+
summoned
|
|
3608
|
+
);
|
|
3609
|
+
}
|
|
3576
3610
|
return withOfficerRunId(
|
|
3577
3611
|
projectOfficerPayloads(officer, thisCourt, outcome.status),
|
|
3578
3612
|
summoned
|
|
@@ -5261,12 +5295,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5261
5295
|
const subjectDirectory = dirname7(dirname7(candidate));
|
|
5262
5296
|
const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname7(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve7(dirname7(subjectDirectory)) === resolve7(bookDirectory);
|
|
5263
5297
|
if (isLegacyUnboundLocator) {
|
|
5264
|
-
candidate = await
|
|
5265
|
-
options.home,
|
|
5266
|
-
identity2.runId,
|
|
5267
|
-
bookKey,
|
|
5268
|
-
identity2.role
|
|
5269
|
-
) ?? candidate;
|
|
5298
|
+
candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
|
|
5270
5299
|
}
|
|
5271
5300
|
}
|
|
5272
5301
|
const real = await requireRunDirectory(candidate, raw);
|
|
@@ -6484,6 +6513,11 @@ import {
|
|
|
6484
6513
|
writeFile
|
|
6485
6514
|
} from "node:fs/promises";
|
|
6486
6515
|
import { dirname as dirname8, isAbsolute as isAbsolute5, join as join10, resolve as resolve8 } from "node:path";
|
|
6516
|
+
function admittedSourceRunPath(admitted) {
|
|
6517
|
+
if (!isRecord(admitted)) return void 0;
|
|
6518
|
+
const path = admitted.sourceRunPath;
|
|
6519
|
+
return typeof path === "string" && path.trim() !== "" ? path : void 0;
|
|
6520
|
+
}
|
|
6487
6521
|
function normalizeAdmittedAttachment(raw) {
|
|
6488
6522
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
6489
6523
|
const record = raw;
|
|
@@ -6595,6 +6629,23 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubj
|
|
|
6595
6629
|
};
|
|
6596
6630
|
});
|
|
6597
6631
|
}
|
|
6632
|
+
function persistAdmittedAuditedSubmissionToolCallId(runDirectory, auditedSubmissionToolCallId) {
|
|
6633
|
+
const id = auditedSubmissionToolCallId.trim();
|
|
6634
|
+
if (id === "") {
|
|
6635
|
+
throw new Error("persistAdmittedAuditedSubmissionToolCallId requires a non-empty id");
|
|
6636
|
+
}
|
|
6637
|
+
if (readPageSync(runDirectory, "admitted") === void 0) return;
|
|
6638
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
6639
|
+
if (current.auditedSubmissionToolCallId === id) return void 0;
|
|
6640
|
+
return { ...current, auditedSubmissionToolCallId: id };
|
|
6641
|
+
});
|
|
6642
|
+
}
|
|
6643
|
+
function readAdmittedAuditedSubmissionToolCallId(runDirectory) {
|
|
6644
|
+
const page = readPageSync(runDirectory, "admitted");
|
|
6645
|
+
if (page === void 0) return void 0;
|
|
6646
|
+
const id = page.auditedSubmissionToolCallId;
|
|
6647
|
+
return typeof id === "string" && id.trim() !== "" ? id : void 0;
|
|
6648
|
+
}
|
|
6598
6649
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
6599
6650
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
6600
6651
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
@@ -8113,13 +8164,10 @@ async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
|
8113
8164
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
8114
8165
|
return mapOwnedToSubmissionRows(owned);
|
|
8115
8166
|
}
|
|
8116
|
-
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId,
|
|
8167
|
+
async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScope) {
|
|
8117
8168
|
if (attemptId.length === 0) return [];
|
|
8118
|
-
const
|
|
8119
|
-
|
|
8120
|
-
runId,
|
|
8121
|
-
home === void 0 ? {} : { home }
|
|
8122
|
-
);
|
|
8169
|
+
const scope = resolveReadScope(homeOrScope);
|
|
8170
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
8123
8171
|
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
8124
8172
|
}
|
|
8125
8173
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
@@ -8818,7 +8866,6 @@ __export(settlement_exports, {
|
|
|
8818
8866
|
LifecycleReadFailure: () => LifecycleReadFailure,
|
|
8819
8867
|
NAVIGATOR_POST_ROLE_GRACE_MS: () => NAVIGATOR_POST_ROLE_GRACE_MS,
|
|
8820
8868
|
appendRunAttemptHistory: () => appendRunAttemptHistory,
|
|
8821
|
-
attachPostAuditCountersignFact: () => attachPostAuditCountersignFact,
|
|
8822
8869
|
attachRecordedSubmissions: () => attachRecordedSubmissions,
|
|
8823
8870
|
classifyPostAdmissionFailure: () => classifyPostAdmissionFailure,
|
|
8824
8871
|
conciseChildDiagnostic: () => conciseChildDiagnostic,
|
|
@@ -8932,13 +8979,12 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
8932
8979
|
return { outcome: { kind: "accepted", role, payloads }, ...belonging };
|
|
8933
8980
|
}
|
|
8934
8981
|
async function sealedLedgerOutcome(admitted, role, scope) {
|
|
8935
|
-
const home = sealedLedgerHome(admitted);
|
|
8936
8982
|
if (scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0) {
|
|
8937
8983
|
const thisCourt = await readAttemptScopedSubmissionRows(
|
|
8938
8984
|
admitted.projectRoot,
|
|
8939
8985
|
admitted.runId,
|
|
8940
8986
|
scope.courtAttemptId,
|
|
8941
|
-
|
|
8987
|
+
ledgerReadScope(admitted, scope)
|
|
8942
8988
|
);
|
|
8943
8989
|
return roleOutcomeFromRows(role, thisCourt);
|
|
8944
8990
|
}
|
|
@@ -9665,97 +9711,11 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
9665
9711
|
if (toolName === void 0) {
|
|
9666
9712
|
throw new Error(`accepted-seat settlement is not declared for ${admitted.role}`);
|
|
9667
9713
|
}
|
|
9668
|
-
|
|
9669
|
-
const record = packagedRoleMetadata(admitted.role);
|
|
9670
|
-
if (settled === void 0 || record === void 0 || !("projectCountersignTerminal" in record) || record.projectCountersignTerminal !== true) {
|
|
9671
|
-
return settled;
|
|
9672
|
-
}
|
|
9673
|
-
return applySecretariatCountersignTerminal(admitted, authority, settled, scope);
|
|
9714
|
+
return settleSealedSeat(admitted, authority, scope, { acceptedOnly: false });
|
|
9674
9715
|
}
|
|
9675
9716
|
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
9676
9717
|
return settleSeat(admitted, authority, scope);
|
|
9677
9718
|
}
|
|
9678
|
-
function countersignTerminalFromEntries(entries) {
|
|
9679
|
-
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
9680
|
-
const entry = entries[index];
|
|
9681
|
-
if (entry?.type !== "custom") continue;
|
|
9682
|
-
if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
|
|
9683
|
-
const data = isRecord(entry.data) ? entry.data : void 0;
|
|
9684
|
-
if (data === void 0 || !packagedDurableOfficerEntry(data.officer)) continue;
|
|
9685
|
-
if (data.receipt === void 0) continue;
|
|
9686
|
-
const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
|
|
9687
|
-
return {
|
|
9688
|
-
receipt: data.receipt,
|
|
9689
|
-
...runId === void 0 ? {} : { runId }
|
|
9690
|
-
};
|
|
9691
|
-
}
|
|
9692
|
-
return void 0;
|
|
9693
|
-
}
|
|
9694
|
-
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
9695
|
-
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
9696
|
-
return {
|
|
9697
|
-
...roleOutcome,
|
|
9698
|
-
decisiveFacts: {
|
|
9699
|
-
...prior,
|
|
9700
|
-
[SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY]: officer
|
|
9701
|
-
}
|
|
9702
|
-
};
|
|
9703
|
-
}
|
|
9704
|
-
function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
9705
|
-
const payloads = roleOutcome.payloads ?? [];
|
|
9706
|
-
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
9707
|
-
const payload = payloads[index];
|
|
9708
|
-
if (!isRecord(payload)) continue;
|
|
9709
|
-
const status = payload.secretariatStatus;
|
|
9710
|
-
if (typeof status !== "string") continue;
|
|
9711
|
-
return status === "converged";
|
|
9712
|
-
}
|
|
9713
|
-
return false;
|
|
9714
|
-
}
|
|
9715
|
-
async function applySecretariatCountersignTerminal(admitted, authority, settled, scope) {
|
|
9716
|
-
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
9717
|
-
let entries = [];
|
|
9718
|
-
try {
|
|
9719
|
-
entries = await readBoundSessionEntries(coordinates.sessionFile);
|
|
9720
|
-
} catch (error) {
|
|
9721
|
-
if (!isEnoent(error)) {
|
|
9722
|
-
await noteSettlementFault(
|
|
9723
|
-
admitted.runDirectory,
|
|
9724
|
-
scope,
|
|
9725
|
-
`secretariat officer read failed beside lawful terminal: ${describeErrorIdentity(error)}`
|
|
9726
|
-
);
|
|
9727
|
-
}
|
|
9728
|
-
return settled;
|
|
9729
|
-
}
|
|
9730
|
-
const officer = countersignTerminalFromEntries(entries);
|
|
9731
|
-
if (officer === void 0) return settled;
|
|
9732
|
-
if (settled.roleOutcome.kind === "audit_escalation") {
|
|
9733
|
-
return {
|
|
9734
|
-
...settled,
|
|
9735
|
-
roleOutcome: withCountersignTerminalFact(
|
|
9736
|
-
{
|
|
9737
|
-
...settled.roleOutcome,
|
|
9738
|
-
payloads: [officer.receipt]
|
|
9739
|
-
},
|
|
9740
|
-
officer
|
|
9741
|
-
)
|
|
9742
|
-
};
|
|
9743
|
-
}
|
|
9744
|
-
if (settled.roleOutcome.kind === "accepted") {
|
|
9745
|
-
if (!acceptedSecretariatDefinesOfficerProjection(settled.roleOutcome)) {
|
|
9746
|
-
return settled;
|
|
9747
|
-
}
|
|
9748
|
-
return {
|
|
9749
|
-
...settled,
|
|
9750
|
-
roleOutcome: withCountersignTerminalFact(settled.roleOutcome, officer)
|
|
9751
|
-
};
|
|
9752
|
-
}
|
|
9753
|
-
return settled;
|
|
9754
|
-
}
|
|
9755
|
-
async function attachPostAuditCountersignFact(admitted, authority, terminal, scope) {
|
|
9756
|
-
if (admitted.role !== "secretariat") return terminal;
|
|
9757
|
-
return applySecretariatCountersignTerminal(admitted, authority, terminal, scope);
|
|
9758
|
-
}
|
|
9759
9719
|
async function publishFailureTerminal(admitted, failure, coordinates, onErrorPublished, scope) {
|
|
9760
9720
|
let historyFailure;
|
|
9761
9721
|
let historyFailed = false;
|
|
@@ -9921,7 +9881,6 @@ var init_settlement = __esm({
|
|
|
9921
9881
|
init_engine_detour_usage();
|
|
9922
9882
|
init_dossier_resolution();
|
|
9923
9883
|
init_invocation();
|
|
9924
|
-
init_secretariat_contracts();
|
|
9925
9884
|
init_navigator_invocation_identity();
|
|
9926
9885
|
init_packaged_role_registry();
|
|
9927
9886
|
init_receipt_delivery_policy();
|
|
@@ -9947,18 +9906,6 @@ var init_settlement = __esm({
|
|
|
9947
9906
|
// src/external-host-turn-loop.ts
|
|
9948
9907
|
import { existsSync as existsSync5 } from "node:fs";
|
|
9949
9908
|
import { basename as basename8 } from "node:path";
|
|
9950
|
-
async function resolveLiveRunDirectoryPath(recordedPath, home) {
|
|
9951
|
-
if (existsSync5(recordedPath)) return recordedPath;
|
|
9952
|
-
const parsed = parseRunLeaf(basename8(recordedPath));
|
|
9953
|
-
const bookKey = tryBookKeyFromAkRolesPath(recordedPath);
|
|
9954
|
-
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
9955
|
-
return await findRunDirectoryById(
|
|
9956
|
-
home,
|
|
9957
|
-
parsed.runId,
|
|
9958
|
-
bookKey,
|
|
9959
|
-
parsed.role
|
|
9960
|
-
);
|
|
9961
|
-
}
|
|
9962
9909
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
9963
9910
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
9964
9911
|
if (live === void 0) {
|
|
@@ -10182,9 +10129,9 @@ function createSerializedRoleTurnHost(execute) {
|
|
|
10182
10129
|
var init_external_host_turn_loop = __esm({
|
|
10183
10130
|
"src/external-host-turn-loop.ts"() {
|
|
10184
10131
|
"use strict";
|
|
10185
|
-
init_activation_ledger_topology();
|
|
10186
10132
|
init_settlement();
|
|
10187
10133
|
init_run_lifecycle();
|
|
10134
|
+
init_run_lifecycle();
|
|
10188
10135
|
init_receipt_delivery_policy();
|
|
10189
10136
|
init_role_run_placement();
|
|
10190
10137
|
init_role_run_relocation();
|
|
@@ -11715,99 +11662,6 @@ var init_session_opening_materials = __esm({
|
|
|
11715
11662
|
}
|
|
11716
11663
|
});
|
|
11717
11664
|
|
|
11718
|
-
// src/archivist-record-pointer.ts
|
|
11719
|
-
import { basename as basename9, join as join19 } from "node:path";
|
|
11720
|
-
function bookDirectOfficerRunPointer(options) {
|
|
11721
|
-
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
11722
|
-
const pointer = {
|
|
11723
|
-
version: 1,
|
|
11724
|
-
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
11725
|
-
officer: options.officer,
|
|
11726
|
-
sessionFile: options.sessionFile,
|
|
11727
|
-
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {},
|
|
11728
|
-
...submissionToolCallId === "" ? {} : { submissionToolCallId }
|
|
11729
|
-
};
|
|
11730
|
-
reportRunRecord(runDirectoryOfSessionFile(options.parentSessionFile), OFFICER_POINTER_RECORD_KIND, pointer, "submission-gate");
|
|
11731
|
-
return pointer;
|
|
11732
|
-
}
|
|
11733
|
-
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
11734
|
-
const where = `${parentRunDirectory} officers`;
|
|
11735
|
-
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
11736
|
-
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
11737
|
-
}
|
|
11738
|
-
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
11739
|
-
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
11740
|
-
}
|
|
11741
|
-
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
11742
|
-
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
11743
|
-
let sessionFile = raw.sessionFile;
|
|
11744
|
-
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
11745
|
-
const leaf = parseRunLeaf(basename9(recordedRunDirectory));
|
|
11746
|
-
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
11747
|
-
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
11748
|
-
const currentRunDirectory = await findRunDirectoryById(
|
|
11749
|
-
homeFromRunDirectory(parentRunDirectory),
|
|
11750
|
-
leaf.runId,
|
|
11751
|
-
parentIdentity.bookKey,
|
|
11752
|
-
leaf.role
|
|
11753
|
-
);
|
|
11754
|
-
if (currentRunDirectory !== void 0) {
|
|
11755
|
-
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
11756
|
-
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
11757
|
-
}
|
|
11758
|
-
}
|
|
11759
|
-
const submissionToolCallId = typeof raw.submissionToolCallId === "string" && raw.submissionToolCallId.trim() !== "" ? raw.submissionToolCallId : void 0;
|
|
11760
|
-
return {
|
|
11761
|
-
sessionFile,
|
|
11762
|
-
...officer === void 0 ? {} : { officer },
|
|
11763
|
-
...runDirectory === void 0 ? {} : { runDirectory },
|
|
11764
|
-
...submissionToolCallId === void 0 ? {} : { submissionToolCallId }
|
|
11765
|
-
};
|
|
11766
|
-
}
|
|
11767
|
-
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
11768
|
-
const { records, diagnostics } = await readSitianRecords(join19(parentRunDirectory, RUN_HISTORY_FILE));
|
|
11769
|
-
if (diagnostics.length > 0) {
|
|
11770
|
-
throw new Error(
|
|
11771
|
-
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
11772
|
-
);
|
|
11773
|
-
}
|
|
11774
|
-
return latestOfficerPointersFromRecords(records);
|
|
11775
|
-
}
|
|
11776
|
-
async function readOfficerPointers(parentRunDirectory) {
|
|
11777
|
-
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
11778
|
-
return Promise.all(
|
|
11779
|
-
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
11780
|
-
);
|
|
11781
|
-
}
|
|
11782
|
-
async function readDirectOfficerRunPointer(parentSessionFile, officer) {
|
|
11783
|
-
try {
|
|
11784
|
-
const parentRunDirectory = runDirectoryOfSessionFile(parentSessionFile);
|
|
11785
|
-
const pointer = await resolveOfficerPointer(
|
|
11786
|
-
(await readBookedOfficerPointers(parentRunDirectory))[officer],
|
|
11787
|
-
parentRunDirectory
|
|
11788
|
-
);
|
|
11789
|
-
if (pointer.officer !== officer) return void 0;
|
|
11790
|
-
return { ...pointer, officer, version: 1, kind: DIRECT_OFFICER_RUN_POINTER_KIND };
|
|
11791
|
-
} catch {
|
|
11792
|
-
return void 0;
|
|
11793
|
-
}
|
|
11794
|
-
}
|
|
11795
|
-
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
11796
|
-
var init_archivist_record_pointer = __esm({
|
|
11797
|
-
"src/archivist-record-pointer.ts"() {
|
|
11798
|
-
"use strict";
|
|
11799
|
-
init_unknown_value();
|
|
11800
|
-
init_run_dossier();
|
|
11801
|
-
init_run_dossier_files();
|
|
11802
|
-
init_sitian_facade();
|
|
11803
|
-
init_activation_ledger_topology();
|
|
11804
|
-
init_run_lifecycle();
|
|
11805
|
-
init_role_run_relocation();
|
|
11806
|
-
init_role_run_placement();
|
|
11807
|
-
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
11808
|
-
}
|
|
11809
|
-
});
|
|
11810
|
-
|
|
11811
11665
|
// src/doctor-auditor.ts
|
|
11812
11666
|
function createPiDoctorAuditor() {
|
|
11813
11667
|
return async (options) => {
|
|
@@ -11953,6 +11807,20 @@ var init_worker_submission_contracts = __esm({
|
|
|
11953
11807
|
});
|
|
11954
11808
|
|
|
11955
11809
|
// src/submission-gate.ts
|
|
11810
|
+
async function directoryForSummonedOfficer(officer, summoned) {
|
|
11811
|
+
if (summoned.admitted?.role === officer) {
|
|
11812
|
+
return summoned.admitted.runDirectory;
|
|
11813
|
+
}
|
|
11814
|
+
let dir = typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? summoned.runDirectory : summoned.admitted?.runDirectory;
|
|
11815
|
+
for (let hop = 0; hop < 8 && dir !== void 0; hop += 1) {
|
|
11816
|
+
const identity = await readRoleRunIdentity(dir);
|
|
11817
|
+
if (identity?.role === officer) return dir;
|
|
11818
|
+
const parent = await readRunParentPath(dir);
|
|
11819
|
+
if (parent === void 0 || parent === dir) break;
|
|
11820
|
+
dir = parent;
|
|
11821
|
+
}
|
|
11822
|
+
return void 0;
|
|
11823
|
+
}
|
|
11956
11824
|
function latestQueueStatus(terminal) {
|
|
11957
11825
|
const outcome = terminal?.roleOutcome;
|
|
11958
11826
|
if (outcome === void 0) return void 0;
|
|
@@ -11990,24 +11858,6 @@ function createDefaultGateOfficerSummon(options) {
|
|
|
11990
11858
|
});
|
|
11991
11859
|
};
|
|
11992
11860
|
}
|
|
11993
|
-
function bookDirectOfficerPointer(context, officer, result, summoned, toolCallId) {
|
|
11994
|
-
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask" && result.status !== "transport_failure") {
|
|
11995
|
-
return;
|
|
11996
|
-
}
|
|
11997
|
-
const parentFile = context.sessionManager?.getSessionFile?.();
|
|
11998
|
-
if (typeof parentFile !== "string" || parentFile.trim() === "") return;
|
|
11999
|
-
const sessionFile = sessionFileFromPublicSummon(summoned);
|
|
12000
|
-
if (sessionFile === void 0) {
|
|
12001
|
-
return;
|
|
12002
|
-
}
|
|
12003
|
-
bookDirectOfficerRunPointer({
|
|
12004
|
-
parentSessionFile: parentFile,
|
|
12005
|
-
officer,
|
|
12006
|
-
sessionFile,
|
|
12007
|
-
...typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? { runDirectory: summoned.runDirectory } : {},
|
|
12008
|
-
...toolCallId.trim() === "" ? {} : { submissionToolCallId: toolCallId }
|
|
12009
|
-
});
|
|
12010
|
-
}
|
|
12011
11861
|
async function requireSubmissionGate(options) {
|
|
12012
11862
|
let reask;
|
|
12013
11863
|
let reasksSpent = 0;
|
|
@@ -12025,17 +11875,13 @@ async function requireSubmissionGate(options) {
|
|
|
12025
11875
|
...reask === void 0 ? {} : { reask }
|
|
12026
11876
|
});
|
|
12027
11877
|
const gatekeeper = projected.result;
|
|
12028
|
-
if (projected.summoned !== void 0) {
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
options.toolCallId
|
|
12036
|
-
);
|
|
12037
|
-
} catch (error) {
|
|
12038
|
-
options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
|
|
11878
|
+
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")) {
|
|
11879
|
+
const officerRunDirectory = await directoryForSummonedOfficer(
|
|
11880
|
+
projected.officer,
|
|
11881
|
+
projected.summoned
|
|
11882
|
+
);
|
|
11883
|
+
if (officerRunDirectory !== void 0) {
|
|
11884
|
+
persistAdmittedAuditedSubmissionToolCallId(officerRunDirectory, options.toolCallId);
|
|
12039
11885
|
}
|
|
12040
11886
|
}
|
|
12041
11887
|
if (gatekeeper.status === "converged") {
|
|
@@ -12043,7 +11889,11 @@ async function requireSubmissionGate(options) {
|
|
|
12043
11889
|
status: "converged",
|
|
12044
11890
|
officer: projected.officer,
|
|
12045
11891
|
receipt: gatekeeper.receipt,
|
|
12046
|
-
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
|
|
11892
|
+
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
11893
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
11894
|
+
// Keep the officer terminal for escalate / unsettled surfaces; parent
|
|
11895
|
+
// finals do not project other-seat tables (#1195).
|
|
11896
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
12047
11897
|
};
|
|
12048
11898
|
}
|
|
12049
11899
|
if (gatekeeper.status === "continue") {
|
|
@@ -12055,7 +11905,8 @@ async function requireSubmissionGate(options) {
|
|
|
12055
11905
|
};
|
|
12056
11906
|
}
|
|
12057
11907
|
if (gatekeeper.status === "needs_reask") {
|
|
12058
|
-
|
|
11908
|
+
const nestedIncomplete = projected.summoned?.terminal?.roleOutcome.kind === "accepted" && projected.summoned.terminal.roleOutcome.decisiveFacts?.directionUnsettled === true;
|
|
11909
|
+
if (nestedIncomplete || reasksSpent >= reaskLimit) {
|
|
12059
11910
|
return {
|
|
12060
11911
|
status: "needs_reask",
|
|
12061
11912
|
officer: projected.officer,
|
|
@@ -12082,7 +11933,9 @@ async function requireSubmissionGate(options) {
|
|
|
12082
11933
|
officer: projected.officer,
|
|
12083
11934
|
receipt: gatekeeper.receipt,
|
|
12084
11935
|
...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {},
|
|
12085
|
-
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {}
|
|
11936
|
+
...typeof projected.summoned?.runDirectory === "string" && projected.summoned.runDirectory.trim() !== "" ? { runDirectory: projected.summoned.runDirectory } : {},
|
|
11937
|
+
// Keep the actual officer terminal so callers resume that seat.
|
|
11938
|
+
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
12086
11939
|
};
|
|
12087
11940
|
}
|
|
12088
11941
|
options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
|
|
@@ -12092,11 +11945,11 @@ async function requireSubmissionGate(options) {
|
|
|
12092
11945
|
var init_submission_gate = __esm({
|
|
12093
11946
|
"src/submission-gate.ts"() {
|
|
12094
11947
|
"use strict";
|
|
12095
|
-
|
|
11948
|
+
init_invocation();
|
|
11949
|
+
init_run_lifecycle();
|
|
12096
11950
|
init_gatekeeper_role();
|
|
12097
11951
|
init_submission_errors();
|
|
12098
11952
|
init_receipt_delivery_policy();
|
|
12099
|
-
init_session_assistant_usage();
|
|
12100
11953
|
init_unknown_value();
|
|
12101
11954
|
}
|
|
12102
11955
|
});
|
|
@@ -12116,7 +11969,7 @@ __export(auditor_soul_exports, {
|
|
|
12116
11969
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
12117
11970
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
12118
11971
|
});
|
|
12119
|
-
import { basename as
|
|
11972
|
+
import { basename as basename9 } from "node:path";
|
|
12120
11973
|
function auditorSoulRelativePath(role) {
|
|
12121
11974
|
return `souls/${role}-auditor.md`;
|
|
12122
11975
|
}
|
|
@@ -12152,22 +12005,24 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
12152
12005
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
12153
12006
|
}
|
|
12154
12007
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
12155
|
-
const role = parseRunLeaf(
|
|
12008
|
+
const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
|
|
12156
12009
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
12157
12010
|
}
|
|
12158
|
-
async function readAuditorResumeBinding(
|
|
12159
|
-
const record = readPageSync(runDirectory, "admitted");
|
|
12011
|
+
async function readAuditorResumeBinding(admitted) {
|
|
12012
|
+
const record = readPageSync(admitted.runDirectory, "admitted");
|
|
12160
12013
|
if (record === void 0) return void 0;
|
|
12161
|
-
|
|
12162
|
-
|
|
12014
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
12015
|
+
if (sourceRunPath === void 0) return void 0;
|
|
12016
|
+
const subject = isAuditorSoulRole(record.auditorSubject) ? record.auditorSubject : subjectFromSourceDirectory(sourceRunPath);
|
|
12163
12017
|
if (subject === void 0) return void 0;
|
|
12164
|
-
return { subject, sourceRunDirectory:
|
|
12018
|
+
return { subject, sourceRunDirectory: sourceRunPath };
|
|
12165
12019
|
}
|
|
12166
12020
|
var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
|
|
12167
12021
|
var init_auditor_soul = __esm({
|
|
12168
12022
|
"src/auditor-soul.ts"() {
|
|
12169
12023
|
"use strict";
|
|
12170
12024
|
init_run_dossier();
|
|
12025
|
+
init_invocation();
|
|
12171
12026
|
init_role_run_placement();
|
|
12172
12027
|
init_unknown_value();
|
|
12173
12028
|
init_session_opening_materials();
|
|
@@ -12193,16 +12048,16 @@ var init_auditor_soul = __esm({
|
|
|
12193
12048
|
// src/public-cli/machine-method-skills.ts
|
|
12194
12049
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
12195
12050
|
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12196
|
-
import { join as
|
|
12051
|
+
import { join as join20 } from "node:path";
|
|
12197
12052
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
12198
12053
|
function skillRoot(home) {
|
|
12199
|
-
return
|
|
12054
|
+
return join20(home, ".agents/skills");
|
|
12200
12055
|
}
|
|
12201
12056
|
function installedMethodSkillPath(home, name) {
|
|
12202
12057
|
return installedSkillPath(skillRoot(home), name);
|
|
12203
12058
|
}
|
|
12204
12059
|
function installedSkillPath(root, name) {
|
|
12205
|
-
const path =
|
|
12060
|
+
const path = join20(root, name, "SKILL.md");
|
|
12206
12061
|
try {
|
|
12207
12062
|
if (!statSync5(path).isFile()) return void 0;
|
|
12208
12063
|
accessSync(path, constants2.R_OK);
|
|
@@ -12215,9 +12070,9 @@ function installedSkillPath(root, name) {
|
|
|
12215
12070
|
}
|
|
12216
12071
|
function linkedSkillRoot(home, host) {
|
|
12217
12072
|
if (host === "claude" || host === "claude-code") {
|
|
12218
|
-
return
|
|
12073
|
+
return join20(process.env.CLAUDE_CONFIG_DIR?.trim() || join20(home, ".claude"), "skills");
|
|
12219
12074
|
}
|
|
12220
|
-
if (host === "hermes") return
|
|
12075
|
+
if (host === "hermes") return join20(home, ".hermes/skills");
|
|
12221
12076
|
return void 0;
|
|
12222
12077
|
}
|
|
12223
12078
|
async function occupied(path) {
|
|
@@ -12274,7 +12129,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12274
12129
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
12275
12130
|
let unsourced = false;
|
|
12276
12131
|
for (const name of packagedMethodSkillNames()) {
|
|
12277
|
-
const path =
|
|
12132
|
+
const path = join20(canonical, name);
|
|
12278
12133
|
if (await occupied(path)) {
|
|
12279
12134
|
warnOccupied(path, stdout);
|
|
12280
12135
|
continue;
|
|
@@ -12304,9 +12159,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12304
12159
|
throw error;
|
|
12305
12160
|
}
|
|
12306
12161
|
for (const name of packagedMethodSkillNames()) {
|
|
12307
|
-
const target =
|
|
12162
|
+
const target = join20(canonical, name);
|
|
12308
12163
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12309
|
-
const link =
|
|
12164
|
+
const link = join20(root, name);
|
|
12310
12165
|
if (await occupied(link)) {
|
|
12311
12166
|
warnOccupied(link, stdout);
|
|
12312
12167
|
continue;
|
|
@@ -12714,7 +12569,6 @@ var init_auto_resume = __esm({
|
|
|
12714
12569
|
|
|
12715
12570
|
// src/public-cli/post-admission.ts
|
|
12716
12571
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12717
|
-
import { existsSync as existsSync11 } from "node:fs";
|
|
12718
12572
|
function describeCaughtError(error) {
|
|
12719
12573
|
if (error instanceof Error) {
|
|
12720
12574
|
const code = error.code;
|
|
@@ -12749,14 +12603,14 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12749
12603
|
}
|
|
12750
12604
|
async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLease) {
|
|
12751
12605
|
const home = homeFromRunDirectory(admitted.runDirectory);
|
|
12752
|
-
const found = await
|
|
12753
|
-
if (found === void 0
|
|
12606
|
+
const found = await resolveLiveRunDirectoryPath(admitted.runDirectory, home);
|
|
12607
|
+
if (found === void 0) {
|
|
12754
12608
|
throw new Error(
|
|
12755
12609
|
`admitted run ${admitted.runId} missing after host turn; not found under ${home}`
|
|
12756
12610
|
);
|
|
12757
12611
|
}
|
|
12758
12612
|
let relocation;
|
|
12759
|
-
if (found !==
|
|
12613
|
+
if (found !== admitted.runDirectory) {
|
|
12760
12614
|
const oldRunDirectory = admitted.runDirectory;
|
|
12761
12615
|
const coords = { ...authority.decode(admitted.principal) };
|
|
12762
12616
|
rewritePrincipalSessionPaths(
|
|
@@ -12774,7 +12628,7 @@ async function refreshAdmittedPlacementAfterHostTurn(admitted, authority, heldLe
|
|
|
12774
12628
|
relocation = { oldRunDirectory, newRunDirectory: found };
|
|
12775
12629
|
}
|
|
12776
12630
|
if (admitted.ticketNumber === void 0) {
|
|
12777
|
-
const boardTicket = await readBoardTicketNumber(found
|
|
12631
|
+
const boardTicket = await readBoardTicketNumber(found);
|
|
12778
12632
|
if (boardTicket !== void 0) {
|
|
12779
12633
|
admitted.ticketNumber = boardTicket;
|
|
12780
12634
|
}
|
|
@@ -13811,10 +13665,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13811
13665
|
return { exitCode: error instanceof CliUsageError ? 2 : 1 };
|
|
13812
13666
|
}
|
|
13813
13667
|
}
|
|
13814
|
-
async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
13668
|
+
async function pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
13815
13669
|
let foundRunDirectory;
|
|
13816
13670
|
try {
|
|
13817
|
-
foundRunDirectory = await findRunDirectoryById(home, runId);
|
|
13671
|
+
foundRunDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
13818
13672
|
} catch {
|
|
13819
13673
|
return false;
|
|
13820
13674
|
}
|
|
@@ -13839,8 +13693,8 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13839
13693
|
);
|
|
13840
13694
|
return true;
|
|
13841
13695
|
}
|
|
13842
|
-
async function presentLocatedResumeFailure(home, runId, authority, io, thrown) {
|
|
13843
|
-
return await pointExistingRunFailure(home, runId, authority, io, thrown);
|
|
13696
|
+
async function presentLocatedResumeFailure(home, runId, authority, io, thrown, knownRunDirectory) {
|
|
13697
|
+
return await pointExistingRunFailure(home, runId, authority, io, thrown, knownRunDirectory);
|
|
13844
13698
|
}
|
|
13845
13699
|
function writeResumeFailurePointer(io, errorPath) {
|
|
13846
13700
|
io.stderr(formatCliDiagnostic(`\u7EED\u8DD1\u5931\u8D25\uFF0C\u5F53\u6B21\u9519\u8BEF\u8BB0\u5F55\uFF1A${errorPath}`));
|
|
@@ -13997,15 +13851,15 @@ var init_post_admission = __esm({
|
|
|
13997
13851
|
async function tryResumeSameTicketSeatRun(input) {
|
|
13998
13852
|
if (input.freshSummons === true) return void 0;
|
|
13999
13853
|
if (input.parentRunPath.trim() === "") return void 0;
|
|
14000
|
-
const
|
|
13854
|
+
const previous = await findLatestRunForSeatTicket({
|
|
14001
13855
|
home: input.home,
|
|
14002
13856
|
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
14003
13857
|
role: input.role,
|
|
14004
13858
|
parentRunPath: input.parentRunPath,
|
|
14005
13859
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
14006
13860
|
});
|
|
14007
|
-
if (
|
|
14008
|
-
return await input.resume(
|
|
13861
|
+
if (previous === void 0) return void 0;
|
|
13862
|
+
return await input.resume(previous.runId, input.summons, previous.runDirectory);
|
|
14009
13863
|
}
|
|
14010
13864
|
var init_seat_ticket_binding = __esm({
|
|
14011
13865
|
"src/public-cli/seat-ticket-binding.ts"() {
|
|
@@ -14148,11 +14002,9 @@ async function presentOriginalVolume(held, terminal, io, runDirectory) {
|
|
|
14148
14002
|
}
|
|
14149
14003
|
for (const value of held) io.stdout(value);
|
|
14150
14004
|
}
|
|
14151
|
-
function withUnsettledDirection(parent
|
|
14005
|
+
function withUnsettledDirection(parent) {
|
|
14152
14006
|
const outcome = parent.roleOutcome;
|
|
14153
14007
|
if (outcome.kind !== "accepted" && outcome.kind !== "audit_escalation") return parent;
|
|
14154
|
-
const officerOutcome = officer?.roleOutcome;
|
|
14155
|
-
const officerPayloads = officer?.submissions !== void 0 && officer.submissions.length > 0 ? officer.submissions : officerOutcome !== void 0 && officerOutcome.kind !== "no_receipt" ? officerOutcome.payloads ?? [] : [];
|
|
14156
14008
|
return {
|
|
14157
14009
|
...parent,
|
|
14158
14010
|
roleOutcome: {
|
|
@@ -14160,10 +14012,7 @@ function withUnsettledDirection(parent, officer) {
|
|
|
14160
14012
|
decisiveFacts: {
|
|
14161
14013
|
...outcome.decisiveFacts ?? {},
|
|
14162
14014
|
directionUnsettled: true,
|
|
14163
|
-
subsequentAudit: "incomplete"
|
|
14164
|
-
...officerOutcome === void 0 ? {} : { officerRole: officerOutcome.role },
|
|
14165
|
-
...officer?.runId === void 0 ? {} : { officerRunId: officer.runId },
|
|
14166
|
-
...officerPayloads.length === 0 ? {} : { officerPayloads }
|
|
14015
|
+
subsequentAudit: "incomplete"
|
|
14167
14016
|
}
|
|
14168
14017
|
}
|
|
14169
14018
|
};
|
|
@@ -14174,10 +14023,9 @@ function heldUnreadableTerminal(terminal) {
|
|
|
14174
14023
|
const status = latestQueueStatus(terminal);
|
|
14175
14024
|
return typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status);
|
|
14176
14025
|
}
|
|
14177
|
-
async function
|
|
14178
|
-
const terminal = withUnsettledDirection(
|
|
14026
|
+
async function presentUnsettledOfficer(officer, io, runDirectory) {
|
|
14027
|
+
const terminal = withUnsettledDirection(officer);
|
|
14179
14028
|
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
14180
|
-
if (officer !== void 0) await presentTerminal(officer, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
14181
14029
|
return terminal;
|
|
14182
14030
|
}
|
|
14183
14031
|
async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io, message = unreadablePostSubmissionStatus(admitted, terminal)) {
|
|
@@ -14185,7 +14033,11 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
|
|
|
14185
14033
|
const next = withUnreadableReask(env);
|
|
14186
14034
|
if (next === void 0) return UNREADABLE_REASK_EXHAUSTED;
|
|
14187
14035
|
return runPublicInstructionSeatResume(
|
|
14188
|
-
{
|
|
14036
|
+
{
|
|
14037
|
+
runId: admitted.runId,
|
|
14038
|
+
runDirectory: admitted.runDirectory,
|
|
14039
|
+
summons: { instruction: message }
|
|
14040
|
+
},
|
|
14189
14041
|
next,
|
|
14190
14042
|
io
|
|
14191
14043
|
);
|
|
@@ -14208,7 +14060,11 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
|
|
|
14208
14060
|
softTicketReaskOwnership
|
|
14209
14061
|
};
|
|
14210
14062
|
const result = await runPublicInstructionSeatResume(
|
|
14211
|
-
{
|
|
14063
|
+
{
|
|
14064
|
+
runId: admitted.runId,
|
|
14065
|
+
runDirectory: admitted.runDirectory,
|
|
14066
|
+
summons: { instruction }
|
|
14067
|
+
},
|
|
14212
14068
|
softReaskEnv,
|
|
14213
14069
|
io
|
|
14214
14070
|
);
|
|
@@ -14324,22 +14180,24 @@ async function resolveReviewSeatDialogueBody(input) {
|
|
|
14324
14180
|
if (reask !== void 0 && reask.length > 0) return reask;
|
|
14325
14181
|
const caller = input.callerInstruction ?? "";
|
|
14326
14182
|
if (caller.length > 0) return caller;
|
|
14327
|
-
const sourceRunPath = input
|
|
14328
|
-
if (sourceRunPath ===
|
|
14183
|
+
const sourceRunPath = admittedSourceRunPath(input)?.trim();
|
|
14184
|
+
if (sourceRunPath === void 0) return void 0;
|
|
14185
|
+
if (input.role === "notary") {
|
|
14186
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
14187
|
+
if (isTicketCourtCountersignSource2(sourceRunPath)) return void 0;
|
|
14188
|
+
}
|
|
14329
14189
|
return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
|
|
14330
14190
|
}
|
|
14331
|
-
function admittedSourceRunPath(admitted) {
|
|
14332
|
-
return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
|
|
14333
|
-
}
|
|
14334
14191
|
async function resolveInitialPrompt(admitted, env) {
|
|
14335
14192
|
const record = roleRecord(admitted.role);
|
|
14336
14193
|
if ("reaskPrompt" in record && record.reaskPrompt === true) {
|
|
14337
14194
|
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
14338
14195
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14339
14196
|
const body = await resolveReviewSeatDialogueBody({
|
|
14197
|
+
role: admitted.role,
|
|
14340
14198
|
...reask === void 0 ? {} : { reask },
|
|
14341
14199
|
callerInstruction: admitted.instruction,
|
|
14342
|
-
...sourceRunPath ===
|
|
14200
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
14343
14201
|
projectRoot: admitted.projectRoot,
|
|
14344
14202
|
home: env.home
|
|
14345
14203
|
});
|
|
@@ -14545,16 +14403,21 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
14545
14403
|
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
14546
14404
|
freshSummons: input.env.freshSummons,
|
|
14547
14405
|
summons: input.summons,
|
|
14548
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14549
|
-
{
|
|
14406
|
+
resume: (runId, materials, runDirectory) => runPublicInstructionSeatResume(
|
|
14407
|
+
{
|
|
14408
|
+
runId,
|
|
14409
|
+
runDirectory,
|
|
14410
|
+
...materials === void 0 ? {} : { summons: materials }
|
|
14411
|
+
},
|
|
14550
14412
|
input.env,
|
|
14551
14413
|
input.io
|
|
14552
14414
|
)
|
|
14553
14415
|
});
|
|
14554
14416
|
}
|
|
14555
|
-
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
|
|
14417
|
+
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
|
|
14556
14418
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14557
14419
|
const body = await resolveReviewSeatDialogueBody({
|
|
14420
|
+
role,
|
|
14558
14421
|
...reask === void 0 ? {} : { reask },
|
|
14559
14422
|
callerInstruction: fallback.instruction,
|
|
14560
14423
|
sourceRunPath,
|
|
@@ -14677,6 +14540,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14677
14540
|
let auditorSource;
|
|
14678
14541
|
let auditorTicket;
|
|
14679
14542
|
let resolvedNotarySource;
|
|
14543
|
+
let instructionSourceRunPath;
|
|
14680
14544
|
if (record.sameParent === "subject-source") {
|
|
14681
14545
|
if (parsed.subject === void 0) {
|
|
14682
14546
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
@@ -14706,7 +14570,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14706
14570
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14707
14571
|
},
|
|
14708
14572
|
sourceDirectory,
|
|
14709
|
-
projectRoot
|
|
14573
|
+
projectRoot,
|
|
14574
|
+
role
|
|
14710
14575
|
),
|
|
14711
14576
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14712
14577
|
};
|
|
@@ -14726,9 +14591,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14726
14591
|
}
|
|
14727
14592
|
if (record.sameParent === "source-run") {
|
|
14728
14593
|
if (parsed.sourceRun !== void 0) {
|
|
14729
|
-
let parentRunPath;
|
|
14730
14594
|
try {
|
|
14731
|
-
|
|
14595
|
+
instructionSourceRunPath = (await resolveNotarySourceRunLocator({
|
|
14732
14596
|
projectRoot,
|
|
14733
14597
|
sourceRun: parsed.sourceRun,
|
|
14734
14598
|
home: env.home
|
|
@@ -14740,6 +14604,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14740
14604
|
}
|
|
14741
14605
|
throw error;
|
|
14742
14606
|
}
|
|
14607
|
+
const parentRunPath = instructionSourceRunPath;
|
|
14743
14608
|
const summons = {
|
|
14744
14609
|
sourceRunPath: parentRunPath,
|
|
14745
14610
|
...await sameParentDialogue(
|
|
@@ -14749,7 +14614,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14749
14614
|
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14750
14615
|
},
|
|
14751
14616
|
parentRunPath,
|
|
14752
|
-
projectRoot
|
|
14617
|
+
projectRoot,
|
|
14618
|
+
role
|
|
14753
14619
|
),
|
|
14754
14620
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14755
14621
|
};
|
|
@@ -14786,7 +14652,8 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14786
14652
|
env,
|
|
14787
14653
|
{ instruction: "", instructionEmpty: true },
|
|
14788
14654
|
source.runDirectory,
|
|
14789
|
-
projectRoot
|
|
14655
|
+
projectRoot,
|
|
14656
|
+
role
|
|
14790
14657
|
)
|
|
14791
14658
|
};
|
|
14792
14659
|
resolvedNotarySource = source;
|
|
@@ -14817,14 +14684,9 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14817
14684
|
if (rejected !== void 0) return rejected;
|
|
14818
14685
|
throw error;
|
|
14819
14686
|
}
|
|
14820
|
-
if (
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
sourceRun: parsed.sourceRun,
|
|
14824
|
-
home: env.home
|
|
14825
|
-
})).runDirectory;
|
|
14826
|
-
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
14827
|
-
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
14687
|
+
if (instructionSourceRunPath !== void 0) {
|
|
14688
|
+
await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
|
|
14689
|
+
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
14828
14690
|
}
|
|
14829
14691
|
if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
14830
14692
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
@@ -14893,6 +14755,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14893
14755
|
return runAdmitted();
|
|
14894
14756
|
}
|
|
14895
14757
|
async function runPublicInstructionSeatResume(request, env, io) {
|
|
14758
|
+
let selectedRequest = request;
|
|
14896
14759
|
const resume = async () => {
|
|
14897
14760
|
const held = [];
|
|
14898
14761
|
const turnIo = {
|
|
@@ -14900,11 +14763,16 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
14900
14763
|
stderr: io.stderr
|
|
14901
14764
|
};
|
|
14902
14765
|
const result = await runPostAdmissionSeatResume({
|
|
14903
|
-
request,
|
|
14766
|
+
request: selectedRequest,
|
|
14904
14767
|
env,
|
|
14905
14768
|
io: turnIo,
|
|
14906
14769
|
load: async (effective) => {
|
|
14907
|
-
const loaded = await loadResumablePublicRole(
|
|
14770
|
+
const loaded = await loadResumablePublicRole(
|
|
14771
|
+
env.home,
|
|
14772
|
+
effective.runId,
|
|
14773
|
+
env.principalAuthority,
|
|
14774
|
+
effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
|
|
14775
|
+
);
|
|
14908
14776
|
if (packagedRebindSourceOnResume(loaded.admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
|
|
14909
14777
|
return {
|
|
14910
14778
|
...loaded,
|
|
@@ -14949,8 +14817,14 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
14949
14817
|
};
|
|
14950
14818
|
let binding;
|
|
14951
14819
|
try {
|
|
14952
|
-
const loaded = await loadResumablePublicRole(
|
|
14953
|
-
|
|
14820
|
+
const loaded = await loadResumablePublicRole(
|
|
14821
|
+
env.home,
|
|
14822
|
+
request.runId,
|
|
14823
|
+
env.principalAuthority,
|
|
14824
|
+
request.runDirectory === void 0 ? void 0 : { runDirectory: request.runDirectory }
|
|
14825
|
+
);
|
|
14826
|
+
selectedRequest = { ...request, runDirectory: loaded.admitted.runDirectory };
|
|
14827
|
+
binding = loaded.admitted.role === "auditor" ? await readAuditorResumeBinding(loaded.admitted) : void 0;
|
|
14954
14828
|
} catch (error) {
|
|
14955
14829
|
if (!(error instanceof CliUsageError)) throw error;
|
|
14956
14830
|
}
|
|
@@ -15012,24 +14886,34 @@ async function queueConclusionFromChild(child, env, io) {
|
|
|
15012
14886
|
}
|
|
15013
14887
|
}
|
|
15014
14888
|
async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
15015
|
-
const
|
|
14889
|
+
const knownParentDirectory = admittedSourceRunPath(child);
|
|
14890
|
+
const loaded = await loadResumablePublicRole(
|
|
14891
|
+
env.home,
|
|
14892
|
+
parentRunId,
|
|
14893
|
+
env.principalAuthority,
|
|
14894
|
+
knownParentDirectory === void 0 ? void 0 : { runDirectory: knownParentDirectory }
|
|
14895
|
+
);
|
|
15016
14896
|
if (loaded.run.state !== "admitted" && !AUDITED_ROLES.has(loaded.admitted.role)) {
|
|
15017
|
-
return runPublicInstructionSeatResume(
|
|
14897
|
+
return runPublicInstructionSeatResume(
|
|
14898
|
+
{
|
|
14899
|
+
runId: parentRunId,
|
|
14900
|
+
runDirectory: loaded.admitted.runDirectory
|
|
14901
|
+
},
|
|
14902
|
+
env,
|
|
14903
|
+
io
|
|
14904
|
+
);
|
|
15018
14905
|
}
|
|
15019
14906
|
const admitted = loaded.admitted;
|
|
15020
14907
|
const resolved = await queueConclusionFromChild(child, env, io);
|
|
15021
14908
|
if (resolved !== void 0 && "stop" in resolved) {
|
|
15022
14909
|
const stopped = resolved.stop;
|
|
15023
|
-
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0) {
|
|
15024
|
-
const
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
14910
|
+
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0 && stopped.admitted !== void 0) {
|
|
14911
|
+
const terminal = await presentUnsettledOfficer(
|
|
14912
|
+
stopped.terminal,
|
|
14913
|
+
io,
|
|
14914
|
+
stopped.admitted.runDirectory
|
|
15028
14915
|
);
|
|
15029
|
-
|
|
15030
|
-
const terminal = await presentUnsettledAudit(parentTerminal, stopped.terminal, io, admitted.runDirectory);
|
|
15031
|
-
return { exitCode: 0, admitted, terminal };
|
|
15032
|
-
}
|
|
14916
|
+
return { exitCode: 0, admitted: stopped.admitted, terminal };
|
|
15033
14917
|
}
|
|
15034
14918
|
return stopped;
|
|
15035
14919
|
}
|
|
@@ -15044,10 +14928,22 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
15044
14928
|
{ ...await readCurrentCourt(admitted.runDirectory), ...packageFaultScope(admitted, env, io) }
|
|
15045
14929
|
);
|
|
15046
14930
|
if (terminal?.roleOutcome.kind !== "accepted") throw new Error("pending submission is not recorded");
|
|
15047
|
-
|
|
14931
|
+
const live = liveChildForCurrentParentSeal(
|
|
14932
|
+
terminal,
|
|
14933
|
+
resolved.admitted,
|
|
14934
|
+
latestQueuePayload(resolved.terminal)
|
|
14935
|
+
);
|
|
14936
|
+
return auditSubmittedRole(
|
|
14937
|
+
{ exitCode: 0, admitted, terminal },
|
|
14938
|
+
env,
|
|
14939
|
+
io,
|
|
14940
|
+
live?.officer,
|
|
14941
|
+
live?.receipt
|
|
14942
|
+
);
|
|
15048
14943
|
}
|
|
15049
14944
|
return runPublicInstructionSeatResume({
|
|
15050
14945
|
runId: parentRunId,
|
|
14946
|
+
runDirectory: admitted.runDirectory,
|
|
15051
14947
|
summons: { instruction: readableGateItem(latestQueuePayload(resolved.terminal)) }
|
|
15052
14948
|
}, envForCourtContinue(env), io);
|
|
15053
14949
|
}
|
|
@@ -15055,28 +14951,21 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
15055
14951
|
showResumeErrorPointer(io, result.exitCode, result.terminal);
|
|
15056
14952
|
return result;
|
|
15057
14953
|
}
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
const
|
|
15061
|
-
if (
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
} catch {
|
|
15074
|
-
return false;
|
|
15075
|
-
}
|
|
15076
|
-
if (admitted.role !== officer) return false;
|
|
15077
|
-
const court = await readCurrentCourt(admitted.runDirectory);
|
|
15078
|
-
const terminal = await trySettlePublicSeat(admitted, env.principalAuthority, court);
|
|
15079
|
-
return latestQueueStatus(terminal) === "converged";
|
|
14954
|
+
function liveChildForCurrentParentSeal(parentTerminal, child, receipt) {
|
|
14955
|
+
if (receipt === void 0) return void 0;
|
|
14956
|
+
const parentSealId = parentTerminal.submissionToolCallId?.trim() ?? "";
|
|
14957
|
+
if (parentSealId === "") return void 0;
|
|
14958
|
+
const childSealId = readAdmittedAuditedSubmissionToolCallId(child.runDirectory);
|
|
14959
|
+
if (childSealId !== parentSealId) return void 0;
|
|
14960
|
+
return { officer: child, receipt };
|
|
14961
|
+
}
|
|
14962
|
+
function officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder) {
|
|
14963
|
+
if (resumedOfficer === void 0 || passedReceipt === void 0) return false;
|
|
14964
|
+
if (resumedOfficer.role === officer) return true;
|
|
14965
|
+
if (chainOrder === void 0) return false;
|
|
14966
|
+
const childIndex = chainOrder.indexOf(resumedOfficer.role);
|
|
14967
|
+
const officerIndex = chainOrder.indexOf(officer);
|
|
14968
|
+
return childIndex >= 0 && officerIndex >= 0 && officerIndex < childIndex;
|
|
15080
14969
|
}
|
|
15081
14970
|
async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt) {
|
|
15082
14971
|
env = withoutSoftTicketReaskTurn(env);
|
|
@@ -15091,21 +14980,29 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15091
14980
|
if (gateOwnsStatusReask) return turn;
|
|
15092
14981
|
const next = withUnreadableReask(env);
|
|
15093
14982
|
if (next === void 0) {
|
|
15094
|
-
const
|
|
15095
|
-
await presentTerminal(
|
|
15096
|
-
return { ...turn, terminal
|
|
14983
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
14984
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
14985
|
+
return { ...turn, terminal };
|
|
15097
14986
|
}
|
|
15098
|
-
return runPublicInstructionSeatResume({
|
|
14987
|
+
return runPublicInstructionSeatResume({
|
|
14988
|
+
runId: admitted.runId,
|
|
14989
|
+
runDirectory: admitted.runDirectory,
|
|
14990
|
+
summons: { instruction: SECRETARIAT_STATUS_REASK }
|
|
14991
|
+
}, next, io);
|
|
15099
14992
|
}
|
|
15100
14993
|
if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
|
|
15101
14994
|
if (gateOwnsStatusReask) return turn;
|
|
15102
14995
|
const next = withUnreadableReask(env);
|
|
15103
14996
|
if (next === void 0) {
|
|
15104
|
-
const
|
|
15105
|
-
await presentTerminal(
|
|
15106
|
-
return { ...turn, terminal
|
|
14997
|
+
const terminal = withUnsettledDirection(turn.terminal);
|
|
14998
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
14999
|
+
return { ...turn, terminal };
|
|
15107
15000
|
}
|
|
15108
|
-
return runPublicInstructionSeatResume({
|
|
15001
|
+
return runPublicInstructionSeatResume({
|
|
15002
|
+
runId: admitted.runId,
|
|
15003
|
+
runDirectory: admitted.runDirectory,
|
|
15004
|
+
summons: { instruction: officerConclusionReask(status) }
|
|
15005
|
+
}, next, io);
|
|
15109
15006
|
}
|
|
15110
15007
|
const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
|
|
15111
15008
|
const skipAudit = selfEscalationSkipsAudit || (admitted.role === "fixer" || admitted.role === "coder") && (typeof status !== "string" || !WORKER_DONE_STATUSES.has(status));
|
|
@@ -15135,14 +15032,9 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15135
15032
|
abort() {
|
|
15136
15033
|
}
|
|
15137
15034
|
};
|
|
15138
|
-
const
|
|
15139
|
-
env,
|
|
15140
|
-
parentSessionFile: sessionFile,
|
|
15141
|
-
officer,
|
|
15142
|
-
toolCallId
|
|
15143
|
-
});
|
|
15035
|
+
const gateSatisfied = (officer, chainOrder) => officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, chainOrder);
|
|
15144
15036
|
if (admitted.role === "doctor") {
|
|
15145
|
-
if (!
|
|
15037
|
+
if (!gateSatisfied("auditor")) {
|
|
15146
15038
|
let lastSummon;
|
|
15147
15039
|
const decision = await createPiDoctorAuditor()({
|
|
15148
15040
|
context,
|
|
@@ -15164,23 +15056,18 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15164
15056
|
...reask === void 0 ? {} : { reviewReask: reask },
|
|
15165
15057
|
...submission === void 0 ? {} : { gateReviewInstruction: submission }
|
|
15166
15058
|
});
|
|
15167
|
-
const officerSession = sessionFileFromPublicSummon(summoned);
|
|
15168
|
-
if (officerSession !== void 0) {
|
|
15169
|
-
bookDirectOfficerRunPointer({
|
|
15170
|
-
parentSessionFile: sessionFile,
|
|
15171
|
-
officer: "auditor",
|
|
15172
|
-
sessionFile: officerSession,
|
|
15173
|
-
submissionToolCallId: toolCallId,
|
|
15174
|
-
...summoned.runDirectory === void 0 ? {} : { runDirectory: summoned.runDirectory }
|
|
15175
|
-
});
|
|
15176
|
-
}
|
|
15177
15059
|
lastSummon = summoned;
|
|
15060
|
+
const officerDir = summoned.runDirectory ?? summoned.admitted?.runDirectory;
|
|
15061
|
+
if (officerDir !== void 0 && toolCallId.length > 0) {
|
|
15062
|
+
persistAdmittedAuditedSubmissionToolCallId(officerDir, toolCallId);
|
|
15063
|
+
}
|
|
15178
15064
|
return summoned;
|
|
15179
15065
|
}
|
|
15180
15066
|
});
|
|
15181
15067
|
if (decision.status === "continue") {
|
|
15182
15068
|
return runPublicInstructionSeatResume({
|
|
15183
15069
|
runId: admitted.runId,
|
|
15070
|
+
runDirectory: admitted.runDirectory,
|
|
15184
15071
|
summons: { instruction: readableGateItem(decision.receipt ?? decision.violations) }
|
|
15185
15072
|
}, envForCourtContinue(env), io);
|
|
15186
15073
|
}
|
|
@@ -15188,9 +15075,14 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15188
15075
|
if (lastSummon?.terminal === void 0) {
|
|
15189
15076
|
throw new Error("doctor audit kept an unreadable reply with no terminal");
|
|
15190
15077
|
}
|
|
15191
|
-
|
|
15192
|
-
const
|
|
15193
|
-
|
|
15078
|
+
const officerAdmitted = lastSummon.admitted;
|
|
15079
|
+
const officerDir = officerAdmitted?.runDirectory ?? lastSummon.runDirectory ?? admitted.runDirectory;
|
|
15080
|
+
const terminal = await presentUnsettledOfficer(lastSummon.terminal, io, officerDir);
|
|
15081
|
+
return {
|
|
15082
|
+
exitCode: 0,
|
|
15083
|
+
...officerAdmitted === void 0 ? { admitted } : { admitted: officerAdmitted },
|
|
15084
|
+
terminal
|
|
15085
|
+
};
|
|
15194
15086
|
}
|
|
15195
15087
|
if (decision.status !== "converged") {
|
|
15196
15088
|
if (lastSummon?.terminal !== void 0) {
|
|
@@ -15213,7 +15105,6 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15213
15105
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
15214
15106
|
});
|
|
15215
15107
|
let chain;
|
|
15216
|
-
let officerRunId = resumedOfficer?.runId;
|
|
15217
15108
|
const runGate = (subject) => requireSubmissionGate({
|
|
15218
15109
|
context,
|
|
15219
15110
|
subject,
|
|
@@ -15231,19 +15122,19 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15231
15122
|
}
|
|
15232
15123
|
});
|
|
15233
15124
|
if (admitted.role === "judge") {
|
|
15125
|
+
const judgeGateOrder = JUDGE_GATES.map(gateOfficerForSubject);
|
|
15234
15126
|
chain = await runJudgeGates({
|
|
15235
|
-
gateAlreadyConverged: async (subject) =>
|
|
15127
|
+
gateAlreadyConverged: async (subject) => gateSatisfied(gateOfficerForSubject(subject), judgeGateOrder),
|
|
15236
15128
|
runGate
|
|
15237
15129
|
});
|
|
15238
15130
|
} else {
|
|
15239
15131
|
const subject = admitted.role === "fixer" || admitted.role === "coder" ? { kind: "worker_completion" } : admitted.role === "secretariat" ? { kind: "secretariat_verdict" } : { kind: "countersign_verdict" };
|
|
15240
15132
|
const officer = gateOfficerForSubject(subject);
|
|
15241
|
-
if (
|
|
15133
|
+
if (gateSatisfied(officer)) {
|
|
15242
15134
|
chain = { status: "converged", passes: [] };
|
|
15243
15135
|
} else {
|
|
15244
15136
|
const pass = await runGate(subject);
|
|
15245
15137
|
if (pass === void 0) throw new Error("audit gate returned no conclusion");
|
|
15246
|
-
officerRunId = pass.runId;
|
|
15247
15138
|
chain = {
|
|
15248
15139
|
status: pass.status,
|
|
15249
15140
|
passes: [{
|
|
@@ -15258,53 +15149,58 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15258
15149
|
}
|
|
15259
15150
|
}
|
|
15260
15151
|
if (chain.status === "needs_reask") {
|
|
15261
|
-
const
|
|
15152
|
+
const pass = chain.passes.at(-1);
|
|
15153
|
+
const officerTerminal = pass?.terminal;
|
|
15262
15154
|
if (officerTerminal === void 0) throw new Error("unreadable audit has no terminal result");
|
|
15263
|
-
|
|
15264
|
-
const
|
|
15265
|
-
|
|
15155
|
+
const officerRunDirectory = pass?.runDirectory;
|
|
15156
|
+
const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
|
|
15157
|
+
if (officerRunId === void 0) throw new Error("unreadable audit has no resumable run identity");
|
|
15158
|
+
const officer = await loadResumablePublicRole(
|
|
15159
|
+
env.home,
|
|
15160
|
+
officerRunId,
|
|
15161
|
+
env.principalAuthority,
|
|
15162
|
+
officerRunDirectory === void 0 ? void 0 : { runDirectory: officerRunDirectory }
|
|
15163
|
+
);
|
|
15164
|
+
const terminal = await presentUnsettledOfficer(
|
|
15165
|
+
officerTerminal,
|
|
15166
|
+
io,
|
|
15167
|
+
officer.admitted.runDirectory
|
|
15168
|
+
);
|
|
15169
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15266
15170
|
}
|
|
15267
15171
|
if (chain.status === "escalate") {
|
|
15268
15172
|
const escalation = chain.passes.at(-1);
|
|
15269
|
-
const
|
|
15173
|
+
const escalatedRunDirectory = escalation?.runDirectory;
|
|
15174
|
+
const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
|
|
15270
15175
|
if (escalatedRunId === void 0) throw new Error("escalated audit has no resumable run identity");
|
|
15271
|
-
const officer = await loadResumablePublicRole(
|
|
15272
|
-
|
|
15273
|
-
|
|
15176
|
+
const officer = await loadResumablePublicRole(
|
|
15177
|
+
env.home,
|
|
15178
|
+
escalatedRunId,
|
|
15274
15179
|
env.principalAuthority,
|
|
15275
|
-
|
|
15180
|
+
escalatedRunDirectory === void 0 ? void 0 : { runDirectory: escalatedRunDirectory }
|
|
15276
15181
|
);
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15182
|
+
let terminal = escalation?.terminal;
|
|
15183
|
+
if (terminal === void 0) {
|
|
15184
|
+
terminal = await trySettlePublicSeat(
|
|
15185
|
+
officer.admitted,
|
|
15186
|
+
env.principalAuthority,
|
|
15187
|
+
{ ...await readCurrentCourt(officer.admitted.runDirectory), ...packageFaultScope(officer.admitted, env, io) }
|
|
15188
|
+
);
|
|
15189
|
+
}
|
|
15190
|
+
if (terminal === void 0) throw new Error("escalated audit has no terminal result");
|
|
15191
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, officer.admitted.runDirectory);
|
|
15192
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15280
15193
|
}
|
|
15281
15194
|
if (chain.status === "continue") {
|
|
15282
15195
|
return runPublicInstructionSeatResume({
|
|
15283
15196
|
runId: admitted.runId,
|
|
15197
|
+
runDirectory: admitted.runDirectory,
|
|
15284
15198
|
summons: { instruction: readableGateItem(chain.passes.at(-1)?.receipt) }
|
|
15285
15199
|
}, envForCourtContinue(env), io);
|
|
15286
15200
|
}
|
|
15287
|
-
if (admitted.role === "secretariat") {
|
|
15288
|
-
const pass = chain.passes.at(-1);
|
|
15289
|
-
const receipt = pass?.receipt ?? passedReceipt;
|
|
15290
|
-
if (receipt !== void 0) {
|
|
15291
|
-
await env.sessionAppender(env.principalAuthority, admitted.principal, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, {
|
|
15292
|
-
officer: "countersign",
|
|
15293
|
-
receipt,
|
|
15294
|
-
...officerRunId === void 0 ? {} : { runId: officerRunId }
|
|
15295
|
-
});
|
|
15296
|
-
}
|
|
15297
|
-
}
|
|
15298
15201
|
}
|
|
15299
15202
|
if (turn.terminal === void 0) throw new Error(`audited ${admitted.role} submission did not settle`);
|
|
15300
|
-
|
|
15301
|
-
admitted,
|
|
15302
|
-
env.principalAuthority,
|
|
15303
|
-
turn.terminal,
|
|
15304
|
-
packageFaultScope(admitted, env, io)
|
|
15305
|
-
);
|
|
15306
|
-
turn = { ...turn, terminal };
|
|
15307
|
-
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15203
|
+
await presentTerminal(turn.terminal, { ...io, omitFailureStderrDiagnostic: true }, admitted.runDirectory);
|
|
15308
15204
|
return turn;
|
|
15309
15205
|
}
|
|
15310
15206
|
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;
|
|
@@ -15315,21 +15211,18 @@ var init_instruction_seat_run = __esm({
|
|
|
15315
15211
|
init_role_run_placement();
|
|
15316
15212
|
init_role_run_relocation();
|
|
15317
15213
|
init_session_opening_materials();
|
|
15318
|
-
init_archivist_record_pointer();
|
|
15319
15214
|
init_doctor_auditor();
|
|
15320
15215
|
init_gatekeeper_role();
|
|
15321
15216
|
init_submission_errors();
|
|
15322
15217
|
init_review_submission();
|
|
15323
15218
|
init_judge_role();
|
|
15324
15219
|
init_worker_submission_contracts();
|
|
15325
|
-
init_secretariat_contracts();
|
|
15326
15220
|
init_readable_gate_item();
|
|
15327
15221
|
init_receipt_delivery_policy();
|
|
15328
15222
|
init_run_terminal_artifacts();
|
|
15329
15223
|
init_submission_gate();
|
|
15330
15224
|
init_submission_ledger();
|
|
15331
15225
|
init_public_role_summons();
|
|
15332
|
-
init_session_assistant_usage();
|
|
15333
15226
|
init_submission_gate();
|
|
15334
15227
|
init_run_ticket_number();
|
|
15335
15228
|
init_notary_source_run();
|
|
@@ -15424,10 +15317,10 @@ var init_analyst_book_key = __esm({
|
|
|
15424
15317
|
// src/atomic-write.ts
|
|
15425
15318
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
15426
15319
|
import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
|
|
15427
|
-
import { dirname as dirname14, join as
|
|
15320
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
15428
15321
|
async function writeFileAtomically(destination, contents, options) {
|
|
15429
15322
|
const parent = dirname14(destination);
|
|
15430
|
-
const temporary =
|
|
15323
|
+
const temporary = join21(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
15431
15324
|
try {
|
|
15432
15325
|
await writeFile3(temporary, contents, options);
|
|
15433
15326
|
await rename2(temporary, destination);
|
|
@@ -15444,12 +15337,12 @@ var init_atomic_write = __esm({
|
|
|
15444
15337
|
|
|
15445
15338
|
// src/analyst-index.ts
|
|
15446
15339
|
import { open, readFile as readFile10, unlink } from "node:fs/promises";
|
|
15447
|
-
import { dirname as dirname15, join as
|
|
15340
|
+
import { dirname as dirname15, join as join22 } from "node:path";
|
|
15448
15341
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15449
15342
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15450
15343
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15451
15344
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
15452
|
-
const lockPath =
|
|
15345
|
+
const lockPath = join22(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15453
15346
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15454
15347
|
const startedAt = Date.now();
|
|
15455
15348
|
while (true) {
|
|
@@ -15476,7 +15369,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15476
15369
|
}
|
|
15477
15370
|
}
|
|
15478
15371
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15479
|
-
return
|
|
15372
|
+
return join22(ledgerHome, "analyst", "library-index.json");
|
|
15480
15373
|
}
|
|
15481
15374
|
function rowFromIssueMetricsPage(page) {
|
|
15482
15375
|
return {
|
|
@@ -15769,6 +15662,70 @@ var init_analyst_cohort = __esm({
|
|
|
15769
15662
|
}
|
|
15770
15663
|
});
|
|
15771
15664
|
|
|
15665
|
+
// src/archivist-record-pointer.ts
|
|
15666
|
+
import { basename as basename10, join as join23 } from "node:path";
|
|
15667
|
+
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
15668
|
+
const where = `${parentRunDirectory} officers`;
|
|
15669
|
+
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
15670
|
+
throw new Error(`direct officer run pointer has unknown shape in ${where}`);
|
|
15671
|
+
}
|
|
15672
|
+
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "") {
|
|
15673
|
+
throw new Error(`direct officer run pointer missing sessionFile in ${where}`);
|
|
15674
|
+
}
|
|
15675
|
+
const officer = raw.officer === "inspector" || raw.officer === "notary" || raw.officer === "auditor" || raw.officer === "countersign" ? raw.officer : void 0;
|
|
15676
|
+
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
15677
|
+
let sessionFile = raw.sessionFile;
|
|
15678
|
+
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
15679
|
+
const leaf = parseRunLeaf(basename10(recordedRunDirectory));
|
|
15680
|
+
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
15681
|
+
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
15682
|
+
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
15683
|
+
recordedRunDirectory,
|
|
15684
|
+
homeFromRunDirectory(parentRunDirectory),
|
|
15685
|
+
parentIdentity.bookKey
|
|
15686
|
+
);
|
|
15687
|
+
if (currentRunDirectory !== void 0) {
|
|
15688
|
+
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
15689
|
+
if (runDirectory !== void 0) runDirectory = currentRunDirectory;
|
|
15690
|
+
}
|
|
15691
|
+
}
|
|
15692
|
+
return {
|
|
15693
|
+
sessionFile,
|
|
15694
|
+
...officer === void 0 ? {} : { officer },
|
|
15695
|
+
...runDirectory === void 0 ? {} : { runDirectory }
|
|
15696
|
+
};
|
|
15697
|
+
}
|
|
15698
|
+
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
15699
|
+
const { records, diagnostics } = await readSitianRecords(join23(parentRunDirectory, RUN_HISTORY_FILE));
|
|
15700
|
+
if (diagnostics.length > 0) {
|
|
15701
|
+
throw new Error(
|
|
15702
|
+
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
15703
|
+
);
|
|
15704
|
+
}
|
|
15705
|
+
return latestOfficerPointersFromRecords(records);
|
|
15706
|
+
}
|
|
15707
|
+
async function readOfficerPointers(parentRunDirectory) {
|
|
15708
|
+
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
15709
|
+
return Promise.all(
|
|
15710
|
+
Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory))
|
|
15711
|
+
);
|
|
15712
|
+
}
|
|
15713
|
+
var DIRECT_OFFICER_RUN_POINTER_KIND;
|
|
15714
|
+
var init_archivist_record_pointer = __esm({
|
|
15715
|
+
"src/archivist-record-pointer.ts"() {
|
|
15716
|
+
"use strict";
|
|
15717
|
+
init_unknown_value();
|
|
15718
|
+
init_run_dossier();
|
|
15719
|
+
init_run_dossier_files();
|
|
15720
|
+
init_sitian_facade();
|
|
15721
|
+
init_activation_ledger_topology();
|
|
15722
|
+
init_run_lifecycle();
|
|
15723
|
+
init_role_run_relocation();
|
|
15724
|
+
init_role_run_placement();
|
|
15725
|
+
DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
15726
|
+
}
|
|
15727
|
+
});
|
|
15728
|
+
|
|
15772
15729
|
// src/analyst-gate-cycles-read.ts
|
|
15773
15730
|
function isParentAttemptBindingRow(row) {
|
|
15774
15731
|
return row.type === "custom" && row.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
|
|
@@ -18497,14 +18454,19 @@ async function runAkRole(argv, env) {
|
|
|
18497
18454
|
env = { ...env, freshSummons: true };
|
|
18498
18455
|
}
|
|
18499
18456
|
if (parsed.command === "resume") {
|
|
18500
|
-
|
|
18457
|
+
let resumeRequest = parseResumeRequest(parsed.args);
|
|
18501
18458
|
resumeFailureContext = {
|
|
18502
18459
|
home,
|
|
18503
18460
|
runId: resumeRequest.runId,
|
|
18504
18461
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
18505
18462
|
};
|
|
18463
|
+
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
18464
|
+
if (runDirectory !== void 0) {
|
|
18465
|
+
resumeRequest = { ...resumeRequest, runDirectory };
|
|
18466
|
+
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
18467
|
+
}
|
|
18506
18468
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
18507
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
18469
|
+
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
18508
18470
|
const seatRole = resumeRole ?? "judge";
|
|
18509
18471
|
const seat = resolveEffectiveSeat(
|
|
18510
18472
|
parts.config,
|
|
@@ -18528,12 +18490,18 @@ async function runAkRole(argv, env) {
|
|
|
18528
18490
|
let current = result;
|
|
18529
18491
|
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true && !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
18530
18492
|
const parentRunId = current.admitted.correlationId;
|
|
18493
|
+
const parentSource = admittedSourceRunPath(current.admitted);
|
|
18531
18494
|
resumeFailureContext = {
|
|
18532
18495
|
home,
|
|
18533
18496
|
runId: parentRunId,
|
|
18497
|
+
...parentSource === void 0 ? {} : { runDirectory: parentSource },
|
|
18534
18498
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
18535
18499
|
};
|
|
18536
|
-
const parentRole = await peekRoleRunRole(
|
|
18500
|
+
const parentRole = await peekRoleRunRole(
|
|
18501
|
+
home,
|
|
18502
|
+
parentRunId,
|
|
18503
|
+
parentSource === void 0 ? void 0 : { runDirectory: parentSource }
|
|
18504
|
+
);
|
|
18537
18505
|
if (parentRole === void 0) break;
|
|
18538
18506
|
const parentSeat = resolveEffectiveSeat(
|
|
18539
18507
|
parts.config,
|
|
@@ -18585,7 +18553,8 @@ async function runAkRole(argv, env) {
|
|
|
18585
18553
|
resumeFailureContext.runId,
|
|
18586
18554
|
resumeFailureContext.authority,
|
|
18587
18555
|
io,
|
|
18588
|
-
error
|
|
18556
|
+
error,
|
|
18557
|
+
resumeFailureContext.runDirectory
|
|
18589
18558
|
)) {
|
|
18590
18559
|
return {
|
|
18591
18560
|
exitCode: error instanceof CliUsageError ? 2 : 1,
|
|
@@ -18666,7 +18635,7 @@ __export(public_role_summons_exports, {
|
|
|
18666
18635
|
summonPublicRole: () => summonPublicRole
|
|
18667
18636
|
});
|
|
18668
18637
|
import { execFile as execFile3 } from "node:child_process";
|
|
18669
|
-
import { existsSync as
|
|
18638
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
18670
18639
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18671
18640
|
import { join as join26 } from "node:path";
|
|
18672
18641
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -18692,7 +18661,7 @@ function parentDir(path) {
|
|
|
18692
18661
|
function walkPackageRoot(start) {
|
|
18693
18662
|
let dir = start;
|
|
18694
18663
|
for (let i = 0; i < 12; i += 1) {
|
|
18695
|
-
if (
|
|
18664
|
+
if (existsSync11(join26(dir, "package.json")) && existsSync11(join26(dir, "souls"))) {
|
|
18696
18665
|
return dir;
|
|
18697
18666
|
}
|
|
18698
18667
|
const parent = parentDir(dir);
|
|
@@ -18911,6 +18880,7 @@ async function summonPublicRole(options) {
|
|
|
18911
18880
|
const stepped = await runPrepared(parse, (env) => runPublicInstructionSeatResume2(
|
|
18912
18881
|
{
|
|
18913
18882
|
runId: resumeRunId,
|
|
18883
|
+
...options.resumeRunDirectory === void 0 ? {} : { runDirectory: options.resumeRunDirectory },
|
|
18914
18884
|
summons: {
|
|
18915
18885
|
instruction,
|
|
18916
18886
|
instructionEmpty: instruction.length === 0
|
|
@@ -18927,10 +18897,13 @@ async function summonPublicRole(options) {
|
|
|
18927
18897
|
result = stepped.ok;
|
|
18928
18898
|
}
|
|
18929
18899
|
const stderr = captured?.stderrText();
|
|
18930
|
-
|
|
18931
|
-
|
|
18932
|
-
|
|
18933
|
-
|
|
18900
|
+
let runDirectory = result.admitted?.runDirectory;
|
|
18901
|
+
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
18902
|
+
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
18903
|
+
home,
|
|
18904
|
+
result.terminal.runId
|
|
18905
|
+
) ?? runDirectory;
|
|
18906
|
+
}
|
|
18934
18907
|
return {
|
|
18935
18908
|
exitCode: result.exitCode,
|
|
18936
18909
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -18961,35 +18934,8 @@ async function summonParallelReviewerLenses(options) {
|
|
|
18961
18934
|
const failure = failedResult(error);
|
|
18962
18935
|
return { completeness: failure, correctness: failure };
|
|
18963
18936
|
};
|
|
18964
|
-
let sourceProjectRoot;
|
|
18965
|
-
let targetCommit;
|
|
18966
|
-
const statusArgs = [
|
|
18967
|
-
"status",
|
|
18968
|
-
"--porcelain=v1",
|
|
18969
|
-
"--untracked-files=all",
|
|
18970
|
-
"--",
|
|
18971
|
-
":/",
|
|
18972
|
-
":(top,exclude).claude/worktrees/**"
|
|
18973
|
-
];
|
|
18974
18937
|
try {
|
|
18975
|
-
sourceProjectRoot = await resolveReviewerGitToplevel(options.projectRoot);
|
|
18976
|
-
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
18977
|
-
cwd: sourceProjectRoot
|
|
18978
|
-
});
|
|
18979
|
-
if (statusStdout !== "") {
|
|
18980
|
-
const diagnostic = [
|
|
18981
|
-
"Reviewer target status gate failed:",
|
|
18982
|
-
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
18983
|
-
statusStdout
|
|
18984
|
-
].join("\n");
|
|
18985
|
-
return dualFailure(new Error(diagnostic));
|
|
18986
|
-
}
|
|
18987
|
-
const { stdout: targetStdout } = await execFileAsync3(
|
|
18988
|
-
"git",
|
|
18989
|
-
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
18990
|
-
{ cwd: sourceProjectRoot }
|
|
18991
|
-
);
|
|
18992
|
-
targetCommit = targetStdout.trim();
|
|
18938
|
+
const sourceProjectRoot = await resolveReviewerGitToplevel(options.projectRoot);
|
|
18993
18939
|
await execFileAsync3(
|
|
18994
18940
|
"git",
|
|
18995
18941
|
["rev-parse", "--verify", `${options.baseRevision}^{commit}`],
|
|
@@ -19025,55 +18971,10 @@ async function summonParallelReviewerLenses(options) {
|
|
|
19025
18971
|
summon("completeness"),
|
|
19026
18972
|
summon("correctness")
|
|
19027
18973
|
]);
|
|
19028
|
-
|
|
18974
|
+
return {
|
|
19029
18975
|
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
19030
18976
|
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
19031
18977
|
};
|
|
19032
|
-
let sealDiagnostic;
|
|
19033
|
-
try {
|
|
19034
|
-
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
19035
|
-
"git",
|
|
19036
|
-
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
19037
|
-
{ cwd: sourceProjectRoot }
|
|
19038
|
-
);
|
|
19039
|
-
const { stdout: sealedStatusStdout } = await execFileAsync3("git", statusArgs, {
|
|
19040
|
-
cwd: sourceProjectRoot
|
|
19041
|
-
});
|
|
19042
|
-
const { stdout: headAfterStdout } = await execFileAsync3(
|
|
19043
|
-
"git",
|
|
19044
|
-
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
19045
|
-
{ cwd: sourceProjectRoot }
|
|
19046
|
-
);
|
|
19047
|
-
const headBefore = headBeforeStdout.trim();
|
|
19048
|
-
const headAfter = headAfterStdout.trim();
|
|
19049
|
-
if (headBefore !== targetCommit || headAfter !== targetCommit || sealedStatusStdout !== "") {
|
|
19050
|
-
sealDiagnostic = [
|
|
19051
|
-
"Reviewer target final seal failed:",
|
|
19052
|
-
`HEAD before status => ${headBefore}`,
|
|
19053
|
-
`HEAD after status => ${headAfter}`,
|
|
19054
|
-
`expected PRE_HEAD ${targetCommit}`,
|
|
19055
|
-
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
19056
|
-
sealedStatusStdout
|
|
19057
|
-
].join("\n");
|
|
19058
|
-
}
|
|
19059
|
-
} catch (error) {
|
|
19060
|
-
sealDiagnostic = `Reviewer target final seal failed:
|
|
19061
|
-
${serializeThrownValue(error)}`;
|
|
19062
|
-
}
|
|
19063
|
-
if (sealDiagnostic !== void 0) {
|
|
19064
|
-
const withSealFailure = (result) => ({
|
|
19065
|
-
...result,
|
|
19066
|
-
exitCode: 1,
|
|
19067
|
-
stderr: [result.stderr, sealDiagnostic].filter(
|
|
19068
|
-
(text) => typeof text === "string" && text !== ""
|
|
19069
|
-
).join("\n")
|
|
19070
|
-
});
|
|
19071
|
-
results = {
|
|
19072
|
-
completeness: withSealFailure(results.completeness),
|
|
19073
|
-
correctness: withSealFailure(results.correctness)
|
|
19074
|
-
};
|
|
19075
|
-
}
|
|
19076
|
-
return results;
|
|
19077
18978
|
}
|
|
19078
18979
|
async function summonGateOfficer(options) {
|
|
19079
18980
|
let home = options.home;
|
|
@@ -19083,8 +18984,12 @@ async function summonGateOfficer(options) {
|
|
|
19083
18984
|
}
|
|
19084
18985
|
let gateReviewInstruction;
|
|
19085
18986
|
if (options.reask === void 0 && options.submission !== void 0) {
|
|
19086
|
-
const {
|
|
19087
|
-
|
|
18987
|
+
const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
18988
|
+
const blindTicketCourt = options.officer === "notary" && isTicketCourtCountersignSource2(options.sourceRunDirectory);
|
|
18989
|
+
if (!blindTicketCourt) {
|
|
18990
|
+
const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
|
|
18991
|
+
gateReviewInstruction = readableGateItem2(options.submission);
|
|
18992
|
+
}
|
|
19088
18993
|
}
|
|
19089
18994
|
const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
19090
18995
|
const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
|
|
@@ -19324,8 +19229,7 @@ async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirect
|
|
|
19324
19229
|
if (rewriteRunDirectoryPathValue(recordedPathIdentity, unbound.runDirectory, runDirectory) !== currentPathIdentity) {
|
|
19325
19230
|
return false;
|
|
19326
19231
|
}
|
|
19327
|
-
|
|
19328
|
-
return placed !== void 0 && physicalPathIdentity(placed) === runDirectory;
|
|
19232
|
+
return true;
|
|
19329
19233
|
}
|
|
19330
19234
|
return false;
|
|
19331
19235
|
}
|
|
@@ -19354,6 +19258,7 @@ __export(run_lifecycle_exports, {
|
|
|
19354
19258
|
buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
|
|
19355
19259
|
clearCurrentCourt: () => clearCurrentCourt,
|
|
19356
19260
|
describeErrorIdentity: () => describeErrorIdentity,
|
|
19261
|
+
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
19357
19262
|
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
19358
19263
|
findRunDirectoryById: () => findRunDirectoryById,
|
|
19359
19264
|
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
@@ -19366,8 +19271,10 @@ __export(run_lifecycle_exports, {
|
|
|
19366
19271
|
readRoleRunState: () => readRoleRunState,
|
|
19367
19272
|
readRunParentPath: () => readRunParentPath,
|
|
19368
19273
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
19274
|
+
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
19369
19275
|
writeRoleRunState: () => writeRoleRunState
|
|
19370
19276
|
});
|
|
19277
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
19371
19278
|
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
|
|
19372
19279
|
import { basename as basename12, join as join28 } from "node:path";
|
|
19373
19280
|
function buildAutoResumeContinuationPrompt() {
|
|
@@ -19383,7 +19290,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
19383
19290
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
19384
19291
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
19385
19292
|
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
19386
|
-
const sourceRunPath =
|
|
19293
|
+
const sourceRunPath = admittedSourceRunPath(record);
|
|
19387
19294
|
let sourceRun;
|
|
19388
19295
|
if (isRecord(record.sourceRun)) {
|
|
19389
19296
|
const sr = record.sourceRun;
|
|
@@ -19762,7 +19669,16 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19762
19669
|
lastReclaimFailure === void 0 ? void 0 : errnoOf(lastReclaimFailure)
|
|
19763
19670
|
);
|
|
19764
19671
|
}
|
|
19765
|
-
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19672
|
+
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
19673
|
+
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
19674
|
+
const parsed = parseRunLeaf(basename12(knownRunDirectory));
|
|
19675
|
+
if (parsed === void 0 || parsed.runId !== runId) {
|
|
19676
|
+
throw new CliUsageError(
|
|
19677
|
+
`run directory does not match run id ${runId}: ${knownRunDirectory}`
|
|
19678
|
+
);
|
|
19679
|
+
}
|
|
19680
|
+
return knownRunDirectory;
|
|
19681
|
+
}
|
|
19766
19682
|
if (runId.trim() === "") return void 0;
|
|
19767
19683
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19768
19684
|
const booksRoot = join28(ledgerHome, "books");
|
|
@@ -19779,13 +19695,16 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
19779
19695
|
onlyRole
|
|
19780
19696
|
);
|
|
19781
19697
|
}
|
|
19698
|
+
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
19699
|
+
if (existsSync12(recordedPath)) return recordedPath;
|
|
19700
|
+
const parsed = parseRunLeaf(basename12(recordedPath));
|
|
19701
|
+
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
19702
|
+
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
19703
|
+
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
19704
|
+
}
|
|
19782
19705
|
async function readRunParentPath(runDirectory) {
|
|
19783
19706
|
const record = readPageSync(runDirectory, "admitted");
|
|
19784
|
-
|
|
19785
|
-
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
19786
|
-
return record.sourceRunPath;
|
|
19787
|
-
}
|
|
19788
|
-
return void 0;
|
|
19707
|
+
return admittedSourceRunPath(record);
|
|
19789
19708
|
}
|
|
19790
19709
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19791
19710
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
@@ -19800,6 +19719,10 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
19800
19719
|
}
|
|
19801
19720
|
}
|
|
19802
19721
|
async function findLatestRunIdForSeatTicket(input) {
|
|
19722
|
+
const found = await findLatestRunForSeatTicket(input);
|
|
19723
|
+
return found?.runId;
|
|
19724
|
+
}
|
|
19725
|
+
async function findLatestRunForSeatTicket(input) {
|
|
19803
19726
|
if (input.parentRunPath.trim() === "") {
|
|
19804
19727
|
return void 0;
|
|
19805
19728
|
}
|
|
@@ -19822,7 +19745,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19822
19745
|
const parentPath = await readRunParentPath(runDirectory);
|
|
19823
19746
|
if (!await retainedRunPathsMatch(parentPath, input.parentRunPath, input.parentRunPath)) continue;
|
|
19824
19747
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
19825
|
-
if (best === void 0 || runId > best) best = runId;
|
|
19748
|
+
if (best === void 0 || runId > best.runId) best = { runId, runDirectory };
|
|
19826
19749
|
}
|
|
19827
19750
|
return best;
|
|
19828
19751
|
}
|
|
@@ -19840,8 +19763,8 @@ function restoredTicketFields(fields) {
|
|
|
19840
19763
|
...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
|
|
19841
19764
|
};
|
|
19842
19765
|
}
|
|
19843
|
-
async function loadResumableRunRecord(home, runId, authority) {
|
|
19844
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
19766
|
+
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
19767
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
19845
19768
|
if (runDirectory === void 0) {
|
|
19846
19769
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
19847
19770
|
}
|
|
@@ -19933,9 +19856,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19933
19856
|
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
19934
19857
|
}
|
|
19935
19858
|
}
|
|
19936
|
-
|
|
19937
|
-
sourceRunPath = record.sourceRunPath;
|
|
19938
|
-
}
|
|
19859
|
+
sourceRunPath = admittedSourceRunPath(record);
|
|
19939
19860
|
if (isRecord(record.sourceRun)) {
|
|
19940
19861
|
const sr = record.sourceRun;
|
|
19941
19862
|
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
@@ -20011,16 +19932,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20011
19932
|
);
|
|
20012
19933
|
}
|
|
20013
19934
|
}
|
|
20014
|
-
const
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
20018
|
-
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
20019
|
-
home,
|
|
20020
|
-
referencedRunId,
|
|
20021
|
-
run.bookKey,
|
|
20022
|
-
referencedRole
|
|
20023
|
-
);
|
|
19935
|
+
const recordedSourceDirectory = sourceRunPath ?? sourceRun?.runDirectory;
|
|
19936
|
+
if (recordedSourceDirectory !== void 0) {
|
|
19937
|
+
const currentSourceRunDirectory = await resolveLiveRunDirectoryPath(recordedSourceDirectory, home, run.bookKey);
|
|
20024
19938
|
if (currentSourceRunDirectory !== void 0) {
|
|
20025
19939
|
sourceRunPath = currentSourceRunDirectory;
|
|
20026
19940
|
if (sourceRun !== void 0) {
|
|
@@ -20078,14 +19992,19 @@ function seatLoadedResult(loaded, admitted) {
|
|
|
20078
19992
|
run: loaded.run
|
|
20079
19993
|
};
|
|
20080
19994
|
}
|
|
20081
|
-
async function peekRoleRunRole(home, runId) {
|
|
20082
|
-
const runDirectory = await findRunDirectoryById(home, runId);
|
|
19995
|
+
async function peekRoleRunRole(home, runId, options) {
|
|
19996
|
+
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, options?.runDirectory);
|
|
20083
19997
|
if (runDirectory === void 0) return void 0;
|
|
20084
19998
|
const run = await readRoleRunIdentity(runDirectory);
|
|
20085
19999
|
return run?.role;
|
|
20086
20000
|
}
|
|
20087
|
-
async function loadResumablePublicRole(home, runId, authority) {
|
|
20088
|
-
const loaded = await loadResumableRunRecord(
|
|
20001
|
+
async function loadResumablePublicRole(home, runId, authority, options) {
|
|
20002
|
+
const loaded = await loadResumableRunRecord(
|
|
20003
|
+
home,
|
|
20004
|
+
runId,
|
|
20005
|
+
authority,
|
|
20006
|
+
options?.runDirectory
|
|
20007
|
+
);
|
|
20089
20008
|
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
20090
20009
|
}
|
|
20091
20010
|
function admitResumedRole(loaded) {
|
|
@@ -20099,23 +20018,24 @@ function admitResumedRole(loaded) {
|
|
|
20099
20018
|
const base = resumedBaseAdmitted(loaded);
|
|
20100
20019
|
switch (record.admission) {
|
|
20101
20020
|
case "instruction": {
|
|
20021
|
+
const withSource = fields.sourceRunPath === void 0 ? base : { ...base, sourceRunPath: fields.sourceRunPath };
|
|
20102
20022
|
if (packagedResumeSourcePath(role)) {
|
|
20103
20023
|
const admitted = {
|
|
20104
20024
|
role: "inspector",
|
|
20105
|
-
...
|
|
20106
|
-
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
20025
|
+
...withSource
|
|
20107
20026
|
};
|
|
20108
20027
|
return admitted;
|
|
20109
20028
|
}
|
|
20110
20029
|
return {
|
|
20111
20030
|
role,
|
|
20112
|
-
...
|
|
20031
|
+
...withSource
|
|
20113
20032
|
};
|
|
20114
20033
|
}
|
|
20115
20034
|
case "court-materials": {
|
|
20116
20035
|
const admitted = {
|
|
20117
20036
|
role: "countersign",
|
|
20118
|
-
...base
|
|
20037
|
+
...base,
|
|
20038
|
+
...fields.sourceRunPath === void 0 ? {} : { sourceRunPath: fields.sourceRunPath }
|
|
20119
20039
|
};
|
|
20120
20040
|
return admitted;
|
|
20121
20041
|
}
|
|
@@ -20566,6 +20486,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
20566
20486
|
|
|
20567
20487
|
// src/role-runtime.ts
|
|
20568
20488
|
init_run_dossier();
|
|
20489
|
+
init_invocation();
|
|
20569
20490
|
init_host_contracts();
|
|
20570
20491
|
init_sitian_facade();
|
|
20571
20492
|
init_host_session_record();
|
|
@@ -21471,11 +21392,16 @@ function runIdFromNavigatorDirectory(runDirectory) {
|
|
|
21471
21392
|
if (parsed === void 0 || parsed.role !== "navigator") return void 0;
|
|
21472
21393
|
return parsed.runId;
|
|
21473
21394
|
}
|
|
21474
|
-
async function navigatorHostRunResumable(home, runId) {
|
|
21395
|
+
async function navigatorHostRunResumable(home, runId, runDirectory) {
|
|
21475
21396
|
const { piDurablePrincipalAuthority: piDurablePrincipalAuthority2 } = await Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports));
|
|
21476
21397
|
const { loadResumablePublicRole: loadResumablePublicRole2 } = await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports));
|
|
21477
21398
|
try {
|
|
21478
|
-
const loaded = await loadResumablePublicRole2(
|
|
21399
|
+
const loaded = await loadResumablePublicRole2(
|
|
21400
|
+
home,
|
|
21401
|
+
runId,
|
|
21402
|
+
piDurablePrincipalAuthority2,
|
|
21403
|
+
runDirectory === void 0 ? void 0 : { runDirectory }
|
|
21404
|
+
);
|
|
21479
21405
|
return isNavigatorSeat(loaded.admitted.role);
|
|
21480
21406
|
} catch (error) {
|
|
21481
21407
|
if (error instanceof CliUsageError) return false;
|
|
@@ -21489,7 +21415,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21489
21415
|
let noReceipt;
|
|
21490
21416
|
let routePlaybookReadFailure;
|
|
21491
21417
|
let disposed = false;
|
|
21492
|
-
let
|
|
21418
|
+
let hostRun;
|
|
21493
21419
|
const summon = deps?.summonPublicRole ?? (async (options) => {
|
|
21494
21420
|
const { summonPublicRole: summonPublicRole2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
21495
21421
|
return summonPublicRole2(options);
|
|
@@ -21506,7 +21432,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21506
21432
|
try {
|
|
21507
21433
|
const summonHome = await resolveNavigatorLedgerHome(context);
|
|
21508
21434
|
if (disposed) return;
|
|
21509
|
-
const resumeRunId =
|
|
21435
|
+
const resumeRunId = hostRun?.runId;
|
|
21510
21436
|
const baseSummon = {
|
|
21511
21437
|
role: "navigator",
|
|
21512
21438
|
argv: [text],
|
|
@@ -21523,12 +21449,16 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21523
21449
|
if (disposed) return;
|
|
21524
21450
|
summoned = await summon(baseSummon);
|
|
21525
21451
|
} else {
|
|
21526
|
-
const canResume = await resumable(summonHome, resumeRunId);
|
|
21452
|
+
const canResume = await resumable(summonHome, resumeRunId, hostRun?.runDirectory);
|
|
21527
21453
|
if (disposed) return;
|
|
21528
21454
|
if (canResume) {
|
|
21529
|
-
summoned = await summon({
|
|
21455
|
+
summoned = await summon({
|
|
21456
|
+
...baseSummon,
|
|
21457
|
+
resumeRunId,
|
|
21458
|
+
...hostRun === void 0 ? {} : { resumeRunDirectory: hostRun.runDirectory }
|
|
21459
|
+
});
|
|
21530
21460
|
} else {
|
|
21531
|
-
|
|
21461
|
+
hostRun = void 0;
|
|
21532
21462
|
summoned = await summon(baseSummon);
|
|
21533
21463
|
}
|
|
21534
21464
|
}
|
|
@@ -21566,7 +21496,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21566
21496
|
if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
|
|
21567
21497
|
const nextRunId = runIdFromNavigatorDirectory(runDirectory);
|
|
21568
21498
|
if (nextRunId !== void 0) {
|
|
21569
|
-
|
|
21499
|
+
hostRun = { runId: nextRunId, runDirectory };
|
|
21570
21500
|
}
|
|
21571
21501
|
}
|
|
21572
21502
|
if (outcome.kind !== "accepted") {
|
|
@@ -22975,9 +22905,8 @@ function resolveAuditedSourceRunDirectory(roleHost, ctx, role) {
|
|
|
22975
22905
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
22976
22906
|
if (runDirectory !== void 0) {
|
|
22977
22907
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
22978
|
-
|
|
22979
|
-
|
|
22980
|
-
}
|
|
22908
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
22909
|
+
if (sourceRunPath !== void 0) return sourceRunPath.trim();
|
|
22981
22910
|
}
|
|
22982
22911
|
if (role === "auditor") {
|
|
22983
22912
|
const auditor = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV].trim() : "";
|