@akagilnc/pi-workflow-roles 0.1.4992 → 0.1.4996
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +71 -64
- package/dist/analyst-ledger.js +13 -23
- package/dist/analyst-metric-families/acceptance-success-rework.js +1 -1
- package/dist/analyst-metric-families/round-timeline.js +2 -9
- package/dist/headless-host/production-host.js +71 -64
- package/dist/notary-source-run.js +14 -2
- package/dist/pi/role-turn-host.js +7 -10
- package/dist/public-cli/main.js +66 -62
- package/dist/public-cli/post-admission.js +1 -1
- package/dist/public-cli/run-lifecycle.js +31 -22
- package/dist/public-role-summons.js +3 -1
- package/package.json +1 -1
- package/src/analyst-ledger.ts +12 -23
- package/src/analyst-metric-families/acceptance-success-rework.ts +1 -1
- package/src/analyst-metric-families/round-timeline.ts +2 -8
- package/src/analyst-page.ts +1 -0
- package/src/collector-role.ts +4 -1
- package/src/notary-source-run.ts +13 -2
- package/src/pi/role-turn-host.ts +7 -9
- package/src/public-cli/post-admission.ts +1 -1
- package/src/public-cli/run-lifecycle.ts +41 -24
- package/src/public-role-summons.ts +2 -0
|
@@ -6088,16 +6088,13 @@ async function appendPiSessionCustomEntry(authority, principal, customType, data
|
|
|
6088
6088
|
})}
|
|
6089
6089
|
`;
|
|
6090
6090
|
await appendFile(sessionFile, pointerLine, "utf8");
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
});
|
|
6099
|
-
} catch {
|
|
6100
|
-
}
|
|
6091
|
+
sitianReport({
|
|
6092
|
+
level: "event",
|
|
6093
|
+
kind: "dispatch-error",
|
|
6094
|
+
sessionParent: sessionFile,
|
|
6095
|
+
payload: { customType, data },
|
|
6096
|
+
source: "pi-role-turn-host"
|
|
6097
|
+
});
|
|
6101
6098
|
}
|
|
6102
6099
|
var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, EXPLICIT_INTERNAL_LOAD_PROBE_ARGS, execFileAsync;
|
|
6103
6100
|
var init_role_turn_host = __esm({
|
|
@@ -8183,7 +8180,7 @@ function parseCurrentCourtState(raw) {
|
|
|
8183
8180
|
...summons === void 0 ? {} : { summons }
|
|
8184
8181
|
};
|
|
8185
8182
|
}
|
|
8186
|
-
async function
|
|
8183
|
+
async function readRoleRunStateRaw(runDirectory) {
|
|
8187
8184
|
let raw;
|
|
8188
8185
|
try {
|
|
8189
8186
|
raw = JSON.parse(await readFile11(join17(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
@@ -8191,24 +8188,40 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
8191
8188
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
8192
8189
|
throw error;
|
|
8193
8190
|
}
|
|
8191
|
+
return raw;
|
|
8192
|
+
}
|
|
8193
|
+
function parseRoleRunIdentity(raw, runDirectory) {
|
|
8194
8194
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
8195
|
-
|
|
8195
|
+
throw new TypeError("Invalid run-state.json");
|
|
8196
8196
|
}
|
|
8197
8197
|
const record4 = raw;
|
|
8198
8198
|
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
8199
|
-
|
|
8199
|
+
throw new TypeError("Invalid run-state.json");
|
|
8200
8200
|
}
|
|
8201
8201
|
const role = typeof record4.role === "string" ? packagedRoleMetadata(record4.role)?.role : void 0;
|
|
8202
8202
|
if (role === void 0) {
|
|
8203
|
-
|
|
8203
|
+
throw new TypeError("Invalid run-state.json");
|
|
8204
8204
|
}
|
|
8205
8205
|
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
8206
|
-
|
|
8206
|
+
throw new TypeError("Invalid run-state.json");
|
|
8207
8207
|
}
|
|
8208
|
-
if (typeof record4.bookKey !== "string")
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8208
|
+
if (typeof record4.bookKey !== "string") throw new TypeError("Invalid run-state.json");
|
|
8209
|
+
return {
|
|
8210
|
+
runId: record4.runId,
|
|
8211
|
+
role,
|
|
8212
|
+
state: record4.state,
|
|
8213
|
+
bookKey: record4.bookKey,
|
|
8214
|
+
runDirectory
|
|
8215
|
+
};
|
|
8216
|
+
}
|
|
8217
|
+
async function readRoleRunStateDisk(runDirectory) {
|
|
8218
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
8219
|
+
if (raw === void 0) return void 0;
|
|
8220
|
+
const identity = parseRoleRunIdentity(raw, runDirectory);
|
|
8221
|
+
const record4 = raw;
|
|
8222
|
+
if (typeof record4.projectRoot !== "string") throw new TypeError("Invalid run-state.json");
|
|
8223
|
+
if (typeof record4.sessionDirectory !== "string") throw new TypeError("Invalid run-state.json");
|
|
8224
|
+
if (typeof record4.admittedRequestPath !== "string") throw new TypeError("Invalid run-state.json");
|
|
8212
8225
|
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
8213
8226
|
const runDir = runDirectory;
|
|
8214
8227
|
const principalWire = {
|
|
@@ -8231,10 +8244,10 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
8231
8244
|
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
8232
8245
|
const currentCourt = parseCurrentCourtState(record4.currentCourt);
|
|
8233
8246
|
return {
|
|
8234
|
-
runId:
|
|
8235
|
-
role,
|
|
8236
|
-
state:
|
|
8237
|
-
bookKey:
|
|
8247
|
+
runId: identity.runId,
|
|
8248
|
+
role: identity.role,
|
|
8249
|
+
state: identity.state,
|
|
8250
|
+
bookKey: identity.bookKey,
|
|
8238
8251
|
projectRoot: record4.projectRoot,
|
|
8239
8252
|
runDirectory: runDir,
|
|
8240
8253
|
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
@@ -8299,15 +8312,8 @@ async function readRoleRunState(runDirectory, authority) {
|
|
|
8299
8312
|
return materializeRoleRunFromDisk(disk, authority)?.run;
|
|
8300
8313
|
}
|
|
8301
8314
|
async function readRoleRunIdentity(runDirectory) {
|
|
8302
|
-
const
|
|
8303
|
-
|
|
8304
|
-
return {
|
|
8305
|
-
runId: disk.runId,
|
|
8306
|
-
role: disk.role,
|
|
8307
|
-
bookKey: disk.bookKey,
|
|
8308
|
-
runDirectory: disk.runDirectory,
|
|
8309
|
-
state: disk.state
|
|
8310
|
-
};
|
|
8315
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
8316
|
+
return raw === void 0 ? void 0 : parseRoleRunIdentity(raw, runDirectory);
|
|
8311
8317
|
}
|
|
8312
8318
|
async function markRunAdmitted(admitted, authority) {
|
|
8313
8319
|
const { sessionDirectory, sessionFile } = authority.decode(admitted.principal);
|
|
@@ -9310,6 +9316,16 @@ var init_run_lifecycle = __esm({
|
|
|
9310
9316
|
// src/notary-source-run.ts
|
|
9311
9317
|
import { dirname as dirname10, isAbsolute as isAbsolute6, join as join18, resolve as resolve9, basename as basename7 } from "node:path";
|
|
9312
9318
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
9319
|
+
async function readRetainedIdentity(runDirectory) {
|
|
9320
|
+
try {
|
|
9321
|
+
return await readRoleRunIdentity(runDirectory);
|
|
9322
|
+
} catch (error) {
|
|
9323
|
+
if (!(error instanceof TypeError || error instanceof SyntaxError)) throw error;
|
|
9324
|
+
throw new NotarySourceRunError("notary --source-run has invalid retained run-state identity", {
|
|
9325
|
+
cause: error
|
|
9326
|
+
});
|
|
9327
|
+
}
|
|
9328
|
+
}
|
|
9313
9329
|
function parseRunDirectoryName(name) {
|
|
9314
9330
|
const match = RUN_DIR_NAME.exec(name);
|
|
9315
9331
|
if (match === null) return void 0;
|
|
@@ -9384,7 +9400,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
9384
9400
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
9385
9401
|
);
|
|
9386
9402
|
}
|
|
9387
|
-
const runState = await
|
|
9403
|
+
const runState = await readRetainedIdentity(real);
|
|
9388
9404
|
if (runState === void 0) {
|
|
9389
9405
|
throw new NotarySourceRunError(
|
|
9390
9406
|
"notary --source-run lacks retained run-state identity"
|
|
@@ -9414,7 +9430,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
9414
9430
|
async function loadNotarySourceRunLocator(path) {
|
|
9415
9431
|
const real = await requireRunDirectory(path, path);
|
|
9416
9432
|
const identity = parseRunDirectoryName(basename7(real));
|
|
9417
|
-
const runState = await
|
|
9433
|
+
const runState = await readRetainedIdentity(real);
|
|
9418
9434
|
if (runState === void 0) {
|
|
9419
9435
|
throw new NotarySourceRunError(
|
|
9420
9436
|
"notary source-run lacks retained run-state identity"
|
|
@@ -18324,7 +18340,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
18324
18340
|
};
|
|
18325
18341
|
}
|
|
18326
18342
|
function roleTurnOptions(env, admitted, continuation) {
|
|
18327
|
-
const correlationId =
|
|
18343
|
+
const correlationId = env.correlationId ?? admitted.correlationId;
|
|
18328
18344
|
return {
|
|
18329
18345
|
packageRoot: env.packageRoot,
|
|
18330
18346
|
home: env.home,
|
|
@@ -20032,15 +20048,7 @@ function isRecord15(value) {
|
|
|
20032
20048
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20033
20049
|
}
|
|
20034
20050
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
20035
|
-
|
|
20036
|
-
const raw = JSON.parse(
|
|
20037
|
-
await readFile20(join37(runDirectory, "run-state.json"), "utf8")
|
|
20038
|
-
);
|
|
20039
|
-
if (!isRecord15(raw) || typeof raw.state !== "string") return void 0;
|
|
20040
|
-
return raw.state;
|
|
20041
|
-
} catch {
|
|
20042
|
-
return void 0;
|
|
20043
|
-
}
|
|
20051
|
+
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
20044
20052
|
}
|
|
20045
20053
|
function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
20046
20054
|
switch (autopsy.verdict) {
|
|
@@ -20075,13 +20083,6 @@ function parseRunDirectoryName2(name) {
|
|
|
20075
20083
|
if (at <= 0 || at === name.length - 1) return void 0;
|
|
20076
20084
|
return { runId: name.slice(0, at), role: name.slice(at + 1) };
|
|
20077
20085
|
}
|
|
20078
|
-
function tryResolveBookKeyFromProjectRoot(projectRoot) {
|
|
20079
|
-
try {
|
|
20080
|
-
return resolveBookKeyFromGit(projectRoot);
|
|
20081
|
-
} catch {
|
|
20082
|
-
return void 0;
|
|
20083
|
-
}
|
|
20084
|
-
}
|
|
20085
20086
|
async function listLedgerBookNames(booksRoot) {
|
|
20086
20087
|
try {
|
|
20087
20088
|
const entries = await readdir8(booksRoot, { withFileTypes: true });
|
|
@@ -20262,7 +20263,13 @@ async function classifyScopedRun(input) {
|
|
|
20262
20263
|
reasons.push(errorText3(error));
|
|
20263
20264
|
}
|
|
20264
20265
|
}
|
|
20265
|
-
|
|
20266
|
+
let lifecycle;
|
|
20267
|
+
try {
|
|
20268
|
+
lifecycle = await readExistingRunLifecycleState(input.runDirectory);
|
|
20269
|
+
} catch (error) {
|
|
20270
|
+
missingSources.push("run-state");
|
|
20271
|
+
reasons.push(errorText3(error));
|
|
20272
|
+
}
|
|
20266
20273
|
let ghostLeg;
|
|
20267
20274
|
if (lifecycle === "admitted" || lifecycle === "running") {
|
|
20268
20275
|
const ghost = await classifyGhostCandidate({
|
|
@@ -20371,8 +20378,8 @@ async function scanAnalystIssueRuns(input) {
|
|
|
20371
20378
|
wholeBook = true;
|
|
20372
20379
|
}
|
|
20373
20380
|
} else if (input.projectRoot !== void 0) {
|
|
20374
|
-
const resolved =
|
|
20375
|
-
if (resolved
|
|
20381
|
+
const resolved = resolveAnalystBookKey(input.projectRoot);
|
|
20382
|
+
if (!isSyntheticAnalystBookKey(resolved)) {
|
|
20376
20383
|
bookNames = [resolved];
|
|
20377
20384
|
wholeBook = true;
|
|
20378
20385
|
} else {
|
|
@@ -20448,7 +20455,7 @@ var LIVE_RUN_STATES;
|
|
|
20448
20455
|
var init_analyst_ledger = __esm({
|
|
20449
20456
|
"src/analyst-ledger.ts"() {
|
|
20450
20457
|
"use strict";
|
|
20451
|
-
|
|
20458
|
+
init_analyst_book_key();
|
|
20452
20459
|
init_activation_ledger_topology();
|
|
20453
20460
|
init_role_run_placement();
|
|
20454
20461
|
init_run_lifecycle();
|
|
@@ -21116,12 +21123,6 @@ function isRecord17(value) {
|
|
|
21116
21123
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
21117
21124
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
21118
21125
|
}
|
|
21119
|
-
function readOutcomeStatus(body) {
|
|
21120
|
-
if (!isRecord17(body.outcome)) return void 0;
|
|
21121
|
-
const status = body.outcome.status;
|
|
21122
|
-
if (typeof status !== "string" || status.trim() === "") return void 0;
|
|
21123
|
-
return status;
|
|
21124
|
-
}
|
|
21125
21126
|
function readClassCount(body) {
|
|
21126
21127
|
if (!isRecord17(body.outcome)) return void 0;
|
|
21127
21128
|
if (!isRecord17(body.outcome.decisiveFacts)) return void 0;
|
|
@@ -21141,7 +21142,7 @@ function projectTerminal(facts) {
|
|
|
21141
21142
|
if (facts.terminal.file === "audit-incomplete.json") {
|
|
21142
21143
|
return { kind: "death", channel: "audit-incomplete" };
|
|
21143
21144
|
}
|
|
21144
|
-
const status =
|
|
21145
|
+
const status = extractStatus(facts.terminal.body);
|
|
21145
21146
|
const classCount = readClassCount(facts.terminal.body);
|
|
21146
21147
|
const receiptStatus = status ?? "unparsed";
|
|
21147
21148
|
if (classCount === void 0) {
|
|
@@ -21210,6 +21211,7 @@ var roundTimelineFamily, round_timeline_default;
|
|
|
21210
21211
|
var init_round_timeline = __esm({
|
|
21211
21212
|
"src/analyst-metric-families/round-timeline.ts"() {
|
|
21212
21213
|
"use strict";
|
|
21214
|
+
init_acceptance_success_rework();
|
|
21213
21215
|
roundTimelineFamily = {
|
|
21214
21216
|
id: "round-timeline",
|
|
21215
21217
|
contribute(input) {
|
|
@@ -22826,10 +22828,12 @@ async function summonPublicRole(options) {
|
|
|
22826
22828
|
const {
|
|
22827
22829
|
loadCredentialProviders: loadCredentialProviders2,
|
|
22828
22830
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
22829
|
-
resolveEffectiveSeat: resolveEffectiveSeat2
|
|
22831
|
+
resolveEffectiveSeat: resolveEffectiveSeat2,
|
|
22832
|
+
validatePublicCliConfigAxes: validatePublicCliConfigAxes2
|
|
22830
22833
|
} = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
22831
22834
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
22832
22835
|
const config = await loadPublicCliConfig2(home);
|
|
22836
|
+
validatePublicCliConfigAxes2(config, packageRoot);
|
|
22833
22837
|
const resolvedSeat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
22834
22838
|
const inheritedSelection = options.model === void 0 ? void 0 : {
|
|
22835
22839
|
provider: options.model.provider,
|
|
@@ -24157,7 +24161,10 @@ function buildMethodContext(activation) {
|
|
|
24157
24161
|
function parsePositiveTicket(raw, label) {
|
|
24158
24162
|
if (raw === void 0 || raw === null) return void 0;
|
|
24159
24163
|
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1) return raw;
|
|
24160
|
-
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim()))
|
|
24164
|
+
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim())) {
|
|
24165
|
+
const value = Number(raw.trim());
|
|
24166
|
+
if (Number.isSafeInteger(value)) return value;
|
|
24167
|
+
}
|
|
24161
24168
|
throw new CollectorTargetBindError(`\u901A\u8FDB\u53F8\u7ED1\u5B9A ${label} \u987B\u4E3A\u6B63\u5B89\u5168\u6574\u6570`);
|
|
24162
24169
|
}
|
|
24163
24170
|
function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
package/dist/analyst-ledger.js
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { readdir, readFile } from "node:fs/promises";
|
|
16
16
|
import { basename, join } from "node:path";
|
|
17
|
-
import {
|
|
17
|
+
import { isSyntheticAnalystBookKey, resolveAnalystBookKey } from "./analyst-book-key.js";
|
|
18
18
|
import { pathContainedIn, physicalPathIdentity, resolveActivationLedgerHome, } from "./activation-ledger-topology.js";
|
|
19
19
|
import { listBookRunDirectories } from "./role-run-placement.js";
|
|
20
|
-
import { autopsyWriterLock } from "./public-cli/run-lifecycle.js";
|
|
20
|
+
import { autopsyWriterLock, readRoleRunIdentity } from "./public-cli/run-lifecycle.js";
|
|
21
21
|
import { readRunTicketNumber } from "./run-ticket-number.js";
|
|
22
22
|
import { extractSessionModelSequence, extractSessionTimestampSpan, extractSessionToolIntervals, LedgerSessionJsonlError, readLedgerSessionJsonl, } from "./ledger-session-read.js";
|
|
23
23
|
import { readRunTerminalArtifact, } from "./run-terminal-artifacts.js";
|
|
@@ -40,15 +40,7 @@ const LIVE_RUN_STATES = new Set(["admitted", "running", "resumable"]);
|
|
|
40
40
|
* Used only to distinguish live in-flight runs from terminal no-receipt.
|
|
41
41
|
*/
|
|
42
42
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
43
|
-
|
|
44
|
-
const raw = JSON.parse(await readFile(join(runDirectory, "run-state.json"), "utf8"));
|
|
45
|
-
if (!isRecord(raw) || typeof raw.state !== "string")
|
|
46
|
-
return undefined;
|
|
47
|
-
return raw.state;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
43
|
+
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
52
44
|
}
|
|
53
45
|
function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
54
46
|
switch (autopsy.verdict) {
|
|
@@ -89,15 +81,6 @@ function parseRunDirectoryName(name) {
|
|
|
89
81
|
return undefined;
|
|
90
82
|
return { runId: name.slice(0, at), role: name.slice(at + 1) };
|
|
91
83
|
}
|
|
92
|
-
/** Best-effort book key from a projectRoot git common-dir; undefined when not a git tree. */
|
|
93
|
-
function tryResolveBookKeyFromProjectRoot(projectRoot) {
|
|
94
|
-
try {
|
|
95
|
-
return resolveBookKeyFromGit(projectRoot);
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
84
|
async function listLedgerBookNames(booksRoot) {
|
|
102
85
|
try {
|
|
103
86
|
const entries = await readdir(booksRoot, { withFileTypes: true });
|
|
@@ -326,7 +309,14 @@ async function classifyScopedRun(input) {
|
|
|
326
309
|
// #855: writer-lease ghost check is independent of terminal artifact status.
|
|
327
310
|
// present → still emit metrics; unreadable → still enter missingSources;
|
|
328
311
|
// admitted|running + non-live lease → still list in ghostLegs (ticket #4).
|
|
329
|
-
|
|
312
|
+
let lifecycle;
|
|
313
|
+
try {
|
|
314
|
+
lifecycle = await readExistingRunLifecycleState(input.runDirectory);
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
missingSources.push("run-state");
|
|
318
|
+
reasons.push(errorText(error));
|
|
319
|
+
}
|
|
330
320
|
let ghostLeg;
|
|
331
321
|
if (lifecycle === "admitted" || lifecycle === "running") {
|
|
332
322
|
const ghost = await classifyGhostCandidate({
|
|
@@ -466,8 +456,8 @@ export async function scanAnalystIssueRuns(input) {
|
|
|
466
456
|
}
|
|
467
457
|
}
|
|
468
458
|
else if (input.projectRoot !== undefined) {
|
|
469
|
-
const resolved =
|
|
470
|
-
if (resolved
|
|
459
|
+
const resolved = resolveAnalystBookKey(input.projectRoot);
|
|
460
|
+
if (!isSyntheticAnalystBookKey(resolved)) {
|
|
471
461
|
bookNames = [resolved];
|
|
472
462
|
wholeBook = true;
|
|
473
463
|
}
|
|
@@ -42,7 +42,7 @@ function findCollectorGroups(body) {
|
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
44
|
/** Extract role receipt status from canonical terminal body faces. */
|
|
45
|
-
function extractStatus(body) {
|
|
45
|
+
export function extractStatus(body) {
|
|
46
46
|
const outcome = body.outcome;
|
|
47
47
|
if (isRecord(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
48
48
|
return outcome.status;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import { extractStatus } from "./acceptance-success-rework.js";
|
|
1
2
|
function isRecord(value) {
|
|
2
3
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
4
|
}
|
|
4
5
|
function wallMsFromSpan(startedAt, endedAt) {
|
|
5
6
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
6
7
|
}
|
|
7
|
-
function readOutcomeStatus(body) {
|
|
8
|
-
if (!isRecord(body.outcome))
|
|
9
|
-
return undefined;
|
|
10
|
-
const status = body.outcome.status;
|
|
11
|
-
if (typeof status !== "string" || status.trim() === "")
|
|
12
|
-
return undefined;
|
|
13
|
-
return status;
|
|
14
|
-
}
|
|
15
8
|
function readClassCount(body) {
|
|
16
9
|
if (!isRecord(body.outcome))
|
|
17
10
|
return undefined;
|
|
@@ -34,7 +27,7 @@ function projectTerminal(facts) {
|
|
|
34
27
|
return { kind: "death", channel: "audit-incomplete" };
|
|
35
28
|
}
|
|
36
29
|
// report.json — receipt face; classCount only when producer wrote a number.
|
|
37
|
-
const status =
|
|
30
|
+
const status = extractStatus(facts.terminal.body);
|
|
38
31
|
const classCount = readClassCount(facts.terminal.body);
|
|
39
32
|
const receiptStatus = status ?? "unparsed";
|
|
40
33
|
if (classCount === undefined) {
|
|
@@ -5795,16 +5795,13 @@ async function appendPiSessionCustomEntry(authority, principal, customType, data
|
|
|
5795
5795
|
})}
|
|
5796
5796
|
`;
|
|
5797
5797
|
await appendFile(sessionFile, pointerLine, "utf8");
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
});
|
|
5806
|
-
} catch {
|
|
5807
|
-
}
|
|
5798
|
+
sitianReport({
|
|
5799
|
+
level: "event",
|
|
5800
|
+
kind: "dispatch-error",
|
|
5801
|
+
sessionParent: sessionFile,
|
|
5802
|
+
payload: { customType, data },
|
|
5803
|
+
source: "pi-role-turn-host"
|
|
5804
|
+
});
|
|
5808
5805
|
}
|
|
5809
5806
|
var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, EXPLICIT_INTERNAL_LOAD_PROBE_ARGS, execFileAsync;
|
|
5810
5807
|
var init_role_turn_host = __esm({
|
|
@@ -7645,7 +7642,7 @@ function parseCurrentCourtState(raw) {
|
|
|
7645
7642
|
...summons === void 0 ? {} : { summons }
|
|
7646
7643
|
};
|
|
7647
7644
|
}
|
|
7648
|
-
async function
|
|
7645
|
+
async function readRoleRunStateRaw(runDirectory) {
|
|
7649
7646
|
let raw;
|
|
7650
7647
|
try {
|
|
7651
7648
|
raw = JSON.parse(await readFile11(join15(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
@@ -7653,24 +7650,40 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
7653
7650
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
7654
7651
|
throw error;
|
|
7655
7652
|
}
|
|
7653
|
+
return raw;
|
|
7654
|
+
}
|
|
7655
|
+
function parseRoleRunIdentity(raw, runDirectory) {
|
|
7656
7656
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
7657
|
-
|
|
7657
|
+
throw new TypeError("Invalid run-state.json");
|
|
7658
7658
|
}
|
|
7659
7659
|
const record4 = raw;
|
|
7660
7660
|
if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
|
|
7661
|
-
|
|
7661
|
+
throw new TypeError("Invalid run-state.json");
|
|
7662
7662
|
}
|
|
7663
7663
|
const role = typeof record4.role === "string" ? packagedRoleMetadata(record4.role)?.role : void 0;
|
|
7664
7664
|
if (role === void 0) {
|
|
7665
|
-
|
|
7665
|
+
throw new TypeError("Invalid run-state.json");
|
|
7666
7666
|
}
|
|
7667
7667
|
if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
|
|
7668
|
-
|
|
7668
|
+
throw new TypeError("Invalid run-state.json");
|
|
7669
7669
|
}
|
|
7670
|
-
if (typeof record4.bookKey !== "string")
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7670
|
+
if (typeof record4.bookKey !== "string") throw new TypeError("Invalid run-state.json");
|
|
7671
|
+
return {
|
|
7672
|
+
runId: record4.runId,
|
|
7673
|
+
role,
|
|
7674
|
+
state: record4.state,
|
|
7675
|
+
bookKey: record4.bookKey,
|
|
7676
|
+
runDirectory
|
|
7677
|
+
};
|
|
7678
|
+
}
|
|
7679
|
+
async function readRoleRunStateDisk(runDirectory) {
|
|
7680
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
7681
|
+
if (raw === void 0) return void 0;
|
|
7682
|
+
const identity = parseRoleRunIdentity(raw, runDirectory);
|
|
7683
|
+
const record4 = raw;
|
|
7684
|
+
if (typeof record4.projectRoot !== "string") throw new TypeError("Invalid run-state.json");
|
|
7685
|
+
if (typeof record4.sessionDirectory !== "string") throw new TypeError("Invalid run-state.json");
|
|
7686
|
+
if (typeof record4.admittedRequestPath !== "string") throw new TypeError("Invalid run-state.json");
|
|
7674
7687
|
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
7675
7688
|
const runDir = runDirectory;
|
|
7676
7689
|
const principalWire = {
|
|
@@ -7693,10 +7706,10 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
7693
7706
|
const phase = record4.phase === "plan" || record4.phase === "apply" ? record4.phase : void 0;
|
|
7694
7707
|
const currentCourt = parseCurrentCourtState(record4.currentCourt);
|
|
7695
7708
|
return {
|
|
7696
|
-
runId:
|
|
7697
|
-
role,
|
|
7698
|
-
state:
|
|
7699
|
-
bookKey:
|
|
7709
|
+
runId: identity.runId,
|
|
7710
|
+
role: identity.role,
|
|
7711
|
+
state: identity.state,
|
|
7712
|
+
bookKey: identity.bookKey,
|
|
7700
7713
|
projectRoot: record4.projectRoot,
|
|
7701
7714
|
runDirectory: runDir,
|
|
7702
7715
|
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
@@ -7761,15 +7774,8 @@ async function readRoleRunState(runDirectory, authority) {
|
|
|
7761
7774
|
return materializeRoleRunFromDisk(disk, authority)?.run;
|
|
7762
7775
|
}
|
|
7763
7776
|
async function readRoleRunIdentity(runDirectory) {
|
|
7764
|
-
const
|
|
7765
|
-
|
|
7766
|
-
return {
|
|
7767
|
-
runId: disk.runId,
|
|
7768
|
-
role: disk.role,
|
|
7769
|
-
bookKey: disk.bookKey,
|
|
7770
|
-
runDirectory: disk.runDirectory,
|
|
7771
|
-
state: disk.state
|
|
7772
|
-
};
|
|
7777
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
7778
|
+
return raw === void 0 ? void 0 : parseRoleRunIdentity(raw, runDirectory);
|
|
7773
7779
|
}
|
|
7774
7780
|
async function markRunAdmitted(admitted, authority) {
|
|
7775
7781
|
const { sessionDirectory, sessionFile } = authority.decode(admitted.principal);
|
|
@@ -8772,6 +8778,16 @@ var init_run_lifecycle = __esm({
|
|
|
8772
8778
|
// src/notary-source-run.ts
|
|
8773
8779
|
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join16, resolve as resolve8, basename as basename7 } from "node:path";
|
|
8774
8780
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
8781
|
+
async function readRetainedIdentity(runDirectory) {
|
|
8782
|
+
try {
|
|
8783
|
+
return await readRoleRunIdentity(runDirectory);
|
|
8784
|
+
} catch (error) {
|
|
8785
|
+
if (!(error instanceof TypeError || error instanceof SyntaxError)) throw error;
|
|
8786
|
+
throw new NotarySourceRunError("notary --source-run has invalid retained run-state identity", {
|
|
8787
|
+
cause: error
|
|
8788
|
+
});
|
|
8789
|
+
}
|
|
8790
|
+
}
|
|
8775
8791
|
function parseRunDirectoryName(name) {
|
|
8776
8792
|
const match = RUN_DIR_NAME.exec(name);
|
|
8777
8793
|
if (match === null) return void 0;
|
|
@@ -8846,7 +8862,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8846
8862
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
8847
8863
|
);
|
|
8848
8864
|
}
|
|
8849
|
-
const runState = await
|
|
8865
|
+
const runState = await readRetainedIdentity(real);
|
|
8850
8866
|
if (runState === void 0) {
|
|
8851
8867
|
throw new NotarySourceRunError(
|
|
8852
8868
|
"notary --source-run lacks retained run-state identity"
|
|
@@ -8876,7 +8892,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8876
8892
|
async function loadNotarySourceRunLocator(path) {
|
|
8877
8893
|
const real = await requireRunDirectory(path, path);
|
|
8878
8894
|
const identity = parseRunDirectoryName(basename7(real));
|
|
8879
|
-
const runState = await
|
|
8895
|
+
const runState = await readRetainedIdentity(real);
|
|
8880
8896
|
if (runState === void 0) {
|
|
8881
8897
|
throw new NotarySourceRunError(
|
|
8882
8898
|
"notary source-run lacks retained run-state identity"
|
|
@@ -17786,7 +17802,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
17786
17802
|
};
|
|
17787
17803
|
}
|
|
17788
17804
|
function roleTurnOptions(env, admitted, continuation) {
|
|
17789
|
-
const correlationId =
|
|
17805
|
+
const correlationId = env.correlationId ?? admitted.correlationId;
|
|
17790
17806
|
return {
|
|
17791
17807
|
packageRoot: env.packageRoot,
|
|
17792
17808
|
home: env.home,
|
|
@@ -19494,15 +19510,7 @@ function isRecord15(value) {
|
|
|
19494
19510
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19495
19511
|
}
|
|
19496
19512
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
19497
|
-
|
|
19498
|
-
const raw = JSON.parse(
|
|
19499
|
-
await readFile20(join35(runDirectory, "run-state.json"), "utf8")
|
|
19500
|
-
);
|
|
19501
|
-
if (!isRecord15(raw) || typeof raw.state !== "string") return void 0;
|
|
19502
|
-
return raw.state;
|
|
19503
|
-
} catch {
|
|
19504
|
-
return void 0;
|
|
19505
|
-
}
|
|
19513
|
+
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
19506
19514
|
}
|
|
19507
19515
|
function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
19508
19516
|
switch (autopsy.verdict) {
|
|
@@ -19537,13 +19545,6 @@ function parseRunDirectoryName2(name) {
|
|
|
19537
19545
|
if (at <= 0 || at === name.length - 1) return void 0;
|
|
19538
19546
|
return { runId: name.slice(0, at), role: name.slice(at + 1) };
|
|
19539
19547
|
}
|
|
19540
|
-
function tryResolveBookKeyFromProjectRoot(projectRoot) {
|
|
19541
|
-
try {
|
|
19542
|
-
return resolveBookKeyFromGit(projectRoot);
|
|
19543
|
-
} catch {
|
|
19544
|
-
return void 0;
|
|
19545
|
-
}
|
|
19546
|
-
}
|
|
19547
19548
|
async function listLedgerBookNames(booksRoot) {
|
|
19548
19549
|
try {
|
|
19549
19550
|
const entries = await readdir8(booksRoot, { withFileTypes: true });
|
|
@@ -19724,7 +19725,13 @@ async function classifyScopedRun(input) {
|
|
|
19724
19725
|
reasons.push(errorText3(error));
|
|
19725
19726
|
}
|
|
19726
19727
|
}
|
|
19727
|
-
|
|
19728
|
+
let lifecycle;
|
|
19729
|
+
try {
|
|
19730
|
+
lifecycle = await readExistingRunLifecycleState(input.runDirectory);
|
|
19731
|
+
} catch (error) {
|
|
19732
|
+
missingSources.push("run-state");
|
|
19733
|
+
reasons.push(errorText3(error));
|
|
19734
|
+
}
|
|
19728
19735
|
let ghostLeg;
|
|
19729
19736
|
if (lifecycle === "admitted" || lifecycle === "running") {
|
|
19730
19737
|
const ghost = await classifyGhostCandidate({
|
|
@@ -19833,8 +19840,8 @@ async function scanAnalystIssueRuns(input) {
|
|
|
19833
19840
|
wholeBook = true;
|
|
19834
19841
|
}
|
|
19835
19842
|
} else if (input.projectRoot !== void 0) {
|
|
19836
|
-
const resolved =
|
|
19837
|
-
if (resolved
|
|
19843
|
+
const resolved = resolveAnalystBookKey(input.projectRoot);
|
|
19844
|
+
if (!isSyntheticAnalystBookKey(resolved)) {
|
|
19838
19845
|
bookNames = [resolved];
|
|
19839
19846
|
wholeBook = true;
|
|
19840
19847
|
} else {
|
|
@@ -19910,7 +19917,7 @@ var LIVE_RUN_STATES;
|
|
|
19910
19917
|
var init_analyst_ledger = __esm({
|
|
19911
19918
|
"src/analyst-ledger.ts"() {
|
|
19912
19919
|
"use strict";
|
|
19913
|
-
|
|
19920
|
+
init_analyst_book_key();
|
|
19914
19921
|
init_activation_ledger_topology();
|
|
19915
19922
|
init_role_run_placement();
|
|
19916
19923
|
init_run_lifecycle();
|
|
@@ -20578,12 +20585,6 @@ function isRecord17(value) {
|
|
|
20578
20585
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
20579
20586
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
20580
20587
|
}
|
|
20581
|
-
function readOutcomeStatus(body) {
|
|
20582
|
-
if (!isRecord17(body.outcome)) return void 0;
|
|
20583
|
-
const status = body.outcome.status;
|
|
20584
|
-
if (typeof status !== "string" || status.trim() === "") return void 0;
|
|
20585
|
-
return status;
|
|
20586
|
-
}
|
|
20587
20588
|
function readClassCount(body) {
|
|
20588
20589
|
if (!isRecord17(body.outcome)) return void 0;
|
|
20589
20590
|
if (!isRecord17(body.outcome.decisiveFacts)) return void 0;
|
|
@@ -20603,7 +20604,7 @@ function projectTerminal(facts) {
|
|
|
20603
20604
|
if (facts.terminal.file === "audit-incomplete.json") {
|
|
20604
20605
|
return { kind: "death", channel: "audit-incomplete" };
|
|
20605
20606
|
}
|
|
20606
|
-
const status =
|
|
20607
|
+
const status = extractStatus(facts.terminal.body);
|
|
20607
20608
|
const classCount = readClassCount(facts.terminal.body);
|
|
20608
20609
|
const receiptStatus = status ?? "unparsed";
|
|
20609
20610
|
if (classCount === void 0) {
|
|
@@ -20672,6 +20673,7 @@ var roundTimelineFamily, round_timeline_default;
|
|
|
20672
20673
|
var init_round_timeline = __esm({
|
|
20673
20674
|
"src/analyst-metric-families/round-timeline.ts"() {
|
|
20674
20675
|
"use strict";
|
|
20676
|
+
init_acceptance_success_rework();
|
|
20675
20677
|
roundTimelineFamily = {
|
|
20676
20678
|
id: "round-timeline",
|
|
20677
20679
|
contribute(input) {
|
|
@@ -22288,10 +22290,12 @@ async function summonPublicRole(options) {
|
|
|
22288
22290
|
const {
|
|
22289
22291
|
loadCredentialProviders: loadCredentialProviders2,
|
|
22290
22292
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
22291
|
-
resolveEffectiveSeat: resolveEffectiveSeat2
|
|
22293
|
+
resolveEffectiveSeat: resolveEffectiveSeat2,
|
|
22294
|
+
validatePublicCliConfigAxes: validatePublicCliConfigAxes2
|
|
22292
22295
|
} = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
22293
22296
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
22294
22297
|
const config = await loadPublicCliConfig2(home);
|
|
22298
|
+
validatePublicCliConfigAxes2(config, packageRoot);
|
|
22295
22299
|
const resolvedSeat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
22296
22300
|
const inheritedSelection = options.model === void 0 ? void 0 : {
|
|
22297
22301
|
provider: options.model.provider,
|
|
@@ -25068,7 +25072,10 @@ function buildMethodContext(activation) {
|
|
|
25068
25072
|
function parsePositiveTicket(raw, label) {
|
|
25069
25073
|
if (raw === void 0 || raw === null) return void 0;
|
|
25070
25074
|
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1) return raw;
|
|
25071
|
-
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim()))
|
|
25075
|
+
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim())) {
|
|
25076
|
+
const value = Number(raw.trim());
|
|
25077
|
+
if (Number.isSafeInteger(value)) return value;
|
|
25078
|
+
}
|
|
25072
25079
|
throw new CollectorTargetBindError(`\u901A\u8FDB\u53F8\u7ED1\u5B9A ${label} \u987B\u4E3A\u6B63\u5B89\u5168\u6574\u6570`);
|
|
25073
25080
|
}
|
|
25074
25081
|
function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|