@akagilnc/pi-workflow-roles 0.1.5153 → 0.1.5194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +13086 -13034
- package/dist/archivist-record-entry.js +4 -20
- package/dist/archivist-record-pointer.js +28 -0
- package/dist/audit-escalation.js +3 -119
- package/dist/auditor-soul.js +32 -0
- package/dist/doctor-auditor.js +26 -0
- package/dist/headless-host/production-host.js +11218 -11166
- package/dist/judge-role.js +73 -0
- package/dist/migrate-book-topology.js +8 -0
- package/dist/package-contracts/judge-output.js +1 -18
- package/dist/package-contracts/terminating-tools.js +2 -2
- package/dist/public-cli/cli.js +2 -2
- package/dist/public-cli/countersign-run.js +11 -0
- package/dist/public-cli/instruction-seat-run.js +428 -48
- package/dist/public-cli/invocation.js +10 -5
- package/dist/public-cli/main.js +10049 -8911
- package/dist/public-cli/settlement.js +28 -8
- package/dist/public-role-summons.js +6 -4
- package/dist/submission-errors.js +1 -1
- package/dist/submission-gate.js +165 -0
- package/dist/submission-ledger.js +0 -27
- package/dist/worker-submission-contracts.js +8 -0
- package/package.json +1 -1
- package/src/archivist-record-entry.ts +5 -49
- package/src/archivist-record-pointer.ts +49 -0
- package/src/audit-escalation.ts +4 -217
- package/src/auditor-soul.ts +33 -0
- package/src/doctor-role.ts +11 -5
- package/src/gatekeeper-role.ts +2 -2
- package/src/host-contracts.ts +0 -25
- package/src/judge-role.ts +63 -90
- package/src/package-contracts/judge-output.ts +0 -17
- package/src/package-contracts/terminating-tools.ts +0 -2
- package/src/pi/adapter.ts +1 -33
- package/src/public-cli/cli.ts +2 -2
- package/src/public-cli/countersign-run.ts +11 -0
- package/src/public-cli/instruction-seat-run.ts +433 -16
- package/src/public-cli/invocation.ts +9 -3
- package/src/public-cli/post-admission.ts +0 -1
- package/src/public-cli/settlement.ts +32 -8
- package/src/public-role-summons.ts +9 -6
- package/src/role-envelope.ts +0 -32
- package/src/role-runtime-dependencies.ts +0 -4
- package/src/role-runtime.ts +15 -218
- package/src/submission-errors.ts +1 -1
- package/src/submission-gate.ts +46 -10
- package/src/submission-ledger.ts +0 -27
- package/src/worker-role.ts +23 -102
- package/src/worker-submission-contracts.ts +8 -0
- package/src/worker-submission-gates.ts +2 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {} from "./host-contracts.js";
|
|
2
|
+
import { reviewSubmissionSchema } from "./review-submission.js";
|
|
3
|
+
import {} from "./gatekeeper-role.js";
|
|
4
|
+
import { JUDGE_OUTPUT_TOOL_NAME, } from "./package-contracts/judge-output.js";
|
|
5
|
+
export { JUDGE_OUTPUT_TOOL_NAME };
|
|
6
|
+
/** The only judge audit order: 符宝郎, then 审刑院. */
|
|
7
|
+
const JUDGE_GATES = [
|
|
8
|
+
{ kind: "judge_draft" },
|
|
9
|
+
{ kind: "judge_compliance" },
|
|
10
|
+
];
|
|
11
|
+
export async function runJudgeGates(input) {
|
|
12
|
+
const passes = [];
|
|
13
|
+
for (const subject of JUDGE_GATES) {
|
|
14
|
+
if (await input.gateAlreadyConverged(subject))
|
|
15
|
+
continue;
|
|
16
|
+
const pass = await input.runGate(subject);
|
|
17
|
+
const status = pass?.status;
|
|
18
|
+
if (pass === undefined || (status !== "converged" && status !== "continue" && status !== "escalate")) {
|
|
19
|
+
throw new Error("judge gate returned no conclusion");
|
|
20
|
+
}
|
|
21
|
+
passes.push({
|
|
22
|
+
subject,
|
|
23
|
+
status,
|
|
24
|
+
receipt: pass.receipt,
|
|
25
|
+
...(pass.runId === undefined ? {} : { runId: pass.runId }),
|
|
26
|
+
...(pass.runDirectory === undefined ? {} : { runDirectory: pass.runDirectory }),
|
|
27
|
+
});
|
|
28
|
+
if (status === "continue" || status === "escalate")
|
|
29
|
+
return { status, passes };
|
|
30
|
+
}
|
|
31
|
+
return { status: "converged", passes };
|
|
32
|
+
}
|
|
33
|
+
// #836 r16 class 1: fix/classes/note/decisionGate are LLM/human-read narrative
|
|
34
|
+
// content — 符宝郎/审刑院 read the raw receipt, no code branches on their length
|
|
35
|
+
// or nested presence. `status` alone is the machine discriminator the
|
|
36
|
+
// queue reads to pick converged/continue/escalate (below).
|
|
37
|
+
// The shared open schema preserves role-specific prose without adding another contract.
|
|
38
|
+
export const judgeVerdictSchema = reviewSubmissionSchema;
|
|
39
|
+
export function createJudgeRoleRuntime(pi, dependencies) {
|
|
40
|
+
let soul;
|
|
41
|
+
let lifecycleRegistered = false;
|
|
42
|
+
return {
|
|
43
|
+
async activate() {
|
|
44
|
+
soul = (await dependencies.loadSoul()).trim();
|
|
45
|
+
if (soul.length === 0)
|
|
46
|
+
throw new Error("Judge soul is empty");
|
|
47
|
+
if (!lifecycleRegistered) {
|
|
48
|
+
lifecycleRegistered = true;
|
|
49
|
+
pi.registerTool({
|
|
50
|
+
name: JUDGE_OUTPUT_TOOL_NAME,
|
|
51
|
+
label: "大理寺输出",
|
|
52
|
+
description: "提交大理寺终局判词;交卷调用结束后,由公开调用接缝按判词状态执行适用审核。",
|
|
53
|
+
promptSnippet: "提交大理寺终局判词",
|
|
54
|
+
parameters: judgeVerdictSchema,
|
|
55
|
+
async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
56
|
+
if (soul === undefined)
|
|
57
|
+
throw new Error("大理寺职分未装载");
|
|
58
|
+
// ADR 0003: record the original receipt and end the tool call first.
|
|
59
|
+
// The public seam reads status and chooses the next route.
|
|
60
|
+
return { content: [], details: parameters, terminate: true };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
pi.on("before_agent_start", (event) => {
|
|
64
|
+
if (soul === undefined)
|
|
65
|
+
throw new Error("大理寺职分未装载");
|
|
66
|
+
return {
|
|
67
|
+
systemPrompt: `${event.systemPrompt}\n\n<judge_soul>\n${soul}\n</judge_soul>`,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -177487,6 +177487,13 @@ var init_dist6 = __esm({
|
|
|
177487
177487
|
}
|
|
177488
177488
|
});
|
|
177489
177489
|
|
|
177490
|
+
// src/archivist-record-pointer.ts
|
|
177491
|
+
var init_archivist_record_pointer = __esm({
|
|
177492
|
+
"src/archivist-record-pointer.ts"() {
|
|
177493
|
+
"use strict";
|
|
177494
|
+
}
|
|
177495
|
+
});
|
|
177496
|
+
|
|
177490
177497
|
// scripts/migrate-book-topology.ts
|
|
177491
177498
|
import { homedir as homedir4 } from "node:os";
|
|
177492
177499
|
import { join as join15, resolve as resolve9 } from "node:path";
|
|
@@ -177615,6 +177622,7 @@ init_activation_ledger_topology();
|
|
|
177615
177622
|
init_dist6();
|
|
177616
177623
|
|
|
177617
177624
|
// src/archivist-record-entry.ts
|
|
177625
|
+
init_archivist_record_pointer();
|
|
177618
177626
|
var MAX_SESSION_HEADER_SCAN_BYTES2 = 1024 * 1024;
|
|
177619
177627
|
var WORKER_SUBMISSION_GATE_KIND = "worker-submission-gate";
|
|
177620
177628
|
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import { REVIEW_QUEUE_STATUSES, REVIEW_SUBMISSION_OUTPUT_TOOL_NAME } from "../review-submission.js";
|
|
2
2
|
const JUDGE_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
|
|
3
|
-
function validateAcceptedJudgeDetails(verdict) {
|
|
4
|
-
if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
|
|
5
|
-
let status;
|
|
6
|
-
try {
|
|
7
|
-
status = verdict.status;
|
|
8
|
-
} catch {
|
|
9
|
-
throw new Error("Judge verdict has no execution discriminator");
|
|
10
|
-
}
|
|
11
|
-
if (typeof status !== "string") {
|
|
12
|
-
throw new Error("Judge verdict has no execution discriminator");
|
|
13
|
-
}
|
|
14
|
-
if (REVIEW_QUEUE_STATUSES.has(status)) {
|
|
15
|
-
return verdict;
|
|
16
|
-
}
|
|
17
|
-
throw new Error("Judge verdict has no execution discriminator");
|
|
18
|
-
}
|
|
19
3
|
export {
|
|
20
|
-
JUDGE_OUTPUT_TOOL_NAME
|
|
21
|
-
validateAcceptedJudgeDetails
|
|
4
|
+
JUDGE_OUTPUT_TOOL_NAME
|
|
22
5
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Package roles share these terminating leaves.
|
|
4
4
|
*/
|
|
5
5
|
import { COLLECTOR_OUTPUT_TOOL, validateAcceptedCollectorReceipt, } from "./collector-output.js";
|
|
6
|
-
import { JUDGE_OUTPUT_TOOL_NAME,
|
|
6
|
+
import { JUDGE_OUTPUT_TOOL_NAME, } from "./judge-output.js";
|
|
7
7
|
import { REVIEWER_OUTPUT_TOOL_NAME, validateReviewerIntent, } from "./reviewer-output.js";
|
|
8
8
|
import { LEGACY_REVIEW_OUTPUT_ROLES, PACKAGED_ROLE_REGISTRY } from "../packaged-role-registry.js";
|
|
9
9
|
import { CorrectableSubmissionError } from "../submission-correctable-error.js";
|
|
@@ -19,7 +19,7 @@ import { INSPECTOR_OUTPUT_TOOL_NAME, validateRecordedInspectorOutput } from "../
|
|
|
19
19
|
import { DIARIST_OUTPUT_TOOL_NAME, validateRecordedDiaristOutput } from "../diarist-contracts.js";
|
|
20
20
|
import { SECRETARIAT_OUTPUT_TOOL_NAME } from "../secretariat-contracts.js";
|
|
21
21
|
import { CODER_OUTPUT_TOOL_NAME, FIXER_OUTPUT_TOOL_NAME, validateAcceptedWorkerDetails, } from "./worker-output.js";
|
|
22
|
-
export { CODER_OUTPUT_TOOL_NAME, COLLECTOR_OUTPUT_TOOL, FIXER_OUTPUT_TOOL_NAME, JUDGE_OUTPUT_TOOL_NAME, REVIEWER_OUTPUT_TOOL_NAME, MERGER_OUTPUT_TOOL_NAME, validateAcceptedCollectorReceipt,
|
|
22
|
+
export { CODER_OUTPUT_TOOL_NAME, COLLECTOR_OUTPUT_TOOL, FIXER_OUTPUT_TOOL_NAME, JUDGE_OUTPUT_TOOL_NAME, REVIEWER_OUTPUT_TOOL_NAME, MERGER_OUTPUT_TOOL_NAME, validateAcceptedCollectorReceipt, validateReviewerIntent, validateAcceptedWorkerDetails, validateDoctorSubmissionShape, validateRecordedDoctorOutput, validateMergerOutput, validateRecordedNotaryOutput, validateRecordedCountersignOutput, validateRecordedGleanerLeftOutput, validateRecordedInspectorOutput, validateRecordedGatekeeperOutput, validateRecordedNavigatorOutput, validateRecordedAuditorOutput, validateRecordedDiaristOutput, };
|
|
23
23
|
export const TERMINATING_TOOL_NAMES = [...new Set([
|
|
24
24
|
...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
|
|
25
25
|
...LEGACY_REVIEW_OUTPUT_ROLES.keys(),
|
package/dist/public-cli/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ import { parseAnalystArgv, parsePublicSeatArgv, } from "./invocation.js";
|
|
|
20
20
|
import { createTypedOptionConsumer, optionsForOwner, projectCommandHelp, projectOwnerOptions, PUBLIC_NAVIGATOR_HELP_NOTE, PUBLIC_ROLE_OPTION_OWNERS, renderHumanOwnerOptionLines, } from "./option-definitions.js";
|
|
21
21
|
import { TurnDispatchedFailure } from "./auto-resume.js";
|
|
22
22
|
import { continueParentAfterChild, runPublicInstructionSeat, runPublicInstructionSeatResume } from "./instruction-seat-run.js";
|
|
23
|
-
import {
|
|
23
|
+
import { latestPayloadEscalated } from "./countersign-run.js";
|
|
24
24
|
import { runPublicAnalyst } from "./analyst-run.js";
|
|
25
25
|
import { AUTO_RESUME_LIMIT, peekRoleRunRole, } from "./run-lifecycle.js";
|
|
26
26
|
import { INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, isPublicCallableRole, isPublicCliSupportCommand, isPublicConfigurableSeat, listHelpCapabilities, } from "./registry.js";
|
|
@@ -850,7 +850,7 @@ export async function runAkRole(argv, env) {
|
|
|
850
850
|
let current = result;
|
|
851
851
|
while (current.exitCode === 0 && current.admitted?.correlationId !== undefined
|
|
852
852
|
&& current.terminal?.roleOutcome.kind === "accepted"
|
|
853
|
-
&& !
|
|
853
|
+
&& !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
854
854
|
const parentRunId = current.admitted.correlationId;
|
|
855
855
|
resumeFailureContext = {
|
|
856
856
|
home,
|
|
@@ -96,6 +96,17 @@ export function courtTicketNumbersFromOutcome(roleOutcome, principalTicket, subm
|
|
|
96
96
|
}
|
|
97
97
|
return latest;
|
|
98
98
|
}
|
|
99
|
+
/** Latest payload only. An earlier escalate must not block a later non-escalate submission. */
|
|
100
|
+
export function latestPayloadEscalated(roleOutcome) {
|
|
101
|
+
if (roleOutcome === undefined)
|
|
102
|
+
return false;
|
|
103
|
+
if (roleOutcome.kind === "audit_escalation")
|
|
104
|
+
return true;
|
|
105
|
+
if (roleOutcome.kind !== "accepted")
|
|
106
|
+
return false;
|
|
107
|
+
const payloads = roleOutcome.payloads ?? [];
|
|
108
|
+
return isEscalatePayload(payloads[payloads.length - 1]);
|
|
109
|
+
}
|
|
99
110
|
/** Routing boolean over the child's own typed sequence — does not pick or rewrite a sole row. */
|
|
100
111
|
export function courtDiaristEscalated(roleOutcome) {
|
|
101
112
|
if (roleOutcome === undefined)
|