@akagilnc/pi-workflow-roles 0.1.3572 → 0.1.3621
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 +20239 -10556
- package/dist/analyst-gate-cycles-read.js +387 -0
- package/dist/archivist-record-entry.js +22 -1
- package/dist/audit-escalation.js +6 -0
- package/dist/auditor-soul.js +74 -0
- package/dist/collector-config.js +86 -0
- package/dist/collector-evidence.js +316 -0
- package/dist/collector-github.js +527 -0
- package/dist/collector-ledger.js +853 -0
- package/dist/collector-tool-schemas.js +33 -0
- package/dist/compliance-transport.js +104 -52
- package/dist/diarist-mechanical.js +411 -0
- package/dist/diarist-ticket-resolution.js +177 -0
- package/dist/diarist.js +311 -0
- package/dist/doctor-auditor.js +25 -0
- package/dist/doctor-contracts.js +2 -0
- package/dist/doctor-evidence.js +142 -0
- package/dist/gatekeeper-role.js +104 -81
- package/dist/host-transition-prior-native.js +78 -0
- package/dist/institutional-resolution.js +1 -95
- package/dist/judge-auditor.js +26 -0
- package/dist/ledger-session-read.js +227 -0
- package/dist/merger-git-state.js +78 -0
- package/dist/navigator-attendance.js +15 -7
- package/dist/navigator-public-session.js +170 -0
- package/dist/navigator-session-contracts.js +36 -40
- package/dist/notary-source-run.js +122 -0
- package/dist/package-contracts/auditor-output.js +66 -0
- package/dist/package-contracts/evidence-child-output.js +34 -0
- package/dist/package-contracts/judge-output.js +2 -0
- package/dist/package-contracts/terminating-tools.js +25 -2
- package/dist/package-resources/method-skill.js +254 -0
- package/dist/packaged-role-registry.js +36 -0
- package/dist/pi/durable-principal.js +61 -0
- package/dist/pi/in-process-session.js +25 -6
- package/dist/pi/known-failure.js +52 -0
- package/dist/pi/role-turn-host.js +430 -0
- package/dist/public-cli/auto-resume.js +414 -0
- package/dist/public-cli/cli-errors.js +8 -0
- package/dist/public-cli/cli-io.js +1 -0
- package/dist/public-cli/command-renderer.js +5 -0
- package/dist/public-cli/doctor-run.js +84 -0
- package/dist/public-cli/inspector-run.js +136 -0
- package/dist/public-cli/instruction-seat-run.js +256 -0
- package/dist/public-cli/invocation.js +2225 -0
- package/dist/public-cli/judge-run.js +118 -0
- package/dist/public-cli/load-production-acp-host.js +40 -0
- package/dist/public-cli/main.js +1140 -652
- package/dist/public-cli/notary-run.js +161 -0
- package/dist/public-cli/option-definitions.js +1192 -0
- package/dist/public-cli/post-admission.js +667 -0
- package/dist/public-cli/public-run-credentials.js +49 -0
- package/dist/public-cli/registry.js +4 -1
- package/dist/public-cli/reviewer-dispatch-rejection.js +77 -0
- package/dist/public-cli/run-lifecycle.js +1344 -0
- package/dist/public-cli/seat-ticket-binding.js +113 -0
- package/dist/public-cli/settlement.js +3441 -0
- package/dist/public-cli/terminal.js +135 -0
- package/dist/public-cli/turn-request.js +25 -0
- package/dist/public-role-summons.js +301 -0
- package/dist/receipt-delivery-policy.js +10 -0
- package/dist/reviewer-child-executor.js +80 -8
- package/dist/reviewer-execution-ledger.js +2 -1
- package/dist/run-terminal-artifacts.js +195 -0
- package/dist/run-ticket-number.js +40 -0
- package/dist/session-assistant-usage.js +107 -0
- package/dist/shape-unreadable-failure.js +34 -0
- package/dist/submission-errors.js +3 -0
- package/dist/submission-ledger.js +388 -0
- package/dist/ticket-provenance-contracts.js +115 -0
- package/dist/ticket-provenance.js +340 -0
- package/extensions/role-runtime.ts +7 -0
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -1
- package/souls/doctor-auditor.md +1 -0
- package/souls/evidence-child.md +1 -0
- package/src/acp-host/production-host.ts +3 -0
- package/src/acp-host/role-envelope.ts +2 -2
- package/src/acp-host/role-turn-host.ts +9 -1
- package/src/analyst-gate-cycles-read.ts +37 -2
- package/src/archivist-record-entry.ts +45 -1
- package/src/audit-escalation.ts +17 -0
- package/src/auditor-role.ts +22 -0
- package/src/auditor-soul.ts +42 -0
- package/src/compliance-transport.ts +177 -66
- package/src/doctor-auditor.ts +10 -14
- package/src/doctor-contracts.ts +1 -0
- package/src/doctor-role.ts +2 -2
- package/src/evidence-child-role.ts +22 -0
- package/src/gatekeeper-pass-envelope.ts +109 -0
- package/src/gatekeeper-role.ts +145 -104
- package/src/host-contracts.ts +9 -1
- package/src/institutional-resolution.ts +8 -163
- package/src/judge-auditor.ts +10 -15
- package/src/judge-role.ts +8 -0
- package/src/navigator-attendance.ts +25 -9
- package/src/navigator-public-session.ts +217 -0
- package/src/navigator-session-contracts.ts +61 -54
- package/src/notary-source-run.ts +3 -1
- package/src/package-contracts/auditor-output.ts +82 -0
- package/src/package-contracts/evidence-child-output.ts +51 -0
- package/src/package-contracts/judge-output.ts +1 -0
- package/src/package-contracts/reviewer-output.ts +2 -2
- package/src/package-contracts/terminating-tools.ts +31 -1
- package/src/packaged-role-registry.ts +43 -0
- package/src/pi/adapter.ts +2 -1
- package/src/pi/in-process-session.ts +38 -12
- package/src/pi/role-turn-host.ts +34 -0
- package/src/public-cli/cli.ts +14 -6
- package/src/public-cli/instruction-seat-run.ts +289 -50
- package/src/public-cli/invocation.ts +66 -25
- package/src/public-cli/option-definitions.ts +61 -0
- package/src/public-cli/post-admission.ts +7 -1
- package/src/public-cli/registry.ts +4 -1
- package/src/public-cli/run-lifecycle.ts +22 -3
- package/src/public-cli/settlement.ts +120 -5
- package/src/public-cli/terminal.ts +2 -0
- package/src/public-role-summons.ts +431 -0
- package/src/receipt-delivery-policy.ts +10 -0
- package/src/reviewer-agent.ts +1 -1
- package/src/reviewer-child-executor.ts +114 -12
- package/src/reviewer-execution-ledger.ts +3 -2
- package/src/role-runtime.ts +158 -17
- package/src/session-assistant-usage.ts +119 -0
- package/src/session-opening-materials.ts +1 -1
- package/src/shape-unreadable-failure.ts +49 -0
- package/src/submission-errors.ts +3 -0
- package/dist/evidence-child-executor.js +0 -829
- package/src/evidence-child-executor.ts +0 -1140
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { engineSessionMaterialFromOptions } from "../package-resources/engine-material.js";
|
|
2
|
+
import { readRunTicketNumber } from "../run-ticket-number.js";
|
|
3
|
+
import { CliUsageError } from "./cli-errors.js";
|
|
4
|
+
import { admitAuditorInvocation, admitEvidenceChildInvocation, admitGatekeeperInvocation, admitNavigatorInvocation, bindAdmittedTicketNumber, buildInstructionTransportPrompt, } from "./invocation.js";
|
|
5
|
+
import { prepareSummonsResumeMaterials, runPostAdmissionOneShot, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
6
|
+
import { loadResumableInstructionSeatRun, markRunAdmitted, } from "./run-lifecycle.js";
|
|
7
|
+
import { applyInstructionTicketProbe, probeInstructionTicket, ticketNumberFromProbe, tryResumeSameTicketSeatRun, } from "./seat-ticket-binding.js";
|
|
8
|
+
import { presentStructuralRejection, readEngineDetourInfrastructureFailure, trySettleAuditorTerminalResult, trySettleEvidenceChildTerminalResult, trySettleGatekeeperTerminalResult, trySettleNavigatorTerminalResult, } from "./settlement.js";
|
|
9
|
+
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
10
|
+
/** Project an admitted instruction-seat invocation onto the host-neutral turn request. */
|
|
11
|
+
export function buildInstructionSeatTurnRequest(admitted, options) {
|
|
12
|
+
return projectRoleTurnRequest(admitted, {
|
|
13
|
+
activation: {
|
|
14
|
+
role: admitted.role,
|
|
15
|
+
},
|
|
16
|
+
}, options);
|
|
17
|
+
}
|
|
18
|
+
function instructionSeatAdapters(options) {
|
|
19
|
+
return {
|
|
20
|
+
trySettle: (admitted, authority, scope) => {
|
|
21
|
+
switch (admitted.role) {
|
|
22
|
+
case "gatekeeper":
|
|
23
|
+
return trySettleGatekeeperTerminalResult(admitted, authority, scope);
|
|
24
|
+
case "navigator":
|
|
25
|
+
return trySettleNavigatorTerminalResult(admitted, authority, scope);
|
|
26
|
+
case "auditor":
|
|
27
|
+
return trySettleAuditorTerminalResult(admitted, authority, scope);
|
|
28
|
+
case "evidence-child":
|
|
29
|
+
return trySettleEvidenceChildTerminalResult(admitted, authority, scope);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
// Accepted receipts and failure terminals both present via shared path.
|
|
33
|
+
shouldPresentSettled: () => true,
|
|
34
|
+
// #675 / #357 T2: failInfrastructure abort after engine-detour tool failure must not
|
|
35
|
+
// wash the durable toolResult diagnostic (same seam as reviewer-run / judge-run).
|
|
36
|
+
resolveRunnerKnownFailure: async ({ result, sessionFile, }) => {
|
|
37
|
+
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
38
|
+
return infrastructureFailure === undefined
|
|
39
|
+
? result.knownFailure
|
|
40
|
+
: {
|
|
41
|
+
cause: infrastructureFailure.cause,
|
|
42
|
+
diagnostic: infrastructureFailure.diagnostic,
|
|
43
|
+
...(infrastructureFailure.identity === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { identity: infrastructureFailure.identity }),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
...(options?.beforeDispatch === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: { beforeDispatch: options.beforeDispatch }),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function admitInstructionSeat(role, options) {
|
|
54
|
+
switch (role) {
|
|
55
|
+
case "gatekeeper":
|
|
56
|
+
return admitGatekeeperInvocation(options);
|
|
57
|
+
case "navigator":
|
|
58
|
+
return admitNavigatorInvocation(options);
|
|
59
|
+
case "auditor":
|
|
60
|
+
return admitAuditorInvocation(options);
|
|
61
|
+
case "evidence-child":
|
|
62
|
+
return admitEvidenceChildInvocation(options);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function runPublicInstructionSeatResume(request, env, io) {
|
|
66
|
+
return await runPostAdmissionSeatResume({
|
|
67
|
+
request,
|
|
68
|
+
env,
|
|
69
|
+
io,
|
|
70
|
+
load: (effective) => loadResumableInstructionSeatRun(env.home, effective.runId, env.principalAuthority),
|
|
71
|
+
buildTurnRequest: async (admitted, effective) => {
|
|
72
|
+
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
73
|
+
return buildInstructionSeatTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared));
|
|
74
|
+
},
|
|
75
|
+
adapters: instructionSeatAdapters(),
|
|
76
|
+
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** Scope auditor subject/source-run env for the duration of one seat turn. */
|
|
80
|
+
async function withAuditorSoulEnv(options) {
|
|
81
|
+
if (options.subject === undefined && options.sourceRunDirectory === undefined) {
|
|
82
|
+
return options.run();
|
|
83
|
+
}
|
|
84
|
+
const { AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV } = await import("../auditor-soul.js");
|
|
85
|
+
const priorSubject = process.env[AK_ROLE_AUDITOR_SUBJECT_ENV];
|
|
86
|
+
const priorSource = process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV];
|
|
87
|
+
if (options.subject !== undefined) {
|
|
88
|
+
process.env[AK_ROLE_AUDITOR_SUBJECT_ENV] = options.subject;
|
|
89
|
+
}
|
|
90
|
+
if (options.sourceRunDirectory !== undefined) {
|
|
91
|
+
process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] = options.sourceRunDirectory;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
return await options.run();
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
if (options.subject !== undefined) {
|
|
98
|
+
if (priorSubject === undefined)
|
|
99
|
+
delete process.env[AK_ROLE_AUDITOR_SUBJECT_ENV];
|
|
100
|
+
else
|
|
101
|
+
process.env[AK_ROLE_AUDITOR_SUBJECT_ENV] = priorSubject;
|
|
102
|
+
}
|
|
103
|
+
if (options.sourceRunDirectory !== undefined) {
|
|
104
|
+
if (priorSource === undefined)
|
|
105
|
+
delete process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV];
|
|
106
|
+
else
|
|
107
|
+
process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] = priorSource;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = parseArgv(argv);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error instanceof CliUsageError) {
|
|
118
|
+
presentStructuralRejection(error, io);
|
|
119
|
+
return { exitCode: 2 };
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
let auditorSubject;
|
|
124
|
+
let auditorSourceRun;
|
|
125
|
+
let auditorSourceTicket;
|
|
126
|
+
let ticketProbe;
|
|
127
|
+
// #637: same ticket → resume prior seat run with this summons' materials.
|
|
128
|
+
// Auditor inherits ticket from source-run (notary face); other instruction seats
|
|
129
|
+
// probe instruction (inspector face). No bare catch→fresh: lookup/resume failures
|
|
130
|
+
// surface; only true absence of a prior run mints new.
|
|
131
|
+
const projectRoot = parsed.project ?? env.cwd;
|
|
132
|
+
if (role === "auditor") {
|
|
133
|
+
if (parsed.subject !== "judge" && parsed.subject !== "doctor") {
|
|
134
|
+
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
135
|
+
return { exitCode: 2 };
|
|
136
|
+
}
|
|
137
|
+
auditorSubject = parsed.subject;
|
|
138
|
+
const source = typeof parsed.sourceRun === "string" ? parsed.sourceRun.trim() : "";
|
|
139
|
+
if (source === "") {
|
|
140
|
+
presentStructuralRejection(new CliUsageError("auditor --source-run requires a run locator"), io);
|
|
141
|
+
return { exitCode: 2 };
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const { resolveNotarySourceRunLocator } = await import("../notary-source-run.js");
|
|
145
|
+
const resolved = await resolveNotarySourceRunLocator({
|
|
146
|
+
projectRoot,
|
|
147
|
+
sourceRun: source,
|
|
148
|
+
home: env.home,
|
|
149
|
+
});
|
|
150
|
+
auditorSourceRun = resolved.runDirectory;
|
|
151
|
+
auditorSourceTicket = await readRunTicketNumber(resolved.runDirectory);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
presentStructuralRejection(new CliUsageError(error instanceof Error ? error.message : String(error)), io);
|
|
155
|
+
return { exitCode: 2 };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Inspector face: unconditional probe (same seam as inspector-run.ts).
|
|
160
|
+
ticketProbe = await probeInstructionTicket(parsed.instruction, projectRoot, env);
|
|
161
|
+
}
|
|
162
|
+
const probedTicketNumber = auditorSourceTicket
|
|
163
|
+
?? (ticketProbe === undefined ? undefined : ticketNumberFromProbe(ticketProbe));
|
|
164
|
+
if (probedTicketNumber !== undefined) {
|
|
165
|
+
const summons = {
|
|
166
|
+
instruction: parsed.instruction,
|
|
167
|
+
instructionEmpty: parsed.instruction.trim() === "",
|
|
168
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
169
|
+
};
|
|
170
|
+
const resumed = await withAuditorSoulEnv({
|
|
171
|
+
...(auditorSubject === undefined ? {} : { subject: auditorSubject }),
|
|
172
|
+
...(auditorSourceRun === undefined
|
|
173
|
+
? {}
|
|
174
|
+
: { sourceRunDirectory: auditorSourceRun }),
|
|
175
|
+
run: () => tryResumeSameTicketSeatRun({
|
|
176
|
+
home: env.home,
|
|
177
|
+
projectRoot,
|
|
178
|
+
role,
|
|
179
|
+
ticketNumber: probedTicketNumber,
|
|
180
|
+
freshSummons: env.freshSummons,
|
|
181
|
+
summons,
|
|
182
|
+
resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
if (resumed !== undefined)
|
|
186
|
+
return resumed;
|
|
187
|
+
}
|
|
188
|
+
let admitted;
|
|
189
|
+
try {
|
|
190
|
+
admitted = await admitInstructionSeat(role, {
|
|
191
|
+
home: env.home,
|
|
192
|
+
principalAuthority: env.principalAuthority,
|
|
193
|
+
cwd: env.cwd,
|
|
194
|
+
instruction: parsed.instruction,
|
|
195
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
196
|
+
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
197
|
+
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
198
|
+
...(env.model === undefined ? {} : { model: env.model }),
|
|
199
|
+
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (error instanceof CliUsageError) {
|
|
204
|
+
presentStructuralRejection(error, io);
|
|
205
|
+
return { exitCode: 2 };
|
|
206
|
+
}
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
return await withAuditorSoulEnv({
|
|
210
|
+
...(auditorSubject === undefined ? {} : { subject: auditorSubject }),
|
|
211
|
+
...(auditorSourceRun === undefined
|
|
212
|
+
? {}
|
|
213
|
+
: { sourceRunDirectory: auditorSourceRun }),
|
|
214
|
+
run: async () => {
|
|
215
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
216
|
+
const turnRequest = buildInstructionSeatTurnRequest(admitted, {
|
|
217
|
+
packageRoot: env.packageRoot,
|
|
218
|
+
home: env.home,
|
|
219
|
+
agentDir: env.agentDir,
|
|
220
|
+
...(env.model === undefined ? {} : { model: env.model }),
|
|
221
|
+
...(env.engine === undefined ? {} : { engine: env.engine }),
|
|
222
|
+
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
223
|
+
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
224
|
+
? {}
|
|
225
|
+
: { correlationId: env.correlationId }),
|
|
226
|
+
continuation: {
|
|
227
|
+
kind: "initial",
|
|
228
|
+
prompt: buildInstructionTransportPrompt(admitted, engineSessionMaterialFromOptions({
|
|
229
|
+
...(env.engine === undefined ? {} : { engine: env.engine }),
|
|
230
|
+
packageRoot: env.packageRoot,
|
|
231
|
+
})),
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
return await runPostAdmissionOneShot({
|
|
235
|
+
admitted,
|
|
236
|
+
env,
|
|
237
|
+
io,
|
|
238
|
+
request: turnRequest,
|
|
239
|
+
adapters: instructionSeatAdapters({
|
|
240
|
+
beforeDispatch: async (admittedSeat) => {
|
|
241
|
+
// #635/#637: ticket bind inside controlled-failure boundary.
|
|
242
|
+
// Auditor inherits source-run ticket (notary face).
|
|
243
|
+
// Other seats: same applyInstructionTicketProbe as inspector-run.
|
|
244
|
+
if (auditorSourceTicket !== undefined) {
|
|
245
|
+
await bindAdmittedTicketNumber(admittedSeat, auditorSourceTicket);
|
|
246
|
+
}
|
|
247
|
+
else if (ticketProbe !== undefined) {
|
|
248
|
+
await applyInstructionTicketProbe(admittedSeat, ticketProbe);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
}
|