@akagilnc/pi-workflow-roles 0.1.4631 → 0.1.4641
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 +731 -329
- package/dist/gatekeeper-role.js +76 -6
- package/dist/headless-host/production-host.js +708 -306
- package/dist/migrate-book-topology.js +9 -0
- package/dist/public-cli/countersign-run.js +31 -10
- package/dist/public-cli/main.js +401 -287
- package/dist/public-cli/settlement.js +95 -2
- package/dist/public-role-summons.js +19 -0
- package/dist/secretariat-contracts.js +4 -0
- package/package.json +1 -1
- package/src/archivist-record-entry.ts +2 -2
- package/src/audit-escalation.ts +1 -1
- package/src/gatekeeper-pass-envelope.ts +37 -5
- package/src/gatekeeper-role.ts +125 -20
- package/src/host-contracts.ts +22 -2
- package/src/pi/adapter.ts +5 -1
- package/src/public-cli/countersign-run.ts +50 -13
- package/src/public-cli/settlement.ts +117 -1
- package/src/public-role-summons.ts +30 -4
- package/src/role-envelope.ts +27 -10
- package/src/role-runtime.ts +142 -4
- package/src/secretariat-contracts.ts +18 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -374,6 +374,15 @@ var init_activation_ledger_topology = __esm({
|
|
|
374
374
|
});
|
|
375
375
|
|
|
376
376
|
// src/run-ticket-number.ts
|
|
377
|
+
var run_ticket_number_exports = {};
|
|
378
|
+
__export(run_ticket_number_exports, {
|
|
379
|
+
MIGRATION_TICKET_DERIVATION_PAGE: () => MIGRATION_TICKET_DERIVATION_PAGE,
|
|
380
|
+
isSafePositiveTicketNumber: () => isSafePositiveTicketNumber,
|
|
381
|
+
readBoardTicketNumber: () => readBoardTicketNumber,
|
|
382
|
+
readMigrationDerivedTicketNumber: () => readMigrationDerivedTicketNumber,
|
|
383
|
+
readRunTicketNumber: () => readRunTicketNumber,
|
|
384
|
+
requireSafePositiveTicketNumber: () => requireSafePositiveTicketNumber
|
|
385
|
+
});
|
|
377
386
|
import { readFile } from "node:fs/promises";
|
|
378
387
|
import { join as join3 } from "node:path";
|
|
379
388
|
function isEnoent(error) {
|
|
@@ -14940,11 +14949,13 @@ var init_diarist_contracts = __esm({
|
|
|
14940
14949
|
});
|
|
14941
14950
|
|
|
14942
14951
|
// src/secretariat-contracts.ts
|
|
14943
|
-
var SECRETARIAT_OUTPUT_TOOL_NAME;
|
|
14952
|
+
var SECRETARIAT_OUTPUT_TOOL_NAME, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
|
|
14944
14953
|
var init_secretariat_contracts = __esm({
|
|
14945
14954
|
"src/secretariat-contracts.ts"() {
|
|
14946
14955
|
"use strict";
|
|
14947
14956
|
SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
14957
|
+
SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
|
|
14958
|
+
SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
|
|
14948
14959
|
}
|
|
14949
14960
|
});
|
|
14950
14961
|
|
|
@@ -16901,6 +16912,154 @@ var init_submission_errors = __esm({
|
|
|
16901
16912
|
}
|
|
16902
16913
|
});
|
|
16903
16914
|
|
|
16915
|
+
// src/run-terminal-artifacts.ts
|
|
16916
|
+
var run_terminal_artifacts_exports = {};
|
|
16917
|
+
__export(run_terminal_artifacts_exports, {
|
|
16918
|
+
RUN_TERMINAL_ARTIFACT_FILES: () => RUN_TERMINAL_ARTIFACT_FILES,
|
|
16919
|
+
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS: () => RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS,
|
|
16920
|
+
isUniqueErrorFallbackName: () => isUniqueErrorFallbackName,
|
|
16921
|
+
readRunTerminalArtifact: () => readRunTerminalArtifact,
|
|
16922
|
+
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
16923
|
+
});
|
|
16924
|
+
import { readdir as readdir2, readFile as readFile5 } from "node:fs/promises";
|
|
16925
|
+
import { basename as basename4, dirname as dirname7, join as join11 } from "node:path";
|
|
16926
|
+
function isMissingPathError2(error) {
|
|
16927
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
16928
|
+
}
|
|
16929
|
+
function errorText2(error) {
|
|
16930
|
+
return error instanceof Error ? error.message : String(error);
|
|
16931
|
+
}
|
|
16932
|
+
function isRecord3(value) {
|
|
16933
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16934
|
+
}
|
|
16935
|
+
function readUsableTerminalArtifactBody(body) {
|
|
16936
|
+
if (body === null) {
|
|
16937
|
+
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
16938
|
+
}
|
|
16939
|
+
if (!isRecord3(body)) {
|
|
16940
|
+
return {
|
|
16941
|
+
ok: false,
|
|
16942
|
+
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
16943
|
+
};
|
|
16944
|
+
}
|
|
16945
|
+
if (typeof body.role !== "string" || body.role.trim() === "") {
|
|
16946
|
+
return {
|
|
16947
|
+
ok: false,
|
|
16948
|
+
reason: "terminal artifact missing nonblank producer-owned role field"
|
|
16949
|
+
};
|
|
16950
|
+
}
|
|
16951
|
+
return { ok: true, body };
|
|
16952
|
+
}
|
|
16953
|
+
async function readTerminalArtifactAtPath(path, file) {
|
|
16954
|
+
let raw;
|
|
16955
|
+
try {
|
|
16956
|
+
raw = await readFile5(path, "utf8");
|
|
16957
|
+
} catch (error) {
|
|
16958
|
+
if (isMissingPathError2(error)) return void 0;
|
|
16959
|
+
return {
|
|
16960
|
+
status: "unreadable",
|
|
16961
|
+
file,
|
|
16962
|
+
path,
|
|
16963
|
+
reason: errorText2(error)
|
|
16964
|
+
};
|
|
16965
|
+
}
|
|
16966
|
+
let parsed;
|
|
16967
|
+
try {
|
|
16968
|
+
parsed = JSON.parse(raw);
|
|
16969
|
+
} catch (error) {
|
|
16970
|
+
return {
|
|
16971
|
+
status: "unreadable",
|
|
16972
|
+
file,
|
|
16973
|
+
path,
|
|
16974
|
+
reason: error instanceof Error ? error.message : `terminal artifact JSON parse failed: ${String(error)}`
|
|
16975
|
+
};
|
|
16976
|
+
}
|
|
16977
|
+
const usable = readUsableTerminalArtifactBody(parsed);
|
|
16978
|
+
if (!usable.ok) {
|
|
16979
|
+
return {
|
|
16980
|
+
status: "unreadable",
|
|
16981
|
+
file,
|
|
16982
|
+
path,
|
|
16983
|
+
reason: usable.reason
|
|
16984
|
+
};
|
|
16985
|
+
}
|
|
16986
|
+
return { status: "present", file, path, body: usable.body };
|
|
16987
|
+
}
|
|
16988
|
+
async function listUniqueErrorFallbackPaths(directories) {
|
|
16989
|
+
const found = [];
|
|
16990
|
+
for (const dir of directories) {
|
|
16991
|
+
let names;
|
|
16992
|
+
try {
|
|
16993
|
+
names = await readdir2(dir);
|
|
16994
|
+
} catch (error) {
|
|
16995
|
+
if (isMissingPathError2(error)) continue;
|
|
16996
|
+
throw error;
|
|
16997
|
+
}
|
|
16998
|
+
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
16999
|
+
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
17000
|
+
found.push(join11(dir, name));
|
|
17001
|
+
}
|
|
17002
|
+
}
|
|
17003
|
+
return found;
|
|
17004
|
+
}
|
|
17005
|
+
function runIdFromRunDirectory(runDirectory) {
|
|
17006
|
+
const name = basename4(runDirectory);
|
|
17007
|
+
const at = name.lastIndexOf("@");
|
|
17008
|
+
if (at <= 0 || at === name.length - 1) return void 0;
|
|
17009
|
+
return name.slice(0, at);
|
|
17010
|
+
}
|
|
17011
|
+
function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
17012
|
+
if (expectedRunId === void 0) return false;
|
|
17013
|
+
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
17014
|
+
}
|
|
17015
|
+
async function readRunTerminalArtifact(runDirectory) {
|
|
17016
|
+
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
17017
|
+
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
17018
|
+
const path = join11(artifactsDir, file);
|
|
17019
|
+
const read = await readTerminalArtifactAtPath(path, file);
|
|
17020
|
+
if (read !== void 0) return read;
|
|
17021
|
+
}
|
|
17022
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
17023
|
+
const path = join11(runDirectory, relative4);
|
|
17024
|
+
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
17025
|
+
if (read !== void 0) return read;
|
|
17026
|
+
}
|
|
17027
|
+
for (const path of await listUniqueErrorFallbackPaths([artifactsDir, runDirectory])) {
|
|
17028
|
+
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
17029
|
+
if (read !== void 0) return read;
|
|
17030
|
+
}
|
|
17031
|
+
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
17032
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname7(runDirectory)])) {
|
|
17033
|
+
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
17034
|
+
if (read === void 0) continue;
|
|
17035
|
+
if (read.status === "present") {
|
|
17036
|
+
if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
|
|
17037
|
+
return read;
|
|
17038
|
+
}
|
|
17039
|
+
}
|
|
17040
|
+
return { status: "absent" };
|
|
17041
|
+
}
|
|
17042
|
+
function isUniqueErrorFallbackName(name) {
|
|
17043
|
+
return UNIQUE_ERROR_FALLBACK_NAME.test(basename4(name));
|
|
17044
|
+
}
|
|
17045
|
+
var RUN_TERMINAL_ARTIFACT_FILES, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_NAME;
|
|
17046
|
+
var init_run_terminal_artifacts = __esm({
|
|
17047
|
+
"src/run-terminal-artifacts.ts"() {
|
|
17048
|
+
"use strict";
|
|
17049
|
+
init_role_run_placement();
|
|
17050
|
+
RUN_TERMINAL_ARTIFACT_FILES = [
|
|
17051
|
+
"report.json",
|
|
17052
|
+
"error.json",
|
|
17053
|
+
"audit-incomplete.json"
|
|
17054
|
+
];
|
|
17055
|
+
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
|
|
17056
|
+
"artifacts/error.settlement.json",
|
|
17057
|
+
"error.settlement.json"
|
|
17058
|
+
];
|
|
17059
|
+
UNIQUE_ERROR_FALLBACK_NAME = /^error\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.json$/i;
|
|
17060
|
+
}
|
|
17061
|
+
});
|
|
17062
|
+
|
|
16904
17063
|
// src/gatekeeper-role.ts
|
|
16905
17064
|
var init_gatekeeper_role = __esm({
|
|
16906
17065
|
"src/gatekeeper-role.ts"() {
|
|
@@ -16909,6 +17068,7 @@ var init_gatekeeper_role = __esm({
|
|
|
16909
17068
|
init_submission_errors();
|
|
16910
17069
|
init_inspector_contracts();
|
|
16911
17070
|
init_gatekeeper_output();
|
|
17071
|
+
init_run_terminal_artifacts();
|
|
16912
17072
|
init_submission_errors();
|
|
16913
17073
|
}
|
|
16914
17074
|
});
|
|
@@ -16927,8 +17087,8 @@ var init_compliance_transport = __esm({
|
|
|
16927
17087
|
|
|
16928
17088
|
// src/role-run-relocation.ts
|
|
16929
17089
|
import { existsSync as existsSync5 } from "node:fs";
|
|
16930
|
-
import { readdir as
|
|
16931
|
-
import { join as
|
|
17090
|
+
import { readdir as readdir3, readFile as readFile6, writeFile as writeFile2 } from "node:fs/promises";
|
|
17091
|
+
import { join as join12, sep as sep2 } from "node:path";
|
|
16932
17092
|
function isEnoent2(error) {
|
|
16933
17093
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
16934
17094
|
}
|
|
@@ -17017,7 +17177,7 @@ function rewriteSummonsMaterials(value, rewrites) {
|
|
|
17017
17177
|
}
|
|
17018
17178
|
async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
17019
17179
|
if (!existsSync5(path)) return;
|
|
17020
|
-
const page = JSON.parse(await
|
|
17180
|
+
const page = JSON.parse(await readFile6(path, "utf8"));
|
|
17021
17181
|
if (!isPlainObject(page)) return;
|
|
17022
17182
|
rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
|
|
17023
17183
|
await writeFile2(path, `${JSON.stringify(page, null, 2)}
|
|
@@ -17025,7 +17185,7 @@ async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
|
17025
17185
|
}
|
|
17026
17186
|
async function rewriteOfficerPointerFile(path, rewrites) {
|
|
17027
17187
|
if (!existsSync5(path)) return;
|
|
17028
|
-
const page = JSON.parse(await
|
|
17188
|
+
const page = JSON.parse(await readFile6(path, "utf8"));
|
|
17029
17189
|
if (!isPlainObject(page)) return;
|
|
17030
17190
|
if (page.kind !== "direct-officer-run-pointer") return;
|
|
17031
17191
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
@@ -17038,7 +17198,7 @@ async function rewriteOfficerPointerFile(path, rewrites) {
|
|
|
17038
17198
|
}
|
|
17039
17199
|
async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
17040
17200
|
if (!existsSync5(path)) return;
|
|
17041
|
-
const raw = await
|
|
17201
|
+
const raw = await readFile6(path, "utf8");
|
|
17042
17202
|
if (raw.length === 0) return;
|
|
17043
17203
|
const endsWithNewline = raw.endsWith("\n");
|
|
17044
17204
|
const lines = raw.split("\n");
|
|
@@ -17089,7 +17249,7 @@ async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
|
17089
17249
|
}
|
|
17090
17250
|
async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
17091
17251
|
if (!existsSync5(path)) return;
|
|
17092
|
-
const raw = await
|
|
17252
|
+
const raw = await readFile6(path, "utf8");
|
|
17093
17253
|
if (raw.length === 0) return;
|
|
17094
17254
|
const endsWithNewline = raw.endsWith("\n");
|
|
17095
17255
|
const lines = raw.split("\n");
|
|
@@ -17148,17 +17308,17 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
|
17148
17308
|
);
|
|
17149
17309
|
}
|
|
17150
17310
|
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
17151
|
-
const sessionRoot =
|
|
17311
|
+
const sessionRoot = join12(pagesDirectory, "session");
|
|
17152
17312
|
async function walk(directory) {
|
|
17153
17313
|
let entries;
|
|
17154
17314
|
try {
|
|
17155
|
-
entries = await
|
|
17315
|
+
entries = await readdir3(directory, { withFileTypes: true });
|
|
17156
17316
|
} catch (error) {
|
|
17157
17317
|
if (isEnoent2(error)) return;
|
|
17158
17318
|
throw error;
|
|
17159
17319
|
}
|
|
17160
17320
|
for (const entry of entries) {
|
|
17161
|
-
const path =
|
|
17321
|
+
const path = join12(directory, entry.name);
|
|
17162
17322
|
if (entry.isDirectory()) {
|
|
17163
17323
|
await walk(path);
|
|
17164
17324
|
continue;
|
|
@@ -17180,9 +17340,9 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
17180
17340
|
async function rewriteRoleRunDurablePages(input) {
|
|
17181
17341
|
const { pagesDirectory } = input;
|
|
17182
17342
|
const rewrites = collectRewrites(input);
|
|
17183
|
-
const admittedPath =
|
|
17343
|
+
const admittedPath = join12(pagesDirectory, "admitted-request.json");
|
|
17184
17344
|
if (existsSync5(admittedPath)) {
|
|
17185
|
-
const page = JSON.parse(await
|
|
17345
|
+
const page = JSON.parse(await readFile6(admittedPath, "utf8"));
|
|
17186
17346
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17187
17347
|
page,
|
|
17188
17348
|
ADMITTED_PAGE_FIELDS,
|
|
@@ -17210,9 +17370,9 @@ async function rewriteRoleRunDurablePages(input) {
|
|
|
17210
17370
|
await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
|
|
17211
17371
|
`, "utf8");
|
|
17212
17372
|
}
|
|
17213
|
-
const invocationPath =
|
|
17373
|
+
const invocationPath = join12(pagesDirectory, "invocation.json");
|
|
17214
17374
|
if (existsSync5(invocationPath)) {
|
|
17215
|
-
const page = JSON.parse(await
|
|
17375
|
+
const page = JSON.parse(await readFile6(invocationPath, "utf8"));
|
|
17216
17376
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17217
17377
|
page,
|
|
17218
17378
|
INVOCATION_PAGE_FIELDS,
|
|
@@ -17225,9 +17385,9 @@ async function rewriteRoleRunDurablePages(input) {
|
|
|
17225
17385
|
"utf8"
|
|
17226
17386
|
);
|
|
17227
17387
|
}
|
|
17228
|
-
const statePath =
|
|
17388
|
+
const statePath = join12(pagesDirectory, "run-state.json");
|
|
17229
17389
|
if (existsSync5(statePath)) {
|
|
17230
|
-
const page = JSON.parse(await
|
|
17390
|
+
const page = JSON.parse(await readFile6(statePath, "utf8"));
|
|
17231
17391
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
17232
17392
|
page,
|
|
17233
17393
|
RUN_STATE_PAGE_FIELDS,
|
|
@@ -17391,15 +17551,15 @@ var init_terminating_tools = __esm({
|
|
|
17391
17551
|
});
|
|
17392
17552
|
|
|
17393
17553
|
// src/doctor-evidence.ts
|
|
17394
|
-
import { readdir as
|
|
17395
|
-
import { dirname as
|
|
17554
|
+
import { readdir as readdir4, readFile as readFile7, realpath as realpath2, stat } from "node:fs/promises";
|
|
17555
|
+
import { dirname as dirname8, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
|
|
17396
17556
|
function record2(value) {
|
|
17397
17557
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17398
17558
|
}
|
|
17399
17559
|
async function discoverCaseFiles(root) {
|
|
17400
17560
|
const found = [];
|
|
17401
17561
|
async function walk(dir, depth) {
|
|
17402
|
-
for (const item of await
|
|
17562
|
+
for (const item of await readdir4(dir, { withFileTypes: true })) {
|
|
17403
17563
|
const path = resolve4(dir, item.name);
|
|
17404
17564
|
if (item.isDirectory()) {
|
|
17405
17565
|
await walk(path, depth + 1);
|
|
@@ -17419,7 +17579,7 @@ function accumulate(metric, value, source) {
|
|
|
17419
17579
|
function timestamp(row) {
|
|
17420
17580
|
return typeof row.timestamp === "string" && Number.isFinite(Date.parse(row.timestamp)) ? row.timestamp : void 0;
|
|
17421
17581
|
}
|
|
17422
|
-
function
|
|
17582
|
+
function isMissingPathError3(error) {
|
|
17423
17583
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
17424
17584
|
}
|
|
17425
17585
|
async function stableRunsIdentity(root) {
|
|
@@ -17429,9 +17589,9 @@ async function stableRunsIdentity(root) {
|
|
|
17429
17589
|
const git2 = await stat(resolve4(cursor, ".git"));
|
|
17430
17590
|
if (git2.isDirectory() || git2.isFile()) return relative2(cursor, root).split(sep3).join("/");
|
|
17431
17591
|
} catch (error) {
|
|
17432
|
-
if (!
|
|
17592
|
+
if (!isMissingPathError3(error)) throw error;
|
|
17433
17593
|
}
|
|
17434
|
-
const parent =
|
|
17594
|
+
const parent = dirname8(cursor);
|
|
17435
17595
|
if (parent === cursor) return root;
|
|
17436
17596
|
cursor = parent;
|
|
17437
17597
|
}
|
|
@@ -17507,7 +17667,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
17507
17667
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
17508
17668
|
for (const path of await discoverCaseFiles(root)) {
|
|
17509
17669
|
const id = relative2(root, path).split(sep3).join("/");
|
|
17510
|
-
const bytes = await
|
|
17670
|
+
const bytes = await readFile7(path);
|
|
17511
17671
|
const content = bytes.toString("utf8");
|
|
17512
17672
|
const kind = id.endsWith(".jsonl") ? "session" : "stderr";
|
|
17513
17673
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -17520,7 +17680,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
17520
17680
|
accumulate(calls, result.calls, id);
|
|
17521
17681
|
accumulate(tokens, result.tokens, id);
|
|
17522
17682
|
}
|
|
17523
|
-
const runDirs = (await
|
|
17683
|
+
const runDirs = (await readdir4(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
|
|
17524
17684
|
const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
|
|
17525
17685
|
const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
|
|
17526
17686
|
const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
|
|
@@ -17537,7 +17697,7 @@ var init_doctor_evidence = __esm({
|
|
|
17537
17697
|
|
|
17538
17698
|
// src/collector-config.ts
|
|
17539
17699
|
import { createHash as createHash3 } from "node:crypto";
|
|
17540
|
-
import { readFile as
|
|
17700
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
17541
17701
|
function fail3(message, cause) {
|
|
17542
17702
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
17543
17703
|
}
|
|
@@ -17580,7 +17740,7 @@ function emptyCollectorManifest() {
|
|
|
17580
17740
|
async function loadCollectorManifest(path) {
|
|
17581
17741
|
let bytes;
|
|
17582
17742
|
try {
|
|
17583
|
-
bytes = await
|
|
17743
|
+
bytes = await readFile8(path);
|
|
17584
17744
|
} catch (error) {
|
|
17585
17745
|
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
17586
17746
|
}
|
|
@@ -17615,7 +17775,7 @@ var init_collector_config = __esm({
|
|
|
17615
17775
|
|
|
17616
17776
|
// src/collector-github.ts
|
|
17617
17777
|
import { spawn as spawn2 } from "node:child_process";
|
|
17618
|
-
function
|
|
17778
|
+
function isRecord4(value) {
|
|
17619
17779
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17620
17780
|
}
|
|
17621
17781
|
function parseJson(text, label) {
|
|
@@ -17631,7 +17791,7 @@ function parsePullRequestNumberList(raw, label) {
|
|
|
17631
17791
|
}
|
|
17632
17792
|
const numbers = [];
|
|
17633
17793
|
for (const item of raw) {
|
|
17634
|
-
if (!
|
|
17794
|
+
if (!isRecord4(item)) {
|
|
17635
17795
|
throw new Error(`GitHub ${label} payload contains a non-object pull request entry`);
|
|
17636
17796
|
}
|
|
17637
17797
|
try {
|
|
@@ -17971,7 +18131,7 @@ var init_git_object_id = __esm({
|
|
|
17971
18131
|
|
|
17972
18132
|
// src/merger-git-state.ts
|
|
17973
18133
|
import { execFile as execFile2 } from "node:child_process";
|
|
17974
|
-
import { access as access2, readFile as
|
|
18134
|
+
import { access as access2, readFile as readFile9 } from "node:fs/promises";
|
|
17975
18135
|
import { constants as fsConstants } from "node:fs";
|
|
17976
18136
|
import { isAbsolute as isAbsolute4, resolve as resolve5 } from "node:path";
|
|
17977
18137
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -18041,7 +18201,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
18041
18201
|
const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve5(repositoryRoot, mergeHeadReported);
|
|
18042
18202
|
let sourceObjectId = "";
|
|
18043
18203
|
if (await pathExists(mergeHeadPath)) {
|
|
18044
|
-
const raw = exactUtf8(await
|
|
18204
|
+
const raw = exactUtf8(await readFile9(mergeHeadPath), "Git MERGE_HEAD");
|
|
18045
18205
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
18046
18206
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
18047
18207
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -18093,10 +18253,10 @@ var init_uuidv7 = __esm({
|
|
|
18093
18253
|
});
|
|
18094
18254
|
|
|
18095
18255
|
// src/typed-provider-http.ts
|
|
18096
|
-
import { readFile as
|
|
18097
|
-
import { join as
|
|
18256
|
+
import { readFile as readFile10, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
18257
|
+
import { join as join13 } from "node:path";
|
|
18098
18258
|
function typedProviderHttpPath(runDirectory) {
|
|
18099
|
-
return
|
|
18259
|
+
return join13(runDirectory, TYPED_HTTP_FILE);
|
|
18100
18260
|
}
|
|
18101
18261
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
18102
18262
|
try {
|
|
@@ -18111,7 +18271,7 @@ async function clearTypedProviderHttpObservation(runDirectory) {
|
|
|
18111
18271
|
async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
18112
18272
|
let text;
|
|
18113
18273
|
try {
|
|
18114
|
-
text = await
|
|
18274
|
+
text = await readFile10(typedProviderHttpPath(runDirectory), "utf8");
|
|
18115
18275
|
} catch (error) {
|
|
18116
18276
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
18117
18277
|
return void 0;
|
|
@@ -18140,8 +18300,8 @@ var init_typed_provider_http = __esm({
|
|
|
18140
18300
|
});
|
|
18141
18301
|
|
|
18142
18302
|
// src/public-cli/run-lifecycle.ts
|
|
18143
|
-
import { chmod, lstat as lstat2, open, readdir as
|
|
18144
|
-
import { basename as
|
|
18303
|
+
import { chmod, lstat as lstat2, open, readdir as readdir5, readFile as readFile11, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
|
|
18304
|
+
import { basename as basename5, join as join14 } from "node:path";
|
|
18145
18305
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
18146
18306
|
const lines = message !== void 0 ? [message] : [];
|
|
18147
18307
|
return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
|
|
@@ -18180,7 +18340,7 @@ function renderResumeCommand(runId) {
|
|
|
18180
18340
|
async function writeRoleRunState(runDirectory, record4) {
|
|
18181
18341
|
const payload = { ...record4, runDirectory };
|
|
18182
18342
|
await writeFile4(
|
|
18183
|
-
|
|
18343
|
+
join14(runDirectory, RUN_STATE_FILE),
|
|
18184
18344
|
`${JSON.stringify(payload, null, 2)}
|
|
18185
18345
|
`,
|
|
18186
18346
|
"utf8"
|
|
@@ -18230,7 +18390,7 @@ function parseCurrentCourtState(raw) {
|
|
|
18230
18390
|
async function readRoleRunStateDisk(runDirectory) {
|
|
18231
18391
|
let raw;
|
|
18232
18392
|
try {
|
|
18233
|
-
raw = JSON.parse(await
|
|
18393
|
+
raw = JSON.parse(await readFile11(join14(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
18234
18394
|
} catch (error) {
|
|
18235
18395
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
18236
18396
|
throw error;
|
|
@@ -18298,7 +18458,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
18298
18458
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
18299
18459
|
};
|
|
18300
18460
|
await writeFile4(
|
|
18301
|
-
|
|
18461
|
+
join14(runDirectory, RUN_STATE_FILE),
|
|
18302
18462
|
`${JSON.stringify(payload, null, 2)}
|
|
18303
18463
|
`,
|
|
18304
18464
|
"utf8"
|
|
@@ -18465,7 +18625,7 @@ function isProcessAlive(pid) {
|
|
|
18465
18625
|
async function autopsyWriterLock(lockPath) {
|
|
18466
18626
|
let content;
|
|
18467
18627
|
try {
|
|
18468
|
-
content = await
|
|
18628
|
+
content = await readFile11(lockPath, "utf8");
|
|
18469
18629
|
} catch (error) {
|
|
18470
18630
|
if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
|
|
18471
18631
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -18524,7 +18684,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
18524
18684
|
},
|
|
18525
18685
|
relocate(nextRunDirectory) {
|
|
18526
18686
|
currentRunDirectory = nextRunDirectory;
|
|
18527
|
-
currentLockPath =
|
|
18687
|
+
currentLockPath = join14(nextRunDirectory, WRITER_LOCK_FILE);
|
|
18528
18688
|
},
|
|
18529
18689
|
async release() {
|
|
18530
18690
|
if (released) return;
|
|
@@ -18563,10 +18723,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
18563
18723
|
};
|
|
18564
18724
|
const reportReadFailure = (error) => {
|
|
18565
18725
|
reportDiagnostic(
|
|
18566
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
18726
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join14(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
18567
18727
|
);
|
|
18568
18728
|
};
|
|
18569
|
-
const lockPath =
|
|
18729
|
+
const lockPath = join14(runDirectory, WRITER_LOCK_FILE);
|
|
18570
18730
|
let lastAutopsy = { verdict: "absent" };
|
|
18571
18731
|
let lastReclaimFailure;
|
|
18572
18732
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -18621,10 +18781,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
18621
18781
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
18622
18782
|
if (runId.trim() === "") return void 0;
|
|
18623
18783
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
18624
|
-
const booksRoot =
|
|
18784
|
+
const booksRoot = join14(ledgerHome, "books");
|
|
18625
18785
|
let bookKeys;
|
|
18626
18786
|
try {
|
|
18627
|
-
bookKeys = await
|
|
18787
|
+
bookKeys = await readdir5(booksRoot);
|
|
18628
18788
|
} catch (error) {
|
|
18629
18789
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
18630
18790
|
throw error;
|
|
@@ -18641,7 +18801,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
18641
18801
|
throw error;
|
|
18642
18802
|
}
|
|
18643
18803
|
for (const runDirectory of runDirectories) {
|
|
18644
|
-
const entry =
|
|
18804
|
+
const entry = basename5(runDirectory);
|
|
18645
18805
|
if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
|
|
18646
18806
|
matches.push(runDirectory);
|
|
18647
18807
|
}
|
|
@@ -18662,7 +18822,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
18662
18822
|
let raw;
|
|
18663
18823
|
try {
|
|
18664
18824
|
raw = JSON.parse(
|
|
18665
|
-
await
|
|
18825
|
+
await readFile11(join14(runDirectory, "admitted-request.json"), "utf8")
|
|
18666
18826
|
);
|
|
18667
18827
|
} catch (error) {
|
|
18668
18828
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -18683,7 +18843,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
18683
18843
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
18684
18844
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
18685
18845
|
if (disk === void 0) return false;
|
|
18686
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
18846
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join14(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
18687
18847
|
try {
|
|
18688
18848
|
const stat2 = await lstat2(sessionFile);
|
|
18689
18849
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -18708,7 +18868,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
18708
18868
|
const suffix = `@${input.role}`;
|
|
18709
18869
|
let best;
|
|
18710
18870
|
for (const runDirectory of runDirectories) {
|
|
18711
|
-
const entry =
|
|
18871
|
+
const entry = basename5(runDirectory);
|
|
18712
18872
|
if (!entry.endsWith(suffix)) continue;
|
|
18713
18873
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
18714
18874
|
if (runId.length === 0) continue;
|
|
@@ -18831,7 +18991,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
18831
18991
|
let sourceRun;
|
|
18832
18992
|
try {
|
|
18833
18993
|
const raw = JSON.parse(
|
|
18834
|
-
await
|
|
18994
|
+
await readFile11(run.admittedRequestPath, "utf8")
|
|
18835
18995
|
);
|
|
18836
18996
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
18837
18997
|
const record4 = raw;
|
|
@@ -18949,7 +19109,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
18949
19109
|
let model;
|
|
18950
19110
|
try {
|
|
18951
19111
|
const invocationRaw = JSON.parse(
|
|
18952
|
-
await
|
|
19112
|
+
await readFile11(join14(run.runDirectory, "invocation.json"), "utf8")
|
|
18953
19113
|
);
|
|
18954
19114
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
18955
19115
|
const rec = invocationRaw;
|
|
@@ -19418,7 +19578,7 @@ __export(notary_source_run_exports, {
|
|
|
19418
19578
|
loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
|
|
19419
19579
|
resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
|
|
19420
19580
|
});
|
|
19421
|
-
import { dirname as
|
|
19581
|
+
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join15, resolve as resolve6, basename as basename6 } from "node:path";
|
|
19422
19582
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
19423
19583
|
function parseRunDirectoryName(name) {
|
|
19424
19584
|
const match = RUN_DIR_NAME.exec(name);
|
|
@@ -19449,10 +19609,10 @@ async function requireRunDirectory(candidate, display) {
|
|
|
19449
19609
|
`notary --source-run must be a run directory: ${display}`
|
|
19450
19610
|
);
|
|
19451
19611
|
}
|
|
19452
|
-
const identity = parseRunDirectoryName(
|
|
19612
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
19453
19613
|
if (identity === void 0) {
|
|
19454
19614
|
throw new NotarySourceRunError(
|
|
19455
|
-
`notary --source-run must be named <runId>@<role>: ${
|
|
19615
|
+
`notary --source-run must be named <runId>@<role>: ${basename6(real)}`
|
|
19456
19616
|
);
|
|
19457
19617
|
}
|
|
19458
19618
|
return real;
|
|
@@ -19464,20 +19624,20 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
19464
19624
|
}
|
|
19465
19625
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
19466
19626
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
19467
|
-
const bookRunsRoot =
|
|
19627
|
+
const bookRunsRoot = join15(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
19468
19628
|
let candidate;
|
|
19469
19629
|
const bare = parseRunDirectoryName(raw);
|
|
19470
19630
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
19471
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
19631
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
19472
19632
|
} else {
|
|
19473
19633
|
candidate = isAbsolute6(raw) ? raw : resolve6(options.projectRoot, raw);
|
|
19474
19634
|
}
|
|
19475
19635
|
const real = await requireRunDirectory(candidate, raw);
|
|
19476
|
-
const identity = parseRunDirectoryName(
|
|
19636
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
19477
19637
|
const bookIdentity = physicalPathIdentity(activationBookDirectory(ledgerHome, bookKey));
|
|
19478
|
-
const parentIdentity = physicalPathIdentity(
|
|
19479
|
-
const subjectBookIdentity = physicalPathIdentity(
|
|
19480
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(
|
|
19638
|
+
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
19639
|
+
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
19640
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
19481
19641
|
throw new NotarySourceRunError(
|
|
19482
19642
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
19483
19643
|
);
|
|
@@ -19511,7 +19671,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
19511
19671
|
}
|
|
19512
19672
|
async function loadNotarySourceRunLocator(path) {
|
|
19513
19673
|
const real = await requireRunDirectory(path, path);
|
|
19514
|
-
const identity = parseRunDirectoryName(
|
|
19674
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
19515
19675
|
const runState = await readRoleRunIdentity(real);
|
|
19516
19676
|
if (runState === void 0) {
|
|
19517
19677
|
throw new NotarySourceRunError(
|
|
@@ -20720,14 +20880,14 @@ import { existsSync as existsSync6 } from "node:fs";
|
|
|
20720
20880
|
import {
|
|
20721
20881
|
lstat as lstat4,
|
|
20722
20882
|
mkdtemp,
|
|
20723
|
-
readFile as
|
|
20883
|
+
readFile as readFile12,
|
|
20724
20884
|
realpath as realpath4,
|
|
20725
20885
|
rename,
|
|
20726
20886
|
rm,
|
|
20727
20887
|
writeFile as writeFile5
|
|
20728
20888
|
} from "node:fs/promises";
|
|
20729
20889
|
import { tmpdir } from "node:os";
|
|
20730
|
-
import { basename as
|
|
20890
|
+
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join16, resolve as resolve7, sep as sep4 } from "node:path";
|
|
20731
20891
|
function issueAdmissionPlacement(authority, request) {
|
|
20732
20892
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
20733
20893
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -20781,15 +20941,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
20781
20941
|
...effectiveModelLedgerFields(effectiveModel)
|
|
20782
20942
|
};
|
|
20783
20943
|
await writeFile5(
|
|
20784
|
-
|
|
20944
|
+
join16(source.runDirectory, "invocation.json"),
|
|
20785
20945
|
`${JSON.stringify(identity, null, 2)}
|
|
20786
20946
|
`,
|
|
20787
20947
|
"utf8"
|
|
20788
20948
|
);
|
|
20789
20949
|
}
|
|
20790
20950
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
20791
|
-
const ledgerPath =
|
|
20792
|
-
const current = JSON.parse(await
|
|
20951
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
20952
|
+
const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
|
|
20793
20953
|
const next = { ...current };
|
|
20794
20954
|
if (model !== void 0) {
|
|
20795
20955
|
next.provider = model.provider;
|
|
@@ -20821,8 +20981,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
20821
20981
|
);
|
|
20822
20982
|
}
|
|
20823
20983
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
20824
|
-
const ledgerPath =
|
|
20825
|
-
const current = JSON.parse(await
|
|
20984
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
20985
|
+
const current = JSON.parse(await readFile12(ledgerPath, "utf8"));
|
|
20826
20986
|
await writeFile5(
|
|
20827
20987
|
ledgerPath,
|
|
20828
20988
|
`${JSON.stringify({
|
|
@@ -20838,7 +20998,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
20838
20998
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
20839
20999
|
}
|
|
20840
21000
|
const admittedPath = admitted.admittedRequestPath;
|
|
20841
|
-
const current = JSON.parse(await
|
|
21001
|
+
const current = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
20842
21002
|
if (typeof current.sourceRunPath === "string") {
|
|
20843
21003
|
if (current.sourceRunPath === sourceRunPath) return;
|
|
20844
21004
|
throw new Error(
|
|
@@ -20864,7 +21024,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
20864
21024
|
}
|
|
20865
21025
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
20866
21026
|
const current = JSON.parse(
|
|
20867
|
-
await
|
|
21027
|
+
await readFile12(admitted.admittedRequestPath, "utf8")
|
|
20868
21028
|
);
|
|
20869
21029
|
const prior = [
|
|
20870
21030
|
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
@@ -20912,7 +21072,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
20912
21072
|
}
|
|
20913
21073
|
const frozen = Object.freeze([...projected]);
|
|
20914
21074
|
const admittedPath = admitted.admittedRequestPath;
|
|
20915
|
-
const current = JSON.parse(await
|
|
21075
|
+
const current = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
20916
21076
|
await writeFile5(
|
|
20917
21077
|
admittedPath,
|
|
20918
21078
|
`${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
|
|
@@ -20934,7 +21094,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20934
21094
|
runId: admitted.runId,
|
|
20935
21095
|
role: admitted.role
|
|
20936
21096
|
});
|
|
20937
|
-
ensureRoleRunDirectory(ledgerHome,
|
|
21097
|
+
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
20938
21098
|
await rename(oldRunDirectory, target.runDirectory);
|
|
20939
21099
|
heldLease?.relocate(target.runDirectory);
|
|
20940
21100
|
const admittedRecord = admitted;
|
|
@@ -20972,9 +21132,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20972
21132
|
ticketNumber,
|
|
20973
21133
|
"bindTicketNumberOnRunDirectory"
|
|
20974
21134
|
);
|
|
20975
|
-
const admittedPath =
|
|
20976
|
-
const invocationPath =
|
|
20977
|
-
const admitted = JSON.parse(await
|
|
21135
|
+
const admittedPath = join16(runDirectory, "admitted-request.json");
|
|
21136
|
+
const invocationPath = join16(runDirectory, "invocation.json");
|
|
21137
|
+
const admitted = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
20978
21138
|
const existing = admitted.ticketNumber;
|
|
20979
21139
|
if (typeof existing === "number") {
|
|
20980
21140
|
if (existing === ticketNumber) return;
|
|
@@ -20984,7 +21144,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20984
21144
|
}
|
|
20985
21145
|
if (existsSync6(invocationPath)) {
|
|
20986
21146
|
const invocation = JSON.parse(
|
|
20987
|
-
await
|
|
21147
|
+
await readFile12(invocationPath, "utf8")
|
|
20988
21148
|
);
|
|
20989
21149
|
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
20990
21150
|
throw new Error(
|
|
@@ -21009,7 +21169,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
21009
21169
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
21010
21170
|
const rolePackageRoot = packageRoot2;
|
|
21011
21171
|
const raw = JSON.parse(
|
|
21012
|
-
await
|
|
21172
|
+
await readFile12(join16(rolePackageRoot, "package.json"), "utf8")
|
|
21013
21173
|
);
|
|
21014
21174
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
21015
21175
|
throw new Error(
|
|
@@ -21294,7 +21454,7 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
21294
21454
|
);
|
|
21295
21455
|
}
|
|
21296
21456
|
try {
|
|
21297
|
-
return { absolute, bytes: await
|
|
21457
|
+
return { absolute, bytes: await readFile12(absolute) };
|
|
21298
21458
|
} catch (error) {
|
|
21299
21459
|
throw new CliUsageError(
|
|
21300
21460
|
`attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -21307,13 +21467,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
21307
21467
|
}
|
|
21308
21468
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
21309
21469
|
if (attachmentPaths.length === 0) return await use([]);
|
|
21310
|
-
const stagingDirectory = await mkdtemp(
|
|
21470
|
+
const stagingDirectory = await mkdtemp(join16(tmpdir(), "ak-role-attachments-"));
|
|
21311
21471
|
const prepared = [];
|
|
21312
21472
|
let result;
|
|
21313
21473
|
try {
|
|
21314
21474
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
21315
21475
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
21316
|
-
const snapshotPath =
|
|
21476
|
+
const snapshotPath = join16(stagingDirectory, String(index).padStart(6, "0"));
|
|
21317
21477
|
await writeFile5(snapshotPath, bytes);
|
|
21318
21478
|
prepared.push({ absolute, snapshotPath });
|
|
21319
21479
|
}
|
|
@@ -21334,9 +21494,9 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
21334
21494
|
return result;
|
|
21335
21495
|
}
|
|
21336
21496
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
21337
|
-
const frozenPath =
|
|
21497
|
+
const frozenPath = join16(
|
|
21338
21498
|
destinationDir,
|
|
21339
|
-
`${String(index).padStart(2, "0")}-${
|
|
21499
|
+
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
21340
21500
|
);
|
|
21341
21501
|
await writeFile5(frozenPath, bytes);
|
|
21342
21502
|
return {
|
|
@@ -21350,7 +21510,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
21350
21510
|
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
21351
21511
|
return freezeAttachmentBytes(
|
|
21352
21512
|
prepared.absolute,
|
|
21353
|
-
await
|
|
21513
|
+
await readFile12(prepared.snapshotPath),
|
|
21354
21514
|
destinationDir,
|
|
21355
21515
|
index
|
|
21356
21516
|
);
|
|
@@ -21377,14 +21537,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
21377
21537
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
21378
21538
|
if (attachmentPaths.length === 0) return [];
|
|
21379
21539
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
21380
|
-
const attachmentsDirectory =
|
|
21540
|
+
const attachmentsDirectory = join16(runDirectory, "attachments", summonsKey);
|
|
21381
21541
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21382
21542
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
21383
21543
|
}
|
|
21384
21544
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
21385
21545
|
if (prepared.length === 0) return [];
|
|
21386
21546
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
21387
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
21547
|
+
const attachmentsDirectory = summonsKey === void 0 ? join16(runDirectory, "attachments") : join16(runDirectory, "attachments", summonsKey);
|
|
21388
21548
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21389
21549
|
const attachments = [];
|
|
21390
21550
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -21446,7 +21606,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
21446
21606
|
})),
|
|
21447
21607
|
...ticketFields
|
|
21448
21608
|
};
|
|
21449
|
-
const admittedRequestPath =
|
|
21609
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21450
21610
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21451
21611
|
sessionDirectory,
|
|
21452
21612
|
sessionFile
|
|
@@ -21555,7 +21715,7 @@ async function admitCountersignInvocation(options) {
|
|
|
21555
21715
|
mediaKind: a.mediaKind
|
|
21556
21716
|
}))
|
|
21557
21717
|
};
|
|
21558
|
-
const admittedRequestPath =
|
|
21718
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21559
21719
|
if (options.deferPersistence !== true) {
|
|
21560
21720
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21561
21721
|
sessionDirectory,
|
|
@@ -21606,7 +21766,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
21606
21766
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
21607
21767
|
try {
|
|
21608
21768
|
const raw = JSON.parse(
|
|
21609
|
-
await
|
|
21769
|
+
await readFile12(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
21610
21770
|
);
|
|
21611
21771
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
21612
21772
|
const record4 = raw;
|
|
@@ -21661,7 +21821,7 @@ async function admitCoderInvocation(options) {
|
|
|
21661
21821
|
home: options.home
|
|
21662
21822
|
});
|
|
21663
21823
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
21664
|
-
const taskPath =
|
|
21824
|
+
const taskPath = join16(runDirectory, "task.md");
|
|
21665
21825
|
await writeFile5(taskPath, instruction, "utf8");
|
|
21666
21826
|
const admitted = {
|
|
21667
21827
|
role: "coder",
|
|
@@ -21682,7 +21842,7 @@ async function admitCoderInvocation(options) {
|
|
|
21682
21842
|
mediaKind: a.mediaKind
|
|
21683
21843
|
}))
|
|
21684
21844
|
};
|
|
21685
|
-
const admittedRequestPath =
|
|
21845
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21686
21846
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21687
21847
|
sessionDirectory,
|
|
21688
21848
|
sessionFile
|
|
@@ -21732,7 +21892,7 @@ async function admitFixerInvocation(options) {
|
|
|
21732
21892
|
if (options.prerequisitesPath !== void 0) {
|
|
21733
21893
|
const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve7(options.prerequisitesPath);
|
|
21734
21894
|
try {
|
|
21735
|
-
prerequisitesSource = await
|
|
21895
|
+
prerequisitesSource = await readFile12(absolutePrereq, "utf8");
|
|
21736
21896
|
} catch (error) {
|
|
21737
21897
|
throw new CliUsageError(
|
|
21738
21898
|
`fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
|
|
@@ -21768,7 +21928,7 @@ async function admitFixerInvocation(options) {
|
|
|
21768
21928
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
21769
21929
|
let prerequisitesPath;
|
|
21770
21930
|
if (prerequisitesSource !== void 0) {
|
|
21771
|
-
prerequisitesPath =
|
|
21931
|
+
prerequisitesPath = join16(runDirectory, "prerequisites.json");
|
|
21772
21932
|
await writeFile5(
|
|
21773
21933
|
prerequisitesPath,
|
|
21774
21934
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -21776,7 +21936,7 @@ async function admitFixerInvocation(options) {
|
|
|
21776
21936
|
"utf8"
|
|
21777
21937
|
);
|
|
21778
21938
|
}
|
|
21779
|
-
const packetPath =
|
|
21939
|
+
const packetPath = join16(runDirectory, "fix-packet.md");
|
|
21780
21940
|
await writeFile5(packetPath, instruction, "utf8");
|
|
21781
21941
|
const admitted = {
|
|
21782
21942
|
role: "fixer",
|
|
@@ -21802,7 +21962,7 @@ async function admitFixerInvocation(options) {
|
|
|
21802
21962
|
mediaKind: a.mediaKind
|
|
21803
21963
|
}))
|
|
21804
21964
|
};
|
|
21805
|
-
const admittedRequestPath =
|
|
21965
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21806
21966
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21807
21967
|
sessionDirectory,
|
|
21808
21968
|
sessionFile
|
|
@@ -22022,7 +22182,7 @@ async function admitCollectorInvocation(options) {
|
|
|
22022
22182
|
const prNumber = target.kind === "bound" ? target.prNumber : void 0;
|
|
22023
22183
|
let requestManifestPath;
|
|
22024
22184
|
if (manifestCanonicalJson !== void 0) {
|
|
22025
|
-
requestManifestPath =
|
|
22185
|
+
requestManifestPath = join16(runDirectory, "request-manifest.json");
|
|
22026
22186
|
await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
22027
22187
|
}
|
|
22028
22188
|
const admitted = {
|
|
@@ -22048,7 +22208,7 @@ async function admitCollectorInvocation(options) {
|
|
|
22048
22208
|
mediaKind: a.mediaKind
|
|
22049
22209
|
}))
|
|
22050
22210
|
};
|
|
22051
|
-
const admittedRequestPath =
|
|
22211
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22052
22212
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22053
22213
|
sessionDirectory,
|
|
22054
22214
|
sessionFile
|
|
@@ -22146,7 +22306,7 @@ function parseDoctorArgv(args) {
|
|
|
22146
22306
|
}
|
|
22147
22307
|
async function resolveDoctorCaseRunsPath(options) {
|
|
22148
22308
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
22149
|
-
const defaultRuns =
|
|
22309
|
+
const defaultRuns = join16(
|
|
22150
22310
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
22151
22311
|
String(options.issueNumber),
|
|
22152
22312
|
"runs"
|
|
@@ -22277,7 +22437,7 @@ async function admitDoctorInvocation(options) {
|
|
|
22277
22437
|
mediaKind: a.mediaKind
|
|
22278
22438
|
}))
|
|
22279
22439
|
};
|
|
22280
|
-
const admittedRequestPath =
|
|
22440
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22281
22441
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22282
22442
|
sessionDirectory,
|
|
22283
22443
|
sessionFile
|
|
@@ -22409,7 +22569,7 @@ async function admitNotaryInvocation(options) {
|
|
|
22409
22569
|
...ticketFields,
|
|
22410
22570
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
22411
22571
|
};
|
|
22412
|
-
const admittedRequestPath =
|
|
22572
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22413
22573
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22414
22574
|
sessionDirectory,
|
|
22415
22575
|
sessionFile
|
|
@@ -22512,7 +22672,7 @@ async function admitGleanerLeftInvocation(options) {
|
|
|
22512
22672
|
attachments: [],
|
|
22513
22673
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
22514
22674
|
};
|
|
22515
|
-
const admittedRequestPath =
|
|
22675
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22516
22676
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22517
22677
|
sessionDirectory,
|
|
22518
22678
|
sessionFile
|
|
@@ -22651,7 +22811,7 @@ async function admitReviewerInvocation(options) {
|
|
|
22651
22811
|
mediaKind: a.mediaKind
|
|
22652
22812
|
}))
|
|
22653
22813
|
};
|
|
22654
|
-
const admittedRequestPath =
|
|
22814
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22655
22815
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22656
22816
|
sessionDirectory,
|
|
22657
22817
|
sessionFile
|
|
@@ -22803,7 +22963,7 @@ async function admitMergerInvocation(options) {
|
|
|
22803
22963
|
resolutionScope: [...derived.resolutionScope],
|
|
22804
22964
|
authorizedChecks: []
|
|
22805
22965
|
});
|
|
22806
|
-
const mergerInputPath =
|
|
22966
|
+
const mergerInputPath = join16(runDirectory, "merger-input.json");
|
|
22807
22967
|
await writeFile5(
|
|
22808
22968
|
mergerInputPath,
|
|
22809
22969
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -22834,7 +22994,7 @@ async function admitMergerInvocation(options) {
|
|
|
22834
22994
|
mediaKind: a.mediaKind
|
|
22835
22995
|
}))
|
|
22836
22996
|
};
|
|
22837
|
-
const admittedRequestPath =
|
|
22997
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22838
22998
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22839
22999
|
sessionDirectory,
|
|
22840
23000
|
sessionFile
|
|
@@ -23118,15 +23278,15 @@ var init_invocation = __esm({
|
|
|
23118
23278
|
|
|
23119
23279
|
// src/public-cli/load-production-acp-host.ts
|
|
23120
23280
|
import { existsSync as existsSync7 } from "node:fs";
|
|
23121
|
-
import { join as
|
|
23281
|
+
import { join as join17 } from "node:path";
|
|
23122
23282
|
import { pathToFileURL } from "node:url";
|
|
23123
23283
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
23124
23284
|
const description = lookupHostDescription(host);
|
|
23125
23285
|
if (description === void 0) {
|
|
23126
23286
|
throw new Error(`unregistered host: ${host}`);
|
|
23127
23287
|
}
|
|
23128
|
-
const built =
|
|
23129
|
-
const source =
|
|
23288
|
+
const built = join17(packageRoot2, "dist/acp-host/production-host.js");
|
|
23289
|
+
const source = join17(packageRoot2, "src/acp-host/production-host.ts");
|
|
23130
23290
|
const target = existsSync7(built) ? built : source;
|
|
23131
23291
|
const href = pathToFileURL(target).href;
|
|
23132
23292
|
const mod = await import(href);
|
|
@@ -23142,15 +23302,15 @@ var init_load_production_acp_host = __esm({
|
|
|
23142
23302
|
|
|
23143
23303
|
// src/public-cli/load-production-headless-host.ts
|
|
23144
23304
|
import { existsSync as existsSync8 } from "node:fs";
|
|
23145
|
-
import { join as
|
|
23305
|
+
import { join as join18 } from "node:path";
|
|
23146
23306
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23147
23307
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
23148
23308
|
const description = lookupHeadlessHostDescription(host);
|
|
23149
23309
|
if (description === void 0) {
|
|
23150
23310
|
throw new Error(`unregistered headless host: ${host}`);
|
|
23151
23311
|
}
|
|
23152
|
-
const built =
|
|
23153
|
-
const source =
|
|
23312
|
+
const built = join18(packageRoot2, "dist/headless-host/production-host.js");
|
|
23313
|
+
const source = join18(packageRoot2, "src/headless-host/production-host.ts");
|
|
23154
23314
|
const target = existsSync8(built) ? built : source;
|
|
23155
23315
|
const href = pathToFileURL2(target).href;
|
|
23156
23316
|
const mod = await import(href);
|
|
@@ -23277,8 +23437,8 @@ var init_role_turn_host_resolution = __esm({
|
|
|
23277
23437
|
|
|
23278
23438
|
// src/package-resources/method-skill.ts
|
|
23279
23439
|
import { createHash as createHash4 } from "node:crypto";
|
|
23280
|
-
import { readFile as
|
|
23281
|
-
import { join as
|
|
23440
|
+
import { readFile as readFile13, realpath as realpath5 } from "node:fs/promises";
|
|
23441
|
+
import { join as join19 } from "node:path";
|
|
23282
23442
|
function gitBlobOid(bytes) {
|
|
23283
23443
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
23284
23444
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -23295,16 +23455,16 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
23295
23455
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
23296
23456
|
}
|
|
23297
23457
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
23298
|
-
return
|
|
23458
|
+
return join19(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
23299
23459
|
}
|
|
23300
23460
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
23301
|
-
return
|
|
23461
|
+
return join19(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
23302
23462
|
}
|
|
23303
|
-
function
|
|
23463
|
+
function isRecord5(value) {
|
|
23304
23464
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23305
23465
|
}
|
|
23306
23466
|
function parseProvenance(raw, expectedName) {
|
|
23307
|
-
if (!
|
|
23467
|
+
if (!isRecord5(raw)) {
|
|
23308
23468
|
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
23309
23469
|
}
|
|
23310
23470
|
if (raw.name !== expectedName) {
|
|
@@ -23318,7 +23478,7 @@ function parseProvenance(raw, expectedName) {
|
|
|
23318
23478
|
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
23319
23479
|
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
23320
23480
|
}
|
|
23321
|
-
if (!
|
|
23481
|
+
if (!isRecord5(raw.upstream)) {
|
|
23322
23482
|
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
23323
23483
|
}
|
|
23324
23484
|
const upstream = raw.upstream;
|
|
@@ -23345,12 +23505,12 @@ function parseProvenance(raw, expectedName) {
|
|
|
23345
23505
|
`Packaged method provenance upstream must include nonblank tag or version`
|
|
23346
23506
|
);
|
|
23347
23507
|
}
|
|
23348
|
-
if (!
|
|
23508
|
+
if (!isRecord5(raw.files)) {
|
|
23349
23509
|
throw new Error(`Packaged method provenance files must be an object`);
|
|
23350
23510
|
}
|
|
23351
23511
|
const files = {};
|
|
23352
23512
|
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
23353
|
-
if (!
|
|
23513
|
+
if (!isRecord5(entry)) {
|
|
23354
23514
|
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
23355
23515
|
}
|
|
23356
23516
|
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
@@ -23392,11 +23552,11 @@ function parseProvenance(raw, expectedName) {
|
|
|
23392
23552
|
}
|
|
23393
23553
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
23394
23554
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
23395
|
-
const skillPathConfigured =
|
|
23396
|
-
const provenancePath =
|
|
23555
|
+
const skillPathConfigured = join19(rootDirectory, "SKILL.md");
|
|
23556
|
+
const provenancePath = join19(rootDirectory, "provenance.json");
|
|
23397
23557
|
let provenanceRaw;
|
|
23398
23558
|
try {
|
|
23399
|
-
provenanceRaw = await
|
|
23559
|
+
provenanceRaw = await readFile13(provenancePath, "utf8");
|
|
23400
23560
|
} catch (error) {
|
|
23401
23561
|
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
23402
23562
|
}
|
|
@@ -23410,10 +23570,10 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23410
23570
|
}
|
|
23411
23571
|
const provenance = parseProvenance(provenanceJson, name);
|
|
23412
23572
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
23413
|
-
const absolute =
|
|
23573
|
+
const absolute = join19(rootDirectory, rel);
|
|
23414
23574
|
let bytes;
|
|
23415
23575
|
try {
|
|
23416
|
-
bytes = await
|
|
23576
|
+
bytes = await readFile13(absolute);
|
|
23417
23577
|
} catch (error) {
|
|
23418
23578
|
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
23419
23579
|
}
|
|
@@ -23429,7 +23589,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23429
23589
|
let raw;
|
|
23430
23590
|
try {
|
|
23431
23591
|
skillPath = await realpath5(skillPathConfigured);
|
|
23432
|
-
raw = await
|
|
23592
|
+
raw = await readFile13(skillPath, "utf8");
|
|
23433
23593
|
} catch (error) {
|
|
23434
23594
|
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
23435
23595
|
}
|
|
@@ -23513,12 +23673,12 @@ var init_method_skill = __esm({
|
|
|
23513
23673
|
});
|
|
23514
23674
|
|
|
23515
23675
|
// src/ledger-session-read.ts
|
|
23516
|
-
import { readFile as
|
|
23517
|
-
function
|
|
23676
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
23677
|
+
function isRecord6(value) {
|
|
23518
23678
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23519
23679
|
}
|
|
23520
23680
|
async function readLedgerSessionJsonlLines(path) {
|
|
23521
|
-
const text = await
|
|
23681
|
+
const text = await readFile14(path, "utf8");
|
|
23522
23682
|
const lines = text.split("\n");
|
|
23523
23683
|
const out = [];
|
|
23524
23684
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -23539,7 +23699,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
23539
23699
|
});
|
|
23540
23700
|
continue;
|
|
23541
23701
|
}
|
|
23542
|
-
if (!
|
|
23702
|
+
if (!isRecord6(row)) {
|
|
23543
23703
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
23544
23704
|
out.push({
|
|
23545
23705
|
line: lineNumber,
|
|
@@ -23592,7 +23752,7 @@ function extractSessionModelSequence(rows) {
|
|
|
23592
23752
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
23593
23753
|
push(row.modelId);
|
|
23594
23754
|
}
|
|
23595
|
-
const message =
|
|
23755
|
+
const message = isRecord6(row.message) ? row.message : void 0;
|
|
23596
23756
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
23597
23757
|
push(message.model);
|
|
23598
23758
|
}
|
|
@@ -23608,11 +23768,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
23608
23768
|
const openById = /* @__PURE__ */ new Map();
|
|
23609
23769
|
for (const row of rows) {
|
|
23610
23770
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
23611
|
-
const message =
|
|
23771
|
+
const message = isRecord6(row.message) ? row.message : void 0;
|
|
23612
23772
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
23613
23773
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
23614
23774
|
for (const part of message.content) {
|
|
23615
|
-
if (!
|
|
23775
|
+
if (!isRecord6(part) || part.type !== "toolCall") continue;
|
|
23616
23776
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
23617
23777
|
throw new Error("toolCall frame missing string id");
|
|
23618
23778
|
}
|
|
@@ -23625,7 +23785,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
23625
23785
|
if (openById.has(part.id)) {
|
|
23626
23786
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
23627
23787
|
}
|
|
23628
|
-
const args =
|
|
23788
|
+
const args = isRecord6(part.arguments) ? part.arguments : void 0;
|
|
23629
23789
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
23630
23790
|
const interval = {
|
|
23631
23791
|
toolCallId: part.id,
|
|
@@ -23709,9 +23869,9 @@ var init_ledger_session_read = __esm({
|
|
|
23709
23869
|
});
|
|
23710
23870
|
|
|
23711
23871
|
// src/analyst-gate-cycles-read.ts
|
|
23712
|
-
import { readdir as
|
|
23713
|
-
import { join as
|
|
23714
|
-
function
|
|
23872
|
+
import { readdir as readdir6 } from "node:fs/promises";
|
|
23873
|
+
import { join as join20 } from "node:path";
|
|
23874
|
+
function isRecord7(value) {
|
|
23715
23875
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23716
23876
|
}
|
|
23717
23877
|
function isParentAttemptBindingRow(row) {
|
|
@@ -23741,7 +23901,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
23741
23901
|
function acceptedGateReceiptIds(rows) {
|
|
23742
23902
|
const accepted = /* @__PURE__ */ new Set();
|
|
23743
23903
|
for (const row of rows) {
|
|
23744
|
-
const message =
|
|
23904
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
23745
23905
|
if (message?.role !== "toolResult") continue;
|
|
23746
23906
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
23747
23907
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -23776,7 +23936,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
23776
23936
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
23777
23937
|
const row = rows[i];
|
|
23778
23938
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
23779
|
-
if (!
|
|
23939
|
+
if (!isRecord7(row.data) || !isRecord7(row.data.parent)) continue;
|
|
23780
23940
|
const id = row.data.parent.attemptEntryId;
|
|
23781
23941
|
const sessionFile = row.data.parent.sessionFile;
|
|
23782
23942
|
return {
|
|
@@ -23791,10 +23951,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
23791
23951
|
const out = [];
|
|
23792
23952
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
23793
23953
|
const row = rows[rowIndex];
|
|
23794
|
-
const message =
|
|
23954
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
23795
23955
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
23796
23956
|
for (const part of message.content) {
|
|
23797
|
-
if (!
|
|
23957
|
+
if (!isRecord7(part) || part.type !== "toolCall") continue;
|
|
23798
23958
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
23799
23959
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
23800
23960
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -23802,7 +23962,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
23802
23962
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
23803
23963
|
out.push({
|
|
23804
23964
|
toolName: part.name,
|
|
23805
|
-
args:
|
|
23965
|
+
args: isRecord7(part.arguments) ? part.arguments : void 0,
|
|
23806
23966
|
accepted: true,
|
|
23807
23967
|
rowIndex,
|
|
23808
23968
|
...binding
|
|
@@ -23935,7 +24095,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
23935
24095
|
{ cause: error }
|
|
23936
24096
|
);
|
|
23937
24097
|
}
|
|
23938
|
-
if (!
|
|
24098
|
+
if (!isRecord7(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
23939
24099
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
23940
24100
|
}
|
|
23941
24101
|
const sessionFile = raw.sessionFile;
|
|
@@ -23951,7 +24111,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
23951
24111
|
for (const directory of directories) {
|
|
23952
24112
|
let names;
|
|
23953
24113
|
try {
|
|
23954
|
-
const entries = await
|
|
24114
|
+
const entries = await readdir6(directory, { withFileTypes: true });
|
|
23955
24115
|
names = entries.filter(
|
|
23956
24116
|
(e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
|
|
23957
24117
|
).map((e) => e.name).sort();
|
|
@@ -23960,7 +24120,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
23960
24120
|
throw error;
|
|
23961
24121
|
}
|
|
23962
24122
|
for (const name of names) {
|
|
23963
|
-
const path =
|
|
24123
|
+
const path = join20(directory, name);
|
|
23964
24124
|
const fromPointer = name.endsWith(".pointer.json");
|
|
23965
24125
|
const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
23966
24126
|
if (sessionPath === void 0) continue;
|
|
@@ -24010,143 +24170,6 @@ var init_audit_escalation = __esm({
|
|
|
24010
24170
|
}
|
|
24011
24171
|
});
|
|
24012
24172
|
|
|
24013
|
-
// src/run-terminal-artifacts.ts
|
|
24014
|
-
import { readdir as readdir6, readFile as readFile14 } from "node:fs/promises";
|
|
24015
|
-
import { basename as basename7, dirname as dirname10, join as join20 } from "node:path";
|
|
24016
|
-
function isMissingPathError3(error) {
|
|
24017
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
24018
|
-
}
|
|
24019
|
-
function errorText2(error) {
|
|
24020
|
-
return error instanceof Error ? error.message : String(error);
|
|
24021
|
-
}
|
|
24022
|
-
function isRecord7(value) {
|
|
24023
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24024
|
-
}
|
|
24025
|
-
function readUsableTerminalArtifactBody(body) {
|
|
24026
|
-
if (body === null) {
|
|
24027
|
-
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
24028
|
-
}
|
|
24029
|
-
if (!isRecord7(body)) {
|
|
24030
|
-
return {
|
|
24031
|
-
ok: false,
|
|
24032
|
-
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
24033
|
-
};
|
|
24034
|
-
}
|
|
24035
|
-
if (typeof body.role !== "string" || body.role.trim() === "") {
|
|
24036
|
-
return {
|
|
24037
|
-
ok: false,
|
|
24038
|
-
reason: "terminal artifact missing nonblank producer-owned role field"
|
|
24039
|
-
};
|
|
24040
|
-
}
|
|
24041
|
-
return { ok: true, body };
|
|
24042
|
-
}
|
|
24043
|
-
async function readTerminalArtifactAtPath(path, file) {
|
|
24044
|
-
let raw;
|
|
24045
|
-
try {
|
|
24046
|
-
raw = await readFile14(path, "utf8");
|
|
24047
|
-
} catch (error) {
|
|
24048
|
-
if (isMissingPathError3(error)) return void 0;
|
|
24049
|
-
return {
|
|
24050
|
-
status: "unreadable",
|
|
24051
|
-
file,
|
|
24052
|
-
path,
|
|
24053
|
-
reason: errorText2(error)
|
|
24054
|
-
};
|
|
24055
|
-
}
|
|
24056
|
-
let parsed;
|
|
24057
|
-
try {
|
|
24058
|
-
parsed = JSON.parse(raw);
|
|
24059
|
-
} catch (error) {
|
|
24060
|
-
return {
|
|
24061
|
-
status: "unreadable",
|
|
24062
|
-
file,
|
|
24063
|
-
path,
|
|
24064
|
-
reason: error instanceof Error ? error.message : `terminal artifact JSON parse failed: ${String(error)}`
|
|
24065
|
-
};
|
|
24066
|
-
}
|
|
24067
|
-
const usable = readUsableTerminalArtifactBody(parsed);
|
|
24068
|
-
if (!usable.ok) {
|
|
24069
|
-
return {
|
|
24070
|
-
status: "unreadable",
|
|
24071
|
-
file,
|
|
24072
|
-
path,
|
|
24073
|
-
reason: usable.reason
|
|
24074
|
-
};
|
|
24075
|
-
}
|
|
24076
|
-
return { status: "present", file, path, body: usable.body };
|
|
24077
|
-
}
|
|
24078
|
-
async function listUniqueErrorFallbackPaths(directories) {
|
|
24079
|
-
const found = [];
|
|
24080
|
-
for (const dir of directories) {
|
|
24081
|
-
let names;
|
|
24082
|
-
try {
|
|
24083
|
-
names = await readdir6(dir);
|
|
24084
|
-
} catch (error) {
|
|
24085
|
-
if (isMissingPathError3(error)) continue;
|
|
24086
|
-
throw error;
|
|
24087
|
-
}
|
|
24088
|
-
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
24089
|
-
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
24090
|
-
found.push(join20(dir, name));
|
|
24091
|
-
}
|
|
24092
|
-
}
|
|
24093
|
-
return found;
|
|
24094
|
-
}
|
|
24095
|
-
function runIdFromRunDirectory(runDirectory) {
|
|
24096
|
-
const name = basename7(runDirectory);
|
|
24097
|
-
const at = name.lastIndexOf("@");
|
|
24098
|
-
if (at <= 0 || at === name.length - 1) return void 0;
|
|
24099
|
-
return name.slice(0, at);
|
|
24100
|
-
}
|
|
24101
|
-
function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
24102
|
-
if (expectedRunId === void 0) return false;
|
|
24103
|
-
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
24104
|
-
}
|
|
24105
|
-
async function readRunTerminalArtifact(runDirectory) {
|
|
24106
|
-
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
24107
|
-
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
24108
|
-
const path = join20(artifactsDir, file);
|
|
24109
|
-
const read = await readTerminalArtifactAtPath(path, file);
|
|
24110
|
-
if (read !== void 0) return read;
|
|
24111
|
-
}
|
|
24112
|
-
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
24113
|
-
const path = join20(runDirectory, relative4);
|
|
24114
|
-
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
24115
|
-
if (read !== void 0) return read;
|
|
24116
|
-
}
|
|
24117
|
-
for (const path of await listUniqueErrorFallbackPaths([artifactsDir, runDirectory])) {
|
|
24118
|
-
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
24119
|
-
if (read !== void 0) return read;
|
|
24120
|
-
}
|
|
24121
|
-
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
24122
|
-
for (const path of await listUniqueErrorFallbackPaths([dirname10(runDirectory)])) {
|
|
24123
|
-
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
24124
|
-
if (read === void 0) continue;
|
|
24125
|
-
if (read.status === "present") {
|
|
24126
|
-
if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
|
|
24127
|
-
return read;
|
|
24128
|
-
}
|
|
24129
|
-
}
|
|
24130
|
-
return { status: "absent" };
|
|
24131
|
-
}
|
|
24132
|
-
var RUN_TERMINAL_ARTIFACT_FILES, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_NAME;
|
|
24133
|
-
var init_run_terminal_artifacts = __esm({
|
|
24134
|
-
"src/run-terminal-artifacts.ts"() {
|
|
24135
|
-
"use strict";
|
|
24136
|
-
init_role_run_placement();
|
|
24137
|
-
RUN_TERMINAL_ARTIFACT_FILES = [
|
|
24138
|
-
"report.json",
|
|
24139
|
-
"error.json",
|
|
24140
|
-
"audit-incomplete.json"
|
|
24141
|
-
];
|
|
24142
|
-
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
|
|
24143
|
-
"artifacts/error.settlement.json",
|
|
24144
|
-
"error.settlement.json"
|
|
24145
|
-
];
|
|
24146
|
-
UNIQUE_ERROR_FALLBACK_NAME = /^error\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.json$/i;
|
|
24147
|
-
}
|
|
24148
|
-
});
|
|
24149
|
-
|
|
24150
24173
|
// src/submission-ledger.ts
|
|
24151
24174
|
import { join as join21 } from "node:path";
|
|
24152
24175
|
async function submissionRecordFile(cwd, runId, scope) {
|
|
@@ -26836,11 +26859,75 @@ async function settleLawfulDiaristTerminalResult(admitted, authority, scope) {
|
|
|
26836
26859
|
async function trySettleDiaristTerminalResult(admitted, authority, scope) {
|
|
26837
26860
|
return settleLawfulDiaristTerminalResult(admitted, authority, scope);
|
|
26838
26861
|
}
|
|
26862
|
+
function countersignTerminalFromEntries(entries) {
|
|
26863
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
26864
|
+
const entry = entries[index];
|
|
26865
|
+
if (entry?.type !== "custom") continue;
|
|
26866
|
+
if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
|
|
26867
|
+
const data = entry.data !== null && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : void 0;
|
|
26868
|
+
if (data?.officer !== "countersign") continue;
|
|
26869
|
+
if (data.receipt === void 0) continue;
|
|
26870
|
+
const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
|
|
26871
|
+
return {
|
|
26872
|
+
receipt: data.receipt,
|
|
26873
|
+
...runId === void 0 ? {} : { runId }
|
|
26874
|
+
};
|
|
26875
|
+
}
|
|
26876
|
+
return void 0;
|
|
26877
|
+
}
|
|
26878
|
+
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
26879
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord10(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
26880
|
+
return {
|
|
26881
|
+
...roleOutcome,
|
|
26882
|
+
decisiveFacts: {
|
|
26883
|
+
...prior,
|
|
26884
|
+
[SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY]: officer
|
|
26885
|
+
}
|
|
26886
|
+
};
|
|
26887
|
+
}
|
|
26888
|
+
function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
26889
|
+
const payloads = roleOutcome.payloads ?? [];
|
|
26890
|
+
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
26891
|
+
const payload = payloads[index];
|
|
26892
|
+
if (!isRecord10(payload)) continue;
|
|
26893
|
+
const status = payload.secretariatStatus;
|
|
26894
|
+
if (typeof status !== "string") continue;
|
|
26895
|
+
return status === "converged";
|
|
26896
|
+
}
|
|
26897
|
+
return false;
|
|
26898
|
+
}
|
|
26839
26899
|
async function settleLawfulSecretariatTerminalResult(admitted, authority, scope) {
|
|
26840
|
-
|
|
26900
|
+
const settled = await settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
26841
26901
|
role: "secretariat",
|
|
26842
26902
|
toolName: SECRETARIAT_OUTPUT_TOOL_NAME
|
|
26843
26903
|
}, scope);
|
|
26904
|
+
if (settled === void 0) return void 0;
|
|
26905
|
+
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
26906
|
+
const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
|
|
26907
|
+
const officer = countersignTerminalFromEntries(entries);
|
|
26908
|
+
if (officer === void 0) return settled;
|
|
26909
|
+
if (settled.roleOutcome.kind === "audit_escalation") {
|
|
26910
|
+
return {
|
|
26911
|
+
...settled,
|
|
26912
|
+
roleOutcome: withCountersignTerminalFact(
|
|
26913
|
+
{
|
|
26914
|
+
...settled.roleOutcome,
|
|
26915
|
+
payloads: [officer.receipt]
|
|
26916
|
+
},
|
|
26917
|
+
officer
|
|
26918
|
+
)
|
|
26919
|
+
};
|
|
26920
|
+
}
|
|
26921
|
+
if (settled.roleOutcome.kind === "accepted") {
|
|
26922
|
+
if (!acceptedSecretariatDefinesOfficerProjection(settled.roleOutcome)) {
|
|
26923
|
+
return settled;
|
|
26924
|
+
}
|
|
26925
|
+
return {
|
|
26926
|
+
...settled,
|
|
26927
|
+
roleOutcome: withCountersignTerminalFact(settled.roleOutcome, officer)
|
|
26928
|
+
};
|
|
26929
|
+
}
|
|
26930
|
+
return settled;
|
|
26844
26931
|
}
|
|
26845
26932
|
async function trySettleSecretariatTerminalResult(admitted, authority, scope) {
|
|
26846
26933
|
return settleLawfulSecretariatTerminalResult(admitted, authority, scope);
|
|
@@ -31614,6 +31701,25 @@ async function summonGateOfficer(options) {
|
|
|
31614
31701
|
...common
|
|
31615
31702
|
});
|
|
31616
31703
|
}
|
|
31704
|
+
if (options.officer === "countersign") {
|
|
31705
|
+
const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
|
|
31706
|
+
const correlationId = runIdFromRunDirectory2(options.sourceRunDirectory);
|
|
31707
|
+
if (correlationId === void 0 || correlationId.trim() === "") {
|
|
31708
|
+
throw new Error(
|
|
31709
|
+
`countersign gate summon requires parent runId from sourceRunDirectory: ${options.sourceRunDirectory}`
|
|
31710
|
+
);
|
|
31711
|
+
}
|
|
31712
|
+
const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
31713
|
+
const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
|
|
31714
|
+
const instruction = options.reask ?? gateReviewInstruction ?? "";
|
|
31715
|
+
return summonPublicRole({
|
|
31716
|
+
role: "countersign",
|
|
31717
|
+
argv: ["--project", options.cwd, "--", instruction],
|
|
31718
|
+
...common,
|
|
31719
|
+
correlationId,
|
|
31720
|
+
...parentTicket === void 0 ? {} : { boundTicketNumber: parentTicket }
|
|
31721
|
+
});
|
|
31722
|
+
}
|
|
31617
31723
|
return summonPublicRole({
|
|
31618
31724
|
role: "inspector",
|
|
31619
31725
|
argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
|
|
@@ -31847,7 +31953,9 @@ async function runPublicCountersign(argv2, env, io, parseCountersignArgv2) {
|
|
|
31847
31953
|
{
|
|
31848
31954
|
instruction: parsed.instruction,
|
|
31849
31955
|
projectRoot: admitted.projectRoot,
|
|
31850
|
-
failureLabel: "unbound summons"
|
|
31956
|
+
failureLabel: "unbound summons",
|
|
31957
|
+
// #969: parent durable ticket is the resume/bind key (ADR 0079).
|
|
31958
|
+
...env.boundTicketNumber === void 0 ? {} : { boundTicketNumber: env.boundTicketNumber }
|
|
31851
31959
|
},
|
|
31852
31960
|
env,
|
|
31853
31961
|
io
|
|
@@ -31899,12 +32007,16 @@ async function runPublicCountersign(argv2, env, io, parseCountersignArgv2) {
|
|
|
31899
32007
|
);
|
|
31900
32008
|
}
|
|
31901
32009
|
if (outcome.identity.kind === "ticket") {
|
|
31902
|
-
|
|
31903
|
-
typedTicket = assertedTicket;
|
|
32010
|
+
typedTicket = isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : outcome.identity.ticketNumber;
|
|
31904
32011
|
typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
|
|
32012
|
+
} else if (isSafePositiveTicketNumber(env.boundTicketNumber)) {
|
|
32013
|
+
typedTicket = env.boundTicketNumber;
|
|
32014
|
+
}
|
|
32015
|
+
if (typedTicket !== void 0) {
|
|
32016
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction;
|
|
31905
32017
|
const summons = {
|
|
31906
|
-
instruction:
|
|
31907
|
-
instructionEmpty:
|
|
32018
|
+
instruction: resumeInstruction,
|
|
32019
|
+
instructionEmpty: resumeInstruction.trim() === ""
|
|
31908
32020
|
};
|
|
31909
32021
|
const resumed = await tryResumeSameTicketSeatRun({
|
|
31910
32022
|
home: env.home,
|
|
@@ -31986,7 +32098,9 @@ async function runPublicCountersign(argv2, env, io, parseCountersignArgv2) {
|
|
|
31986
32098
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
31987
32099
|
continuation: {
|
|
31988
32100
|
kind: "initial",
|
|
31989
|
-
|
|
32101
|
+
// #969/#879: gate path first mint carries parent payload as dialogue content;
|
|
32102
|
+
// ordinary public entry keeps package transport prompt.
|
|
32103
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildCountersignTransportPrompt(
|
|
31990
32104
|
admitted,
|
|
31991
32105
|
engineSessionMaterialFromOptions({
|
|
31992
32106
|
...pickEngineAxis(env),
|