@akagilnc/pi-workflow-roles 0.1.1817 → 0.1.1837
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit-escalation.js +1 -1
- package/dist/compliance-transport.js +7 -6
- package/dist/evidence-child-executor.js +65 -23
- package/dist/navigator-attendance.js +9 -1
- package/dist/public-cli/main.js +187 -224
- package/dist/receipt-delivery-policy.js +14 -5
- package/dist/sitian-record-entry.js +24 -29
- package/dist/sitian-role-run-coordinates.js +28 -0
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -0
- package/src/audit-escalation.ts +5 -1
- package/src/compliance-transport.ts +9 -6
- package/src/doctor-role.ts +1 -1
- package/src/evidence-child-executor.ts +65 -27
- package/src/judge-role.ts +2 -1
- package/src/navigator-attendance.ts +14 -1
- package/src/public-cli/invocation.ts +16 -72
- package/src/public-cli/merger-run.ts +4 -16
- package/src/public-cli/run-lifecycle.ts +8 -10
- package/src/receipt-delivery-policy.ts +20 -8
- package/src/reviewer-role.ts +2 -2
- package/src/role-runtime.ts +3 -2
- package/src/sitian-record-entry.ts +4 -0
- package/src/sitian-role-run-coordinates.ts +45 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -14844,6 +14844,35 @@ var init_activation_ledger_git = __esm({
|
|
|
14844
14844
|
}
|
|
14845
14845
|
});
|
|
14846
14846
|
|
|
14847
|
+
// src/sitian-role-run-coordinates.ts
|
|
14848
|
+
import { join as join4 } from "node:path";
|
|
14849
|
+
function roleRunSessionCoordinates(options) {
|
|
14850
|
+
const ledgerHome = resolveActivationLedgerHome(
|
|
14851
|
+
options.home === void 0 ? void 0 : () => options.home
|
|
14852
|
+
);
|
|
14853
|
+
const bookKey = resolveBookKeyFromGit(options.cwd);
|
|
14854
|
+
const runDirectory = join4(
|
|
14855
|
+
activationBookDirectory(ledgerHome, bookKey),
|
|
14856
|
+
"runs",
|
|
14857
|
+
`${options.runId}@${options.role}`
|
|
14858
|
+
);
|
|
14859
|
+
const sessionDirectory = join4(runDirectory, "session");
|
|
14860
|
+
return {
|
|
14861
|
+
ledgerHome,
|
|
14862
|
+
bookKey,
|
|
14863
|
+
runDirectory,
|
|
14864
|
+
sessionDirectory,
|
|
14865
|
+
sessionFile: join4(sessionDirectory, "session.jsonl")
|
|
14866
|
+
};
|
|
14867
|
+
}
|
|
14868
|
+
var init_sitian_role_run_coordinates = __esm({
|
|
14869
|
+
"src/sitian-role-run-coordinates.ts"() {
|
|
14870
|
+
"use strict";
|
|
14871
|
+
init_activation_ledger_git();
|
|
14872
|
+
init_activation_ledger_topology();
|
|
14873
|
+
}
|
|
14874
|
+
});
|
|
14875
|
+
|
|
14847
14876
|
// src/audit-escalation.ts
|
|
14848
14877
|
function isAuditEscalationResult(value) {
|
|
14849
14878
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -15300,10 +15329,7 @@ import {
|
|
|
15300
15329
|
realpath as realpath2,
|
|
15301
15330
|
writeFile as writeFile2
|
|
15302
15331
|
} from "node:fs/promises";
|
|
15303
|
-
import { basename as basename3, isAbsolute as isAbsolute3, join as
|
|
15304
|
-
function roleRunSessionFile(sessionDirectory) {
|
|
15305
|
-
return join4(sessionDirectory, ROLE_RUN_SESSION_FILE_NAME);
|
|
15306
|
-
}
|
|
15332
|
+
import { basename as basename3, isAbsolute as isAbsolute3, join as join5, resolve as resolve4, sep as sep3 } from "node:path";
|
|
15307
15333
|
async function writeRoleInvocationLedger(source, role) {
|
|
15308
15334
|
const identity = {
|
|
15309
15335
|
role,
|
|
@@ -15315,14 +15341,14 @@ async function writeRoleInvocationLedger(source, role) {
|
|
|
15315
15341
|
sessionFile: source.sessionFile
|
|
15316
15342
|
};
|
|
15317
15343
|
await writeFile2(
|
|
15318
|
-
|
|
15344
|
+
join5(source.runDirectory, "invocation.json"),
|
|
15319
15345
|
`${JSON.stringify(identity, null, 2)}
|
|
15320
15346
|
`,
|
|
15321
15347
|
"utf8"
|
|
15322
15348
|
);
|
|
15323
15349
|
}
|
|
15324
15350
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
15325
|
-
const ledgerPath =
|
|
15351
|
+
const ledgerPath = join5(runDirectory, "invocation.json");
|
|
15326
15352
|
const current = JSON.parse(await readFile4(ledgerPath, "utf8"));
|
|
15327
15353
|
await writeFile2(
|
|
15328
15354
|
ledgerPath,
|
|
@@ -15343,7 +15369,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
15343
15369
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
15344
15370
|
const rolePackageRoot = packageRoot2;
|
|
15345
15371
|
const raw = JSON.parse(
|
|
15346
|
-
await readFile4(
|
|
15372
|
+
await readFile4(join5(rolePackageRoot, "package.json"), "utf8")
|
|
15347
15373
|
);
|
|
15348
15374
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
15349
15375
|
throw new Error(
|
|
@@ -15539,7 +15565,7 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
15539
15565
|
}
|
|
15540
15566
|
const bytes = await readFile4(absolute);
|
|
15541
15567
|
const name = `${String(index).padStart(2, "0")}-${basename3(absolute)}`;
|
|
15542
|
-
const frozenPath =
|
|
15568
|
+
const frozenPath = join5(destinationDir, name);
|
|
15543
15569
|
await writeFile2(frozenPath, bytes);
|
|
15544
15570
|
return {
|
|
15545
15571
|
provenancePath: absolute,
|
|
@@ -15554,17 +15580,9 @@ async function admitJudgeInvocation(options) {
|
|
|
15554
15580
|
requireOptionPath("--project", options.project);
|
|
15555
15581
|
}
|
|
15556
15582
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15557
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15558
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15559
15583
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15560
|
-
const runDirectory =
|
|
15561
|
-
|
|
15562
|
-
"runs",
|
|
15563
|
-
`${runId}@judge`
|
|
15564
|
-
);
|
|
15565
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15566
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15567
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15584
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "judge", home: options.home });
|
|
15585
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15568
15586
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15569
15587
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15570
15588
|
const attachments = [];
|
|
@@ -15597,7 +15615,7 @@ async function admitJudgeInvocation(options) {
|
|
|
15597
15615
|
mediaKind: a.mediaKind
|
|
15598
15616
|
}))
|
|
15599
15617
|
};
|
|
15600
|
-
const admittedRequestPath =
|
|
15618
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15601
15619
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15602
15620
|
`, "utf8");
|
|
15603
15621
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -15627,7 +15645,7 @@ function buildJudgeTransportPrompt(admitted) {
|
|
|
15627
15645
|
return lines.join("\n");
|
|
15628
15646
|
}
|
|
15629
15647
|
async function ensureRunArtifactsDir(runDirectory) {
|
|
15630
|
-
const dir =
|
|
15648
|
+
const dir = join5(runDirectory, "artifacts");
|
|
15631
15649
|
await mkdir2(dir, { recursive: true });
|
|
15632
15650
|
return dir;
|
|
15633
15651
|
}
|
|
@@ -15645,17 +15663,9 @@ async function admitCoderInvocation(options) {
|
|
|
15645
15663
|
throw new CliUsageError("coder phase must be plan or apply");
|
|
15646
15664
|
}
|
|
15647
15665
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15648
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15649
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15650
15666
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15651
|
-
const runDirectory =
|
|
15652
|
-
|
|
15653
|
-
"runs",
|
|
15654
|
-
`${runId}@coder`
|
|
15655
|
-
);
|
|
15656
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15657
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15658
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15667
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "coder", home: options.home });
|
|
15668
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15659
15669
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15660
15670
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15661
15671
|
const attachments = [];
|
|
@@ -15668,7 +15678,7 @@ async function admitCoderInvocation(options) {
|
|
|
15668
15678
|
)
|
|
15669
15679
|
);
|
|
15670
15680
|
}
|
|
15671
|
-
const taskPath =
|
|
15681
|
+
const taskPath = join5(runDirectory, "task.md");
|
|
15672
15682
|
await writeFile2(taskPath, instruction, "utf8");
|
|
15673
15683
|
const admitted = {
|
|
15674
15684
|
role: "coder",
|
|
@@ -15690,7 +15700,7 @@ async function admitCoderInvocation(options) {
|
|
|
15690
15700
|
mediaKind: a.mediaKind
|
|
15691
15701
|
}))
|
|
15692
15702
|
};
|
|
15693
|
-
const admittedRequestPath =
|
|
15703
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15694
15704
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15695
15705
|
`, "utf8");
|
|
15696
15706
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -15735,17 +15745,9 @@ async function admitFixerInvocation(options) {
|
|
|
15735
15745
|
throw new CliUsageError("fixer phase must be plan or apply");
|
|
15736
15746
|
}
|
|
15737
15747
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
15738
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
15739
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
15740
15748
|
const runId = (options.createRunId ?? uuidv7)();
|
|
15741
|
-
const runDirectory =
|
|
15742
|
-
|
|
15743
|
-
"runs",
|
|
15744
|
-
`${runId}@fixer`
|
|
15745
|
-
);
|
|
15746
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
15747
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
15748
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
15749
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
|
|
15750
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
15749
15751
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
15750
15752
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
15751
15753
|
const attachments = [];
|
|
@@ -15779,7 +15781,7 @@ async function admitFixerInvocation(options) {
|
|
|
15779
15781
|
}
|
|
15780
15782
|
throw error;
|
|
15781
15783
|
}
|
|
15782
|
-
prerequisitesPath =
|
|
15784
|
+
prerequisitesPath = join5(runDirectory, "prerequisites.json");
|
|
15783
15785
|
await writeFile2(
|
|
15784
15786
|
prerequisitesPath,
|
|
15785
15787
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -15787,7 +15789,7 @@ async function admitFixerInvocation(options) {
|
|
|
15787
15789
|
"utf8"
|
|
15788
15790
|
);
|
|
15789
15791
|
}
|
|
15790
|
-
const packetPath =
|
|
15792
|
+
const packetPath = join5(runDirectory, "fix-packet.md");
|
|
15791
15793
|
await writeFile2(packetPath, instruction, "utf8");
|
|
15792
15794
|
const admitted = {
|
|
15793
15795
|
role: "fixer",
|
|
@@ -15814,7 +15816,7 @@ async function admitFixerInvocation(options) {
|
|
|
15814
15816
|
mediaKind: a.mediaKind
|
|
15815
15817
|
}))
|
|
15816
15818
|
};
|
|
15817
|
-
const admittedRequestPath =
|
|
15819
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
15818
15820
|
await writeFile2(admittedRequestPath, `${JSON.stringify(admitted, null, 2)}
|
|
15819
15821
|
`, "utf8");
|
|
15820
15822
|
await writeRoleInvocationLedger(admitted, admitted.role);
|
|
@@ -16001,17 +16003,9 @@ async function admitCollectorInvocation(options) {
|
|
|
16001
16003
|
} else {
|
|
16002
16004
|
repository = resolveGitHubRemoteRepository(projectRoot);
|
|
16003
16005
|
}
|
|
16004
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16005
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16006
16006
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16007
|
-
const runDirectory =
|
|
16008
|
-
|
|
16009
|
-
"runs",
|
|
16010
|
-
`${runId}@collector`
|
|
16011
|
-
);
|
|
16012
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16013
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16014
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16007
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
|
|
16008
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16015
16009
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16016
16010
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16017
16011
|
const attachments = [];
|
|
@@ -16033,7 +16027,7 @@ async function admitCollectorInvocation(options) {
|
|
|
16033
16027
|
} catch (error) {
|
|
16034
16028
|
throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
|
|
16035
16029
|
}
|
|
16036
|
-
requestManifestPath =
|
|
16030
|
+
requestManifestPath = join5(runDirectory, "request-manifest.json");
|
|
16037
16031
|
await writeFile2(requestManifestPath, manifest.canonicalJson, "utf8");
|
|
16038
16032
|
}
|
|
16039
16033
|
const manifestDigest = manifest.digest;
|
|
@@ -16062,7 +16056,7 @@ async function admitCollectorInvocation(options) {
|
|
|
16062
16056
|
mediaKind: a.mediaKind
|
|
16063
16057
|
}))
|
|
16064
16058
|
};
|
|
16065
|
-
const admittedRequestPath =
|
|
16059
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16066
16060
|
await writeFile2(
|
|
16067
16061
|
admittedRequestPath,
|
|
16068
16062
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16184,7 +16178,7 @@ function parseDoctorArgv(args) {
|
|
|
16184
16178
|
}
|
|
16185
16179
|
async function resolveDoctorCaseRunsPath(options) {
|
|
16186
16180
|
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16187
|
-
const defaultRuns =
|
|
16181
|
+
const defaultRuns = join5(
|
|
16188
16182
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
16189
16183
|
"issues",
|
|
16190
16184
|
String(options.issueNumber),
|
|
@@ -16242,8 +16236,8 @@ async function admitDoctorInvocation(options) {
|
|
|
16242
16236
|
);
|
|
16243
16237
|
}
|
|
16244
16238
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
16245
|
-
const
|
|
16246
|
-
const ledgerHome =
|
|
16239
|
+
const runId = (options.createRunId ?? uuidv7)();
|
|
16240
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "doctor", home: options.home });
|
|
16247
16241
|
let caseRunsPath;
|
|
16248
16242
|
try {
|
|
16249
16243
|
caseRunsPath = await resolveDoctorCaseRunsPath({
|
|
@@ -16279,15 +16273,7 @@ async function admitDoctorInvocation(options) {
|
|
|
16279
16273
|
{ cause: error }
|
|
16280
16274
|
);
|
|
16281
16275
|
}
|
|
16282
|
-
const
|
|
16283
|
-
const runDirectory = join4(
|
|
16284
|
-
activationBookDirectory(ledgerHome, bookKey),
|
|
16285
|
-
"runs",
|
|
16286
|
-
`${runId}@doctor`
|
|
16287
|
-
);
|
|
16288
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16289
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16290
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16276
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16291
16277
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16292
16278
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16293
16279
|
const attachments = [];
|
|
@@ -16324,7 +16310,7 @@ async function admitDoctorInvocation(options) {
|
|
|
16324
16310
|
mediaKind: a.mediaKind
|
|
16325
16311
|
}))
|
|
16326
16312
|
};
|
|
16327
|
-
const admittedRequestPath =
|
|
16313
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16328
16314
|
await writeFile2(
|
|
16329
16315
|
admittedRequestPath,
|
|
16330
16316
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16411,17 +16397,9 @@ async function admitReviewerInvocation(options) {
|
|
|
16411
16397
|
throw new CliUsageError("--base requires a nonempty revision");
|
|
16412
16398
|
}
|
|
16413
16399
|
const projectRoot = resolve4(options.project ?? options.cwd);
|
|
16414
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16415
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16416
16400
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16417
|
-
const runDirectory =
|
|
16418
|
-
|
|
16419
|
-
"runs",
|
|
16420
|
-
`${runId}@reviewer`
|
|
16421
|
-
);
|
|
16422
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16423
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16424
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16401
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "reviewer", home: options.home });
|
|
16402
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16425
16403
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16426
16404
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16427
16405
|
const attachments = [];
|
|
@@ -16455,7 +16433,7 @@ async function admitReviewerInvocation(options) {
|
|
|
16455
16433
|
mediaKind: a.mediaKind
|
|
16456
16434
|
}))
|
|
16457
16435
|
};
|
|
16458
|
-
const admittedRequestPath =
|
|
16436
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16459
16437
|
await writeFile2(
|
|
16460
16438
|
admittedRequestPath,
|
|
16461
16439
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16572,17 +16550,9 @@ async function admitMergerInvocation(options) {
|
|
|
16572
16550
|
projectRoot,
|
|
16573
16551
|
options.gitState ?? createProductionMergerGitState(projectRoot)
|
|
16574
16552
|
);
|
|
16575
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
16576
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
16577
16553
|
const runId = (options.createRunId ?? uuidv7)();
|
|
16578
|
-
const runDirectory =
|
|
16579
|
-
|
|
16580
|
-
"runs",
|
|
16581
|
-
`${runId}@merger`
|
|
16582
|
-
);
|
|
16583
|
-
const sessionDirectory = join4(runDirectory, "session");
|
|
16584
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
16585
|
-
const attachmentsDirectory = join4(runDirectory, "attachments");
|
|
16554
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "merger", home: options.home });
|
|
16555
|
+
const attachmentsDirectory = join5(runDirectory, "attachments");
|
|
16586
16556
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
16587
16557
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
16588
16558
|
const attachments = [];
|
|
@@ -16619,7 +16589,7 @@ async function admitMergerInvocation(options) {
|
|
|
16619
16589
|
// Authorized checks remain available on the assignment; default none.
|
|
16620
16590
|
authorizedChecks: []
|
|
16621
16591
|
});
|
|
16622
|
-
const mergerInputPath =
|
|
16592
|
+
const mergerInputPath = join5(runDirectory, "merger-input.json");
|
|
16623
16593
|
await writeFile2(
|
|
16624
16594
|
mergerInputPath,
|
|
16625
16595
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -16652,7 +16622,7 @@ async function admitMergerInvocation(options) {
|
|
|
16652
16622
|
mediaKind: a.mediaKind
|
|
16653
16623
|
}))
|
|
16654
16624
|
};
|
|
16655
|
-
const admittedRequestPath =
|
|
16625
|
+
const admittedRequestPath = join5(runDirectory, "admitted-request.json");
|
|
16656
16626
|
await writeFile2(
|
|
16657
16627
|
admittedRequestPath,
|
|
16658
16628
|
`${JSON.stringify(admitted, null, 2)}
|
|
@@ -16689,12 +16659,13 @@ function buildMergerTransportPrompt(admitted) {
|
|
|
16689
16659
|
}
|
|
16690
16660
|
return lines.join("\n");
|
|
16691
16661
|
}
|
|
16692
|
-
var
|
|
16662
|
+
var MergerEnvelopeDerivationError, DOCTOR_ISSUE_NUMBER_PATTERN, DOCTOR_CASE_RUNS_PATH_PATTERN;
|
|
16693
16663
|
var init_invocation = __esm({
|
|
16694
16664
|
"src/public-cli/invocation.ts"() {
|
|
16695
16665
|
"use strict";
|
|
16696
16666
|
init_activation_ledger_topology();
|
|
16697
16667
|
init_activation_ledger_git();
|
|
16668
|
+
init_sitian_role_run_coordinates();
|
|
16698
16669
|
init_doctor_evidence();
|
|
16699
16670
|
init_collector_config();
|
|
16700
16671
|
init_fixer_packet();
|
|
@@ -16703,7 +16674,6 @@ var init_invocation = __esm({
|
|
|
16703
16674
|
init_sha256();
|
|
16704
16675
|
init_uuidv7();
|
|
16705
16676
|
init_cli_errors();
|
|
16706
|
-
ROLE_RUN_SESSION_FILE_NAME = "session.jsonl";
|
|
16707
16677
|
MergerEnvelopeDerivationError = class extends Error {
|
|
16708
16678
|
code = "merger-envelope-derivation";
|
|
16709
16679
|
/** Typed cause for #107 classifyPostAdmissionFailure (isTypedActivationError). */
|
|
@@ -16813,14 +16783,14 @@ var init_reviewer_dispatch = __esm({
|
|
|
16813
16783
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
16814
16784
|
import { constants, writeFileSync } from "node:fs";
|
|
16815
16785
|
import { access, readFile as readFile5, realpath as realpath3, unlink } from "node:fs/promises";
|
|
16816
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as
|
|
16786
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute4, join as join6, resolve as resolve5 } from "node:path";
|
|
16817
16787
|
import { platform } from "node:process";
|
|
16818
16788
|
import { promisify as promisify3 } from "node:util";
|
|
16819
16789
|
function isReviewerPreflightViolation(value) {
|
|
16820
16790
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
16821
16791
|
}
|
|
16822
16792
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
16823
|
-
return
|
|
16793
|
+
return join6(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
16824
16794
|
}
|
|
16825
16795
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
16826
16796
|
try {
|
|
@@ -16862,7 +16832,7 @@ async function readReviewerDispatchRejection(runDirectory) {
|
|
|
16862
16832
|
};
|
|
16863
16833
|
}
|
|
16864
16834
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
16865
|
-
return
|
|
16835
|
+
return join6(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
|
|
16866
16836
|
}
|
|
16867
16837
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
16868
16838
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -17002,7 +16972,7 @@ var init_explicit_internal = __esm({
|
|
|
17002
16972
|
// src/package-resources/method-skill.ts
|
|
17003
16973
|
import { createHash as createHash3 } from "node:crypto";
|
|
17004
16974
|
import { readFile as readFile6, realpath as realpath4 } from "node:fs/promises";
|
|
17005
|
-
import { join as
|
|
16975
|
+
import { join as join7 } from "node:path";
|
|
17006
16976
|
function gitBlobOid(bytes) {
|
|
17007
16977
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
17008
16978
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -17019,10 +16989,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
17019
16989
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
17020
16990
|
}
|
|
17021
16991
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
17022
|
-
return
|
|
16992
|
+
return join7(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
17023
16993
|
}
|
|
17024
16994
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
17025
|
-
return
|
|
16995
|
+
return join7(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
17026
16996
|
}
|
|
17027
16997
|
function isRecord3(value) {
|
|
17028
16998
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -17116,8 +17086,8 @@ function parseProvenance(raw, expectedName) {
|
|
|
17116
17086
|
}
|
|
17117
17087
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
17118
17088
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
17119
|
-
const skillPathConfigured =
|
|
17120
|
-
const provenancePath =
|
|
17089
|
+
const skillPathConfigured = join7(rootDirectory, "SKILL.md");
|
|
17090
|
+
const provenancePath = join7(rootDirectory, "provenance.json");
|
|
17121
17091
|
let provenanceRaw;
|
|
17122
17092
|
try {
|
|
17123
17093
|
provenanceRaw = await readFile6(provenancePath, "utf8");
|
|
@@ -17134,7 +17104,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
17134
17104
|
}
|
|
17135
17105
|
const provenance = parseProvenance(provenanceJson, name);
|
|
17136
17106
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
17137
|
-
const absolute =
|
|
17107
|
+
const absolute = join7(rootDirectory, rel);
|
|
17138
17108
|
let bytes;
|
|
17139
17109
|
try {
|
|
17140
17110
|
bytes = await readFile6(absolute);
|
|
@@ -17269,12 +17239,12 @@ var init_public_run_credentials = __esm({
|
|
|
17269
17239
|
|
|
17270
17240
|
// src/public-cli/run-lifecycle.ts
|
|
17271
17241
|
import { lstat as lstat2, open, readdir as readdir2, readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
17272
|
-
import { join as
|
|
17242
|
+
import { join as join8 } from "node:path";
|
|
17273
17243
|
function isV1ResumableProvider(provider) {
|
|
17274
17244
|
return V1_RESUMABLE_PROVIDERS.includes(provider);
|
|
17275
17245
|
}
|
|
17276
17246
|
function typedProviderHttpPath(runDirectory) {
|
|
17277
|
-
return
|
|
17247
|
+
return join8(runDirectory, TYPED_HTTP_FILE);
|
|
17278
17248
|
}
|
|
17279
17249
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
17280
17250
|
try {
|
|
@@ -17313,62 +17283,61 @@ function renderResumeCommand(runId) {
|
|
|
17313
17283
|
async function writeRoleRunState(runDirectory, record4) {
|
|
17314
17284
|
const payload = { ...record4, runDirectory };
|
|
17315
17285
|
await writeFile3(
|
|
17316
|
-
|
|
17286
|
+
join8(runDirectory, RUN_STATE_FILE),
|
|
17317
17287
|
`${JSON.stringify(payload, null, 2)}
|
|
17318
17288
|
`,
|
|
17319
17289
|
"utf8"
|
|
17320
17290
|
);
|
|
17321
17291
|
}
|
|
17322
17292
|
async function readRoleRunState(runDirectory) {
|
|
17293
|
+
let raw;
|
|
17323
17294
|
try {
|
|
17324
|
-
|
|
17325
|
-
await readFile7(join7(runDirectory, RUN_STATE_FILE), "utf8")
|
|
17326
|
-
);
|
|
17327
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
17328
|
-
return void 0;
|
|
17329
|
-
}
|
|
17330
|
-
const record4 = raw;
|
|
17331
|
-
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
17332
|
-
return void 0;
|
|
17333
|
-
}
|
|
17334
|
-
if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger") {
|
|
17335
|
-
return void 0;
|
|
17336
|
-
}
|
|
17337
|
-
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
17338
|
-
return void 0;
|
|
17339
|
-
}
|
|
17340
|
-
if (typeof record4.bookKey !== "string") return void 0;
|
|
17341
|
-
if (typeof record4.projectRoot !== "string") return void 0;
|
|
17342
|
-
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
17343
|
-
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
17344
|
-
const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
17345
|
-
const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : roleRunSessionFile(record4.sessionDirectory);
|
|
17346
|
-
let resumable;
|
|
17347
|
-
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
17348
|
-
if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
|
|
17349
|
-
const r = record4.resumable;
|
|
17350
|
-
if (r.httpStatus === 429 && typeof r.provider === "string" && isV1ResumableProvider(r.provider)) {
|
|
17351
|
-
resumable = { httpStatus: 429, provider: r.provider };
|
|
17352
|
-
}
|
|
17353
|
-
}
|
|
17354
|
-
}
|
|
17355
|
-
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
17356
|
-
return {
|
|
17357
|
-
runId: record4.runId,
|
|
17358
|
-
role: record4.role,
|
|
17359
|
-
state: record4.state,
|
|
17360
|
-
bookKey: record4.bookKey,
|
|
17361
|
-
projectRoot: record4.projectRoot,
|
|
17362
|
-
sessionDirectory: record4.sessionDirectory,
|
|
17363
|
-
sessionFile,
|
|
17364
|
-
runDirectory: runDir,
|
|
17365
|
-
admittedRequestPath: record4.admittedRequestPath,
|
|
17366
|
-
...phase === void 0 ? {} : { phase },
|
|
17367
|
-
...resumable === void 0 ? {} : { resumable }
|
|
17368
|
-
};
|
|
17295
|
+
raw = JSON.parse(await readFile7(join8(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
17369
17296
|
} catch {
|
|
17370
17297
|
return void 0;
|
|
17371
17298
|
}
|
|
17299
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
17300
|
+
return void 0;
|
|
17301
|
+
}
|
|
17302
|
+
const record4 = raw;
|
|
17303
|
+
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
17304
|
+
return void 0;
|
|
17305
|
+
}
|
|
17306
|
+
if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger") {
|
|
17307
|
+
return void 0;
|
|
17308
|
+
}
|
|
17309
|
+
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
17310
|
+
return void 0;
|
|
17311
|
+
}
|
|
17312
|
+
if (typeof record4.bookKey !== "string") return void 0;
|
|
17313
|
+
if (typeof record4.projectRoot !== "string") return void 0;
|
|
17314
|
+
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
17315
|
+
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
17316
|
+
const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
17317
|
+
const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join8(record4.sessionDirectory, "session.jsonl");
|
|
17318
|
+
let resumable;
|
|
17319
|
+
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
17320
|
+
if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
|
|
17321
|
+
const r = record4.resumable;
|
|
17322
|
+
if (r.httpStatus === 429 && typeof r.provider === "string" && isV1ResumableProvider(r.provider)) {
|
|
17323
|
+
resumable = { httpStatus: 429, provider: r.provider };
|
|
17324
|
+
}
|
|
17325
|
+
}
|
|
17326
|
+
}
|
|
17327
|
+
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
17328
|
+
return {
|
|
17329
|
+
runId: record4.runId,
|
|
17330
|
+
role: record4.role,
|
|
17331
|
+
state: record4.state,
|
|
17332
|
+
bookKey: record4.bookKey,
|
|
17333
|
+
projectRoot: record4.projectRoot,
|
|
17334
|
+
sessionDirectory: record4.sessionDirectory,
|
|
17335
|
+
sessionFile,
|
|
17336
|
+
runDirectory: runDir,
|
|
17337
|
+
admittedRequestPath: record4.admittedRequestPath,
|
|
17338
|
+
...phase === void 0 ? {} : { phase },
|
|
17339
|
+
...resumable === void 0 ? {} : { resumable }
|
|
17340
|
+
};
|
|
17372
17341
|
}
|
|
17373
17342
|
async function markRunAdmitted(admitted) {
|
|
17374
17343
|
await writeRoleRunState(admitted.runDirectory, {
|
|
@@ -17438,7 +17407,7 @@ async function isSessionPrincipalAvailable(sessionFile) {
|
|
|
17438
17407
|
}
|
|
17439
17408
|
}
|
|
17440
17409
|
async function acquireRunWriterLease(runDirectory) {
|
|
17441
|
-
const lockPath =
|
|
17410
|
+
const lockPath = join8(runDirectory, WRITER_LOCK_FILE);
|
|
17442
17411
|
try {
|
|
17443
17412
|
const handle = await open(lockPath, "wx");
|
|
17444
17413
|
try {
|
|
@@ -17469,7 +17438,7 @@ async function acquireRunWriterLease(runDirectory) {
|
|
|
17469
17438
|
async function findRunDirectoryById(home, runId) {
|
|
17470
17439
|
if (runId.trim() === "") return void 0;
|
|
17471
17440
|
const ledgerHome = resolveActivationLedgerHome(() => home);
|
|
17472
|
-
const booksRoot =
|
|
17441
|
+
const booksRoot = join8(ledgerHome, "books");
|
|
17473
17442
|
let bookKeys;
|
|
17474
17443
|
try {
|
|
17475
17444
|
bookKeys = await readdir2(booksRoot);
|
|
@@ -17477,7 +17446,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17477
17446
|
return void 0;
|
|
17478
17447
|
}
|
|
17479
17448
|
for (const bookKey of bookKeys) {
|
|
17480
|
-
const runsDir =
|
|
17449
|
+
const runsDir = join8(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
17481
17450
|
let entries;
|
|
17482
17451
|
try {
|
|
17483
17452
|
entries = await readdir2(runsDir);
|
|
@@ -17486,7 +17455,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17486
17455
|
}
|
|
17487
17456
|
for (const entry of entries) {
|
|
17488
17457
|
if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
|
|
17489
|
-
return
|
|
17458
|
+
return join8(runsDir, entry);
|
|
17490
17459
|
}
|
|
17491
17460
|
}
|
|
17492
17461
|
}
|
|
@@ -17909,12 +17878,15 @@ function isRecord4(value) {
|
|
|
17909
17878
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17910
17879
|
}
|
|
17911
17880
|
function parseNoReceiptLifecycleFacts(input) {
|
|
17912
|
-
if (!isRecord4(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord4(item) && typeof item.reason === "string"
|
|
17881
|
+
if (!isRecord4(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord4(item) && typeof item.reason === "string")) {
|
|
17913
17882
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
17914
17883
|
}
|
|
17915
17884
|
return {
|
|
17916
17885
|
terminalToolCalled: input.terminalToolCalled,
|
|
17917
|
-
rejectedReceipts: input.rejectedReceipts.map((item) => ({
|
|
17886
|
+
rejectedReceipts: input.rejectedReceipts.map((item) => ({
|
|
17887
|
+
reason: item.reason,
|
|
17888
|
+
diagnosticAvailable: item.reason.trim() !== ""
|
|
17889
|
+
})),
|
|
17918
17890
|
deliveryTurns: RECEIPT_DELIVERY_TURN_LIMIT,
|
|
17919
17891
|
sessionCompletion: "settled-without-accepted-receipt",
|
|
17920
17892
|
runPointer: input.runPointer,
|
|
@@ -17967,7 +17939,6 @@ var init_compliance_transport = __esm({
|
|
|
17967
17939
|
init_build();
|
|
17968
17940
|
init_evidence_child_executor();
|
|
17969
17941
|
init_auditor_dossier_tool();
|
|
17970
|
-
init_receipt_delivery_policy();
|
|
17971
17942
|
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
17972
17943
|
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
17973
17944
|
complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "Auditor decision status." }), violations: typebox_exports.Array(nonblank2, { description: "Observed compliance violations." }), conflicts: typebox_exports.Array(nonblank2, { description: "Unresolved authority or execution conflicts." }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "Escalation question and available options." }) }, { additionalProperties: true, required: [] });
|
|
@@ -18461,7 +18432,7 @@ var init_terminal = __esm({
|
|
|
18461
18432
|
// src/public-cli/settlement.ts
|
|
18462
18433
|
import { randomUUID } from "node:crypto";
|
|
18463
18434
|
import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile8, readdir as readdir3, writeFile as writeFile4 } from "node:fs/promises";
|
|
18464
|
-
import { dirname as dirname6, join as
|
|
18435
|
+
import { dirname as dirname6, join as join9 } from "node:path";
|
|
18465
18436
|
function isChildDiagnosticFloodLine(line2) {
|
|
18466
18437
|
if (/^at\s+/.test(line2)) return true;
|
|
18467
18438
|
if (line2.startsWith("event:")) return true;
|
|
@@ -18714,7 +18685,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
18714
18685
|
}
|
|
18715
18686
|
}
|
|
18716
18687
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
18717
|
-
const childDirectory =
|
|
18688
|
+
const childDirectory = join9(dirname6(sessionFile), "evidence-children");
|
|
18718
18689
|
let names;
|
|
18719
18690
|
try {
|
|
18720
18691
|
names = await readdir3(childDirectory);
|
|
@@ -18725,7 +18696,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
18725
18696
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
18726
18697
|
let entries;
|
|
18727
18698
|
try {
|
|
18728
|
-
entries = await readBoundSessionEntries(
|
|
18699
|
+
entries = await readBoundSessionEntries(join9(childDirectory, file));
|
|
18729
18700
|
} catch (error) {
|
|
18730
18701
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
18731
18702
|
}
|
|
@@ -18762,7 +18733,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
18762
18733
|
break;
|
|
18763
18734
|
}
|
|
18764
18735
|
}
|
|
18765
|
-
const childDirectory =
|
|
18736
|
+
const childDirectory = join9(dirname6(sessionFile), "auditor-roles");
|
|
18766
18737
|
let names;
|
|
18767
18738
|
try {
|
|
18768
18739
|
names = await readdir3(childDirectory);
|
|
@@ -18773,7 +18744,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
18773
18744
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
18774
18745
|
let entries;
|
|
18775
18746
|
try {
|
|
18776
|
-
entries = await readBoundSessionEntries(
|
|
18747
|
+
entries = await readBoundSessionEntries(join9(childDirectory, file));
|
|
18777
18748
|
} catch (error) {
|
|
18778
18749
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
18779
18750
|
}
|
|
@@ -19387,7 +19358,7 @@ function auditArtifactPublicationError(message, code) {
|
|
|
19387
19358
|
return error;
|
|
19388
19359
|
}
|
|
19389
19360
|
async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
19390
|
-
const artifactsDir =
|
|
19361
|
+
const artifactsDir = join9(runDirectory, "artifacts");
|
|
19391
19362
|
const runStat = await lstat3(runDirectory);
|
|
19392
19363
|
if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
|
|
19393
19364
|
throw auditArtifactPublicationError(
|
|
@@ -19424,7 +19395,7 @@ async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
|
19424
19395
|
}
|
|
19425
19396
|
async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
19426
19397
|
const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
|
|
19427
|
-
const evidencePath =
|
|
19398
|
+
const evidencePath = join9(artifactsDir, "audit-incomplete.json");
|
|
19428
19399
|
try {
|
|
19429
19400
|
const existing = await lstat3(evidencePath);
|
|
19430
19401
|
throw auditArtifactPublicationError(
|
|
@@ -19446,7 +19417,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
|
19446
19417
|
}
|
|
19447
19418
|
function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
|
|
19448
19419
|
const attempt = publicationAttemptFromError(
|
|
19449
|
-
|
|
19420
|
+
join9(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
|
|
19450
19421
|
error
|
|
19451
19422
|
);
|
|
19452
19423
|
const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
|
|
@@ -19740,8 +19711,8 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
|
|
|
19740
19711
|
}
|
|
19741
19712
|
async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
19742
19713
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19743
|
-
const reportPath =
|
|
19744
|
-
const evidencePath =
|
|
19714
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19715
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19745
19716
|
await writeFile4(
|
|
19746
19717
|
reportPath,
|
|
19747
19718
|
`${JSON.stringify(
|
|
@@ -19784,8 +19755,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
|
19784
19755
|
}
|
|
19785
19756
|
async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
19786
19757
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19787
|
-
const reportPath =
|
|
19788
|
-
const evidencePath =
|
|
19758
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19759
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19789
19760
|
await writeFile4(
|
|
19790
19761
|
reportPath,
|
|
19791
19762
|
`${JSON.stringify(
|
|
@@ -19959,8 +19930,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
19959
19930
|
}
|
|
19960
19931
|
async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
19961
19932
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
19962
|
-
const reportPath =
|
|
19963
|
-
const evidencePath =
|
|
19933
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
19934
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
19964
19935
|
await writeFile4(
|
|
19965
19936
|
reportPath,
|
|
19966
19937
|
`${JSON.stringify(
|
|
@@ -20073,8 +20044,8 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
|
|
|
20073
20044
|
}
|
|
20074
20045
|
async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
20075
20046
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20076
|
-
const reportPath =
|
|
20077
|
-
const evidencePath =
|
|
20047
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20048
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20078
20049
|
await writeFile4(
|
|
20079
20050
|
reportPath,
|
|
20080
20051
|
`${JSON.stringify(
|
|
@@ -20195,8 +20166,8 @@ async function trySettleCollectorTerminalResult(admitted) {
|
|
|
20195
20166
|
}
|
|
20196
20167
|
async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
20197
20168
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20198
|
-
const reportPath =
|
|
20199
|
-
const evidencePath =
|
|
20169
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20170
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20200
20171
|
await writeFile4(
|
|
20201
20172
|
reportPath,
|
|
20202
20173
|
`${JSON.stringify(
|
|
@@ -20364,8 +20335,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
20364
20335
|
}
|
|
20365
20336
|
async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
20366
20337
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20367
|
-
const reportPath =
|
|
20368
|
-
const evidencePath =
|
|
20338
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20339
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20369
20340
|
await writeFile4(
|
|
20370
20341
|
reportPath,
|
|
20371
20342
|
`${JSON.stringify(
|
|
@@ -20531,8 +20502,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
20531
20502
|
}
|
|
20532
20503
|
async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
20533
20504
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
20534
|
-
const reportPath =
|
|
20535
|
-
const evidencePath =
|
|
20505
|
+
const reportPath = join9(artifactsDir, "report.json");
|
|
20506
|
+
const evidencePath = join9(artifactsDir, "evidence.json");
|
|
20536
20507
|
await writeFile4(
|
|
20537
20508
|
reportPath,
|
|
20538
20509
|
`${JSON.stringify(
|
|
@@ -20703,7 +20674,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
20703
20674
|
return dirs;
|
|
20704
20675
|
}
|
|
20705
20676
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
20706
|
-
const artifactsDir =
|
|
20677
|
+
const artifactsDir = join9(runDirectory, "artifacts");
|
|
20707
20678
|
try {
|
|
20708
20679
|
await ensureRunArtifactsDir(runDirectory);
|
|
20709
20680
|
return { baseDir: artifactsDir };
|
|
@@ -20719,7 +20690,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
20719
20690
|
const candidates = [
|
|
20720
20691
|
...preferredCandidates,
|
|
20721
20692
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
20722
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
20693
|
+
...uniqueFallbackDirs.map((dir) => join9(dir, `${stem}.${randomUUID()}.json`))
|
|
20723
20694
|
];
|
|
20724
20695
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
20725
20696
|
const path = candidates[i];
|
|
@@ -20754,26 +20725,26 @@ async function publishFailureArtifacts(admitted, failure) {
|
|
|
20754
20725
|
admitted.runDirectory
|
|
20755
20726
|
);
|
|
20756
20727
|
const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
|
|
20757
|
-
const underArtifacts = baseDir ===
|
|
20728
|
+
const underArtifacts = baseDir === join9(admitted.runDirectory, "artifacts");
|
|
20758
20729
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
20759
20730
|
admitted.runDirectory,
|
|
20760
20731
|
baseDir
|
|
20761
20732
|
);
|
|
20762
20733
|
const errorCandidates = underArtifacts ? [
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20734
|
+
join9(baseDir, "error.json"),
|
|
20735
|
+
join9(baseDir, "error.settlement.json"),
|
|
20736
|
+
join9(admitted.runDirectory, "error.settlement.json")
|
|
20766
20737
|
] : [
|
|
20767
|
-
|
|
20768
|
-
|
|
20738
|
+
join9(baseDir, "error.settlement.json"),
|
|
20739
|
+
join9(baseDir, "error.json")
|
|
20769
20740
|
];
|
|
20770
20741
|
const evidenceCandidates = underArtifacts ? [
|
|
20771
|
-
|
|
20772
|
-
|
|
20773
|
-
|
|
20742
|
+
join9(baseDir, "evidence.json"),
|
|
20743
|
+
join9(baseDir, "evidence.settlement.json"),
|
|
20744
|
+
join9(admitted.runDirectory, "evidence.settlement.json")
|
|
20774
20745
|
] : [
|
|
20775
|
-
|
|
20776
|
-
|
|
20746
|
+
join9(baseDir, "evidence.settlement.json"),
|
|
20747
|
+
join9(baseDir, "evidence.json")
|
|
20777
20748
|
];
|
|
20778
20749
|
const errorPayloadBase = {
|
|
20779
20750
|
kind: "error",
|
|
@@ -20987,7 +20958,7 @@ var init_settlement = __esm({
|
|
|
20987
20958
|
|
|
20988
20959
|
// src/public-cli/coder-run.ts
|
|
20989
20960
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
20990
|
-
import { join as
|
|
20961
|
+
import { join as join10 } from "node:path";
|
|
20991
20962
|
function buildModelArgs(model) {
|
|
20992
20963
|
if (model === void 0) return [];
|
|
20993
20964
|
return [
|
|
@@ -21147,7 +21118,7 @@ async function dispatchAdmittedCoder(input) {
|
|
|
21147
21118
|
}
|
|
21148
21119
|
try {
|
|
21149
21120
|
await writeFile5(
|
|
21150
|
-
|
|
21121
|
+
join10(admitted.runDirectory, "stderr.log"),
|
|
21151
21122
|
result2.stderr,
|
|
21152
21123
|
"utf8"
|
|
21153
21124
|
);
|
|
@@ -21361,7 +21332,7 @@ var init_coder_run = __esm({
|
|
|
21361
21332
|
|
|
21362
21333
|
// src/public-cli/collector-run.ts
|
|
21363
21334
|
import { writeFile as writeFile6 } from "node:fs/promises";
|
|
21364
|
-
import { join as
|
|
21335
|
+
import { join as join11 } from "node:path";
|
|
21365
21336
|
function buildModelArgs2(model) {
|
|
21366
21337
|
if (model === void 0) return [];
|
|
21367
21338
|
return [
|
|
@@ -21472,7 +21443,7 @@ async function dispatchAdmittedCollector(input) {
|
|
|
21472
21443
|
}
|
|
21473
21444
|
try {
|
|
21474
21445
|
await writeFile6(
|
|
21475
|
-
|
|
21446
|
+
join11(admitted.runDirectory, "stderr.log"),
|
|
21476
21447
|
result2.stderr,
|
|
21477
21448
|
"utf8"
|
|
21478
21449
|
);
|
|
@@ -21593,7 +21564,7 @@ var init_collector_run = __esm({
|
|
|
21593
21564
|
|
|
21594
21565
|
// src/public-cli/doctor-run.ts
|
|
21595
21566
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
21596
|
-
import { join as
|
|
21567
|
+
import { join as join12 } from "node:path";
|
|
21597
21568
|
function buildModelArgs3(model) {
|
|
21598
21569
|
if (model === void 0) return [];
|
|
21599
21570
|
return [
|
|
@@ -21698,7 +21669,7 @@ async function dispatchAdmittedDoctor(input) {
|
|
|
21698
21669
|
}
|
|
21699
21670
|
try {
|
|
21700
21671
|
await writeFile7(
|
|
21701
|
-
|
|
21672
|
+
join12(admitted.runDirectory, "stderr.log"),
|
|
21702
21673
|
result2.stderr,
|
|
21703
21674
|
"utf8"
|
|
21704
21675
|
);
|
|
@@ -21825,7 +21796,7 @@ var init_doctor_run = __esm({
|
|
|
21825
21796
|
|
|
21826
21797
|
// src/public-cli/fixer-run.ts
|
|
21827
21798
|
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
21828
|
-
import { join as
|
|
21799
|
+
import { join as join13 } from "node:path";
|
|
21829
21800
|
function buildModelArgs4(model) {
|
|
21830
21801
|
if (model === void 0) return [];
|
|
21831
21802
|
return [
|
|
@@ -21994,7 +21965,7 @@ async function dispatchAdmittedFixer(input) {
|
|
|
21994
21965
|
}
|
|
21995
21966
|
try {
|
|
21996
21967
|
await writeFile8(
|
|
21997
|
-
|
|
21968
|
+
join13(admitted.runDirectory, "stderr.log"),
|
|
21998
21969
|
result2.stderr,
|
|
21999
21970
|
"utf8"
|
|
22000
21971
|
);
|
|
@@ -22217,7 +22188,7 @@ var init_fixer_run = __esm({
|
|
|
22217
22188
|
|
|
22218
22189
|
// src/public-cli/judge-run.ts
|
|
22219
22190
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
22220
|
-
import { join as
|
|
22191
|
+
import { join as join14 } from "node:path";
|
|
22221
22192
|
function buildModelArgs5(model) {
|
|
22222
22193
|
if (model === void 0) return [];
|
|
22223
22194
|
return [
|
|
@@ -22359,7 +22330,7 @@ async function dispatchAdmittedJudge(input) {
|
|
|
22359
22330
|
}
|
|
22360
22331
|
try {
|
|
22361
22332
|
await writeFile9(
|
|
22362
|
-
|
|
22333
|
+
join14(admitted.runDirectory, "stderr.log"),
|
|
22363
22334
|
result2.stderr,
|
|
22364
22335
|
"utf8"
|
|
22365
22336
|
);
|
|
@@ -22533,7 +22504,7 @@ var init_judge_run = __esm({
|
|
|
22533
22504
|
|
|
22534
22505
|
// src/public-cli/merger-run.ts
|
|
22535
22506
|
import { mkdir as mkdir4, writeFile as writeFile10 } from "node:fs/promises";
|
|
22536
|
-
import { join as
|
|
22507
|
+
import { join as join15, resolve as resolve7 } from "node:path";
|
|
22537
22508
|
function buildModelArgs6(model) {
|
|
22538
22509
|
if (model === void 0) return [];
|
|
22539
22510
|
return [
|
|
@@ -22691,7 +22662,7 @@ async function dispatchAdmittedMerger(input) {
|
|
|
22691
22662
|
}
|
|
22692
22663
|
try {
|
|
22693
22664
|
await writeFile10(
|
|
22694
|
-
|
|
22665
|
+
join15(admitted.runDirectory, "stderr.log"),
|
|
22695
22666
|
result2.stderr,
|
|
22696
22667
|
"utf8"
|
|
22697
22668
|
);
|
|
@@ -22760,16 +22731,8 @@ async function loadMergerMethodMaterial(packageRoot2) {
|
|
|
22760
22731
|
}
|
|
22761
22732
|
async function admitMergerShellForActivationFailure(options) {
|
|
22762
22733
|
const projectRoot = resolve7(options.project ?? options.cwd);
|
|
22763
|
-
const bookKey = resolveBookKeyFromGit(projectRoot);
|
|
22764
|
-
const ledgerHome = resolveActivationLedgerHome(() => options.home);
|
|
22765
22734
|
const runId = (options.createRunId ?? uuidv7)();
|
|
22766
|
-
const runDirectory =
|
|
22767
|
-
activationBookDirectory(ledgerHome, bookKey),
|
|
22768
|
-
"runs",
|
|
22769
|
-
`${runId}@merger`
|
|
22770
|
-
);
|
|
22771
|
-
const sessionDirectory = join14(runDirectory, "session");
|
|
22772
|
-
const sessionFile = roleRunSessionFile(sessionDirectory);
|
|
22735
|
+
const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "merger", home: options.home });
|
|
22773
22736
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
22774
22737
|
await mkdir4(runDirectory, { recursive: true });
|
|
22775
22738
|
const emptyDerived = {
|
|
@@ -22779,8 +22742,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
22779
22742
|
expectedConflictPaths: [],
|
|
22780
22743
|
resolutionScope: []
|
|
22781
22744
|
};
|
|
22782
|
-
const admittedRequestPath =
|
|
22783
|
-
const mergerInputPath =
|
|
22745
|
+
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
22746
|
+
const mergerInputPath = join15(runDirectory, "merger-input.json");
|
|
22784
22747
|
await writeFile10(
|
|
22785
22748
|
admittedRequestPath,
|
|
22786
22749
|
`${JSON.stringify(
|
|
@@ -22980,8 +22943,8 @@ async function runPublicMergerResume(argv, env, io) {
|
|
|
22980
22943
|
var init_merger_run = __esm({
|
|
22981
22944
|
"src/public-cli/merger-run.ts"() {
|
|
22982
22945
|
"use strict";
|
|
22983
|
-
init_activation_ledger_git();
|
|
22984
22946
|
init_activation_ledger_topology();
|
|
22947
|
+
init_sitian_role_run_coordinates();
|
|
22985
22948
|
init_method_skill();
|
|
22986
22949
|
init_uuidv7();
|
|
22987
22950
|
init_explicit_internal();
|
|
@@ -22996,7 +22959,7 @@ var init_merger_run = __esm({
|
|
|
22996
22959
|
|
|
22997
22960
|
// src/public-cli/reviewer-run.ts
|
|
22998
22961
|
import { writeFile as writeFile11 } from "node:fs/promises";
|
|
22999
|
-
import { join as
|
|
22962
|
+
import { join as join16 } from "node:path";
|
|
23000
22963
|
function buildModelArgs7(model) {
|
|
23001
22964
|
if (model === void 0) return [];
|
|
23002
22965
|
return [
|
|
@@ -23152,7 +23115,7 @@ async function dispatchAdmittedReviewer(input) {
|
|
|
23152
23115
|
}
|
|
23153
23116
|
try {
|
|
23154
23117
|
await writeFile11(
|
|
23155
|
-
|
|
23118
|
+
join16(admitted.runDirectory, "stderr.log"),
|
|
23156
23119
|
result2.stderr,
|
|
23157
23120
|
"utf8"
|
|
23158
23121
|
);
|
|
@@ -23384,7 +23347,7 @@ __export(cli_exports, {
|
|
|
23384
23347
|
});
|
|
23385
23348
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
23386
23349
|
import { homedir as homedir3 } from "node:os";
|
|
23387
|
-
import { join as
|
|
23350
|
+
import { join as join17 } from "node:path";
|
|
23388
23351
|
function defaultIo() {
|
|
23389
23352
|
return {
|
|
23390
23353
|
stdout: (text) => {
|
|
@@ -23399,7 +23362,7 @@ function resolveHome(env) {
|
|
|
23399
23362
|
return env.home ?? process.env.HOME ?? homedir3();
|
|
23400
23363
|
}
|
|
23401
23364
|
function resolveAgentDir(env, home) {
|
|
23402
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
23365
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join17(home, ".pi", "agent");
|
|
23403
23366
|
}
|
|
23404
23367
|
function parseThinking(value) {
|
|
23405
23368
|
if (!THINKING_LEVELS2.has(value)) {
|
|
@@ -24039,7 +24002,7 @@ var init_cli = __esm({
|
|
|
24039
24002
|
});
|
|
24040
24003
|
|
|
24041
24004
|
// src/public-cli/main.ts
|
|
24042
|
-
import { dirname as dirname7, join as
|
|
24005
|
+
import { dirname as dirname7, join as join18 } from "node:path";
|
|
24043
24006
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24044
24007
|
|
|
24045
24008
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -24127,7 +24090,7 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
24127
24090
|
|
|
24128
24091
|
// src/public-cli/main.ts
|
|
24129
24092
|
var here = dirname7(fileURLToPath2(import.meta.url));
|
|
24130
|
-
var packageRoot =
|
|
24093
|
+
var packageRoot = join18(here, "..", "..");
|
|
24131
24094
|
ensureHostPiRuntimeResolvable(packageRoot);
|
|
24132
24095
|
var { runAkRole: runAkRole2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
|
|
24133
24096
|
var result = await runAkRole2(process.argv.slice(2), { packageRoot });
|