@akagilnc/pi-workflow-roles 0.1.4802 → 0.1.4874
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 +19434 -18218
- package/dist/analyst-book-key.js +63 -0
- package/dist/analyst-cohort.js +167 -0
- package/dist/analyst-entry.js +320 -0
- package/dist/analyst-index.js +247 -0
- package/dist/analyst-ledger.js +561 -0
- package/dist/analyst-median.js +16 -0
- package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
- package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
- package/dist/analyst-metric-families/gate-cycles.js +77 -0
- package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
- package/dist/analyst-metric-families/round-timeline.js +126 -0
- package/dist/analyst-metric-families.js +23 -0
- package/dist/analyst-metric-family.js +11 -0
- package/dist/analyst-model-groups.js +135 -0
- package/dist/analyst-page.js +182 -0
- package/dist/atomic-write.js +23 -0
- package/dist/auditor-soul.js +1 -1
- package/dist/countersign-contracts.js +0 -2
- package/dist/diarist-contracts.js +0 -1
- package/dist/doctor-contracts.js +2 -2
- package/dist/gatekeeper-role.js +15 -16
- package/dist/gleaner-left-contracts.js +0 -2
- package/dist/headless-host/production-host.js +16967 -15749
- package/dist/host-contracts.js +0 -4
- package/dist/inspector-contracts.js +0 -2
- package/dist/institutional-resolution.js +4 -2
- package/dist/merger-contracts.js +0 -2
- package/dist/migrate-book-topology.js +3908 -3089
- package/dist/navigator-public-session.js +4 -3
- package/dist/notary-contracts.js +0 -2
- package/dist/package-contracts/auditor-output.js +0 -1
- package/dist/package-contracts/collector-output.js +0 -2
- package/dist/package-contracts/fixer-output.js +0 -2
- package/dist/package-contracts/gatekeeper-output.js +0 -2
- package/dist/package-contracts/judge-output.js +0 -2
- package/dist/package-contracts/navigator-output.js +0 -2
- package/dist/package-contracts/reviewer-output.js +0 -2
- package/dist/package-contracts/terminating-tools.js +32 -92
- package/dist/package-contracts/worker-output.js +0 -4
- package/dist/packaged-role-registry.js +518 -36
- package/dist/pi/role-turn-host.js +2 -1
- package/dist/public-cli/analyst-run.js +185 -0
- package/dist/public-cli/cli.js +885 -0
- package/dist/public-cli/config.js +12 -9
- package/dist/public-cli/countersign-run.js +4 -311
- package/dist/public-cli/instruction-seat-run.js +628 -158
- package/dist/public-cli/invocation.js +806 -1550
- package/dist/public-cli/main.js +6962 -9882
- package/dist/public-cli/option-definitions.js +51 -99
- package/dist/public-cli/post-admission.js +30 -2
- package/dist/public-cli/run-lifecycle.js +234 -353
- package/dist/public-cli/seat-ticket-binding.js +6 -0
- package/dist/public-cli/settlement.js +261 -675
- package/dist/public-cli/turn-request.js +76 -0
- package/dist/public-role-summons.js +38 -112
- package/dist/role-activation-flags.js +23 -45
- package/dist/secretariat-contracts.js +0 -2
- package/dist/session-identity.js +17 -8
- package/dist/session-opening-materials.js +3 -2
- package/extensions/role-runtime.ts +6 -80
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +4 -1
- package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
- package/src/auditor-role.ts +1 -2
- package/src/auditor-soul.ts +1 -1
- package/src/collector-role.ts +2 -2
- package/src/countersign-contracts.ts +0 -1
- package/src/countersign-role.ts +1 -1
- package/src/diarist-contracts.ts +0 -1
- package/src/diarist-role.ts +0 -1
- package/src/doctor-auditor.ts +1 -2
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-role.ts +3 -2
- package/src/external-host-turn-loop.ts +1 -1
- package/src/factory-board.ts +10 -7
- package/src/gatekeeper-role.ts +16 -10
- package/src/gleaner-left-contracts.ts +0 -1
- package/src/gleaner-left-role.ts +0 -1
- package/src/headless-host/role-turn-host.ts +7 -1
- package/src/host-contracts.ts +10 -6
- package/src/inspector-contracts.ts +0 -1
- package/src/inspector-role.ts +0 -2
- package/src/institutional-resolution.ts +6 -4
- package/src/judge-role.ts +3 -3
- package/src/merger-contracts.ts +0 -1
- package/src/merger-role.ts +2 -2
- package/src/navigator-public-session.ts +7 -6
- package/src/navigator-work-context.ts +6 -8
- package/src/notary-contracts.ts +0 -1
- package/src/notary-role.ts +2 -3
- package/src/package-contracts/auditor-output.ts +0 -1
- package/src/package-contracts/collector-output.ts +0 -1
- package/src/package-contracts/fixer-output.ts +0 -1
- package/src/package-contracts/gatekeeper-output.ts +0 -1
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/navigator-output.ts +0 -1
- package/src/package-contracts/reviewer-output.ts +0 -1
- package/src/package-contracts/terminating-tools.ts +27 -99
- package/src/package-contracts/worker-output.ts +0 -2
- package/src/packaged-role-registry.ts +604 -35
- package/src/pi/role-turn-host.ts +2 -1
- package/src/public-cli/cli.ts +64 -259
- package/src/public-cli/config.ts +18 -10
- package/src/public-cli/countersign-run.ts +14 -449
- package/src/public-cli/instruction-seat-run.ts +758 -277
- package/src/public-cli/invocation.ts +1097 -2051
- package/src/public-cli/option-definitions.ts +62 -127
- package/src/public-cli/post-admission.ts +47 -2
- package/src/public-cli/run-lifecycle.ts +303 -613
- package/src/public-cli/seat-ticket-binding.ts +6 -0
- package/src/public-cli/settlement.ts +399 -1185
- package/src/public-cli/turn-request.ts +92 -1
- package/src/public-role-summons.ts +44 -128
- package/src/reviewer-role.ts +3 -2
- package/src/role-activation-flags.ts +20 -41
- package/src/role-runtime-dependencies.ts +25 -26
- package/src/role-runtime.ts +121 -232
- package/src/secretariat-contracts.ts +0 -1
- package/src/secretariat-role.ts +0 -2
- package/src/session-identity.ts +23 -8
- package/src/session-opening-materials.ts +2 -1
- package/src/worker-role.ts +3 -4
- package/dist/doctor-auditor.js +0 -25
- package/dist/public-cli/diarist-run.js +0 -130
- package/dist/public-cli/doctor-run.js +0 -87
- package/dist/public-cli/inspector-run.js +0 -151
- package/dist/public-cli/judge-run.js +0 -114
- package/dist/public-cli/notary-run.js +0 -174
- package/dist/public-cli/reviewer-run.js +0 -339
- package/src/public-cli/coder-run.ts +0 -255
- package/src/public-cli/collector-run.ts +0 -189
- package/src/public-cli/diarist-run.ts +0 -233
- package/src/public-cli/doctor-run.ts +0 -167
- package/src/public-cli/fixer-run.ts +0 -265
- package/src/public-cli/gleaner-left-run.ts +0 -167
- package/src/public-cli/inspector-run.ts +0 -261
- package/src/public-cli/judge-run.ts +0 -196
- package/src/public-cli/merger-run.ts +0 -294
- package/src/public-cli/notary-run.ts +0 -279
- package/src/public-cli/reviewer-run.ts +0 -480
- package/src/public-cli/secretariat-run.ts +0 -265
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public Reviewer Role run: admit → post-admission coordinator → settle Terminal result (#917 / #517).
|
|
3
|
-
* Package-owned ak-cross-m-review method is forced; users never submit
|
|
4
|
-
* extra packets. Controlled-failure settlement reuses #107.
|
|
5
|
-
* #526: execution via RoleTurnHost; argv is Pi adapter internal.
|
|
6
|
-
*/
|
|
7
|
-
import { resolve } from "node:path";
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
DurablePrincipalAuthority,
|
|
11
|
-
MethodBinding,
|
|
12
|
-
RoleTurnKnownFailure,
|
|
13
|
-
RoleTurnRequest,
|
|
14
|
-
} from "../host-contracts.ts";
|
|
15
|
-
import {
|
|
16
|
-
appendEngineSessionMaterial,
|
|
17
|
-
engineSessionMaterialFromOptions,
|
|
18
|
-
pickEngineAxis,
|
|
19
|
-
} from "../package-resources/engine-material.ts";
|
|
20
|
-
import {
|
|
21
|
-
loadPackagedMethodSkillMaterial,
|
|
22
|
-
resolvePackagedMethodSkillPath,
|
|
23
|
-
type PackagedMethodSkillMaterial,
|
|
24
|
-
type PackagedMethodSkillProvenance,
|
|
25
|
-
} from "../package-resources/method-skill.ts";
|
|
26
|
-
import { CliUsageError } from "./cli-errors.ts";
|
|
27
|
-
import {
|
|
28
|
-
admitReviewerInvocation,
|
|
29
|
-
buildReviewerTransportPrompt,
|
|
30
|
-
type AdmittedReviewerInvocation,
|
|
31
|
-
type ReviewerLens,
|
|
32
|
-
} from "./invocation.ts";
|
|
33
|
-
import {
|
|
34
|
-
loadResumableReviewerRun,
|
|
35
|
-
markRunAdmitted,
|
|
36
|
-
RESUME_TRANSPORT_ENVELOPE,
|
|
37
|
-
type PublicResumeRequest,
|
|
38
|
-
} from "./run-lifecycle.ts";
|
|
39
|
-
import {
|
|
40
|
-
presentStructuralRejection,
|
|
41
|
-
readEngineDetourInfrastructureFailure,
|
|
42
|
-
trySettleReviewerTerminalResult,
|
|
43
|
-
} from "./settlement.ts";
|
|
44
|
-
import type { CliIo } from "./cli-io.ts";
|
|
45
|
-
import {
|
|
46
|
-
formatTerminalResult,
|
|
47
|
-
isLawfulTypedTerminalOutcome,
|
|
48
|
-
type TerminalResult,
|
|
49
|
-
} from "./terminal.ts";
|
|
50
|
-
import {
|
|
51
|
-
projectRoleTurnRequest,
|
|
52
|
-
type RoleTurnRequestProjectionOptions,
|
|
53
|
-
} from "./turn-request.ts";
|
|
54
|
-
import {
|
|
55
|
-
presentControlledFailure,
|
|
56
|
-
resolveResumeMethodMaterialAdapters,
|
|
57
|
-
runPostAdmissionResumable,
|
|
58
|
-
runPostAdmissionSeatResume,
|
|
59
|
-
type PostAdmissionAdapters,
|
|
60
|
-
type PostAdmissionEnv,
|
|
61
|
-
resumeTurnRequestProjectionOptions,
|
|
62
|
-
} from "./post-admission.ts";
|
|
63
|
-
|
|
64
|
-
export type ReviewerRunEnv = PostAdmissionEnv & {
|
|
65
|
-
createRunId?: () => string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
type ReviewerRunResult = {
|
|
69
|
-
exitCode: number;
|
|
70
|
-
admitted?: AdmittedReviewerInvocation;
|
|
71
|
-
terminal?: TerminalResult;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
function reviewerMethods(packageRoot: string): readonly MethodBinding[] {
|
|
75
|
-
return [{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "ak-cross-m-review") }];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* All Reviewer turns (explicit --lens, dual-lens child, resume) execute in a
|
|
80
|
-
* fresh worktree of the source tree's current HEAD (#946 统一新副本). Dual-lens
|
|
81
|
-
* summon already injects executionCwd; only mint when absent. Cleanup failure
|
|
82
|
-
* is diagnostic only and does not flip the exit code. Mint failure propagates
|
|
83
|
-
* so the caller can settle a controlled failure against the admitted run.
|
|
84
|
-
*/
|
|
85
|
-
async function runReviewerTurnInFreshCopy(
|
|
86
|
-
env: ReviewerRunEnv,
|
|
87
|
-
projectRoot: string,
|
|
88
|
-
io: CliIo,
|
|
89
|
-
body: (sandboxedEnv: ReviewerRunEnv) => Promise<ReviewerRunResult>,
|
|
90
|
-
): Promise<ReviewerRunResult> {
|
|
91
|
-
if (env.executionCwd !== undefined) {
|
|
92
|
-
return body(env);
|
|
93
|
-
}
|
|
94
|
-
const { withEphemeralReviewerWorktree } = await import("../public-role-summons.ts");
|
|
95
|
-
return await withEphemeralReviewerWorktree({
|
|
96
|
-
projectRoot,
|
|
97
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
98
|
-
io.stderr(`${diagnostic}\n`);
|
|
99
|
-
},
|
|
100
|
-
run: (executionCwd) => body({ ...env, executionCwd }),
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Project admitted Reviewer invocation onto the host-neutral turn request. */
|
|
105
|
-
export function buildReviewerTurnRequest(
|
|
106
|
-
admitted: AdmittedReviewerInvocation,
|
|
107
|
-
options: RoleTurnRequestProjectionOptions,
|
|
108
|
-
): RoleTurnRequest {
|
|
109
|
-
return projectRoleTurnRequest(
|
|
110
|
-
admitted,
|
|
111
|
-
{
|
|
112
|
-
activation: {
|
|
113
|
-
role: "reviewer",
|
|
114
|
-
baseRevision: admitted.baseRevision,
|
|
115
|
-
lens: admitted.lens,
|
|
116
|
-
authorityRefs: admitted.authorityRefs,
|
|
117
|
-
...(admitted.ticketNumber === undefined ? {} : { ticketNumber: admitted.ticketNumber }),
|
|
118
|
-
},
|
|
119
|
-
methods: reviewerMethods(options.packageRoot),
|
|
120
|
-
},
|
|
121
|
-
options,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function reviewerAdapters(
|
|
126
|
-
packageRoot: string,
|
|
127
|
-
methodMaterial?: PackagedMethodSkillMaterial,
|
|
128
|
-
): PostAdmissionAdapters<AdmittedReviewerInvocation> {
|
|
129
|
-
return {
|
|
130
|
-
trySettle: (admitted, authority, scope) =>
|
|
131
|
-
methodMaterial === undefined
|
|
132
|
-
? Promise.resolve(undefined)
|
|
133
|
-
: trySettleReviewerTerminalResult(
|
|
134
|
-
admitted,
|
|
135
|
-
authority,
|
|
136
|
-
{
|
|
137
|
-
methodProvenance: methodMaterial.provenance,
|
|
138
|
-
methodSkillPath: methodMaterial.skillPath,
|
|
139
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
140
|
-
packageRoot,
|
|
141
|
-
"ak-cross-m-review",
|
|
142
|
-
),
|
|
143
|
-
},
|
|
144
|
-
scope,
|
|
145
|
-
),
|
|
146
|
-
resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
|
|
147
|
-
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
148
|
-
return infrastructureFailure === undefined
|
|
149
|
-
? result.knownFailure
|
|
150
|
-
: {
|
|
151
|
-
...(infrastructureFailure.cause === undefined
|
|
152
|
-
? {}
|
|
153
|
-
: { cause: infrastructureFailure.cause }),
|
|
154
|
-
diagnostic: infrastructureFailure.diagnostic,
|
|
155
|
-
...(infrastructureFailure.identity === undefined
|
|
156
|
-
? {}
|
|
157
|
-
: { identity: infrastructureFailure.identity }),
|
|
158
|
-
};
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async function loadReviewerMethodMaterial(
|
|
164
|
-
packageRoot: string,
|
|
165
|
-
): Promise<PackagedMethodSkillMaterial> {
|
|
166
|
-
return await loadPackagedMethodSkillMaterial(packageRoot, "ak-cross-m-review");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** Continue the existing method turn; frozen axes remain on typed activation fields. */
|
|
170
|
-
function reviewerResumePrompt(env: ReviewerRunEnv, message?: string): string {
|
|
171
|
-
const lines: string[] = [RESUME_TRANSPORT_ENVELOPE];
|
|
172
|
-
if (message !== undefined) lines.push("", message);
|
|
173
|
-
return appendEngineSessionMaterial(
|
|
174
|
-
lines,
|
|
175
|
-
engineSessionMaterialFromOptions({
|
|
176
|
-
...pickEngineAxis(env),
|
|
177
|
-
packageRoot: env.packageRoot,
|
|
178
|
-
}),
|
|
179
|
-
).join("\n");
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export async function runPublicReviewer(
|
|
183
|
-
argv: readonly string[],
|
|
184
|
-
env: ReviewerRunEnv,
|
|
185
|
-
io: CliIo,
|
|
186
|
-
parseReviewerArgv: (args: readonly string[]) => {
|
|
187
|
-
instruction: string;
|
|
188
|
-
attachmentPaths: string[];
|
|
189
|
-
baseRevision: string;
|
|
190
|
-
lens?: ReviewerLens;
|
|
191
|
-
authorityRefs: string[];
|
|
192
|
-
project?: string;
|
|
193
|
-
},
|
|
194
|
-
): Promise<{
|
|
195
|
-
exitCode: number;
|
|
196
|
-
admitted?: AdmittedReviewerInvocation;
|
|
197
|
-
terminal?: TerminalResult;
|
|
198
|
-
}> {
|
|
199
|
-
let parsed: ReturnType<typeof parseReviewerArgv>;
|
|
200
|
-
try {
|
|
201
|
-
parsed = parseReviewerArgv(argv);
|
|
202
|
-
} catch (error) {
|
|
203
|
-
if (error instanceof CliUsageError) {
|
|
204
|
-
presentStructuralRejection(error, io);
|
|
205
|
-
return { exitCode: 2 };
|
|
206
|
-
}
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Omitted public lens is the parallel two-axis branch mark; never admitted as a parent run.
|
|
211
|
-
// Each leg reuses this call's public argv and only adds --lens (#946 / 10a).
|
|
212
|
-
if (parsed.lens === undefined) {
|
|
213
|
-
const { summonParallelReviewerLenses } = await import("../public-role-summons.ts");
|
|
214
|
-
const children = await summonParallelReviewerLenses({
|
|
215
|
-
argv,
|
|
216
|
-
// Replay argv under the same cwd the single-axis entry would see (10a).
|
|
217
|
-
// Do not substitute the resolved project path — relative --project must
|
|
218
|
-
// not be re-resolved against a shifted cwd.
|
|
219
|
-
cwd: env.cwd,
|
|
220
|
-
projectRoot: resolve(parsed.project ?? env.cwd),
|
|
221
|
-
// Typed base from the public parse — precheck only; child argv stays verbatim.
|
|
222
|
-
baseRevision: parsed.baseRevision,
|
|
223
|
-
home: env.home,
|
|
224
|
-
agentDir: env.agentDir,
|
|
225
|
-
...(env.credentials === undefined ? {} : { credentials: env.credentials }),
|
|
226
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
227
|
-
...(env.host === undefined ? {} : { host: env.host }),
|
|
228
|
-
...(env.engine === undefined ? {} : { engine: env.engine }),
|
|
229
|
-
...(env.engineModel === undefined ? {} : { engineModel: env.engineModel }),
|
|
230
|
-
packageRoot: env.packageRoot,
|
|
231
|
-
...(env.signal === undefined ? {} : { signal: env.signal }),
|
|
232
|
-
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
233
|
-
roleTurnHost: env.roleTurnHost,
|
|
234
|
-
...(env.hostAdapters === undefined ? {} : { hostAdapters: env.hostAdapters }),
|
|
235
|
-
principalAuthority: env.principalAuthority,
|
|
236
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
237
|
-
});
|
|
238
|
-
const childResults = [children.completeness, children.correctness] as const;
|
|
239
|
-
const terminals = childResults
|
|
240
|
-
.map((child) => child.terminal)
|
|
241
|
-
.filter((terminal): terminal is TerminalResult => terminal !== undefined);
|
|
242
|
-
// ADR 0052 / terminal.ts: lawful typed child terminals (accepted / no_receipt /
|
|
243
|
-
// audit_escalation) are not batch failures. Child exitCode remains the live
|
|
244
|
-
// surface for seal/infrastructure overlays that keep the original Terminal.
|
|
245
|
-
// failedChildren counts only non-lawful/missing child Terminals; seal overlays
|
|
246
|
-
// that flip exitCode while keeping lawful Terminals are a separate identity.
|
|
247
|
-
const failedChildren = childResults.filter((child) =>
|
|
248
|
-
child.terminal === undefined
|
|
249
|
-
|| !isLawfulTypedTerminalOutcome(child.terminal.roleOutcome)).length;
|
|
250
|
-
const overlayExit = childResults.some((child) => child.exitCode !== 0);
|
|
251
|
-
const failed = failedChildren > 0 || overlayExit;
|
|
252
|
-
const overlayDiagnostics = [...new Set(
|
|
253
|
-
childResults
|
|
254
|
-
.map((child) => child.stderr)
|
|
255
|
-
.filter((text): text is string => typeof text === "string" && text !== ""),
|
|
256
|
-
)];
|
|
257
|
-
const terminal: TerminalResult = {
|
|
258
|
-
batch: "reviewer",
|
|
259
|
-
roleOutcome: failed
|
|
260
|
-
? {
|
|
261
|
-
kind: "failure",
|
|
262
|
-
role: "reviewer",
|
|
263
|
-
diagnostic: failedChildren > 0
|
|
264
|
-
? "Reviewer batch child failure"
|
|
265
|
-
: (overlayDiagnostics[0] ?? "Reviewer batch infrastructure failure"),
|
|
266
|
-
decisiveFacts: { failedChildren },
|
|
267
|
-
payloads: terminals,
|
|
268
|
-
}
|
|
269
|
-
: { kind: "accepted", role: "reviewer", payloads: terminals },
|
|
270
|
-
reviewerChildren: {
|
|
271
|
-
...(children.completeness.terminal === undefined ? {} : { completeness: children.completeness.terminal }),
|
|
272
|
-
...(children.correctness.terminal === undefined ? {} : { correctness: children.correctness.terminal }),
|
|
273
|
-
},
|
|
274
|
-
reviewerChildOutcomes: {
|
|
275
|
-
completeness: { exitCode: children.completeness.exitCode, ...(children.completeness.stderr === undefined ? {} : { stderr: children.completeness.stderr }) },
|
|
276
|
-
correctness: { exitCode: children.correctness.exitCode, ...(children.correctness.stderr === undefined ? {} : { stderr: children.correctness.stderr }) },
|
|
277
|
-
},
|
|
278
|
-
// Batch has no parent run and no own attendance; no-advice is affirmative
|
|
279
|
-
// only (navigator-attendance.ts). Children carry their own navigator facts.
|
|
280
|
-
navigator: {
|
|
281
|
-
disposition: "unavailable",
|
|
282
|
-
source: "unknown",
|
|
283
|
-
reason: "Reviewer batch has no parent-run Navigator attendance",
|
|
284
|
-
},
|
|
285
|
-
artifacts: terminals.flatMap((item) => item.artifacts),
|
|
286
|
-
};
|
|
287
|
-
io.stdout(formatTerminalResult(terminal));
|
|
288
|
-
return { exitCode: failed ? 1 : 0, terminal };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
let admitted: AdmittedReviewerInvocation;
|
|
292
|
-
try {
|
|
293
|
-
admitted = await admitReviewerInvocation({
|
|
294
|
-
home: env.home,
|
|
295
|
-
principalAuthority: env.principalAuthority,
|
|
296
|
-
cwd: env.cwd,
|
|
297
|
-
instruction: parsed.instruction,
|
|
298
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
299
|
-
baseRevision: parsed.baseRevision,
|
|
300
|
-
lens: parsed.lens,
|
|
301
|
-
authorityRefs: parsed.authorityRefs,
|
|
302
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
303
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
304
|
-
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
305
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
306
|
-
});
|
|
307
|
-
} catch (error) {
|
|
308
|
-
if (error instanceof CliUsageError) {
|
|
309
|
-
presentStructuralRejection(error, io);
|
|
310
|
-
return { exitCode: 2 };
|
|
311
|
-
}
|
|
312
|
-
throw error;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
316
|
-
|
|
317
|
-
let methodMaterial: PackagedMethodSkillMaterial;
|
|
318
|
-
try {
|
|
319
|
-
methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
|
|
320
|
-
} catch (error) {
|
|
321
|
-
return (await presentControlledFailure(
|
|
322
|
-
admitted,
|
|
323
|
-
{
|
|
324
|
-
timedOut: false,
|
|
325
|
-
code: null,
|
|
326
|
-
stderr: "",
|
|
327
|
-
thrown: error,
|
|
328
|
-
},
|
|
329
|
-
reviewerAdapters(env.packageRoot),
|
|
330
|
-
env.principalAuthority,
|
|
331
|
-
io,
|
|
332
|
-
)) as { exitCode: number; admitted: AdmittedReviewerInvocation; terminal: TerminalResult };
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Fresh copy for this call (explicit --lens or dual-lens child with pre-set cwd).
|
|
336
|
-
// Durable projectRoot stays the caller project; only the host turn uses the sandbox.
|
|
337
|
-
try {
|
|
338
|
-
return await runReviewerTurnInFreshCopy(env, admitted.projectRoot, io, async (sandboxedEnv) =>
|
|
339
|
-
await runPostAdmissionResumable({
|
|
340
|
-
admitted,
|
|
341
|
-
env: sandboxedEnv,
|
|
342
|
-
io,
|
|
343
|
-
buildInitialRequest: () =>
|
|
344
|
-
buildReviewerTurnRequest(admitted, {
|
|
345
|
-
packageRoot: sandboxedEnv.packageRoot,
|
|
346
|
-
home: sandboxedEnv.home,
|
|
347
|
-
agentDir: sandboxedEnv.agentDir,
|
|
348
|
-
...(sandboxedEnv.model === undefined ? {} : { model: sandboxedEnv.model }),
|
|
349
|
-
...pickEngineAxis(sandboxedEnv),
|
|
350
|
-
...(sandboxedEnv.timeoutMs === undefined ? {} : { timeoutMs: sandboxedEnv.timeoutMs }),
|
|
351
|
-
...(admitted.correlationId === undefined && sandboxedEnv.correlationId === undefined
|
|
352
|
-
? {}
|
|
353
|
-
: { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId }),
|
|
354
|
-
// Ephemeral worktree cwd; durable projectRoot stays on admitted caller project.
|
|
355
|
-
...(sandboxedEnv.executionCwd === undefined ? {} : { cwd: sandboxedEnv.executionCwd }),
|
|
356
|
-
continuation: {
|
|
357
|
-
kind: "initial",
|
|
358
|
-
prompt: buildReviewerTransportPrompt(
|
|
359
|
-
admitted,
|
|
360
|
-
engineSessionMaterialFromOptions({
|
|
361
|
-
...pickEngineAxis(sandboxedEnv),
|
|
362
|
-
packageRoot: sandboxedEnv.packageRoot,
|
|
363
|
-
}),
|
|
364
|
-
),
|
|
365
|
-
},
|
|
366
|
-
}),
|
|
367
|
-
buildResumeRequest: () =>
|
|
368
|
-
buildReviewerTurnRequest(admitted, {
|
|
369
|
-
packageRoot: sandboxedEnv.packageRoot,
|
|
370
|
-
home: sandboxedEnv.home,
|
|
371
|
-
agentDir: sandboxedEnv.agentDir,
|
|
372
|
-
...(sandboxedEnv.model === undefined ? {} : { model: sandboxedEnv.model }),
|
|
373
|
-
...pickEngineAxis(sandboxedEnv),
|
|
374
|
-
...(sandboxedEnv.timeoutMs === undefined ? {} : { timeoutMs: sandboxedEnv.timeoutMs }),
|
|
375
|
-
...(admitted.correlationId === undefined && sandboxedEnv.correlationId === undefined
|
|
376
|
-
? {}
|
|
377
|
-
: { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId }),
|
|
378
|
-
// In-batch auto-resume keeps the same call's sandbox (dual-lens or single).
|
|
379
|
-
...(sandboxedEnv.executionCwd === undefined ? {} : { cwd: sandboxedEnv.executionCwd }),
|
|
380
|
-
continuation: {
|
|
381
|
-
kind: "resume",
|
|
382
|
-
prompt: reviewerResumePrompt(sandboxedEnv),
|
|
383
|
-
},
|
|
384
|
-
}),
|
|
385
|
-
adapters: reviewerAdapters(sandboxedEnv.packageRoot, methodMaterial),
|
|
386
|
-
...(sandboxedEnv.engine === undefined ? {} : { effectiveEngine: sandboxedEnv.engine }),
|
|
387
|
-
}));
|
|
388
|
-
} catch (error) {
|
|
389
|
-
return (await presentControlledFailure(
|
|
390
|
-
admitted,
|
|
391
|
-
{
|
|
392
|
-
timedOut: false,
|
|
393
|
-
code: null,
|
|
394
|
-
stderr: "",
|
|
395
|
-
thrown: error,
|
|
396
|
-
},
|
|
397
|
-
reviewerAdapters(env.packageRoot, methodMaterial),
|
|
398
|
-
env.principalAuthority,
|
|
399
|
-
io,
|
|
400
|
-
)) as ReviewerRunResult;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Resume a previously admitted Reviewer Role run after a typed HTTP 429.
|
|
406
|
-
* Restores task/base/session identity; model override is temporary.
|
|
407
|
-
* Execution always uses a fresh worktree of the source tree at resume time
|
|
408
|
-
* (#946 统一新副本 / 10a) — no old worktree, no ownership record.
|
|
409
|
-
* Fresh-copy mint reuses the coordinator's single pre-lease load via
|
|
410
|
-
* afterAdmittedPrepare; does not pre-load outside the coordinator.
|
|
411
|
-
*/
|
|
412
|
-
export async function runPublicReviewerResume(
|
|
413
|
-
request: PublicResumeRequest,
|
|
414
|
-
env: ReviewerRunEnv,
|
|
415
|
-
io: CliIo,
|
|
416
|
-
): Promise<{
|
|
417
|
-
exitCode: number;
|
|
418
|
-
admitted?: AdmittedReviewerInvocation;
|
|
419
|
-
terminal?: TerminalResult;
|
|
420
|
-
}> {
|
|
421
|
-
// Call-local cell: afterAdmittedPrepare writes executionCwd; buildTurnRequest reads it.
|
|
422
|
-
// Keeps the single-load coordinator contract — no preliminary load outside.
|
|
423
|
-
const sandbox: { executionCwd?: string } = {
|
|
424
|
-
...(env.executionCwd === undefined ? {} : { executionCwd: env.executionCwd }),
|
|
425
|
-
};
|
|
426
|
-
return await runPostAdmissionSeatResume({
|
|
427
|
-
request,
|
|
428
|
-
env,
|
|
429
|
-
io,
|
|
430
|
-
load: (effective) =>
|
|
431
|
-
loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
|
|
432
|
-
buildTurnRequest: (admitted, effective) => {
|
|
433
|
-
const activeEnv: ReviewerRunEnv = sandbox.executionCwd === undefined
|
|
434
|
-
? env
|
|
435
|
-
: { ...env, executionCwd: sandbox.executionCwd };
|
|
436
|
-
const base = resumeTurnRequestProjectionOptions(admitted, effective, activeEnv);
|
|
437
|
-
return buildReviewerTurnRequest(admitted, {
|
|
438
|
-
...base,
|
|
439
|
-
// Fresh copy at resume time; durable projectRoot unchanged.
|
|
440
|
-
...(sandbox.executionCwd === undefined ? {} : { cwd: sandbox.executionCwd }),
|
|
441
|
-
continuation: {
|
|
442
|
-
kind: "resume",
|
|
443
|
-
prompt: effective.message ?? "",
|
|
444
|
-
},
|
|
445
|
-
});
|
|
446
|
-
},
|
|
447
|
-
adapters: reviewerAdapters(env.packageRoot),
|
|
448
|
-
afterAdmittedLoad: async (admitted) => {
|
|
449
|
-
return resolveResumeMethodMaterialAdapters({
|
|
450
|
-
admitted,
|
|
451
|
-
authority: env.principalAuthority,
|
|
452
|
-
io,
|
|
453
|
-
loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
|
|
454
|
-
adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
|
|
455
|
-
emptyAdapters: reviewerAdapters(env.packageRoot),
|
|
456
|
-
});
|
|
457
|
-
},
|
|
458
|
-
afterAdmittedPrepare: async (admitted) => {
|
|
459
|
-
// Already sandboxed (in-batch auto-resume path) — nothing to mint.
|
|
460
|
-
if (sandbox.executionCwd !== undefined) {
|
|
461
|
-
return { env: { ...env, executionCwd: sandbox.executionCwd } };
|
|
462
|
-
}
|
|
463
|
-
const { openEphemeralReviewerWorktree } = await import("../public-role-summons.ts");
|
|
464
|
-
const opened = await openEphemeralReviewerWorktree({
|
|
465
|
-
projectRoot: admitted.projectRoot,
|
|
466
|
-
onCleanupDiagnostic: (diagnostic) => {
|
|
467
|
-
io.stderr(`${diagnostic}\n`);
|
|
468
|
-
},
|
|
469
|
-
});
|
|
470
|
-
sandbox.executionCwd = opened.executionCwd;
|
|
471
|
-
return {
|
|
472
|
-
env: { ...env, executionCwd: opened.executionCwd },
|
|
473
|
-
cleanup: opened.close,
|
|
474
|
-
};
|
|
475
|
-
},
|
|
476
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
export type { RoleTurnKnownFailure, PackagedMethodSkillProvenance };
|