@akagilnc/pi-workflow-roles 0.1.3452 → 0.1.3471
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/CLAUDE.md +2 -0
- package/dist/evidence-child-executor.js +2 -11
- package/dist/grok/production-host.js +196 -205
- package/dist/pi/in-process-session.js +4 -0
- package/dist/public-cli/main.js +998 -920
- package/package.json +1 -1
- package/scripts/build-package.mjs +1 -3
- package/src/analyst-gate-cycles-read.ts +3 -21
- package/src/analyst-ledger.ts +11 -42
- package/src/archivist-record-entry.ts +5 -6
- package/src/evidence-child-executor.ts +5 -15
- package/src/grok/production-host.ts +3 -32
- package/src/grok/role-envelope.ts +10 -4
- package/src/host-contracts.ts +4 -11
- package/src/host-transition-prior-native.ts +3 -7
- package/src/ledger-session-read.ts +1 -17
- package/src/pi/in-process-session.ts +6 -2
- package/src/pi/role-turn-host.ts +9 -0
- package/src/public-cli/collector-run.ts +4 -4
- package/src/public-cli/countersign-run.ts +90 -20
- package/src/public-cli/doctor-run.ts +4 -4
- package/src/public-cli/gleaner-left-run.ts +9 -6
- package/src/public-cli/inspector-run.ts +95 -32
- package/src/public-cli/instruction-seat-run.ts +7 -6
- package/src/public-cli/invocation.ts +14 -8
- package/src/public-cli/judge-run.ts +4 -4
- package/src/public-cli/notary-run.ts +91 -30
- package/src/public-cli/post-admission.ts +424 -360
- package/src/public-cli/run-lifecycle.ts +205 -0
- package/src/public-cli/seat-ticket-binding.ts +136 -16
- package/src/public-cli/settlement.ts +74 -52
- package/src/run-ticket-number.ts +53 -0
- package/src/submission-ledger.ts +86 -18
- package/dist/ledger-session-read.js +0 -241
- package/dist/ticket-seat-memory.js +0 -244
- package/src/ticket-seat-memory.ts +0 -454
package/dist/public-cli/main.js
CHANGED
|
@@ -15901,7 +15901,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
15901
15901
|
}
|
|
15902
15902
|
const command = input.argv[0];
|
|
15903
15903
|
const args = input.argv.slice(1);
|
|
15904
|
-
return await new Promise((
|
|
15904
|
+
return await new Promise((resolve12, reject) => {
|
|
15905
15905
|
let settled = false;
|
|
15906
15906
|
const signal = input.signal;
|
|
15907
15907
|
const child = spawn(command, args, {
|
|
@@ -15931,7 +15931,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
15931
15931
|
if (signal !== void 0) {
|
|
15932
15932
|
signal.removeEventListener("abort", onAbort);
|
|
15933
15933
|
}
|
|
15934
|
-
|
|
15934
|
+
resolve12(result2);
|
|
15935
15935
|
};
|
|
15936
15936
|
const onAbort = () => {
|
|
15937
15937
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -16571,6 +16571,8 @@ ${paths.join("\n")}`
|
|
|
16571
16571
|
PI_CODING_AGENT_DIR: request.agentDir,
|
|
16572
16572
|
AK_ROLE_RUN_DIR: request.runDirectory
|
|
16573
16573
|
};
|
|
16574
|
+
if (request.courtAttemptId === void 0) delete env.AK_ROLE_COURT_ATTEMPT;
|
|
16575
|
+
else env.AK_ROLE_COURT_ATTEMPT = request.courtAttemptId;
|
|
16574
16576
|
applyEngineChildEnv(env, request.engine);
|
|
16575
16577
|
if (request.correlationId !== void 0 && request.correlationId.trim() !== "") {
|
|
16576
16578
|
env.AK_CORRELATION_ID = request.correlationId;
|
|
@@ -16632,294 +16634,37 @@ var init_role_turn_host = __esm({
|
|
|
16632
16634
|
}
|
|
16633
16635
|
});
|
|
16634
16636
|
|
|
16635
|
-
// src/
|
|
16636
|
-
import {
|
|
16637
|
+
// src/run-ticket-number.ts
|
|
16638
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
16637
16639
|
import { join as join11 } from "node:path";
|
|
16638
|
-
function subjectKeyedRecordDirectory(input) {
|
|
16639
|
-
const ledgerHome = input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0 ? resolveActivationLedgerHomeForPath(input.parentSessionFile) : resolveActivationLedgerHome(input.home);
|
|
16640
|
-
const digest = createHash3("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
16641
|
-
return join11(
|
|
16642
|
-
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
16643
|
-
input.kind,
|
|
16644
|
-
digest
|
|
16645
|
-
);
|
|
16646
|
-
}
|
|
16647
|
-
var init_archivist_record_topology = __esm({
|
|
16648
|
-
"src/archivist-record-topology.ts"() {
|
|
16649
|
-
"use strict";
|
|
16650
|
-
init_activation_ledger_git();
|
|
16651
|
-
init_activation_ledger_topology();
|
|
16652
|
-
}
|
|
16653
|
-
});
|
|
16654
|
-
|
|
16655
|
-
// src/session-opening-materials.ts
|
|
16656
|
-
import { existsSync as existsSync6 } from "node:fs";
|
|
16657
|
-
import { dirname as dirname6, join as join12 } from "node:path";
|
|
16658
|
-
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
16659
|
-
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
16660
|
-
let dir = dirname6(fileURLToPath(moduleUrl));
|
|
16661
|
-
for (let i = 0; i < 8; i += 1) {
|
|
16662
|
-
if (existsSync6(join12(dir, "package.json")) && existsSync6(join12(dir, "souls"))) {
|
|
16663
|
-
return dir;
|
|
16664
|
-
}
|
|
16665
|
-
const parent = dirname6(dir);
|
|
16666
|
-
if (parent === dir) break;
|
|
16667
|
-
dir = parent;
|
|
16668
|
-
}
|
|
16669
|
-
return fileURLToPath(new URL("..", moduleUrl));
|
|
16670
|
-
}
|
|
16671
|
-
var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
|
|
16672
|
-
var init_session_opening_materials = __esm({
|
|
16673
|
-
"src/session-opening-materials.ts"() {
|
|
16674
|
-
"use strict";
|
|
16675
|
-
init_packaged_role_registry();
|
|
16676
|
-
packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
|
|
16677
|
-
MAIN_ROLE_SESSION_MATERIALS = {
|
|
16678
|
-
...Object.fromEntries(
|
|
16679
|
-
PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
|
|
16680
|
-
)
|
|
16681
|
-
};
|
|
16682
|
-
GATEKEEPER_SESSION_MATERIALS = {
|
|
16683
|
-
// #639: single authority — the public gatekeeper record owns the province list.
|
|
16684
|
-
gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
|
|
16685
|
-
inspector: INSPECTOR_SESSION_MATERIALS,
|
|
16686
|
-
notary: NOTARY_SESSION_MATERIALS
|
|
16687
|
-
};
|
|
16688
|
-
}
|
|
16689
|
-
});
|
|
16690
|
-
|
|
16691
|
-
// src/ticket-seat-memory.ts
|
|
16692
|
-
import { existsSync as existsSync7 } from "node:fs";
|
|
16693
|
-
import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
|
|
16694
|
-
import { join as join13 } from "node:path";
|
|
16695
|
-
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
16696
|
-
function isTicketSeatRunBindingRow(row) {
|
|
16697
|
-
return row.type === "custom" && row.customType === TICKET_SEAT_RUN_BINDING_ENTRY_TYPE;
|
|
16698
|
-
}
|
|
16699
|
-
function ticketSeatRunBindingRunId(row) {
|
|
16700
|
-
if (!isTicketSeatRunBindingRow(row)) return void 0;
|
|
16701
|
-
if (row.data === null || typeof row.data !== "object" || Array.isArray(row.data)) {
|
|
16702
|
-
return void 0;
|
|
16703
|
-
}
|
|
16704
|
-
const runId = row.data.runId;
|
|
16705
|
-
return typeof runId === "string" && runId.length > 0 ? runId : void 0;
|
|
16706
|
-
}
|
|
16707
|
-
async function loadCreateRecordSessionOpen() {
|
|
16708
|
-
const packageRoot2 = resolvePackageRootDir(import.meta.url);
|
|
16709
|
-
const built = join13(packageRoot2, "dist/archivist-record-entry.js");
|
|
16710
|
-
const source = join13(packageRoot2, "src/archivist-record-entry.ts");
|
|
16711
|
-
const target = existsSync7(built) ? built : source;
|
|
16712
|
-
const mod = await import(pathToFileURL3(target).href);
|
|
16713
|
-
return mod.createRecordSessionOpen;
|
|
16714
|
-
}
|
|
16715
|
-
function isTicketSeatMemorySeat(value) {
|
|
16716
|
-
return TICKET_SEAT_MEMORY_SEATS.includes(value);
|
|
16717
|
-
}
|
|
16718
|
-
function isTicketSeatMemoryBound(input) {
|
|
16719
|
-
return isTicketSeatMemorySeat(input.role) && typeof input.ticketNumber === "number" && Number.isSafeInteger(input.ticketNumber) && input.ticketNumber >= 1;
|
|
16720
|
-
}
|
|
16721
16640
|
function isEnoent(error) {
|
|
16722
16641
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
16723
16642
|
}
|
|
16724
|
-
function
|
|
16725
|
-
|
|
16726
|
-
|
|
16727
|
-
|
|
16728
|
-
);
|
|
16729
|
-
}
|
|
16730
|
-
return `${ticketNumber}:${seat}`;
|
|
16731
|
-
}
|
|
16732
|
-
function ticketSeatMemorySessionDirectory(input) {
|
|
16733
|
-
return subjectKeyedRecordDirectory({
|
|
16734
|
-
cwd: input.cwd,
|
|
16735
|
-
kind: TICKET_SEAT_MEMORY_KIND,
|
|
16736
|
-
subject: ticketSeatMemorySubject(input.ticketNumber, input.seat),
|
|
16737
|
-
...input.parentSessionFile === void 0 ? {} : { parentSessionFile: input.parentSessionFile },
|
|
16738
|
-
...input.home === void 0 ? {} : { home: input.home }
|
|
16739
|
-
});
|
|
16740
|
-
}
|
|
16741
|
-
async function readRunAdmittedPageFacts(runDirectory) {
|
|
16742
|
-
try {
|
|
16743
|
-
const raw = JSON.parse(
|
|
16744
|
-
await readFile5(join13(runDirectory, "admitted-request.json"), "utf8")
|
|
16745
|
-
);
|
|
16746
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
16747
|
-
return {};
|
|
16748
|
-
}
|
|
16749
|
-
const record4 = raw;
|
|
16750
|
-
const ticketNumber = record4.ticketNumber;
|
|
16751
|
-
const projectRoot = record4.projectRoot;
|
|
16752
|
-
return {
|
|
16753
|
-
...typeof ticketNumber === "number" && Number.isSafeInteger(ticketNumber) && ticketNumber >= 1 ? { ticketNumber } : {},
|
|
16754
|
-
...typeof projectRoot === "string" ? { projectRoot } : {}
|
|
16755
|
-
};
|
|
16756
|
-
} catch (error) {
|
|
16757
|
-
if (isEnoent(error)) return {};
|
|
16758
|
-
throw error;
|
|
16643
|
+
function ticketFromRecord(record4) {
|
|
16644
|
+
const ticketNumber = record4.ticketNumber;
|
|
16645
|
+
if (typeof ticketNumber === "number" && Number.isSafeInteger(ticketNumber) && ticketNumber >= 1) {
|
|
16646
|
+
return ticketNumber;
|
|
16759
16647
|
}
|
|
16648
|
+
return void 0;
|
|
16760
16649
|
}
|
|
16761
|
-
async function
|
|
16650
|
+
async function readPageTicketNumber(runDirectory, page) {
|
|
16762
16651
|
try {
|
|
16763
|
-
const raw = JSON.parse(
|
|
16764
|
-
await readFile5(join13(runDirectory, "invocation.json"), "utf8")
|
|
16765
|
-
);
|
|
16652
|
+
const raw = JSON.parse(await readFile5(join11(runDirectory, page), "utf8"));
|
|
16766
16653
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
16767
16654
|
return void 0;
|
|
16768
16655
|
}
|
|
16769
|
-
|
|
16770
|
-
if (typeof ticketNumber === "number" && Number.isSafeInteger(ticketNumber) && ticketNumber >= 1) {
|
|
16771
|
-
return ticketNumber;
|
|
16772
|
-
}
|
|
16656
|
+
return ticketFromRecord(raw);
|
|
16773
16657
|
} catch (error) {
|
|
16774
16658
|
if (isEnoent(error)) return void 0;
|
|
16775
16659
|
throw error;
|
|
16776
16660
|
}
|
|
16777
|
-
return void 0;
|
|
16778
16661
|
}
|
|
16779
16662
|
async function readRunTicketNumber(runDirectory) {
|
|
16780
|
-
|
|
16781
|
-
if (admitted.ticketNumber !== void 0) return admitted.ticketNumber;
|
|
16782
|
-
return readInvocationTicketNumber(runDirectory);
|
|
16783
|
-
}
|
|
16784
|
-
async function resolveTicketSeatMemoryNestDirectories(input) {
|
|
16785
|
-
if (input.seats.length === 0) return [];
|
|
16786
|
-
const admitted = await readRunAdmittedPageFacts(input.runDirectory);
|
|
16787
|
-
const ticketNumber = admitted.ticketNumber ?? await readInvocationTicketNumber(input.runDirectory);
|
|
16788
|
-
if (ticketNumber === void 0) return [];
|
|
16789
|
-
let home;
|
|
16790
|
-
try {
|
|
16791
|
-
home = homeFromRunDirectory(input.runDirectory);
|
|
16792
|
-
} catch {
|
|
16793
|
-
return [];
|
|
16794
|
-
}
|
|
16795
|
-
const projectRoot = admitted.projectRoot;
|
|
16796
|
-
if (projectRoot === void 0) return [];
|
|
16797
|
-
return input.seats.map(
|
|
16798
|
-
(seat) => ticketSeatMemorySessionDirectory({
|
|
16799
|
-
ticketNumber,
|
|
16800
|
-
seat,
|
|
16801
|
-
cwd: projectRoot,
|
|
16802
|
-
home
|
|
16803
|
-
})
|
|
16804
|
-
);
|
|
16805
|
-
}
|
|
16806
|
-
async function openTicketSeatMemoryCoordinates(input) {
|
|
16807
|
-
const createRecordSessionOpen = await loadCreateRecordSessionOpen();
|
|
16808
|
-
const opened = createRecordSessionOpen({
|
|
16809
|
-
cwd: input.cwd,
|
|
16810
|
-
kind: TICKET_SEAT_MEMORY_KIND,
|
|
16811
|
-
subject: ticketSeatMemorySubject(input.ticketNumber, input.seat),
|
|
16812
|
-
parent: {
|
|
16813
|
-
getSessionFile: () => input.ledgerAnchorSessionFile
|
|
16814
|
-
}
|
|
16815
|
-
});
|
|
16816
|
-
if (input.runId !== void 0) {
|
|
16817
|
-
const data = { version: 1, runId: input.runId };
|
|
16818
|
-
opened.session.appendCustomEntry(TICKET_SEAT_RUN_BINDING_ENTRY_TYPE, data);
|
|
16819
|
-
}
|
|
16820
|
-
const sessionFile = opened.session.getSessionFile();
|
|
16821
|
-
const sessionDirectory = opened.session.getSessionDir();
|
|
16822
|
-
if (typeof sessionFile !== "string" || sessionFile.length === 0) {
|
|
16823
|
-
throw new Error(
|
|
16824
|
-
`ticket-seat memory principal missing session file for ticket #${input.ticketNumber} seat ${input.seat}`
|
|
16825
|
-
);
|
|
16826
|
-
}
|
|
16827
|
-
if (typeof sessionDirectory !== "string" || sessionDirectory.length === 0) {
|
|
16828
|
-
throw new Error(
|
|
16829
|
-
`ticket-seat memory principal missing session directory for ticket #${input.ticketNumber} seat ${input.seat}`
|
|
16830
|
-
);
|
|
16831
|
-
}
|
|
16832
|
-
return { sessionDirectory, sessionFile, resumed: opened.resumed };
|
|
16833
|
-
}
|
|
16834
|
-
async function rebindAdmittedToTicketSeatMemory(input) {
|
|
16835
|
-
const ticketNumber = input.admitted.ticketNumber;
|
|
16836
|
-
if (ticketNumber === void 0) return void 0;
|
|
16837
|
-
const anchor = input.principalAuthority.decode(input.admitted.principal);
|
|
16838
|
-
const opened = await openTicketSeatMemoryCoordinates({
|
|
16839
|
-
ticketNumber,
|
|
16840
|
-
seat: input.seat,
|
|
16841
|
-
cwd: input.admitted.projectRoot,
|
|
16842
|
-
ledgerAnchorSessionFile: anchor.sessionFile,
|
|
16843
|
-
// Analyst attributes frame/model/tool to this binding interval only (#636 D).
|
|
16844
|
-
runId: input.admitted.runId
|
|
16845
|
-
});
|
|
16846
|
-
const coordinates = {
|
|
16847
|
-
sessionDirectory: opened.sessionDirectory,
|
|
16848
|
-
sessionFile: opened.sessionFile
|
|
16849
|
-
};
|
|
16850
|
-
const principal = input.principalAuthority.seal(coordinates);
|
|
16851
|
-
input.principalAuthority.decode(principal);
|
|
16852
|
-
input.admitted.principal = principal;
|
|
16853
|
-
for (const page of ["admitted-request.json", "invocation.json"]) {
|
|
16854
|
-
const path = join13(input.admitted.runDirectory, page);
|
|
16855
|
-
try {
|
|
16856
|
-
const raw = JSON.parse(await readFile5(path, "utf8"));
|
|
16857
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
16858
|
-
const next = {
|
|
16859
|
-
...raw,
|
|
16860
|
-
sessionDirectory: coordinates.sessionDirectory,
|
|
16861
|
-
sessionFile: coordinates.sessionFile
|
|
16862
|
-
};
|
|
16863
|
-
await writeFile4(path, `${JSON.stringify(next, null, 2)}
|
|
16864
|
-
`, "utf8");
|
|
16865
|
-
} catch (error) {
|
|
16866
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
16867
|
-
continue;
|
|
16868
|
-
}
|
|
16869
|
-
throw error;
|
|
16870
|
-
}
|
|
16871
|
-
}
|
|
16872
|
-
return { coordinates, resumed: opened.resumed };
|
|
16873
|
-
}
|
|
16874
|
-
async function readTicketSeatMemoryLastHost(sessionDirectory) {
|
|
16875
|
-
try {
|
|
16876
|
-
const raw = JSON.parse(
|
|
16877
|
-
await readFile5(join13(sessionDirectory, TICKET_SEAT_LAST_HOST_FILE), "utf8")
|
|
16878
|
-
);
|
|
16879
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw) || typeof raw.host !== "string" || raw.host.length === 0) {
|
|
16880
|
-
throw new Error(
|
|
16881
|
-
`ticket-seat memory last-host page is damaged under ${sessionDirectory}`
|
|
16882
|
-
);
|
|
16883
|
-
}
|
|
16884
|
-
const host = raw.host;
|
|
16885
|
-
const runDirectory = raw.runDirectory;
|
|
16886
|
-
return {
|
|
16887
|
-
host,
|
|
16888
|
-
...typeof runDirectory === "string" && runDirectory.length > 0 ? { runDirectory } : {}
|
|
16889
|
-
};
|
|
16890
|
-
} catch (error) {
|
|
16891
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
16892
|
-
return void 0;
|
|
16893
|
-
}
|
|
16894
|
-
throw error;
|
|
16895
|
-
}
|
|
16896
|
-
}
|
|
16897
|
-
async function writeTicketSeatMemoryLastHost(sessionDirectory, host, runDirectory) {
|
|
16898
|
-
if (host.trim() === "") {
|
|
16899
|
-
throw new Error("ticket-seat memory last-host requires a non-empty host");
|
|
16900
|
-
}
|
|
16901
|
-
const body = {
|
|
16902
|
-
host,
|
|
16903
|
-
...runDirectory !== void 0 && runDirectory.length > 0 ? { runDirectory } : {}
|
|
16904
|
-
};
|
|
16905
|
-
await writeFile4(
|
|
16906
|
-
join13(sessionDirectory, TICKET_SEAT_LAST_HOST_FILE),
|
|
16907
|
-
`${JSON.stringify(body, null, 2)}
|
|
16908
|
-
`,
|
|
16909
|
-
"utf8"
|
|
16910
|
-
);
|
|
16663
|
+
return await readPageTicketNumber(runDirectory, "admitted-request.json") ?? await readPageTicketNumber(runDirectory, "invocation.json");
|
|
16911
16664
|
}
|
|
16912
|
-
var
|
|
16913
|
-
|
|
16914
|
-
"src/ticket-seat-memory.ts"() {
|
|
16665
|
+
var init_run_ticket_number = __esm({
|
|
16666
|
+
"src/run-ticket-number.ts"() {
|
|
16915
16667
|
"use strict";
|
|
16916
|
-
init_activation_ledger_topology();
|
|
16917
|
-
init_archivist_record_topology();
|
|
16918
|
-
init_session_opening_materials();
|
|
16919
|
-
TICKET_SEAT_RUN_BINDING_ENTRY_TYPE = "ak_ticket_seat_run_binding";
|
|
16920
|
-
TICKET_SEAT_MEMORY_KIND = "auditor-roles";
|
|
16921
|
-
TICKET_SEAT_MEMORY_SEATS = ["inspector", "notary", "auditor"];
|
|
16922
|
-
TICKET_SEAT_LAST_HOST_FILE = "last-host.json";
|
|
16923
16668
|
}
|
|
16924
16669
|
});
|
|
16925
16670
|
|
|
@@ -17108,7 +16853,7 @@ var init_terminating_tools = __esm({
|
|
|
17108
16853
|
|
|
17109
16854
|
// src/doctor-evidence.ts
|
|
17110
16855
|
import { readdir, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
|
|
17111
|
-
import { dirname as
|
|
16856
|
+
import { dirname as dirname6, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
17112
16857
|
function record2(value) {
|
|
17113
16858
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17114
16859
|
}
|
|
@@ -17148,7 +16893,7 @@ async function stableRunsIdentity(root) {
|
|
|
17148
16893
|
} catch (error) {
|
|
17149
16894
|
if (!isMissingPathError(error)) throw error;
|
|
17150
16895
|
}
|
|
17151
|
-
const parent =
|
|
16896
|
+
const parent = dirname6(cursor);
|
|
17152
16897
|
if (parent === cursor) return root;
|
|
17153
16898
|
cursor = parent;
|
|
17154
16899
|
}
|
|
@@ -17258,7 +17003,7 @@ var init_doctor_evidence = __esm({
|
|
|
17258
17003
|
});
|
|
17259
17004
|
|
|
17260
17005
|
// src/collector-config.ts
|
|
17261
|
-
import { createHash as
|
|
17006
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
17262
17007
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
17263
17008
|
function fail3(message, cause) {
|
|
17264
17009
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
@@ -17297,7 +17042,7 @@ function canonicalManifest(requests) {
|
|
|
17297
17042
|
}
|
|
17298
17043
|
function emptyCollectorManifest() {
|
|
17299
17044
|
const canonicalJson2 = canonicalManifest([]);
|
|
17300
|
-
return { requests: [], canonicalJson: canonicalJson2, digest:
|
|
17045
|
+
return { requests: [], canonicalJson: canonicalJson2, digest: createHash3("sha256").update(canonicalJson2).digest("hex") };
|
|
17301
17046
|
}
|
|
17302
17047
|
async function loadCollectorManifest(path) {
|
|
17303
17048
|
let bytes;
|
|
@@ -17324,7 +17069,7 @@ async function loadCollectorManifest(path) {
|
|
|
17324
17069
|
requests.push({ id: item.id, requestBody: item.body });
|
|
17325
17070
|
}
|
|
17326
17071
|
const canonicalJson2 = canonicalManifest(requests);
|
|
17327
|
-
return { requests, canonicalJson: canonicalJson2, digest:
|
|
17072
|
+
return { requests, canonicalJson: canonicalJson2, digest: createHash3("sha256").update(canonicalJson2).digest("hex"), sourcePath: path };
|
|
17328
17073
|
}
|
|
17329
17074
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN, COLLECTOR_FIXED_KICKOFF;
|
|
17330
17075
|
var init_collector_config = __esm({
|
|
@@ -17437,10 +17182,10 @@ var init_uuidv7 = __esm({
|
|
|
17437
17182
|
});
|
|
17438
17183
|
|
|
17439
17184
|
// src/typed-provider-http.ts
|
|
17440
|
-
import { readFile as readFile8, unlink, writeFile as
|
|
17441
|
-
import { join as
|
|
17185
|
+
import { readFile as readFile8, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
17186
|
+
import { join as join12 } from "node:path";
|
|
17442
17187
|
function typedProviderHttpPath(runDirectory) {
|
|
17443
|
-
return
|
|
17188
|
+
return join12(runDirectory, TYPED_HTTP_FILE);
|
|
17444
17189
|
}
|
|
17445
17190
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
17446
17191
|
try {
|
|
@@ -17484,8 +17229,8 @@ var init_typed_provider_http = __esm({
|
|
|
17484
17229
|
});
|
|
17485
17230
|
|
|
17486
17231
|
// src/public-cli/run-lifecycle.ts
|
|
17487
|
-
import { chmod, open, readdir as readdir2, readFile as readFile9, unlink as unlink2, writeFile as
|
|
17488
|
-
import { join as
|
|
17232
|
+
import { chmod, open, readdir as readdir2, readFile as readFile9, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
|
|
17233
|
+
import { join as join13 } from "node:path";
|
|
17489
17234
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
17490
17235
|
const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
|
|
17491
17236
|
return appendEngineSessionMaterial([base], engineMaterial).join("\n");
|
|
@@ -17514,17 +17259,58 @@ function renderResumeCommand(runId) {
|
|
|
17514
17259
|
}
|
|
17515
17260
|
async function writeRoleRunState(runDirectory, record4) {
|
|
17516
17261
|
const payload = { ...record4, runDirectory };
|
|
17517
|
-
await
|
|
17518
|
-
|
|
17262
|
+
await writeFile5(
|
|
17263
|
+
join13(runDirectory, RUN_STATE_FILE),
|
|
17519
17264
|
`${JSON.stringify(payload, null, 2)}
|
|
17520
17265
|
`,
|
|
17521
17266
|
"utf8"
|
|
17522
17267
|
);
|
|
17523
17268
|
}
|
|
17269
|
+
function parseSameTicketSummonsMaterials(raw) {
|
|
17270
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
17271
|
+
const record4 = raw;
|
|
17272
|
+
const instruction = typeof record4.instruction === "string" ? record4.instruction : void 0;
|
|
17273
|
+
const instructionEmpty = typeof record4.instructionEmpty === "boolean" ? record4.instructionEmpty : void 0;
|
|
17274
|
+
const attachmentPaths = Array.isArray(record4.attachmentPaths) ? record4.attachmentPaths.filter((p) => typeof p === "string" && p.length > 0) : void 0;
|
|
17275
|
+
const sourceRunPath = typeof record4.sourceRunPath === "string" && record4.sourceRunPath.trim() !== "" ? record4.sourceRunPath : void 0;
|
|
17276
|
+
let sourceRun;
|
|
17277
|
+
if (record4.sourceRun !== null && typeof record4.sourceRun === "object" && !Array.isArray(record4.sourceRun)) {
|
|
17278
|
+
const sr = record4.sourceRun;
|
|
17279
|
+
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
17280
|
+
sourceRun = {
|
|
17281
|
+
runId: sr.runId,
|
|
17282
|
+
role: sr.role,
|
|
17283
|
+
runDirectory: sr.runDirectory
|
|
17284
|
+
};
|
|
17285
|
+
}
|
|
17286
|
+
}
|
|
17287
|
+
if (instruction === void 0 && instructionEmpty === void 0 && (attachmentPaths === void 0 || attachmentPaths.length === 0) && sourceRunPath === void 0 && sourceRun === void 0) {
|
|
17288
|
+
return void 0;
|
|
17289
|
+
}
|
|
17290
|
+
return {
|
|
17291
|
+
...instruction === void 0 ? {} : { instruction },
|
|
17292
|
+
...instructionEmpty === void 0 ? {} : { instructionEmpty },
|
|
17293
|
+
...attachmentPaths === void 0 || attachmentPaths.length === 0 ? {} : { attachmentPaths },
|
|
17294
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
17295
|
+
...sourceRun === void 0 ? {} : { sourceRun }
|
|
17296
|
+
};
|
|
17297
|
+
}
|
|
17298
|
+
function parseCurrentCourtState(raw) {
|
|
17299
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
17300
|
+
const record4 = raw;
|
|
17301
|
+
if (typeof record4.courtAttemptId !== "string" || record4.courtAttemptId.length === 0) {
|
|
17302
|
+
return void 0;
|
|
17303
|
+
}
|
|
17304
|
+
const summons = parseSameTicketSummonsMaterials(record4.summons);
|
|
17305
|
+
return {
|
|
17306
|
+
courtAttemptId: record4.courtAttemptId,
|
|
17307
|
+
...summons === void 0 ? {} : { summons }
|
|
17308
|
+
};
|
|
17309
|
+
}
|
|
17524
17310
|
async function readRoleRunStateDisk(runDirectory) {
|
|
17525
17311
|
let raw;
|
|
17526
17312
|
try {
|
|
17527
|
-
raw = JSON.parse(await readFile9(
|
|
17313
|
+
raw = JSON.parse(await readFile9(join13(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
17528
17314
|
} catch {
|
|
17529
17315
|
return void 0;
|
|
17530
17316
|
}
|
|
@@ -17560,6 +17346,7 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
17560
17346
|
}
|
|
17561
17347
|
}
|
|
17562
17348
|
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
17349
|
+
const currentCourt = parseCurrentCourtState(record4.currentCourt);
|
|
17563
17350
|
return {
|
|
17564
17351
|
runId: record4.runId,
|
|
17565
17352
|
role: record4.role,
|
|
@@ -17570,7 +17357,8 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
17570
17357
|
admittedRequestPath: record4.admittedRequestPath,
|
|
17571
17358
|
principalWire,
|
|
17572
17359
|
...phase === void 0 ? {} : { phase },
|
|
17573
|
-
...resumable === void 0 ? {} : { resumable }
|
|
17360
|
+
...resumable === void 0 ? {} : { resumable },
|
|
17361
|
+
...currentCourt === void 0 ? {} : { currentCourt }
|
|
17574
17362
|
};
|
|
17575
17363
|
}
|
|
17576
17364
|
async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
@@ -17585,10 +17373,11 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
17585
17373
|
...disk.principalWire.sessionFile === void 0 ? {} : { sessionFile: disk.principalWire.sessionFile },
|
|
17586
17374
|
admittedRequestPath: disk.admittedRequestPath,
|
|
17587
17375
|
...disk.phase === void 0 ? {} : { phase: disk.phase },
|
|
17588
|
-
...disk.resumable === void 0 ? {} : { resumable: disk.resumable }
|
|
17376
|
+
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
17377
|
+
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
17589
17378
|
};
|
|
17590
|
-
await
|
|
17591
|
-
|
|
17379
|
+
await writeFile5(
|
|
17380
|
+
join13(runDirectory, RUN_STATE_FILE),
|
|
17592
17381
|
`${JSON.stringify(payload, null, 2)}
|
|
17593
17382
|
`,
|
|
17594
17383
|
"utf8"
|
|
@@ -17663,7 +17452,8 @@ async function markRunRunning(runDirectory, effectiveModel, effectiveEngine, eff
|
|
|
17663
17452
|
runDirectory: current.runDirectory,
|
|
17664
17453
|
admittedRequestPath: current.admittedRequestPath,
|
|
17665
17454
|
principalWire: current.principalWire,
|
|
17666
|
-
...current.phase === void 0 ? {} : { phase: current.phase }
|
|
17455
|
+
...current.phase === void 0 ? {} : { phase: current.phase },
|
|
17456
|
+
...current.currentCourt === void 0 ? {} : { currentCourt: current.currentCourt }
|
|
17667
17457
|
});
|
|
17668
17458
|
}
|
|
17669
17459
|
async function markRunResumable(runDirectory, observation) {
|
|
@@ -17691,7 +17481,41 @@ async function markRunTerminal(runDirectory) {
|
|
|
17691
17481
|
runDirectory: current.runDirectory,
|
|
17692
17482
|
admittedRequestPath: current.admittedRequestPath,
|
|
17693
17483
|
principalWire: current.principalWire,
|
|
17694
|
-
...current.phase === void 0 ? {} : { phase: current.phase }
|
|
17484
|
+
...current.phase === void 0 ? {} : { phase: current.phase },
|
|
17485
|
+
...current.currentCourt === void 0 ? {} : { currentCourt: current.currentCourt }
|
|
17486
|
+
});
|
|
17487
|
+
}
|
|
17488
|
+
async function readCurrentCourt(runDirectory) {
|
|
17489
|
+
const current = await readRoleRunStateDisk(runDirectory);
|
|
17490
|
+
return current?.currentCourt;
|
|
17491
|
+
}
|
|
17492
|
+
async function recordCurrentCourt(runDirectory, court) {
|
|
17493
|
+
const current = await readRoleRunStateDisk(runDirectory);
|
|
17494
|
+
if (current === void 0) {
|
|
17495
|
+
throw new Error("cannot record current court: run state missing");
|
|
17496
|
+
}
|
|
17497
|
+
await writeRoleRunStateDisk(runDirectory, {
|
|
17498
|
+
...current,
|
|
17499
|
+
currentCourt: court
|
|
17500
|
+
});
|
|
17501
|
+
}
|
|
17502
|
+
async function clearCurrentCourt(runDirectory, expectedCourtAttemptId) {
|
|
17503
|
+
const current = await readRoleRunStateDisk(runDirectory);
|
|
17504
|
+
if (current === void 0 || current.currentCourt === void 0) return;
|
|
17505
|
+
if (expectedCourtAttemptId !== void 0 && current.currentCourt.courtAttemptId !== expectedCourtAttemptId) {
|
|
17506
|
+
return;
|
|
17507
|
+
}
|
|
17508
|
+
await writeRoleRunStateDisk(runDirectory, {
|
|
17509
|
+
runId: current.runId,
|
|
17510
|
+
role: current.role,
|
|
17511
|
+
state: current.state,
|
|
17512
|
+
bookKey: current.bookKey,
|
|
17513
|
+
projectRoot: current.projectRoot,
|
|
17514
|
+
runDirectory: current.runDirectory,
|
|
17515
|
+
admittedRequestPath: current.admittedRequestPath,
|
|
17516
|
+
principalWire: current.principalWire,
|
|
17517
|
+
...current.phase === void 0 ? {} : { phase: current.phase },
|
|
17518
|
+
...current.resumable === void 0 ? {} : { resumable: current.resumable }
|
|
17695
17519
|
});
|
|
17696
17520
|
}
|
|
17697
17521
|
async function isDurablePrincipalAvailable(principal, authority) {
|
|
@@ -17797,15 +17621,15 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
17797
17621
|
};
|
|
17798
17622
|
const reportCleanupFailure = (error) => {
|
|
17799
17623
|
reportDiagnostic(
|
|
17800
|
-
`writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${
|
|
17624
|
+
`writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
17801
17625
|
);
|
|
17802
17626
|
};
|
|
17803
17627
|
const reportReadFailure = (error) => {
|
|
17804
17628
|
reportDiagnostic(
|
|
17805
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
17629
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
17806
17630
|
);
|
|
17807
17631
|
};
|
|
17808
|
-
const lockPath =
|
|
17632
|
+
const lockPath = join13(runDirectory, WRITER_LOCK_FILE);
|
|
17809
17633
|
let lastAutopsy = { verdict: "absent" };
|
|
17810
17634
|
let lastReclaimFailure;
|
|
17811
17635
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -17855,7 +17679,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
17855
17679
|
async function findRunDirectoryById(home, runId) {
|
|
17856
17680
|
if (runId.trim() === "") return void 0;
|
|
17857
17681
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
17858
|
-
const booksRoot =
|
|
17682
|
+
const booksRoot = join13(ledgerHome, "books");
|
|
17859
17683
|
let bookKeys;
|
|
17860
17684
|
try {
|
|
17861
17685
|
bookKeys = await readdir2(booksRoot);
|
|
@@ -17863,7 +17687,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17863
17687
|
return void 0;
|
|
17864
17688
|
}
|
|
17865
17689
|
for (const bookKey of bookKeys) {
|
|
17866
|
-
const runsDir =
|
|
17690
|
+
const runsDir = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
17867
17691
|
let entries;
|
|
17868
17692
|
try {
|
|
17869
17693
|
entries = await readdir2(runsDir);
|
|
@@ -17872,12 +17696,37 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17872
17696
|
}
|
|
17873
17697
|
for (const entry of entries) {
|
|
17874
17698
|
if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
|
|
17875
|
-
return
|
|
17699
|
+
return join13(runsDir, entry);
|
|
17876
17700
|
}
|
|
17877
17701
|
}
|
|
17878
17702
|
}
|
|
17879
17703
|
return void 0;
|
|
17880
17704
|
}
|
|
17705
|
+
async function findLatestRunIdForSeatTicket(input) {
|
|
17706
|
+
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
17707
|
+
const runsDir = join13(
|
|
17708
|
+
activationBookDirectory(ledgerHome, input.bookKey),
|
|
17709
|
+
"runs"
|
|
17710
|
+
);
|
|
17711
|
+
let entries;
|
|
17712
|
+
try {
|
|
17713
|
+
entries = await readdir2(runsDir);
|
|
17714
|
+
} catch (error) {
|
|
17715
|
+
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
17716
|
+
throw error;
|
|
17717
|
+
}
|
|
17718
|
+
const suffix = `@${input.role}`;
|
|
17719
|
+
let best;
|
|
17720
|
+
for (const entry of entries) {
|
|
17721
|
+
if (!entry.endsWith(suffix)) continue;
|
|
17722
|
+
const runId = entry.slice(0, entry.length - suffix.length);
|
|
17723
|
+
if (runId.length === 0) continue;
|
|
17724
|
+
const ticketNumber = await readRunTicketNumber(join13(runsDir, entry));
|
|
17725
|
+
if (ticketNumber !== input.ticketNumber) continue;
|
|
17726
|
+
if (best === void 0 || runId > best) best = runId;
|
|
17727
|
+
}
|
|
17728
|
+
return best;
|
|
17729
|
+
}
|
|
17881
17730
|
function parsePersistedTicketIdentity(record4) {
|
|
17882
17731
|
const correlationId = typeof record4.correlationId === "string" && record4.correlationId.trim() !== "" ? record4.correlationId : void 0;
|
|
17883
17732
|
const ticketNumber = typeof record4.ticketNumber === "number" && Number.isSafeInteger(record4.ticketNumber) && record4.ticketNumber >= 1 ? record4.ticketNumber : void 0;
|
|
@@ -18054,7 +17903,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
18054
17903
|
let model;
|
|
18055
17904
|
try {
|
|
18056
17905
|
const invocationRaw = JSON.parse(
|
|
18057
|
-
await readFile9(
|
|
17906
|
+
await readFile9(join13(run.runDirectory, "invocation.json"), "utf8")
|
|
18058
17907
|
);
|
|
18059
17908
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
18060
17909
|
const rec = invocationRaw;
|
|
@@ -18422,6 +18271,7 @@ var init_run_lifecycle = __esm({
|
|
|
18422
18271
|
"src/public-cli/run-lifecycle.ts"() {
|
|
18423
18272
|
"use strict";
|
|
18424
18273
|
init_activation_ledger_topology();
|
|
18274
|
+
init_run_ticket_number();
|
|
18425
18275
|
init_cli_errors();
|
|
18426
18276
|
init_typed_provider_http();
|
|
18427
18277
|
init_typed_provider_http();
|
|
@@ -18445,7 +18295,7 @@ var init_run_lifecycle = __esm({
|
|
|
18445
18295
|
});
|
|
18446
18296
|
|
|
18447
18297
|
// src/notary-source-run.ts
|
|
18448
|
-
import { dirname as
|
|
18298
|
+
import { dirname as dirname7, isAbsolute as isAbsolute4, join as join14, resolve as resolve6, basename as basename4 } from "node:path";
|
|
18449
18299
|
import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
|
|
18450
18300
|
function parseRunDirectoryName(name) {
|
|
18451
18301
|
const match = RUN_DIR_NAME.exec(name);
|
|
@@ -18491,18 +18341,18 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
18491
18341
|
}
|
|
18492
18342
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
18493
18343
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
18494
|
-
const bookRunsRoot =
|
|
18344
|
+
const bookRunsRoot = join14(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
18495
18345
|
let candidate;
|
|
18496
18346
|
const bare = parseRunDirectoryName(raw);
|
|
18497
18347
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
18498
|
-
candidate =
|
|
18348
|
+
candidate = join14(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
18499
18349
|
} else {
|
|
18500
18350
|
candidate = isAbsolute4(raw) ? raw : resolve6(options.projectRoot, raw);
|
|
18501
18351
|
}
|
|
18502
18352
|
const real = await requireRunDirectory(candidate, raw);
|
|
18503
18353
|
const identity = parseRunDirectoryName(basename4(real));
|
|
18504
18354
|
const runsRootIdentity = physicalPathIdentity(bookRunsRoot);
|
|
18505
|
-
const parentIdentity = physicalPathIdentity(
|
|
18355
|
+
const parentIdentity = physicalPathIdentity(dirname7(real));
|
|
18506
18356
|
if (parentIdentity !== runsRootIdentity) {
|
|
18507
18357
|
throw new NotarySourceRunError(
|
|
18508
18358
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
@@ -19526,13 +19376,13 @@ import {
|
|
|
19526
19376
|
mkdir as mkdir2,
|
|
19527
19377
|
readFile as readFile10,
|
|
19528
19378
|
realpath as realpath4,
|
|
19529
|
-
writeFile as
|
|
19379
|
+
writeFile as writeFile6
|
|
19530
19380
|
} from "node:fs/promises";
|
|
19531
|
-
import { basename as basename5, isAbsolute as isAbsolute5, join as
|
|
19381
|
+
import { basename as basename5, isAbsolute as isAbsolute5, join as join15, resolve as resolve7, sep as sep3 } from "node:path";
|
|
19532
19382
|
function issueAdmissionPlacement(authority, request) {
|
|
19533
19383
|
const principal = authority.issue(request);
|
|
19534
19384
|
const { sessionDirectory, sessionFile } = authority.decode(principal);
|
|
19535
|
-
const runDirectory =
|
|
19385
|
+
const runDirectory = join15(sessionDirectory, "..");
|
|
19536
19386
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
19537
19387
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
19538
19388
|
return {
|
|
@@ -19551,7 +19401,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
19551
19401
|
sessionDirectory: coordinates.sessionDirectory,
|
|
19552
19402
|
sessionFile: coordinates.sessionFile
|
|
19553
19403
|
};
|
|
19554
|
-
await
|
|
19404
|
+
await writeFile6(
|
|
19555
19405
|
admittedRequestPath,
|
|
19556
19406
|
`${JSON.stringify(projection, null, 2)}
|
|
19557
19407
|
`,
|
|
@@ -19579,8 +19429,8 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19579
19429
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
19580
19430
|
...effectiveModelLedgerFields(effectiveModel)
|
|
19581
19431
|
};
|
|
19582
|
-
await
|
|
19583
|
-
|
|
19432
|
+
await writeFile6(
|
|
19433
|
+
join15(source.runDirectory, "invocation.json"),
|
|
19584
19434
|
`${JSON.stringify(identity, null, 2)}
|
|
19585
19435
|
`,
|
|
19586
19436
|
"utf8"
|
|
@@ -19591,7 +19441,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19591
19441
|
await writeInstitutionalResolutionPage(source.runDirectory, institutionalPage);
|
|
19592
19442
|
}
|
|
19593
19443
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host) {
|
|
19594
|
-
const ledgerPath =
|
|
19444
|
+
const ledgerPath = join15(runDirectory, "invocation.json");
|
|
19595
19445
|
const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
|
|
19596
19446
|
const next = { ...current };
|
|
19597
19447
|
if (model !== void 0) {
|
|
@@ -19611,7 +19461,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host)
|
|
|
19611
19461
|
if (host !== void 0) {
|
|
19612
19462
|
next.host = host;
|
|
19613
19463
|
}
|
|
19614
|
-
await
|
|
19464
|
+
await writeFile6(
|
|
19615
19465
|
ledgerPath,
|
|
19616
19466
|
`${JSON.stringify(next, null, 2)}
|
|
19617
19467
|
`,
|
|
@@ -19628,9 +19478,9 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host)
|
|
|
19628
19478
|
await writeInstitutionalResolutionPage(runDirectory, institutionalPage);
|
|
19629
19479
|
}
|
|
19630
19480
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
19631
|
-
const ledgerPath =
|
|
19481
|
+
const ledgerPath = join15(runDirectory, "invocation.json");
|
|
19632
19482
|
const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
|
|
19633
|
-
await
|
|
19483
|
+
await writeFile6(
|
|
19634
19484
|
ledgerPath,
|
|
19635
19485
|
`${JSON.stringify({
|
|
19636
19486
|
...current,
|
|
@@ -19659,7 +19509,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
19659
19509
|
await mergeInvocationIdentityPage(admitted.runDirectory, { ticketNumber });
|
|
19660
19510
|
const admittedPath = admitted.admittedRequestPath;
|
|
19661
19511
|
const current = JSON.parse(await readFile10(admittedPath, "utf8"));
|
|
19662
|
-
await
|
|
19512
|
+
await writeFile6(
|
|
19663
19513
|
admittedPath,
|
|
19664
19514
|
`${JSON.stringify({ ...current, ticketNumber }, null, 2)}
|
|
19665
19515
|
`,
|
|
@@ -19679,7 +19529,7 @@ async function recordTrueUnboundTicketResolution(admitted) {
|
|
|
19679
19529
|
});
|
|
19680
19530
|
const admittedPath = admitted.admittedRequestPath;
|
|
19681
19531
|
const current = JSON.parse(await readFile10(admittedPath, "utf8"));
|
|
19682
|
-
await
|
|
19532
|
+
await writeFile6(
|
|
19683
19533
|
admittedPath,
|
|
19684
19534
|
`${JSON.stringify({ ...current, ticketResolution: "true-unbound" }, null, 2)}
|
|
19685
19535
|
`,
|
|
@@ -19695,7 +19545,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
19695
19545
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
19696
19546
|
const rolePackageRoot = packageRoot2;
|
|
19697
19547
|
const raw = JSON.parse(
|
|
19698
|
-
await readFile10(
|
|
19548
|
+
await readFile10(join15(rolePackageRoot, "package.json"), "utf8")
|
|
19699
19549
|
);
|
|
19700
19550
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
19701
19551
|
throw new Error(
|
|
@@ -19914,8 +19764,8 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
19914
19764
|
}
|
|
19915
19765
|
const bytes = await readFile10(absolute);
|
|
19916
19766
|
const name = `${String(index).padStart(2, "0")}-${basename5(absolute)}`;
|
|
19917
|
-
const frozenPath =
|
|
19918
|
-
await
|
|
19767
|
+
const frozenPath = join15(destinationDir, name);
|
|
19768
|
+
await writeFile6(frozenPath, bytes);
|
|
19919
19769
|
return {
|
|
19920
19770
|
attachment: {
|
|
19921
19771
|
provenancePath: absolute,
|
|
@@ -19939,8 +19789,12 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
19939
19789
|
}
|
|
19940
19790
|
return attachments;
|
|
19941
19791
|
}
|
|
19942
|
-
async function
|
|
19943
|
-
|
|
19792
|
+
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
19793
|
+
if (attachmentPaths.length === 0) return [];
|
|
19794
|
+
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
19795
|
+
const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
|
|
19796
|
+
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
19797
|
+
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
19944
19798
|
}
|
|
19945
19799
|
function ticketAdmissionFields(ticketNumber) {
|
|
19946
19800
|
return ticketNumber === void 0 ? {} : { ticketNumber };
|
|
@@ -19964,7 +19818,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
19964
19818
|
role,
|
|
19965
19819
|
home: options.home
|
|
19966
19820
|
});
|
|
19967
|
-
const attachmentsDirectory =
|
|
19821
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
19968
19822
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
19969
19823
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
19970
19824
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -19989,7 +19843,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
19989
19843
|
mediaKind: a.mediaKind
|
|
19990
19844
|
}))
|
|
19991
19845
|
};
|
|
19992
|
-
const admittedRequestPath =
|
|
19846
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
19993
19847
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
19994
19848
|
sessionDirectory,
|
|
19995
19849
|
sessionFile
|
|
@@ -20061,7 +19915,7 @@ async function admitCountersignInvocation(options) {
|
|
|
20061
19915
|
role: "countersign",
|
|
20062
19916
|
home: options.home
|
|
20063
19917
|
});
|
|
20064
|
-
const attachmentsDirectory =
|
|
19918
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
20065
19919
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20066
19920
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20067
19921
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -20085,7 +19939,7 @@ async function admitCountersignInvocation(options) {
|
|
|
20085
19939
|
mediaKind: a.mediaKind
|
|
20086
19940
|
}))
|
|
20087
19941
|
};
|
|
20088
|
-
const admittedRequestPath =
|
|
19942
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20089
19943
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20090
19944
|
sessionDirectory,
|
|
20091
19945
|
sessionFile
|
|
@@ -20109,7 +19963,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
20109
19963
|
return buildInstructionTransportPrompt(admitted, engineMaterial);
|
|
20110
19964
|
}
|
|
20111
19965
|
async function ensureRunArtifactsDir(runDirectory) {
|
|
20112
|
-
const dir =
|
|
19966
|
+
const dir = join15(runDirectory, "artifacts");
|
|
20113
19967
|
await mkdir2(dir, { recursive: true });
|
|
20114
19968
|
return dir;
|
|
20115
19969
|
}
|
|
@@ -20141,12 +19995,12 @@ async function admitCoderInvocation(options) {
|
|
|
20141
19995
|
role: "coder",
|
|
20142
19996
|
home: options.home
|
|
20143
19997
|
});
|
|
20144
|
-
const attachmentsDirectory =
|
|
19998
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
20145
19999
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20146
20000
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20147
20001
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
20148
|
-
const taskPath =
|
|
20149
|
-
await
|
|
20002
|
+
const taskPath = join15(runDirectory, "task.md");
|
|
20003
|
+
await writeFile6(taskPath, instruction, "utf8");
|
|
20150
20004
|
const admitted = {
|
|
20151
20005
|
role: "coder",
|
|
20152
20006
|
phase: options.phase,
|
|
@@ -20166,7 +20020,7 @@ async function admitCoderInvocation(options) {
|
|
|
20166
20020
|
mediaKind: a.mediaKind
|
|
20167
20021
|
}))
|
|
20168
20022
|
};
|
|
20169
|
-
const admittedRequestPath =
|
|
20023
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20170
20024
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20171
20025
|
sessionDirectory,
|
|
20172
20026
|
sessionFile
|
|
@@ -20247,22 +20101,22 @@ async function admitFixerInvocation(options) {
|
|
|
20247
20101
|
role: "fixer",
|
|
20248
20102
|
home: options.home
|
|
20249
20103
|
});
|
|
20250
|
-
const attachmentsDirectory =
|
|
20104
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
20251
20105
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20252
20106
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20253
20107
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
20254
20108
|
let prerequisitesPath;
|
|
20255
20109
|
if (prerequisitesSource !== void 0) {
|
|
20256
|
-
prerequisitesPath =
|
|
20257
|
-
await
|
|
20110
|
+
prerequisitesPath = join15(runDirectory, "prerequisites.json");
|
|
20111
|
+
await writeFile6(
|
|
20258
20112
|
prerequisitesPath,
|
|
20259
20113
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
20260
20114
|
`,
|
|
20261
20115
|
"utf8"
|
|
20262
20116
|
);
|
|
20263
20117
|
}
|
|
20264
|
-
const packetPath =
|
|
20265
|
-
await
|
|
20118
|
+
const packetPath = join15(runDirectory, "fix-packet.md");
|
|
20119
|
+
await writeFile6(packetPath, instruction, "utf8");
|
|
20266
20120
|
const admitted = {
|
|
20267
20121
|
role: "fixer",
|
|
20268
20122
|
phase: options.phase,
|
|
@@ -20287,7 +20141,7 @@ async function admitFixerInvocation(options) {
|
|
|
20287
20141
|
mediaKind: a.mediaKind
|
|
20288
20142
|
}))
|
|
20289
20143
|
};
|
|
20290
|
-
const admittedRequestPath =
|
|
20144
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20291
20145
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20292
20146
|
sessionDirectory,
|
|
20293
20147
|
sessionFile
|
|
@@ -20496,14 +20350,14 @@ async function admitCollectorInvocation(options) {
|
|
|
20496
20350
|
role: "collector",
|
|
20497
20351
|
home: options.home
|
|
20498
20352
|
});
|
|
20499
|
-
const attachmentsDirectory =
|
|
20353
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
20500
20354
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20501
20355
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20502
20356
|
const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
|
|
20503
20357
|
let requestManifestPath;
|
|
20504
20358
|
if (manifestCanonicalJson !== void 0) {
|
|
20505
|
-
requestManifestPath =
|
|
20506
|
-
await
|
|
20359
|
+
requestManifestPath = join15(runDirectory, "request-manifest.json");
|
|
20360
|
+
await writeFile6(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
20507
20361
|
}
|
|
20508
20362
|
const instruction = options.instruction ?? "";
|
|
20509
20363
|
const instructionEmpty = instruction.trim() === "";
|
|
@@ -20529,7 +20383,7 @@ async function admitCollectorInvocation(options) {
|
|
|
20529
20383
|
mediaKind: a.mediaKind
|
|
20530
20384
|
}))
|
|
20531
20385
|
};
|
|
20532
|
-
const admittedRequestPath =
|
|
20386
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20533
20387
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20534
20388
|
sessionDirectory,
|
|
20535
20389
|
sessionFile
|
|
@@ -20626,7 +20480,7 @@ function parseDoctorArgv(args) {
|
|
|
20626
20480
|
}
|
|
20627
20481
|
async function resolveDoctorCaseRunsPath(options) {
|
|
20628
20482
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
20629
|
-
const defaultRuns =
|
|
20483
|
+
const defaultRuns = join15(
|
|
20630
20484
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
20631
20485
|
"issues",
|
|
20632
20486
|
String(options.issueNumber),
|
|
@@ -20733,7 +20587,7 @@ async function admitDoctorInvocation(options) {
|
|
|
20733
20587
|
{ cause: error }
|
|
20734
20588
|
);
|
|
20735
20589
|
}
|
|
20736
|
-
const attachmentsDirectory =
|
|
20590
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
20737
20591
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20738
20592
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20739
20593
|
const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
|
|
@@ -20759,7 +20613,7 @@ async function admitDoctorInvocation(options) {
|
|
|
20759
20613
|
mediaKind: a.mediaKind
|
|
20760
20614
|
}))
|
|
20761
20615
|
};
|
|
20762
|
-
const admittedRequestPath =
|
|
20616
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20763
20617
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20764
20618
|
sessionDirectory,
|
|
20765
20619
|
sessionFile
|
|
@@ -20874,7 +20728,7 @@ async function admitNotaryInvocation(options) {
|
|
|
20874
20728
|
});
|
|
20875
20729
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20876
20730
|
const ticketFields = ticketAdmissionFields(
|
|
20877
|
-
await
|
|
20731
|
+
await readRunTicketNumber(sourceRun.runDirectory)
|
|
20878
20732
|
);
|
|
20879
20733
|
const admitted = {
|
|
20880
20734
|
role: "notary",
|
|
@@ -20891,7 +20745,7 @@ async function admitNotaryInvocation(options) {
|
|
|
20891
20745
|
...ticketFields,
|
|
20892
20746
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
20893
20747
|
};
|
|
20894
|
-
const admittedRequestPath =
|
|
20748
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20895
20749
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20896
20750
|
sessionDirectory,
|
|
20897
20751
|
sessionFile
|
|
@@ -20993,7 +20847,7 @@ async function admitGleanerLeftInvocation(options) {
|
|
|
20993
20847
|
attachments: [],
|
|
20994
20848
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
20995
20849
|
};
|
|
20996
|
-
const admittedRequestPath =
|
|
20850
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
20997
20851
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20998
20852
|
sessionDirectory,
|
|
20999
20853
|
sessionFile
|
|
@@ -21098,7 +20952,7 @@ async function admitReviewerInvocation(options) {
|
|
|
21098
20952
|
role: "reviewer",
|
|
21099
20953
|
home: options.home
|
|
21100
20954
|
});
|
|
21101
|
-
const attachmentsDirectory =
|
|
20955
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
21102
20956
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
21103
20957
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21104
20958
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -21123,7 +20977,7 @@ async function admitReviewerInvocation(options) {
|
|
|
21123
20977
|
mediaKind: a.mediaKind
|
|
21124
20978
|
}))
|
|
21125
20979
|
};
|
|
21126
|
-
const admittedRequestPath =
|
|
20980
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
21127
20981
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21128
20982
|
sessionDirectory,
|
|
21129
20983
|
sessionFile
|
|
@@ -21250,7 +21104,7 @@ async function admitMergerInvocation(options) {
|
|
|
21250
21104
|
role: "merger",
|
|
21251
21105
|
home: options.home
|
|
21252
21106
|
});
|
|
21253
|
-
const attachmentsDirectory =
|
|
21107
|
+
const attachmentsDirectory = join15(runDirectory, "attachments");
|
|
21254
21108
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
21255
21109
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21256
21110
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -21278,8 +21132,8 @@ async function admitMergerInvocation(options) {
|
|
|
21278
21132
|
// Authorized checks remain available on the assignment; default none.
|
|
21279
21133
|
authorizedChecks: []
|
|
21280
21134
|
});
|
|
21281
|
-
const mergerInputPath =
|
|
21282
|
-
await
|
|
21135
|
+
const mergerInputPath = join15(runDirectory, "merger-input.json");
|
|
21136
|
+
await writeFile6(
|
|
21283
21137
|
mergerInputPath,
|
|
21284
21138
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
21285
21139
|
`,
|
|
@@ -21310,7 +21164,7 @@ async function admitMergerInvocation(options) {
|
|
|
21310
21164
|
mediaKind: a.mediaKind
|
|
21311
21165
|
}))
|
|
21312
21166
|
};
|
|
21313
|
-
const admittedRequestPath =
|
|
21167
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
21314
21168
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21315
21169
|
sessionDirectory,
|
|
21316
21170
|
sessionFile
|
|
@@ -21570,7 +21424,7 @@ var init_invocation = __esm({
|
|
|
21570
21424
|
"use strict";
|
|
21571
21425
|
init_activation_ledger_topology();
|
|
21572
21426
|
init_activation_ledger_git();
|
|
21573
|
-
|
|
21427
|
+
init_run_ticket_number();
|
|
21574
21428
|
init_doctor_evidence();
|
|
21575
21429
|
init_collector_config();
|
|
21576
21430
|
init_fixer_packet();
|
|
@@ -21601,13 +21455,13 @@ var init_invocation = __esm({
|
|
|
21601
21455
|
});
|
|
21602
21456
|
|
|
21603
21457
|
// src/package-resources/method-skill.ts
|
|
21604
|
-
import { createHash as
|
|
21458
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
21605
21459
|
import { readFile as readFile11, realpath as realpath5 } from "node:fs/promises";
|
|
21606
|
-
import { join as
|
|
21460
|
+
import { join as join16 } from "node:path";
|
|
21607
21461
|
function gitBlobOid(bytes) {
|
|
21608
21462
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
21609
21463
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
21610
|
-
return
|
|
21464
|
+
return createHash4("sha1").update(header).update(body).digest("hex");
|
|
21611
21465
|
}
|
|
21612
21466
|
function stripSkillFrontmatter(content) {
|
|
21613
21467
|
if (!content.startsWith("---")) return content;
|
|
@@ -21620,10 +21474,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
21620
21474
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
21621
21475
|
}
|
|
21622
21476
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
21623
|
-
return
|
|
21477
|
+
return join16(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
21624
21478
|
}
|
|
21625
21479
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
21626
|
-
return
|
|
21480
|
+
return join16(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
21627
21481
|
}
|
|
21628
21482
|
function isRecord8(value) {
|
|
21629
21483
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -21717,8 +21571,8 @@ function parseProvenance(raw, expectedName) {
|
|
|
21717
21571
|
}
|
|
21718
21572
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
21719
21573
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
21720
|
-
const skillPathConfigured =
|
|
21721
|
-
const provenancePath =
|
|
21574
|
+
const skillPathConfigured = join16(rootDirectory, "SKILL.md");
|
|
21575
|
+
const provenancePath = join16(rootDirectory, "provenance.json");
|
|
21722
21576
|
let provenanceRaw;
|
|
21723
21577
|
try {
|
|
21724
21578
|
provenanceRaw = await readFile11(provenancePath, "utf8");
|
|
@@ -21735,7 +21589,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
21735
21589
|
}
|
|
21736
21590
|
const provenance = parseProvenance(provenanceJson, name);
|
|
21737
21591
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
21738
|
-
const absolute =
|
|
21592
|
+
const absolute = join16(rootDirectory, rel);
|
|
21739
21593
|
let bytes;
|
|
21740
21594
|
try {
|
|
21741
21595
|
bytes = await readFile11(absolute);
|
|
@@ -21982,7 +21836,7 @@ function normalizeReviewComment(raw) {
|
|
|
21982
21836
|
function createGhApiRunner(options = {}) {
|
|
21983
21837
|
const spawnImpl = options.spawnImpl ?? spawn3;
|
|
21984
21838
|
return async (args, runOptions = {}) => {
|
|
21985
|
-
return await new Promise((
|
|
21839
|
+
return await new Promise((resolve12, reject) => {
|
|
21986
21840
|
const signal = runOptions.signal;
|
|
21987
21841
|
if (signal?.aborted) {
|
|
21988
21842
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -22055,11 +21909,11 @@ function createGhApiRunner(options = {}) {
|
|
|
22055
21909
|
const value = line2.slice(idx + 1).trim();
|
|
22056
21910
|
headers[name] = value;
|
|
22057
21911
|
}
|
|
22058
|
-
|
|
21912
|
+
resolve12({ status, headers, bodyText });
|
|
22059
21913
|
return;
|
|
22060
21914
|
}
|
|
22061
21915
|
if (code === 0) {
|
|
22062
|
-
|
|
21916
|
+
resolve12({ status: 200, headers: {}, bodyText: stdout });
|
|
22063
21917
|
return;
|
|
22064
21918
|
}
|
|
22065
21919
|
const failure = new Error(
|
|
@@ -22288,11 +22142,11 @@ var init_collector_github = __esm({
|
|
|
22288
22142
|
});
|
|
22289
22143
|
|
|
22290
22144
|
// src/diarist-ticket-resolution.ts
|
|
22291
|
-
import { existsSync as
|
|
22292
|
-
import { join as
|
|
22293
|
-
import { fileURLToPath
|
|
22294
|
-
function resolveDiaristResolveTicketMethodPath(packageRoot2 =
|
|
22295
|
-
return
|
|
22145
|
+
import { existsSync as existsSync6, readFileSync as readFileSync2 } from "node:fs";
|
|
22146
|
+
import { join as join17 } from "node:path";
|
|
22147
|
+
import { fileURLToPath } from "node:url";
|
|
22148
|
+
function resolveDiaristResolveTicketMethodPath(packageRoot2 = fileURLToPath(new URL("..", import.meta.url))) {
|
|
22149
|
+
return join17(packageRoot2, DIARIST_RESOLVE_TICKET_METHOD_RELATIVE);
|
|
22296
22150
|
}
|
|
22297
22151
|
function instructionContainsTicketNumber(instruction, ticketNumber) {
|
|
22298
22152
|
if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) return false;
|
|
@@ -22341,7 +22195,7 @@ function parseDiaristTicketResolverStdout(stdout) {
|
|
|
22341
22195
|
}
|
|
22342
22196
|
function createHermesDiaristTicketResolver(options = {}) {
|
|
22343
22197
|
const methodPath = resolveDiaristResolveTicketMethodPath(options.packageRoot);
|
|
22344
|
-
if (!
|
|
22198
|
+
if (!existsSync6(methodPath)) {
|
|
22345
22199
|
throw new Error(`diarist resolve-ticket method material missing (${methodPath})`);
|
|
22346
22200
|
}
|
|
22347
22201
|
const method = readFileSync2(methodPath, "utf8");
|
|
@@ -22513,9 +22367,9 @@ var init_adr_path_refs = __esm({
|
|
|
22513
22367
|
});
|
|
22514
22368
|
|
|
22515
22369
|
// src/diarist-mechanical.ts
|
|
22516
|
-
import { createHash as
|
|
22517
|
-
import { existsSync as
|
|
22518
|
-
import { basename as basename6, join as
|
|
22370
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
22371
|
+
import { existsSync as existsSync7, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
|
|
22372
|
+
import { basename as basename6, join as join18, resolve as resolve8 } from "node:path";
|
|
22519
22373
|
import { homedir } from "node:os";
|
|
22520
22374
|
function extractCornerQuotes(text, minLength = DEFAULT_QUOTE_MIN) {
|
|
22521
22375
|
const out = [];
|
|
@@ -22553,7 +22407,7 @@ function blockKey(block) {
|
|
|
22553
22407
|
r.entryId === void 0 ? "" : String(r.entryId),
|
|
22554
22408
|
r.path ?? "",
|
|
22555
22409
|
r.url ?? "",
|
|
22556
|
-
|
|
22410
|
+
createHash5("sha256").update(block.transcript, "utf8").digest("hex").slice(0, 16)
|
|
22557
22411
|
].join("|");
|
|
22558
22412
|
}
|
|
22559
22413
|
function dedupeSourceBlocks(blocks) {
|
|
@@ -22619,20 +22473,20 @@ function isNotificationRow(type, text) {
|
|
|
22619
22473
|
return false;
|
|
22620
22474
|
}
|
|
22621
22475
|
function readCcSessionBlocks(options) {
|
|
22622
|
-
const root = options.projectsRoot ??
|
|
22623
|
-
if (!
|
|
22476
|
+
const root = options.projectsRoot ?? join18(homedir(), ".claude", "projects");
|
|
22477
|
+
if (!existsSync7(root)) return [];
|
|
22624
22478
|
const blocks = [];
|
|
22625
22479
|
const dirs = /* @__PURE__ */ new Set();
|
|
22626
22480
|
for (const cwd of options.cwds) {
|
|
22627
|
-
dirs.add(
|
|
22481
|
+
dirs.add(join18(root, encodeClaudeProjectDir(cwd)));
|
|
22628
22482
|
}
|
|
22629
22483
|
for (const cwd of options.cwds) {
|
|
22630
22484
|
if (cwd.includes("projects")) continue;
|
|
22631
|
-
const direct =
|
|
22632
|
-
if (
|
|
22485
|
+
const direct = join18(root, cwd);
|
|
22486
|
+
if (existsSync7(direct)) dirs.add(direct);
|
|
22633
22487
|
}
|
|
22634
22488
|
for (const dir of dirs) {
|
|
22635
|
-
if (!
|
|
22489
|
+
if (!existsSync7(dir)) continue;
|
|
22636
22490
|
let dirStat;
|
|
22637
22491
|
try {
|
|
22638
22492
|
dirStat = statSync2(dir);
|
|
@@ -22657,7 +22511,7 @@ function readCcSessionBlocks(options) {
|
|
|
22657
22511
|
);
|
|
22658
22512
|
}
|
|
22659
22513
|
for (const name of files) {
|
|
22660
|
-
const sessionFile =
|
|
22514
|
+
const sessionFile = join18(dir, name);
|
|
22661
22515
|
let text;
|
|
22662
22516
|
try {
|
|
22663
22517
|
text = readFileSync3(sessionFile, "utf8");
|
|
@@ -22757,7 +22611,7 @@ function readAdrDecisionKeyBlocks(input) {
|
|
|
22757
22611
|
const adrRootAbs = resolve8(cwdAbs, DIARIST_ADR_ROOT_REL);
|
|
22758
22612
|
let adrRootReal;
|
|
22759
22613
|
try {
|
|
22760
|
-
adrRootReal =
|
|
22614
|
+
adrRootReal = existsSync7(adrRootAbs) ? realpathSync3(adrRootAbs) : resolve8(realpathSync3(cwdAbs), DIARIST_ADR_ROOT_REL);
|
|
22761
22615
|
} catch (error) {
|
|
22762
22616
|
throw new DiaristSourceReadError(
|
|
22763
22617
|
"adr-unreadable",
|
|
@@ -22783,7 +22637,7 @@ function readAdrDecisionKeyBlocks(input) {
|
|
|
22783
22637
|
`diarist referenced ADR escapes docs/adr (${rel})`
|
|
22784
22638
|
);
|
|
22785
22639
|
}
|
|
22786
|
-
if (!
|
|
22640
|
+
if (!existsSync7(abs)) {
|
|
22787
22641
|
throw new DiaristSourceReadError(
|
|
22788
22642
|
"adr-missing",
|
|
22789
22643
|
abs,
|
|
@@ -22885,11 +22739,11 @@ var init_diarist_mechanical = __esm({
|
|
|
22885
22739
|
});
|
|
22886
22740
|
|
|
22887
22741
|
// src/diarist-llm-collector.ts
|
|
22888
|
-
import { existsSync as
|
|
22889
|
-
import { join as
|
|
22890
|
-
import { fileURLToPath as
|
|
22891
|
-
function resolveDiaristCollectMethodPath(packageRoot2 =
|
|
22892
|
-
return
|
|
22742
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
22743
|
+
import { join as join19 } from "node:path";
|
|
22744
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22745
|
+
function resolveDiaristCollectMethodPath(packageRoot2 = fileURLToPath2(packageRootUrl)) {
|
|
22746
|
+
return join19(packageRoot2, DIARIST_COLLECT_METHOD_RELATIVE);
|
|
22893
22747
|
}
|
|
22894
22748
|
function isRecord11(value) {
|
|
22895
22749
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -23001,7 +22855,7 @@ function serializeDiaristCollectorEnginePayload(payload) {
|
|
|
23001
22855
|
function createHermesDiaristCollector(options = {}) {
|
|
23002
22856
|
const executable = options.executable ?? "hermes";
|
|
23003
22857
|
const methodPath = resolveDiaristCollectMethodPath(options.packageRoot);
|
|
23004
|
-
if (!
|
|
22858
|
+
if (!existsSync8(methodPath)) {
|
|
23005
22859
|
throw new Error(`diarist collect method material missing (${methodPath})`);
|
|
23006
22860
|
}
|
|
23007
22861
|
const method = readFileSync4(methodPath, "utf8");
|
|
@@ -23051,13 +22905,13 @@ function createHermesDiaristCollector(options = {}) {
|
|
|
23051
22905
|
};
|
|
23052
22906
|
};
|
|
23053
22907
|
}
|
|
23054
|
-
var DIARIST_COLLECT_METHOD_RELATIVE,
|
|
22908
|
+
var DIARIST_COLLECT_METHOD_RELATIVE, packageRootUrl, DiaristLlmStdoutError, HERMES_DIARIST_COLLECTOR_TOOLSET;
|
|
23055
22909
|
var init_diarist_llm_collector = __esm({
|
|
23056
22910
|
"src/diarist-llm-collector.ts"() {
|
|
23057
22911
|
"use strict";
|
|
23058
22912
|
init_engine_detour();
|
|
23059
22913
|
DIARIST_COLLECT_METHOD_RELATIVE = "resources/diarist-collect.md";
|
|
23060
|
-
|
|
22914
|
+
packageRootUrl = new URL("..", import.meta.url);
|
|
23061
22915
|
DiaristLlmStdoutError = class extends Error {
|
|
23062
22916
|
code = "diarist-llm-stdout";
|
|
23063
22917
|
reason;
|
|
@@ -23220,9 +23074,9 @@ var init_ticket_provenance_contracts = __esm({
|
|
|
23220
23074
|
});
|
|
23221
23075
|
|
|
23222
23076
|
// src/ticket-provenance.ts
|
|
23223
|
-
import { createHash as
|
|
23224
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
23225
|
-
import { join as
|
|
23077
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
23078
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
23079
|
+
import { join as join20 } from "node:path";
|
|
23226
23080
|
function ticketProvenanceSubject(ticketNumber) {
|
|
23227
23081
|
if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
|
|
23228
23082
|
throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
|
|
@@ -23243,7 +23097,7 @@ function ticketProvenanceEntryIdentity(input) {
|
|
|
23243
23097
|
refKey,
|
|
23244
23098
|
input.transcript
|
|
23245
23099
|
].join("\0");
|
|
23246
|
-
return
|
|
23100
|
+
return createHash6("sha256").update(material, "utf8").digest("hex");
|
|
23247
23101
|
}
|
|
23248
23102
|
function appendTicketProvenanceEntry(input) {
|
|
23249
23103
|
const subject = ticketProvenanceSubject(input.ticketNumber);
|
|
@@ -23280,13 +23134,13 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
|
23280
23134
|
return {
|
|
23281
23135
|
recordFile: path.recordFile,
|
|
23282
23136
|
volumeDir: path.sessionDir,
|
|
23283
|
-
humanViewFile:
|
|
23284
|
-
offeredWatermarkFile:
|
|
23137
|
+
humanViewFile: join20(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
|
|
23138
|
+
offeredWatermarkFile: join20(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
|
|
23285
23139
|
};
|
|
23286
23140
|
}
|
|
23287
23141
|
function readOfferedIdentities(ticketNumber, cwd, home) {
|
|
23288
23142
|
const { offeredWatermarkFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
23289
|
-
if (!
|
|
23143
|
+
if (!existsSync9(offeredWatermarkFile)) return /* @__PURE__ */ new Set();
|
|
23290
23144
|
let text;
|
|
23291
23145
|
try {
|
|
23292
23146
|
text = readFileSync5(offeredWatermarkFile, "utf8");
|
|
@@ -23442,7 +23296,7 @@ function appendTicketProvenanceDiagnostic(input) {
|
|
|
23442
23296
|
input.diagnostic.cause,
|
|
23443
23297
|
input.diagnostic.reason ?? ""
|
|
23444
23298
|
];
|
|
23445
|
-
const identity =
|
|
23299
|
+
const identity = createHash6("sha256").update(identityParts.join("\0"), "utf8").digest("hex");
|
|
23446
23300
|
return sitianReport({
|
|
23447
23301
|
level: "event",
|
|
23448
23302
|
kind: TICKET_PROVENANCE_KIND,
|
|
@@ -23795,36 +23649,82 @@ var init_diarist = __esm({
|
|
|
23795
23649
|
});
|
|
23796
23650
|
|
|
23797
23651
|
// src/public-cli/seat-ticket-binding.ts
|
|
23798
|
-
async function
|
|
23799
|
-
if (admitted.ticketNumber !== void 0) return void 0;
|
|
23800
|
-
if (admitted.ticketResolution === "true-unbound") {
|
|
23801
|
-
return { kind: "true-unbound" };
|
|
23802
|
-
}
|
|
23652
|
+
async function resolveInstructionTicket(instruction, projectRoot, env = {}) {
|
|
23803
23653
|
const resolver = createHermesDiaristTicketResolver({
|
|
23804
23654
|
...env.packageRoot === void 0 ? {} : { packageRoot: env.packageRoot },
|
|
23805
|
-
cwd:
|
|
23655
|
+
cwd: projectRoot
|
|
23806
23656
|
});
|
|
23807
23657
|
const checkExistence = createGhTicketExistenceChecker();
|
|
23808
|
-
const origin = resolveDiaristGithubOrigin(
|
|
23809
|
-
|
|
23810
|
-
instruction
|
|
23658
|
+
const origin = resolveDiaristGithubOrigin(projectRoot);
|
|
23659
|
+
return resolveDiaristTicketFromInstruction({
|
|
23660
|
+
instruction,
|
|
23811
23661
|
origin,
|
|
23812
23662
|
resolver,
|
|
23813
23663
|
checkExistence
|
|
23814
23664
|
});
|
|
23665
|
+
}
|
|
23666
|
+
async function probeInstructionTicket(instruction, projectRoot, env = {}) {
|
|
23667
|
+
try {
|
|
23668
|
+
const resolution = await resolveInstructionTicket(
|
|
23669
|
+
instruction,
|
|
23670
|
+
projectRoot,
|
|
23671
|
+
env
|
|
23672
|
+
);
|
|
23673
|
+
return { kind: "resolved", resolution };
|
|
23674
|
+
} catch (error) {
|
|
23675
|
+
if (error instanceof DiaristTicketResolutionError) {
|
|
23676
|
+
return { kind: "failed", error };
|
|
23677
|
+
}
|
|
23678
|
+
throw error;
|
|
23679
|
+
}
|
|
23680
|
+
}
|
|
23681
|
+
function ticketNumberFromProbe(probe) {
|
|
23682
|
+
if (probe.kind !== "resolved") return void 0;
|
|
23683
|
+
if (probe.resolution.kind !== "ticket") return void 0;
|
|
23684
|
+
return probe.resolution.ticketNumber;
|
|
23685
|
+
}
|
|
23686
|
+
async function applyTicketResolution(admitted, resolution) {
|
|
23815
23687
|
if (resolution.kind === "ticket") {
|
|
23816
23688
|
await bindAdmittedTicketNumber(admitted, resolution.ticketNumber);
|
|
23817
23689
|
} else {
|
|
23818
23690
|
await recordTrueUnboundTicketResolution(admitted);
|
|
23819
23691
|
}
|
|
23692
|
+
}
|
|
23693
|
+
async function applyInstructionTicketProbe(admitted, probe) {
|
|
23694
|
+
if (probe.kind === "failed") throw probe.error;
|
|
23695
|
+
await applyTicketResolution(admitted, probe.resolution);
|
|
23696
|
+
}
|
|
23697
|
+
async function resolveSeatTicketBinding(admitted, env = {}) {
|
|
23698
|
+
if (admitted.ticketNumber !== void 0) return void 0;
|
|
23699
|
+
if (admitted.ticketResolution === "true-unbound") {
|
|
23700
|
+
return { kind: "true-unbound" };
|
|
23701
|
+
}
|
|
23702
|
+
const resolution = await resolveInstructionTicket(
|
|
23703
|
+
admitted.instruction,
|
|
23704
|
+
admitted.projectRoot,
|
|
23705
|
+
env
|
|
23706
|
+
);
|
|
23707
|
+
await applyTicketResolution(admitted, resolution);
|
|
23820
23708
|
return resolution;
|
|
23821
23709
|
}
|
|
23710
|
+
async function tryResumeSameTicketSeatRun(input) {
|
|
23711
|
+
const previousRunId = await findLatestRunIdForSeatTicket({
|
|
23712
|
+
home: input.home,
|
|
23713
|
+
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
23714
|
+
role: input.role,
|
|
23715
|
+
ticketNumber: input.ticketNumber
|
|
23716
|
+
});
|
|
23717
|
+
if (previousRunId === void 0) return void 0;
|
|
23718
|
+
return await input.resume(previousRunId, input.summons);
|
|
23719
|
+
}
|
|
23822
23720
|
var init_seat_ticket_binding = __esm({
|
|
23823
23721
|
"src/public-cli/seat-ticket-binding.ts"() {
|
|
23824
23722
|
"use strict";
|
|
23723
|
+
init_activation_ledger_git();
|
|
23825
23724
|
init_diarist_ticket_resolution();
|
|
23826
23725
|
init_diarist();
|
|
23827
23726
|
init_invocation();
|
|
23727
|
+
init_run_lifecycle();
|
|
23828
23728
|
}
|
|
23829
23729
|
});
|
|
23830
23730
|
|
|
@@ -23855,15 +23755,51 @@ var init_engine_detour_tool = __esm({
|
|
|
23855
23755
|
}
|
|
23856
23756
|
});
|
|
23857
23757
|
|
|
23858
|
-
// src/
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
|
|
23758
|
+
// src/session-opening-materials.ts
|
|
23759
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
23760
|
+
import { dirname as dirname8, join as join21 } from "node:path";
|
|
23761
|
+
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23762
|
+
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
23763
|
+
let dir = dirname8(fileURLToPath3(moduleUrl));
|
|
23764
|
+
for (let i = 0; i < 8; i += 1) {
|
|
23765
|
+
if (existsSync10(join21(dir, "package.json")) && existsSync10(join21(dir, "souls"))) {
|
|
23766
|
+
return dir;
|
|
23767
|
+
}
|
|
23768
|
+
const parent = dirname8(dir);
|
|
23769
|
+
if (parent === dir) break;
|
|
23770
|
+
dir = parent;
|
|
23771
|
+
}
|
|
23772
|
+
return fileURLToPath3(new URL("..", moduleUrl));
|
|
23773
|
+
}
|
|
23774
|
+
var packageRootUrl2, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
|
|
23775
|
+
var init_session_opening_materials = __esm({
|
|
23776
|
+
"src/session-opening-materials.ts"() {
|
|
23862
23777
|
"use strict";
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23778
|
+
init_packaged_role_registry();
|
|
23779
|
+
packageRootUrl2 = pathToFileURL2(resolvePackageRootDir() + "/").href;
|
|
23780
|
+
MAIN_ROLE_SESSION_MATERIALS = {
|
|
23781
|
+
...Object.fromEntries(
|
|
23782
|
+
PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
|
|
23783
|
+
)
|
|
23784
|
+
};
|
|
23785
|
+
GATEKEEPER_SESSION_MATERIALS = {
|
|
23786
|
+
// #639: single authority — the public gatekeeper record owns the province list.
|
|
23787
|
+
gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
|
|
23788
|
+
inspector: INSPECTOR_SESSION_MATERIALS,
|
|
23789
|
+
notary: NOTARY_SESSION_MATERIALS
|
|
23790
|
+
};
|
|
23791
|
+
}
|
|
23792
|
+
});
|
|
23793
|
+
|
|
23794
|
+
// src/navigator-session-contracts.ts
|
|
23795
|
+
var navigatorProviderFailureSchema;
|
|
23796
|
+
var init_navigator_session_contracts = __esm({
|
|
23797
|
+
"src/navigator-session-contracts.ts"() {
|
|
23798
|
+
"use strict";
|
|
23799
|
+
init_build();
|
|
23800
|
+
init_value2();
|
|
23801
|
+
init_auditor_dossier_tool();
|
|
23802
|
+
init_institutional_resolution();
|
|
23867
23803
|
navigatorProviderFailureSchema = typebox_exports.Object({
|
|
23868
23804
|
source: typebox_exports.Union([
|
|
23869
23805
|
typebox_exports.Literal("context"),
|
|
@@ -23947,7 +23883,6 @@ var init_evidence_child_executor = __esm({
|
|
|
23947
23883
|
init_compliance_transport();
|
|
23948
23884
|
init_auditor_dossier_tool();
|
|
23949
23885
|
init_sitian_facade();
|
|
23950
|
-
init_ticket_seat_memory();
|
|
23951
23886
|
init_engine_detour_tool();
|
|
23952
23887
|
init_engine_detour();
|
|
23953
23888
|
init_engine_material();
|
|
@@ -24143,14 +24078,6 @@ function intervalRowsAroundAnchor(rows, anchorIndex, isBindingRow) {
|
|
|
24143
24078
|
}
|
|
24144
24079
|
return { rows: rows.slice(start, end), closed: end < rows.length };
|
|
24145
24080
|
}
|
|
24146
|
-
function intervalRowsForMatchingBinding(rows, isBindingRow, matches) {
|
|
24147
|
-
for (let i = 0; i < rows.length; i += 1) {
|
|
24148
|
-
const row = rows[i];
|
|
24149
|
-
if (!isBindingRow(row) || !matches(row)) continue;
|
|
24150
|
-
return intervalRowsAroundAnchor(rows, i, isBindingRow);
|
|
24151
|
-
}
|
|
24152
|
-
return void 0;
|
|
24153
|
-
}
|
|
24154
24081
|
var LedgerSessionJsonlError;
|
|
24155
24082
|
var init_ledger_session_read = __esm({
|
|
24156
24083
|
"src/ledger-session-read.ts"() {
|
|
@@ -24172,7 +24099,7 @@ var init_ledger_session_read = __esm({
|
|
|
24172
24099
|
|
|
24173
24100
|
// src/analyst-gate-cycles-read.ts
|
|
24174
24101
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
24175
|
-
import { join as
|
|
24102
|
+
import { join as join22 } from "node:path";
|
|
24176
24103
|
function isRecord15(value) {
|
|
24177
24104
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24178
24105
|
}
|
|
@@ -24331,16 +24258,7 @@ function projectAcceptedGateCall(filePath, rows, call) {
|
|
|
24331
24258
|
};
|
|
24332
24259
|
}
|
|
24333
24260
|
async function classifyAuditorVolume(filePath) {
|
|
24334
|
-
|
|
24335
|
-
try {
|
|
24336
|
-
rows = await readLedgerSessionJsonl(filePath);
|
|
24337
|
-
} catch (error) {
|
|
24338
|
-
if (error instanceof LedgerSessionJsonlError && error.prefixRows.some((row) => isTicketSeatRunBindingRow(row))) {
|
|
24339
|
-
rows = error.prefixRows;
|
|
24340
|
-
} else {
|
|
24341
|
-
throw error;
|
|
24342
|
-
}
|
|
24343
|
-
}
|
|
24261
|
+
const rows = await readLedgerSessionJsonl(filePath);
|
|
24344
24262
|
const accepted = extractAllAcceptedGateToolCalls(rows);
|
|
24345
24263
|
if (accepted.length === 0) return [];
|
|
24346
24264
|
const volumes = [];
|
|
@@ -24420,7 +24338,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
24420
24338
|
throw error;
|
|
24421
24339
|
}
|
|
24422
24340
|
for (const name of names) {
|
|
24423
|
-
const classified = await classifyAuditorVolume(
|
|
24341
|
+
const classified = await classifyAuditorVolume(join22(directory, name));
|
|
24424
24342
|
for (const volume of classified) {
|
|
24425
24343
|
if (options.parentSessionFile !== void 0 && volume.parentSessionFile !== void 0 && volume.parentSessionFile !== options.parentSessionFile) {
|
|
24426
24344
|
continue;
|
|
@@ -24437,7 +24355,6 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
24437
24355
|
"use strict";
|
|
24438
24356
|
init_compliance_transport();
|
|
24439
24357
|
init_ledger_session_read();
|
|
24440
|
-
init_ticket_seat_memory();
|
|
24441
24358
|
DISPATCH_TOOLS = /* @__PURE__ */ new Set(["ak_menxia_output", "ak_gatekeeper_output"]);
|
|
24442
24359
|
OFFICER_TOOL_TO_FACE = {
|
|
24443
24360
|
ak_jishizhong_output: "inspector",
|
|
@@ -24479,7 +24396,7 @@ var init_gatekeeper_role = __esm({
|
|
|
24479
24396
|
|
|
24480
24397
|
// src/run-terminal-artifacts.ts
|
|
24481
24398
|
import { readdir as readdir4, readFile as readFile13 } from "node:fs/promises";
|
|
24482
|
-
import { basename as basename7, dirname as dirname9, join as
|
|
24399
|
+
import { basename as basename7, dirname as dirname9, join as join23 } from "node:path";
|
|
24483
24400
|
function isMissingPathError2(error) {
|
|
24484
24401
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
24485
24402
|
}
|
|
@@ -24554,7 +24471,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
24554
24471
|
}
|
|
24555
24472
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
24556
24473
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
24557
|
-
found.push(
|
|
24474
|
+
found.push(join23(dir, name));
|
|
24558
24475
|
}
|
|
24559
24476
|
}
|
|
24560
24477
|
return found;
|
|
@@ -24570,14 +24487,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
24570
24487
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
24571
24488
|
}
|
|
24572
24489
|
async function readRunTerminalArtifact(runDirectory) {
|
|
24573
|
-
const artifactsDir =
|
|
24490
|
+
const artifactsDir = join23(runDirectory, "artifacts");
|
|
24574
24491
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
24575
|
-
const path =
|
|
24492
|
+
const path = join23(artifactsDir, file);
|
|
24576
24493
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
24577
24494
|
if (read3 !== void 0) return read3;
|
|
24578
24495
|
}
|
|
24579
24496
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
24580
|
-
const path =
|
|
24497
|
+
const path = join23(runDirectory, relative3);
|
|
24581
24498
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
24582
24499
|
if (read3 !== void 0) return read3;
|
|
24583
24500
|
}
|
|
@@ -24641,10 +24558,32 @@ async function readOwnedSubmissionRecords(cwd, runId, home) {
|
|
|
24641
24558
|
owned: records2.filter((record4) => typeof record4.subject === "object" && record4.subject !== null && record4.subject.runId === runId)
|
|
24642
24559
|
};
|
|
24643
24560
|
}
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24561
|
+
function resolveReadScope(homeOrScope) {
|
|
24562
|
+
if (homeOrScope === void 0) return {};
|
|
24563
|
+
if (typeof homeOrScope === "string") return { home: homeOrScope };
|
|
24564
|
+
return homeOrScope;
|
|
24565
|
+
}
|
|
24566
|
+
function recordAttemptId(record4) {
|
|
24567
|
+
if (typeof record4.subject === "object" && record4.subject !== null) {
|
|
24568
|
+
const fromSubject = record4.subject.attemptId;
|
|
24569
|
+
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
24570
|
+
}
|
|
24571
|
+
if (typeof record4.payload === "object" && record4.payload !== null) {
|
|
24572
|
+
const fromPayload = record4.payload.attemptId;
|
|
24573
|
+
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
24574
|
+
}
|
|
24575
|
+
return void 0;
|
|
24576
|
+
}
|
|
24577
|
+
function recordsForAttempt(owned, attemptId) {
|
|
24578
|
+
if (attemptId === void 0) return owned;
|
|
24579
|
+
return owned.filter((record4) => recordAttemptId(record4) === attemptId);
|
|
24580
|
+
}
|
|
24581
|
+
async function readSealedSubmission(cwd, runId, homeOrScope) {
|
|
24582
|
+
const scope = resolveReadScope(homeOrScope);
|
|
24583
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
24584
|
+
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
24585
|
+
for (let index = scoped.length - 1; index >= 0; index -= 1) {
|
|
24586
|
+
const record4 = scoped[index];
|
|
24648
24587
|
if (record4?.kind === "post-seal-anomaly") return void 0;
|
|
24649
24588
|
if (record4?.kind !== "sealed") continue;
|
|
24650
24589
|
const payload = record4.payload;
|
|
@@ -24652,10 +24591,12 @@ async function readSealedSubmission(cwd, runId, home) {
|
|
|
24652
24591
|
}
|
|
24653
24592
|
return void 0;
|
|
24654
24593
|
}
|
|
24655
|
-
async function readAuditEscalationSubmission(cwd, runId,
|
|
24656
|
-
const
|
|
24657
|
-
|
|
24658
|
-
|
|
24594
|
+
async function readAuditEscalationSubmission(cwd, runId, homeOrScope) {
|
|
24595
|
+
const scope = resolveReadScope(homeOrScope);
|
|
24596
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
24597
|
+
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
24598
|
+
for (let index = scoped.length - 1; index >= 0; index -= 1) {
|
|
24599
|
+
const record4 = scoped[index];
|
|
24659
24600
|
if (record4?.kind !== "outcome") continue;
|
|
24660
24601
|
const payload = record4.payload;
|
|
24661
24602
|
if (payload?.type !== "outcome" || payload.outcome !== "audit-escalation") continue;
|
|
@@ -24663,10 +24604,12 @@ async function readAuditEscalationSubmission(cwd, runId, home) {
|
|
|
24663
24604
|
}
|
|
24664
24605
|
return void 0;
|
|
24665
24606
|
}
|
|
24666
|
-
async function readLatestSubmissionOutcome(cwd, runId,
|
|
24667
|
-
const
|
|
24668
|
-
|
|
24669
|
-
|
|
24607
|
+
async function readLatestSubmissionOutcome(cwd, runId, homeOrScope) {
|
|
24608
|
+
const scope = resolveReadScope(homeOrScope);
|
|
24609
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
24610
|
+
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
24611
|
+
for (let index = scoped.length - 1; index >= 0; index -= 1) {
|
|
24612
|
+
const record4 = scoped[index];
|
|
24670
24613
|
if (record4?.kind !== "outcome") continue;
|
|
24671
24614
|
const payload = record4.payload;
|
|
24672
24615
|
if (payload?.type === "outcome" && typeof payload.outcome === "string") {
|
|
@@ -24838,12 +24781,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
24838
24781
|
|
|
24839
24782
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
24840
24783
|
import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
|
|
24841
|
-
import { join as
|
|
24784
|
+
import { join as join24 } from "node:path";
|
|
24842
24785
|
function isReviewerPreflightViolation(value) {
|
|
24843
24786
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
24844
24787
|
}
|
|
24845
24788
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
24846
|
-
return
|
|
24789
|
+
return join24(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
24847
24790
|
}
|
|
24848
24791
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
24849
24792
|
try {
|
|
@@ -25224,13 +25167,19 @@ var init_terminal = __esm({
|
|
|
25224
25167
|
|
|
25225
25168
|
// src/public-cli/settlement.ts
|
|
25226
25169
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25227
|
-
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as
|
|
25228
|
-
import { dirname as dirname10, join as
|
|
25170
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile7 } from "node:fs/promises";
|
|
25171
|
+
import { dirname as dirname10, join as join25 } from "node:path";
|
|
25229
25172
|
function sealedLedgerHome(admitted) {
|
|
25230
25173
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
25231
25174
|
}
|
|
25232
|
-
|
|
25233
|
-
return
|
|
25175
|
+
function ledgerReadScope(admitted, scope) {
|
|
25176
|
+
return {
|
|
25177
|
+
home: sealedLedgerHome(admitted),
|
|
25178
|
+
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
25179
|
+
};
|
|
25180
|
+
}
|
|
25181
|
+
async function sealedLedgerOutcome(admitted, scope) {
|
|
25182
|
+
return readSealedSubmission(admitted.projectRoot, admitted.runId, ledgerReadScope(admitted, scope));
|
|
25234
25183
|
}
|
|
25235
25184
|
async function sealedAcceptanceRedispatchDisposition(admitted) {
|
|
25236
25185
|
try {
|
|
@@ -25242,18 +25191,18 @@ async function sealedAcceptanceRedispatchDisposition(admitted) {
|
|
|
25242
25191
|
return { kind: "block", reason: "authority-failed", cause };
|
|
25243
25192
|
}
|
|
25244
25193
|
}
|
|
25245
|
-
async function auditEscalationLedgerOutcome(admitted, role) {
|
|
25194
|
+
async function auditEscalationLedgerOutcome(admitted, role, scope) {
|
|
25246
25195
|
const projection = await readAuditEscalationSubmission(
|
|
25247
25196
|
admitted.projectRoot,
|
|
25248
25197
|
admitted.runId,
|
|
25249
|
-
|
|
25198
|
+
ledgerReadScope(admitted, scope)
|
|
25250
25199
|
);
|
|
25251
25200
|
if (projection?.role !== role) return void 0;
|
|
25252
25201
|
return projection;
|
|
25253
25202
|
}
|
|
25254
|
-
async function closedLedgerOutcome(admitted, role) {
|
|
25255
|
-
const sealed = await sealedLedgerOutcome(admitted);
|
|
25256
|
-
return sealed?.role === role ? sealed : auditEscalationLedgerOutcome(admitted, role);
|
|
25203
|
+
async function closedLedgerOutcome(admitted, role, scope) {
|
|
25204
|
+
const sealed = await sealedLedgerOutcome(admitted, scope);
|
|
25205
|
+
return sealed?.role === role ? sealed : auditEscalationLedgerOutcome(admitted, role, scope);
|
|
25257
25206
|
}
|
|
25258
25207
|
function coordinatesFromAdmitted(authority, admitted) {
|
|
25259
25208
|
return authority.decode(admitted.principal);
|
|
@@ -25620,7 +25569,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
25620
25569
|
}
|
|
25621
25570
|
}
|
|
25622
25571
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
25623
|
-
const childDirectory =
|
|
25572
|
+
const childDirectory = join25(dirname10(sessionFile), "evidence-children");
|
|
25624
25573
|
let names;
|
|
25625
25574
|
try {
|
|
25626
25575
|
names = await readdir5(childDirectory);
|
|
@@ -25631,7 +25580,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
25631
25580
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25632
25581
|
let entries;
|
|
25633
25582
|
try {
|
|
25634
|
-
entries = await readBoundSessionEntries(
|
|
25583
|
+
entries = await readBoundSessionEntries(join25(childDirectory, file));
|
|
25635
25584
|
} catch (error) {
|
|
25636
25585
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
25637
25586
|
}
|
|
@@ -25685,15 +25634,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25685
25634
|
latestParentUserIndex = i;
|
|
25686
25635
|
break;
|
|
25687
25636
|
}
|
|
25688
|
-
const
|
|
25689
|
-
const memoryNests = await resolveTicketSeatMemoryNestDirectories({
|
|
25690
|
-
runDirectory,
|
|
25691
|
-
seats: ["auditor"]
|
|
25692
|
-
});
|
|
25693
|
-
const childDirectories = [
|
|
25694
|
-
join26(dirname10(sessionFile), "auditor-roles"),
|
|
25695
|
-
...memoryNests
|
|
25696
|
-
];
|
|
25637
|
+
const childDirectories = [join25(dirname10(sessionFile), "auditor-roles")];
|
|
25697
25638
|
const valid = [];
|
|
25698
25639
|
let sawAnyDirectory = false;
|
|
25699
25640
|
for (const childDirectory of childDirectories) {
|
|
@@ -25708,7 +25649,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25708
25649
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25709
25650
|
let entries;
|
|
25710
25651
|
try {
|
|
25711
|
-
entries = await readBoundSessionEntries(
|
|
25652
|
+
entries = await readBoundSessionEntries(join25(childDirectory, file));
|
|
25712
25653
|
} catch (error) {
|
|
25713
25654
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
25714
25655
|
}
|
|
@@ -26474,16 +26415,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
26474
26415
|
};
|
|
26475
26416
|
}
|
|
26476
26417
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
26477
|
-
const
|
|
26478
|
-
const
|
|
26479
|
-
runDirectory,
|
|
26480
|
-
seats: ["inspector", "notary"]
|
|
26481
|
-
});
|
|
26482
|
-
const directories = [
|
|
26483
|
-
join26(sessionDirectory, "auditor-roles"),
|
|
26484
|
-
...memoryNests
|
|
26485
|
-
];
|
|
26486
|
-
const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
|
|
26418
|
+
const directories = [join25(sessionDirectory, "auditor-roles")];
|
|
26419
|
+
const parentSessionFile = options.parentSessionFile ?? join25(sessionDirectory, "session.jsonl");
|
|
26487
26420
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
26488
26421
|
parentSessionFile
|
|
26489
26422
|
});
|
|
@@ -26581,9 +26514,9 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
26581
26514
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
26582
26515
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26583
26516
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26584
|
-
const reportPath =
|
|
26585
|
-
const evidencePath =
|
|
26586
|
-
await
|
|
26517
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26518
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26519
|
+
await writeFile7(
|
|
26587
26520
|
reportPath,
|
|
26588
26521
|
`${JSON.stringify(
|
|
26589
26522
|
{
|
|
@@ -26597,7 +26530,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
26597
26530
|
`,
|
|
26598
26531
|
"utf8"
|
|
26599
26532
|
);
|
|
26600
|
-
await
|
|
26533
|
+
await writeFile7(
|
|
26601
26534
|
evidencePath,
|
|
26602
26535
|
`${JSON.stringify(
|
|
26603
26536
|
{
|
|
@@ -26626,9 +26559,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
26626
26559
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26627
26560
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26628
26561
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26629
|
-
const reportPath =
|
|
26630
|
-
const evidencePath =
|
|
26631
|
-
await
|
|
26562
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26563
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26564
|
+
await writeFile7(
|
|
26632
26565
|
reportPath,
|
|
26633
26566
|
`${JSON.stringify(
|
|
26634
26567
|
{
|
|
@@ -26644,7 +26577,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
26644
26577
|
`,
|
|
26645
26578
|
"utf8"
|
|
26646
26579
|
);
|
|
26647
|
-
await
|
|
26580
|
+
await writeFile7(
|
|
26648
26581
|
evidencePath,
|
|
26649
26582
|
`${JSON.stringify(
|
|
26650
26583
|
{
|
|
@@ -26786,9 +26719,9 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
26786
26719
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26787
26720
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26788
26721
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26789
|
-
const reportPath =
|
|
26790
|
-
const evidencePath =
|
|
26791
|
-
await
|
|
26722
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26723
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26724
|
+
await writeFile7(
|
|
26792
26725
|
reportPath,
|
|
26793
26726
|
`${JSON.stringify(
|
|
26794
26727
|
{
|
|
@@ -26804,7 +26737,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
26804
26737
|
`,
|
|
26805
26738
|
"utf8"
|
|
26806
26739
|
);
|
|
26807
|
-
await
|
|
26740
|
+
await writeFile7(
|
|
26808
26741
|
evidencePath,
|
|
26809
26742
|
`${JSON.stringify(
|
|
26810
26743
|
{
|
|
@@ -26886,9 +26819,9 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
|
|
|
26886
26819
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26887
26820
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26888
26821
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26889
|
-
const reportPath =
|
|
26890
|
-
const evidencePath =
|
|
26891
|
-
await
|
|
26822
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26823
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26824
|
+
await writeFile7(
|
|
26892
26825
|
reportPath,
|
|
26893
26826
|
`${JSON.stringify(
|
|
26894
26827
|
{
|
|
@@ -26903,7 +26836,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, opt
|
|
|
26903
26836
|
`,
|
|
26904
26837
|
"utf8"
|
|
26905
26838
|
);
|
|
26906
|
-
await
|
|
26839
|
+
await writeFile7(
|
|
26907
26840
|
evidencePath,
|
|
26908
26841
|
`${JSON.stringify(
|
|
26909
26842
|
{
|
|
@@ -26994,9 +26927,9 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
|
|
|
26994
26927
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26995
26928
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26996
26929
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26997
|
-
const reportPath =
|
|
26998
|
-
const evidencePath =
|
|
26999
|
-
await
|
|
26930
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26931
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26932
|
+
await writeFile7(
|
|
27000
26933
|
reportPath,
|
|
27001
26934
|
`${JSON.stringify(
|
|
27002
26935
|
{
|
|
@@ -27011,7 +26944,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
27011
26944
|
`,
|
|
27012
26945
|
"utf8"
|
|
27013
26946
|
);
|
|
27014
|
-
await
|
|
26947
|
+
await writeFile7(
|
|
27015
26948
|
evidencePath,
|
|
27016
26949
|
`${JSON.stringify(
|
|
27017
26950
|
{
|
|
@@ -27107,11 +27040,11 @@ function currentAttemptStartIndex(entries) {
|
|
|
27107
27040
|
}
|
|
27108
27041
|
return 0;
|
|
27109
27042
|
}
|
|
27110
|
-
async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec) {
|
|
27043
|
+
async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec, scope) {
|
|
27111
27044
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
27112
27045
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
27113
27046
|
const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
|
|
27114
|
-
const roleOutcome = await closedLedgerOutcome(admitted, spec.role);
|
|
27047
|
+
const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
|
|
27115
27048
|
if (roleOutcome?.kind === "audit_escalation") {
|
|
27116
27049
|
const navigator2 = extractNavigatorFact(entries);
|
|
27117
27050
|
return withOptionalGateProjection(
|
|
@@ -27191,7 +27124,7 @@ function tryAcceptWithValidator(validate) {
|
|
|
27191
27124
|
}
|
|
27192
27125
|
};
|
|
27193
27126
|
}
|
|
27194
|
-
async function settleLawfulNotaryTerminalResult(admitted, authority) {
|
|
27127
|
+
async function settleLawfulNotaryTerminalResult(admitted, authority, scope) {
|
|
27195
27128
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27196
27129
|
role: "notary",
|
|
27197
27130
|
toolName: NOTARY_OUTPUT_TOOL_NAME,
|
|
@@ -27207,12 +27140,12 @@ async function settleLawfulNotaryTerminalResult(admitted, authority) {
|
|
|
27207
27140
|
};
|
|
27208
27141
|
return accepted;
|
|
27209
27142
|
}
|
|
27210
|
-
});
|
|
27143
|
+
}, scope);
|
|
27211
27144
|
}
|
|
27212
|
-
async function trySettleNotaryTerminalResult(admitted, authority) {
|
|
27213
|
-
return settleLawfulNotaryTerminalResult(admitted, authority);
|
|
27145
|
+
async function trySettleNotaryTerminalResult(admitted, authority, scope) {
|
|
27146
|
+
return settleLawfulNotaryTerminalResult(admitted, authority, scope);
|
|
27214
27147
|
}
|
|
27215
|
-
async function settleLawfulCountersignTerminalResult(admitted, authority) {
|
|
27148
|
+
async function settleLawfulCountersignTerminalResult(admitted, authority, scope) {
|
|
27216
27149
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27217
27150
|
role: "countersign",
|
|
27218
27151
|
toolName: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
@@ -27228,12 +27161,12 @@ async function settleLawfulCountersignTerminalResult(admitted, authority) {
|
|
|
27228
27161
|
};
|
|
27229
27162
|
return accepted;
|
|
27230
27163
|
}
|
|
27231
|
-
});
|
|
27164
|
+
}, scope);
|
|
27232
27165
|
}
|
|
27233
|
-
async function trySettleCountersignTerminalResult(admitted, authority) {
|
|
27234
|
-
return settleLawfulCountersignTerminalResult(admitted, authority);
|
|
27166
|
+
async function trySettleCountersignTerminalResult(admitted, authority, scope) {
|
|
27167
|
+
return settleLawfulCountersignTerminalResult(admitted, authority, scope);
|
|
27235
27168
|
}
|
|
27236
|
-
async function settleLawfulGleanerLeftTerminalResult(admitted, authority) {
|
|
27169
|
+
async function settleLawfulGleanerLeftTerminalResult(admitted, authority, scope) {
|
|
27237
27170
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27238
27171
|
role: "gleaner-left",
|
|
27239
27172
|
toolName: GLEANER_LEFT_OUTPUT_TOOL_NAME,
|
|
@@ -27249,12 +27182,12 @@ async function settleLawfulGleanerLeftTerminalResult(admitted, authority) {
|
|
|
27249
27182
|
};
|
|
27250
27183
|
return accepted;
|
|
27251
27184
|
}
|
|
27252
|
-
});
|
|
27185
|
+
}, scope);
|
|
27253
27186
|
}
|
|
27254
|
-
async function trySettleGleanerLeftTerminalResult(admitted, authority) {
|
|
27255
|
-
return settleLawfulGleanerLeftTerminalResult(admitted, authority);
|
|
27187
|
+
async function trySettleGleanerLeftTerminalResult(admitted, authority, scope) {
|
|
27188
|
+
return settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
|
|
27256
27189
|
}
|
|
27257
|
-
async function settleLawfulInspectorTerminalResult(admitted, authority) {
|
|
27190
|
+
async function settleLawfulInspectorTerminalResult(admitted, authority, scope) {
|
|
27258
27191
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27259
27192
|
role: "inspector",
|
|
27260
27193
|
toolName: INSPECTOR_OUTPUT_TOOL_NAME,
|
|
@@ -27270,12 +27203,12 @@ async function settleLawfulInspectorTerminalResult(admitted, authority) {
|
|
|
27270
27203
|
};
|
|
27271
27204
|
return accepted;
|
|
27272
27205
|
}
|
|
27273
|
-
});
|
|
27206
|
+
}, scope);
|
|
27274
27207
|
}
|
|
27275
|
-
async function trySettleInspectorTerminalResult(admitted, authority) {
|
|
27276
|
-
return settleLawfulInspectorTerminalResult(admitted, authority);
|
|
27208
|
+
async function trySettleInspectorTerminalResult(admitted, authority, scope) {
|
|
27209
|
+
return settleLawfulInspectorTerminalResult(admitted, authority, scope);
|
|
27277
27210
|
}
|
|
27278
|
-
async function settleLawfulGatekeeperTerminalResult(admitted, authority) {
|
|
27211
|
+
async function settleLawfulGatekeeperTerminalResult(admitted, authority, scope) {
|
|
27279
27212
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27280
27213
|
role: "gatekeeper",
|
|
27281
27214
|
toolName: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
@@ -27291,12 +27224,12 @@ async function settleLawfulGatekeeperTerminalResult(admitted, authority) {
|
|
|
27291
27224
|
};
|
|
27292
27225
|
return accepted;
|
|
27293
27226
|
}
|
|
27294
|
-
});
|
|
27227
|
+
}, scope);
|
|
27295
27228
|
}
|
|
27296
|
-
async function trySettleGatekeeperTerminalResult(admitted, authority) {
|
|
27297
|
-
return settleLawfulGatekeeperTerminalResult(admitted, authority);
|
|
27229
|
+
async function trySettleGatekeeperTerminalResult(admitted, authority, scope) {
|
|
27230
|
+
return settleLawfulGatekeeperTerminalResult(admitted, authority, scope);
|
|
27298
27231
|
}
|
|
27299
|
-
async function settleLawfulNavigatorTerminalResult(admitted, authority) {
|
|
27232
|
+
async function settleLawfulNavigatorTerminalResult(admitted, authority, scope) {
|
|
27300
27233
|
return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
|
|
27301
27234
|
role: "navigator",
|
|
27302
27235
|
toolName: NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
@@ -27312,10 +27245,10 @@ async function settleLawfulNavigatorTerminalResult(admitted, authority) {
|
|
|
27312
27245
|
};
|
|
27313
27246
|
return accepted;
|
|
27314
27247
|
}
|
|
27315
|
-
});
|
|
27248
|
+
}, scope);
|
|
27316
27249
|
}
|
|
27317
|
-
async function trySettleNavigatorTerminalResult(admitted, authority) {
|
|
27318
|
-
return settleLawfulNavigatorTerminalResult(admitted, authority);
|
|
27250
|
+
async function trySettleNavigatorTerminalResult(admitted, authority, scope) {
|
|
27251
|
+
return settleLawfulNavigatorTerminalResult(admitted, authority, scope);
|
|
27319
27252
|
}
|
|
27320
27253
|
async function trySettleCoderTerminalResult(admitted, authority, options = {}) {
|
|
27321
27254
|
return settleLawfulCoderTerminalResult(admitted, authority, options);
|
|
@@ -27342,9 +27275,9 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
27342
27275
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
27343
27276
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
27344
27277
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
27345
|
-
const reportPath =
|
|
27346
|
-
const evidencePath =
|
|
27347
|
-
await
|
|
27278
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
27279
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
27280
|
+
await writeFile7(
|
|
27348
27281
|
reportPath,
|
|
27349
27282
|
`${JSON.stringify(
|
|
27350
27283
|
{
|
|
@@ -27359,7 +27292,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
|
|
|
27359
27292
|
`,
|
|
27360
27293
|
"utf8"
|
|
27361
27294
|
);
|
|
27362
|
-
await
|
|
27295
|
+
await writeFile7(
|
|
27363
27296
|
evidencePath,
|
|
27364
27297
|
`${JSON.stringify(
|
|
27365
27298
|
{
|
|
@@ -27470,9 +27403,9 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
27470
27403
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
27471
27404
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
27472
27405
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
27473
|
-
const reportPath =
|
|
27474
|
-
const evidencePath =
|
|
27475
|
-
await
|
|
27406
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
27407
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
27408
|
+
await writeFile7(
|
|
27476
27409
|
reportPath,
|
|
27477
27410
|
`${JSON.stringify(
|
|
27478
27411
|
{
|
|
@@ -27487,7 +27420,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
27487
27420
|
`,
|
|
27488
27421
|
"utf8"
|
|
27489
27422
|
);
|
|
27490
|
-
await
|
|
27423
|
+
await writeFile7(
|
|
27491
27424
|
evidencePath,
|
|
27492
27425
|
`${JSON.stringify(
|
|
27493
27426
|
{
|
|
@@ -27620,7 +27553,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
27620
27553
|
return dirs;
|
|
27621
27554
|
}
|
|
27622
27555
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
27623
|
-
const artifactsDir =
|
|
27556
|
+
const artifactsDir = join25(runDirectory, "artifacts");
|
|
27624
27557
|
try {
|
|
27625
27558
|
await ensureRunArtifactsDir(runDirectory);
|
|
27626
27559
|
return { baseDir: artifactsDir };
|
|
@@ -27636,13 +27569,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
27636
27569
|
const candidates = [
|
|
27637
27570
|
...preferredCandidates,
|
|
27638
27571
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
27639
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
27572
|
+
...uniqueFallbackDirs.map((dir) => join25(dir, `${stem}.${randomUUID3()}.json`))
|
|
27640
27573
|
];
|
|
27641
27574
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
27642
27575
|
const path = candidates[i];
|
|
27643
27576
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
27644
27577
|
try {
|
|
27645
|
-
await
|
|
27578
|
+
await writeFile7(
|
|
27646
27579
|
path,
|
|
27647
27580
|
`${JSON.stringify(payload, null, 2)}
|
|
27648
27581
|
`,
|
|
@@ -27681,26 +27614,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
27681
27614
|
} catch (error) {
|
|
27682
27615
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
27683
27616
|
}
|
|
27684
|
-
const underArtifacts = baseDir ===
|
|
27617
|
+
const underArtifacts = baseDir === join25(admitted.runDirectory, "artifacts");
|
|
27685
27618
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
27686
27619
|
admitted.runDirectory,
|
|
27687
27620
|
baseDir
|
|
27688
27621
|
);
|
|
27689
27622
|
const errorCandidates = underArtifacts ? [
|
|
27690
|
-
|
|
27691
|
-
|
|
27692
|
-
|
|
27623
|
+
join25(baseDir, "error.json"),
|
|
27624
|
+
join25(baseDir, "error.settlement.json"),
|
|
27625
|
+
join25(admitted.runDirectory, "error.settlement.json")
|
|
27693
27626
|
] : [
|
|
27694
|
-
|
|
27695
|
-
|
|
27627
|
+
join25(baseDir, "error.settlement.json"),
|
|
27628
|
+
join25(baseDir, "error.json")
|
|
27696
27629
|
];
|
|
27697
27630
|
const evidenceCandidates = underArtifacts ? [
|
|
27698
|
-
|
|
27699
|
-
|
|
27700
|
-
|
|
27631
|
+
join25(baseDir, "evidence.json"),
|
|
27632
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
27633
|
+
join25(admitted.runDirectory, "evidence.settlement.json")
|
|
27701
27634
|
] : [
|
|
27702
|
-
|
|
27703
|
-
|
|
27635
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
27636
|
+
join25(baseDir, "evidence.json")
|
|
27704
27637
|
];
|
|
27705
27638
|
const errorPayloadBase = {
|
|
27706
27639
|
kind: "error",
|
|
@@ -27891,7 +27824,6 @@ var init_settlement = __esm({
|
|
|
27891
27824
|
"use strict";
|
|
27892
27825
|
init_analyst_gate_cycles_read();
|
|
27893
27826
|
init_sitian_facade();
|
|
27894
|
-
init_ticket_seat_memory();
|
|
27895
27827
|
init_submission_ledger();
|
|
27896
27828
|
init_audit_escalation();
|
|
27897
27829
|
init_auditor_soul();
|
|
@@ -27973,7 +27905,7 @@ var init_turn_request = __esm({
|
|
|
27973
27905
|
|
|
27974
27906
|
// src/host-transition-prior-native.ts
|
|
27975
27907
|
import { access as access2, readdir as readdir6 } from "node:fs/promises";
|
|
27976
|
-
import { join as
|
|
27908
|
+
import { join as join26 } from "node:path";
|
|
27977
27909
|
function isKnownRoleTurnHost(value) {
|
|
27978
27910
|
return KNOWN_ROLE_TURN_HOSTS.includes(value);
|
|
27979
27911
|
}
|
|
@@ -27990,7 +27922,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
27990
27922
|
}
|
|
27991
27923
|
}
|
|
27992
27924
|
async function listGrokNativeRecordPaths(runDirectory) {
|
|
27993
|
-
const grokSessionsDir =
|
|
27925
|
+
const grokSessionsDir = join26(runDirectory, "grok-home", "sessions");
|
|
27994
27926
|
let encodedCwds;
|
|
27995
27927
|
try {
|
|
27996
27928
|
encodedCwds = await readdir6(grokSessionsDir, { withFileTypes: true });
|
|
@@ -28003,14 +27935,14 @@ async function listGrokNativeRecordPaths(runDirectory) {
|
|
|
28003
27935
|
if (!cwdEntry.isDirectory()) continue;
|
|
28004
27936
|
let sessionDirs;
|
|
28005
27937
|
try {
|
|
28006
|
-
sessionDirs = await readdir6(
|
|
27938
|
+
sessionDirs = await readdir6(join26(grokSessionsDir, cwdEntry.name), { withFileTypes: true });
|
|
28007
27939
|
} catch (error) {
|
|
28008
27940
|
if (isEnoent2(error)) continue;
|
|
28009
27941
|
throw error;
|
|
28010
27942
|
}
|
|
28011
27943
|
for (const sessEntry of sessionDirs) {
|
|
28012
27944
|
if (!sessEntry.isDirectory()) continue;
|
|
28013
|
-
updatesPaths.push(
|
|
27945
|
+
updatesPaths.push(join26(grokSessionsDir, cwdEntry.name, sessEntry.name, "updates.jsonl"));
|
|
28014
27946
|
}
|
|
28015
27947
|
}
|
|
28016
27948
|
updatesPaths.sort();
|
|
@@ -28037,8 +27969,7 @@ async function projectHostTransitionPriorNative(input) {
|
|
|
28037
27969
|
priorNativePaths: paths2
|
|
28038
27970
|
};
|
|
28039
27971
|
}
|
|
28040
|
-
const
|
|
28041
|
-
const paths = await listGrokNativeRecordPaths(grokRoot);
|
|
27972
|
+
const paths = await listGrokNativeRecordPaths(input.runDirectory);
|
|
28042
27973
|
return {
|
|
28043
27974
|
previousHost: "grok-build",
|
|
28044
27975
|
priorNativePaths: paths
|
|
@@ -28092,7 +28023,7 @@ var init_public_run_credentials = __esm({
|
|
|
28092
28023
|
import { constants as fsConstants } from "node:fs";
|
|
28093
28024
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
28094
28025
|
import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
28095
|
-
import { join as
|
|
28026
|
+
import { join as join27 } from "node:path";
|
|
28096
28027
|
function presentTerminal(terminal, io) {
|
|
28097
28028
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
28098
28029
|
presentFailureTerminal(terminal, io);
|
|
@@ -28111,7 +28042,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
28111
28042
|
}
|
|
28112
28043
|
}
|
|
28113
28044
|
function runArtifactsDirectory(runDirectory) {
|
|
28114
|
-
return
|
|
28045
|
+
return join27(runDirectory, "artifacts");
|
|
28115
28046
|
}
|
|
28116
28047
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
28117
28048
|
const runStat = await lstat5(runDirectory);
|
|
@@ -28194,7 +28125,7 @@ function jsonSafeReplacer() {
|
|
|
28194
28125
|
}
|
|
28195
28126
|
async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
|
|
28196
28127
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28197
|
-
const filePath =
|
|
28128
|
+
const filePath = join27(
|
|
28198
28129
|
artifactsDir,
|
|
28199
28130
|
`dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
|
|
28200
28131
|
);
|
|
@@ -28441,11 +28372,12 @@ var init_auto_resume = __esm({
|
|
|
28441
28372
|
});
|
|
28442
28373
|
|
|
28443
28374
|
// src/public-cli/post-admission.ts
|
|
28444
|
-
import {
|
|
28445
|
-
import {
|
|
28375
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
28376
|
+
import { readFile as readFile16, writeFile as writeFile8 } from "node:fs/promises";
|
|
28377
|
+
import { isAbsolute as isAbsolute6, join as join28, resolve as resolve9 } from "node:path";
|
|
28446
28378
|
async function readInvocationHost(runDirectory) {
|
|
28447
28379
|
try {
|
|
28448
|
-
const raw = JSON.parse(await readFile16(
|
|
28380
|
+
const raw = JSON.parse(await readFile16(join28(runDirectory, "invocation.json"), "utf8"));
|
|
28449
28381
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
28450
28382
|
} catch (error) {
|
|
28451
28383
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -28500,71 +28432,6 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
28500
28432
|
terminal
|
|
28501
28433
|
};
|
|
28502
28434
|
}
|
|
28503
|
-
function concurrentFailureLeafRecord(leaf) {
|
|
28504
|
-
return {
|
|
28505
|
-
cause: leaf.cause,
|
|
28506
|
-
diagnostic: leaf.diagnostic,
|
|
28507
|
-
...leaf.identity === void 0 ? {} : { identity: leaf.identity },
|
|
28508
|
-
...leaf.details === void 0 ? {} : { details: leaf.details }
|
|
28509
|
-
};
|
|
28510
|
-
}
|
|
28511
|
-
function existingConcurrentFailureLeaves(details) {
|
|
28512
|
-
const value = details?.concurrentFailures;
|
|
28513
|
-
return Array.isArray(value) ? [...value] : [];
|
|
28514
|
-
}
|
|
28515
|
-
function withLastHostWriteConcurrentFailure(input, writeError) {
|
|
28516
|
-
const writeLeaf = concurrentFailureLeafRecord(projectThrownFailureLeaf(writeError));
|
|
28517
|
-
if (input.knownFailure !== void 0) {
|
|
28518
|
-
const failure = input.knownFailure;
|
|
28519
|
-
return {
|
|
28520
|
-
...input,
|
|
28521
|
-
knownFailure: {
|
|
28522
|
-
cause: failure.cause,
|
|
28523
|
-
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
28524
|
-
...failure.diagnostic === void 0 ? {} : { diagnostic: failure.diagnostic },
|
|
28525
|
-
details: {
|
|
28526
|
-
...failure.details ?? {},
|
|
28527
|
-
concurrentFailures: [
|
|
28528
|
-
...existingConcurrentFailureLeaves(failure.details),
|
|
28529
|
-
writeLeaf
|
|
28530
|
-
]
|
|
28531
|
-
}
|
|
28532
|
-
}
|
|
28533
|
-
};
|
|
28534
|
-
}
|
|
28535
|
-
return {
|
|
28536
|
-
...input,
|
|
28537
|
-
knownDetails: {
|
|
28538
|
-
...input.knownDetails ?? {},
|
|
28539
|
-
concurrentFailures: [
|
|
28540
|
-
...existingConcurrentFailureLeaves(input.knownDetails),
|
|
28541
|
-
writeLeaf
|
|
28542
|
-
]
|
|
28543
|
-
}
|
|
28544
|
-
};
|
|
28545
|
-
}
|
|
28546
|
-
function knownFailureFromSettledFailureOutcome(outcome) {
|
|
28547
|
-
const facts = outcome.decisiveFacts;
|
|
28548
|
-
const secondary = facts.secondaryEvidence;
|
|
28549
|
-
const details = secondary !== void 0 && typeof secondary === "object" && secondary !== null && !Array.isArray(secondary) ? secondary : void 0;
|
|
28550
|
-
const identity = {};
|
|
28551
|
-
if (typeof facts.errorName === "string") identity.name = facts.errorName;
|
|
28552
|
-
if (typeof facts.errorCode === "string" || typeof facts.errorCode === "number") {
|
|
28553
|
-
identity.code = facts.errorCode;
|
|
28554
|
-
}
|
|
28555
|
-
return {
|
|
28556
|
-
cause: outcome.cause,
|
|
28557
|
-
diagnostic: outcome.diagnostic,
|
|
28558
|
-
...Object.keys(identity).length > 0 ? { identity } : {},
|
|
28559
|
-
...details === void 0 ? {} : { details }
|
|
28560
|
-
};
|
|
28561
|
-
}
|
|
28562
|
-
function withOptionalLastHostWriteThrow(primary, writeFailure, message) {
|
|
28563
|
-
if (writeFailure === void 0) return primary;
|
|
28564
|
-
return new AggregateError([primary, writeFailure.error], message, {
|
|
28565
|
-
cause: primary
|
|
28566
|
-
});
|
|
28567
|
-
}
|
|
28568
28435
|
async function dispatchPostAdmissionTurn(input) {
|
|
28569
28436
|
const { admitted, env, io, request, lease, adapters, effectiveEngine } = input;
|
|
28570
28437
|
const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
|
|
@@ -28583,55 +28450,21 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28583
28450
|
);
|
|
28584
28451
|
}
|
|
28585
28452
|
let previousHost;
|
|
28586
|
-
let previousRunDirectory;
|
|
28587
|
-
let nativeHomeRunDirectory;
|
|
28588
|
-
let openedNativeHomeRunDirectory;
|
|
28589
28453
|
const liveHost = env.host;
|
|
28590
28454
|
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
28591
|
-
const ticketSeatMemoryBound = isTicketSeatMemoryBound({
|
|
28592
|
-
role: admitted.role,
|
|
28593
|
-
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
28594
|
-
});
|
|
28595
28455
|
let turnRequest;
|
|
28596
28456
|
try {
|
|
28597
|
-
|
|
28598
|
-
const lastHost = await readTicketSeatMemoryLastHost(
|
|
28599
|
-
principalCoordinates.sessionDirectory
|
|
28600
|
-
);
|
|
28601
|
-
if (lastHost !== void 0) {
|
|
28602
|
-
previousHost = lastHost.host;
|
|
28603
|
-
if (typeof lastHost.runDirectory === "string" && lastHost.runDirectory.length > 0) {
|
|
28604
|
-
previousRunDirectory = lastHost.runDirectory;
|
|
28605
|
-
if (liveHost === "grok-build" && request.continuation.kind === "resume") {
|
|
28606
|
-
nativeHomeRunDirectory = lastHost.runDirectory;
|
|
28607
|
-
}
|
|
28608
|
-
}
|
|
28609
|
-
}
|
|
28610
|
-
} else {
|
|
28611
|
-
previousHost = await readInvocationHost(admitted.runDirectory);
|
|
28612
|
-
}
|
|
28457
|
+
previousHost = await readInvocationHost(admitted.runDirectory);
|
|
28613
28458
|
const hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
28614
28459
|
previousHost,
|
|
28615
28460
|
liveHost,
|
|
28616
28461
|
runDirectory: admitted.runDirectory,
|
|
28617
|
-
piSessionFile: principalCoordinates.sessionFile
|
|
28618
|
-
...previousRunDirectory === void 0 ? {} : { previousRunDirectory }
|
|
28462
|
+
piSessionFile: principalCoordinates.sessionFile
|
|
28619
28463
|
}) : void 0;
|
|
28620
28464
|
turnRequest = request;
|
|
28621
28465
|
if (hostTransition !== void 0) {
|
|
28622
28466
|
turnRequest = { ...turnRequest, hostTransition };
|
|
28623
28467
|
}
|
|
28624
|
-
if (nativeHomeRunDirectory !== void 0) {
|
|
28625
|
-
turnRequest = { ...turnRequest, nativeHomeRunDirectory };
|
|
28626
|
-
}
|
|
28627
|
-
if (ticketSeatMemoryBound) {
|
|
28628
|
-
turnRequest = {
|
|
28629
|
-
...turnRequest,
|
|
28630
|
-
noteNativeHomeOpened: (runDirectory) => {
|
|
28631
|
-
openedNativeHomeRunDirectory = runDirectory;
|
|
28632
|
-
}
|
|
28633
|
-
};
|
|
28634
|
-
}
|
|
28635
28468
|
} catch (error) {
|
|
28636
28469
|
return await presentControlledFailure2(
|
|
28637
28470
|
admitted,
|
|
@@ -28666,58 +28499,35 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28666
28499
|
);
|
|
28667
28500
|
}
|
|
28668
28501
|
}
|
|
28669
|
-
let
|
|
28502
|
+
let result2;
|
|
28670
28503
|
try {
|
|
28671
|
-
|
|
28672
|
-
kind: "returned",
|
|
28673
|
-
result: await env.roleTurnHost.executeTurn(turnRequest)
|
|
28674
|
-
};
|
|
28504
|
+
result2 = await env.roleTurnHost.executeTurn(turnRequest);
|
|
28675
28505
|
} catch (error) {
|
|
28676
|
-
turnOutcome = { kind: "thrown", error };
|
|
28677
|
-
}
|
|
28678
|
-
let lastHostWriteFailure;
|
|
28679
|
-
const hostEngaged = turnOutcome.kind === "returned" || openedNativeHomeRunDirectory !== void 0;
|
|
28680
|
-
if (hostEngaged && liveHost !== void 0 && principalCoordinates !== void 0 && ticketSeatMemoryBound) {
|
|
28681
|
-
try {
|
|
28682
|
-
await writeTicketSeatMemoryLastHost(
|
|
28683
|
-
principalCoordinates.sessionDirectory,
|
|
28684
|
-
liveHost,
|
|
28685
|
-
liveHost === "grok-build" ? openedNativeHomeRunDirectory ?? nativeHomeRunDirectory ?? admitted.runDirectory : previousRunDirectory
|
|
28686
|
-
);
|
|
28687
|
-
} catch (error) {
|
|
28688
|
-
lastHostWriteFailure = { error };
|
|
28689
|
-
}
|
|
28690
|
-
}
|
|
28691
|
-
if (turnOutcome.kind === "thrown") {
|
|
28692
28506
|
return await presentControlledFailure2(
|
|
28693
28507
|
admitted,
|
|
28694
28508
|
{
|
|
28695
28509
|
timedOut: false,
|
|
28696
28510
|
code: null,
|
|
28697
28511
|
stderr: "",
|
|
28698
|
-
thrown:
|
|
28699
|
-
turnOutcome.error,
|
|
28700
|
-
lastHostWriteFailure,
|
|
28701
|
-
"host turn and ticket-seat last-host write failed"
|
|
28702
|
-
)
|
|
28512
|
+
thrown: error
|
|
28703
28513
|
},
|
|
28704
28514
|
adapters,
|
|
28705
28515
|
env.principalAuthority,
|
|
28706
28516
|
io
|
|
28707
28517
|
);
|
|
28708
28518
|
}
|
|
28709
|
-
const result2 = turnOutcome.result;
|
|
28710
28519
|
try {
|
|
28711
|
-
await
|
|
28712
|
-
|
|
28520
|
+
await writeFile8(
|
|
28521
|
+
join28(admitted.runDirectory, "stderr.log"),
|
|
28713
28522
|
result2.stderr,
|
|
28714
28523
|
"utf8"
|
|
28715
28524
|
);
|
|
28716
28525
|
} catch {
|
|
28717
28526
|
}
|
|
28718
28527
|
let settled;
|
|
28528
|
+
const courtScope = request.courtAttemptId === void 0 || request.courtAttemptId.length === 0 ? void 0 : { courtAttemptId: request.courtAttemptId };
|
|
28719
28529
|
try {
|
|
28720
|
-
settled = await adapters.trySettle(admitted, env.principalAuthority);
|
|
28530
|
+
settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
|
|
28721
28531
|
} catch (error) {
|
|
28722
28532
|
return await presentControlledFailure2(
|
|
28723
28533
|
admitted,
|
|
@@ -28725,11 +28535,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28725
28535
|
timedOut: false,
|
|
28726
28536
|
code: result2.code,
|
|
28727
28537
|
stderr: result2.stderr,
|
|
28728
|
-
thrown:
|
|
28729
|
-
error,
|
|
28730
|
-
lastHostWriteFailure,
|
|
28731
|
-
"settlement and ticket-seat last-host write failed"
|
|
28732
|
-
)
|
|
28538
|
+
thrown: error
|
|
28733
28539
|
},
|
|
28734
28540
|
adapters,
|
|
28735
28541
|
env.principalAuthority,
|
|
@@ -28737,38 +28543,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28737
28543
|
);
|
|
28738
28544
|
}
|
|
28739
28545
|
if (settled !== void 0 && shouldPresent(settled)) {
|
|
28740
|
-
if (
|
|
28741
|
-
|
|
28742
|
-
return await presentControlledFailure2(
|
|
28743
|
-
admitted,
|
|
28744
|
-
withLastHostWriteConcurrentFailure(
|
|
28745
|
-
{
|
|
28746
|
-
timedOut: result2.timedOut,
|
|
28747
|
-
code: result2.code,
|
|
28748
|
-
stderr: result2.stderr,
|
|
28749
|
-
knownFailure: knownFailureFromSettledFailureOutcome(
|
|
28750
|
-
settled.roleOutcome
|
|
28751
|
-
)
|
|
28752
|
-
},
|
|
28753
|
-
lastHostWriteFailure.error
|
|
28754
|
-
),
|
|
28755
|
-
adapters,
|
|
28756
|
-
env.principalAuthority,
|
|
28757
|
-
io
|
|
28758
|
-
);
|
|
28759
|
-
}
|
|
28760
|
-
return await presentControlledFailure2(
|
|
28761
|
-
admitted,
|
|
28762
|
-
{
|
|
28763
|
-
timedOut: result2.timedOut,
|
|
28764
|
-
code: result2.code,
|
|
28765
|
-
stderr: result2.stderr,
|
|
28766
|
-
thrown: lastHostWriteFailure.error
|
|
28767
|
-
},
|
|
28768
|
-
adapters,
|
|
28769
|
-
env.principalAuthority,
|
|
28770
|
-
io
|
|
28771
|
-
);
|
|
28546
|
+
if (settled.roleOutcome.kind === "accepted" && request.courtAttemptId !== void 0 && request.courtAttemptId.length > 0) {
|
|
28547
|
+
await clearCurrentCourt(admitted.runDirectory, request.courtAttemptId);
|
|
28772
28548
|
}
|
|
28773
28549
|
await markRunTerminal(admitted.runDirectory);
|
|
28774
28550
|
io.stdout(formatTerminalResult(settled));
|
|
@@ -28791,18 +28567,14 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28791
28567
|
credential: credentialFailure,
|
|
28792
28568
|
runDirectory: admitted.runDirectory
|
|
28793
28569
|
});
|
|
28794
|
-
const hostFailureInput = {
|
|
28795
|
-
timedOut: result2.timedOut,
|
|
28796
|
-
code: result2.code,
|
|
28797
|
-
stderr: result2.stderr,
|
|
28798
|
-
...controlledFailureInputFromResolution(resolution)
|
|
28799
|
-
};
|
|
28800
28570
|
return await presentControlledFailure2(
|
|
28801
28571
|
admitted,
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28572
|
+
{
|
|
28573
|
+
timedOut: result2.timedOut,
|
|
28574
|
+
code: result2.code,
|
|
28575
|
+
stderr: result2.stderr,
|
|
28576
|
+
...controlledFailureInputFromResolution(resolution)
|
|
28577
|
+
},
|
|
28806
28578
|
adapters,
|
|
28807
28579
|
env.principalAuthority,
|
|
28808
28580
|
io
|
|
@@ -28811,7 +28583,37 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28811
28583
|
await lease.release();
|
|
28812
28584
|
}
|
|
28813
28585
|
}
|
|
28814
|
-
function resumeTurnRequestProjectionOptions(admitted, request, env) {
|
|
28586
|
+
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
28587
|
+
const engineMaterial = engineSessionMaterialFromOptions({
|
|
28588
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28589
|
+
packageRoot: env.packageRoot
|
|
28590
|
+
});
|
|
28591
|
+
let prompt;
|
|
28592
|
+
if (request.message !== void 0) {
|
|
28593
|
+
if (summonsPrepared !== void 0 && summonsPrepared.attachments.length > 0) {
|
|
28594
|
+
prompt = buildInstructionTransportPrompt(
|
|
28595
|
+
{
|
|
28596
|
+
instruction: request.message,
|
|
28597
|
+
instructionEmpty: false,
|
|
28598
|
+
attachments: summonsPrepared.attachments
|
|
28599
|
+
},
|
|
28600
|
+
engineMaterial
|
|
28601
|
+
);
|
|
28602
|
+
} else {
|
|
28603
|
+
prompt = buildResumeContinuationPrompt({
|
|
28604
|
+
packageRoot: env.packageRoot,
|
|
28605
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28606
|
+
message: request.message
|
|
28607
|
+
});
|
|
28608
|
+
}
|
|
28609
|
+
} else if (summonsPrepared !== void 0) {
|
|
28610
|
+
prompt = buildInstructionTransportPrompt(summonsPrepared, engineMaterial);
|
|
28611
|
+
} else {
|
|
28612
|
+
prompt = buildResumeContinuationPrompt({
|
|
28613
|
+
packageRoot: env.packageRoot,
|
|
28614
|
+
...env.engine === void 0 ? {} : { engine: env.engine }
|
|
28615
|
+
});
|
|
28616
|
+
}
|
|
28815
28617
|
return {
|
|
28816
28618
|
packageRoot: env.packageRoot,
|
|
28817
28619
|
home: env.home,
|
|
@@ -28822,18 +28624,115 @@ function resumeTurnRequestProjectionOptions(admitted, request, env) {
|
|
|
28822
28624
|
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
28823
28625
|
continuation: {
|
|
28824
28626
|
kind: "resume",
|
|
28825
|
-
prompt
|
|
28826
|
-
packageRoot: env.packageRoot,
|
|
28827
|
-
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
28828
|
-
...request.message === void 0 ? {} : { message: request.message }
|
|
28829
|
-
})
|
|
28627
|
+
prompt
|
|
28830
28628
|
}
|
|
28831
28629
|
};
|
|
28832
28630
|
}
|
|
28631
|
+
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
28632
|
+
const absolute = isAbsolute6(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
|
|
28633
|
+
return pathContainedIn(join28(runDirectory, "attachments"), absolute);
|
|
28634
|
+
}
|
|
28635
|
+
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
28636
|
+
if (summons === void 0) return void 0;
|
|
28637
|
+
if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
|
|
28638
|
+
return void 0;
|
|
28639
|
+
}
|
|
28640
|
+
const instruction = summons.instruction ?? "";
|
|
28641
|
+
const instructionEmpty = summons.instructionEmpty ?? instruction.trim() === "";
|
|
28642
|
+
let attachments = [];
|
|
28643
|
+
if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
|
|
28644
|
+
const alreadyFrozen = summons.attachmentPaths.every(
|
|
28645
|
+
(path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
|
|
28646
|
+
);
|
|
28647
|
+
attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
|
|
28648
|
+
}
|
|
28649
|
+
return { instruction, instructionEmpty, attachments };
|
|
28650
|
+
}
|
|
28833
28651
|
async function runPostAdmissionSeatResume(input) {
|
|
28652
|
+
let request = input.request;
|
|
28834
28653
|
let loaded;
|
|
28835
28654
|
try {
|
|
28836
|
-
loaded = await input.load();
|
|
28655
|
+
loaded = await input.load(request);
|
|
28656
|
+
} catch (error) {
|
|
28657
|
+
if (error instanceof CliUsageError) {
|
|
28658
|
+
presentStructuralRejection(error, input.io);
|
|
28659
|
+
return { exitCode: 2 };
|
|
28660
|
+
}
|
|
28661
|
+
throw error;
|
|
28662
|
+
}
|
|
28663
|
+
try {
|
|
28664
|
+
return await runPostAdmissionManualResume({
|
|
28665
|
+
admitted: loaded.admitted,
|
|
28666
|
+
env: input.env,
|
|
28667
|
+
io: input.io,
|
|
28668
|
+
adapters: input.adapters,
|
|
28669
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
28670
|
+
forceContinuation: true,
|
|
28671
|
+
buildRequestAfterLease: async () => {
|
|
28672
|
+
let openCourtAttemptId;
|
|
28673
|
+
let admittedForBuild = loaded.admitted;
|
|
28674
|
+
if (request.summons === void 0) {
|
|
28675
|
+
const openCourt = await readCurrentCourt(admittedForBuild.runDirectory);
|
|
28676
|
+
if (openCourt !== void 0) {
|
|
28677
|
+
const sealedForOpen = await readSealedSubmission(
|
|
28678
|
+
admittedForBuild.projectRoot,
|
|
28679
|
+
admittedForBuild.runId,
|
|
28680
|
+
{
|
|
28681
|
+
home: homeFromRunDirectory(admittedForBuild.runDirectory),
|
|
28682
|
+
attemptId: openCourt.courtAttemptId
|
|
28683
|
+
}
|
|
28684
|
+
);
|
|
28685
|
+
if (sealedForOpen === void 0) {
|
|
28686
|
+
openCourtAttemptId = openCourt.courtAttemptId;
|
|
28687
|
+
request = {
|
|
28688
|
+
runId: request.runId,
|
|
28689
|
+
...request.message === void 0 ? {} : { message: request.message },
|
|
28690
|
+
...openCourt.summons === void 0 ? {} : { summons: openCourt.summons }
|
|
28691
|
+
};
|
|
28692
|
+
if (openCourt.summons !== void 0) {
|
|
28693
|
+
const reloaded = await input.load(request);
|
|
28694
|
+
admittedForBuild = reloaded.admitted;
|
|
28695
|
+
}
|
|
28696
|
+
} else {
|
|
28697
|
+
await clearCurrentCourt(
|
|
28698
|
+
admittedForBuild.runDirectory,
|
|
28699
|
+
openCourt.courtAttemptId
|
|
28700
|
+
);
|
|
28701
|
+
}
|
|
28702
|
+
}
|
|
28703
|
+
}
|
|
28704
|
+
if (request.summons !== void 0) {
|
|
28705
|
+
const prepared = await prepareSummonsResumeMaterials(
|
|
28706
|
+
admittedForBuild.runDirectory,
|
|
28707
|
+
request.summons
|
|
28708
|
+
);
|
|
28709
|
+
if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
|
|
28710
|
+
request = {
|
|
28711
|
+
...request,
|
|
28712
|
+
summons: {
|
|
28713
|
+
...request.summons,
|
|
28714
|
+
attachmentPaths: prepared.attachments.map(
|
|
28715
|
+
(attachment) => attachment.frozenPath
|
|
28716
|
+
)
|
|
28717
|
+
}
|
|
28718
|
+
};
|
|
28719
|
+
}
|
|
28720
|
+
}
|
|
28721
|
+
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
28722
|
+
if (openCourtAttemptId !== void 0 || request.summons !== void 0) {
|
|
28723
|
+
const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID5());
|
|
28724
|
+
turnRequest = { ...turnRequest, courtAttemptId };
|
|
28725
|
+
if (openCourtAttemptId === void 0) {
|
|
28726
|
+
const court = {
|
|
28727
|
+
courtAttemptId,
|
|
28728
|
+
...request.summons === void 0 ? {} : { summons: request.summons }
|
|
28729
|
+
};
|
|
28730
|
+
await recordCurrentCourt(admittedForBuild.runDirectory, court);
|
|
28731
|
+
}
|
|
28732
|
+
}
|
|
28733
|
+
return turnRequest;
|
|
28734
|
+
}
|
|
28735
|
+
});
|
|
28837
28736
|
} catch (error) {
|
|
28838
28737
|
if (error instanceof CliUsageError) {
|
|
28839
28738
|
presentStructuralRejection(error, input.io);
|
|
@@ -28841,14 +28740,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28841
28740
|
}
|
|
28842
28741
|
throw error;
|
|
28843
28742
|
}
|
|
28844
|
-
return await runPostAdmissionManualResume({
|
|
28845
|
-
admitted: loaded.admitted,
|
|
28846
|
-
env: input.env,
|
|
28847
|
-
io: input.io,
|
|
28848
|
-
request: input.buildTurnRequest(loaded.admitted),
|
|
28849
|
-
adapters: input.adapters,
|
|
28850
|
-
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
28851
|
-
});
|
|
28852
28743
|
}
|
|
28853
28744
|
async function runPostAdmissionOneShot(input) {
|
|
28854
28745
|
const { admitted, env, io, request, adapters, effectiveEngine } = input;
|
|
@@ -28901,10 +28792,8 @@ async function runPostAdmissionResumable(input) {
|
|
|
28901
28792
|
})
|
|
28902
28793
|
});
|
|
28903
28794
|
}
|
|
28904
|
-
async function
|
|
28905
|
-
const { admitted, env, io,
|
|
28906
|
-
const effectiveModel = env.model;
|
|
28907
|
-
const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
|
|
28795
|
+
async function presentSealedAcceptedManualResumeIfAny(input) {
|
|
28796
|
+
const { admitted, env, io, adapters, shouldPresent } = input;
|
|
28908
28797
|
try {
|
|
28909
28798
|
const existing = await adapters.trySettle(admitted, env.principalAuthority);
|
|
28910
28799
|
if (existing !== void 0 && existing.roleOutcome.kind === "accepted" && shouldPresent(existing)) {
|
|
@@ -28933,6 +28822,34 @@ async function runPostAdmissionManualResume(input) {
|
|
|
28933
28822
|
);
|
|
28934
28823
|
}
|
|
28935
28824
|
}
|
|
28825
|
+
return void 0;
|
|
28826
|
+
}
|
|
28827
|
+
async function runPostAdmissionManualResume(input) {
|
|
28828
|
+
const {
|
|
28829
|
+
admitted,
|
|
28830
|
+
env,
|
|
28831
|
+
io,
|
|
28832
|
+
adapters,
|
|
28833
|
+
effectiveEngine,
|
|
28834
|
+
forceContinuation,
|
|
28835
|
+
buildRequestAfterLease
|
|
28836
|
+
} = input;
|
|
28837
|
+
let request = input.request;
|
|
28838
|
+
const effectiveModel = env.model;
|
|
28839
|
+
const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
|
|
28840
|
+
const sealedIdempotenceInput = {
|
|
28841
|
+
admitted,
|
|
28842
|
+
env,
|
|
28843
|
+
io,
|
|
28844
|
+
adapters,
|
|
28845
|
+
shouldPresent
|
|
28846
|
+
};
|
|
28847
|
+
if (forceContinuation !== true && request !== void 0) {
|
|
28848
|
+
const presented = await presentSealedAcceptedManualResumeIfAny(
|
|
28849
|
+
sealedIdempotenceInput
|
|
28850
|
+
);
|
|
28851
|
+
if (presented !== void 0) return presented;
|
|
28852
|
+
}
|
|
28936
28853
|
let lease;
|
|
28937
28854
|
let staleWriterLeaseReclaimed;
|
|
28938
28855
|
try {
|
|
@@ -28950,36 +28867,67 @@ async function runPostAdmissionManualResume(input) {
|
|
|
28950
28867
|
}
|
|
28951
28868
|
throw error;
|
|
28952
28869
|
}
|
|
28953
|
-
|
|
28954
|
-
|
|
28955
|
-
|
|
28956
|
-
|
|
28957
|
-
|
|
28958
|
-
|
|
28959
|
-
|
|
28960
|
-
|
|
28961
|
-
|
|
28962
|
-
|
|
28963
|
-
|
|
28964
|
-
|
|
28965
|
-
|
|
28966
|
-
|
|
28967
|
-
|
|
28870
|
+
let handedOffToDispatch = false;
|
|
28871
|
+
try {
|
|
28872
|
+
if (request === void 0) {
|
|
28873
|
+
if (buildRequestAfterLease === void 0) {
|
|
28874
|
+
throw new Error(
|
|
28875
|
+
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
28876
|
+
);
|
|
28877
|
+
}
|
|
28878
|
+
request = await buildRequestAfterLease();
|
|
28879
|
+
if (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) {
|
|
28880
|
+
const presented = await presentSealedAcceptedManualResumeIfAny(
|
|
28881
|
+
sealedIdempotenceInput
|
|
28882
|
+
);
|
|
28883
|
+
if (presented !== void 0) {
|
|
28884
|
+
return {
|
|
28885
|
+
...presented,
|
|
28886
|
+
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
28887
|
+
};
|
|
28888
|
+
}
|
|
28889
|
+
}
|
|
28890
|
+
}
|
|
28891
|
+
handedOffToDispatch = true;
|
|
28892
|
+
const result2 = await dispatchPostAdmissionTurn({
|
|
28893
|
+
admitted,
|
|
28894
|
+
env: {
|
|
28895
|
+
...env,
|
|
28896
|
+
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
28897
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
28898
|
+
},
|
|
28899
|
+
io,
|
|
28900
|
+
request,
|
|
28901
|
+
lease,
|
|
28902
|
+
adapters,
|
|
28903
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
28904
|
+
});
|
|
28905
|
+
if (result2.terminal !== void 0) {
|
|
28906
|
+
result2.terminal.autoResumeCount = 0;
|
|
28907
|
+
}
|
|
28908
|
+
return {
|
|
28909
|
+
...result2,
|
|
28910
|
+
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
28911
|
+
};
|
|
28912
|
+
} finally {
|
|
28913
|
+
if (!handedOffToDispatch) {
|
|
28914
|
+
await lease.release();
|
|
28915
|
+
}
|
|
28968
28916
|
}
|
|
28969
|
-
return {
|
|
28970
|
-
...result2,
|
|
28971
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
28972
|
-
};
|
|
28973
28917
|
}
|
|
28974
28918
|
var init_post_admission = __esm({
|
|
28975
28919
|
"src/public-cli/post-admission.ts"() {
|
|
28976
28920
|
"use strict";
|
|
28977
28921
|
init_run_lifecycle();
|
|
28978
28922
|
init_cli_errors();
|
|
28923
|
+
init_invocation();
|
|
28924
|
+
init_activation_ledger_topology();
|
|
28925
|
+
init_engine_material();
|
|
28979
28926
|
init_host_transition_prior_native();
|
|
28980
|
-
init_ticket_seat_memory();
|
|
28981
28927
|
init_public_run_credentials();
|
|
28982
28928
|
init_run_lifecycle();
|
|
28929
|
+
init_activation_ledger_topology();
|
|
28930
|
+
init_submission_ledger();
|
|
28983
28931
|
init_settlement();
|
|
28984
28932
|
init_terminal();
|
|
28985
28933
|
init_auto_resume();
|
|
@@ -29184,7 +29132,7 @@ function buildInstructionSeatTurnRequest(admitted, options) {
|
|
|
29184
29132
|
}
|
|
29185
29133
|
function instructionSeatAdapters() {
|
|
29186
29134
|
return {
|
|
29187
|
-
trySettle: (admitted, authority) => admitted.role === "gatekeeper" ? trySettleGatekeeperTerminalResult(admitted, authority) : trySettleNavigatorTerminalResult(admitted, authority),
|
|
29135
|
+
trySettle: (admitted, authority, scope) => admitted.role === "gatekeeper" ? trySettleGatekeeperTerminalResult(admitted, authority, scope) : trySettleNavigatorTerminalResult(admitted, authority, scope),
|
|
29188
29136
|
// Accepted receipts and failure terminals both present via shared path.
|
|
29189
29137
|
shouldPresentSettled: () => true
|
|
29190
29138
|
};
|
|
@@ -29194,14 +29142,14 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
29194
29142
|
request,
|
|
29195
29143
|
env,
|
|
29196
29144
|
io,
|
|
29197
|
-
load: () => loadResumableInstructionSeatRun(
|
|
29145
|
+
load: (effective) => loadResumableInstructionSeatRun(
|
|
29198
29146
|
env.home,
|
|
29199
|
-
|
|
29147
|
+
effective.runId,
|
|
29200
29148
|
env.principalAuthority
|
|
29201
29149
|
),
|
|
29202
|
-
buildTurnRequest: (admitted) => buildInstructionSeatTurnRequest(
|
|
29150
|
+
buildTurnRequest: (admitted, effective) => buildInstructionSeatTurnRequest(
|
|
29203
29151
|
admitted,
|
|
29204
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
29152
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
29205
29153
|
),
|
|
29206
29154
|
adapters: instructionSeatAdapters(),
|
|
29207
29155
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -29353,14 +29301,14 @@ async function runPublicCollectorResume(request, env, io) {
|
|
|
29353
29301
|
request,
|
|
29354
29302
|
env,
|
|
29355
29303
|
io,
|
|
29356
|
-
load: () => loadResumableCollectorRun(
|
|
29304
|
+
load: (effective) => loadResumableCollectorRun(
|
|
29357
29305
|
env.home,
|
|
29358
|
-
|
|
29306
|
+
effective.runId,
|
|
29359
29307
|
env.principalAuthority
|
|
29360
29308
|
),
|
|
29361
|
-
buildTurnRequest: (admitted) => buildCollectorTurnRequest(
|
|
29309
|
+
buildTurnRequest: (admitted, effective) => buildCollectorTurnRequest(
|
|
29362
29310
|
admitted,
|
|
29363
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
29311
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
29364
29312
|
),
|
|
29365
29313
|
adapters: collectorAdapters(),
|
|
29366
29314
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -29394,9 +29342,45 @@ function buildCountersignTurnRequest(admitted, options) {
|
|
|
29394
29342
|
);
|
|
29395
29343
|
}
|
|
29396
29344
|
async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
29345
|
+
let parsed;
|
|
29346
|
+
try {
|
|
29347
|
+
parsed = parseCountersignArgv2(argv);
|
|
29348
|
+
} catch (error) {
|
|
29349
|
+
if (error instanceof CliUsageError) {
|
|
29350
|
+
presentStructuralRejection(error, io);
|
|
29351
|
+
return { exitCode: 2 };
|
|
29352
|
+
}
|
|
29353
|
+
throw error;
|
|
29354
|
+
}
|
|
29355
|
+
const projectRoot = parsed.project ?? env.cwd;
|
|
29356
|
+
const ticketProbe = await probeInstructionTicket(
|
|
29357
|
+
parsed.instruction,
|
|
29358
|
+
projectRoot,
|
|
29359
|
+
env
|
|
29360
|
+
);
|
|
29361
|
+
const probedTicketNumber = ticketNumberFromProbe(ticketProbe);
|
|
29362
|
+
if (probedTicketNumber !== void 0) {
|
|
29363
|
+
const summons = {
|
|
29364
|
+
instruction: parsed.instruction,
|
|
29365
|
+
instructionEmpty: parsed.instruction.trim() === "",
|
|
29366
|
+
attachmentPaths: parsed.attachmentPaths
|
|
29367
|
+
};
|
|
29368
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
29369
|
+
home: env.home,
|
|
29370
|
+
projectRoot,
|
|
29371
|
+
role: "countersign",
|
|
29372
|
+
ticketNumber: probedTicketNumber,
|
|
29373
|
+
summons,
|
|
29374
|
+
resume: (runId, materials) => runPublicCountersignResume(
|
|
29375
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
29376
|
+
env,
|
|
29377
|
+
io
|
|
29378
|
+
)
|
|
29379
|
+
});
|
|
29380
|
+
if (resumed !== void 0) return resumed;
|
|
29381
|
+
}
|
|
29397
29382
|
let admitted;
|
|
29398
29383
|
try {
|
|
29399
|
-
const parsed = parseCountersignArgv2(argv);
|
|
29400
29384
|
admitted = await admitCountersignInvocation({
|
|
29401
29385
|
home: env.home,
|
|
29402
29386
|
principalAuthority: env.principalAuthority,
|
|
@@ -29443,7 +29427,7 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29443
29427
|
request: turnRequest,
|
|
29444
29428
|
adapters: countersignAdapters({
|
|
29445
29429
|
beforeDispatch: async (admitted2) => {
|
|
29446
|
-
await
|
|
29430
|
+
await applyInstructionTicketProbe(admitted2, ticketProbe);
|
|
29447
29431
|
Object.assign(
|
|
29448
29432
|
turnRequest,
|
|
29449
29433
|
buildCountersignTurnRequest(admitted2, turnProjection)
|
|
@@ -29456,7 +29440,7 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29456
29440
|
}
|
|
29457
29441
|
function countersignAdapters(options) {
|
|
29458
29442
|
return {
|
|
29459
|
-
trySettle: (admitted, authority) => trySettleCountersignTerminalResult(admitted, authority),
|
|
29443
|
+
trySettle: (admitted, authority, scope) => trySettleCountersignTerminalResult(admitted, authority, scope),
|
|
29460
29444
|
// Accepted receipts and failure terminals both present via shared path.
|
|
29461
29445
|
shouldPresentSettled: () => true,
|
|
29462
29446
|
...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
|
|
@@ -29467,16 +29451,31 @@ async function runPublicCountersignResume(request, env, io) {
|
|
|
29467
29451
|
request,
|
|
29468
29452
|
env,
|
|
29469
29453
|
io,
|
|
29470
|
-
load: () => loadResumableCountersignRun(
|
|
29454
|
+
load: (effective) => loadResumableCountersignRun(
|
|
29471
29455
|
env.home,
|
|
29472
|
-
|
|
29456
|
+
effective.runId,
|
|
29473
29457
|
env.principalAuthority
|
|
29474
29458
|
),
|
|
29475
|
-
buildTurnRequest: (admitted) =>
|
|
29476
|
-
|
|
29477
|
-
|
|
29478
|
-
|
|
29479
|
-
|
|
29459
|
+
buildTurnRequest: async (admitted, effective) => {
|
|
29460
|
+
const summonsPrepared = await prepareSummonsResumeMaterials(
|
|
29461
|
+
admitted.runDirectory,
|
|
29462
|
+
effective.summons
|
|
29463
|
+
);
|
|
29464
|
+
return buildCountersignTurnRequest(
|
|
29465
|
+
admitted,
|
|
29466
|
+
resumeTurnRequestProjectionOptions(
|
|
29467
|
+
admitted,
|
|
29468
|
+
effective,
|
|
29469
|
+
env,
|
|
29470
|
+
summonsPrepared
|
|
29471
|
+
)
|
|
29472
|
+
);
|
|
29473
|
+
},
|
|
29474
|
+
adapters: countersignAdapters({
|
|
29475
|
+
beforeDispatch: async (admitted) => {
|
|
29476
|
+
await runCountersignDiaristStation(admitted, env);
|
|
29477
|
+
}
|
|
29478
|
+
}),
|
|
29480
29479
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29481
29480
|
});
|
|
29482
29481
|
}
|
|
@@ -29632,7 +29631,7 @@ async function runPublicGleanerLeft(argv, env, io, parseGleanerLeftArgv2) {
|
|
|
29632
29631
|
}
|
|
29633
29632
|
function gleanerLeftAdapters() {
|
|
29634
29633
|
return {
|
|
29635
|
-
trySettle: (admitted, authority) => trySettleGleanerLeftTerminalResult(admitted, authority),
|
|
29634
|
+
trySettle: (admitted, authority, scope) => trySettleGleanerLeftTerminalResult(admitted, authority, scope),
|
|
29636
29635
|
shouldPresentSettled: () => true
|
|
29637
29636
|
};
|
|
29638
29637
|
}
|
|
@@ -29641,14 +29640,14 @@ async function runPublicGleanerLeftResume(request, env, io) {
|
|
|
29641
29640
|
request,
|
|
29642
29641
|
env,
|
|
29643
29642
|
io,
|
|
29644
|
-
load: () => loadResumableGleanerLeftRun(
|
|
29643
|
+
load: (effective) => loadResumableGleanerLeftRun(
|
|
29645
29644
|
env.home,
|
|
29646
|
-
|
|
29645
|
+
effective.runId,
|
|
29647
29646
|
env.principalAuthority
|
|
29648
29647
|
),
|
|
29649
|
-
buildTurnRequest: (admitted) => buildGleanerLeftTurnRequest(
|
|
29648
|
+
buildTurnRequest: (admitted, effective) => buildGleanerLeftTurnRequest(
|
|
29650
29649
|
admitted,
|
|
29651
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
29650
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
29652
29651
|
),
|
|
29653
29652
|
adapters: gleanerLeftAdapters(),
|
|
29654
29653
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -29734,14 +29733,14 @@ async function runPublicDoctorResume(request, env, io) {
|
|
|
29734
29733
|
request,
|
|
29735
29734
|
env,
|
|
29736
29735
|
io,
|
|
29737
|
-
load: () => loadResumableDoctorRun(
|
|
29736
|
+
load: (effective) => loadResumableDoctorRun(
|
|
29738
29737
|
env.home,
|
|
29739
|
-
|
|
29738
|
+
effective.runId,
|
|
29740
29739
|
env.principalAuthority
|
|
29741
29740
|
),
|
|
29742
|
-
buildTurnRequest: (admitted) => buildDoctorTurnRequest(
|
|
29741
|
+
buildTurnRequest: (admitted, effective) => buildDoctorTurnRequest(
|
|
29743
29742
|
admitted,
|
|
29744
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
29743
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
29745
29744
|
),
|
|
29746
29745
|
adapters: doctorAdapters(),
|
|
29747
29746
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -29960,9 +29959,53 @@ function buildNotaryTurnRequest(admitted, options) {
|
|
|
29960
29959
|
);
|
|
29961
29960
|
}
|
|
29962
29961
|
async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
29962
|
+
let parsed;
|
|
29963
|
+
try {
|
|
29964
|
+
parsed = parseNotaryArgv2(argv);
|
|
29965
|
+
} catch (error) {
|
|
29966
|
+
if (error instanceof CliUsageError) {
|
|
29967
|
+
presentStructuralRejection(error, io);
|
|
29968
|
+
return { exitCode: 2 };
|
|
29969
|
+
}
|
|
29970
|
+
throw error;
|
|
29971
|
+
}
|
|
29972
|
+
const projectRoot = parsed.project ?? env.cwd;
|
|
29973
|
+
let source;
|
|
29974
|
+
try {
|
|
29975
|
+
source = await resolveNotarySourceRunLocator({
|
|
29976
|
+
projectRoot,
|
|
29977
|
+
sourceRun: parsed.sourceRun,
|
|
29978
|
+
home: env.home
|
|
29979
|
+
});
|
|
29980
|
+
} catch (error) {
|
|
29981
|
+
if (error instanceof NotarySourceRunError) {
|
|
29982
|
+
presentStructuralRejection(new CliUsageError(error.message, { cause: error }), io);
|
|
29983
|
+
return { exitCode: 2 };
|
|
29984
|
+
}
|
|
29985
|
+
throw error;
|
|
29986
|
+
}
|
|
29987
|
+
const ticketNumber = await readRunTicketNumber(source.runDirectory);
|
|
29988
|
+
if (ticketNumber !== void 0) {
|
|
29989
|
+
const summons = {
|
|
29990
|
+
sourceRunPath: source.runDirectory,
|
|
29991
|
+
sourceRun: source
|
|
29992
|
+
};
|
|
29993
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
29994
|
+
home: env.home,
|
|
29995
|
+
projectRoot,
|
|
29996
|
+
role: "notary",
|
|
29997
|
+
ticketNumber,
|
|
29998
|
+
summons,
|
|
29999
|
+
resume: (runId, materials) => runPublicNotaryResume(
|
|
30000
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
30001
|
+
env,
|
|
30002
|
+
io
|
|
30003
|
+
)
|
|
30004
|
+
});
|
|
30005
|
+
if (resumed !== void 0) return resumed;
|
|
30006
|
+
}
|
|
29963
30007
|
let admitted;
|
|
29964
30008
|
try {
|
|
29965
|
-
const parsed = parseNotaryArgv2(argv);
|
|
29966
30009
|
admitted = await admitNotaryInvocation({
|
|
29967
30010
|
home: env.home,
|
|
29968
30011
|
principalAuthority: env.principalAuthority,
|
|
@@ -29980,20 +30023,11 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
29980
30023
|
}
|
|
29981
30024
|
throw error;
|
|
29982
30025
|
}
|
|
29983
|
-
const memory = await rebindAdmittedToTicketSeatMemory({
|
|
29984
|
-
admitted,
|
|
29985
|
-
seat: "notary",
|
|
29986
|
-
principalAuthority: env.principalAuthority
|
|
29987
|
-
});
|
|
29988
30026
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
29989
30027
|
const engineMaterial = engineSessionMaterialFromOptions({
|
|
29990
30028
|
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
29991
30029
|
packageRoot: env.packageRoot
|
|
29992
30030
|
});
|
|
29993
|
-
const continuation = {
|
|
29994
|
-
kind: memory?.resumed === true ? "resume" : "initial",
|
|
29995
|
-
prompt: buildNotaryTransportPrompt(admitted, engineMaterial)
|
|
29996
|
-
};
|
|
29997
30031
|
const turnRequest = buildNotaryTurnRequest(admitted, {
|
|
29998
30032
|
packageRoot: env.packageRoot,
|
|
29999
30033
|
home: env.home,
|
|
@@ -30002,7 +30036,10 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
30002
30036
|
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
30003
30037
|
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
30004
30038
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
30005
|
-
continuation
|
|
30039
|
+
continuation: {
|
|
30040
|
+
kind: "initial",
|
|
30041
|
+
prompt: buildNotaryTransportPrompt(admitted, engineMaterial)
|
|
30042
|
+
}
|
|
30006
30043
|
});
|
|
30007
30044
|
return await runPostAdmissionOneShot({
|
|
30008
30045
|
admitted,
|
|
@@ -30015,7 +30052,7 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
30015
30052
|
}
|
|
30016
30053
|
function notaryAdapters() {
|
|
30017
30054
|
return {
|
|
30018
|
-
trySettle: (admitted, authority) => trySettleNotaryTerminalResult(admitted, authority),
|
|
30055
|
+
trySettle: (admitted, authority, scope) => trySettleNotaryTerminalResult(admitted, authority, scope),
|
|
30019
30056
|
// Accepted receipts and failure terminals both present via shared path.
|
|
30020
30057
|
shouldPresentSettled: () => true
|
|
30021
30058
|
};
|
|
@@ -30025,21 +30062,32 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
30025
30062
|
request,
|
|
30026
30063
|
env,
|
|
30027
30064
|
io,
|
|
30028
|
-
load: () => {
|
|
30029
|
-
if (
|
|
30065
|
+
load: async (effective) => {
|
|
30066
|
+
if (effective.message !== void 0) {
|
|
30030
30067
|
throw new CliUsageError(
|
|
30031
30068
|
"notary rejects caller prompt/instruction; only zero caller-prompt continuation admitted"
|
|
30032
30069
|
);
|
|
30033
30070
|
}
|
|
30034
|
-
|
|
30071
|
+
const loaded = await loadResumableNotaryRun(
|
|
30035
30072
|
env.home,
|
|
30036
|
-
|
|
30073
|
+
effective.runId,
|
|
30037
30074
|
env.principalAuthority
|
|
30038
30075
|
);
|
|
30076
|
+
const summons = effective.summons;
|
|
30077
|
+
if (summons?.sourceRunPath !== void 0 && summons.sourceRun !== void 0) {
|
|
30078
|
+
return {
|
|
30079
|
+
admitted: {
|
|
30080
|
+
...loaded.admitted,
|
|
30081
|
+
sourceRunPath: summons.sourceRunPath,
|
|
30082
|
+
sourceRun: summons.sourceRun
|
|
30083
|
+
}
|
|
30084
|
+
};
|
|
30085
|
+
}
|
|
30086
|
+
return loaded;
|
|
30039
30087
|
},
|
|
30040
|
-
buildTurnRequest: (admitted) => buildNotaryTurnRequest(
|
|
30088
|
+
buildTurnRequest: (admitted, effective) => buildNotaryTurnRequest(
|
|
30041
30089
|
admitted,
|
|
30042
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
30090
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
30043
30091
|
),
|
|
30044
30092
|
adapters: notaryAdapters(),
|
|
30045
30093
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -30048,10 +30096,12 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
30048
30096
|
var init_notary_run = __esm({
|
|
30049
30097
|
"src/public-cli/notary-run.ts"() {
|
|
30050
30098
|
"use strict";
|
|
30099
|
+
init_notary_source_run();
|
|
30051
30100
|
init_engine_material();
|
|
30052
|
-
|
|
30101
|
+
init_run_ticket_number();
|
|
30053
30102
|
init_cli_errors();
|
|
30054
30103
|
init_invocation();
|
|
30104
|
+
init_seat_ticket_binding();
|
|
30055
30105
|
init_post_admission();
|
|
30056
30106
|
init_run_lifecycle();
|
|
30057
30107
|
init_settlement();
|
|
@@ -30072,9 +30122,45 @@ function buildInspectorTurnRequest(admitted, options) {
|
|
|
30072
30122
|
);
|
|
30073
30123
|
}
|
|
30074
30124
|
async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
30125
|
+
let parsed;
|
|
30126
|
+
try {
|
|
30127
|
+
parsed = parseInspectorArgv2(argv);
|
|
30128
|
+
} catch (error) {
|
|
30129
|
+
if (error instanceof CliUsageError) {
|
|
30130
|
+
presentStructuralRejection(error, io);
|
|
30131
|
+
return { exitCode: 2 };
|
|
30132
|
+
}
|
|
30133
|
+
throw error;
|
|
30134
|
+
}
|
|
30135
|
+
const projectRoot = parsed.project ?? env.cwd;
|
|
30136
|
+
const ticketProbe = await probeInstructionTicket(
|
|
30137
|
+
parsed.instruction,
|
|
30138
|
+
projectRoot,
|
|
30139
|
+
env
|
|
30140
|
+
);
|
|
30141
|
+
const probedTicketNumber = ticketNumberFromProbe(ticketProbe);
|
|
30142
|
+
if (probedTicketNumber !== void 0) {
|
|
30143
|
+
const summons = {
|
|
30144
|
+
instruction: parsed.instruction,
|
|
30145
|
+
instructionEmpty: parsed.instruction.trim() === "",
|
|
30146
|
+
attachmentPaths: parsed.attachmentPaths
|
|
30147
|
+
};
|
|
30148
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
30149
|
+
home: env.home,
|
|
30150
|
+
projectRoot,
|
|
30151
|
+
role: "inspector",
|
|
30152
|
+
ticketNumber: probedTicketNumber,
|
|
30153
|
+
summons,
|
|
30154
|
+
resume: (runId, materials) => runPublicInspectorResume(
|
|
30155
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
30156
|
+
env,
|
|
30157
|
+
io
|
|
30158
|
+
)
|
|
30159
|
+
});
|
|
30160
|
+
if (resumed !== void 0) return resumed;
|
|
30161
|
+
}
|
|
30075
30162
|
let admitted;
|
|
30076
30163
|
try {
|
|
30077
|
-
const parsed = parseInspectorArgv2(argv);
|
|
30078
30164
|
admitted = await admitInspectorInvocation({
|
|
30079
30165
|
home: env.home,
|
|
30080
30166
|
principalAuthority: env.principalAuthority,
|
|
@@ -30093,21 +30179,11 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
30093
30179
|
}
|
|
30094
30180
|
throw error;
|
|
30095
30181
|
}
|
|
30096
|
-
await resolveSeatTicketBinding(admitted, env);
|
|
30097
|
-
const memory = await rebindAdmittedToTicketSeatMemory({
|
|
30098
|
-
admitted,
|
|
30099
|
-
seat: "inspector",
|
|
30100
|
-
principalAuthority: env.principalAuthority
|
|
30101
|
-
});
|
|
30102
30182
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
30103
30183
|
const engineMaterial = engineSessionMaterialFromOptions({
|
|
30104
30184
|
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
30105
30185
|
packageRoot: env.packageRoot
|
|
30106
30186
|
});
|
|
30107
|
-
const continuation = {
|
|
30108
|
-
kind: memory?.resumed === true ? "resume" : "initial",
|
|
30109
|
-
prompt: buildInspectorTransportPrompt(admitted, engineMaterial)
|
|
30110
|
-
};
|
|
30111
30187
|
const turnRequest = buildInspectorTurnRequest(admitted, {
|
|
30112
30188
|
packageRoot: env.packageRoot,
|
|
30113
30189
|
home: env.home,
|
|
@@ -30116,21 +30192,29 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
30116
30192
|
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
30117
30193
|
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
30118
30194
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
30119
|
-
continuation
|
|
30195
|
+
continuation: {
|
|
30196
|
+
kind: "initial",
|
|
30197
|
+
prompt: buildInspectorTransportPrompt(admitted, engineMaterial)
|
|
30198
|
+
}
|
|
30120
30199
|
});
|
|
30121
30200
|
return await runPostAdmissionOneShot({
|
|
30122
30201
|
admitted,
|
|
30123
30202
|
env,
|
|
30124
30203
|
io,
|
|
30125
30204
|
request: turnRequest,
|
|
30126
|
-
adapters: inspectorAdapters(
|
|
30205
|
+
adapters: inspectorAdapters({
|
|
30206
|
+
beforeDispatch: async (admittedSeat) => {
|
|
30207
|
+
await applyInstructionTicketProbe(admittedSeat, ticketProbe);
|
|
30208
|
+
}
|
|
30209
|
+
}),
|
|
30127
30210
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
30128
30211
|
});
|
|
30129
30212
|
}
|
|
30130
|
-
function inspectorAdapters() {
|
|
30213
|
+
function inspectorAdapters(options) {
|
|
30131
30214
|
return {
|
|
30132
|
-
trySettle: (admitted, authority) => trySettleInspectorTerminalResult(admitted, authority),
|
|
30133
|
-
shouldPresentSettled: () => true
|
|
30215
|
+
trySettle: (admitted, authority, scope) => trySettleInspectorTerminalResult(admitted, authority, scope),
|
|
30216
|
+
shouldPresentSettled: () => true,
|
|
30217
|
+
...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
|
|
30134
30218
|
};
|
|
30135
30219
|
}
|
|
30136
30220
|
async function runPublicInspectorResume(request, env, io) {
|
|
@@ -30138,15 +30222,26 @@ async function runPublicInspectorResume(request, env, io) {
|
|
|
30138
30222
|
request,
|
|
30139
30223
|
env,
|
|
30140
30224
|
io,
|
|
30141
|
-
load: () => loadResumableInspectorRun(
|
|
30225
|
+
load: (effective) => loadResumableInspectorRun(
|
|
30142
30226
|
env.home,
|
|
30143
|
-
|
|
30227
|
+
effective.runId,
|
|
30144
30228
|
env.principalAuthority
|
|
30145
30229
|
),
|
|
30146
|
-
buildTurnRequest: (admitted) =>
|
|
30147
|
-
|
|
30148
|
-
|
|
30149
|
-
|
|
30230
|
+
buildTurnRequest: async (admitted, effective) => {
|
|
30231
|
+
const summonsPrepared = await prepareSummonsResumeMaterials(
|
|
30232
|
+
admitted.runDirectory,
|
|
30233
|
+
effective.summons
|
|
30234
|
+
);
|
|
30235
|
+
return buildInspectorTurnRequest(
|
|
30236
|
+
admitted,
|
|
30237
|
+
resumeTurnRequestProjectionOptions(
|
|
30238
|
+
admitted,
|
|
30239
|
+
effective,
|
|
30240
|
+
env,
|
|
30241
|
+
summonsPrepared
|
|
30242
|
+
)
|
|
30243
|
+
);
|
|
30244
|
+
},
|
|
30150
30245
|
adapters: inspectorAdapters(),
|
|
30151
30246
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
30152
30247
|
});
|
|
@@ -30155,7 +30250,6 @@ var init_inspector_run = __esm({
|
|
|
30155
30250
|
"src/public-cli/inspector-run.ts"() {
|
|
30156
30251
|
"use strict";
|
|
30157
30252
|
init_engine_material();
|
|
30158
|
-
init_ticket_seat_memory();
|
|
30159
30253
|
init_cli_errors();
|
|
30160
30254
|
init_seat_ticket_binding();
|
|
30161
30255
|
init_invocation();
|
|
@@ -30258,10 +30352,10 @@ async function runPublicResume(request, env, io) {
|
|
|
30258
30352
|
request,
|
|
30259
30353
|
env,
|
|
30260
30354
|
io,
|
|
30261
|
-
load: () => loadResumableJudgeRun(env.home,
|
|
30262
|
-
buildTurnRequest: (admitted) => buildJudgeTurnRequest(
|
|
30355
|
+
load: (effective) => loadResumableJudgeRun(env.home, effective.runId, env.principalAuthority),
|
|
30356
|
+
buildTurnRequest: (admitted, effective) => buildJudgeTurnRequest(
|
|
30263
30357
|
admitted,
|
|
30264
|
-
resumeTurnRequestProjectionOptions(admitted,
|
|
30358
|
+
resumeTurnRequestProjectionOptions(admitted, effective, env)
|
|
30265
30359
|
),
|
|
30266
30360
|
adapters: judgeAdapters(),
|
|
30267
30361
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -30282,8 +30376,8 @@ var init_judge_run = __esm({
|
|
|
30282
30376
|
});
|
|
30283
30377
|
|
|
30284
30378
|
// src/public-cli/merger-run.ts
|
|
30285
|
-
import { mkdir as mkdir5, writeFile as
|
|
30286
|
-
import { join as
|
|
30379
|
+
import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
30380
|
+
import { join as join29, resolve as resolve10 } from "node:path";
|
|
30287
30381
|
function mergerMethods(packageRoot2) {
|
|
30288
30382
|
return [
|
|
30289
30383
|
{
|
|
@@ -30325,7 +30419,7 @@ async function loadMergerMethodMaterial(packageRoot2) {
|
|
|
30325
30419
|
);
|
|
30326
30420
|
}
|
|
30327
30421
|
async function admitMergerShellForActivationFailure(options) {
|
|
30328
|
-
const projectRoot =
|
|
30422
|
+
const projectRoot = resolve10(options.project ?? options.cwd);
|
|
30329
30423
|
const runId = (options.createRunId ?? uuidv7)();
|
|
30330
30424
|
const {
|
|
30331
30425
|
principal,
|
|
@@ -30349,9 +30443,9 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
30349
30443
|
expectedConflictPaths: [],
|
|
30350
30444
|
resolutionScope: []
|
|
30351
30445
|
};
|
|
30352
|
-
const admittedRequestPath =
|
|
30353
|
-
const mergerInputPath =
|
|
30354
|
-
await
|
|
30446
|
+
const admittedRequestPath = join29(runDirectory, "admitted-request.json");
|
|
30447
|
+
const mergerInputPath = join29(runDirectory, "merger-input.json");
|
|
30448
|
+
await writeFile9(
|
|
30355
30449
|
admittedRequestPath,
|
|
30356
30450
|
`${JSON.stringify(
|
|
30357
30451
|
{
|
|
@@ -30755,7 +30849,7 @@ var init_reviewer_run = __esm({
|
|
|
30755
30849
|
|
|
30756
30850
|
// src/analyst-book-key.ts
|
|
30757
30851
|
import { statSync as statSync3 } from "node:fs";
|
|
30758
|
-
import { isAbsolute as
|
|
30852
|
+
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
30759
30853
|
function resolveAnalystBookKey(projectRoot) {
|
|
30760
30854
|
const identity = physicalPathIdentity(projectRoot);
|
|
30761
30855
|
let stats;
|
|
@@ -30777,7 +30871,7 @@ function resolveAnalystBookKey(projectRoot) {
|
|
|
30777
30871
|
}
|
|
30778
30872
|
}
|
|
30779
30873
|
function isSyntheticAnalystBookKey(bookKey) {
|
|
30780
|
-
return bookKey.startsWith("root:") &&
|
|
30874
|
+
return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
|
|
30781
30875
|
}
|
|
30782
30876
|
var init_analyst_book_key = __esm({
|
|
30783
30877
|
"src/analyst-book-key.ts"() {
|
|
@@ -30788,14 +30882,14 @@ var init_analyst_book_key = __esm({
|
|
|
30788
30882
|
});
|
|
30789
30883
|
|
|
30790
30884
|
// src/atomic-write.ts
|
|
30791
|
-
import { randomUUID as
|
|
30792
|
-
import { rename, rm as rm2, writeFile as
|
|
30793
|
-
import { dirname as dirname11, join as
|
|
30885
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
30886
|
+
import { rename, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
|
|
30887
|
+
import { dirname as dirname11, join as join30 } from "node:path";
|
|
30794
30888
|
async function writeFileAtomically(destination, contents) {
|
|
30795
30889
|
const parent = dirname11(destination);
|
|
30796
|
-
const temporary =
|
|
30890
|
+
const temporary = join30(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
30797
30891
|
try {
|
|
30798
|
-
await
|
|
30892
|
+
await writeFile10(temporary, contents);
|
|
30799
30893
|
await rename(temporary, destination);
|
|
30800
30894
|
} catch (error) {
|
|
30801
30895
|
await rm2(temporary, { force: true }).catch(() => void 0);
|
|
@@ -30810,16 +30904,16 @@ var init_atomic_write = __esm({
|
|
|
30810
30904
|
|
|
30811
30905
|
// src/analyst-index.ts
|
|
30812
30906
|
import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
30813
|
-
import { dirname as dirname12, join as
|
|
30907
|
+
import { dirname as dirname12, join as join31 } from "node:path";
|
|
30814
30908
|
function sleep(ms) {
|
|
30815
|
-
return new Promise((
|
|
30816
|
-
setTimeout(
|
|
30909
|
+
return new Promise((resolve12) => {
|
|
30910
|
+
setTimeout(resolve12, ms);
|
|
30817
30911
|
});
|
|
30818
30912
|
}
|
|
30819
30913
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
30820
30914
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
30821
30915
|
ensureRealDirectoryTree(ledgerHome, dirname12(indexPath));
|
|
30822
|
-
const lockPath =
|
|
30916
|
+
const lockPath = join31(dirname12(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
30823
30917
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
30824
30918
|
const startedAt = Date.now();
|
|
30825
30919
|
while (true) {
|
|
@@ -30846,7 +30940,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
30846
30940
|
}
|
|
30847
30941
|
}
|
|
30848
30942
|
function analystLibraryIndexPath(ledgerHome) {
|
|
30849
|
-
return
|
|
30943
|
+
return join31(ledgerHome, "analyst", "library-index.json");
|
|
30850
30944
|
}
|
|
30851
30945
|
function rowFromIssueMetricsPage(page) {
|
|
30852
30946
|
return {
|
|
@@ -31142,7 +31236,7 @@ var init_analyst_cohort = __esm({
|
|
|
31142
31236
|
|
|
31143
31237
|
// src/analyst-ledger.ts
|
|
31144
31238
|
import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
|
|
31145
|
-
import { join as
|
|
31239
|
+
import { join as join32 } from "node:path";
|
|
31146
31240
|
function isMissingPathError5(error) {
|
|
31147
31241
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
31148
31242
|
}
|
|
@@ -31155,7 +31249,7 @@ function isRecord18(value) {
|
|
|
31155
31249
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
31156
31250
|
try {
|
|
31157
31251
|
const raw = JSON.parse(
|
|
31158
|
-
await readFile18(
|
|
31252
|
+
await readFile18(join32(runDirectory, "run-state.json"), "utf8")
|
|
31159
31253
|
);
|
|
31160
31254
|
if (!isRecord18(raw) || typeof raw.state !== "string") return void 0;
|
|
31161
31255
|
return raw.state;
|
|
@@ -31187,7 +31281,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
31187
31281
|
async function readInvocationScopeFields(runDirectory) {
|
|
31188
31282
|
let raw;
|
|
31189
31283
|
try {
|
|
31190
|
-
raw = await readFile18(
|
|
31284
|
+
raw = await readFile18(join32(runDirectory, "invocation.json"), "utf8");
|
|
31191
31285
|
} catch (error) {
|
|
31192
31286
|
if (isMissingPathError5(error)) return void 0;
|
|
31193
31287
|
throw error;
|
|
@@ -31219,7 +31313,7 @@ function decideIssueScope(input) {
|
|
|
31219
31313
|
}
|
|
31220
31314
|
async function resolveSessionFile(runDirectory) {
|
|
31221
31315
|
try {
|
|
31222
|
-
const raw = await readFile18(
|
|
31316
|
+
const raw = await readFile18(join32(runDirectory, "invocation.json"), "utf8");
|
|
31223
31317
|
const parsed = JSON.parse(raw);
|
|
31224
31318
|
if (isRecord18(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31225
31319
|
return parsed.sessionFile;
|
|
@@ -31227,24 +31321,16 @@ async function resolveSessionFile(runDirectory) {
|
|
|
31227
31321
|
} catch (error) {
|
|
31228
31322
|
if (!isMissingPathError5(error)) throw error;
|
|
31229
31323
|
}
|
|
31230
|
-
return
|
|
31324
|
+
return join32(runDirectory, "session", "session.jsonl");
|
|
31231
31325
|
}
|
|
31232
31326
|
function attributeSessionRowsForRun(input) {
|
|
31233
31327
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
31234
31328
|
return { kind: "attributed", rows: input.rows, closed: false };
|
|
31235
31329
|
}
|
|
31236
|
-
|
|
31237
|
-
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
);
|
|
31241
|
-
if (interval === void 0) {
|
|
31242
|
-
return {
|
|
31243
|
-
kind: "missing-boundary",
|
|
31244
|
-
reason: "shared session volume has no ticket-seat run binding for this run"
|
|
31245
|
-
};
|
|
31246
|
-
}
|
|
31247
|
-
return { kind: "attributed", rows: interval.rows, closed: interval.closed };
|
|
31330
|
+
return {
|
|
31331
|
+
kind: "missing-boundary",
|
|
31332
|
+
reason: "session volume is outside the run directory"
|
|
31333
|
+
};
|
|
31248
31334
|
}
|
|
31249
31335
|
function admitFrameSpanFromRows(rows) {
|
|
31250
31336
|
const models = extractSessionModelSequence(rows);
|
|
@@ -31407,18 +31493,11 @@ async function classifyScopedRun(input) {
|
|
|
31407
31493
|
}
|
|
31408
31494
|
let gateCycles;
|
|
31409
31495
|
try {
|
|
31410
|
-
const
|
|
31411
|
-
|
|
31412
|
-
|
|
31413
|
-
|
|
31414
|
-
|
|
31415
|
-
join33(input.runDirectory, "session", "auditor-roles"),
|
|
31416
|
-
...memoryNests
|
|
31417
|
-
];
|
|
31418
|
-
const parentSessionFile = join33(input.runDirectory, "session", "session.jsonl");
|
|
31419
|
-
gateCycles = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
31420
|
-
parentSessionFile
|
|
31421
|
-
});
|
|
31496
|
+
const parentSessionFile = join32(input.runDirectory, "session", "session.jsonl");
|
|
31497
|
+
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
31498
|
+
join32(input.runDirectory, "session", "auditor-roles"),
|
|
31499
|
+
{ parentSessionFile }
|
|
31500
|
+
);
|
|
31422
31501
|
} catch (error) {
|
|
31423
31502
|
return {
|
|
31424
31503
|
kind: "unreadable",
|
|
@@ -31449,7 +31528,7 @@ async function classifyScopedRun(input) {
|
|
|
31449
31528
|
async function scanAnalystIssueRuns(input) {
|
|
31450
31529
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31451
31530
|
const scopeTicketNumber = input.ticketNumber;
|
|
31452
|
-
const booksRoot =
|
|
31531
|
+
const booksRoot = join32(ledgerHome, "books");
|
|
31453
31532
|
let wholeBook = false;
|
|
31454
31533
|
let scopeRootIdentity;
|
|
31455
31534
|
let bookNames;
|
|
@@ -31481,7 +31560,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31481
31560
|
const unreadable = [];
|
|
31482
31561
|
const scopeConflicts = [];
|
|
31483
31562
|
for (const book of bookNames) {
|
|
31484
|
-
const runsDir =
|
|
31563
|
+
const runsDir = join32(booksRoot, book, "runs");
|
|
31485
31564
|
let runNames;
|
|
31486
31565
|
try {
|
|
31487
31566
|
const entries = await readdir7(runsDir, { withFileTypes: true });
|
|
@@ -31493,7 +31572,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31493
31572
|
for (const runName of runNames) {
|
|
31494
31573
|
const parsed = parseRunDirectoryName2(runName);
|
|
31495
31574
|
if (parsed === void 0) continue;
|
|
31496
|
-
const runDirectory =
|
|
31575
|
+
const runDirectory = join32(runsDir, runName);
|
|
31497
31576
|
let scopeFields;
|
|
31498
31577
|
try {
|
|
31499
31578
|
scopeFields = await readInvocationScopeFields(runDirectory);
|
|
@@ -31536,7 +31615,6 @@ var init_analyst_ledger = __esm({
|
|
|
31536
31615
|
init_ledger_session_read();
|
|
31537
31616
|
init_run_terminal_artifacts();
|
|
31538
31617
|
init_analyst_gate_cycles_read();
|
|
31539
|
-
init_ticket_seat_memory();
|
|
31540
31618
|
LIVE_RUN_STATES = /* @__PURE__ */ new Set(["admitted", "running", "resumable"]);
|
|
31541
31619
|
}
|
|
31542
31620
|
});
|
|
@@ -32347,8 +32425,8 @@ var init_analyst_metric_family = __esm({
|
|
|
32347
32425
|
});
|
|
32348
32426
|
|
|
32349
32427
|
// src/analyst-page.ts
|
|
32350
|
-
import { createHash as
|
|
32351
|
-
import { dirname as dirname13, join as
|
|
32428
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
32429
|
+
import { dirname as dirname13, join as join33 } from "node:path";
|
|
32352
32430
|
function analystIssuePageKey(address) {
|
|
32353
32431
|
const parts = ["book", address.bookKey];
|
|
32354
32432
|
if (address.issueNumber !== void 0) {
|
|
@@ -32356,10 +32434,10 @@ function analystIssuePageKey(address) {
|
|
|
32356
32434
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
32357
32435
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
32358
32436
|
}
|
|
32359
|
-
return
|
|
32437
|
+
return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32360
32438
|
}
|
|
32361
32439
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32362
|
-
return
|
|
32440
|
+
return join33(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32363
32441
|
}
|
|
32364
32442
|
function analystIssuePageAddressFromPage(page) {
|
|
32365
32443
|
return {
|
|
@@ -32720,7 +32798,7 @@ var init_analyst_entry = __esm({
|
|
|
32720
32798
|
|
|
32721
32799
|
// src/public-cli/analyst-run.ts
|
|
32722
32800
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
32723
|
-
import { isAbsolute as
|
|
32801
|
+
import { isAbsolute as isAbsolute8, resolve as resolve11 } from "node:path";
|
|
32724
32802
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
32725
32803
|
try {
|
|
32726
32804
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -32769,7 +32847,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
32769
32847
|
);
|
|
32770
32848
|
}
|
|
32771
32849
|
const sourcePath = attachmentPaths[0];
|
|
32772
|
-
const absolute =
|
|
32850
|
+
const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve11(sourcePath);
|
|
32773
32851
|
let bytes;
|
|
32774
32852
|
try {
|
|
32775
32853
|
bytes = await readFile20(absolute);
|
|
@@ -32892,7 +32970,7 @@ __export(cli_exports, {
|
|
|
32892
32970
|
runAkRole: () => runAkRole
|
|
32893
32971
|
});
|
|
32894
32972
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
32895
|
-
import { join as
|
|
32973
|
+
import { join as join34 } from "node:path";
|
|
32896
32974
|
function takePublicGlobalFlag(argv, index, options) {
|
|
32897
32975
|
const tokens = argv.slice(index);
|
|
32898
32976
|
const taken = options.takeDashed(tokens);
|
|
@@ -33023,7 +33101,7 @@ function resolveHome(env) {
|
|
|
33023
33101
|
return env.home ?? packageMachineHome();
|
|
33024
33102
|
}
|
|
33025
33103
|
function resolveAgentDir(env, home) {
|
|
33026
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
33104
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join34(home, ".pi", "agent");
|
|
33027
33105
|
}
|
|
33028
33106
|
function parseThinking(value) {
|
|
33029
33107
|
return value;
|
|
@@ -33935,8 +34013,8 @@ var init_cli = __esm({
|
|
|
33935
34013
|
});
|
|
33936
34014
|
|
|
33937
34015
|
// src/public-cli/main.ts
|
|
33938
|
-
import { existsSync as
|
|
33939
|
-
import { dirname as dirname14, join as
|
|
34016
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
34017
|
+
import { dirname as dirname14, join as join35 } from "node:path";
|
|
33940
34018
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
33941
34019
|
|
|
33942
34020
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -34025,8 +34103,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
34025
34103
|
// src/public-cli/main.ts
|
|
34026
34104
|
var here = dirname14(fileURLToPath4(import.meta.url));
|
|
34027
34105
|
function resolvePackageRoot(binDir) {
|
|
34028
|
-
const canonical =
|
|
34029
|
-
if (
|
|
34106
|
+
const canonical = join35(binDir, "..", "..");
|
|
34107
|
+
if (existsSync11(join35(canonical, "package.json"))) {
|
|
34030
34108
|
return canonical;
|
|
34031
34109
|
}
|
|
34032
34110
|
return binDir;
|