@akagilnc/pi-workflow-roles 0.1.2383 → 0.1.2402
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/audit-escalation.js +0 -13
- package/dist/compliance-transport.js +28 -5
- package/dist/doctor-contracts.js +2 -9
- package/dist/dossier-resolution.js +21 -2
- package/dist/engine-detour-tool.js +10 -35
- package/dist/evidence-child-executor.js +12 -4
- package/dist/merger-contracts.js +2 -8
- package/dist/navigator-attendance.js +1 -9
- package/dist/navigator-invocation-identity.js +16 -4
- package/dist/notary-contracts.js +7 -25
- package/dist/package-contracts/judge-output.js +1 -4
- package/dist/package-contracts/reviewer-output.js +1 -7
- package/dist/package-contracts/terminating-tools.js +6 -11
- package/dist/public-cli/main.js +125 -475
- package/package.json +1 -1
- package/scripts/build-package.mjs +1 -2
- package/src/analyst-gate-cycles-read.ts +5 -8
- package/src/analyst-metric-families/acceptance-success-rework.ts +3 -6
- package/src/audit-escalation.ts +0 -25
- package/src/collector-role.ts +1 -8
- package/src/compliance-transport.ts +38 -6
- package/src/doctor-auditor.ts +3 -3
- package/src/doctor-contracts.ts +3 -18
- package/src/doctor-role.ts +1 -5
- package/src/dossier-resolution.ts +25 -4
- package/src/engine-detour-tool.ts +16 -51
- package/src/evidence-child-executor.ts +12 -4
- package/src/factory-board.ts +2 -4
- package/src/gatekeeper-role.ts +33 -43
- package/src/judge-auditor.ts +3 -3
- package/src/judge-role.ts +1 -8
- package/src/merger-contracts.ts +3 -17
- package/src/merger-role.ts +1 -8
- package/src/navigator-attendance.ts +1 -14
- package/src/navigator-invocation-identity.ts +34 -13
- package/src/notary-contracts.ts +9 -43
- package/src/notary-role.ts +3 -5
- package/src/package-contracts/judge-output.ts +2 -17
- package/src/package-contracts/reviewer-output.ts +2 -21
- package/src/package-contracts/terminating-tools.ts +5 -14
- package/src/package-contracts/worker-output.ts +2 -10
- package/src/public-cli/doctor-run.ts +0 -2
- package/src/public-cli/fixer-run.ts +0 -15
- package/src/public-cli/judge-run.ts +0 -16
- package/src/public-cli/notary-run.ts +1 -1
- package/src/public-cli/one-shot-dispatch.ts +1 -1
- package/src/public-cli/reviewer-run.ts +0 -15
- package/src/public-cli/settlement.ts +110 -368
- package/src/public-cli/terminal.ts +3 -71
- package/src/reviewer-auditor.ts +3 -3
- package/src/reviewer-role.ts +2 -11
- package/src/role-runtime.ts +43 -37
- package/src/worker-role.ts +2 -14
- package/dist/engine-labor-fallback.js +0 -136
- package/src/engine-labor-fallback.ts +0 -270
package/dist/public-cli/main.js
CHANGED
|
@@ -136,54 +136,6 @@ var init_collector_output = __esm({
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
// src/engine-labor-fallback.ts
|
|
140
|
-
function buildEngineLaborFallbackField(input) {
|
|
141
|
-
return Object.freeze({
|
|
142
|
-
engineLaborFallback: Object.freeze({
|
|
143
|
-
engine: input.engine,
|
|
144
|
-
failure: input.failure,
|
|
145
|
-
laborBy: "seat"
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function isSeatFallbackTaintedStatus(status) {
|
|
150
|
-
return status.endsWith(SEAT_FALLBACK_STATUS_SUFFIX);
|
|
151
|
-
}
|
|
152
|
-
function seatFallbackBaseStatus(status) {
|
|
153
|
-
return isSeatFallbackTaintedStatus(status) ? status.slice(0, -SEAT_FALLBACK_STATUS_SUFFIX.length) : status;
|
|
154
|
-
}
|
|
155
|
-
function seatFallbackStatusHasLawfulEvidence(status, source) {
|
|
156
|
-
if (!isSeatFallbackTaintedStatus(status)) return true;
|
|
157
|
-
return readEngineLaborFallbackFieldFrom(source) !== void 0;
|
|
158
|
-
}
|
|
159
|
-
function readEngineLaborFallbackFieldFrom(source) {
|
|
160
|
-
if (typeof source !== "object" || source === null || Array.isArray(source)) {
|
|
161
|
-
return void 0;
|
|
162
|
-
}
|
|
163
|
-
let raw;
|
|
164
|
-
try {
|
|
165
|
-
raw = source.engineLaborFallback;
|
|
166
|
-
} catch {
|
|
167
|
-
return void 0;
|
|
168
|
-
}
|
|
169
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
|
|
170
|
-
const rec = raw;
|
|
171
|
-
if (typeof rec.engine !== "string" || typeof rec.failure !== "string" || rec.laborBy !== "seat") {
|
|
172
|
-
return void 0;
|
|
173
|
-
}
|
|
174
|
-
return buildEngineLaborFallbackField({
|
|
175
|
-
engine: rec.engine,
|
|
176
|
-
failure: rec.failure
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
var SEAT_FALLBACK_STATUS_SUFFIX;
|
|
180
|
-
var init_engine_labor_fallback = __esm({
|
|
181
|
-
"src/engine-labor-fallback.ts"() {
|
|
182
|
-
"use strict";
|
|
183
|
-
SEAT_FALLBACK_STATUS_SUFFIX = "-by-fallback";
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
139
|
// src/package-contracts/judge-output.ts
|
|
188
140
|
function validateAcceptedJudgeDetails(verdict) {
|
|
189
141
|
if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
|
|
@@ -196,8 +148,7 @@ function validateAcceptedJudgeDetails(verdict) {
|
|
|
196
148
|
if (typeof judgeStatus !== "string") {
|
|
197
149
|
throw new Error("Judge verdict has no execution discriminator");
|
|
198
150
|
}
|
|
199
|
-
|
|
200
|
-
if (["converged", "continue", "escalate"].includes(base) && seatFallbackStatusHasLawfulEvidence(judgeStatus, verdict)) {
|
|
151
|
+
if (["converged", "continue", "escalate"].includes(judgeStatus)) {
|
|
201
152
|
return verdict;
|
|
202
153
|
}
|
|
203
154
|
throw new Error("Judge verdict has no execution discriminator");
|
|
@@ -206,7 +157,6 @@ var JUDGE_OUTPUT_TOOL_NAME;
|
|
|
206
157
|
var init_judge_output = __esm({
|
|
207
158
|
"src/package-contracts/judge-output.ts"() {
|
|
208
159
|
"use strict";
|
|
209
|
-
init_engine_labor_fallback();
|
|
210
160
|
JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
|
|
211
161
|
}
|
|
212
162
|
});
|
|
@@ -225,9 +175,6 @@ function read(value, key) {
|
|
|
225
175
|
}
|
|
226
176
|
function validateRuntimeReviewerReceipt(output) {
|
|
227
177
|
const status = read(output, "status");
|
|
228
|
-
if (typeof status === "string" && !seatFallbackStatusHasLawfulEvidence(status, output)) {
|
|
229
|
-
throw new Error("Reviewer receipt has no recognized execution discriminator");
|
|
230
|
-
}
|
|
231
178
|
const acceptedBatch = read(output, "acceptedBatch");
|
|
232
179
|
const identities = read(output, "identities");
|
|
233
180
|
const construction = read(identities, "construction");
|
|
@@ -283,7 +230,6 @@ var REVIEWER_OUTPUT_TOOL_NAME;
|
|
|
283
230
|
var init_reviewer_output = __esm({
|
|
284
231
|
"src/package-contracts/reviewer-output.ts"() {
|
|
285
232
|
"use strict";
|
|
286
|
-
init_engine_labor_fallback();
|
|
287
233
|
REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
|
|
288
234
|
}
|
|
289
235
|
});
|
|
@@ -14154,18 +14100,13 @@ function read2(value, key) {
|
|
|
14154
14100
|
}
|
|
14155
14101
|
function validateDoctorSubmissionShape(value) {
|
|
14156
14102
|
const status = read2(value, "status");
|
|
14157
|
-
|
|
14158
|
-
if (base !== "completed" && base !== "refused") throw new DoctorSubmissionContractError("Doctor submission has no recognized execution status");
|
|
14159
|
-
if (typeof status === "string" && !seatFallbackStatusHasLawfulEvidence(status, value)) {
|
|
14160
|
-
throw new DoctorSubmissionContractError("Doctor submission has no recognized execution status");
|
|
14161
|
-
}
|
|
14103
|
+
if (status !== "completed" && status !== "refused") throw new DoctorSubmissionContractError("Doctor submission has no recognized execution status");
|
|
14162
14104
|
return value;
|
|
14163
14105
|
}
|
|
14164
14106
|
function validateRecordedDoctorOutput(value) {
|
|
14165
14107
|
const output = validateDoctorSubmissionShape(value);
|
|
14166
14108
|
const status = read2(output, "status");
|
|
14167
|
-
|
|
14168
|
-
if (base === "completed" && read2(output, "cost") === void 0) throw new Error("Completed Doctor receipt has no runtime-owned cost testimony");
|
|
14109
|
+
if (status === "completed" && read2(output, "cost") === void 0) throw new Error("Completed Doctor receipt has no runtime-owned cost testimony");
|
|
14169
14110
|
return output;
|
|
14170
14111
|
}
|
|
14171
14112
|
var DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_TARGET_KINDS, nonblank, count, evidenceIds, guardrail, lastRealBite, assetKinds, findingBody, finding, caseIdentity, cost, doctorSubmissionVariants, doctorSubmissionSchema, doctorOutputSchema, doctorEvidenceReadSchema, DoctorSubmissionContractError;
|
|
@@ -14174,7 +14115,6 @@ var init_doctor_contracts = __esm({
|
|
|
14174
14115
|
"use strict";
|
|
14175
14116
|
init_build();
|
|
14176
14117
|
init_canonical_json();
|
|
14177
|
-
init_engine_labor_fallback();
|
|
14178
14118
|
init_open_tool_schema();
|
|
14179
14119
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
14180
14120
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
@@ -14319,12 +14259,8 @@ function validateMergerInput(value) {
|
|
|
14319
14259
|
function validateMergerOutput(value, expectedAttemptId) {
|
|
14320
14260
|
if (!record(value) || expectedAttemptId !== void 0 && value.attemptId !== expectedAttemptId) throw new Error("Merger output attempt mismatch");
|
|
14321
14261
|
const status = typeof value.status === "string" ? value.status : void 0;
|
|
14322
|
-
|
|
14323
|
-
if (status
|
|
14324
|
-
throw new Error("Merger output has no recognized execution discriminator");
|
|
14325
|
-
}
|
|
14326
|
-
if (statusBase === "completed" && isFullGitObjectId(value.mergeCommitId)) return structuredClone(value);
|
|
14327
|
-
if (statusBase === "escalate") return structuredClone(value);
|
|
14262
|
+
if (status === "completed" && isFullGitObjectId(value.mergeCommitId)) return structuredClone(value);
|
|
14263
|
+
if (status === "escalate") return structuredClone(value);
|
|
14328
14264
|
throw new Error("Merger output has no recognized execution discriminator");
|
|
14329
14265
|
}
|
|
14330
14266
|
var oidPattern, materialSchema, checkSchema, mergerInputSchema, mergerOutputVariants, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, record, blank, MergerInputContractError;
|
|
@@ -14334,7 +14270,6 @@ var init_merger_contracts = __esm({
|
|
|
14334
14270
|
init_build();
|
|
14335
14271
|
init_git_object_id();
|
|
14336
14272
|
init_exact_utf8();
|
|
14337
|
-
init_engine_labor_fallback();
|
|
14338
14273
|
init_sha256();
|
|
14339
14274
|
init_open_tool_schema();
|
|
14340
14275
|
oidPattern = "^(?:[0-9a-f]{40}|[0-9a-f]{64})$";
|
|
@@ -14380,17 +14315,10 @@ function validateNotaryOutput(value) {
|
|
|
14380
14315
|
throw new Error("Notary output has no recognized execution discriminator");
|
|
14381
14316
|
}
|
|
14382
14317
|
const statusRaw = typeof value.status === "string" ? value.status : void 0;
|
|
14383
|
-
if (statusRaw === void 0
|
|
14318
|
+
if (statusRaw === void 0) {
|
|
14384
14319
|
throw new Error("Notary output has no recognized execution discriminator");
|
|
14385
14320
|
}
|
|
14386
|
-
const status =
|
|
14387
|
-
if (status === "incomplete") {
|
|
14388
|
-
const reason = value.reason;
|
|
14389
|
-
if (typeof reason !== "string" || reason.trim() === "") {
|
|
14390
|
-
throw new Error("Notary incomplete requires a non-empty reason");
|
|
14391
|
-
}
|
|
14392
|
-
return structuredClone(value);
|
|
14393
|
-
}
|
|
14321
|
+
const status = statusRaw;
|
|
14394
14322
|
if (status === "bounce") {
|
|
14395
14323
|
const clone = structuredClone(value);
|
|
14396
14324
|
if (clone.disposition === void 0) clone.disposition = "rewrite";
|
|
@@ -14408,7 +14336,7 @@ function validateRecordedNotaryOutput(value) {
|
|
|
14408
14336
|
return validateNotaryOutput(value);
|
|
14409
14337
|
}
|
|
14410
14338
|
function notaryDecisiveFacts(output) {
|
|
14411
|
-
const status =
|
|
14339
|
+
const status = String(output.status);
|
|
14412
14340
|
const facts = { status, officer: "notary" };
|
|
14413
14341
|
if (status === "pass" || status === "bounce") {
|
|
14414
14342
|
const findings = output.findings;
|
|
@@ -14417,9 +14345,6 @@ function notaryDecisiveFacts(output) {
|
|
|
14417
14345
|
if (status === "bounce") {
|
|
14418
14346
|
facts.disposition = "rewrite";
|
|
14419
14347
|
}
|
|
14420
|
-
if (status === "incomplete") {
|
|
14421
|
-
facts.reason = output.reason;
|
|
14422
|
-
}
|
|
14423
14348
|
return facts;
|
|
14424
14349
|
}
|
|
14425
14350
|
var NOTARY_OUTPUT_TOOL_NAME, NOTARY_FIXED_KICKOFF, notaryOutputSchema;
|
|
@@ -14427,20 +14352,16 @@ var init_notary_contracts = __esm({
|
|
|
14427
14352
|
"src/notary-contracts.ts"() {
|
|
14428
14353
|
"use strict";
|
|
14429
14354
|
init_build();
|
|
14430
|
-
init_engine_labor_fallback();
|
|
14431
14355
|
init_open_tool_schema();
|
|
14432
14356
|
NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
|
|
14433
14357
|
NOTARY_FIXED_KICKOFF = "Notary review. Bound source-run locator is on the session materials; fetch authoritative ticket, git, and dossier evidence yourself; submit one typed decision.";
|
|
14434
14358
|
notaryOutputSchema = openToolObject(
|
|
14435
14359
|
typebox_exports.Object({
|
|
14436
14360
|
status: typebox_exports.Unknown({
|
|
14437
|
-
description: "pass | bounce
|
|
14361
|
+
description: "pass | bounce \u2014 guidance, not a schema gate."
|
|
14438
14362
|
}),
|
|
14439
14363
|
findings: typebox_exports.Unknown({
|
|
14440
14364
|
description: "string[] findings retained with pass or bounce."
|
|
14441
|
-
}),
|
|
14442
|
-
reason: typebox_exports.Unknown({
|
|
14443
|
-
description: "Why the notary decision is incomplete."
|
|
14444
14365
|
})
|
|
14445
14366
|
})
|
|
14446
14367
|
);
|
|
@@ -15444,13 +15365,12 @@ function validateAcceptedDetails(toolName, details) {
|
|
|
15444
15365
|
[COLLECTOR_OUTPUT_TOOL]: [],
|
|
15445
15366
|
[DOCTOR_OUTPUT_TOOL_NAME]: ["completed", "refused"],
|
|
15446
15367
|
[MERGER_OUTPUT_TOOL_NAME]: ["completed", "escalate"],
|
|
15447
|
-
[NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce"
|
|
15368
|
+
[NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce"]
|
|
15448
15369
|
};
|
|
15449
15370
|
const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
|
|
15450
|
-
const baseDiscriminator =
|
|
15451
|
-
const taintedWithoutEvidence = typeof discriminator === "string" && !seatFallbackStatusHasLawfulEvidence(discriminator, details);
|
|
15371
|
+
const baseDiscriminator = discriminator;
|
|
15452
15372
|
const runtimeBindingMissing = toolName === DOCTOR_OUTPUT_TOOL_NAME && baseDiscriminator === "completed" && !(candidate?.cost !== null && typeof candidate?.cost === "object") || toolName === REVIEWER_OUTPUT_TOOL_NAME && candidate?.version !== 2;
|
|
15453
|
-
if (
|
|
15373
|
+
if (runtimeBindingMissing || !collectorDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator))) {
|
|
15454
15374
|
throw new AcceptedDetailsContractError("terminating receipt has no recognized execution discriminator");
|
|
15455
15375
|
}
|
|
15456
15376
|
try {
|
|
@@ -15490,7 +15410,7 @@ function acceptedFacts(toolName, details) {
|
|
|
15490
15410
|
case MERGER_OUTPUT_TOOL_NAME: {
|
|
15491
15411
|
const output = details;
|
|
15492
15412
|
const status = output.status;
|
|
15493
|
-
return { status, ...
|
|
15413
|
+
return { status, ...status === "completed" && typeof output.mergeCommitId === "string" ? { commit: output.mergeCommitId } : {} };
|
|
15494
15414
|
}
|
|
15495
15415
|
case COLLECTOR_OUTPUT_TOOL:
|
|
15496
15416
|
return { status: "collected" };
|
|
@@ -15504,7 +15424,6 @@ var init_terminating_tools = __esm({
|
|
|
15504
15424
|
init_judge_output();
|
|
15505
15425
|
init_reviewer_output();
|
|
15506
15426
|
init_audit_escalation();
|
|
15507
|
-
init_engine_labor_fallback();
|
|
15508
15427
|
init_doctor_contracts();
|
|
15509
15428
|
init_merger_contracts();
|
|
15510
15429
|
init_notary_contracts();
|
|
@@ -19893,9 +19812,6 @@ var init_command_renderer = __esm({
|
|
|
19893
19812
|
function encodeTerminalField(value) {
|
|
19894
19813
|
return JSON.stringify(value);
|
|
19895
19814
|
}
|
|
19896
|
-
function jsonSafeComplianceCandidate(value) {
|
|
19897
|
-
return value === void 0 ? JSON_SAFE_UNDEFINED_ARGUMENT : value;
|
|
19898
|
-
}
|
|
19899
19815
|
function isLawfulTypedTerminalOutcome(outcome) {
|
|
19900
19816
|
return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
|
|
19901
19817
|
}
|
|
@@ -19919,31 +19835,6 @@ function buildResidualIncompleteTerminalOutcome(input) {
|
|
|
19919
19835
|
}
|
|
19920
19836
|
};
|
|
19921
19837
|
}
|
|
19922
|
-
function buildAuditIncompleteTerminalOutcome(input) {
|
|
19923
|
-
const roleCandidate = jsonSafeComplianceCandidate(input.roleCandidate);
|
|
19924
|
-
const audit = {
|
|
19925
|
-
...input.audit,
|
|
19926
|
-
candidate: jsonSafeComplianceCandidate(input.audit.candidate)
|
|
19927
|
-
};
|
|
19928
|
-
return {
|
|
19929
|
-
kind: "audit_incomplete",
|
|
19930
|
-
role: input.role,
|
|
19931
|
-
status: "audit-incomplete",
|
|
19932
|
-
decision: "no-usable-decision",
|
|
19933
|
-
roleCandidate,
|
|
19934
|
-
audit,
|
|
19935
|
-
acceptedReceipt: false,
|
|
19936
|
-
decisiveFacts: {
|
|
19937
|
-
decision: "no-usable-decision",
|
|
19938
|
-
roleCandidate,
|
|
19939
|
-
auditCandidate: audit.candidate,
|
|
19940
|
-
auditObservation: audit.observation,
|
|
19941
|
-
observationKind: audit.observation.kind,
|
|
19942
|
-
observationType: audit.observation.kind === "non-object-arguments" ? audit.observation.type : audit.observation.kind === "object-status-unreadable" ? audit.observation.status : audit.observation.kind === "missing-subject" ? audit.observation.subject : audit.observation.kind,
|
|
19943
|
-
acceptedReceipt: false
|
|
19944
|
-
}
|
|
19945
|
-
};
|
|
19946
|
-
}
|
|
19947
19838
|
function redactExactRunId(text, runId) {
|
|
19948
19839
|
if (runId.length === 0) return text;
|
|
19949
19840
|
if (!text.includes(runId)) return text;
|
|
@@ -20026,15 +19917,11 @@ function formatTerminalResult(result2) {
|
|
|
20026
19917
|
return `${lines.join("\n")}
|
|
20027
19918
|
`;
|
|
20028
19919
|
}
|
|
20029
|
-
var
|
|
19920
|
+
var REDACTED_RUN_ID_TOKEN;
|
|
20030
19921
|
var init_terminal = __esm({
|
|
20031
19922
|
"src/public-cli/terminal.ts"() {
|
|
20032
19923
|
"use strict";
|
|
20033
19924
|
init_command_renderer();
|
|
20034
|
-
JSON_SAFE_UNDEFINED_ARGUMENT = Object.freeze({
|
|
20035
|
-
kind: "json-safe-sentinel",
|
|
20036
|
-
type: "undefined"
|
|
20037
|
-
});
|
|
20038
19925
|
REDACTED_RUN_ID_TOKEN = "[run-id]";
|
|
20039
19926
|
}
|
|
20040
19927
|
});
|
|
@@ -20155,8 +20042,8 @@ function extractSessionToolIntervals(rows) {
|
|
|
20155
20042
|
if (resultTimestamp === void 0 || resultTimestamp.length === 0) {
|
|
20156
20043
|
throw new Error(`toolResult ${message.toolCallId} missing timestamp`);
|
|
20157
20044
|
}
|
|
20158
|
-
const
|
|
20159
|
-
if (
|
|
20045
|
+
const open4 = openById.get(message.toolCallId);
|
|
20046
|
+
if (open4 === void 0) {
|
|
20160
20047
|
const toolName = typeof message.toolName === "string" && message.toolName.length > 0 ? message.toolName : "unknown";
|
|
20161
20048
|
order.push({
|
|
20162
20049
|
toolCallId: message.toolCallId,
|
|
@@ -20166,10 +20053,10 @@ function extractSessionToolIntervals(rows) {
|
|
|
20166
20053
|
});
|
|
20167
20054
|
continue;
|
|
20168
20055
|
}
|
|
20169
|
-
if (
|
|
20056
|
+
if (open4.endedAt !== void 0) {
|
|
20170
20057
|
throw new Error(`duplicate toolResult for toolCallId ${message.toolCallId}`);
|
|
20171
20058
|
}
|
|
20172
|
-
|
|
20059
|
+
open4.endedAt = resultTimestamp;
|
|
20173
20060
|
}
|
|
20174
20061
|
}
|
|
20175
20062
|
return order.map((interval) => {
|
|
@@ -20293,7 +20180,6 @@ async function classifyAuditorVolume(filePath) {
|
|
|
20293
20180
|
const findings = asStringFindings(call.args?.findings);
|
|
20294
20181
|
const findingsCount = findings.length;
|
|
20295
20182
|
if (DISPATCH_TOOLS.has(call.toolName)) {
|
|
20296
|
-
if (status === "incomplete") return void 0;
|
|
20297
20183
|
if (status !== "dispatch") {
|
|
20298
20184
|
throw new Error(
|
|
20299
20185
|
`accepted dispatch receipt has non-dispatch status ${JSON.stringify(status)} in ${filePath}`
|
|
@@ -20415,16 +20301,10 @@ var init_session_opening_materials = __esm({
|
|
|
20415
20301
|
});
|
|
20416
20302
|
|
|
20417
20303
|
// src/auditor-soul.ts
|
|
20418
|
-
var AUDITOR_SOUL_ROLES;
|
|
20419
20304
|
var init_auditor_soul = __esm({
|
|
20420
20305
|
"src/auditor-soul.ts"() {
|
|
20421
20306
|
"use strict";
|
|
20422
20307
|
init_session_opening_materials();
|
|
20423
|
-
AUDITOR_SOUL_ROLES = [
|
|
20424
|
-
"judge",
|
|
20425
|
-
"reviewer",
|
|
20426
|
-
"doctor"
|
|
20427
|
-
];
|
|
20428
20308
|
}
|
|
20429
20309
|
});
|
|
20430
20310
|
|
|
@@ -20443,7 +20323,6 @@ var init_engine_detour_tool = __esm({
|
|
|
20443
20323
|
"use strict";
|
|
20444
20324
|
init_build();
|
|
20445
20325
|
init_engine_detour();
|
|
20446
|
-
init_engine_labor_fallback();
|
|
20447
20326
|
engineDetourArgsSchema = typebox_exports.Object(
|
|
20448
20327
|
{
|
|
20449
20328
|
argv: typebox_exports.Array(typebox_exports.String({ minLength: 1 }), {
|
|
@@ -20519,21 +20398,44 @@ function readListField(value) {
|
|
|
20519
20398
|
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
20520
20399
|
}
|
|
20521
20400
|
function readComplianceCandidate(arguments_, usage) {
|
|
20522
|
-
if (typeof arguments_ !== "object" || arguments_ === null || Array.isArray(arguments_))
|
|
20401
|
+
if (typeof arguments_ !== "object" || arguments_ === null || Array.isArray(arguments_)) {
|
|
20402
|
+
throw new ComplianceCandidateUnreadableError(
|
|
20403
|
+
{ kind: "non-object-arguments", type: arguments_ === null ? "null" : Array.isArray(arguments_) ? "array" : typeof arguments_ },
|
|
20404
|
+
arguments_,
|
|
20405
|
+
usage
|
|
20406
|
+
);
|
|
20407
|
+
}
|
|
20523
20408
|
const args = arguments_;
|
|
20524
20409
|
const status = args.status;
|
|
20525
20410
|
if (status === "pass") return { status, ...usage === void 0 ? {} : { usage } };
|
|
20526
20411
|
if (status === "revise") return { status, violations: readListField(args.violations), ...usage === void 0 ? {} : { usage } };
|
|
20527
20412
|
if (status === "escalate") return { status, ...Object.hasOwn(args, "conflicts") ? { conflicts: args.conflicts } : {}, ...Object.hasOwn(args, "decisionGate") ? { decisionGate: args.decisionGate } : {}, ...usage === void 0 ? {} : { usage } };
|
|
20528
|
-
|
|
20413
|
+
throw new ComplianceCandidateUnreadableError(
|
|
20414
|
+
{ kind: "object-status-unreadable", status: status === void 0 ? "missing" : "unknown" },
|
|
20415
|
+
arguments_,
|
|
20416
|
+
usage
|
|
20417
|
+
);
|
|
20529
20418
|
}
|
|
20530
|
-
var nonblank2, decisionGateSchema, complianceDecisionSchema, COMPLIANCE_RESPONSE_ENTRY_TYPE, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
|
|
20419
|
+
var ComplianceCandidateUnreadableError, nonblank2, decisionGateSchema, complianceDecisionSchema, COMPLIANCE_RESPONSE_ENTRY_TYPE, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
|
|
20531
20420
|
var init_compliance_transport = __esm({
|
|
20532
20421
|
"src/compliance-transport.ts"() {
|
|
20533
20422
|
"use strict";
|
|
20534
20423
|
init_build();
|
|
20535
20424
|
init_evidence_child_executor();
|
|
20536
20425
|
init_auditor_dossier_tool();
|
|
20426
|
+
ComplianceCandidateUnreadableError = class extends Error {
|
|
20427
|
+
observation;
|
|
20428
|
+
candidate;
|
|
20429
|
+
usage;
|
|
20430
|
+
constructor(observation, candidate, usage) {
|
|
20431
|
+
const detail = observation.kind === "non-object-arguments" ? `${observation.kind}:${observation.type}` : observation.kind === "object-status-unreadable" ? `${observation.kind}:${observation.status}` : observation.kind === "missing-subject" ? `${observation.kind}:${observation.subject}` : observation.kind;
|
|
20432
|
+
super(`Compliance candidate unreadable: ${detail}`);
|
|
20433
|
+
this.name = "ComplianceCandidateUnreadableError";
|
|
20434
|
+
this.observation = observation;
|
|
20435
|
+
this.candidate = candidate;
|
|
20436
|
+
if (usage !== void 0) this.usage = usage;
|
|
20437
|
+
}
|
|
20438
|
+
};
|
|
20537
20439
|
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
20538
20440
|
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
20539
20441
|
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: [] });
|
|
@@ -20663,11 +20565,16 @@ var init_work_subject_identity = __esm({
|
|
|
20663
20565
|
});
|
|
20664
20566
|
|
|
20665
20567
|
// src/navigator-invocation-identity.ts
|
|
20666
|
-
function
|
|
20568
|
+
function buildNavigatorInfrastructureFailureFact() {
|
|
20569
|
+
return {
|
|
20570
|
+
kind: NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND,
|
|
20571
|
+
source: "shared-role-lifecycle",
|
|
20572
|
+
reasonCode: "host_failure"
|
|
20573
|
+
};
|
|
20574
|
+
}
|
|
20575
|
+
function hasNavigatorInfrastructureFailureBase(value) {
|
|
20667
20576
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
20668
20577
|
const record4 = value;
|
|
20669
|
-
const keys = Object.keys(record4);
|
|
20670
|
-
if (keys.length !== NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS.length) return false;
|
|
20671
20578
|
for (const key of NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS) {
|
|
20672
20579
|
if (!Object.hasOwn(record4, key)) return false;
|
|
20673
20580
|
}
|
|
@@ -20698,7 +20605,8 @@ function parseInvocationMarkerIdentity(data) {
|
|
|
20698
20605
|
function classifyPackagedRoleTerminalResult(message) {
|
|
20699
20606
|
if (typeof message.toolName !== "string") return { kind: "nonterminal" };
|
|
20700
20607
|
if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName)) return { kind: "nonterminal" };
|
|
20701
|
-
const
|
|
20608
|
+
const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
|
|
20609
|
+
const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
|
|
20702
20610
|
if (message.isError === true) {
|
|
20703
20611
|
if (infraFact === void 0) return { kind: "nonterminal" };
|
|
20704
20612
|
return { kind: "infrastructure", fact: infraFact };
|
|
@@ -20805,8 +20713,7 @@ var init_navigator_invocation_identity = __esm({
|
|
|
20805
20713
|
|
|
20806
20714
|
// src/public-cli/settlement.ts
|
|
20807
20715
|
import { randomUUID } from "node:crypto";
|
|
20808
|
-
import {
|
|
20809
|
-
import { appendFile, lstat as lstat4, mkdir as mkdir3, open as open2, readFile as readFile10, readdir as readdir4, writeFile as writeFile5 } from "node:fs/promises";
|
|
20716
|
+
import { appendFile, readFile as readFile10, readdir as readdir4, writeFile as writeFile5 } from "node:fs/promises";
|
|
20810
20717
|
import { dirname as dirname7, join as join13 } from "node:path";
|
|
20811
20718
|
function isChildDiagnosticFloodLine(line2) {
|
|
20812
20719
|
if (/^at\s+/.test(line2)) return true;
|
|
@@ -21110,7 +21017,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
21110
21017
|
}
|
|
21111
21018
|
return void 0;
|
|
21112
21019
|
}
|
|
21113
|
-
async function
|
|
21020
|
+
async function loadBoundAuditorVolumes(sessionFile) {
|
|
21114
21021
|
let parentEntries;
|
|
21115
21022
|
try {
|
|
21116
21023
|
parentEntries = await readBoundSessionEntries(sessionFile);
|
|
@@ -21147,7 +21054,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
21147
21054
|
if (isMissingPathError2(error)) return void 0;
|
|
21148
21055
|
throw sessionReadFailure(error, "failed to read bound auditor session directory");
|
|
21149
21056
|
}
|
|
21150
|
-
const
|
|
21057
|
+
const valid = [];
|
|
21151
21058
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
21152
21059
|
let entries;
|
|
21153
21060
|
try {
|
|
@@ -21162,9 +21069,17 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
21162
21069
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
21163
21070
|
const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
|
|
21164
21071
|
if (bindingParent?.sessionId !== parentId || bindingParent.sessionFile !== sessionFile || attemptEntryIndex < latestParentUserIndex) continue;
|
|
21165
|
-
|
|
21072
|
+
valid.push({
|
|
21073
|
+
entries,
|
|
21074
|
+
parentId,
|
|
21075
|
+
sessionFile,
|
|
21076
|
+
...attemptEntryId === void 0 ? {} : { attemptEntryId }
|
|
21077
|
+
});
|
|
21166
21078
|
}
|
|
21167
|
-
|
|
21079
|
+
return valid;
|
|
21080
|
+
}
|
|
21081
|
+
function complianceFailureFromAuditorVolumes(volumes) {
|
|
21082
|
+
for (const { entries, attemptEntryId, parentId, sessionFile } of volumes) {
|
|
21168
21083
|
const stop = extractSessionProviderStop(entries);
|
|
21169
21084
|
if (stop === void 0) continue;
|
|
21170
21085
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
@@ -21185,7 +21100,10 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
21185
21100
|
};
|
|
21186
21101
|
}
|
|
21187
21102
|
}
|
|
21188
|
-
|
|
21103
|
+
return void 0;
|
|
21104
|
+
}
|
|
21105
|
+
function providerStopFallbackFromAuditorVolumes(volumes) {
|
|
21106
|
+
for (const { entries } of volumes) {
|
|
21189
21107
|
const stop = extractSessionProviderStop(entries);
|
|
21190
21108
|
if (stop === void 0) continue;
|
|
21191
21109
|
const primary = knownFailureFromProviderStop(stop);
|
|
@@ -21199,6 +21117,16 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
21199
21117
|
}
|
|
21200
21118
|
return void 0;
|
|
21201
21119
|
}
|
|
21120
|
+
async function readBoundAuditorComplianceFailure(sessionFile) {
|
|
21121
|
+
const volumes = await loadBoundAuditorVolumes(sessionFile);
|
|
21122
|
+
if (volumes === void 0) return void 0;
|
|
21123
|
+
return complianceFailureFromAuditorVolumes(volumes);
|
|
21124
|
+
}
|
|
21125
|
+
async function readBoundAuditorProviderStopFallback(sessionFile) {
|
|
21126
|
+
const volumes = await loadBoundAuditorVolumes(sessionFile);
|
|
21127
|
+
if (volumes === void 0) return void 0;
|
|
21128
|
+
return providerStopFallbackFromAuditorVolumes(volumes);
|
|
21129
|
+
}
|
|
21202
21130
|
function typedFailedTerminatingToolKnownFailure(entries) {
|
|
21203
21131
|
let attemptStart = 0;
|
|
21204
21132
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
@@ -21217,11 +21145,12 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
21217
21145
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
21218
21146
|
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord8(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
21219
21147
|
const diagnostic = isRecord8(textPart) ? textPart.text : void 0;
|
|
21148
|
+
const details = isRecord8(message.details) ? message.details : classification.fact;
|
|
21220
21149
|
return {
|
|
21221
21150
|
cause: "output",
|
|
21222
21151
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
21223
21152
|
...typeof diagnostic === "string" && diagnostic.trim() !== "" ? { diagnostic } : {},
|
|
21224
|
-
details
|
|
21153
|
+
details
|
|
21225
21154
|
};
|
|
21226
21155
|
}
|
|
21227
21156
|
return void 0;
|
|
@@ -21249,8 +21178,8 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
21249
21178
|
}
|
|
21250
21179
|
}
|
|
21251
21180
|
try {
|
|
21252
|
-
const
|
|
21253
|
-
if (
|
|
21181
|
+
const auditorCompliance = await readBoundAuditorComplianceFailure(input.sessionFile);
|
|
21182
|
+
if (auditorCompliance !== void 0) return resolutionOf(auditorCompliance);
|
|
21254
21183
|
} catch (error) {
|
|
21255
21184
|
const failure = sessionReadFailure(error, "failed to recover bound auditor failure");
|
|
21256
21185
|
return resolutionOf({
|
|
@@ -21274,6 +21203,17 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
21274
21203
|
});
|
|
21275
21204
|
}
|
|
21276
21205
|
}
|
|
21206
|
+
try {
|
|
21207
|
+
const auditorStop = await readBoundAuditorProviderStopFallback(input.sessionFile);
|
|
21208
|
+
if (auditorStop !== void 0) return resolutionOf(auditorStop);
|
|
21209
|
+
} catch (error) {
|
|
21210
|
+
const failure = sessionReadFailure(error, "failed to recover bound auditor provider stop");
|
|
21211
|
+
return resolutionOf({
|
|
21212
|
+
cause: "session",
|
|
21213
|
+
identity: thrownIdentity(failure),
|
|
21214
|
+
diagnostic: failure.message || failure.name
|
|
21215
|
+
});
|
|
21216
|
+
}
|
|
21277
21217
|
try {
|
|
21278
21218
|
const evidenceChildFailure = await readBoundEvidenceChildKnownFailure(input.sessionFile);
|
|
21279
21219
|
if (evidenceChildFailure !== void 0) return resolutionOf(evidenceChildFailure);
|
|
@@ -21388,11 +21328,9 @@ function auditNoReceiptDecisiveFact(candidate) {
|
|
|
21388
21328
|
function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
21389
21329
|
const facts = {
|
|
21390
21330
|
judgeStatus,
|
|
21391
|
-
...auditNoReceiptDecisiveFact(verdict)
|
|
21392
|
-
// #380: spread sole-built field; do not re-key here (S1).
|
|
21393
|
-
...readEngineLaborFallbackFieldFrom(verdict)
|
|
21331
|
+
...auditNoReceiptDecisiveFact(verdict)
|
|
21394
21332
|
};
|
|
21395
|
-
const statusBase =
|
|
21333
|
+
const statusBase = judgeStatus;
|
|
21396
21334
|
if (statusBase === "continue") {
|
|
21397
21335
|
const fix = safelyRead(verdict, "fix");
|
|
21398
21336
|
if (fix.readable && isRecord8(fix.value)) {
|
|
@@ -21442,7 +21380,7 @@ function coderDecisiveFacts(output) {
|
|
|
21442
21380
|
const status = safelyRead(candidate, "status");
|
|
21443
21381
|
const facts = {};
|
|
21444
21382
|
if (status.readable && typeof status.value === "string") facts.coderStatus = status.value;
|
|
21445
|
-
const statusBase = status.readable && typeof status.value === "string" ?
|
|
21383
|
+
const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
|
|
21446
21384
|
const remainingScope = safelyRead(candidate, "remainingScope");
|
|
21447
21385
|
if (statusBase === "unfinished" && remainingScope.readable && typeof remainingScope.value === "string") facts.remainingScope = remainingScope.value;
|
|
21448
21386
|
const reason = safelyRead(candidate, "reason");
|
|
@@ -21458,7 +21396,7 @@ function fixerDecisiveFacts(output) {
|
|
|
21458
21396
|
const status = safelyRead(candidate, "status");
|
|
21459
21397
|
const facts = {};
|
|
21460
21398
|
if (status.readable && typeof status.value === "string") facts.fixerStatus = status.value;
|
|
21461
|
-
const statusBase = status.readable && typeof status.value === "string" ?
|
|
21399
|
+
const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
|
|
21462
21400
|
const remainingScope = safelyRead(candidate, "remainingScope");
|
|
21463
21401
|
if ((statusBase === "unfinished" || statusBase === "refused") && remainingScope.readable && typeof remainingScope.value === "string") facts.remainingScope = remainingScope.value;
|
|
21464
21402
|
const reason = safelyRead(candidate, "reason");
|
|
@@ -21542,7 +21480,7 @@ function doctorDecisiveFacts(output) {
|
|
|
21542
21480
|
const status = safelyRead(candidate, "status");
|
|
21543
21481
|
const facts = { ...auditNoReceiptDecisiveFact(candidate) };
|
|
21544
21482
|
if (status.readable && typeof status.value === "string") facts.doctorStatus = status.value;
|
|
21545
|
-
const statusBase = status.readable && typeof status.value === "string" ?
|
|
21483
|
+
const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
|
|
21546
21484
|
if (statusBase === "refused") {
|
|
21547
21485
|
const reason = safelyRead(candidate, "reason");
|
|
21548
21486
|
if (reason.readable && reason.value !== void 0) facts.reason = reason.value;
|
|
@@ -21584,16 +21522,14 @@ function reviewerDecisiveFacts(output) {
|
|
|
21584
21522
|
reportAxes,
|
|
21585
21523
|
amendmentAxes,
|
|
21586
21524
|
acceptedBatchPresent: acceptedBatch.readable && acceptedBatch.value !== void 0,
|
|
21587
|
-
...auditNoReceiptDecisiveFact(candidate)
|
|
21588
|
-
// #380: spread sole-built field; do not re-key here (S1).
|
|
21589
|
-
...readEngineLaborFallbackFieldFrom(candidate)
|
|
21525
|
+
...auditNoReceiptDecisiveFact(candidate)
|
|
21590
21526
|
};
|
|
21591
21527
|
if (status.readable && typeof status.value === "string") facts.reviewerStatus = status.value;
|
|
21592
21528
|
if (specDisposition.readable && (specDisposition.value === "launched" || specDisposition.value === "skipped-missing")) {
|
|
21593
21529
|
facts.specDisposition = specDisposition.value;
|
|
21594
21530
|
}
|
|
21595
21531
|
const diagnostic = safelyRead(candidate, "diagnostic");
|
|
21596
|
-
const statusBase = status.readable && typeof status.value === "string" ?
|
|
21532
|
+
const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
|
|
21597
21533
|
if (statusBase === "refused" && diagnostic.readable) {
|
|
21598
21534
|
facts.diagnosticPresent = typeof diagnostic.value === "string" && diagnostic.value.trim().length > 0;
|
|
21599
21535
|
}
|
|
@@ -21679,29 +21615,6 @@ function assertCollectorReceiptMatchesAdmitted(receipt, admitted) {
|
|
|
21679
21615
|
);
|
|
21680
21616
|
}
|
|
21681
21617
|
}
|
|
21682
|
-
function isComplianceAuditIncomplete(value) {
|
|
21683
|
-
if (!isRecord8(value) || value.status !== "audit-incomplete") return false;
|
|
21684
|
-
const observation = value.observation;
|
|
21685
|
-
if (!isRecord8(observation)) return false;
|
|
21686
|
-
if (observation.kind === "missing-dossier") return true;
|
|
21687
|
-
if (observation.kind === "missing-subject") {
|
|
21688
|
-
return typeof observation.subject === "string" && observation.subject.length > 0;
|
|
21689
|
-
}
|
|
21690
|
-
if (observation.kind === "object-status-unreadable") {
|
|
21691
|
-
return observation.status === "missing" || observation.status === "unknown";
|
|
21692
|
-
}
|
|
21693
|
-
return observation.kind === "non-object-arguments" && [
|
|
21694
|
-
"null",
|
|
21695
|
-
"array",
|
|
21696
|
-
"undefined",
|
|
21697
|
-
"string",
|
|
21698
|
-
"number",
|
|
21699
|
-
"boolean",
|
|
21700
|
-
"bigint",
|
|
21701
|
-
"symbol",
|
|
21702
|
-
"function"
|
|
21703
|
-
].includes(observation.type);
|
|
21704
|
-
}
|
|
21705
21618
|
function auditToolNameForRole(role) {
|
|
21706
21619
|
switch (role) {
|
|
21707
21620
|
case "judge":
|
|
@@ -21712,16 +21625,6 @@ function auditToolNameForRole(role) {
|
|
|
21712
21625
|
return DOCTOR_AUDIT_TOOL_NAME;
|
|
21713
21626
|
}
|
|
21714
21627
|
}
|
|
21715
|
-
function outputToolNameForAuditedRole(role) {
|
|
21716
|
-
switch (role) {
|
|
21717
|
-
case "judge":
|
|
21718
|
-
return JUDGE_OUTPUT_TOOL_NAME;
|
|
21719
|
-
case "reviewer":
|
|
21720
|
-
return REVIEWER_OUTPUT_TOOL_NAME;
|
|
21721
|
-
case "doctor":
|
|
21722
|
-
return DOCTOR_OUTPUT_TOOL_NAME;
|
|
21723
|
-
}
|
|
21724
|
-
}
|
|
21725
21628
|
function boundRoleToolCallForResult(entries, resultIndex, message, outputToolName) {
|
|
21726
21629
|
const callId = message.toolCallId;
|
|
21727
21630
|
if (typeof callId !== "string" || callId.trim() === "") return void 0;
|
|
@@ -21816,10 +21719,6 @@ function isUnboundAuditEscalationFace(details) {
|
|
|
21816
21719
|
const kind = safelyRead(details, "kind");
|
|
21817
21720
|
return kind.readable && kind.value === "audit_escalation";
|
|
21818
21721
|
}
|
|
21819
|
-
function auditIncompleteFromCandidate(candidate) {
|
|
21820
|
-
const decision = readComplianceCandidate(candidate);
|
|
21821
|
-
return decision.status === "audit-incomplete" ? decision : void 0;
|
|
21822
|
-
}
|
|
21823
21722
|
function boundRetainedAuditResponse(entries, callIndex, resultIndex, auditToolName) {
|
|
21824
21723
|
const matches = [];
|
|
21825
21724
|
for (let index = callIndex + 1; index < resultIndex; index += 1) {
|
|
@@ -21838,92 +21737,6 @@ function boundRetainedAuditResponse(entries, callIndex, resultIndex, auditToolNa
|
|
|
21838
21737
|
}
|
|
21839
21738
|
return matches.length === 1 ? matches[0] : void 0;
|
|
21840
21739
|
}
|
|
21841
|
-
function extractComplianceAuditIncompleteRoleOutcome(entries, role, outputToolName) {
|
|
21842
|
-
if (outputToolName !== outputToolNameForAuditedRole(role)) return void 0;
|
|
21843
|
-
const auditToolName = auditToolNameForRole(role);
|
|
21844
|
-
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
21845
|
-
const message = entries[index]?.message;
|
|
21846
|
-
if (entries[index]?.type !== "message" || message?.role !== "toolResult" || message.toolName !== outputToolName || message.isError === true || !isComplianceAuditIncomplete(message.details)) {
|
|
21847
|
-
continue;
|
|
21848
|
-
}
|
|
21849
|
-
const roleCall = boundRoleToolCallForResult(
|
|
21850
|
-
entries,
|
|
21851
|
-
index,
|
|
21852
|
-
message,
|
|
21853
|
-
outputToolName
|
|
21854
|
-
);
|
|
21855
|
-
if (roleCall === void 0) continue;
|
|
21856
|
-
const details = message.details;
|
|
21857
|
-
if (details.observation.kind === "missing-dossier" || details.observation.kind === "missing-subject") {
|
|
21858
|
-
return {
|
|
21859
|
-
outcome: buildAuditIncompleteTerminalOutcome({
|
|
21860
|
-
role,
|
|
21861
|
-
roleCandidate: roleCall.candidate,
|
|
21862
|
-
audit: details
|
|
21863
|
-
})
|
|
21864
|
-
};
|
|
21865
|
-
}
|
|
21866
|
-
const retained = boundRetainedAuditResponse(
|
|
21867
|
-
entries,
|
|
21868
|
-
roleCall.callIndex,
|
|
21869
|
-
index,
|
|
21870
|
-
auditToolName
|
|
21871
|
-
);
|
|
21872
|
-
if (retained === void 0) continue;
|
|
21873
|
-
const audit = auditIncompleteFromCandidate(retained.candidate);
|
|
21874
|
-
if (audit === void 0) continue;
|
|
21875
|
-
return {
|
|
21876
|
-
outcome: buildAuditIncompleteTerminalOutcome({
|
|
21877
|
-
role,
|
|
21878
|
-
roleCandidate: roleCall.candidate,
|
|
21879
|
-
audit
|
|
21880
|
-
})
|
|
21881
|
-
};
|
|
21882
|
-
}
|
|
21883
|
-
return void 0;
|
|
21884
|
-
}
|
|
21885
|
-
function auditArtifactPublicationError(message, code) {
|
|
21886
|
-
const error = new Error(message);
|
|
21887
|
-
error.name = "ArtifactPublicationError";
|
|
21888
|
-
error.code = code;
|
|
21889
|
-
return error;
|
|
21890
|
-
}
|
|
21891
|
-
async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
21892
|
-
const artifactsDir = join13(runDirectory, "artifacts");
|
|
21893
|
-
const runStat = await lstat4(runDirectory);
|
|
21894
|
-
if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
|
|
21895
|
-
throw auditArtifactPublicationError(
|
|
21896
|
-
"audit evidence run directory is not a real directory",
|
|
21897
|
-
"ELOOP"
|
|
21898
|
-
);
|
|
21899
|
-
}
|
|
21900
|
-
try {
|
|
21901
|
-
const existing = await lstat4(artifactsDir);
|
|
21902
|
-
if (existing.isSymbolicLink()) {
|
|
21903
|
-
throw auditArtifactPublicationError(
|
|
21904
|
-
"audit evidence artifacts directory is a symlink",
|
|
21905
|
-
"ELOOP"
|
|
21906
|
-
);
|
|
21907
|
-
}
|
|
21908
|
-
if (!existing.isDirectory()) {
|
|
21909
|
-
throw auditArtifactPublicationError(
|
|
21910
|
-
"audit evidence artifacts path is not a directory",
|
|
21911
|
-
"EEXIST"
|
|
21912
|
-
);
|
|
21913
|
-
}
|
|
21914
|
-
} catch (error) {
|
|
21915
|
-
if (!isMissingPathError2(error)) throw error;
|
|
21916
|
-
await mkdir3(artifactsDir, { recursive: true });
|
|
21917
|
-
const created = await lstat4(artifactsDir);
|
|
21918
|
-
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
21919
|
-
throw auditArtifactPublicationError(
|
|
21920
|
-
"audit evidence artifacts directory is not a real directory",
|
|
21921
|
-
"ELOOP"
|
|
21922
|
-
);
|
|
21923
|
-
}
|
|
21924
|
-
}
|
|
21925
|
-
return artifactsDir;
|
|
21926
|
-
}
|
|
21927
21740
|
async function appendRunAttemptHistory(admitted, outcome) {
|
|
21928
21741
|
const entries = await readBoundSessionEntries(admitted.sessionFile);
|
|
21929
21742
|
let parentId = null;
|
|
@@ -21952,119 +21765,6 @@ async function appendRunAttemptHistory(admitted, outcome) {
|
|
|
21952
21765
|
`;
|
|
21953
21766
|
await appendFile(admitted.sessionFile, line2, "utf8");
|
|
21954
21767
|
}
|
|
21955
|
-
async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
21956
|
-
await appendRunAttemptHistory(admitted, outcome);
|
|
21957
|
-
if (typeof fsConstants.O_NOFOLLOW !== "number" || typeof fsConstants.O_NONBLOCK !== "number") {
|
|
21958
|
-
throw auditArtifactPublicationError(
|
|
21959
|
-
"audit evidence publication requires O_NOFOLLOW|O_NONBLOCK open-flag support (anti-symlink/anti-planted protection must not be silently dropped); refusing to publish",
|
|
21960
|
-
"ENOSYS"
|
|
21961
|
-
);
|
|
21962
|
-
}
|
|
21963
|
-
const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
|
|
21964
|
-
const evidencePath = join13(artifactsDir, "audit-incomplete.json");
|
|
21965
|
-
let existing;
|
|
21966
|
-
try {
|
|
21967
|
-
existing = await lstat4(evidencePath);
|
|
21968
|
-
} catch (error) {
|
|
21969
|
-
if (!isMissingPathError2(error)) throw error;
|
|
21970
|
-
}
|
|
21971
|
-
if (existing?.isSymbolicLink()) {
|
|
21972
|
-
throw auditArtifactPublicationError(
|
|
21973
|
-
"audit evidence destination is a symlink",
|
|
21974
|
-
"ELOOP"
|
|
21975
|
-
);
|
|
21976
|
-
}
|
|
21977
|
-
if (existing && !existing.isFile()) {
|
|
21978
|
-
throw auditArtifactPublicationError(
|
|
21979
|
-
"audit evidence destination is not a regular file",
|
|
21980
|
-
"EEXIST"
|
|
21981
|
-
);
|
|
21982
|
-
}
|
|
21983
|
-
const handle = await open2(
|
|
21984
|
-
evidencePath,
|
|
21985
|
-
fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_TRUNC | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK,
|
|
21986
|
-
384
|
|
21987
|
-
);
|
|
21988
|
-
try {
|
|
21989
|
-
if (!(await handle.stat()).isFile()) {
|
|
21990
|
-
throw auditArtifactPublicationError(
|
|
21991
|
-
"audit evidence destination is not a regular file",
|
|
21992
|
-
"EEXIST"
|
|
21993
|
-
);
|
|
21994
|
-
}
|
|
21995
|
-
await handle.writeFile(`${JSON.stringify(outcome, null, 2)}
|
|
21996
|
-
`, "utf8");
|
|
21997
|
-
await handle.sync();
|
|
21998
|
-
} finally {
|
|
21999
|
-
await handle.close();
|
|
22000
|
-
}
|
|
22001
|
-
return { kind: "evidence", path: evidencePath };
|
|
22002
|
-
}
|
|
22003
|
-
function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
|
|
22004
|
-
const attempt = publicationAttemptFromError(
|
|
22005
|
-
join13(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
|
|
22006
|
-
error
|
|
22007
|
-
);
|
|
22008
|
-
const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
|
|
22009
|
-
const decisiveFacts = {
|
|
22010
|
-
...outcome.decisiveFacts,
|
|
22011
|
-
cause: "unrecognized",
|
|
22012
|
-
diagnostic,
|
|
22013
|
-
publicationFailure: attempt
|
|
22014
|
-
};
|
|
22015
|
-
if (attempt.identity?.name !== void 0) decisiveFacts.errorName = attempt.identity.name;
|
|
22016
|
-
if (attempt.identity?.code !== void 0) decisiveFacts.errorCode = attempt.identity.code;
|
|
22017
|
-
const auditResidual = {
|
|
22018
|
-
roleCandidate: outcome.roleCandidate,
|
|
22019
|
-
audit: outcome.audit,
|
|
22020
|
-
acceptedReceipt: false
|
|
22021
|
-
};
|
|
22022
|
-
return {
|
|
22023
|
-
roleOutcome: {
|
|
22024
|
-
kind: "failure",
|
|
22025
|
-
role: admitted.role,
|
|
22026
|
-
cause: "unrecognized",
|
|
22027
|
-
diagnostic,
|
|
22028
|
-
decisiveFacts,
|
|
22029
|
-
auditResidual
|
|
22030
|
-
},
|
|
22031
|
-
navigator: extractNavigatorFact(entries),
|
|
22032
|
-
artifacts: [],
|
|
22033
|
-
runId: admitted.runId
|
|
22034
|
-
};
|
|
22035
|
-
}
|
|
22036
|
-
async function trySettleComplianceAuditIncompleteTerminalResult(admitted) {
|
|
22037
|
-
if (!AUDITOR_SOUL_ROLES.includes(admitted.role)) {
|
|
22038
|
-
return void 0;
|
|
22039
|
-
}
|
|
22040
|
-
const outputToolName = admitted.role === "judge" ? JUDGE_OUTPUT_TOOL_NAME : admitted.role === "reviewer" ? REVIEWER_OUTPUT_TOOL_NAME : DOCTOR_OUTPUT_TOOL_NAME;
|
|
22041
|
-
const entries = await readLawfulSettlementEntries(admitted);
|
|
22042
|
-
if (entries === void 0) return void 0;
|
|
22043
|
-
const extracted = extractComplianceAuditIncompleteRoleOutcome(
|
|
22044
|
-
entries,
|
|
22045
|
-
admitted.role,
|
|
22046
|
-
outputToolName
|
|
22047
|
-
);
|
|
22048
|
-
if (extracted === void 0) return void 0;
|
|
22049
|
-
let evidence;
|
|
22050
|
-
try {
|
|
22051
|
-
evidence = await publishComplianceAuditIncompleteEvidence(
|
|
22052
|
-
admitted,
|
|
22053
|
-
extracted.outcome
|
|
22054
|
-
);
|
|
22055
|
-
} catch (error) {
|
|
22056
|
-
return auditPublicationFailureTerminal(admitted, entries, extracted.outcome, error);
|
|
22057
|
-
}
|
|
22058
|
-
return withOptionalMenxiaProjection(
|
|
22059
|
-
{
|
|
22060
|
-
roleOutcome: extracted.outcome,
|
|
22061
|
-
navigator: extractNavigatorFact(entries),
|
|
22062
|
-
artifacts: [evidence],
|
|
22063
|
-
runId: admitted.runId
|
|
22064
|
-
},
|
|
22065
|
-
admitted.sessionDirectory
|
|
22066
|
-
);
|
|
22067
|
-
}
|
|
22068
21768
|
function extractJudgeRoleOutcome(entries) {
|
|
22069
21769
|
if (!isReceiptSettlementBindingClear(entries)) return void 0;
|
|
22070
21770
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
@@ -22095,9 +21795,8 @@ function extractJudgeRoleOutcome(entries) {
|
|
|
22095
21795
|
const statusRead = safelyRead(details, "judgeStatus");
|
|
22096
21796
|
if (!statusRead.readable || typeof statusRead.value !== "string") continue;
|
|
22097
21797
|
const judgeStatus = statusRead.value;
|
|
22098
|
-
const statusBase =
|
|
21798
|
+
const statusBase = judgeStatus;
|
|
22099
21799
|
if (statusBase !== "converged" && statusBase !== "continue" && statusBase !== "escalate") continue;
|
|
22100
|
-
if (!seatFallbackStatusHasLawfulEvidence(judgeStatus, details)) continue;
|
|
22101
21800
|
return {
|
|
22102
21801
|
kind: "accepted",
|
|
22103
21802
|
role: "judge",
|
|
@@ -22196,6 +21895,8 @@ async function extractMenxiaFactFromSessionDirectory(sessionDirectory) {
|
|
|
22196
21895
|
return projectTerminalMenxiaFact(rounds);
|
|
22197
21896
|
}
|
|
22198
21897
|
async function withOptionalMenxiaProjection(base, sessionDirectory) {
|
|
21898
|
+
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
21899
|
+
if (isRecord8(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
|
|
22199
21900
|
const menxia = await extractMenxiaFactFromSessionDirectory(sessionDirectory);
|
|
22200
21901
|
return menxia === void 0 ? base : { ...base, menxia };
|
|
22201
21902
|
}
|
|
@@ -22839,7 +22540,7 @@ async function settleLawfulDoctorTerminalResult(admitted) {
|
|
|
22839
22540
|
if (entries === void 0) return void 0;
|
|
22840
22541
|
const extracted = extractDoctorRoleOutcome(entries);
|
|
22841
22542
|
if (extracted === void 0) return void 0;
|
|
22842
|
-
if (extracted.output !== void 0 &&
|
|
22543
|
+
if (extracted.output !== void 0 && String(extracted.output.status) === "completed") {
|
|
22843
22544
|
const completedCase = extracted.output.case;
|
|
22844
22545
|
if (completedCase.issueNumber !== admitted.caseIdentity.issueNumber || completedCase.runsPath !== admitted.caseIdentity.runsPath) {
|
|
22845
22546
|
const error = new Error(
|
|
@@ -22909,16 +22610,11 @@ async function settleLawfulNotaryTerminalResult(admitted) {
|
|
|
22909
22610
|
NOTARY_OUTPUT_TOOL_NAME
|
|
22910
22611
|
);
|
|
22911
22612
|
if (residual === void 0) continue;
|
|
22912
|
-
return {
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
}),
|
|
22918
|
-
navigator: extractNavigatorFact(entries),
|
|
22919
|
-
artifacts: [],
|
|
22920
|
-
runId: admitted.runId
|
|
22921
|
-
};
|
|
22613
|
+
return settleFailureTerminalResult(admitted, {
|
|
22614
|
+
cause: "output",
|
|
22615
|
+
diagnostic: residual.diagnostic,
|
|
22616
|
+
details: { candidate: residual.candidate, acceptedReceipt: false }
|
|
22617
|
+
});
|
|
22922
22618
|
}
|
|
22923
22619
|
return void 0;
|
|
22924
22620
|
}
|
|
@@ -23128,7 +22824,7 @@ function mergerDecisiveFacts(output) {
|
|
|
23128
22824
|
const attemptId = safelyRead(candidate, "attemptId");
|
|
23129
22825
|
if (status.readable && typeof status.value === "string") facts.mergerStatus = status.value;
|
|
23130
22826
|
if (attemptId.readable && attemptId.value !== void 0) facts.attemptId = attemptId.value;
|
|
23131
|
-
const statusBase = status.readable && typeof status.value === "string" ?
|
|
22827
|
+
const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
|
|
23132
22828
|
const decisiveKey = statusBase === "completed" ? "mergeCommitId" : "diagnosis";
|
|
23133
22829
|
const decisive = safelyRead(candidate, decisiveKey);
|
|
23134
22830
|
if (decisive.readable && decisive.value !== void 0) facts[decisiveKey] = decisive.value;
|
|
@@ -23605,7 +23301,6 @@ var init_settlement = __esm({
|
|
|
23605
23301
|
init_compliance_transport();
|
|
23606
23302
|
init_collector_ledger();
|
|
23607
23303
|
init_engine_detour();
|
|
23608
|
-
init_engine_labor_fallback();
|
|
23609
23304
|
init_judge_output();
|
|
23610
23305
|
init_collector_output();
|
|
23611
23306
|
init_worker_output();
|
|
@@ -23640,9 +23335,9 @@ var init_settlement = __esm({
|
|
|
23640
23335
|
});
|
|
23641
23336
|
|
|
23642
23337
|
// src/public-cli/auto-resume.ts
|
|
23643
|
-
import { constants as
|
|
23338
|
+
import { constants as fsConstants } from "node:fs";
|
|
23644
23339
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
23645
|
-
import { appendFile as appendFile2, lstat as lstat5, mkdir as mkdir4, open as
|
|
23340
|
+
import { appendFile as appendFile2, lstat as lstat5, mkdir as mkdir4, open as open2, readFile as readFile11 } from "node:fs/promises";
|
|
23646
23341
|
import { join as join14 } from "node:path";
|
|
23647
23342
|
function presentTerminal(terminal, io) {
|
|
23648
23343
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
@@ -23760,10 +23455,10 @@ async function retainDispatchError(admitted, attempt, error) {
|
|
|
23760
23455
|
2
|
|
23761
23456
|
)}
|
|
23762
23457
|
`;
|
|
23763
|
-
const noFollowFlag = typeof
|
|
23764
|
-
const handle = await
|
|
23458
|
+
const noFollowFlag = typeof fsConstants.O_NOFOLLOW === "number" ? fsConstants.O_NOFOLLOW : 0;
|
|
23459
|
+
const handle = await open2(
|
|
23765
23460
|
filePath,
|
|
23766
|
-
|
|
23461
|
+
fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL | noFollowFlag,
|
|
23767
23462
|
384
|
|
23768
23463
|
);
|
|
23769
23464
|
try {
|
|
@@ -24826,8 +24521,7 @@ async function runPublicDoctor(argv, env, io, parseDoctorArgv2) {
|
|
|
24826
24521
|
extraArgs,
|
|
24827
24522
|
adapters: {
|
|
24828
24523
|
trySettle: trySettleDoctorTerminalResult,
|
|
24829
|
-
shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
|
|
24830
|
-
trySettleSecondary: trySettleComplianceAuditIncompleteTerminalResult
|
|
24524
|
+
shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
|
|
24831
24525
|
},
|
|
24832
24526
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
24833
24527
|
});
|
|
@@ -25055,20 +24749,6 @@ async function dispatchAdmittedFixer(input) {
|
|
|
25055
24749
|
terminal: lawful
|
|
25056
24750
|
};
|
|
25057
24751
|
}
|
|
25058
|
-
const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
|
|
25059
|
-
if (auditIncomplete !== void 0) {
|
|
25060
|
-
await markRunTerminal(admitted.runDirectory).catch(() => void 0);
|
|
25061
|
-
if (auditIncomplete.roleOutcome.kind === "failure") {
|
|
25062
|
-
presentFailureTerminal(auditIncomplete, io);
|
|
25063
|
-
} else {
|
|
25064
|
-
io.stdout(formatTerminalResult(auditIncomplete));
|
|
25065
|
-
}
|
|
25066
|
-
return {
|
|
25067
|
-
exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
|
|
25068
|
-
admitted,
|
|
25069
|
-
terminal: auditIncomplete
|
|
25070
|
-
};
|
|
25071
|
-
}
|
|
25072
24752
|
const credentialFailure = postRunMissingCredentialFailure(
|
|
25073
24753
|
result2,
|
|
25074
24754
|
env.model,
|
|
@@ -25299,7 +24979,7 @@ async function runPublicNotary(argv, env, io, parseNotaryArgv2) {
|
|
|
25299
24979
|
extraArgs,
|
|
25300
24980
|
adapters: {
|
|
25301
24981
|
trySettle: trySettleNotaryTerminalResult,
|
|
25302
|
-
// Accepted receipts and
|
|
24982
|
+
// Accepted receipts and failure terminals both present via shared path.
|
|
25303
24983
|
shouldPresentSettled: () => true
|
|
25304
24984
|
},
|
|
25305
24985
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -25497,20 +25177,6 @@ async function dispatchAdmittedJudge(input) {
|
|
|
25497
25177
|
terminal: lawful
|
|
25498
25178
|
};
|
|
25499
25179
|
}
|
|
25500
|
-
const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
|
|
25501
|
-
if (auditIncomplete !== void 0) {
|
|
25502
|
-
await markRunTerminal(admitted.runDirectory).catch(() => void 0);
|
|
25503
|
-
if (auditIncomplete.roleOutcome.kind === "failure") {
|
|
25504
|
-
presentFailureTerminal(auditIncomplete, io);
|
|
25505
|
-
} else {
|
|
25506
|
-
io.stdout(formatTerminalResult(auditIncomplete));
|
|
25507
|
-
}
|
|
25508
|
-
return {
|
|
25509
|
-
exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
|
|
25510
|
-
admitted,
|
|
25511
|
-
terminal: auditIncomplete
|
|
25512
|
-
};
|
|
25513
|
-
}
|
|
25514
25180
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(
|
|
25515
25181
|
admitted.sessionFile
|
|
25516
25182
|
);
|
|
@@ -26316,20 +25982,6 @@ async function dispatchAdmittedReviewer(input) {
|
|
|
26316
25982
|
terminal: lawful
|
|
26317
25983
|
};
|
|
26318
25984
|
}
|
|
26319
|
-
const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
|
|
26320
|
-
if (auditIncomplete !== void 0) {
|
|
26321
|
-
await markRunTerminal(admitted.runDirectory).catch(() => void 0);
|
|
26322
|
-
if (auditIncomplete.roleOutcome.kind === "failure") {
|
|
26323
|
-
presentFailureTerminal(auditIncomplete, io);
|
|
26324
|
-
} else {
|
|
26325
|
-
io.stdout(formatTerminalResult(auditIncomplete));
|
|
26326
|
-
}
|
|
26327
|
-
return {
|
|
26328
|
-
exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
|
|
26329
|
-
admitted,
|
|
26330
|
-
terminal: auditIncomplete
|
|
26331
|
-
};
|
|
26332
|
-
}
|
|
26333
25985
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(
|
|
26334
25986
|
admitted.sessionFile
|
|
26335
25987
|
);
|
|
@@ -26564,7 +26216,7 @@ var init_atomic_write = __esm({
|
|
|
26564
26216
|
});
|
|
26565
26217
|
|
|
26566
26218
|
// src/analyst-index.ts
|
|
26567
|
-
import { open as
|
|
26219
|
+
import { open as open3, readFile as readFile12, unlink as unlink4 } from "node:fs/promises";
|
|
26568
26220
|
import { dirname as dirname9, join as join23 } from "node:path";
|
|
26569
26221
|
function sleep(ms) {
|
|
26570
26222
|
return new Promise((resolve9) => {
|
|
@@ -26579,7 +26231,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
26579
26231
|
const startedAt = Date.now();
|
|
26580
26232
|
while (true) {
|
|
26581
26233
|
try {
|
|
26582
|
-
const handle = await
|
|
26234
|
+
const handle = await open3(lockPath, "wx");
|
|
26583
26235
|
try {
|
|
26584
26236
|
await handle.writeFile(`${process.pid}
|
|
26585
26237
|
`, "utf8");
|
|
@@ -27424,9 +27076,8 @@ function mapTerminal(role, terminal) {
|
|
|
27424
27076
|
noReceipt: false
|
|
27425
27077
|
};
|
|
27426
27078
|
}
|
|
27427
|
-
const statusBase = seatFallbackBaseStatus(status);
|
|
27428
27079
|
const acceptedSet = ACCEPTED_STATUS[role];
|
|
27429
|
-
if (acceptedSet === void 0 || !acceptedSet.has(
|
|
27080
|
+
if (acceptedSet === void 0 || !acceptedSet.has(status)) {
|
|
27430
27081
|
return {
|
|
27431
27082
|
terminalLabel: status,
|
|
27432
27083
|
accepted: false,
|
|
@@ -27435,9 +27086,9 @@ function mapTerminal(role, terminal) {
|
|
|
27435
27086
|
noReceipt: false
|
|
27436
27087
|
};
|
|
27437
27088
|
}
|
|
27438
|
-
const plannedDuty = WORKER_ROLES.has(role) &&
|
|
27089
|
+
const plannedDuty = WORKER_ROLES.has(role) && status === "planned";
|
|
27439
27090
|
const successSet = SUCCESS_STATUS[role] ?? /* @__PURE__ */ new Set();
|
|
27440
|
-
const success = !plannedDuty && successSet.has(
|
|
27091
|
+
const success = !plannedDuty && successSet.has(status);
|
|
27441
27092
|
const successEligible = !plannedDuty;
|
|
27442
27093
|
return {
|
|
27443
27094
|
terminalLabel: status,
|
|
@@ -27559,7 +27210,6 @@ var WORKER_ROLES, ACCEPTED_STATUS, SUCCESS_STATUS, acceptanceSuccessReworkFamily
|
|
|
27559
27210
|
var init_acceptance_success_rework = __esm({
|
|
27560
27211
|
"src/analyst-metric-families/acceptance-success-rework.ts"() {
|
|
27561
27212
|
"use strict";
|
|
27562
|
-
init_engine_labor_fallback();
|
|
27563
27213
|
init_analyst_median();
|
|
27564
27214
|
WORKER_ROLES = /* @__PURE__ */ new Set(["coder", "fixer"]);
|
|
27565
27215
|
ACCEPTED_STATUS = {
|