@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
package/dist/public-cli/main.js
CHANGED
|
@@ -16918,6 +16918,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
16918
16918
|
RUN_TERMINAL_ARTIFACT_FILES: () => RUN_TERMINAL_ARTIFACT_FILES,
|
|
16919
16919
|
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS: () => RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS,
|
|
16920
16920
|
isUniqueErrorFallbackName: () => isUniqueErrorFallbackName,
|
|
16921
|
+
listSeamOwnedUniqueErrorFacePaths: () => listSeamOwnedUniqueErrorFacePaths,
|
|
16921
16922
|
readRunTerminalArtifact: () => readRunTerminalArtifact,
|
|
16922
16923
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
16923
16924
|
});
|
|
@@ -17012,30 +17013,55 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
17012
17013
|
if (expectedRunId === void 0) return false;
|
|
17013
17014
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
17014
17015
|
}
|
|
17016
|
+
async function listSeamOwnedUniqueErrorFacePaths(runDirectory) {
|
|
17017
|
+
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
17018
|
+
const owned = await listUniqueErrorFallbackPaths([
|
|
17019
|
+
artifactsDir,
|
|
17020
|
+
runDirectory
|
|
17021
|
+
]);
|
|
17022
|
+
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
17023
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname7(runDirectory)])) {
|
|
17024
|
+
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
17025
|
+
if (read === void 0 || read.status !== "present") continue;
|
|
17026
|
+
if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
|
|
17027
|
+
owned.push(path);
|
|
17028
|
+
}
|
|
17029
|
+
return owned;
|
|
17030
|
+
}
|
|
17031
|
+
function failureClassRank(file) {
|
|
17032
|
+
return file === "error.json" ? 1 : 0;
|
|
17033
|
+
}
|
|
17015
17034
|
async function readRunTerminalArtifact(runDirectory) {
|
|
17016
17035
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
17036
|
+
const present = [];
|
|
17037
|
+
const unreadable = [];
|
|
17038
|
+
const consider = (read) => {
|
|
17039
|
+
if (read === void 0 || read.status === "absent") return;
|
|
17040
|
+
if (read.status === "present") {
|
|
17041
|
+
present.push(read);
|
|
17042
|
+
return;
|
|
17043
|
+
}
|
|
17044
|
+
unreadable.push(read);
|
|
17045
|
+
};
|
|
17017
17046
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
17018
|
-
|
|
17019
|
-
const read = await readTerminalArtifactAtPath(path, file);
|
|
17020
|
-
if (read !== void 0) return read;
|
|
17047
|
+
consider(await readTerminalArtifactAtPath(join11(artifactsDir, file), file));
|
|
17021
17048
|
}
|
|
17022
17049
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
17023
|
-
|
|
17024
|
-
|
|
17025
|
-
|
|
17050
|
+
consider(
|
|
17051
|
+
await readTerminalArtifactAtPath(join11(runDirectory, relative4), "error.json")
|
|
17052
|
+
);
|
|
17026
17053
|
}
|
|
17027
|
-
for (const path of await
|
|
17028
|
-
|
|
17029
|
-
if (read !== void 0) return read;
|
|
17054
|
+
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
17055
|
+
consider(await readTerminalArtifactAtPath(path, "error.json"));
|
|
17030
17056
|
}
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17057
|
+
if (present.length > 0) {
|
|
17058
|
+
present.sort(
|
|
17059
|
+
(a, b) => failureClassRank(b.file) - failureClassRank(a.file)
|
|
17060
|
+
);
|
|
17061
|
+
return present[0];
|
|
17062
|
+
}
|
|
17063
|
+
if (unreadable.length > 0) {
|
|
17064
|
+
return unreadable[0];
|
|
17039
17065
|
}
|
|
17040
17066
|
return { status: "absent" };
|
|
17041
17067
|
}
|
|
@@ -17073,6 +17099,114 @@ var init_gatekeeper_role = __esm({
|
|
|
17073
17099
|
}
|
|
17074
17100
|
});
|
|
17075
17101
|
|
|
17102
|
+
// src/public-cli/terminal.ts
|
|
17103
|
+
function encodeTerminalField(value) {
|
|
17104
|
+
return JSON.stringify(value);
|
|
17105
|
+
}
|
|
17106
|
+
function isLawfulTypedTerminalOutcome(outcome) {
|
|
17107
|
+
return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
|
|
17108
|
+
}
|
|
17109
|
+
function exitCodeForTerminalOutcome(outcome) {
|
|
17110
|
+
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
17111
|
+
}
|
|
17112
|
+
function coalesceSubmissionRows(payloads, submissions) {
|
|
17113
|
+
if (payloads !== void 0 && payloads.length > 0) return payloads;
|
|
17114
|
+
if (submissions !== void 0 && submissions.length > 0) return submissions;
|
|
17115
|
+
return payloads ?? submissions ?? [];
|
|
17116
|
+
}
|
|
17117
|
+
function adviceNavigatorFact(input) {
|
|
17118
|
+
return {
|
|
17119
|
+
disposition: "advice",
|
|
17120
|
+
prose: input.prose,
|
|
17121
|
+
...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
|
|
17122
|
+
};
|
|
17123
|
+
}
|
|
17124
|
+
function formatTerminalResult(result) {
|
|
17125
|
+
const lines = [];
|
|
17126
|
+
lines.push("role outcome status");
|
|
17127
|
+
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
17128
|
+
lines.push(
|
|
17129
|
+
`${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
17130
|
+
);
|
|
17131
|
+
if (result.roleOutcome.kind === "failure") {
|
|
17132
|
+
lines.push(
|
|
17133
|
+
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
17134
|
+
);
|
|
17135
|
+
}
|
|
17136
|
+
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
17137
|
+
const facts = result.roleOutcome.decisiveFacts;
|
|
17138
|
+
for (const [key, value] of Object.entries(facts)) {
|
|
17139
|
+
if (value === void 0) continue;
|
|
17140
|
+
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
17141
|
+
lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
|
|
17142
|
+
}
|
|
17143
|
+
}
|
|
17144
|
+
lines.push(`navigator ${result.navigator.disposition}`);
|
|
17145
|
+
if (result.navigator.advisoryDiagnostic !== void 0) {
|
|
17146
|
+
lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
|
|
17147
|
+
}
|
|
17148
|
+
if (result.navigator.disposition === "advice") {
|
|
17149
|
+
lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
|
|
17150
|
+
} else if (result.navigator.disposition === "unavailable") {
|
|
17151
|
+
lines.push(
|
|
17152
|
+
`unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
|
|
17153
|
+
);
|
|
17154
|
+
}
|
|
17155
|
+
for (const artifact of result.artifacts) {
|
|
17156
|
+
lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
|
|
17157
|
+
}
|
|
17158
|
+
if (result.gate !== void 0) {
|
|
17159
|
+
lines.push(
|
|
17160
|
+
`gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
|
|
17161
|
+
);
|
|
17162
|
+
for (const round of result.gate.rounds) {
|
|
17163
|
+
const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
|
|
17164
|
+
lines.push(
|
|
17165
|
+
`gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
|
|
17166
|
+
);
|
|
17167
|
+
}
|
|
17168
|
+
}
|
|
17169
|
+
if (result.reviewerChildOutcomes !== void 0) {
|
|
17170
|
+
for (const axis of ["completeness", "correctness"]) {
|
|
17171
|
+
const child = result.reviewerChildOutcomes[axis];
|
|
17172
|
+
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
17173
|
+
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
17174
|
+
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
17175
|
+
}
|
|
17176
|
+
}
|
|
17177
|
+
}
|
|
17178
|
+
if (result.resume !== void 0) {
|
|
17179
|
+
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
17180
|
+
} else if (result.runId !== void 0) {
|
|
17181
|
+
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
17182
|
+
}
|
|
17183
|
+
if (result.autoResumeCount !== void 0) {
|
|
17184
|
+
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
17185
|
+
}
|
|
17186
|
+
if (result.roleOutcome.kind === "failure") {
|
|
17187
|
+
const recorded = result.submissions ?? [];
|
|
17188
|
+
for (let i = recorded.length - 1; i >= 0; i -= 1) {
|
|
17189
|
+
const payload = recorded[i];
|
|
17190
|
+
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
17191
|
+
lines.push(`recorded-submission ${encodeTerminalField(rendered)}`);
|
|
17192
|
+
}
|
|
17193
|
+
} else {
|
|
17194
|
+
const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? coalesceSubmissionRows(result.roleOutcome.payloads, result.submissions) : result.submissions ?? [];
|
|
17195
|
+
for (let i = payloads.length - 1; i >= 0; i -= 1) {
|
|
17196
|
+
const payload = payloads[i];
|
|
17197
|
+
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
17198
|
+
lines.push(`submission ${encodeTerminalField(rendered)}`);
|
|
17199
|
+
}
|
|
17200
|
+
}
|
|
17201
|
+
return `${lines.join("\n")}
|
|
17202
|
+
`;
|
|
17203
|
+
}
|
|
17204
|
+
var init_terminal = __esm({
|
|
17205
|
+
"src/public-cli/terminal.ts"() {
|
|
17206
|
+
"use strict";
|
|
17207
|
+
}
|
|
17208
|
+
});
|
|
17209
|
+
|
|
17076
17210
|
// src/compliance-transport.ts
|
|
17077
17211
|
var AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
|
|
17078
17212
|
var init_compliance_transport = __esm({
|
|
@@ -17080,6 +17214,7 @@ var init_compliance_transport = __esm({
|
|
|
17080
17214
|
"use strict";
|
|
17081
17215
|
init_auditor_dossier_tool();
|
|
17082
17216
|
init_gatekeeper_role();
|
|
17217
|
+
init_terminal();
|
|
17083
17218
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
17084
17219
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
17085
17220
|
}
|
|
@@ -24904,100 +25039,6 @@ var init_receipt_delivery_policy = __esm({
|
|
|
24904
25039
|
}
|
|
24905
25040
|
});
|
|
24906
25041
|
|
|
24907
|
-
// src/public-cli/terminal.ts
|
|
24908
|
-
function encodeTerminalField(value) {
|
|
24909
|
-
return JSON.stringify(value);
|
|
24910
|
-
}
|
|
24911
|
-
function isLawfulTypedTerminalOutcome(outcome) {
|
|
24912
|
-
return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
|
|
24913
|
-
}
|
|
24914
|
-
function exitCodeForTerminalOutcome(outcome) {
|
|
24915
|
-
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
24916
|
-
}
|
|
24917
|
-
function adviceNavigatorFact(input) {
|
|
24918
|
-
return {
|
|
24919
|
-
disposition: "advice",
|
|
24920
|
-
prose: input.prose,
|
|
24921
|
-
...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
|
|
24922
|
-
};
|
|
24923
|
-
}
|
|
24924
|
-
function formatTerminalResult(result) {
|
|
24925
|
-
const lines = [];
|
|
24926
|
-
lines.push("role outcome status");
|
|
24927
|
-
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
24928
|
-
lines.push(
|
|
24929
|
-
`${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
24930
|
-
);
|
|
24931
|
-
if (result.roleOutcome.kind === "failure") {
|
|
24932
|
-
lines.push(
|
|
24933
|
-
`diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
|
|
24934
|
-
);
|
|
24935
|
-
}
|
|
24936
|
-
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
24937
|
-
const facts = result.roleOutcome.decisiveFacts;
|
|
24938
|
-
for (const [key, value] of Object.entries(facts)) {
|
|
24939
|
-
if (value === void 0) continue;
|
|
24940
|
-
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
24941
|
-
lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
|
|
24942
|
-
}
|
|
24943
|
-
}
|
|
24944
|
-
lines.push(`navigator ${result.navigator.disposition}`);
|
|
24945
|
-
if (result.navigator.advisoryDiagnostic !== void 0) {
|
|
24946
|
-
lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
|
|
24947
|
-
}
|
|
24948
|
-
if (result.navigator.disposition === "advice") {
|
|
24949
|
-
lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
|
|
24950
|
-
} else if (result.navigator.disposition === "unavailable") {
|
|
24951
|
-
lines.push(
|
|
24952
|
-
`unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
|
|
24953
|
-
);
|
|
24954
|
-
}
|
|
24955
|
-
for (const artifact of result.artifacts) {
|
|
24956
|
-
lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
|
|
24957
|
-
}
|
|
24958
|
-
if (result.gate !== void 0) {
|
|
24959
|
-
lines.push(
|
|
24960
|
-
`gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
|
|
24961
|
-
);
|
|
24962
|
-
for (const round of result.gate.rounds) {
|
|
24963
|
-
const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
|
|
24964
|
-
lines.push(
|
|
24965
|
-
`gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
|
|
24966
|
-
);
|
|
24967
|
-
}
|
|
24968
|
-
}
|
|
24969
|
-
if (result.reviewerChildOutcomes !== void 0) {
|
|
24970
|
-
for (const axis of ["completeness", "correctness"]) {
|
|
24971
|
-
const child = result.reviewerChildOutcomes[axis];
|
|
24972
|
-
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
24973
|
-
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
24974
|
-
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
24975
|
-
}
|
|
24976
|
-
}
|
|
24977
|
-
}
|
|
24978
|
-
if (result.resume !== void 0) {
|
|
24979
|
-
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
24980
|
-
} else if (result.runId !== void 0) {
|
|
24981
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
24982
|
-
}
|
|
24983
|
-
if (result.autoResumeCount !== void 0) {
|
|
24984
|
-
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
24985
|
-
}
|
|
24986
|
-
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 ?? [];
|
|
24987
|
-
for (let i = payloads.length - 1; i >= 0; i -= 1) {
|
|
24988
|
-
const payload = payloads[i];
|
|
24989
|
-
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
24990
|
-
lines.push(`submission ${encodeTerminalField(rendered)}`);
|
|
24991
|
-
}
|
|
24992
|
-
return `${lines.join("\n")}
|
|
24993
|
-
`;
|
|
24994
|
-
}
|
|
24995
|
-
var init_terminal = __esm({
|
|
24996
|
-
"src/public-cli/terminal.ts"() {
|
|
24997
|
-
"use strict";
|
|
24998
|
-
}
|
|
24999
|
-
});
|
|
25000
|
-
|
|
25001
25042
|
// src/public-cli/settlement.ts
|
|
25002
25043
|
var settlement_exports = {};
|
|
25003
25044
|
__export(settlement_exports, {
|
|
@@ -25079,7 +25120,7 @@ __export(settlement_exports, {
|
|
|
25079
25120
|
withSubmissions: () => withSubmissions
|
|
25080
25121
|
});
|
|
25081
25122
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
25082
|
-
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, writeFile as writeFile6 } from "node:fs/promises";
|
|
25123
|
+
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
25083
25124
|
import { dirname as dirname13, join as join24 } from "node:path";
|
|
25084
25125
|
function sealedLedgerHome(admitted) {
|
|
25085
25126
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
@@ -25140,7 +25181,13 @@ async function recordedSubmissionPayloads(admitted, scope) {
|
|
|
25140
25181
|
function withSubmissions(terminal, submissions) {
|
|
25141
25182
|
if (submissions.length === 0) return terminal;
|
|
25142
25183
|
const roleOutcome = terminal.roleOutcome;
|
|
25143
|
-
|
|
25184
|
+
if (roleOutcome.kind === "failure") {
|
|
25185
|
+
return { ...terminal, submissions };
|
|
25186
|
+
}
|
|
25187
|
+
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? {
|
|
25188
|
+
...roleOutcome,
|
|
25189
|
+
payloads: coalesceSubmissionRows(roleOutcome.payloads, submissions)
|
|
25190
|
+
} : roleOutcome;
|
|
25144
25191
|
return { ...terminal, roleOutcome: withPayloads, submissions };
|
|
25145
25192
|
}
|
|
25146
25193
|
async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
@@ -25159,6 +25206,7 @@ async function settleHostEndedNoReceipt(admitted, authority, scope) {
|
|
|
25159
25206
|
attemptPointer: `current:${admitted.runDirectory}`
|
|
25160
25207
|
});
|
|
25161
25208
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
25209
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
25162
25210
|
return withOptionalGateProjection(
|
|
25163
25211
|
{
|
|
25164
25212
|
roleOutcome: {
|
|
@@ -25429,6 +25477,9 @@ function explicitInternalKnownFailureClassificationInput(failure) {
|
|
|
25429
25477
|
function isMissingPathError4(error) {
|
|
25430
25478
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
25431
25479
|
}
|
|
25480
|
+
function isAbsentFacePathError(error) {
|
|
25481
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
25482
|
+
}
|
|
25432
25483
|
function sessionReadFailure(error, fallbackMessage) {
|
|
25433
25484
|
if (error instanceof SyntaxError) {
|
|
25434
25485
|
const failed2 = new SyntaxError(
|
|
@@ -26187,43 +26238,60 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
26187
26238
|
};
|
|
26188
26239
|
}
|
|
26189
26240
|
}
|
|
26190
|
-
async function
|
|
26191
|
-
|
|
26192
|
-
|
|
26241
|
+
async function removeFaceIfPresent(path) {
|
|
26242
|
+
try {
|
|
26243
|
+
await rm2(path, { recursive: true, force: true });
|
|
26244
|
+
} catch (error) {
|
|
26245
|
+
if (isAbsentFacePathError(error)) return;
|
|
26246
|
+
throw error;
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
26250
|
+
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
26251
|
+
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
26252
|
+
await removeFaceIfPresent(join24(artifactsDir, file));
|
|
26253
|
+
}
|
|
26254
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
26255
|
+
await removeFaceIfPresent(join24(runDirectory, relative4));
|
|
26256
|
+
}
|
|
26257
|
+
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
26258
|
+
await removeFaceIfPresent(path);
|
|
26259
|
+
}
|
|
26260
|
+
}
|
|
26261
|
+
async function ensureTerminalArtifactFace(runDirectory) {
|
|
26262
|
+
const artifactsDir = await ensureRunArtifactsDir(runDirectory);
|
|
26263
|
+
await clearOppositeTerminalArtifactFace(runDirectory);
|
|
26264
|
+
return artifactsDir;
|
|
26265
|
+
}
|
|
26266
|
+
function acceptedArtifactAttachmentRefs(attachments) {
|
|
26267
|
+
return attachments.map((a) => ({
|
|
26268
|
+
provenancePath: a.provenancePath,
|
|
26269
|
+
frozenPath: a.frozenPath,
|
|
26270
|
+
sha256: a.sha256,
|
|
26271
|
+
byteLength: a.byteLength
|
|
26272
|
+
}));
|
|
26273
|
+
}
|
|
26274
|
+
async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, bodies) {
|
|
26275
|
+
await appendRunAttemptHistory(
|
|
26276
|
+
{
|
|
26277
|
+
role: admitted.role,
|
|
26278
|
+
runId: admitted.runId,
|
|
26279
|
+
sessionFile: coordinates.sessionFile
|
|
26280
|
+
},
|
|
26281
|
+
roleOutcome
|
|
26282
|
+
);
|
|
26283
|
+
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
26193
26284
|
const reportPath = join24(artifactsDir, "report.json");
|
|
26194
26285
|
const evidencePath = join24(artifactsDir, "evidence.json");
|
|
26195
26286
|
await writeFile6(
|
|
26196
26287
|
reportPath,
|
|
26197
|
-
`${JSON.stringify(
|
|
26198
|
-
{
|
|
26199
|
-
role: "judge",
|
|
26200
|
-
runId: admitted.runId,
|
|
26201
|
-
outcome: roleOutcome
|
|
26202
|
-
},
|
|
26203
|
-
null,
|
|
26204
|
-
2
|
|
26205
|
-
)}
|
|
26288
|
+
`${JSON.stringify(bodies.report, null, 2)}
|
|
26206
26289
|
`,
|
|
26207
26290
|
"utf8"
|
|
26208
26291
|
);
|
|
26209
26292
|
await writeFile6(
|
|
26210
26293
|
evidencePath,
|
|
26211
|
-
`${JSON.stringify(
|
|
26212
|
-
{
|
|
26213
|
-
runId: admitted.runId,
|
|
26214
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
26215
|
-
sessionFile: coordinates.sessionFile,
|
|
26216
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
26217
|
-
attachments: admitted.attachments.map((a) => ({
|
|
26218
|
-
provenancePath: a.provenancePath,
|
|
26219
|
-
frozenPath: a.frozenPath,
|
|
26220
|
-
sha256: a.sha256,
|
|
26221
|
-
byteLength: a.byteLength
|
|
26222
|
-
}))
|
|
26223
|
-
},
|
|
26224
|
-
null,
|
|
26225
|
-
2
|
|
26226
|
-
)}
|
|
26294
|
+
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
26227
26295
|
`,
|
|
26228
26296
|
"utf8"
|
|
26229
26297
|
);
|
|
@@ -26232,55 +26300,42 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
26232
26300
|
{ kind: "evidence", path: evidencePath }
|
|
26233
26301
|
];
|
|
26234
26302
|
}
|
|
26303
|
+
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
26304
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26305
|
+
report: {
|
|
26306
|
+
role: "judge",
|
|
26307
|
+
runId: admitted.runId,
|
|
26308
|
+
outcome: roleOutcome
|
|
26309
|
+
},
|
|
26310
|
+
evidence: {
|
|
26311
|
+
runId: admitted.runId,
|
|
26312
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26313
|
+
sessionFile: coordinates.sessionFile,
|
|
26314
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26315
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
26316
|
+
}
|
|
26317
|
+
});
|
|
26318
|
+
}
|
|
26235
26319
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26236
|
-
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
-
|
|
26240
|
-
|
|
26241
|
-
|
|
26242
|
-
|
|
26243
|
-
|
|
26244
|
-
|
|
26245
|
-
|
|
26246
|
-
|
|
26247
|
-
|
|
26248
|
-
|
|
26249
|
-
|
|
26250
|
-
|
|
26251
|
-
|
|
26252
|
-
|
|
26253
|
-
|
|
26254
|
-
);
|
|
26255
|
-
await writeFile6(
|
|
26256
|
-
evidencePath,
|
|
26257
|
-
`${JSON.stringify(
|
|
26258
|
-
{
|
|
26259
|
-
runId: admitted.runId,
|
|
26260
|
-
role: "coder",
|
|
26261
|
-
phase: admitted.phase,
|
|
26262
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
26263
|
-
sessionFile: coordinates.sessionFile,
|
|
26264
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
26265
|
-
taskPath: admitted.taskPath,
|
|
26266
|
-
attachments: admitted.attachments.map((a) => ({
|
|
26267
|
-
provenancePath: a.provenancePath,
|
|
26268
|
-
frozenPath: a.frozenPath,
|
|
26269
|
-
sha256: a.sha256,
|
|
26270
|
-
byteLength: a.byteLength
|
|
26271
|
-
})),
|
|
26272
|
-
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
26273
|
-
},
|
|
26274
|
-
null,
|
|
26275
|
-
2
|
|
26276
|
-
)}
|
|
26277
|
-
`,
|
|
26278
|
-
"utf8"
|
|
26279
|
-
);
|
|
26280
|
-
return [
|
|
26281
|
-
{ kind: "report", path: reportPath },
|
|
26282
|
-
{ kind: "evidence", path: evidencePath }
|
|
26283
|
-
];
|
|
26320
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26321
|
+
report: {
|
|
26322
|
+
role: "coder",
|
|
26323
|
+
runId: admitted.runId,
|
|
26324
|
+
phase: admitted.phase,
|
|
26325
|
+
outcome: roleOutcome
|
|
26326
|
+
},
|
|
26327
|
+
evidence: {
|
|
26328
|
+
runId: admitted.runId,
|
|
26329
|
+
role: "coder",
|
|
26330
|
+
phase: admitted.phase,
|
|
26331
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26332
|
+
sessionFile: coordinates.sessionFile,
|
|
26333
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26334
|
+
taskPath: admitted.taskPath,
|
|
26335
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
26336
|
+
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
26337
|
+
}
|
|
26338
|
+
});
|
|
26284
26339
|
}
|
|
26285
26340
|
async function readLawfulSettlementEntries(sessionFile) {
|
|
26286
26341
|
try {
|
|
@@ -26391,59 +26446,30 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
26391
26446
|
return Object.freeze(observed);
|
|
26392
26447
|
}
|
|
26393
26448
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26394
|
-
|
|
26395
|
-
|
|
26396
|
-
|
|
26397
|
-
|
|
26398
|
-
|
|
26399
|
-
|
|
26400
|
-
|
|
26401
|
-
|
|
26402
|
-
|
|
26403
|
-
|
|
26404
|
-
|
|
26405
|
-
|
|
26406
|
-
|
|
26407
|
-
|
|
26408
|
-
|
|
26409
|
-
|
|
26410
|
-
|
|
26411
|
-
|
|
26412
|
-
|
|
26413
|
-
|
|
26414
|
-
|
|
26415
|
-
|
|
26416
|
-
|
|
26417
|
-
|
|
26418
|
-
role: "fixer",
|
|
26419
|
-
phase: admitted.phase,
|
|
26420
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
26421
|
-
sessionFile: coordinates.sessionFile,
|
|
26422
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
26423
|
-
packetPath: admitted.packetPath,
|
|
26424
|
-
...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
|
|
26425
|
-
prerequisites: admitted.prerequisites,
|
|
26426
|
-
attachments: admitted.attachments.map((a) => ({
|
|
26427
|
-
provenancePath: a.provenancePath,
|
|
26428
|
-
frozenPath: a.frozenPath,
|
|
26429
|
-
sha256: a.sha256,
|
|
26430
|
-
byteLength: a.byteLength
|
|
26431
|
-
})),
|
|
26432
|
-
methodProvenance: options.methodProvenance,
|
|
26433
|
-
// Optional diagnosis: availability is package-bound; invocation only when observed.
|
|
26434
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
26435
|
-
methodInvocations: options.methodInvocations ?? []
|
|
26436
|
-
},
|
|
26437
|
-
null,
|
|
26438
|
-
2
|
|
26439
|
-
)}
|
|
26440
|
-
`,
|
|
26441
|
-
"utf8"
|
|
26442
|
-
);
|
|
26443
|
-
return [
|
|
26444
|
-
{ kind: "report", path: reportPath },
|
|
26445
|
-
{ kind: "evidence", path: evidencePath }
|
|
26446
|
-
];
|
|
26449
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26450
|
+
report: {
|
|
26451
|
+
role: "fixer",
|
|
26452
|
+
runId: admitted.runId,
|
|
26453
|
+
phase: admitted.phase,
|
|
26454
|
+
outcome: roleOutcome
|
|
26455
|
+
},
|
|
26456
|
+
evidence: {
|
|
26457
|
+
runId: admitted.runId,
|
|
26458
|
+
role: "fixer",
|
|
26459
|
+
phase: admitted.phase,
|
|
26460
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26461
|
+
sessionFile: coordinates.sessionFile,
|
|
26462
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26463
|
+
packetPath: admitted.packetPath,
|
|
26464
|
+
...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
|
|
26465
|
+
prerequisites: admitted.prerequisites,
|
|
26466
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
26467
|
+
methodProvenance: options.methodProvenance,
|
|
26468
|
+
// Optional diagnosis: availability is package-bound; invocation only when observed.
|
|
26469
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
26470
|
+
methodInvocations: options.methodInvocations ?? []
|
|
26471
|
+
}
|
|
26472
|
+
});
|
|
26447
26473
|
}
|
|
26448
26474
|
async function settleLawfulFixerTerminalResult(admitted, authority, options, scope) {
|
|
26449
26475
|
const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
|
|
@@ -26489,53 +26515,24 @@ async function settleFixerTerminalResult(admitted, authority, options, scope) {
|
|
|
26489
26515
|
return settled;
|
|
26490
26516
|
}
|
|
26491
26517
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
26492
|
-
|
|
26493
|
-
|
|
26494
|
-
|
|
26495
|
-
|
|
26496
|
-
|
|
26497
|
-
|
|
26498
|
-
|
|
26499
|
-
|
|
26500
|
-
|
|
26501
|
-
|
|
26502
|
-
|
|
26503
|
-
|
|
26504
|
-
|
|
26505
|
-
|
|
26506
|
-
|
|
26507
|
-
|
|
26508
|
-
|
|
26509
|
-
);
|
|
26510
|
-
await writeFile6(
|
|
26511
|
-
evidencePath,
|
|
26512
|
-
`${JSON.stringify(
|
|
26513
|
-
{
|
|
26514
|
-
runId: admitted.runId,
|
|
26515
|
-
role: "collector",
|
|
26516
|
-
...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
|
|
26517
|
-
repository: admitted.repository.canonical,
|
|
26518
|
-
manifestDigest: admitted.manifestDigest,
|
|
26519
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
26520
|
-
sessionFile: coordinates.sessionFile,
|
|
26521
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
26522
|
-
attachments: admitted.attachments.map((a) => ({
|
|
26523
|
-
provenancePath: a.provenancePath,
|
|
26524
|
-
frozenPath: a.frozenPath,
|
|
26525
|
-
sha256: a.sha256,
|
|
26526
|
-
byteLength: a.byteLength
|
|
26527
|
-
}))
|
|
26528
|
-
},
|
|
26529
|
-
null,
|
|
26530
|
-
2
|
|
26531
|
-
)}
|
|
26532
|
-
`,
|
|
26533
|
-
"utf8"
|
|
26534
|
-
);
|
|
26535
|
-
return [
|
|
26536
|
-
{ kind: "report", path: reportPath },
|
|
26537
|
-
{ kind: "evidence", path: evidencePath }
|
|
26538
|
-
];
|
|
26518
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26519
|
+
report: {
|
|
26520
|
+
role: "collector",
|
|
26521
|
+
runId: admitted.runId,
|
|
26522
|
+
outcome: roleOutcome
|
|
26523
|
+
},
|
|
26524
|
+
evidence: {
|
|
26525
|
+
runId: admitted.runId,
|
|
26526
|
+
role: "collector",
|
|
26527
|
+
...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
|
|
26528
|
+
repository: admitted.repository.canonical,
|
|
26529
|
+
manifestDigest: admitted.manifestDigest,
|
|
26530
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26531
|
+
sessionFile: coordinates.sessionFile,
|
|
26532
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26533
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
26534
|
+
}
|
|
26535
|
+
});
|
|
26539
26536
|
}
|
|
26540
26537
|
async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
|
|
26541
26538
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
@@ -26622,55 +26619,26 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
26622
26619
|
return void 0;
|
|
26623
26620
|
}
|
|
26624
26621
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
|
|
26632
|
-
|
|
26633
|
-
|
|
26634
|
-
|
|
26635
|
-
|
|
26636
|
-
|
|
26637
|
-
|
|
26638
|
-
|
|
26639
|
-
|
|
26640
|
-
|
|
26641
|
-
|
|
26642
|
-
|
|
26643
|
-
|
|
26644
|
-
);
|
|
26645
|
-
await writeFile6(
|
|
26646
|
-
evidencePath,
|
|
26647
|
-
`${JSON.stringify(
|
|
26648
|
-
{
|
|
26649
|
-
runId: admitted.runId,
|
|
26650
|
-
role: "doctor",
|
|
26651
|
-
issueNumber: admitted.issueNumber,
|
|
26652
|
-
caseRunsPath: admitted.caseRunsPath,
|
|
26653
|
-
caseIdentity: admitted.caseIdentity,
|
|
26654
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
26655
|
-
sessionFile: coordinates.sessionFile,
|
|
26656
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
26657
|
-
attachments: admitted.attachments.map((a) => ({
|
|
26658
|
-
provenancePath: a.provenancePath,
|
|
26659
|
-
frozenPath: a.frozenPath,
|
|
26660
|
-
sha256: a.sha256,
|
|
26661
|
-
byteLength: a.byteLength
|
|
26662
|
-
}))
|
|
26663
|
-
},
|
|
26664
|
-
null,
|
|
26665
|
-
2
|
|
26666
|
-
)}
|
|
26667
|
-
`,
|
|
26668
|
-
"utf8"
|
|
26669
|
-
);
|
|
26670
|
-
return [
|
|
26671
|
-
{ kind: "report", path: reportPath },
|
|
26672
|
-
{ kind: "evidence", path: evidencePath }
|
|
26673
|
-
];
|
|
26622
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26623
|
+
report: {
|
|
26624
|
+
role: "doctor",
|
|
26625
|
+
runId: admitted.runId,
|
|
26626
|
+
outcome: roleOutcome,
|
|
26627
|
+
...options.cost === void 0 ? {} : { cost: options.cost },
|
|
26628
|
+
...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
|
|
26629
|
+
},
|
|
26630
|
+
evidence: {
|
|
26631
|
+
runId: admitted.runId,
|
|
26632
|
+
role: "doctor",
|
|
26633
|
+
issueNumber: admitted.issueNumber,
|
|
26634
|
+
caseRunsPath: admitted.caseRunsPath,
|
|
26635
|
+
caseIdentity: admitted.caseIdentity,
|
|
26636
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26637
|
+
sessionFile: coordinates.sessionFile,
|
|
26638
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26639
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
26640
|
+
}
|
|
26641
|
+
});
|
|
26674
26642
|
}
|
|
26675
26643
|
async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
26676
26644
|
const sealed = await sealedLedgerOutcome(admitted, "doctor", scope);
|
|
@@ -26736,6 +26704,22 @@ function currentAttemptStartIndex(entries) {
|
|
|
26736
26704
|
}
|
|
26737
26705
|
return 0;
|
|
26738
26706
|
}
|
|
26707
|
+
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates) {
|
|
26708
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26709
|
+
report: {
|
|
26710
|
+
role: admitted.role,
|
|
26711
|
+
runId: admitted.runId,
|
|
26712
|
+
outcome: roleOutcome
|
|
26713
|
+
},
|
|
26714
|
+
evidence: {
|
|
26715
|
+
runId: admitted.runId,
|
|
26716
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26717
|
+
sessionFile: coordinates.sessionFile,
|
|
26718
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26719
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
26720
|
+
}
|
|
26721
|
+
});
|
|
26722
|
+
}
|
|
26739
26723
|
async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec, scope) {
|
|
26740
26724
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
26741
26725
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
@@ -26766,12 +26750,17 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26766
26750
|
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
26767
26751
|
if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
|
|
26768
26752
|
const navigator = extractNavigatorFact(entries);
|
|
26753
|
+
const artifacts = await publishSeatAcceptedArtifacts(
|
|
26754
|
+
admitted,
|
|
26755
|
+
roleOutcome,
|
|
26756
|
+
coordinates
|
|
26757
|
+
);
|
|
26769
26758
|
return withSubmissions(
|
|
26770
26759
|
await withOptionalGateProjection(
|
|
26771
26760
|
{
|
|
26772
26761
|
roleOutcome,
|
|
26773
26762
|
navigator,
|
|
26774
|
-
artifacts
|
|
26763
|
+
artifacts,
|
|
26775
26764
|
runId: admitted.runId
|
|
26776
26765
|
},
|
|
26777
26766
|
sessionDirectory,
|
|
@@ -26991,58 +26980,29 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
26991
26980
|
return Object.freeze(observed);
|
|
26992
26981
|
}
|
|
26993
26982
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26994
|
-
|
|
26995
|
-
|
|
26996
|
-
|
|
26997
|
-
|
|
26998
|
-
|
|
26999
|
-
|
|
27000
|
-
|
|
27001
|
-
|
|
27002
|
-
|
|
27003
|
-
|
|
27004
|
-
|
|
27005
|
-
|
|
27006
|
-
|
|
27007
|
-
|
|
27008
|
-
|
|
27009
|
-
|
|
27010
|
-
|
|
27011
|
-
|
|
27012
|
-
|
|
27013
|
-
|
|
27014
|
-
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
role: "reviewer",
|
|
27018
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
27019
|
-
sessionFile: coordinates.sessionFile,
|
|
27020
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
27021
|
-
baseRevision: admitted.baseRevision,
|
|
27022
|
-
lens: admitted.lens,
|
|
27023
|
-
authorityRefs: [...admitted.authorityRefs],
|
|
27024
|
-
...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
|
|
27025
|
-
attachments: admitted.attachments.map((a) => ({
|
|
27026
|
-
provenancePath: a.provenancePath,
|
|
27027
|
-
frozenPath: a.frozenPath,
|
|
27028
|
-
sha256: a.sha256,
|
|
27029
|
-
byteLength: a.byteLength
|
|
27030
|
-
})),
|
|
27031
|
-
methodProvenance: options.methodProvenance,
|
|
27032
|
-
// Forced package method: availability is package-bound; expansion only when observed.
|
|
27033
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
27034
|
-
methodInvocations: options.methodInvocations ?? []
|
|
27035
|
-
},
|
|
27036
|
-
null,
|
|
27037
|
-
2
|
|
27038
|
-
)}
|
|
27039
|
-
`,
|
|
27040
|
-
"utf8"
|
|
27041
|
-
);
|
|
27042
|
-
return [
|
|
27043
|
-
{ kind: "report", path: reportPath },
|
|
27044
|
-
{ kind: "evidence", path: evidencePath }
|
|
27045
|
-
];
|
|
26983
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
26984
|
+
report: {
|
|
26985
|
+
role: "reviewer",
|
|
26986
|
+
runId: admitted.runId,
|
|
26987
|
+
outcome: roleOutcome
|
|
26988
|
+
},
|
|
26989
|
+
evidence: {
|
|
26990
|
+
runId: admitted.runId,
|
|
26991
|
+
role: "reviewer",
|
|
26992
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
26993
|
+
sessionFile: coordinates.sessionFile,
|
|
26994
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
26995
|
+
baseRevision: admitted.baseRevision,
|
|
26996
|
+
lens: admitted.lens,
|
|
26997
|
+
authorityRefs: [...admitted.authorityRefs],
|
|
26998
|
+
...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
|
|
26999
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
27000
|
+
methodProvenance: options.methodProvenance,
|
|
27001
|
+
// Forced package method: availability is package-bound; expansion only when observed.
|
|
27002
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
27003
|
+
methodInvocations: options.methodInvocations ?? []
|
|
27004
|
+
}
|
|
27005
|
+
});
|
|
27046
27006
|
}
|
|
27047
27007
|
async function settleLawfulReviewerTerminalResult(admitted, authority, options, scope) {
|
|
27048
27008
|
const sealed = await sealedLedgerOutcome(admitted, "reviewer", scope);
|
|
@@ -27107,55 +27067,26 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
27107
27067
|
return Object.freeze(observed);
|
|
27108
27068
|
}
|
|
27109
27069
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
|
|
27113
|
-
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
|
|
27121
|
-
|
|
27122
|
-
|
|
27123
|
-
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
`${JSON.stringify(
|
|
27131
|
-
{
|
|
27132
|
-
runId: admitted.runId,
|
|
27133
|
-
role: "merger",
|
|
27134
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
27135
|
-
sessionFile: coordinates.sessionFile,
|
|
27136
|
-
admittedRequestPath: admitted.admittedRequestPath,
|
|
27137
|
-
mergerInputPath: admitted.mergerInputPath,
|
|
27138
|
-
derived: admitted.derived,
|
|
27139
|
-
attachments: admitted.attachments.map((a) => ({
|
|
27140
|
-
provenancePath: a.provenancePath,
|
|
27141
|
-
frozenPath: a.frozenPath,
|
|
27142
|
-
sha256: a.sha256,
|
|
27143
|
-
byteLength: a.byteLength
|
|
27144
|
-
})),
|
|
27145
|
-
methodProvenance: options.methodProvenance,
|
|
27146
|
-
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
27147
|
-
methodInvocations: options.methodInvocations ?? []
|
|
27148
|
-
},
|
|
27149
|
-
null,
|
|
27150
|
-
2
|
|
27151
|
-
)}
|
|
27152
|
-
`,
|
|
27153
|
-
"utf8"
|
|
27154
|
-
);
|
|
27155
|
-
return [
|
|
27156
|
-
{ kind: "report", path: reportPath },
|
|
27157
|
-
{ kind: "evidence", path: evidencePath }
|
|
27158
|
-
];
|
|
27070
|
+
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
27071
|
+
report: {
|
|
27072
|
+
role: "merger",
|
|
27073
|
+
runId: admitted.runId,
|
|
27074
|
+
outcome: roleOutcome
|
|
27075
|
+
},
|
|
27076
|
+
evidence: {
|
|
27077
|
+
runId: admitted.runId,
|
|
27078
|
+
role: "merger",
|
|
27079
|
+
sessionDirectory: coordinates.sessionDirectory,
|
|
27080
|
+
sessionFile: coordinates.sessionFile,
|
|
27081
|
+
admittedRequestPath: admitted.admittedRequestPath,
|
|
27082
|
+
mergerInputPath: admitted.mergerInputPath,
|
|
27083
|
+
derived: admitted.derived,
|
|
27084
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
|
|
27085
|
+
methodProvenance: options.methodProvenance,
|
|
27086
|
+
methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
|
|
27087
|
+
methodInvocations: options.methodInvocations ?? []
|
|
27088
|
+
}
|
|
27089
|
+
});
|
|
27159
27090
|
}
|
|
27160
27091
|
async function settleLawfulMergerTerminalResult(admitted, authority, options, scope) {
|
|
27161
27092
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
@@ -27302,6 +27233,16 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
27302
27233
|
admitted.runDirectory
|
|
27303
27234
|
);
|
|
27304
27235
|
const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
|
|
27236
|
+
try {
|
|
27237
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
27238
|
+
} catch (error) {
|
|
27239
|
+
priorIssues.push(
|
|
27240
|
+
publicationAttemptFromError(
|
|
27241
|
+
roleRunArtifactsDirectory(admitted.runDirectory),
|
|
27242
|
+
error
|
|
27243
|
+
)
|
|
27244
|
+
);
|
|
27245
|
+
}
|
|
27305
27246
|
try {
|
|
27306
27247
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile }, {
|
|
27307
27248
|
kind: "failure",
|
|
@@ -27390,33 +27331,41 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
27390
27331
|
const lifecycleEntry = entries.slice(attemptStart).reverse().find((entry) => entry.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE || entry.message?.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE);
|
|
27391
27332
|
const raw = lifecycleEntry?.data ?? lifecycleEntry?.message?.details;
|
|
27392
27333
|
if (raw !== void 0) {
|
|
27334
|
+
let facts;
|
|
27393
27335
|
try {
|
|
27394
|
-
|
|
27395
|
-
|
|
27396
|
-
|
|
27397
|
-
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
|
|
27401
|
-
|
|
27402
|
-
|
|
27403
|
-
|
|
27404
|
-
|
|
27405
|
-
|
|
27406
|
-
|
|
27336
|
+
facts = parseNoReceiptLifecycleFacts(raw);
|
|
27337
|
+
} catch {
|
|
27338
|
+
}
|
|
27339
|
+
if (facts !== void 0 && facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
|
|
27340
|
+
let decisiveFacts2 = facts;
|
|
27341
|
+
if (admitted.role === "collector") {
|
|
27342
|
+
const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
|
|
27343
|
+
if (bindRejection !== void 0) {
|
|
27344
|
+
decisiveFacts2 = {
|
|
27345
|
+
...facts,
|
|
27346
|
+
targetBindRejected: true,
|
|
27347
|
+
targetBindDiagnostic: bindRejection.diagnostic,
|
|
27348
|
+
...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
|
|
27349
|
+
};
|
|
27407
27350
|
}
|
|
27408
|
-
return withOptionalGateProjection(
|
|
27409
|
-
{
|
|
27410
|
-
roleOutcome: { kind: "no_receipt", role: admitted.role, status: "no-accepted-receipt", ...facts, decisiveFacts: decisiveFacts2 },
|
|
27411
|
-
navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
|
|
27412
|
-
artifacts: [],
|
|
27413
|
-
runId: admitted.runId
|
|
27414
|
-
},
|
|
27415
|
-
sessionDirectory,
|
|
27416
|
-
detourGateContext(admitted, options)
|
|
27417
|
-
);
|
|
27418
27351
|
}
|
|
27419
|
-
|
|
27352
|
+
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
27353
|
+
return withOptionalGateProjection(
|
|
27354
|
+
{
|
|
27355
|
+
roleOutcome: {
|
|
27356
|
+
kind: "no_receipt",
|
|
27357
|
+
role: admitted.role,
|
|
27358
|
+
status: "no-accepted-receipt",
|
|
27359
|
+
...facts,
|
|
27360
|
+
decisiveFacts: decisiveFacts2
|
|
27361
|
+
},
|
|
27362
|
+
navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
|
|
27363
|
+
artifacts: [],
|
|
27364
|
+
runId: admitted.runId
|
|
27365
|
+
},
|
|
27366
|
+
sessionDirectory,
|
|
27367
|
+
detourGateContext(admitted, options)
|
|
27368
|
+
);
|
|
27420
27369
|
}
|
|
27421
27370
|
}
|
|
27422
27371
|
}
|
|
@@ -27567,6 +27516,7 @@ var init_settlement = __esm({
|
|
|
27567
27516
|
init_navigator_invocation_identity();
|
|
27568
27517
|
init_receipt_delivery_policy();
|
|
27569
27518
|
init_role_run_placement();
|
|
27519
|
+
init_run_terminal_artifacts();
|
|
27570
27520
|
init_invocation();
|
|
27571
27521
|
init_terminal();
|
|
27572
27522
|
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
@@ -27624,7 +27574,7 @@ var init_turn_request = __esm({
|
|
|
27624
27574
|
});
|
|
27625
27575
|
|
|
27626
27576
|
// src/session-identity.ts
|
|
27627
|
-
import { mkdir as
|
|
27577
|
+
import { mkdir as mkdir2, readFile as readFile17, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
|
|
27628
27578
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
27629
27579
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
27630
27580
|
const bindingPath = (principal) => join25(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
@@ -27646,7 +27596,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
27646
27596
|
},
|
|
27647
27597
|
async bind(principal, sessionId) {
|
|
27648
27598
|
const target = bindingPath(principal);
|
|
27649
|
-
await
|
|
27599
|
+
await mkdir2(dirname14(target), { recursive: true });
|
|
27650
27600
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
27651
27601
|
await writeFile7(temporary, `${JSON.stringify({ sessionId })}
|
|
27652
27602
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -27717,7 +27667,7 @@ var init_ticket_provenance = __esm({
|
|
|
27717
27667
|
});
|
|
27718
27668
|
|
|
27719
27669
|
// src/public-cli/case-dossier-delivery.ts
|
|
27720
|
-
import { mkdtemp as mkdtemp2, readFile as readFile18, rm as
|
|
27670
|
+
import { mkdtemp as mkdtemp2, readFile as readFile18, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
|
|
27721
27671
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
27722
27672
|
import { join as join26 } from "node:path";
|
|
27723
27673
|
async function projectCaseDossierPointerSection(input) {
|
|
@@ -27757,7 +27707,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
27757
27707
|
CASE_DOSSIER_ATTACH_KEY
|
|
27758
27708
|
);
|
|
27759
27709
|
} finally {
|
|
27760
|
-
await
|
|
27710
|
+
await rm3(stagingDir, { recursive: true, force: true });
|
|
27761
27711
|
}
|
|
27762
27712
|
}
|
|
27763
27713
|
var CASE_DOSSIER_SECTION_HEADING, UNBOUND_DOSSIER_PATH_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
@@ -27923,7 +27873,7 @@ var init_process_cancel = __esm({
|
|
|
27923
27873
|
// src/public-cli/auto-resume.ts
|
|
27924
27874
|
import { constants as fsConstants2 } from "node:fs";
|
|
27925
27875
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
27926
|
-
import { lstat as lstat6, mkdir as
|
|
27876
|
+
import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
|
|
27927
27877
|
import { join as join28 } from "node:path";
|
|
27928
27878
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
27929
27879
|
if (options?.lawful === true) {
|
|
@@ -27972,7 +27922,7 @@ async function ensureRealArtifactsDirectory(runDirectory) {
|
|
|
27972
27922
|
}
|
|
27973
27923
|
} catch (error) {
|
|
27974
27924
|
if (!isMissingPathError5(error)) throw error;
|
|
27975
|
-
await
|
|
27925
|
+
await mkdir3(artifactsDir, { recursive: true });
|
|
27976
27926
|
const created = await lstat6(artifactsDir);
|
|
27977
27927
|
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
27978
27928
|
throw new Error("run artifact retention: artifacts directory is not a real directory");
|
|
@@ -31013,7 +30963,7 @@ __export(public_role_summons_exports, {
|
|
|
31013
30963
|
});
|
|
31014
30964
|
import { execFile as execFile3 } from "node:child_process";
|
|
31015
30965
|
import { existsSync as existsSync10 } from "node:fs";
|
|
31016
|
-
import { mkdir as
|
|
30966
|
+
import { mkdir as mkdir4, mkdtemp as mkdtemp3, realpath as realpath6, rm as rm4 } from "node:fs/promises";
|
|
31017
30967
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
31018
30968
|
import { join as join30, relative as relative3, sep as sep5 } from "node:path";
|
|
31019
30969
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -31412,7 +31362,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
31412
31362
|
}
|
|
31413
31363
|
}
|
|
31414
31364
|
try {
|
|
31415
|
-
await
|
|
31365
|
+
await rm4(root, { recursive: true, force: true });
|
|
31416
31366
|
} catch (error) {
|
|
31417
31367
|
cleanupErrors.push(error);
|
|
31418
31368
|
}
|
|
@@ -31430,7 +31380,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
31430
31380
|
});
|
|
31431
31381
|
registered = true;
|
|
31432
31382
|
if (projectRelative !== "") {
|
|
31433
|
-
await
|
|
31383
|
+
await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
31434
31384
|
}
|
|
31435
31385
|
} catch (error) {
|
|
31436
31386
|
await rollback(error);
|
|
@@ -31450,7 +31400,7 @@ async function openEphemeralReviewerWorktree(options) {
|
|
|
31450
31400
|
cleanupErrors.push(error);
|
|
31451
31401
|
}
|
|
31452
31402
|
try {
|
|
31453
|
-
await
|
|
31403
|
+
await rm4(root, { recursive: true, force: true });
|
|
31454
31404
|
} catch (error) {
|
|
31455
31405
|
cleanupErrors.push(error);
|
|
31456
31406
|
}
|
|
@@ -31542,7 +31492,7 @@ async function summonParallelReviewerLenses(options) {
|
|
|
31542
31492
|
});
|
|
31543
31493
|
created.add(path);
|
|
31544
31494
|
if (projectRelative !== "") {
|
|
31545
|
-
await
|
|
31495
|
+
await mkdir4(reviewerSandboxPath(path, projectRelative), { recursive: true });
|
|
31546
31496
|
}
|
|
31547
31497
|
})
|
|
31548
31498
|
);
|
|
@@ -31637,7 +31587,7 @@ ${describeFailure(error)}`;
|
|
|
31637
31587
|
);
|
|
31638
31588
|
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
31639
31589
|
if (cleanupFailures.length === 0) {
|
|
31640
|
-
const rootCleanup = await Promise.allSettled([
|
|
31590
|
+
const rootCleanup = await Promise.allSettled([rm4(root, { recursive: true, force: true })]);
|
|
31641
31591
|
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
31642
31592
|
}
|
|
31643
31593
|
if (cleanupFailures.length > 0) {
|
|
@@ -31758,9 +31708,39 @@ function buildCountersignTurnRequest(admitted, options) {
|
|
|
31758
31708
|
options
|
|
31759
31709
|
);
|
|
31760
31710
|
}
|
|
31761
|
-
function
|
|
31711
|
+
function isRecord11(value) {
|
|
31712
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31713
|
+
}
|
|
31714
|
+
function isEscalatePayload(payload) {
|
|
31715
|
+
if (!isRecord11(payload)) return false;
|
|
31716
|
+
return payload.status === "escalate" || payload.countersignStatus === "escalate";
|
|
31717
|
+
}
|
|
31718
|
+
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
31719
|
+
if (roleOutcome === void 0) return submissions ?? [];
|
|
31720
|
+
if (roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation") {
|
|
31721
|
+
return roleOutcome.payloads ?? [];
|
|
31722
|
+
}
|
|
31723
|
+
if (roleOutcome.kind === "failure") return submissions ?? [];
|
|
31724
|
+
return [];
|
|
31725
|
+
}
|
|
31726
|
+
function courtDiaristEscalateDiagnostic(roleOutcome, submissions) {
|
|
31727
|
+
const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
|
|
31728
|
+
const escalatePayloads = [];
|
|
31729
|
+
for (const payload of payloads) {
|
|
31730
|
+
if (isEscalatePayload(payload)) escalatePayloads.push(payload);
|
|
31731
|
+
}
|
|
31732
|
+
if (escalatePayloads.length === 0) return "court diarist station escalated";
|
|
31733
|
+
if (escalatePayloads.length === 1) {
|
|
31734
|
+
return `court diarist station escalated: ${readableGateItem(escalatePayloads[0])}`;
|
|
31735
|
+
}
|
|
31736
|
+
return `court diarist station escalated: ${readableGateItem({
|
|
31737
|
+
receipts: escalatePayloads,
|
|
31738
|
+
currentConclusion: escalatePayloads[escalatePayloads.length - 1]
|
|
31739
|
+
})}`;
|
|
31740
|
+
}
|
|
31741
|
+
function courtTicketNumbersFromOutcome(roleOutcome, principalTicket, submissions) {
|
|
31762
31742
|
if (roleOutcome === void 0) return void 0;
|
|
31763
|
-
const payloads = roleOutcome
|
|
31743
|
+
const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
|
|
31764
31744
|
let latest;
|
|
31765
31745
|
for (const payload of payloads) {
|
|
31766
31746
|
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
@@ -31786,12 +31766,7 @@ function courtDiaristEscalated(roleOutcome) {
|
|
|
31786
31766
|
if (roleOutcome === void 0) return false;
|
|
31787
31767
|
if (roleOutcome.kind === "audit_escalation") return true;
|
|
31788
31768
|
if (roleOutcome.kind !== "accepted") return false;
|
|
31789
|
-
return (roleOutcome.payloads ?? []).some(
|
|
31790
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
31791
|
-
return false;
|
|
31792
|
-
const record4 = payload;
|
|
31793
|
-
return record4.status === "escalate" || record4.countersignStatus === "escalate";
|
|
31794
|
-
});
|
|
31769
|
+
return (roleOutcome.payloads ?? []).some(isEscalatePayload);
|
|
31795
31770
|
}
|
|
31796
31771
|
async function invokeCourtDiarist(input, env, io) {
|
|
31797
31772
|
const quietIo = {
|
|
@@ -31825,9 +31800,13 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
31825
31800
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
|
|
31826
31801
|
});
|
|
31827
31802
|
const roleOutcome = result.terminal?.roleOutcome;
|
|
31803
|
+
const submissions = result.terminal?.submissions;
|
|
31828
31804
|
if (courtDiaristEscalated(roleOutcome)) {
|
|
31829
31805
|
return {
|
|
31830
|
-
identity: {
|
|
31806
|
+
identity: {
|
|
31807
|
+
kind: "escalate",
|
|
31808
|
+
diagnostic: courtDiaristEscalateDiagnostic(roleOutcome, submissions)
|
|
31809
|
+
}
|
|
31831
31810
|
};
|
|
31832
31811
|
}
|
|
31833
31812
|
if (result.exitCode !== 0) {
|
|
@@ -31843,7 +31822,8 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
31843
31822
|
if (isSafePositiveTicketNumber(asserted)) {
|
|
31844
31823
|
const courtTicketNumbers = courtTicketNumbersFromOutcome(
|
|
31845
31824
|
roleOutcome,
|
|
31846
|
-
asserted
|
|
31825
|
+
asserted,
|
|
31826
|
+
submissions
|
|
31847
31827
|
);
|
|
31848
31828
|
return {
|
|
31849
31829
|
identity: {
|
|
@@ -31888,9 +31868,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
31888
31868
|
io
|
|
31889
31869
|
);
|
|
31890
31870
|
if (outcome.identity.kind === "escalate") {
|
|
31891
|
-
throw new StationChildExhaustedError(
|
|
31892
|
-
"court diarist station escalated (cannot identify court target)"
|
|
31893
|
-
);
|
|
31871
|
+
throw new StationChildExhaustedError(outcome.identity.diagnostic);
|
|
31894
31872
|
}
|
|
31895
31873
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
31896
31874
|
throw new StationChildExhaustedError(
|
|
@@ -31981,9 +31959,7 @@ async function runPublicCountersign(argv2, env, io, parseCountersignArgv2) {
|
|
|
31981
31959
|
timedOut: false,
|
|
31982
31960
|
code: null,
|
|
31983
31961
|
stderr: "",
|
|
31984
|
-
thrown: new Error(
|
|
31985
|
-
"court diarist station escalated (cannot identify court target)"
|
|
31986
|
-
)
|
|
31962
|
+
thrown: new Error(outcome.identity.diagnostic)
|
|
31987
31963
|
},
|
|
31988
31964
|
countersignAdapters(),
|
|
31989
31965
|
env.principalAuthority,
|
|
@@ -32208,6 +32184,7 @@ var init_countersign_run = __esm({
|
|
|
32208
32184
|
init_engine_material();
|
|
32209
32185
|
init_cli_errors();
|
|
32210
32186
|
init_diarist_contracts();
|
|
32187
|
+
init_readable_gate_item();
|
|
32211
32188
|
init_run_ticket_number();
|
|
32212
32189
|
init_invocation();
|
|
32213
32190
|
init_post_admission();
|
|
@@ -32292,9 +32269,7 @@ async function runPublicSecretariat(argv2, env, io, parseSecretariatArgv2) {
|
|
|
32292
32269
|
timedOut: false,
|
|
32293
32270
|
code: null,
|
|
32294
32271
|
stderr: "",
|
|
32295
|
-
thrown: new Error(
|
|
32296
|
-
"court diarist station escalated (cannot identify court target)"
|
|
32297
|
-
)
|
|
32272
|
+
thrown: new Error(outcome.identity.diagnostic)
|
|
32298
32273
|
},
|
|
32299
32274
|
secretariatAdapters(),
|
|
32300
32275
|
env.principalAuthority,
|
|
@@ -32879,7 +32854,7 @@ var init_analyst_book_key = __esm({
|
|
|
32879
32854
|
|
|
32880
32855
|
// src/atomic-write.ts
|
|
32881
32856
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
32882
|
-
import { rename as rename3, rm as
|
|
32857
|
+
import { rename as rename3, rm as rm5, writeFile as writeFile10 } from "node:fs/promises";
|
|
32883
32858
|
import { dirname as dirname16, join as join31 } from "node:path";
|
|
32884
32859
|
async function writeFileAtomically(destination, contents) {
|
|
32885
32860
|
const parent = dirname16(destination);
|
|
@@ -32888,7 +32863,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
32888
32863
|
await writeFile10(temporary, contents);
|
|
32889
32864
|
await rename3(temporary, destination);
|
|
32890
32865
|
} catch (error) {
|
|
32891
|
-
await
|
|
32866
|
+
await rm5(temporary, { force: true }).catch(() => void 0);
|
|
32892
32867
|
throw error;
|
|
32893
32868
|
}
|
|
32894
32869
|
}
|
|
@@ -32899,7 +32874,7 @@ var init_atomic_write = __esm({
|
|
|
32899
32874
|
});
|
|
32900
32875
|
|
|
32901
32876
|
// src/analyst-index.ts
|
|
32902
|
-
import { open as open3, readFile as readFile19, unlink as
|
|
32877
|
+
import { open as open3, readFile as readFile19, unlink as unlink4 } from "node:fs/promises";
|
|
32903
32878
|
import { dirname as dirname17, join as join32 } from "node:path";
|
|
32904
32879
|
function sleep(ms) {
|
|
32905
32880
|
return new Promise((resolve11) => {
|
|
@@ -32921,7 +32896,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
32921
32896
|
return await fn();
|
|
32922
32897
|
} finally {
|
|
32923
32898
|
await handle.close().catch(() => void 0);
|
|
32924
|
-
await
|
|
32899
|
+
await unlink4(lockPath).catch(() => void 0);
|
|
32925
32900
|
}
|
|
32926
32901
|
} catch (error) {
|
|
32927
32902
|
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
@@ -33239,7 +33214,7 @@ function isMissingPathError6(error) {
|
|
|
33239
33214
|
function errorText3(error) {
|
|
33240
33215
|
return error instanceof Error ? error.message : String(error);
|
|
33241
33216
|
}
|
|
33242
|
-
function
|
|
33217
|
+
function isRecord12(value) {
|
|
33243
33218
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33244
33219
|
}
|
|
33245
33220
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -33247,7 +33222,7 @@ async function readExistingRunLifecycleState(runDirectory) {
|
|
|
33247
33222
|
const raw = JSON.parse(
|
|
33248
33223
|
await readFile20(join33(runDirectory, "run-state.json"), "utf8")
|
|
33249
33224
|
);
|
|
33250
|
-
if (!
|
|
33225
|
+
if (!isRecord12(raw) || typeof raw.state !== "string") return void 0;
|
|
33251
33226
|
return raw.state;
|
|
33252
33227
|
} catch {
|
|
33253
33228
|
return void 0;
|
|
@@ -33311,7 +33286,7 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
33311
33286
|
throw error;
|
|
33312
33287
|
}
|
|
33313
33288
|
const parsed = JSON.parse(raw);
|
|
33314
|
-
if (!
|
|
33289
|
+
if (!isRecord12(parsed)) return void 0;
|
|
33315
33290
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
33316
33291
|
return void 0;
|
|
33317
33292
|
}
|
|
@@ -33340,7 +33315,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
33340
33315
|
try {
|
|
33341
33316
|
const raw = await readFile20(join33(runDirectory, "invocation.json"), "utf8");
|
|
33342
33317
|
const parsed = JSON.parse(raw);
|
|
33343
|
-
if (
|
|
33318
|
+
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
33344
33319
|
return parsed.sessionFile;
|
|
33345
33320
|
}
|
|
33346
33321
|
} catch (error) {
|
|
@@ -33672,7 +33647,7 @@ var init_analyst_ledger = __esm({
|
|
|
33672
33647
|
});
|
|
33673
33648
|
|
|
33674
33649
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
33675
|
-
function
|
|
33650
|
+
function isRecord13(value) {
|
|
33676
33651
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33677
33652
|
}
|
|
33678
33653
|
function wallMsFromSpan(span) {
|
|
@@ -33681,21 +33656,21 @@ function wallMsFromSpan(span) {
|
|
|
33681
33656
|
function findCollectorGroups(body) {
|
|
33682
33657
|
if (Array.isArray(body.groups)) return body.groups;
|
|
33683
33658
|
const receipt = body.receipt;
|
|
33684
|
-
if (
|
|
33659
|
+
if (isRecord13(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
33685
33660
|
const outcome = body.outcome;
|
|
33686
|
-
if (
|
|
33661
|
+
if (isRecord13(outcome)) {
|
|
33687
33662
|
const facts = outcome.decisiveFacts;
|
|
33688
|
-
if (
|
|
33663
|
+
if (isRecord13(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
33689
33664
|
}
|
|
33690
33665
|
return void 0;
|
|
33691
33666
|
}
|
|
33692
33667
|
function extractStatus(body) {
|
|
33693
33668
|
const outcome = body.outcome;
|
|
33694
|
-
if (
|
|
33669
|
+
if (isRecord13(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
33695
33670
|
return outcome.status;
|
|
33696
33671
|
}
|
|
33697
33672
|
const receipt = body.receipt;
|
|
33698
|
-
if (
|
|
33673
|
+
if (isRecord13(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
33699
33674
|
return receipt.status;
|
|
33700
33675
|
}
|
|
33701
33676
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -34320,21 +34295,21 @@ var init_leg_wall_clock = __esm({
|
|
|
34320
34295
|
});
|
|
34321
34296
|
|
|
34322
34297
|
// src/analyst-metric-families/round-timeline.ts
|
|
34323
|
-
function
|
|
34298
|
+
function isRecord14(value) {
|
|
34324
34299
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34325
34300
|
}
|
|
34326
34301
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
34327
34302
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
34328
34303
|
}
|
|
34329
34304
|
function readOutcomeStatus(body) {
|
|
34330
|
-
if (!
|
|
34305
|
+
if (!isRecord14(body.outcome)) return void 0;
|
|
34331
34306
|
const status = body.outcome.status;
|
|
34332
34307
|
if (typeof status !== "string" || status.trim() === "") return void 0;
|
|
34333
34308
|
return status;
|
|
34334
34309
|
}
|
|
34335
34310
|
function readClassCount(body) {
|
|
34336
|
-
if (!
|
|
34337
|
-
if (!
|
|
34311
|
+
if (!isRecord14(body.outcome)) return void 0;
|
|
34312
|
+
if (!isRecord14(body.outcome.decisiveFacts)) return void 0;
|
|
34338
34313
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
34339
34314
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
34340
34315
|
return void 0;
|