@akagilnc/pi-workflow-roles 0.1.4673 → 0.1.4698
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 +496 -518
- package/dist/compliance-transport.js +6 -2
- package/dist/gatekeeper-role.js +6 -7
- package/dist/headless-host/production-host.js +492 -514
- package/dist/migrate-book-topology.js +8 -0
- package/dist/public-cli/countersign-run.js +63 -18
- package/dist/public-cli/main.js +488 -513
- package/dist/public-cli/settlement.js +316 -247
- package/dist/public-cli/terminal.js +36 -9
- package/dist/run-terminal-artifacts.js +71 -32
- package/package.json +1 -1
- package/souls/audit-law.md +7 -2
- package/souls/countersign.md +1 -1
- package/souls/gleaner-left.md +1 -1
- package/souls/notary.md +1 -1
- package/souls/quality-law.md +9 -0
- package/souls/reviewer.md +1 -1
- package/src/compliance-transport.ts +8 -2
- package/src/gatekeeper-role.ts +6 -6
- package/src/public-cli/countersign-run.ts +75 -26
- package/src/public-cli/secretariat-run.ts +2 -3
- package/src/public-cli/settlement.ts +380 -355
- package/src/public-cli/terminal.ts +48 -13
- package/src/role-runtime.ts +9 -11
- package/src/run-terminal-artifacts.ts +81 -28
- package/src/secretariat-role.ts +9 -4
|
@@ -1416,6 +1416,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
1416
1416
|
RUN_TERMINAL_ARTIFACT_FILES: () => RUN_TERMINAL_ARTIFACT_FILES,
|
|
1417
1417
|
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS: () => RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS,
|
|
1418
1418
|
isUniqueErrorFallbackName: () => isUniqueErrorFallbackName,
|
|
1419
|
+
listSeamOwnedUniqueErrorFacePaths: () => listSeamOwnedUniqueErrorFacePaths,
|
|
1419
1420
|
readRunTerminalArtifact: () => readRunTerminalArtifact,
|
|
1420
1421
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
1421
1422
|
});
|
|
@@ -1510,30 +1511,55 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
1510
1511
|
if (expectedRunId === void 0) return false;
|
|
1511
1512
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
1512
1513
|
}
|
|
1514
|
+
async function listSeamOwnedUniqueErrorFacePaths(runDirectory) {
|
|
1515
|
+
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
1516
|
+
const owned = await listUniqueErrorFallbackPaths([
|
|
1517
|
+
artifactsDir,
|
|
1518
|
+
runDirectory
|
|
1519
|
+
]);
|
|
1520
|
+
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
1521
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname4(runDirectory)])) {
|
|
1522
|
+
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
1523
|
+
if (read === void 0 || read.status !== "present") continue;
|
|
1524
|
+
if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
|
|
1525
|
+
owned.push(path);
|
|
1526
|
+
}
|
|
1527
|
+
return owned;
|
|
1528
|
+
}
|
|
1529
|
+
function failureClassRank(file) {
|
|
1530
|
+
return file === "error.json" ? 1 : 0;
|
|
1531
|
+
}
|
|
1513
1532
|
async function readRunTerminalArtifact(runDirectory) {
|
|
1514
1533
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
1534
|
+
const present = [];
|
|
1535
|
+
const unreadable = [];
|
|
1536
|
+
const consider = (read) => {
|
|
1537
|
+
if (read === void 0 || read.status === "absent") return;
|
|
1538
|
+
if (read.status === "present") {
|
|
1539
|
+
present.push(read);
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
unreadable.push(read);
|
|
1543
|
+
};
|
|
1515
1544
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
1516
|
-
|
|
1517
|
-
const read = await readTerminalArtifactAtPath(path, file);
|
|
1518
|
-
if (read !== void 0) return read;
|
|
1545
|
+
consider(await readTerminalArtifactAtPath(join5(artifactsDir, file), file));
|
|
1519
1546
|
}
|
|
1520
1547
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1548
|
+
consider(
|
|
1549
|
+
await readTerminalArtifactAtPath(join5(runDirectory, relative4), "error.json")
|
|
1550
|
+
);
|
|
1524
1551
|
}
|
|
1525
|
-
for (const path of await
|
|
1526
|
-
|
|
1527
|
-
if (read !== void 0) return read;
|
|
1552
|
+
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
1553
|
+
consider(await readTerminalArtifactAtPath(path, "error.json"));
|
|
1528
1554
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1555
|
+
if (present.length > 0) {
|
|
1556
|
+
present.sort(
|
|
1557
|
+
(a, b) => failureClassRank(b.file) - failureClassRank(a.file)
|
|
1558
|
+
);
|
|
1559
|
+
return present[0];
|
|
1560
|
+
}
|
|
1561
|
+
if (unreadable.length > 0) {
|
|
1562
|
+
return unreadable[0];
|
|
1537
1563
|
}
|
|
1538
1564
|
return { status: "absent" };
|
|
1539
1565
|
}
|
|
@@ -1616,14 +1642,9 @@ function thisCourtOfficerPayloads(terminal) {
|
|
|
1616
1642
|
if (outcome !== void 0 && (outcome.kind === "accepted" || outcome.kind === "audit_escalation")) {
|
|
1617
1643
|
if (outcome.payloads !== void 0 && outcome.payloads.length > 0) return outcome.payloads;
|
|
1618
1644
|
}
|
|
1619
|
-
if (outcome?.kind === "failure" && outcome.payloads !== void 0 && outcome.payloads.length > 0) {
|
|
1620
|
-
return outcome.payloads;
|
|
1621
|
-
}
|
|
1622
1645
|
return [];
|
|
1623
1646
|
}
|
|
1624
1647
|
function officerFailurePayloads(terminal) {
|
|
1625
|
-
const outcome = terminal?.roleOutcome;
|
|
1626
|
-
if (outcome?.kind === "failure") return outcome.payloads ?? terminal?.submissions ?? [];
|
|
1627
1648
|
return terminal?.submissions ?? [];
|
|
1628
1649
|
}
|
|
1629
1650
|
function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
@@ -1769,6 +1790,114 @@ var init_gatekeeper_role = __esm({
|
|
|
1769
1790
|
}
|
|
1770
1791
|
});
|
|
1771
1792
|
|
|
1793
|
+
// src/public-cli/terminal.ts
|
|
1794
|
+
function encodeTerminalField(value) {
|
|
1795
|
+
return JSON.stringify(value);
|
|
1796
|
+
}
|
|
1797
|
+
function isLawfulTypedTerminalOutcome(outcome) {
|
|
1798
|
+
return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
|
|
1799
|
+
}
|
|
1800
|
+
function exitCodeForTerminalOutcome(outcome) {
|
|
1801
|
+
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
1802
|
+
}
|
|
1803
|
+
function coalesceSubmissionRows(payloads, submissions) {
|
|
1804
|
+
if (payloads !== void 0 && payloads.length > 0) return payloads;
|
|
1805
|
+
if (submissions !== void 0 && submissions.length > 0) return submissions;
|
|
1806
|
+
return payloads ?? submissions ?? [];
|
|
1807
|
+
}
|
|
1808
|
+
function adviceNavigatorFact(input) {
|
|
1809
|
+
return {
|
|
1810
|
+
disposition: "advice",
|
|
1811
|
+
prose: input.prose,
|
|
1812
|
+
...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
function formatTerminalResult(result) {
|
|
1816
|
+
const lines = [];
|
|
1817
|
+
lines.push("role outcome status");
|
|
1818
|
+
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
1819
|
+
lines.push(
|
|
1820
|
+
`${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
1821
|
+
);
|
|
1822
|
+
if (result.roleOutcome.kind === "failure") {
|
|
1823
|
+
lines.push(
|
|
1824
|
+
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
1825
|
+
);
|
|
1826
|
+
}
|
|
1827
|
+
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
1828
|
+
const facts = result.roleOutcome.decisiveFacts;
|
|
1829
|
+
for (const [key, value] of Object.entries(facts)) {
|
|
1830
|
+
if (value === void 0) continue;
|
|
1831
|
+
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
1832
|
+
lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
lines.push(`navigator ${result.navigator.disposition}`);
|
|
1836
|
+
if (result.navigator.advisoryDiagnostic !== void 0) {
|
|
1837
|
+
lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
|
|
1838
|
+
}
|
|
1839
|
+
if (result.navigator.disposition === "advice") {
|
|
1840
|
+
lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
|
|
1841
|
+
} else if (result.navigator.disposition === "unavailable") {
|
|
1842
|
+
lines.push(
|
|
1843
|
+
`unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
for (const artifact of result.artifacts) {
|
|
1847
|
+
lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
|
|
1848
|
+
}
|
|
1849
|
+
if (result.gate !== void 0) {
|
|
1850
|
+
lines.push(
|
|
1851
|
+
`gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
|
|
1852
|
+
);
|
|
1853
|
+
for (const round of result.gate.rounds) {
|
|
1854
|
+
const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
|
|
1855
|
+
lines.push(
|
|
1856
|
+
`gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
if (result.reviewerChildOutcomes !== void 0) {
|
|
1861
|
+
for (const axis of ["completeness", "correctness"]) {
|
|
1862
|
+
const child = result.reviewerChildOutcomes[axis];
|
|
1863
|
+
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
1864
|
+
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
1865
|
+
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
if (result.resume !== void 0) {
|
|
1870
|
+
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
1871
|
+
} else if (result.runId !== void 0) {
|
|
1872
|
+
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
1873
|
+
}
|
|
1874
|
+
if (result.autoResumeCount !== void 0) {
|
|
1875
|
+
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
1876
|
+
}
|
|
1877
|
+
if (result.roleOutcome.kind === "failure") {
|
|
1878
|
+
const recorded = result.submissions ?? [];
|
|
1879
|
+
for (let i = recorded.length - 1; i >= 0; i -= 1) {
|
|
1880
|
+
const payload = recorded[i];
|
|
1881
|
+
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
1882
|
+
lines.push(`recorded-submission ${encodeTerminalField(rendered)}`);
|
|
1883
|
+
}
|
|
1884
|
+
} else {
|
|
1885
|
+
const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? coalesceSubmissionRows(result.roleOutcome.payloads, result.submissions) : result.submissions ?? [];
|
|
1886
|
+
for (let i = payloads.length - 1; i >= 0; i -= 1) {
|
|
1887
|
+
const payload = payloads[i];
|
|
1888
|
+
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
1889
|
+
lines.push(`submission ${encodeTerminalField(rendered)}`);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return `${lines.join("\n")}
|
|
1893
|
+
`;
|
|
1894
|
+
}
|
|
1895
|
+
var init_terminal = __esm({
|
|
1896
|
+
"src/public-cli/terminal.ts"() {
|
|
1897
|
+
"use strict";
|
|
1898
|
+
}
|
|
1899
|
+
});
|
|
1900
|
+
|
|
1772
1901
|
// src/session-assistant-usage.ts
|
|
1773
1902
|
var session_assistant_usage_exports = {};
|
|
1774
1903
|
__export(session_assistant_usage_exports, {
|
|
@@ -14190,100 +14319,6 @@ var init_receipt_delivery_policy = __esm({
|
|
|
14190
14319
|
}
|
|
14191
14320
|
});
|
|
14192
14321
|
|
|
14193
|
-
// src/public-cli/terminal.ts
|
|
14194
|
-
function encodeTerminalField(value) {
|
|
14195
|
-
return JSON.stringify(value);
|
|
14196
|
-
}
|
|
14197
|
-
function isLawfulTypedTerminalOutcome(outcome) {
|
|
14198
|
-
return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
|
|
14199
|
-
}
|
|
14200
|
-
function exitCodeForTerminalOutcome(outcome) {
|
|
14201
|
-
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
14202
|
-
}
|
|
14203
|
-
function adviceNavigatorFact(input) {
|
|
14204
|
-
return {
|
|
14205
|
-
disposition: "advice",
|
|
14206
|
-
prose: input.prose,
|
|
14207
|
-
...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
|
|
14208
|
-
};
|
|
14209
|
-
}
|
|
14210
|
-
function formatTerminalResult(result) {
|
|
14211
|
-
const lines = [];
|
|
14212
|
-
lines.push("role outcome status");
|
|
14213
|
-
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
14214
|
-
lines.push(
|
|
14215
|
-
`${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
14216
|
-
);
|
|
14217
|
-
if (result.roleOutcome.kind === "failure") {
|
|
14218
|
-
lines.push(
|
|
14219
|
-
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
14220
|
-
);
|
|
14221
|
-
}
|
|
14222
|
-
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
14223
|
-
const facts = result.roleOutcome.decisiveFacts;
|
|
14224
|
-
for (const [key, value] of Object.entries(facts)) {
|
|
14225
|
-
if (value === void 0) continue;
|
|
14226
|
-
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
14227
|
-
lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
|
|
14228
|
-
}
|
|
14229
|
-
}
|
|
14230
|
-
lines.push(`navigator ${result.navigator.disposition}`);
|
|
14231
|
-
if (result.navigator.advisoryDiagnostic !== void 0) {
|
|
14232
|
-
lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
|
|
14233
|
-
}
|
|
14234
|
-
if (result.navigator.disposition === "advice") {
|
|
14235
|
-
lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
|
|
14236
|
-
} else if (result.navigator.disposition === "unavailable") {
|
|
14237
|
-
lines.push(
|
|
14238
|
-
`unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
|
|
14239
|
-
);
|
|
14240
|
-
}
|
|
14241
|
-
for (const artifact of result.artifacts) {
|
|
14242
|
-
lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
|
|
14243
|
-
}
|
|
14244
|
-
if (result.gate !== void 0) {
|
|
14245
|
-
lines.push(
|
|
14246
|
-
`gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
|
|
14247
|
-
);
|
|
14248
|
-
for (const round of result.gate.rounds) {
|
|
14249
|
-
const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
|
|
14250
|
-
lines.push(
|
|
14251
|
-
`gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
|
|
14252
|
-
);
|
|
14253
|
-
}
|
|
14254
|
-
}
|
|
14255
|
-
if (result.reviewerChildOutcomes !== void 0) {
|
|
14256
|
-
for (const axis of ["completeness", "correctness"]) {
|
|
14257
|
-
const child = result.reviewerChildOutcomes[axis];
|
|
14258
|
-
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
14259
|
-
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
14260
|
-
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
14261
|
-
}
|
|
14262
|
-
}
|
|
14263
|
-
}
|
|
14264
|
-
if (result.resume !== void 0) {
|
|
14265
|
-
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
14266
|
-
} else if (result.runId !== void 0) {
|
|
14267
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
14268
|
-
}
|
|
14269
|
-
if (result.autoResumeCount !== void 0) {
|
|
14270
|
-
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
14271
|
-
}
|
|
14272
|
-
const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.roleOutcome.kind === "failure" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.submissions ?? [];
|
|
14273
|
-
for (let i = payloads.length - 1; i >= 0; i -= 1) {
|
|
14274
|
-
const payload = payloads[i];
|
|
14275
|
-
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
14276
|
-
lines.push(`submission ${encodeTerminalField(rendered)}`);
|
|
14277
|
-
}
|
|
14278
|
-
return `${lines.join("\n")}
|
|
14279
|
-
`;
|
|
14280
|
-
}
|
|
14281
|
-
var init_terminal = __esm({
|
|
14282
|
-
"src/public-cli/terminal.ts"() {
|
|
14283
|
-
"use strict";
|
|
14284
|
-
}
|
|
14285
|
-
});
|
|
14286
|
-
|
|
14287
14322
|
// src/public-cli/settlement.ts
|
|
14288
14323
|
var settlement_exports = {};
|
|
14289
14324
|
__export(settlement_exports, {
|
|
@@ -14365,7 +14400,7 @@ __export(settlement_exports, {
|
|
|
14365
14400
|
withSubmissions: () => withSubmissions
|
|
14366
14401
|
});
|
|
14367
14402
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14368
|
-
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
|
|
14403
|
+
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
|
|
14369
14404
|
import { dirname as dirname14, join as join26 } from "node:path";
|
|
14370
14405
|
function sealedLedgerHome(admitted) {
|
|
14371
14406
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
@@ -14426,7 +14461,13 @@ async function recordedSubmissionPayloads(admitted, scope) {
|
|
|
14426
14461
|
function withSubmissions(terminal, submissions) {
|
|
14427
14462
|
if (submissions.length === 0) return terminal;
|
|
14428
14463
|
const roleOutcome = terminal.roleOutcome;
|
|
14429
|
-
|
|
14464
|
+
if (roleOutcome.kind === "failure") {
|
|
14465
|
+
return { ...terminal, submissions };
|
|
14466
|
+
}
|
|
14467
|
+
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? {
|
|
14468
|
+
...roleOutcome,
|
|
14469
|
+
payloads: coalesceSubmissionRows(roleOutcome.payloads, submissions)
|
|
14470
|
+
} : roleOutcome;
|
|
14430
14471
|
return { ...terminal, roleOutcome: withPayloads, submissions };
|
|
14431
14472
|
}
|
|
14432
14473
|
async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
@@ -14445,6 +14486,7 @@ async function settleHostEndedNoReceipt(admitted, authority, scope) {
|
|
|
14445
14486
|
attemptPointer: `current:${admitted.runDirectory}`
|
|
14446
14487
|
});
|
|
14447
14488
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
14489
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
14448
14490
|
return withOptionalGateProjection(
|
|
14449
14491
|
{
|
|
14450
14492
|
roleOutcome: {
|
|
@@ -14715,6 +14757,9 @@ function explicitInternalKnownFailureClassificationInput(failure2) {
|
|
|
14715
14757
|
function isMissingPathError4(error) {
|
|
14716
14758
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
14717
14759
|
}
|
|
14760
|
+
function isAbsentFacePathError(error) {
|
|
14761
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
14762
|
+
}
|
|
14718
14763
|
function sessionReadFailure(error, fallbackMessage) {
|
|
14719
14764
|
if (error instanceof SyntaxError) {
|
|
14720
14765
|
const failed2 = new SyntaxError(
|
|
@@ -15473,43 +15518,60 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
15473
15518
|
};
|
|
15474
15519
|
}
|
|
15475
15520
|
}
|
|
15476
|
-
async function
|
|
15477
|
-
|
|
15478
|
-
|
|
15521
|
+
async function removeFaceIfPresent(path) {
|
|
15522
|
+
try {
|
|
15523
|
+
await rm3(path, { recursive: true, force: true });
|
|
15524
|
+
} catch (error) {
|
|
15525
|
+
if (isAbsentFacePathError(error)) return;
|
|
15526
|
+
throw error;
|
|
15527
|
+
}
|
|
15528
|
+
}
|
|
15529
|
+
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
15530
|
+
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
15531
|
+
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
15532
|
+
await removeFaceIfPresent(join26(artifactsDir, file));
|
|
15533
|
+
}
|
|
15534
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
15535
|
+
await removeFaceIfPresent(join26(runDirectory, relative4));
|
|
15536
|
+
}
|
|
15537
|
+
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
15538
|
+
await removeFaceIfPresent(path);
|
|
15539
|
+
}
|
|
15540
|
+
}
|
|
15541
|
+
async function ensureTerminalArtifactFace(runDirectory) {
|
|
15542
|
+
const artifactsDir = await ensureRunArtifactsDir(runDirectory);
|
|
15543
|
+
await clearOppositeTerminalArtifactFace(runDirectory);
|
|
15544
|
+
return artifactsDir;
|
|
15545
|
+
}
|
|
15546
|
+
function acceptedArtifactAttachmentRefs(attachments) {
|
|
15547
|
+
return attachments.map((a) => ({
|
|
15548
|
+
provenancePath: a.provenancePath,
|
|
15549
|
+
frozenPath: a.frozenPath,
|
|
15550
|
+
sha256: a.sha256,
|
|
15551
|
+
byteLength: a.byteLength
|
|
15552
|
+
}));
|
|
15553
|
+
}
|
|
15554
|
+
async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, bodies) {
|
|
15555
|
+
await appendRunAttemptHistory(
|
|
15556
|
+
{
|
|
15557
|
+
role: admitted.role,
|
|
15558
|
+
runId: admitted.runId,
|
|
15559
|
+
sessionFile: coordinates.sessionFile
|
|
15560
|
+
},
|
|
15561
|
+
roleOutcome
|
|
15562
|
+
);
|
|
15563
|
+
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
15479
15564
|
const reportPath = join26(artifactsDir, "report.json");
|
|
15480
15565
|
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
15481
15566
|
await writeFile7(
|
|
15482
15567
|
reportPath,
|
|
15483
|
-
`${JSON.stringify(
|
|
15484
|
-
{
|
|
15485
|
-
role: "judge",
|
|
15486
|
-
runId: admitted.runId,
|
|
15487
|
-
outcome: roleOutcome
|
|
15488
|
-
},
|
|
15489
|
-
null,
|
|
15490
|
-
2
|
|
15491
|
-
)}
|
|
15568
|
+
`${JSON.stringify(bodies.report, null, 2)}
|
|
15492
15569
|
`,
|
|
15493
15570
|
"utf8"
|
|
15494
15571
|
);
|
|
15495
15572
|
await writeFile7(
|
|
15496
15573
|
evidencePath,
|
|
15497
|
-
`${JSON.stringify(
|
|
15498
|
-
{
|
|
15499
|
-
runId: admitted.runId,
|
|
15500
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
15501
|
-
sessionFile: coordinates.sessionFile,
|
|
15502
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
15503
|
-
attachments: admitted.attachments.map((a) => ({
|
|
15504
|
-
provenancePath: a.provenancePath,
|
|
15505
|
-
frozenPath: a.frozenPath,
|
|
15506
|
-
sha256: a.sha256,
|
|
15507
|
-
byteLength: a.byteLength
|
|
15508
|
-
}))
|
|
15509
|
-
},
|
|
15510
|
-
null,
|
|
15511
|
-
2
|
|
15512
|
-
)}
|
|
15574
|
+
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
15513
15575
|
`,
|
|
15514
15576
|
"utf8"
|
|
15515
15577
|
);
|
|
@@ -15518,55 +15580,42 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
15518
15580
|
{ kind: "evidence", path: evidencePath }
|
|
15519
15581
|
];
|
|
15520
15582
|
}
|
|
15583
|
+
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
15584
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15585
|
+
report: {
|
|
15586
|
+
role: "judge",
|
|
15587
|
+
runId: admitted.runId,
|
|
15588
|
+
outcome: roleOutcome
|
|
15589
|
+
},
|
|
15590
|
+
evidence: {
|
|
15591
|
+
runId: admitted.runId,
|
|
15592
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15593
|
+
sessionFile: coordinates.sessionFile,
|
|
15594
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15595
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
15596
|
+
}
|
|
15597
|
+
});
|
|
15598
|
+
}
|
|
15521
15599
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
);
|
|
15541
|
-
await writeFile7(
|
|
15542
|
-
evidencePath,
|
|
15543
|
-
`${JSON.stringify(
|
|
15544
|
-
{
|
|
15545
|
-
runId: admitted.runId,
|
|
15546
|
-
role: "coder",
|
|
15547
|
-
phase: admitted.phase,
|
|
15548
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
15549
|
-
sessionFile: coordinates.sessionFile,
|
|
15550
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
15551
|
-
taskPath: admitted.taskPath,
|
|
15552
|
-
attachments: admitted.attachments.map((a) => ({
|
|
15553
|
-
provenancePath: a.provenancePath,
|
|
15554
|
-
frozenPath: a.frozenPath,
|
|
15555
|
-
sha256: a.sha256,
|
|
15556
|
-
byteLength: a.byteLength
|
|
15557
|
-
})),
|
|
15558
|
-
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
15559
|
-
},
|
|
15560
|
-
null,
|
|
15561
|
-
2
|
|
15562
|
-
)}
|
|
15563
|
-
`,
|
|
15564
|
-
"utf8"
|
|
15565
|
-
);
|
|
15566
|
-
return [
|
|
15567
|
-
{ kind: "report", path: reportPath },
|
|
15568
|
-
{ kind: "evidence", path: evidencePath }
|
|
15569
|
-
];
|
|
15600
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15601
|
+
report: {
|
|
15602
|
+
role: "coder",
|
|
15603
|
+
runId: admitted.runId,
|
|
15604
|
+
phase: admitted.phase,
|
|
15605
|
+
outcome: roleOutcome
|
|
15606
|
+
},
|
|
15607
|
+
evidence: {
|
|
15608
|
+
runId: admitted.runId,
|
|
15609
|
+
role: "coder",
|
|
15610
|
+
phase: admitted.phase,
|
|
15611
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15612
|
+
sessionFile: coordinates.sessionFile,
|
|
15613
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15614
|
+
taskPath: admitted.taskPath,
|
|
15615
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
15616
|
+
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
15617
|
+
}
|
|
15618
|
+
});
|
|
15570
15619
|
}
|
|
15571
15620
|
async function readLawfulSettlementEntries(sessionFile) {
|
|
15572
15621
|
try {
|
|
@@ -15677,59 +15726,30 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
15677
15726
|
return Object.freeze(observed);
|
|
15678
15727
|
}
|
|
15679
15728
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
role: "fixer",
|
|
15705
|
-
phase: admitted.phase,
|
|
15706
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
15707
|
-
sessionFile: coordinates.sessionFile,
|
|
15708
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
15709
|
-
packetPath: admitted.packetPath,
|
|
15710
|
-
...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
|
|
15711
|
-
prerequisites: admitted.prerequisites,
|
|
15712
|
-
attachments: admitted.attachments.map((a) => ({
|
|
15713
|
-
provenancePath: a.provenancePath,
|
|
15714
|
-
frozenPath: a.frozenPath,
|
|
15715
|
-
sha256: a.sha256,
|
|
15716
|
-
byteLength: a.byteLength
|
|
15717
|
-
})),
|
|
15718
|
-
methodProvenance: options.methodProvenance,
|
|
15719
|
-
// Optional diagnosis: availability is package-bound; invocation only when observed.
|
|
15720
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
15721
|
-
methodInvocations: options.methodInvocations ?? []
|
|
15722
|
-
},
|
|
15723
|
-
null,
|
|
15724
|
-
2
|
|
15725
|
-
)}
|
|
15726
|
-
`,
|
|
15727
|
-
"utf8"
|
|
15728
|
-
);
|
|
15729
|
-
return [
|
|
15730
|
-
{ kind: "report", path: reportPath },
|
|
15731
|
-
{ kind: "evidence", path: evidencePath }
|
|
15732
|
-
];
|
|
15729
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15730
|
+
report: {
|
|
15731
|
+
role: "fixer",
|
|
15732
|
+
runId: admitted.runId,
|
|
15733
|
+
phase: admitted.phase,
|
|
15734
|
+
outcome: roleOutcome
|
|
15735
|
+
},
|
|
15736
|
+
evidence: {
|
|
15737
|
+
runId: admitted.runId,
|
|
15738
|
+
role: "fixer",
|
|
15739
|
+
phase: admitted.phase,
|
|
15740
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15741
|
+
sessionFile: coordinates.sessionFile,
|
|
15742
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15743
|
+
packetPath: admitted.packetPath,
|
|
15744
|
+
...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
|
|
15745
|
+
prerequisites: admitted.prerequisites,
|
|
15746
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
15747
|
+
methodProvenance: options.methodProvenance,
|
|
15748
|
+
// Optional diagnosis: availability is package-bound; invocation only when observed.
|
|
15749
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
15750
|
+
methodInvocations: options.methodInvocations ?? []
|
|
15751
|
+
}
|
|
15752
|
+
});
|
|
15733
15753
|
}
|
|
15734
15754
|
async function settleLawfulFixerTerminalResult(admitted, authority, options, scope) {
|
|
15735
15755
|
const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
|
|
@@ -15775,53 +15795,24 @@ async function settleFixerTerminalResult(admitted, authority, options, scope) {
|
|
|
15775
15795
|
return settled;
|
|
15776
15796
|
}
|
|
15777
15797
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
);
|
|
15796
|
-
await writeFile7(
|
|
15797
|
-
evidencePath,
|
|
15798
|
-
`${JSON.stringify(
|
|
15799
|
-
{
|
|
15800
|
-
runId: admitted.runId,
|
|
15801
|
-
role: "collector",
|
|
15802
|
-
...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
|
|
15803
|
-
repository: admitted.repository.canonical,
|
|
15804
|
-
manifestDigest: admitted.manifestDigest,
|
|
15805
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
15806
|
-
sessionFile: coordinates.sessionFile,
|
|
15807
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
15808
|
-
attachments: admitted.attachments.map((a) => ({
|
|
15809
|
-
provenancePath: a.provenancePath,
|
|
15810
|
-
frozenPath: a.frozenPath,
|
|
15811
|
-
sha256: a.sha256,
|
|
15812
|
-
byteLength: a.byteLength
|
|
15813
|
-
}))
|
|
15814
|
-
},
|
|
15815
|
-
null,
|
|
15816
|
-
2
|
|
15817
|
-
)}
|
|
15818
|
-
`,
|
|
15819
|
-
"utf8"
|
|
15820
|
-
);
|
|
15821
|
-
return [
|
|
15822
|
-
{ kind: "report", path: reportPath },
|
|
15823
|
-
{ kind: "evidence", path: evidencePath }
|
|
15824
|
-
];
|
|
15798
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15799
|
+
report: {
|
|
15800
|
+
role: "collector",
|
|
15801
|
+
runId: admitted.runId,
|
|
15802
|
+
outcome: roleOutcome
|
|
15803
|
+
},
|
|
15804
|
+
evidence: {
|
|
15805
|
+
runId: admitted.runId,
|
|
15806
|
+
role: "collector",
|
|
15807
|
+
...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
|
|
15808
|
+
repository: admitted.repository.canonical,
|
|
15809
|
+
manifestDigest: admitted.manifestDigest,
|
|
15810
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15811
|
+
sessionFile: coordinates.sessionFile,
|
|
15812
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15813
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
15814
|
+
}
|
|
15815
|
+
});
|
|
15825
15816
|
}
|
|
15826
15817
|
async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
|
|
15827
15818
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
@@ -15908,55 +15899,26 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
15908
15899
|
return void 0;
|
|
15909
15900
|
}
|
|
15910
15901
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
);
|
|
15931
|
-
await writeFile7(
|
|
15932
|
-
evidencePath,
|
|
15933
|
-
`${JSON.stringify(
|
|
15934
|
-
{
|
|
15935
|
-
runId: admitted.runId,
|
|
15936
|
-
role: "doctor",
|
|
15937
|
-
issueNumber: admitted.issueNumber,
|
|
15938
|
-
caseRunsPath: admitted.caseRunsPath,
|
|
15939
|
-
caseIdentity: admitted.caseIdentity,
|
|
15940
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
15941
|
-
sessionFile: coordinates.sessionFile,
|
|
15942
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
15943
|
-
attachments: admitted.attachments.map((a) => ({
|
|
15944
|
-
provenancePath: a.provenancePath,
|
|
15945
|
-
frozenPath: a.frozenPath,
|
|
15946
|
-
sha256: a.sha256,
|
|
15947
|
-
byteLength: a.byteLength
|
|
15948
|
-
}))
|
|
15949
|
-
},
|
|
15950
|
-
null,
|
|
15951
|
-
2
|
|
15952
|
-
)}
|
|
15953
|
-
`,
|
|
15954
|
-
"utf8"
|
|
15955
|
-
);
|
|
15956
|
-
return [
|
|
15957
|
-
{ kind: "report", path: reportPath },
|
|
15958
|
-
{ kind: "evidence", path: evidencePath }
|
|
15959
|
-
];
|
|
15902
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15903
|
+
report: {
|
|
15904
|
+
role: "doctor",
|
|
15905
|
+
runId: admitted.runId,
|
|
15906
|
+
outcome: roleOutcome,
|
|
15907
|
+
...options.cost === void 0 ? {} : { cost: options.cost },
|
|
15908
|
+
...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
|
|
15909
|
+
},
|
|
15910
|
+
evidence: {
|
|
15911
|
+
runId: admitted.runId,
|
|
15912
|
+
role: "doctor",
|
|
15913
|
+
issueNumber: admitted.issueNumber,
|
|
15914
|
+
caseRunsPath: admitted.caseRunsPath,
|
|
15915
|
+
caseIdentity: admitted.caseIdentity,
|
|
15916
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15917
|
+
sessionFile: coordinates.sessionFile,
|
|
15918
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15919
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
15920
|
+
}
|
|
15921
|
+
});
|
|
15960
15922
|
}
|
|
15961
15923
|
async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
15962
15924
|
const sealed = await sealedLedgerOutcome(admitted, "doctor", scope);
|
|
@@ -16022,6 +15984,22 @@ function currentAttemptStartIndex(entries) {
|
|
|
16022
15984
|
}
|
|
16023
15985
|
return 0;
|
|
16024
15986
|
}
|
|
15987
|
+
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates) {
|
|
15988
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
15989
|
+
report: {
|
|
15990
|
+
role: admitted.role,
|
|
15991
|
+
runId: admitted.runId,
|
|
15992
|
+
outcome: roleOutcome
|
|
15993
|
+
},
|
|
15994
|
+
evidence: {
|
|
15995
|
+
runId: admitted.runId,
|
|
15996
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
15997
|
+
sessionFile: coordinates.sessionFile,
|
|
15998
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
15999
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
16000
|
+
}
|
|
16001
|
+
});
|
|
16002
|
+
}
|
|
16025
16003
|
async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec, scope) {
|
|
16026
16004
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
16027
16005
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
@@ -16052,12 +16030,17 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16052
16030
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
16053
16031
|
if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
|
|
16054
16032
|
const navigator = extractNavigatorFact(entries);
|
|
16033
|
+
const artifacts = await publishSeatAcceptedArtifacts(
|
|
16034
|
+
admitted,
|
|
16035
|
+
roleOutcome,
|
|
16036
|
+
coordinates
|
|
16037
|
+
);
|
|
16055
16038
|
return withSubmissions(
|
|
16056
16039
|
await withOptionalGateProjection(
|
|
16057
16040
|
{
|
|
16058
16041
|
roleOutcome,
|
|
16059
16042
|
navigator,
|
|
16060
|
-
artifacts
|
|
16043
|
+
artifacts,
|
|
16061
16044
|
runId: admitted.runId
|
|
16062
16045
|
},
|
|
16063
16046
|
sessionDirectory,
|
|
@@ -16277,58 +16260,29 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
16277
16260
|
return Object.freeze(observed);
|
|
16278
16261
|
}
|
|
16279
16262
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16303
|
-
role: "reviewer",
|
|
16304
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
16305
|
-
sessionFile: coordinates.sessionFile,
|
|
16306
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
16307
|
-
baseRevision: admitted.baseRevision,
|
|
16308
|
-
lens: admitted.lens,
|
|
16309
|
-
authorityRefs: [...admitted.authorityRefs],
|
|
16310
|
-
...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
|
|
16311
|
-
attachments: admitted.attachments.map((a) => ({
|
|
16312
|
-
provenancePath: a.provenancePath,
|
|
16313
|
-
frozenPath: a.frozenPath,
|
|
16314
|
-
sha256: a.sha256,
|
|
16315
|
-
byteLength: a.byteLength
|
|
16316
|
-
})),
|
|
16317
|
-
methodProvenance: options.methodProvenance,
|
|
16318
|
-
// Forced package method: availability is package-bound; expansion only when observed.
|
|
16319
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
16320
|
-
methodInvocations: options.methodInvocations ?? []
|
|
16321
|
-
},
|
|
16322
|
-
null,
|
|
16323
|
-
2
|
|
16324
|
-
)}
|
|
16325
|
-
`,
|
|
16326
|
-
"utf8"
|
|
16327
|
-
);
|
|
16328
|
-
return [
|
|
16329
|
-
{ kind: "report", path: reportPath },
|
|
16330
|
-
{ kind: "evidence", path: evidencePath }
|
|
16331
|
-
];
|
|
16263
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
16264
|
+
report: {
|
|
16265
|
+
role: "reviewer",
|
|
16266
|
+
runId: admitted.runId,
|
|
16267
|
+
outcome: roleOutcome
|
|
16268
|
+
},
|
|
16269
|
+
evidence: {
|
|
16270
|
+
runId: admitted.runId,
|
|
16271
|
+
role: "reviewer",
|
|
16272
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
16273
|
+
sessionFile: coordinates.sessionFile,
|
|
16274
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
16275
|
+
baseRevision: admitted.baseRevision,
|
|
16276
|
+
lens: admitted.lens,
|
|
16277
|
+
authorityRefs: [...admitted.authorityRefs],
|
|
16278
|
+
...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
|
|
16279
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
16280
|
+
methodProvenance: options.methodProvenance,
|
|
16281
|
+
// Forced package method: availability is package-bound; expansion only when observed.
|
|
16282
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
16283
|
+
methodInvocations: options.methodInvocations ?? []
|
|
16284
|
+
}
|
|
16285
|
+
});
|
|
16332
16286
|
}
|
|
16333
16287
|
async function settleLawfulReviewerTerminalResult(admitted, authority, options, scope) {
|
|
16334
16288
|
const sealed = await sealedLedgerOutcome(admitted, "reviewer", scope);
|
|
@@ -16393,55 +16347,26 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
16393
16347
|
return Object.freeze(observed);
|
|
16394
16348
|
}
|
|
16395
16349
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
16396
|
-
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16402
|
-
|
|
16403
|
-
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
`${JSON.stringify(
|
|
16417
|
-
{
|
|
16418
|
-
runId: admitted.runId,
|
|
16419
|
-
role: "merger",
|
|
16420
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
16421
|
-
sessionFile: coordinates.sessionFile,
|
|
16422
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
16423
|
-
mergerInputPath: admitted.mergerInputPath,
|
|
16424
|
-
derived: admitted.derived,
|
|
16425
|
-
attachments: admitted.attachments.map((a) => ({
|
|
16426
|
-
provenancePath: a.provenancePath,
|
|
16427
|
-
frozenPath: a.frozenPath,
|
|
16428
|
-
sha256: a.sha256,
|
|
16429
|
-
byteLength: a.byteLength
|
|
16430
|
-
})),
|
|
16431
|
-
methodProvenance: options.methodProvenance,
|
|
16432
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
16433
|
-
methodInvocations: options.methodInvocations ?? []
|
|
16434
|
-
},
|
|
16435
|
-
null,
|
|
16436
|
-
2
|
|
16437
|
-
)}
|
|
16438
|
-
`,
|
|
16439
|
-
"utf8"
|
|
16440
|
-
);
|
|
16441
|
-
return [
|
|
16442
|
-
{ kind: "report", path: reportPath },
|
|
16443
|
-
{ kind: "evidence", path: evidencePath }
|
|
16444
|
-
];
|
|
16350
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
16351
|
+
report: {
|
|
16352
|
+
role: "merger",
|
|
16353
|
+
runId: admitted.runId,
|
|
16354
|
+
outcome: roleOutcome
|
|
16355
|
+
},
|
|
16356
|
+
evidence: {
|
|
16357
|
+
runId: admitted.runId,
|
|
16358
|
+
role: "merger",
|
|
16359
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
16360
|
+
sessionFile: coordinates.sessionFile,
|
|
16361
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
16362
|
+
mergerInputPath: admitted.mergerInputPath,
|
|
16363
|
+
derived: admitted.derived,
|
|
16364
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
16365
|
+
methodProvenance: options.methodProvenance,
|
|
16366
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
16367
|
+
methodInvocations: options.methodInvocations ?? []
|
|
16368
|
+
}
|
|
16369
|
+
});
|
|
16445
16370
|
}
|
|
16446
16371
|
async function settleLawfulMergerTerminalResult(admitted, authority, options, scope) {
|
|
16447
16372
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
@@ -16588,6 +16513,16 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
16588
16513
|
admitted.runDirectory
|
|
16589
16514
|
);
|
|
16590
16515
|
const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
|
|
16516
|
+
try {
|
|
16517
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
16518
|
+
} catch (error) {
|
|
16519
|
+
priorIssues.push(
|
|
16520
|
+
publicationAttemptFromError(
|
|
16521
|
+
roleRunArtifactsDirectory(admitted.runDirectory),
|
|
16522
|
+
error
|
|
16523
|
+
)
|
|
16524
|
+
);
|
|
16525
|
+
}
|
|
16591
16526
|
try {
|
|
16592
16527
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile }, {
|
|
16593
16528
|
kind: "failure",
|
|
@@ -16676,33 +16611,41 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
16676
16611
|
const lifecycleEntry = entries.slice(attemptStart).reverse().find((entry) => entry.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE || entry.message?.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE);
|
|
16677
16612
|
const raw = lifecycleEntry?.data ?? lifecycleEntry?.message?.details;
|
|
16678
16613
|
if (raw !== void 0) {
|
|
16614
|
+
let facts;
|
|
16679
16615
|
try {
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16616
|
+
facts = parseNoReceiptLifecycleFacts(raw);
|
|
16617
|
+
} catch {
|
|
16618
|
+
}
|
|
16619
|
+
if (facts !== void 0 && facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
|
|
16620
|
+
let decisiveFacts2 = facts;
|
|
16621
|
+
if (admitted.role === "collector") {
|
|
16622
|
+
const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
|
|
16623
|
+
if (bindRejection !== void 0) {
|
|
16624
|
+
decisiveFacts2 = {
|
|
16625
|
+
...facts,
|
|
16626
|
+
targetBindRejected: true,
|
|
16627
|
+
targetBindDiagnostic: bindRejection.diagnostic,
|
|
16628
|
+
...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
|
|
16629
|
+
};
|
|
16693
16630
|
}
|
|
16694
|
-
return withOptionalGateProjection(
|
|
16695
|
-
{
|
|
16696
|
-
roleOutcome: { kind: "no_receipt", role: admitted.role, status: "no-accepted-receipt", ...facts, decisiveFacts: decisiveFacts2 },
|
|
16697
|
-
navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
|
|
16698
|
-
artifacts: [],
|
|
16699
|
-
runId: admitted.runId
|
|
16700
|
-
},
|
|
16701
|
-
sessionDirectory,
|
|
16702
|
-
detourGateContext(admitted, options)
|
|
16703
|
-
);
|
|
16704
16631
|
}
|
|
16705
|
-
|
|
16632
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
16633
|
+
return withOptionalGateProjection(
|
|
16634
|
+
{
|
|
16635
|
+
roleOutcome: {
|
|
16636
|
+
kind: "no_receipt",
|
|
16637
|
+
role: admitted.role,
|
|
16638
|
+
status: "no-accepted-receipt",
|
|
16639
|
+
...facts,
|
|
16640
|
+
decisiveFacts: decisiveFacts2
|
|
16641
|
+
},
|
|
16642
|
+
navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
|
|
16643
|
+
artifacts: [],
|
|
16644
|
+
runId: admitted.runId
|
|
16645
|
+
},
|
|
16646
|
+
sessionDirectory,
|
|
16647
|
+
detourGateContext(admitted, options)
|
|
16648
|
+
);
|
|
16706
16649
|
}
|
|
16707
16650
|
}
|
|
16708
16651
|
}
|
|
@@ -16853,6 +16796,7 @@ var init_settlement = __esm({
|
|
|
16853
16796
|
init_navigator_invocation_identity();
|
|
16854
16797
|
init_receipt_delivery_policy();
|
|
16855
16798
|
init_role_run_placement();
|
|
16799
|
+
init_run_terminal_artifacts();
|
|
16856
16800
|
init_invocation();
|
|
16857
16801
|
init_terminal();
|
|
16858
16802
|
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
@@ -16904,7 +16848,7 @@ var init_seat_ticket_binding = __esm({
|
|
|
16904
16848
|
});
|
|
16905
16849
|
|
|
16906
16850
|
// src/session-identity.ts
|
|
16907
|
-
import { mkdir as
|
|
16851
|
+
import { mkdir as mkdir2, readFile as readFile18, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
|
|
16908
16852
|
import { dirname as dirname15, join as join27 } from "node:path";
|
|
16909
16853
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
16910
16854
|
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
@@ -16926,7 +16870,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
16926
16870
|
},
|
|
16927
16871
|
async bind(principal, sessionId) {
|
|
16928
16872
|
const target = bindingPath(principal);
|
|
16929
|
-
await
|
|
16873
|
+
await mkdir2(dirname15(target), { recursive: true });
|
|
16930
16874
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
16931
16875
|
await writeFile8(temporary, `${JSON.stringify({ sessionId })}
|
|
16932
16876
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -17651,7 +17595,7 @@ __export(case_dossier_delivery_exports, {
|
|
|
17651
17595
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
17652
17596
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
17653
17597
|
});
|
|
17654
|
-
import { mkdtemp as mkdtemp3, readFile as readFile20, rm as
|
|
17598
|
+
import { mkdtemp as mkdtemp3, readFile as readFile20, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
|
|
17655
17599
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
17656
17600
|
import { join as join29 } from "node:path";
|
|
17657
17601
|
async function projectCaseDossierPointerSection(input) {
|
|
@@ -17691,7 +17635,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
17691
17635
|
CASE_DOSSIER_ATTACH_KEY
|
|
17692
17636
|
);
|
|
17693
17637
|
} finally {
|
|
17694
|
-
await
|
|
17638
|
+
await rm4(stagingDir, { recursive: true, force: true });
|
|
17695
17639
|
}
|
|
17696
17640
|
}
|
|
17697
17641
|
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
@@ -17839,7 +17783,7 @@ var init_process_cancel = __esm({
|
|
|
17839
17783
|
// src/public-cli/auto-resume.ts
|
|
17840
17784
|
import { constants as fsConstants2 } from "node:fs";
|
|
17841
17785
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
17842
|
-
import { lstat as lstat6, mkdir as
|
|
17786
|
+
import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
|
|
17843
17787
|
import { join as join31 } from "node:path";
|
|
17844
17788
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
17845
17789
|
if (options?.lawful === true) {
|
|
@@ -17888,7 +17832,7 @@ async function ensureRealArtifactsDirectory(runDirectory) {
|
|
|
17888
17832
|
}
|
|
17889
17833
|
} catch (error) {
|
|
17890
17834
|
if (!isMissingPathError5(error)) throw error;
|
|
17891
|
-
await
|
|
17835
|
+
await mkdir3(artifactsDir, { recursive: true });
|
|
17892
17836
|
const created = await lstat6(artifactsDir);
|
|
17893
17837
|
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
17894
17838
|
throw new Error("run artifact retention: artifacts directory is not a real directory");
|
|
@@ -20346,9 +20290,39 @@ function buildCountersignTurnRequest(admitted, options) {
|
|
|
20346
20290
|
options
|
|
20347
20291
|
);
|
|
20348
20292
|
}
|
|
20349
|
-
function
|
|
20293
|
+
function isRecord14(value) {
|
|
20294
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20295
|
+
}
|
|
20296
|
+
function isEscalatePayload(payload) {
|
|
20297
|
+
if (!isRecord14(payload)) return false;
|
|
20298
|
+
return payload.status === "escalate" || payload.countersignStatus === "escalate";
|
|
20299
|
+
}
|
|
20300
|
+
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
20301
|
+
if (roleOutcome === void 0) return submissions ?? [];
|
|
20302
|
+
if (roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation") {
|
|
20303
|
+
return roleOutcome.payloads ?? [];
|
|
20304
|
+
}
|
|
20305
|
+
if (roleOutcome.kind === "failure") return submissions ?? [];
|
|
20306
|
+
return [];
|
|
20307
|
+
}
|
|
20308
|
+
function courtDiaristEscalateDiagnostic(roleOutcome, submissions) {
|
|
20309
|
+
const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
|
|
20310
|
+
const escalatePayloads = [];
|
|
20311
|
+
for (const payload of payloads) {
|
|
20312
|
+
if (isEscalatePayload(payload)) escalatePayloads.push(payload);
|
|
20313
|
+
}
|
|
20314
|
+
if (escalatePayloads.length === 0) return "court diarist station escalated";
|
|
20315
|
+
if (escalatePayloads.length === 1) {
|
|
20316
|
+
return `court diarist station escalated: ${readableGateItem(escalatePayloads[0])}`;
|
|
20317
|
+
}
|
|
20318
|
+
return `court diarist station escalated: ${readableGateItem({
|
|
20319
|
+
receipts: escalatePayloads,
|
|
20320
|
+
currentConclusion: escalatePayloads[escalatePayloads.length - 1]
|
|
20321
|
+
})}`;
|
|
20322
|
+
}
|
|
20323
|
+
function courtTicketNumbersFromOutcome(roleOutcome, principalTicket, submissions) {
|
|
20350
20324
|
if (roleOutcome === void 0) return void 0;
|
|
20351
|
-
const payloads = roleOutcome
|
|
20325
|
+
const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
|
|
20352
20326
|
let latest;
|
|
20353
20327
|
for (const payload of payloads) {
|
|
20354
20328
|
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
@@ -20374,12 +20348,7 @@ function courtDiaristEscalated(roleOutcome) {
|
|
|
20374
20348
|
if (roleOutcome === void 0) return false;
|
|
20375
20349
|
if (roleOutcome.kind === "audit_escalation") return true;
|
|
20376
20350
|
if (roleOutcome.kind !== "accepted") return false;
|
|
20377
|
-
return (roleOutcome.payloads ?? []).some(
|
|
20378
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
20379
|
-
return false;
|
|
20380
|
-
const record4 = payload;
|
|
20381
|
-
return record4.status === "escalate" || record4.countersignStatus === "escalate";
|
|
20382
|
-
});
|
|
20351
|
+
return (roleOutcome.payloads ?? []).some(isEscalatePayload);
|
|
20383
20352
|
}
|
|
20384
20353
|
async function invokeCourtDiarist(input, env, io) {
|
|
20385
20354
|
const quietIo = {
|
|
@@ -20413,9 +20382,13 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
20413
20382
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
20414
20383
|
});
|
|
20415
20384
|
const roleOutcome = result.terminal?.roleOutcome;
|
|
20385
|
+
const submissions = result.terminal?.submissions;
|
|
20416
20386
|
if (courtDiaristEscalated(roleOutcome)) {
|
|
20417
20387
|
return {
|
|
20418
|
-
identity: {
|
|
20388
|
+
identity: {
|
|
20389
|
+
kind: "escalate",
|
|
20390
|
+
diagnostic: courtDiaristEscalateDiagnostic(roleOutcome, submissions)
|
|
20391
|
+
}
|
|
20419
20392
|
};
|
|
20420
20393
|
}
|
|
20421
20394
|
if (result.exitCode !== 0) {
|
|
@@ -20431,7 +20404,8 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
20431
20404
|
if (isSafePositiveTicketNumber(asserted)) {
|
|
20432
20405
|
const courtTicketNumbers = courtTicketNumbersFromOutcome(
|
|
20433
20406
|
roleOutcome,
|
|
20434
|
-
asserted
|
|
20407
|
+
asserted,
|
|
20408
|
+
submissions
|
|
20435
20409
|
);
|
|
20436
20410
|
return {
|
|
20437
20411
|
identity: {
|
|
@@ -20476,9 +20450,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
20476
20450
|
io
|
|
20477
20451
|
);
|
|
20478
20452
|
if (outcome.identity.kind === "escalate") {
|
|
20479
|
-
throw new StationChildExhaustedError(
|
|
20480
|
-
"court diarist station escalated (cannot identify court target)"
|
|
20481
|
-
);
|
|
20453
|
+
throw new StationChildExhaustedError(outcome.identity.diagnostic);
|
|
20482
20454
|
}
|
|
20483
20455
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
20484
20456
|
throw new StationChildExhaustedError(
|
|
@@ -20569,9 +20541,7 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
20569
20541
|
timedOut: false,
|
|
20570
20542
|
code: null,
|
|
20571
20543
|
stderr: "",
|
|
20572
|
-
thrown: new Error(
|
|
20573
|
-
"court diarist station escalated (cannot identify court target)"
|
|
20574
|
-
)
|
|
20544
|
+
thrown: new Error(outcome.identity.diagnostic)
|
|
20575
20545
|
},
|
|
20576
20546
|
countersignAdapters(),
|
|
20577
20547
|
env.principalAuthority,
|
|
@@ -20796,6 +20766,7 @@ var init_countersign_run = __esm({
|
|
|
20796
20766
|
init_engine_material();
|
|
20797
20767
|
init_cli_errors();
|
|
20798
20768
|
init_diarist_contracts();
|
|
20769
|
+
init_readable_gate_item();
|
|
20799
20770
|
init_run_ticket_number();
|
|
20800
20771
|
init_invocation();
|
|
20801
20772
|
init_post_admission();
|
|
@@ -21142,7 +21113,7 @@ __export(public_role_summons_exports, {
|
|
|
21142
21113
|
});
|
|
21143
21114
|
import { execFile as execFile3 } from "node:child_process";
|
|
21144
21115
|
import { existsSync as existsSync10 } from "node:fs";
|
|
21145
|
-
import { mkdir as
|
|
21116
|
+
import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath7, rm as rm5 } from "node:fs/promises";
|
|
21146
21117
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
21147
21118
|
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
21148
21119
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -21541,7 +21512,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
21541
21512
|
}
|
|
21542
21513
|
}
|
|
21543
21514
|
try {
|
|
21544
|
-
await
|
|
21515
|
+
await rm5(root, { recursive: true, force: true });
|
|
21545
21516
|
} catch (error) {
|
|
21546
21517
|
cleanupErrors.push(error);
|
|
21547
21518
|
}
|
|
@@ -21559,7 +21530,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
21559
21530
|
});
|
|
21560
21531
|
registered = true;
|
|
21561
21532
|
if (projectRelative !== "") {
|
|
21562
|
-
await
|
|
21533
|
+
await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
21563
21534
|
}
|
|
21564
21535
|
} catch (error) {
|
|
21565
21536
|
await rollback(error);
|
|
@@ -21579,7 +21550,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
21579
21550
|
cleanupErrors.push(error);
|
|
21580
21551
|
}
|
|
21581
21552
|
try {
|
|
21582
|
-
await
|
|
21553
|
+
await rm5(root, { recursive: true, force: true });
|
|
21583
21554
|
} catch (error) {
|
|
21584
21555
|
cleanupErrors.push(error);
|
|
21585
21556
|
}
|
|
@@ -21671,7 +21642,7 @@ async function summonParallelReviewerLenses(options) {
|
|
|
21671
21642
|
});
|
|
21672
21643
|
created.add(path);
|
|
21673
21644
|
if (projectRelative !== "") {
|
|
21674
|
-
await
|
|
21645
|
+
await mkdir4(reviewerSandboxPath(path, projectRelative), { recursive: true });
|
|
21675
21646
|
}
|
|
21676
21647
|
})
|
|
21677
21648
|
);
|
|
@@ -21766,7 +21737,7 @@ ${describeFailure(error)}`;
|
|
|
21766
21737
|
);
|
|
21767
21738
|
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
21768
21739
|
if (cleanupFailures.length === 0) {
|
|
21769
|
-
const rootCleanup = await Promise.allSettled([
|
|
21740
|
+
const rootCleanup = await Promise.allSettled([rm5(root, { recursive: true, force: true })]);
|
|
21770
21741
|
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
21771
21742
|
}
|
|
21772
21743
|
if (cleanupFailures.length > 0) {
|
|
@@ -21919,7 +21890,7 @@ async function projectAuditorTerminal(summoned) {
|
|
|
21919
21890
|
};
|
|
21920
21891
|
}
|
|
21921
21892
|
if (outcome.kind === "failure") {
|
|
21922
|
-
const rows =
|
|
21893
|
+
const rows = summoned.terminal?.submissions ?? [];
|
|
21923
21894
|
return {
|
|
21924
21895
|
status: "transport_failure",
|
|
21925
21896
|
diagnostic: outcome.diagnostic,
|
|
@@ -21929,7 +21900,10 @@ async function projectAuditorTerminal(summoned) {
|
|
|
21929
21900
|
};
|
|
21930
21901
|
}
|
|
21931
21902
|
if (outcome.kind === "accepted") {
|
|
21932
|
-
const rows =
|
|
21903
|
+
const rows = coalesceSubmissionRows(
|
|
21904
|
+
outcome.payloads,
|
|
21905
|
+
summoned.terminal?.submissions
|
|
21906
|
+
);
|
|
21933
21907
|
if (rows.length === 0) {
|
|
21934
21908
|
return readComplianceCandidate({}, usage);
|
|
21935
21909
|
}
|
|
@@ -21991,6 +21965,7 @@ var init_compliance_transport = __esm({
|
|
|
21991
21965
|
"use strict";
|
|
21992
21966
|
init_auditor_dossier_tool();
|
|
21993
21967
|
init_gatekeeper_role();
|
|
21968
|
+
init_terminal();
|
|
21994
21969
|
AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
21995
21970
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
21996
21971
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
@@ -23991,6 +23966,7 @@ function registerEngineDetourTool(roleHost, hostActions) {
|
|
|
23991
23966
|
}
|
|
23992
23967
|
|
|
23993
23968
|
// src/role-runtime.ts
|
|
23969
|
+
init_readable_gate_item();
|
|
23994
23970
|
init_run_terminal_artifacts();
|
|
23995
23971
|
init_receipt_delivery_policy();
|
|
23996
23972
|
|
|
@@ -24005,7 +23981,7 @@ import { join as join38, sep as sep6 } from "node:path";
|
|
|
24005
23981
|
|
|
24006
23982
|
// src/atomic-write.ts
|
|
24007
23983
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
24008
|
-
import { rename as rename3, rm as
|
|
23984
|
+
import { rename as rename3, rm as rm6, writeFile as writeFile11 } from "node:fs/promises";
|
|
24009
23985
|
import { dirname as dirname21, join as join37 } from "node:path";
|
|
24010
23986
|
async function writeFileAtomically(destination, contents) {
|
|
24011
23987
|
const parent = dirname21(destination);
|
|
@@ -24014,7 +23990,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
24014
23990
|
await writeFile11(temporary, contents);
|
|
24015
23991
|
await rename3(temporary, destination);
|
|
24016
23992
|
} catch (error) {
|
|
24017
|
-
await
|
|
23993
|
+
await rm6(temporary, { force: true }).catch(() => void 0);
|
|
24018
23994
|
throw error;
|
|
24019
23995
|
}
|
|
24020
23996
|
}
|
|
@@ -25238,15 +25214,14 @@ function projectSecretariatSummonResult(summoned) {
|
|
|
25238
25214
|
};
|
|
25239
25215
|
}
|
|
25240
25216
|
if (roleOutcome.kind === "failure") {
|
|
25241
|
-
const
|
|
25217
|
+
const submissions = Array.isArray(terminal?.submissions) ? terminal.submissions : void 0;
|
|
25242
25218
|
return {
|
|
25243
25219
|
...base,
|
|
25244
25220
|
outcomeKind: "failure",
|
|
25245
25221
|
diagnostic: roleOutcome.diagnostic,
|
|
25246
25222
|
...roleOutcome.cause === void 0 ? {} : { cause: roleOutcome.cause },
|
|
25247
25223
|
...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts },
|
|
25248
|
-
...
|
|
25249
|
-
...latestObjectPayload(payloads) === void 0 ? {} : { receipt: latestObjectPayload(payloads) }
|
|
25224
|
+
...submissions === void 0 || submissions.length === 0 ? {} : { submissions }
|
|
25250
25225
|
};
|
|
25251
25226
|
}
|
|
25252
25227
|
return {
|
|
@@ -25610,7 +25585,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
25610
25585
|
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
25611
25586
|
}
|
|
25612
25587
|
}
|
|
25613
|
-
function
|
|
25588
|
+
function isRecord15(value) {
|
|
25614
25589
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25615
25590
|
}
|
|
25616
25591
|
function unfinishedReasonPresent(details) {
|
|
@@ -25626,7 +25601,7 @@ function readGateState(session) {
|
|
|
25626
25601
|
if (entry.type !== "custom") continue;
|
|
25627
25602
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
25628
25603
|
const data = entry.data;
|
|
25629
|
-
if (
|
|
25604
|
+
if (isRecord15(data) && (data.head === null || typeof data.head === "string")) {
|
|
25630
25605
|
baseline = data.head;
|
|
25631
25606
|
}
|
|
25632
25607
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26784,10 +26759,13 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
|
|
|
26784
26759
|
...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot }
|
|
26785
26760
|
});
|
|
26786
26761
|
const details = projectSecretariatSummonResult(summoned);
|
|
26787
|
-
const outcomeKind = typeof details.outcomeKind === "string" ? details.outcomeKind : "unknown";
|
|
26788
|
-
const contentText = outcomeKind === "accepted" || outcomeKind === "audit_escalation" ? "\u7ED9\u4E8B\u4E2D\u56DE\u6267\u5DF2\u9001\u8FBE\u4E2D\u4E66\u7701" : outcomeKind === "failure" ? "\u7ED9\u4E8B\u4E2D\u4F20\u53EC\u5931\u8D25" : outcomeKind === "no_receipt" ? "\u7ED9\u4E8B\u4E2D\u65E0\u56DE\u6267" : "\u7ED9\u4E8B\u4E2D\u4F20\u53EC\u672A\u5F97\u7EC8\u5C40";
|
|
26789
26762
|
return {
|
|
26790
|
-
content: [
|
|
26763
|
+
content: [
|
|
26764
|
+
{
|
|
26765
|
+
type: "text",
|
|
26766
|
+
text: readableGateItem(details)
|
|
26767
|
+
}
|
|
26768
|
+
],
|
|
26791
26769
|
details
|
|
26792
26770
|
};
|
|
26793
26771
|
}
|
|
@@ -27840,7 +27818,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27840
27818
|
// src/role-envelope.ts
|
|
27841
27819
|
init_engine_detour();
|
|
27842
27820
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27843
|
-
import { appendFile as appendFile3, mkdir as
|
|
27821
|
+
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
|
|
27844
27822
|
import { createServer } from "node:net";
|
|
27845
27823
|
import { dirname as dirname23, join as join42 } from "node:path";
|
|
27846
27824
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -27938,7 +27916,7 @@ async function requireGatekeeperPass(options) {
|
|
|
27938
27916
|
}
|
|
27939
27917
|
|
|
27940
27918
|
// src/host-native-method.ts
|
|
27941
|
-
import { access as access4, lstat as lstat7, mkdir as
|
|
27919
|
+
import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir9, readFile as readFile24, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
27942
27920
|
import { basename as basename10, dirname as dirname22, join as join41 } from "node:path";
|
|
27943
27921
|
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
27944
27922
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
@@ -28061,7 +28039,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
28061
28039
|
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
28062
28040
|
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
28063
28041
|
}
|
|
28064
|
-
await
|
|
28042
|
+
await mkdir5(dirname22(link), { recursive: true });
|
|
28065
28043
|
try {
|
|
28066
28044
|
await symlink(target, link);
|
|
28067
28045
|
} catch (error) {
|
|
@@ -28116,9 +28094,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
28116
28094
|
let infrastructureRoundFailure;
|
|
28117
28095
|
const hostAbort = new AbortController();
|
|
28118
28096
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28119
|
-
await
|
|
28097
|
+
await mkdir6(request.runDirectory, { recursive: true });
|
|
28120
28098
|
let sessionFile = options.sessionFile ?? join42(request.runDirectory, "session", "session.jsonl");
|
|
28121
|
-
await
|
|
28099
|
+
await mkdir6(dirname23(sessionFile), { recursive: true });
|
|
28122
28100
|
if (request.continuation.kind !== "resume") {
|
|
28123
28101
|
try {
|
|
28124
28102
|
await writeFile12(
|