@akagilnc/pi-workflow-roles 0.1.2135 → 0.1.2146
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/compliance-transport.js +19 -24
- package/dist/doctor-contracts.js +10 -2
- package/dist/engine-detour-tool.js +5 -15
- package/dist/engine-detour.js +3 -11
- package/dist/engine-labor-fallback.js +129 -114
- package/dist/evidence-child-executor.js +3 -4
- package/dist/merger-contracts.js +9 -2
- package/dist/navigator-attendance.js +11 -4
- package/dist/package-contracts/judge-output.js +8 -1
- package/dist/package-contracts/reviewer-output.js +9 -1
- package/dist/package-contracts/terminating-tools.js +14 -5
- package/dist/public-cli/main.js +123 -125
- package/package.json +1 -1
- package/resources/engines/codex.md +3 -4
- package/resources/engines/grok-4.6.md +5 -6
- package/resources/engines/kimi.md +2 -2
- package/resources/engines/opus.md +2 -2
- package/scripts/build-package.mjs +2 -0
- package/src/collector-role.ts +5 -33
- package/src/compliance-transport.ts +19 -24
- package/src/doctor-contracts.ts +19 -3
- package/src/engine-detour-tool.ts +6 -21
- package/src/engine-detour.ts +3 -15
- package/src/engine-labor-fallback.ts +100 -2
- package/src/evidence-child-executor.ts +3 -4
- package/src/factory-board.ts +6 -2
- package/src/merger-contracts.ts +18 -3
- package/src/navigator-attendance.ts +18 -4
- package/src/package-contracts/judge-output.ts +25 -2
- package/src/package-contracts/reviewer-output.ts +23 -2
- package/src/package-contracts/terminating-tools.ts +22 -6
- package/src/package-contracts/worker-output.ts +10 -2
- package/src/public-cli/settlement.ts +51 -17
- package/src/role-runtime.ts +8 -4
- package/src/taishi-metric-families/acceptance-success-rework.ts +6 -3
- package/dist/package-owned-tool-idle.js +0 -223
- package/src/package-owned-tool-idle.ts +0 -257
|
@@ -6,6 +6,7 @@ import { COLLECTOR_ACCEPTED_TEXT, COLLECTOR_OUTPUT_TOOL, validateAcceptedCollect
|
|
|
6
6
|
import { JUDGE_ACCEPTED_TEXT, JUDGE_OUTPUT_TOOL_NAME, validateAcceptedJudgeDetails, } from "./judge-output.js";
|
|
7
7
|
import { REVIEWER_ACCEPTED_TEXT, REVIEWER_OUTPUT_TOOL_NAME, projectReviewerIntentToReceipt, validateReviewerIntent, validateRuntimeReviewerReceipt, } from "./reviewer-output.js";
|
|
8
8
|
import { isAuditEscalationResult } from "../audit-escalation.js";
|
|
9
|
+
import { seatFallbackBaseStatus, seatFallbackStatusHasLawfulEvidence, } from "../engine-labor-fallback.js";
|
|
9
10
|
import { DOCTOR_OUTPUT_TOOL_NAME, validateDoctorSubmissionShape, validateRecordedDoctorOutput } from "../doctor-contracts.js";
|
|
10
11
|
import { MERGER_ACCEPTED_TEXT, MERGER_OUTPUT_TOOL_NAME, validateMergerOutput } from "../merger-contracts.js";
|
|
11
12
|
import { CODER_ACCEPTED_TEXT, CODER_OUTPUT_TOOL_NAME, FIXER_ACCEPTED_TEXT, FIXER_OUTPUT_TOOL_NAME, validateAcceptedWorkerDetails, } from "./worker-output.js";
|
|
@@ -79,9 +80,15 @@ export function validateAcceptedDetails(toolName, details) {
|
|
|
79
80
|
[MERGER_OUTPUT_TOOL_NAME]: ["completed", "escalate"],
|
|
80
81
|
};
|
|
81
82
|
const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
|
|
82
|
-
const
|
|
83
|
+
const baseDiscriminator = typeof discriminator === "string" ? seatFallbackBaseStatus(discriminator) : discriminator;
|
|
84
|
+
// ADR 0071: `-by-fallback` is not independently lawful — require latch-shaped evidence.
|
|
85
|
+
const taintedWithoutEvidence = typeof discriminator === "string" &&
|
|
86
|
+
!seatFallbackStatusHasLawfulEvidence(discriminator, details);
|
|
87
|
+
const runtimeBindingMissing = (toolName === DOCTOR_OUTPUT_TOOL_NAME && baseDiscriminator === "completed" && !(candidate?.cost !== null && typeof candidate?.cost === "object")) ||
|
|
83
88
|
(toolName === REVIEWER_OUTPUT_TOOL_NAME && candidate?.version !== 2);
|
|
84
|
-
if (
|
|
89
|
+
if (taintedWithoutEvidence ||
|
|
90
|
+
runtimeBindingMissing ||
|
|
91
|
+
(!collectorDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator)))) {
|
|
85
92
|
throw new AcceptedDetailsContractError("terminating receipt has no recognized execution discriminator");
|
|
86
93
|
}
|
|
87
94
|
try {
|
|
@@ -112,14 +119,15 @@ export function validateAcceptedLifecycle(toolName, argumentsValue, detailsValue
|
|
|
112
119
|
const details = validateAcceptedDetails(toolName, detailsValue);
|
|
113
120
|
if (toolName === DOCTOR_OUTPUT_TOOL_NAME) {
|
|
114
121
|
const testimony = validateDoctorSubmissionShape(argumentsValue);
|
|
115
|
-
if (testimony.status === "refused") {
|
|
122
|
+
if (seatFallbackBaseStatus(String(testimony.status)) === "refused") {
|
|
116
123
|
if (!deepEqual(testimony, details))
|
|
117
124
|
throw new Error("accepted tool lifecycle details mismatch");
|
|
118
125
|
return details;
|
|
119
126
|
}
|
|
120
127
|
const receipt = details;
|
|
121
|
-
if (receipt.status !== "completed")
|
|
128
|
+
if (seatFallbackBaseStatus(String(receipt.status)) !== "completed") {
|
|
122
129
|
throw new Error("accepted tool lifecycle details mismatch");
|
|
130
|
+
}
|
|
123
131
|
const { cost: _runtimeCost, ...projected } = receipt;
|
|
124
132
|
if (!deepEqual(testimony, projected))
|
|
125
133
|
throw new Error("accepted tool lifecycle details mismatch");
|
|
@@ -139,7 +147,8 @@ export function acceptedFacts(toolName, details) {
|
|
|
139
147
|
case JUDGE_OUTPUT_TOOL_NAME: return { status: details.judgeStatus };
|
|
140
148
|
case MERGER_OUTPUT_TOOL_NAME: {
|
|
141
149
|
const output = details;
|
|
142
|
-
|
|
150
|
+
const status = output.status;
|
|
151
|
+
return { status, ...(seatFallbackBaseStatus(status) === "completed" && typeof output.mergeCommitId === "string" ? { commit: output.mergeCommitId } : {}) };
|
|
143
152
|
}
|
|
144
153
|
case COLLECTOR_OUTPUT_TOOL:
|
|
145
154
|
return { status: "collected" };
|
package/dist/public-cli/main.js
CHANGED
|
@@ -136,6 +136,54 @@ 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
|
+
|
|
139
187
|
// src/package-contracts/judge-output.ts
|
|
140
188
|
function validateAcceptedJudgeDetails(verdict) {
|
|
141
189
|
if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
|
|
@@ -145,13 +193,20 @@ function validateAcceptedJudgeDetails(verdict) {
|
|
|
145
193
|
} catch {
|
|
146
194
|
throw new Error("Judge verdict has no execution discriminator");
|
|
147
195
|
}
|
|
148
|
-
if (
|
|
196
|
+
if (typeof judgeStatus !== "string") {
|
|
197
|
+
throw new Error("Judge verdict has no execution discriminator");
|
|
198
|
+
}
|
|
199
|
+
const base = seatFallbackBaseStatus(judgeStatus);
|
|
200
|
+
if (["converged", "continue", "escalate"].includes(base) && seatFallbackStatusHasLawfulEvidence(judgeStatus, verdict)) {
|
|
201
|
+
return verdict;
|
|
202
|
+
}
|
|
149
203
|
throw new Error("Judge verdict has no execution discriminator");
|
|
150
204
|
}
|
|
151
205
|
var JUDGE_OUTPUT_TOOL_NAME;
|
|
152
206
|
var init_judge_output = __esm({
|
|
153
207
|
"src/package-contracts/judge-output.ts"() {
|
|
154
208
|
"use strict";
|
|
209
|
+
init_engine_labor_fallback();
|
|
155
210
|
JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
|
|
156
211
|
}
|
|
157
212
|
});
|
|
@@ -169,6 +224,10 @@ function read(value, key) {
|
|
|
169
224
|
}
|
|
170
225
|
}
|
|
171
226
|
function validateRuntimeReviewerReceipt(output) {
|
|
227
|
+
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
|
+
}
|
|
172
231
|
const acceptedBatch = read(output, "acceptedBatch");
|
|
173
232
|
const identities = read(output, "identities");
|
|
174
233
|
const construction = read(identities, "construction");
|
|
@@ -199,11 +258,11 @@ function validateRuntimeReviewerReceipt(output) {
|
|
|
199
258
|
const expectedPrompt = read(read(legs[index], "prompt"), "text");
|
|
200
259
|
const actualPrompt = read(read(outcome, "prompt"), "text");
|
|
201
260
|
if (expectedPrompt !== actualPrompt) throw new Error("Reviewer outcome prompt disagrees with accepted leg");
|
|
202
|
-
const
|
|
261
|
+
const status2 = read(outcome, "status");
|
|
203
262
|
const report = read(reports, axis);
|
|
204
|
-
if (
|
|
263
|
+
if (status2 === "successful" && report === void 0)
|
|
205
264
|
throw new Error("Successful Reviewer outcome lacks report");
|
|
206
|
-
if (
|
|
265
|
+
if (status2 === "failed" && report !== void 0) throw new Error("Failed Reviewer outcome cannot bind a report");
|
|
207
266
|
}
|
|
208
267
|
const specDisposition = read(output, "specDisposition");
|
|
209
268
|
if (specDisposition === "launched") {
|
|
@@ -224,6 +283,7 @@ var REVIEWER_OUTPUT_TOOL_NAME;
|
|
|
224
283
|
var init_reviewer_output = __esm({
|
|
225
284
|
"src/package-contracts/reviewer-output.ts"() {
|
|
226
285
|
"use strict";
|
|
286
|
+
init_engine_labor_fallback();
|
|
227
287
|
REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
|
|
228
288
|
}
|
|
229
289
|
});
|
|
@@ -14086,12 +14146,18 @@ function read2(value, key) {
|
|
|
14086
14146
|
}
|
|
14087
14147
|
function validateDoctorSubmissionShape(value) {
|
|
14088
14148
|
const status = read2(value, "status");
|
|
14089
|
-
|
|
14149
|
+
const base = typeof status === "string" ? seatFallbackBaseStatus(status) : status;
|
|
14150
|
+
if (base !== "completed" && base !== "refused") throw new DoctorSubmissionContractError("Doctor submission has no recognized execution status");
|
|
14151
|
+
if (typeof status === "string" && !seatFallbackStatusHasLawfulEvidence(status, value)) {
|
|
14152
|
+
throw new DoctorSubmissionContractError("Doctor submission has no recognized execution status");
|
|
14153
|
+
}
|
|
14090
14154
|
return value;
|
|
14091
14155
|
}
|
|
14092
14156
|
function validateRecordedDoctorOutput(value) {
|
|
14093
14157
|
const output = validateDoctorSubmissionShape(value);
|
|
14094
|
-
|
|
14158
|
+
const status = read2(output, "status");
|
|
14159
|
+
const base = typeof status === "string" ? seatFallbackBaseStatus(status) : status;
|
|
14160
|
+
if (base === "completed" && read2(output, "cost") === void 0) throw new Error("Completed Doctor receipt has no runtime-owned cost testimony");
|
|
14095
14161
|
return output;
|
|
14096
14162
|
}
|
|
14097
14163
|
var DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_TARGET_KINDS, nonblank, count, evidenceIds, guardrail, lastRealBite, assetKinds, findingBody, finding, caseIdentity, cost, doctorSubmissionVariants, doctorSubmissionSchema, doctorOutputSchema, doctorEvidenceReadSchema, DoctorSubmissionContractError;
|
|
@@ -14100,6 +14166,7 @@ var init_doctor_contracts = __esm({
|
|
|
14100
14166
|
"use strict";
|
|
14101
14167
|
init_build();
|
|
14102
14168
|
init_canonical_json();
|
|
14169
|
+
init_engine_labor_fallback();
|
|
14103
14170
|
init_open_tool_schema();
|
|
14104
14171
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
14105
14172
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
@@ -14243,8 +14310,13 @@ function validateMergerInput(value) {
|
|
|
14243
14310
|
}
|
|
14244
14311
|
function validateMergerOutput(value, expectedAttemptId) {
|
|
14245
14312
|
if (!record(value) || expectedAttemptId !== void 0 && value.attemptId !== expectedAttemptId) throw new Error("Merger output attempt mismatch");
|
|
14246
|
-
|
|
14247
|
-
|
|
14313
|
+
const status = typeof value.status === "string" ? value.status : void 0;
|
|
14314
|
+
const statusBase = status !== void 0 ? seatFallbackBaseStatus(status) : void 0;
|
|
14315
|
+
if (status !== void 0 && !seatFallbackStatusHasLawfulEvidence(status, value)) {
|
|
14316
|
+
throw new Error("Merger output has no recognized execution discriminator");
|
|
14317
|
+
}
|
|
14318
|
+
if (statusBase === "completed" && isFullGitObjectId(value.mergeCommitId)) return structuredClone(value);
|
|
14319
|
+
if (statusBase === "escalate") return structuredClone(value);
|
|
14248
14320
|
throw new Error("Merger output has no recognized execution discriminator");
|
|
14249
14321
|
}
|
|
14250
14322
|
var oidPattern, materialSchema, checkSchema, mergerInputSchema, mergerOutputVariants, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, record, blank, MergerInputContractError;
|
|
@@ -14254,6 +14326,7 @@ var init_merger_contracts = __esm({
|
|
|
14254
14326
|
init_build();
|
|
14255
14327
|
init_git_object_id();
|
|
14256
14328
|
init_exact_utf8();
|
|
14329
|
+
init_engine_labor_fallback();
|
|
14257
14330
|
init_sha256();
|
|
14258
14331
|
init_open_tool_schema();
|
|
14259
14332
|
oidPattern = "^(?:[0-9a-f]{40}|[0-9a-f]{64})$";
|
|
@@ -15190,8 +15263,10 @@ function validateAcceptedDetails(toolName, details) {
|
|
|
15190
15263
|
[MERGER_OUTPUT_TOOL_NAME]: ["completed", "escalate"]
|
|
15191
15264
|
};
|
|
15192
15265
|
const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
|
|
15193
|
-
const
|
|
15194
|
-
|
|
15266
|
+
const baseDiscriminator = typeof discriminator === "string" ? seatFallbackBaseStatus(discriminator) : discriminator;
|
|
15267
|
+
const taintedWithoutEvidence = typeof discriminator === "string" && !seatFallbackStatusHasLawfulEvidence(discriminator, details);
|
|
15268
|
+
const runtimeBindingMissing = toolName === DOCTOR_OUTPUT_TOOL_NAME && baseDiscriminator === "completed" && !(candidate?.cost !== null && typeof candidate?.cost === "object") || toolName === REVIEWER_OUTPUT_TOOL_NAME && candidate?.version !== 2;
|
|
15269
|
+
if (taintedWithoutEvidence || runtimeBindingMissing || !collectorDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator))) {
|
|
15195
15270
|
throw new AcceptedDetailsContractError("terminating receipt has no recognized execution discriminator");
|
|
15196
15271
|
}
|
|
15197
15272
|
try {
|
|
@@ -15227,7 +15302,8 @@ function acceptedFacts(toolName, details) {
|
|
|
15227
15302
|
return { status: details.judgeStatus };
|
|
15228
15303
|
case MERGER_OUTPUT_TOOL_NAME: {
|
|
15229
15304
|
const output = details;
|
|
15230
|
-
|
|
15305
|
+
const status = output.status;
|
|
15306
|
+
return { status, ...seatFallbackBaseStatus(status) === "completed" && typeof output.mergeCommitId === "string" ? { commit: output.mergeCommitId } : {} };
|
|
15231
15307
|
}
|
|
15232
15308
|
case COLLECTOR_OUTPUT_TOOL:
|
|
15233
15309
|
return { status: "collected" };
|
|
@@ -15241,6 +15317,7 @@ var init_terminating_tools = __esm({
|
|
|
15241
15317
|
init_judge_output();
|
|
15242
15318
|
init_reviewer_output();
|
|
15243
15319
|
init_audit_escalation();
|
|
15320
|
+
init_engine_labor_fallback();
|
|
15244
15321
|
init_doctor_contracts();
|
|
15245
15322
|
init_merger_contracts();
|
|
15246
15323
|
init_worker_output();
|
|
@@ -19266,100 +19343,6 @@ var init_auditor_dossier_tool = __esm({
|
|
|
19266
19343
|
}
|
|
19267
19344
|
});
|
|
19268
19345
|
|
|
19269
|
-
// src/engine-labor-fallback.ts
|
|
19270
|
-
function buildEngineLaborFallbackField(input) {
|
|
19271
|
-
return Object.freeze({
|
|
19272
|
-
engineLaborFallback: Object.freeze({
|
|
19273
|
-
engine: input.engine,
|
|
19274
|
-
failure: input.failure,
|
|
19275
|
-
laborBy: "seat"
|
|
19276
|
-
})
|
|
19277
|
-
});
|
|
19278
|
-
}
|
|
19279
|
-
function readEngineLaborFallbackFieldFrom(source) {
|
|
19280
|
-
if (typeof source !== "object" || source === null || Array.isArray(source)) {
|
|
19281
|
-
return void 0;
|
|
19282
|
-
}
|
|
19283
|
-
let raw;
|
|
19284
|
-
try {
|
|
19285
|
-
raw = source.engineLaborFallback;
|
|
19286
|
-
} catch {
|
|
19287
|
-
return void 0;
|
|
19288
|
-
}
|
|
19289
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
|
|
19290
|
-
const rec = raw;
|
|
19291
|
-
if (typeof rec.engine !== "string" || typeof rec.failure !== "string" || rec.laborBy !== "seat") {
|
|
19292
|
-
return void 0;
|
|
19293
|
-
}
|
|
19294
|
-
return buildEngineLaborFallbackField({
|
|
19295
|
-
engine: rec.engine,
|
|
19296
|
-
failure: rec.failure
|
|
19297
|
-
});
|
|
19298
|
-
}
|
|
19299
|
-
var init_engine_labor_fallback = __esm({
|
|
19300
|
-
"src/engine-labor-fallback.ts"() {
|
|
19301
|
-
"use strict";
|
|
19302
|
-
}
|
|
19303
|
-
});
|
|
19304
|
-
|
|
19305
|
-
// src/stream-idle-guard.ts
|
|
19306
|
-
var init_stream_idle_guard = __esm({
|
|
19307
|
-
"src/stream-idle-guard.ts"() {
|
|
19308
|
-
"use strict";
|
|
19309
|
-
}
|
|
19310
|
-
});
|
|
19311
|
-
|
|
19312
|
-
// src/stderr-jsonl.ts
|
|
19313
|
-
var init_stderr_jsonl = __esm({
|
|
19314
|
-
"src/stderr-jsonl.ts"() {
|
|
19315
|
-
"use strict";
|
|
19316
|
-
}
|
|
19317
|
-
});
|
|
19318
|
-
|
|
19319
|
-
// src/tool-execution-observation.ts
|
|
19320
|
-
var observationBase, toolExecutionObservationRecordSchema;
|
|
19321
|
-
var init_tool_execution_observation = __esm({
|
|
19322
|
-
"src/tool-execution-observation.ts"() {
|
|
19323
|
-
"use strict";
|
|
19324
|
-
init_build();
|
|
19325
|
-
init_value2();
|
|
19326
|
-
init_stderr_jsonl();
|
|
19327
|
-
observationBase = {
|
|
19328
|
-
role: typebox_exports.String({ minLength: 1 }),
|
|
19329
|
-
toolCallId: typebox_exports.String({ minLength: 1 }),
|
|
19330
|
-
toolName: typebox_exports.String({ minLength: 1 }),
|
|
19331
|
-
timestamp: typebox_exports.String({ format: "date-time" })
|
|
19332
|
-
};
|
|
19333
|
-
toolExecutionObservationRecordSchema = typebox_exports.Union([
|
|
19334
|
-
typebox_exports.Object({
|
|
19335
|
-
...observationBase,
|
|
19336
|
-
event: typebox_exports.Literal("tool_execution_start")
|
|
19337
|
-
}, { additionalProperties: true }),
|
|
19338
|
-
typebox_exports.Object({
|
|
19339
|
-
...observationBase,
|
|
19340
|
-
event: typebox_exports.Literal("tool_execution_update")
|
|
19341
|
-
}, { additionalProperties: true }),
|
|
19342
|
-
typebox_exports.Object({
|
|
19343
|
-
...observationBase,
|
|
19344
|
-
event: typebox_exports.Literal("tool_execution_end"),
|
|
19345
|
-
isError: typebox_exports.Boolean()
|
|
19346
|
-
}, { additionalProperties: true })
|
|
19347
|
-
]);
|
|
19348
|
-
}
|
|
19349
|
-
});
|
|
19350
|
-
|
|
19351
|
-
// src/package-owned-tool-idle.ts
|
|
19352
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
19353
|
-
var packageOwnedToolIdleScope;
|
|
19354
|
-
var init_package_owned_tool_idle = __esm({
|
|
19355
|
-
"src/package-owned-tool-idle.ts"() {
|
|
19356
|
-
"use strict";
|
|
19357
|
-
init_stream_idle_guard();
|
|
19358
|
-
init_tool_execution_observation();
|
|
19359
|
-
packageOwnedToolIdleScope = new AsyncLocalStorage();
|
|
19360
|
-
}
|
|
19361
|
-
});
|
|
19362
|
-
|
|
19363
19346
|
// src/engine-detour-tool.ts
|
|
19364
19347
|
var engineDetourArgsSchema;
|
|
19365
19348
|
var init_engine_detour_tool = __esm({
|
|
@@ -19368,7 +19351,6 @@ var init_engine_detour_tool = __esm({
|
|
|
19368
19351
|
init_build();
|
|
19369
19352
|
init_engine_detour();
|
|
19370
19353
|
init_engine_labor_fallback();
|
|
19371
|
-
init_package_owned_tool_idle();
|
|
19372
19354
|
engineDetourArgsSchema = typebox_exports.Object(
|
|
19373
19355
|
{
|
|
19374
19356
|
argv: typebox_exports.Array(typebox_exports.String({ minLength: 1 }), {
|
|
@@ -19411,6 +19393,13 @@ var init_receipt_delivery_policy = __esm({
|
|
|
19411
19393
|
}
|
|
19412
19394
|
});
|
|
19413
19395
|
|
|
19396
|
+
// src/stream-idle-guard.ts
|
|
19397
|
+
var init_stream_idle_guard = __esm({
|
|
19398
|
+
"src/stream-idle-guard.ts"() {
|
|
19399
|
+
"use strict";
|
|
19400
|
+
}
|
|
19401
|
+
});
|
|
19402
|
+
|
|
19414
19403
|
// src/evidence-child-executor.ts
|
|
19415
19404
|
var init_evidence_child_executor = __esm({
|
|
19416
19405
|
"src/evidence-child-executor.ts"() {
|
|
@@ -19419,7 +19408,6 @@ var init_evidence_child_executor = __esm({
|
|
|
19419
19408
|
init_engine_detour_tool();
|
|
19420
19409
|
init_engine_detour();
|
|
19421
19410
|
init_engine_material();
|
|
19422
|
-
init_package_owned_tool_idle();
|
|
19423
19411
|
init_receipt_delivery_policy();
|
|
19424
19412
|
init_reviewer_construction();
|
|
19425
19413
|
init_stream_idle_guard();
|
|
@@ -19452,7 +19440,6 @@ var init_compliance_transport = __esm({
|
|
|
19452
19440
|
init_build();
|
|
19453
19441
|
init_evidence_child_executor();
|
|
19454
19442
|
init_auditor_dossier_tool();
|
|
19455
|
-
init_package_owned_tool_idle();
|
|
19456
19443
|
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
19457
19444
|
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
19458
19445
|
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: [] });
|
|
@@ -20457,7 +20444,8 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
|
20457
20444
|
// #380: spread sole-built field; do not re-key here (S1).
|
|
20458
20445
|
...readEngineLaborFallbackFieldFrom(verdict)
|
|
20459
20446
|
};
|
|
20460
|
-
|
|
20447
|
+
const statusBase = seatFallbackBaseStatus(judgeStatus);
|
|
20448
|
+
if (statusBase === "continue") {
|
|
20461
20449
|
const fix = safelyRead(verdict, "fix");
|
|
20462
20450
|
if (fix.readable && isRecord5(fix.value)) {
|
|
20463
20451
|
const summary = safelyRead(fix.value, "summary");
|
|
@@ -20482,7 +20470,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
|
20482
20470
|
}
|
|
20483
20471
|
}
|
|
20484
20472
|
}
|
|
20485
|
-
if (
|
|
20473
|
+
if (statusBase === "escalate") {
|
|
20486
20474
|
const gate = safelyRead(verdict, "decisionGate");
|
|
20487
20475
|
if (gate.readable && isRecord5(gate.value)) {
|
|
20488
20476
|
const question = safelyRead(gate.value, "question");
|
|
@@ -20506,10 +20494,11 @@ function coderDecisiveFacts(output) {
|
|
|
20506
20494
|
const status = safelyRead(candidate, "status");
|
|
20507
20495
|
const facts = {};
|
|
20508
20496
|
if (status.readable && typeof status.value === "string") facts.coderStatus = status.value;
|
|
20497
|
+
const statusBase = status.readable && typeof status.value === "string" ? seatFallbackBaseStatus(status.value) : void 0;
|
|
20509
20498
|
const remainingScope = safelyRead(candidate, "remainingScope");
|
|
20510
|
-
if (
|
|
20499
|
+
if (statusBase === "unfinished" && remainingScope.readable && typeof remainingScope.value === "string") facts.remainingScope = remainingScope.value;
|
|
20511
20500
|
const reason = safelyRead(candidate, "reason");
|
|
20512
|
-
if (
|
|
20501
|
+
if (statusBase === "unfinished" && reason.readable && typeof reason.value === "string" && reason.value.trim().length > 0) {
|
|
20513
20502
|
facts.reason = reason.value;
|
|
20514
20503
|
}
|
|
20515
20504
|
const report = safelyRead(candidate, "report");
|
|
@@ -20521,14 +20510,15 @@ function fixerDecisiveFacts(output) {
|
|
|
20521
20510
|
const status = safelyRead(candidate, "status");
|
|
20522
20511
|
const facts = {};
|
|
20523
20512
|
if (status.readable && typeof status.value === "string") facts.fixerStatus = status.value;
|
|
20513
|
+
const statusBase = status.readable && typeof status.value === "string" ? seatFallbackBaseStatus(status.value) : void 0;
|
|
20524
20514
|
const remainingScope = safelyRead(candidate, "remainingScope");
|
|
20525
|
-
if (
|
|
20515
|
+
if ((statusBase === "unfinished" || statusBase === "refused") && remainingScope.readable && typeof remainingScope.value === "string") facts.remainingScope = remainingScope.value;
|
|
20526
20516
|
const reason = safelyRead(candidate, "reason");
|
|
20527
|
-
if (
|
|
20517
|
+
if (statusBase === "unfinished" && reason.readable && typeof reason.value === "string" && reason.value.trim().length > 0) {
|
|
20528
20518
|
facts.reason = reason.value;
|
|
20529
20519
|
}
|
|
20530
20520
|
const blockerRead = safelyRead(candidate, "blocker");
|
|
20531
|
-
if (
|
|
20521
|
+
if (statusBase === "refused" && blockerRead.readable && isRecord5(blockerRead.value)) {
|
|
20532
20522
|
const cause = safelyRead(blockerRead.value, "cause");
|
|
20533
20523
|
if (cause.readable && typeof cause.value === "string") facts.blockerCause = cause.value;
|
|
20534
20524
|
const prerequisiteId = safelyRead(blockerRead.value, "prerequisiteId");
|
|
@@ -20604,7 +20594,8 @@ function doctorDecisiveFacts(output) {
|
|
|
20604
20594
|
const status = safelyRead(candidate, "status");
|
|
20605
20595
|
const facts = { ...auditNoReceiptDecisiveFact(candidate) };
|
|
20606
20596
|
if (status.readable && typeof status.value === "string") facts.doctorStatus = status.value;
|
|
20607
|
-
|
|
20597
|
+
const statusBase = status.readable && typeof status.value === "string" ? seatFallbackBaseStatus(status.value) : void 0;
|
|
20598
|
+
if (statusBase === "refused") {
|
|
20608
20599
|
const reason = safelyRead(candidate, "reason");
|
|
20609
20600
|
if (reason.readable && reason.value !== void 0) facts.reason = reason.value;
|
|
20610
20601
|
const missing = safelyRead(candidate, "missingEvidence");
|
|
@@ -20651,7 +20642,8 @@ function reviewerDecisiveFacts(output) {
|
|
|
20651
20642
|
facts.specDisposition = specDisposition.value;
|
|
20652
20643
|
}
|
|
20653
20644
|
const diagnostic = safelyRead(candidate, "diagnostic");
|
|
20654
|
-
|
|
20645
|
+
const statusBase = status.readable && typeof status.value === "string" ? seatFallbackBaseStatus(status.value) : void 0;
|
|
20646
|
+
if (statusBase === "refused" && diagnostic.readable) {
|
|
20655
20647
|
facts.diagnosticPresent = typeof diagnostic.value === "string" && diagnostic.value.trim().length > 0;
|
|
20656
20648
|
}
|
|
20657
20649
|
return facts;
|
|
@@ -21092,9 +21084,11 @@ function extractJudgeRoleOutcome(entries) {
|
|
|
21092
21084
|
if (isUnboundAuditEscalationFace(details)) continue;
|
|
21093
21085
|
if (!isRecord5(details)) continue;
|
|
21094
21086
|
const statusRead = safelyRead(details, "judgeStatus");
|
|
21095
|
-
if (!statusRead.readable) continue;
|
|
21087
|
+
if (!statusRead.readable || typeof statusRead.value !== "string") continue;
|
|
21096
21088
|
const judgeStatus = statusRead.value;
|
|
21097
|
-
|
|
21089
|
+
const statusBase = seatFallbackBaseStatus(judgeStatus);
|
|
21090
|
+
if (statusBase !== "converged" && statusBase !== "continue" && statusBase !== "escalate") continue;
|
|
21091
|
+
if (!seatFallbackStatusHasLawfulEvidence(judgeStatus, details)) continue;
|
|
21098
21092
|
return {
|
|
21099
21093
|
kind: "accepted",
|
|
21100
21094
|
role: "judge",
|
|
@@ -21784,8 +21778,9 @@ async function settleLawfulDoctorTerminalResult(admitted) {
|
|
|
21784
21778
|
if (entries === void 0) return void 0;
|
|
21785
21779
|
const extracted = extractDoctorRoleOutcome(entries);
|
|
21786
21780
|
if (extracted === void 0) return void 0;
|
|
21787
|
-
if (extracted.output !== void 0 && extracted.output.status === "completed") {
|
|
21788
|
-
|
|
21781
|
+
if (extracted.output !== void 0 && seatFallbackBaseStatus(String(extracted.output.status)) === "completed") {
|
|
21782
|
+
const completedCase = extracted.output.case;
|
|
21783
|
+
if (completedCase.issueNumber !== admitted.caseIdentity.issueNumber || completedCase.runsPath !== admitted.caseIdentity.runsPath) {
|
|
21789
21784
|
const error = new Error(
|
|
21790
21785
|
"Doctor receipt case identity does not match admitted case identity"
|
|
21791
21786
|
);
|
|
@@ -21999,7 +21994,8 @@ function mergerDecisiveFacts(output) {
|
|
|
21999
21994
|
const attemptId = safelyRead(candidate, "attemptId");
|
|
22000
21995
|
if (status.readable && typeof status.value === "string") facts.mergerStatus = status.value;
|
|
22001
21996
|
if (attemptId.readable && attemptId.value !== void 0) facts.attemptId = attemptId.value;
|
|
22002
|
-
const
|
|
21997
|
+
const statusBase = status.readable && typeof status.value === "string" ? seatFallbackBaseStatus(status.value) : void 0;
|
|
21998
|
+
const decisiveKey = statusBase === "completed" ? "mergeCommitId" : "diagnosis";
|
|
22003
21999
|
const decisive = safelyRead(candidate, decisiveKey);
|
|
22004
22000
|
if (decisive.readable && decisive.value !== void 0) facts[decisiveKey] = decisive.value;
|
|
22005
22001
|
return facts;
|
|
@@ -25935,8 +25931,9 @@ function mapTerminal(role, terminal) {
|
|
|
25935
25931
|
noReceipt: false
|
|
25936
25932
|
};
|
|
25937
25933
|
}
|
|
25934
|
+
const statusBase = seatFallbackBaseStatus(status);
|
|
25938
25935
|
const acceptedSet = ACCEPTED_STATUS[role];
|
|
25939
|
-
if (acceptedSet === void 0 || !acceptedSet.has(
|
|
25936
|
+
if (acceptedSet === void 0 || !acceptedSet.has(statusBase)) {
|
|
25940
25937
|
return {
|
|
25941
25938
|
terminalLabel: status,
|
|
25942
25939
|
accepted: false,
|
|
@@ -25945,9 +25942,9 @@ function mapTerminal(role, terminal) {
|
|
|
25945
25942
|
noReceipt: false
|
|
25946
25943
|
};
|
|
25947
25944
|
}
|
|
25948
|
-
const plannedDuty = WORKER_ROLES.has(role) &&
|
|
25945
|
+
const plannedDuty = WORKER_ROLES.has(role) && statusBase === "planned";
|
|
25949
25946
|
const successSet = SUCCESS_STATUS[role] ?? /* @__PURE__ */ new Set();
|
|
25950
|
-
const success = !plannedDuty && successSet.has(
|
|
25947
|
+
const success = !plannedDuty && successSet.has(statusBase);
|
|
25951
25948
|
const successEligible = !plannedDuty;
|
|
25952
25949
|
return {
|
|
25953
25950
|
terminalLabel: status,
|
|
@@ -26069,6 +26066,7 @@ var WORKER_ROLES, ACCEPTED_STATUS, SUCCESS_STATUS, acceptanceSuccessReworkFamily
|
|
|
26069
26066
|
var init_acceptance_success_rework = __esm({
|
|
26070
26067
|
"src/taishi-metric-families/acceptance-success-rework.ts"() {
|
|
26071
26068
|
"use strict";
|
|
26069
|
+
init_engine_labor_fallback();
|
|
26072
26070
|
init_taishi_median();
|
|
26073
26071
|
WORKER_ROLES = /* @__PURE__ */ new Set(["coder", "fixer"]);
|
|
26074
26072
|
ACCEPTED_STATUS = {
|
package/package.json
CHANGED
|
@@ -33,10 +33,9 @@ codex exec --skip-git-repo-check --ephemeral -C "$PROJECT_ROOT" "YOUR_LABOR_PROM
|
|
|
33
33
|
|
|
34
34
|
Default (non-`--json`) mode prints the session banner and progress on stderr
|
|
35
35
|
(measured on this host). Collect the labor body from stdout so that stderr log
|
|
36
|
-
noise is not mixed into the returned body
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
types include `thread.started`, `turn.started`, `item.completed`, `error`,
|
|
36
|
+
noise is not mixed into the returned body. Use `--json` only when the seat itself
|
|
37
|
+
needs machine-readable event rows (those rows land on stdout as JSONL; measured
|
|
38
|
+
event types include `thread.started`, `turn.started`, `item.completed`, `error`,
|
|
40
39
|
`turn.failed`):
|
|
41
40
|
|
|
42
41
|
```bash
|
|
@@ -27,12 +27,11 @@ grok --prompt-file /path/to/labor-prompt.md -m grok-4.6 --always-approve --outpu
|
|
|
27
27
|
- `--output-format plain` keeps stdout clean for capture — but it stays
|
|
28
28
|
silent until the run finishes. **For labor longer than ~2 minutes use
|
|
29
29
|
`--output-format streaming-json` instead**: it emits NDJSON events
|
|
30
|
-
(thought/text deltas) continuously from the first second,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
the answer (live-verified stream shape 2026-08-21).
|
|
30
|
+
(thought/text deltas) continuously from the first second, so long runs stay
|
|
31
|
+
observable instead of appearing hung. Reconstruct the final answer by
|
|
32
|
+
concatenating each NDJSON object's `data` where `type == "text"`, in stream
|
|
33
|
+
order; `type == "end"` (stopReason end_turn) marks completion. Do not treat
|
|
34
|
+
`thought` events as the answer (live-verified stream shape 2026-08-21).
|
|
36
35
|
- **Always pass `--reasoning-effort <low|medium|high>`** matching the effort
|
|
37
36
|
tier ordered in the labor mandate (verified live 2026-08-21: flag exists,
|
|
38
37
|
alias `--effort`; a low-tier run completed correctly). If the mandate names
|
|
@@ -31,8 +31,8 @@ kimi -m <model-alias> -p "YOUR_LABOR_PROMPT"
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Use `--output-format stream-json` (choices measured on this host: `text`,
|
|
34
|
-
`stream-json`; default is `text`)
|
|
35
|
-
|
|
34
|
+
`stream-json`; default is `text`) when long labor needs progressive observability
|
|
35
|
+
while the engine works. Take the labor body from
|
|
36
36
|
`{"role":"assistant","content":...}` rows, not from `role:meta` rows:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
@@ -33,8 +33,8 @@ claude -p --model opus --verbose --output-format=stream-json "YOUR_LABOR_PROMPT"
|
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Use `--output-format=stream-json` (choices measured on this host: `text`, `json`,
|
|
36
|
-
`stream-json`)
|
|
37
|
-
|
|
36
|
+
`stream-json`) when long labor needs progressive observability while the engine
|
|
37
|
+
works; take the labor body from the final `result` event's `result` field,
|
|
38
38
|
not from intermediate stream rows.
|
|
39
39
|
|
|
40
40
|
Prefer `claude --help` on the host over any remembered flag set. Do not wrap this
|
|
@@ -9,6 +9,8 @@ const entries = [
|
|
|
9
9
|
"work-subject-identity",
|
|
10
10
|
"navigator-invocation-identity",
|
|
11
11
|
"navigator-attendance",
|
|
12
|
+
// Navigator package-graph dependency (seat-fallback base status / ADR 0071).
|
|
13
|
+
"engine-labor-fallback",
|
|
12
14
|
"activation-ledger-git",
|
|
13
15
|
"activation-ledger-topology",
|
|
14
16
|
"activation-reconciliation",
|