@akagilnc/pi-workflow-roles 0.1.3932 → 0.1.3975
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/CLAUDE.md +1 -1
- package/dist/acp-host/production-host.js +2389 -6018
- package/dist/analyst-gate-cycles-read.js +15 -19
- package/dist/audit-escalation.js +16 -46
- package/dist/auditor-dossier-tool.js +7 -62
- package/dist/collector-identity.js +0 -157
- package/dist/collector-ledger.js +2 -42
- package/dist/compliance-transport.js +40 -14
- package/dist/diarist-contracts.js +2 -40
- package/dist/doctor-contracts.js +39 -108
- package/dist/doctor-evidence.js +1 -5
- package/dist/engine-detour-tool.js +1 -1
- package/dist/gatekeeper-role.js +49 -38
- package/dist/headless-host/production-host.js +4814 -8450
- package/dist/host-contracts.js +0 -5
- package/dist/merger-contracts.js +4 -6
- package/dist/navigator-attendance.js +30 -52
- package/dist/navigator-invocation-identity.js +0 -1
- package/dist/navigator-public-session.js +2 -1
- package/dist/notary-contracts.js +4 -10
- package/dist/package-contracts/auditor-output.js +5 -23
- package/dist/package-contracts/fixer-output.js +25 -49
- package/dist/package-contracts/gatekeeper-output.js +3 -13
- package/dist/package-contracts/navigator-output.js +4 -7
- package/dist/package-contracts/reviewer-output.js +1 -95
- package/dist/package-contracts/terminating-tools.js +33 -144
- package/dist/package-contracts/worker-output.js +1 -3
- package/dist/public-cli/auto-resume.js +30 -68
- package/dist/public-cli/case-dossier-delivery.js +5 -17
- package/dist/public-cli/diarist-run.js +9 -4
- package/dist/public-cli/inspector-run.js +2 -8
- package/dist/public-cli/instruction-seat-run.js +3 -7
- package/dist/public-cli/invocation.js +5 -2
- package/dist/public-cli/main.js +6068 -6964
- package/dist/public-cli/notary-run.js +1 -8
- package/dist/public-cli/post-admission.js +314 -113
- package/dist/public-cli/run-lifecycle.js +14 -38
- package/dist/public-cli/settlement.js +209 -390
- package/dist/public-cli/terminal.js +51 -45
- package/dist/public-role-summons.js +1 -12
- package/dist/reviewer-dispatch.js +12 -258
- package/dist/submission-correctable-error.js +0 -12
- package/dist/submission-errors.js +6 -1
- package/dist/submission-ledger.js +125 -168
- package/dist/ticket-provenance-contracts.js +2 -49
- package/dist/ticket-provenance.js +82 -31
- package/extensions/role-runtime.ts +1 -6
- package/package.json +1 -1
- package/resources/836-deleted-machine-instruction-inventory.md +18 -0
- package/src/acp-host/role-turn-host.ts +8 -3
- package/src/analyst-gate-cycles-read.ts +17 -29
- package/src/audit-escalation.ts +20 -50
- package/src/auditor-dossier-tool.ts +5 -103
- package/src/canonical-skill-binding.ts +3 -2
- package/src/collector-identity.ts +0 -179
- package/src/collector-ledger.ts +3 -46
- package/src/collector-role.ts +32 -61
- package/src/collector-tool-schemas.ts +20 -14
- package/src/compliance-transport.ts +55 -17
- package/src/countersign-role.ts +17 -8
- package/src/diarist-contracts.ts +3 -36
- package/src/diarist-role.ts +13 -7
- package/src/diarist.ts +4 -16
- package/src/doctor-contracts.ts +73 -94
- package/src/doctor-evidence.ts +1 -1
- package/src/doctor-role.ts +3 -3
- package/src/engine-detour-tool.ts +4 -1
- package/src/external-host-turn-loop.ts +9 -3
- package/src/gatekeeper-pass-envelope.ts +7 -12
- package/src/gatekeeper-role.ts +56 -50
- package/src/gleaner-left-role.ts +4 -2
- package/src/headless-host/role-turn-host.ts +4 -5
- package/src/host-contracts.ts +3 -8
- package/src/judge-role.ts +19 -13
- package/src/merger-contracts.ts +10 -6
- package/src/merger-role.ts +1 -5
- package/src/navigator-attendance.ts +37 -74
- package/src/navigator-invocation-identity.ts +0 -6
- package/src/navigator-public-session.ts +2 -1
- package/src/notary-contracts.ts +7 -10
- package/src/package-contracts/auditor-output.ts +4 -21
- package/src/package-contracts/fixer-output.ts +34 -52
- package/src/package-contracts/gatekeeper-output.ts +5 -22
- package/src/package-contracts/navigator-output.ts +7 -7
- package/src/package-contracts/reviewer-output.ts +2 -150
- package/src/package-contracts/terminating-tools.ts +32 -147
- package/src/package-contracts/worker-output.ts +0 -1
- package/src/pi/adapter.ts +3 -8
- package/src/public-cli/auto-resume.ts +41 -94
- package/src/public-cli/case-dossier-delivery.ts +5 -15
- package/src/public-cli/countersign-run.ts +14 -6
- package/src/public-cli/diarist-run.ts +11 -9
- package/src/public-cli/inspector-run.ts +2 -18
- package/src/public-cli/instruction-seat-run.ts +3 -17
- package/src/public-cli/invocation.ts +5 -2
- package/src/public-cli/merger-run.ts +1 -1
- package/src/public-cli/notary-run.ts +1 -18
- package/src/public-cli/post-admission.ts +385 -115
- package/src/public-cli/run-lifecycle.ts +13 -44
- package/src/public-cli/settlement.ts +314 -562
- package/src/public-cli/terminal.ts +66 -72
- package/src/public-role-summons.ts +5 -30
- package/src/reviewer-dispatch.ts +29 -331
- package/src/reviewer-role.ts +16 -83
- package/src/role-envelope.ts +16 -24
- package/src/role-runtime-dependencies.ts +1 -6
- package/src/role-runtime.ts +65 -201
- package/src/submission-correctable-error.ts +0 -14
- package/src/submission-errors.ts +6 -1
- package/src/submission-ledger.ts +187 -187
- package/src/ticket-provenance-contracts.ts +4 -60
- package/src/ticket-provenance.ts +98 -32
- package/src/worker-role.ts +35 -36
- package/dist/activation-ledger-session.js +0 -105
- package/dist/activation-ledger.js +0 -139
- package/dist/activation-trace.js +0 -33
- package/dist/atomic-write.js +0 -23
- package/dist/auditor-role.js +0 -12
- package/dist/canonical-skill-binding.js +0 -61
- package/dist/collector-handbook.js +0 -142
- package/dist/collector-receipt.js +0 -107
- package/dist/collector-role.js +0 -566
- package/dist/collector-tool-schemas.js +0 -107
- package/dist/countersign-role.js +0 -28
- package/dist/diarist-role.js +0 -44
- package/dist/diarist.js +0 -66
- package/dist/doctor-role.js +0 -75
- package/dist/fixer-bash-seatbelt.js +0 -13
- package/dist/gatekeeper-pass-envelope.js +0 -77
- package/dist/gleaner-left-role.js +0 -26
- package/dist/inspector-role.js +0 -29
- package/dist/judge-role.js +0 -104
- package/dist/merger-role.js +0 -55
- package/dist/navigator-role.js +0 -12
- package/dist/notary-role.js +0 -134
- package/dist/oauth-keepalive.js +0 -158
- package/dist/pi/adapter.js +0 -223
- package/dist/reviewer-agent.js +0 -122
- package/dist/reviewer-child-executor.js +0 -194
- package/dist/reviewer-construction.js +0 -103
- package/dist/reviewer-execution-ledger.js +0 -166
- package/dist/reviewer-failure-diagnostic.js +0 -17
- package/dist/reviewer-role.js +0 -159
- package/dist/reviewer-scope-prompt.js +0 -21
- package/dist/reviewer-settlement.js +0 -66
- package/dist/reviewer-workspace.js +0 -132
- package/dist/role-runtime.js +0 -1604
- package/dist/stderr-jsonl.js +0 -26
- package/dist/tool-execution-observation.js +0 -141
- package/dist/worker-role.js +0 -345
- package/dist/worker-submission-gates.js +0 -305
- package/src/collector-receipt.ts +0 -140
- package/src/diagnostic-tail.ts +0 -18
- package/src/reviewer-agent.ts +0 -135
- package/src/reviewer-child-executor.ts +0 -252
- package/src/reviewer-construction.ts +0 -195
- package/src/reviewer-execution-ledger.ts +0 -212
- package/src/reviewer-failure-diagnostic.ts +0 -18
- package/src/reviewer-scope-prompt.ts +0 -24
- package/src/reviewer-settlement.ts +0 -74
- package/src/reviewer-workspace.ts +0 -105
- package/src/shape-unreadable-failure.ts +0 -49
|
@@ -17,50 +17,42 @@ export function isLawfulTypedTerminalOutcome(outcome) {
|
|
|
17
17
|
export function exitCodeForTerminalOutcome(outcome) {
|
|
18
18
|
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
19
19
|
}
|
|
20
|
-
export function buildResidualIncompleteTerminalOutcome(input) {
|
|
21
|
-
return {
|
|
22
|
-
kind: "incomplete",
|
|
23
|
-
role: input.role,
|
|
24
|
-
status: "incomplete",
|
|
25
|
-
decision: "no-usable-result",
|
|
26
|
-
candidate: input.candidate,
|
|
27
|
-
diagnostic: input.diagnostic,
|
|
28
|
-
acceptedReceipt: false,
|
|
29
|
-
decisiveFacts: {
|
|
30
|
-
decision: "no-usable-result",
|
|
31
|
-
candidate: input.candidate,
|
|
32
|
-
diagnostic: input.diagnostic,
|
|
33
|
-
acceptedReceipt: false,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/** Public free-text stand-in when an exact Role run ID is stripped outside resume.command. */
|
|
38
|
-
export const REDACTED_RUN_ID_TOKEN = "[run-id]";
|
|
39
20
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
21
|
+
* One admitted Role run's typed Terminal aggregate.
|
|
22
|
+
* Resumable failures carry `resume` and must not re-disclose the run ID via
|
|
23
|
+
* top-level `runId` or public artifact path components — only `resume.command`.
|
|
24
|
+
* #416: autoResumeCount (0..2) is a call-local observation of how many in-place
|
|
25
|
+
* auto-resumes occurred during this single LLM call; it is not persisted to
|
|
26
|
+
* run-state.json and does not participate in limit decisions.
|
|
42
27
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
/** Original payloads on a terminal — role result for accepted/audit; coexist on failure. */
|
|
29
|
+
export function roleResultPayloads(outcome) {
|
|
30
|
+
if (outcome.kind === "accepted" || outcome.kind === "audit_escalation")
|
|
31
|
+
return outcome.payloads ?? [];
|
|
32
|
+
if (outcome.kind === "failure")
|
|
33
|
+
return outcome.payloads ?? [];
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
/** Last object payload the role actually wrote. No field remapping. */
|
|
37
|
+
export function lastRolePayloadRecord(payloads) {
|
|
38
|
+
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
39
|
+
const payload = payloads[index];
|
|
40
|
+
if (typeof payload === "object" && payload !== null && !Array.isArray(payload)) {
|
|
41
|
+
return payload;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
49
45
|
}
|
|
50
46
|
/**
|
|
51
|
-
* Build a recommendation navigator fact.
|
|
52
|
-
*
|
|
47
|
+
* Build a recommendation navigator fact. Model command is kept when present;
|
|
48
|
+
* registry render is fallback only. Unknown seats stay recommendations (#836 B4.1).
|
|
53
49
|
*/
|
|
54
50
|
export function recommendationNavigatorFact(input) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
reason: `recommended role is not a public callable seat: ${input.next.role}`,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const command = renderPublicAkRoleCommand(input.next);
|
|
51
|
+
const command = typeof input.modelCommand === "string" && input.modelCommand.trim() !== ""
|
|
52
|
+
? input.modelCommand
|
|
53
|
+
: isPublicCallableRole(input.next.role)
|
|
54
|
+
? renderPublicAkRoleCommand(input.next)
|
|
55
|
+
: undefined;
|
|
64
56
|
return {
|
|
65
57
|
disposition: "recommendation",
|
|
66
58
|
next: input.next,
|
|
@@ -80,17 +72,21 @@ export function formatTerminalResult(result) {
|
|
|
80
72
|
lines.push("role\toutcome\tstatus");
|
|
81
73
|
const outcomeStatus = result.roleOutcome.kind === "failure"
|
|
82
74
|
? result.roleOutcome.cause
|
|
83
|
-
: result.roleOutcome.
|
|
75
|
+
: result.roleOutcome.kind === "accepted"
|
|
76
|
+
? "accepted"
|
|
77
|
+
: result.roleOutcome.status;
|
|
84
78
|
lines.push(`${result.roleOutcome.role}\t${result.roleOutcome.kind}\t${encodeTerminalField(outcomeStatus)}`);
|
|
85
79
|
if (result.roleOutcome.kind === "failure") {
|
|
86
80
|
lines.push(`diagnostic\t${encodeTerminalField(result.roleOutcome.diagnostic)}`);
|
|
87
81
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
|
|
83
|
+
const facts = result.roleOutcome.decisiveFacts;
|
|
84
|
+
for (const [key, value] of Object.entries(facts)) {
|
|
85
|
+
if (value === undefined)
|
|
86
|
+
continue;
|
|
87
|
+
const rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
88
|
+
lines.push(`fact\t${encodeTerminalField(key)}\t${encodeTerminalField(rendered)}`);
|
|
89
|
+
}
|
|
94
90
|
}
|
|
95
91
|
lines.push(`navigator\t${result.navigator.disposition}`);
|
|
96
92
|
if (result.navigator.advisoryDiagnostic !== undefined) {
|
|
@@ -131,5 +127,15 @@ export function formatTerminalResult(result) {
|
|
|
131
127
|
if (result.autoResumeCount !== undefined) {
|
|
132
128
|
lines.push(`autoResumeCount\t${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
133
129
|
}
|
|
130
|
+
// Role-result block: original payloads in ledger order (#836 / ADR 0052).
|
|
131
|
+
const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation"
|
|
132
|
+
? result.roleOutcome.payloads ?? result.submissions ?? []
|
|
133
|
+
: result.roleOutcome.kind === "failure"
|
|
134
|
+
? result.roleOutcome.payloads ?? result.submissions ?? []
|
|
135
|
+
: result.submissions ?? [];
|
|
136
|
+
for (const payload of payloads) {
|
|
137
|
+
const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
138
|
+
lines.push(`submission\t${encodeTerminalField(rendered)}`);
|
|
139
|
+
}
|
|
134
140
|
return `${lines.join("\n")}\n`;
|
|
135
141
|
}
|
|
@@ -158,8 +158,6 @@ async function summonPublicRole(options) {
|
|
|
158
158
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
159
159
|
// #753: reask rides the existing notary same-ticket resume summons.instruction.
|
|
160
160
|
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
161
|
-
// #786: verbatim submission body on same-parent resume (not conclusion re-ask).
|
|
162
|
-
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
163
161
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
164
162
|
// createRunId is the only remaining env overlay — host is seat-selected above.
|
|
165
163
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -267,13 +265,6 @@ async function summonGateOfficer(options) {
|
|
|
267
265
|
const { homeFromRunDirectory } = await import("./activation-ledger-topology.js");
|
|
268
266
|
home = homeFromRunDirectory(options.sourceRunDirectory);
|
|
269
267
|
}
|
|
270
|
-
let gateReviewInstruction;
|
|
271
|
-
if (options.reask === void 0 && options.submission !== void 0) {
|
|
272
|
-
const { buildGateOfficerReviewInstruction } = await import("./auditor-dossier-tool.js");
|
|
273
|
-
gateReviewInstruction = buildGateOfficerReviewInstruction({
|
|
274
|
-
submission: options.submission
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
268
|
const common = {
|
|
278
269
|
cwd: options.cwd,
|
|
279
270
|
...home === void 0 ? {} : { home },
|
|
@@ -281,7 +272,6 @@ async function summonGateOfficer(options) {
|
|
|
281
272
|
...options.io === void 0 ? {} : { io: options.io },
|
|
282
273
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
283
274
|
...options.reask === void 0 ? {} : { reviewReask: options.reask },
|
|
284
|
-
...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
|
|
285
275
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
286
276
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
287
277
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
@@ -294,7 +284,6 @@ async function summonGateOfficer(options) {
|
|
|
294
284
|
});
|
|
295
285
|
}
|
|
296
286
|
if (options.officer === "auditor") {
|
|
297
|
-
const { AUDITOR_DOSSIER_PROMPT } = await import("./compliance-transport.js");
|
|
298
287
|
return summonPublicRole({
|
|
299
288
|
role: "auditor",
|
|
300
289
|
argv: [
|
|
@@ -302,7 +291,7 @@ async function summonGateOfficer(options) {
|
|
|
302
291
|
"judge",
|
|
303
292
|
"--source-run",
|
|
304
293
|
options.sourceRunDirectory,
|
|
305
|
-
|
|
294
|
+
`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`
|
|
306
295
|
],
|
|
307
296
|
...common
|
|
308
297
|
});
|
|
@@ -1,260 +1,14 @@
|
|
|
1
|
-
import { extractReferencedAdrPaths } from "./adr-path-refs.js";
|
|
2
|
-
export { extractReferencedAdrPaths } from "./adr-path-refs.js";
|
|
3
|
-
import { sameReviewerPinnedTarget } from "./reviewer-git-snapshot.js";
|
|
4
|
-
import { branchNamesAtPinnedHead, immutableReviewerPin } from "./reviewer-pinned-git.js";
|
|
5
|
-
export { branchNamesAtPinnedHead, createReviewerPinnedGitReader, immutableReviewerPin } from "./reviewer-pinned-git.js";
|
|
6
|
-
import { isReviewerPromptText, sameReviewerPromptText } from "./reviewer-prompt-identity.js";
|
|
7
|
-
import { sha256Hex } from "./sha256.js";
|
|
8
|
-
import { constructReviewerDispatch, } from "./reviewer-construction.js";
|
|
9
|
-
export {} from "./reviewer-construction.js";
|
|
10
|
-
import { ReviewerCorrectablePreflightError } from "./reviewer-preflight-error.js";
|
|
11
|
-
export { sha256Hex } from "./sha256.js";
|
|
12
|
-
export { isReviewerPromptText as isReviewerPromptIdentity, sameReviewerPromptText as sameReviewerPromptIdentity } from "./reviewer-prompt-identity.js";
|
|
13
|
-
const GENERIC_FEATURE_TOKENS = new Set(["", "head", "main", "master", "trunk", "develop", "development"]);
|
|
14
|
-
/** Conventional branch shells that must not hide the feature token (feat/login → login). */
|
|
15
|
-
const BRANCH_SHELL_PREFIX = /^(?:feat|feature|fix|bugfix|hotfix|chore|docs|refactor)-/;
|
|
16
|
-
/** Branch token ticket capture: (fix|feat|docs|audit|test)/issue-(\d+)- (#343). */
|
|
17
|
-
const BRANCH_ISSUE_TOKEN = /(?:^|\/)((?:fix|feat|docs|audit|test)\/issue-(\d+)-)/;
|
|
18
|
-
/** First #N in a commit subject (positive integer). */
|
|
19
|
-
const COMMIT_TICKET_TOKEN = /#([1-9]\d*)/;
|
|
20
|
-
function normalizeFeatureToken(value) {
|
|
21
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
22
|
-
}
|
|
23
|
-
/** Expand one branch/ref name into matchable tokens, stripping conventional shells. */
|
|
24
|
-
function expandFeatureTokens(raw) {
|
|
25
|
-
const normalized = normalizeFeatureToken(raw);
|
|
26
|
-
if (normalized.length === 0)
|
|
27
|
-
return Object.freeze([]);
|
|
28
|
-
const tokens = new Set([normalized]);
|
|
29
|
-
const stripped = normalized.replace(BRANCH_SHELL_PREFIX, "");
|
|
30
|
-
if (stripped.length > 0 && stripped !== normalized)
|
|
31
|
-
tokens.add(stripped);
|
|
32
|
-
return Object.freeze([...tokens]);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Shared capture/number → positive-integer → frozen candidate conversion.
|
|
36
|
-
* Single true source for branch/commit (and typed) ticket candidate materialization.
|
|
37
|
-
*/
|
|
38
|
-
function ticketCandidateFromRaw(source, raw) {
|
|
39
|
-
const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : Number.NaN;
|
|
40
|
-
if (!Number.isInteger(n) || n < 1)
|
|
41
|
-
return undefined;
|
|
42
|
-
return Object.freeze({ source, ticketNumber: n });
|
|
43
|
-
}
|
|
44
1
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* High-priority hit is adopted; lower sources that also yield a number are abandoned candidates.
|
|
2
|
+
* #836 删 8: no code-compiled axis dispatch.
|
|
3
|
+
* Parent seat invokes packaged code-review skill; this module does not construct or run children.
|
|
48
4
|
*/
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
let commit;
|
|
61
|
-
const newest = input.commitMessagesNewestFirst[0];
|
|
62
|
-
if (newest !== undefined) {
|
|
63
|
-
const match = COMMIT_TICKET_TOKEN.exec(newest);
|
|
64
|
-
if (match) {
|
|
65
|
-
commit = ticketCandidateFromRaw("commit-message", match[1]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (typed !== undefined) {
|
|
69
|
-
const abandoned = [branch, commit].filter((c) => c !== undefined);
|
|
70
|
-
return Object.freeze({ adopted: typed, abandoned: Object.freeze(abandoned) });
|
|
71
|
-
}
|
|
72
|
-
if (branch !== undefined) {
|
|
73
|
-
const abandoned = commit === undefined ? Object.freeze([]) : Object.freeze([commit]);
|
|
74
|
-
return Object.freeze({ adopted: branch, abandoned });
|
|
75
|
-
}
|
|
76
|
-
if (commit !== undefined) {
|
|
77
|
-
return Object.freeze({ adopted: commit, abandoned: Object.freeze([]) });
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
/** Optional AbortSignal carried on the dispatch invocation bag (same shape runDispatch already reads). */
|
|
82
|
-
function optionalInvocationSignal(invocation) {
|
|
83
|
-
if (typeof invocation !== "object" || invocation === null)
|
|
84
|
-
return undefined;
|
|
85
|
-
const signal = invocation.signal;
|
|
86
|
-
return signal instanceof AbortSignal ? signal : undefined;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Unique production owner of code-review Skill step 2 Spec discovery (#343).
|
|
90
|
-
* Primary: self-fetch latest issue by ticket number (typed → branch token → commit #N).
|
|
91
|
-
* Degradation (unique order): self-fetch fail → supplied authorityRefs → local path match → missing.
|
|
92
|
-
* Prompt/admitted-request prose is never Spec material.
|
|
93
|
-
* Only confirmed absence yields missing; non-absence Git/I-O failures keep true cause for preflight.
|
|
94
|
-
* Construction builds Standards/Spec solely from this product.
|
|
95
|
-
*/
|
|
96
|
-
export async function discoverReviewerSpecAuthority(input) {
|
|
97
|
-
// Path-matching tokens (heads/tags/remotes) stay separate from branch-ticket provenance.
|
|
98
|
-
const featureTokens = await input.reader.featureTokens();
|
|
99
|
-
const commitMessages = input.baseCommit === undefined
|
|
100
|
-
? Object.freeze([])
|
|
101
|
-
: await input.reader.commitMessagesNewestFirst(input.baseCommit);
|
|
102
|
-
const ticketResolution = resolveReviewerTicketNumber({
|
|
103
|
-
...(input.ticketNumber === undefined ? {} : { ticketNumber: input.ticketNumber }),
|
|
104
|
-
// Branch ticket source: real heads/remotes at targetHead only — never tags via featureTokens.
|
|
105
|
-
branchNames: branchNamesAtPinnedHead(input.reader.pin),
|
|
106
|
-
commitMessagesNewestFirst: commitMessages,
|
|
107
|
-
});
|
|
108
|
-
// ① Primary: self-fetch latest issue + referenced docs/adr via injected capability only.
|
|
109
|
-
if (ticketResolution !== undefined) {
|
|
110
|
-
const origin = await input.reader.originRepository();
|
|
111
|
-
if (origin !== undefined && input.fetchIssue !== undefined) {
|
|
112
|
-
const issue = await input.fetchIssue({
|
|
113
|
-
owner: origin.owner,
|
|
114
|
-
repo: origin.repo,
|
|
115
|
-
ticketNumber: ticketResolution.adopted.ticketNumber,
|
|
116
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
117
|
-
});
|
|
118
|
-
if (issue !== undefined) {
|
|
119
|
-
const adrPaths = extractReferencedAdrPaths(issue.body);
|
|
120
|
-
const adrs = [];
|
|
121
|
-
for (const path of adrPaths) {
|
|
122
|
-
const body = await input.reader.readPinnedText(path);
|
|
123
|
-
if (body === undefined) {
|
|
124
|
-
adrs.push(Object.freeze({ path, status: "missing" }));
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
adrs.push(Object.freeze({ path, status: "present", body }));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const issueRef = `https://github.com/${origin.owner}/${origin.repo}/issues/${ticketResolution.adopted.ticketNumber}`;
|
|
131
|
-
const presentAdrRefs = adrs
|
|
132
|
-
.filter((a) => a.status === "present")
|
|
133
|
-
.map((a) => a.path);
|
|
134
|
-
const fetched = Object.freeze({
|
|
135
|
-
issueRef,
|
|
136
|
-
owner: origin.owner,
|
|
137
|
-
repo: origin.repo,
|
|
138
|
-
ticketNumber: ticketResolution.adopted.ticketNumber,
|
|
139
|
-
adopted: ticketResolution.adopted,
|
|
140
|
-
abandoned: ticketResolution.abandoned,
|
|
141
|
-
issueBody: issue.body,
|
|
142
|
-
adrs: Object.freeze(adrs),
|
|
143
|
-
});
|
|
144
|
-
return Object.freeze({
|
|
145
|
-
status: "available",
|
|
146
|
-
refs: Object.freeze([issueRef, ...presentAdrRefs]),
|
|
147
|
-
fetched,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// ② Degrade: explicit --authority-ref (human intent before local heuristics).
|
|
153
|
-
if (input.authorityRefs.length > 0) {
|
|
154
|
-
return Object.freeze({
|
|
155
|
-
status: "available",
|
|
156
|
-
refs: Object.freeze([...input.authorityRefs]),
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// ③ Degrade: matching pinned-target docs/specs/.scratch paths via branch feature tokens.
|
|
160
|
-
const tokens = [
|
|
161
|
-
...new Set(featureTokens
|
|
162
|
-
.flatMap((raw) => expandFeatureTokens(raw))
|
|
163
|
-
.filter((token) => token.length >= 3 && !GENERIC_FEATURE_TOKENS.has(token))),
|
|
164
|
-
];
|
|
165
|
-
if (tokens.length === 0) {
|
|
166
|
-
return Object.freeze({ status: "missing" });
|
|
167
|
-
}
|
|
168
|
-
// Pinned target tree only — Spec child cannot read live-worktree or gitignored paths.
|
|
169
|
-
const candidates = await input.reader.listSpecCandidatePaths();
|
|
170
|
-
const matched = candidates.filter((relativePath) => {
|
|
171
|
-
const normalizedPath = normalizeFeatureToken(relativePath);
|
|
172
|
-
return tokens.some((token) => normalizedPath.includes(token));
|
|
173
|
-
});
|
|
174
|
-
if (matched.length === 0) {
|
|
175
|
-
return Object.freeze({ status: "missing" });
|
|
176
|
-
}
|
|
177
|
-
return Object.freeze({
|
|
178
|
-
status: "available",
|
|
179
|
-
refs: Object.freeze(matched),
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
export const REVIEWER_PREFLIGHT_VIOLATIONS = ["base-invalid", "range-invalid", "prompt-identity-invalid", "target-drift"];
|
|
183
|
-
export class ReviewerPreflightError extends Error {
|
|
184
|
-
code;
|
|
185
|
-
diagnostic;
|
|
186
|
-
constructor(code, diagnostic = `${code} constraint failed`) {
|
|
187
|
-
super(`${code}: ${diagnostic}`);
|
|
188
|
-
this.code = code;
|
|
189
|
-
this.diagnostic = diagnostic;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
export function toReviewerExecution(dispatch) {
|
|
193
|
-
return Object.freeze({
|
|
194
|
-
identity: dispatch.identity,
|
|
195
|
-
recipe: dispatch.recipe,
|
|
196
|
-
targetSnapshot: immutableReviewerPin(dispatch.targetSnapshot),
|
|
197
|
-
legs: Object.freeze(dispatch.legs.map((l) => Object.freeze({ axis: l.axis, prompt: l.prompt }))),
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
const preflight = (error) => {
|
|
201
|
-
if (error instanceof ReviewerPreflightError)
|
|
202
|
-
return error;
|
|
203
|
-
if (error instanceof ReviewerCorrectablePreflightError) {
|
|
204
|
-
return new ReviewerPreflightError(error.code, error.diagnostic);
|
|
205
|
-
}
|
|
206
|
-
return undefined;
|
|
207
|
-
};
|
|
208
|
-
export function createReviewerDispatcher(d) {
|
|
209
|
-
const target = immutableReviewerPin(d.reader.pin);
|
|
210
|
-
let started = false;
|
|
211
|
-
return Object.freeze({
|
|
212
|
-
async dispatch(baseRevision, invocation) {
|
|
213
|
-
if (started)
|
|
214
|
-
throw new Error("Reviewer fixed dispatch can start exactly once");
|
|
215
|
-
const identity = sha256Hex(JSON.stringify({
|
|
216
|
-
baseRevision,
|
|
217
|
-
target: target.targetHead,
|
|
218
|
-
canonicalSkill: sha256Hex(d.canonicalSkill),
|
|
219
|
-
}));
|
|
220
|
-
let dispatch;
|
|
221
|
-
try {
|
|
222
|
-
const base = await d.reader.resolve(baseRevision);
|
|
223
|
-
const range = await d.reader.range(base);
|
|
224
|
-
const authorityRefs = Object.freeze([...(d.authorityRefs ?? [])]);
|
|
225
|
-
const signal = optionalInvocationSignal(invocation);
|
|
226
|
-
const specAuthority = await discoverReviewerSpecAuthority({
|
|
227
|
-
authorityRefs,
|
|
228
|
-
reader: d.reader,
|
|
229
|
-
baseCommit: base,
|
|
230
|
-
...(d.ticketNumber === undefined ? {} : { ticketNumber: d.ticketNumber }),
|
|
231
|
-
...(d.fetchIssue === undefined ? {} : { fetchIssue: d.fetchIssue }),
|
|
232
|
-
...(signal === undefined ? {} : { signal }),
|
|
233
|
-
});
|
|
234
|
-
dispatch = constructReviewerDispatch({
|
|
235
|
-
identity,
|
|
236
|
-
canonicalSkill: d.canonicalSkill,
|
|
237
|
-
target,
|
|
238
|
-
range,
|
|
239
|
-
...(d.reviewScopeKeys === undefined ? {} : { reviewScopeKeys: d.reviewScopeKeys }),
|
|
240
|
-
specAuthority,
|
|
241
|
-
});
|
|
242
|
-
if (!sameReviewerPinnedTarget(await d.reader.snapshot(), target)) {
|
|
243
|
-
throw new ReviewerPreflightError("target-drift", "pinned target snapshot changed before child execution");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
catch (error) {
|
|
247
|
-
const p = preflight(error);
|
|
248
|
-
if (!p)
|
|
249
|
-
throw error;
|
|
250
|
-
d.decisionEvidence?.(Object.freeze({ disposition: "rejected", identity, violations: Object.freeze([p.code]), started: false }));
|
|
251
|
-
return Object.freeze({ status: "rejected", identity, violations: Object.freeze([p.code]), diagnostic: p.diagnostic });
|
|
252
|
-
}
|
|
253
|
-
started = true;
|
|
254
|
-
d.decisionEvidence?.(Object.freeze({ disposition: "accepted", identity, dispatch }));
|
|
255
|
-
const results = await d.run(toReviewerExecution(dispatch), invocation);
|
|
256
|
-
return Object.freeze({ status: "accepted", dispatch, results });
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
export { isReviewerPromptText, sameReviewerPromptText };
|
|
5
|
+
export { branchNamesAtPinnedHead, createReviewerPinnedGitReader, immutableReviewerPin, } from "./reviewer-pinned-git.js";
|
|
6
|
+
export { extractReferencedAdrPaths } from "./adr-path-refs.js";
|
|
7
|
+
export { sha256Hex } from "./sha256.js";
|
|
8
|
+
export { isReviewerPromptText as isReviewerPromptIdentity, sameReviewerPromptText as sameReviewerPromptIdentity, } from "./reviewer-prompt-identity.js";
|
|
9
|
+
export const REVIEWER_PREFLIGHT_VIOLATIONS = [
|
|
10
|
+
"base-invalid",
|
|
11
|
+
"range-invalid",
|
|
12
|
+
"prompt-identity-invalid",
|
|
13
|
+
"target-drift",
|
|
14
|
+
];
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { GatekeeperDecisionError, ParentQueueReaskError, WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, } from "./submission-errors.js";
|
|
2
|
-
/**
|
|
3
|
-
* Mechanical non-sole resume text — one shared authority for Pi followUp and
|
|
4
|
-
* ACP/headless closeRound retry (#813). Officer bounce/escalate use projected
|
|
5
|
-
* receipt text instead; this string is only the round-shape correction.
|
|
6
|
-
*/
|
|
7
|
-
export const NON_SOLE_ROUND_RESUME_MESSAGE = "终局交卷并非本轮唯一工具调用。";
|
|
8
|
-
/** Resume text for mechanical deliverSubmissionRejection codes (no officer receipt). */
|
|
9
|
-
export function mechanicalSubmissionRejectionResumeMessage(code) {
|
|
10
|
-
if (code === "non-sole-round")
|
|
11
|
-
return NON_SOLE_ROUND_RESUME_MESSAGE;
|
|
12
|
-
return code;
|
|
13
|
-
}
|
|
14
2
|
/** Shared, unforgeable identity for submission errors that the same session may correct. */
|
|
15
3
|
const correctableSubmissionErrorBrand = Symbol("ak-roles.correctable-submission-error");
|
|
16
4
|
export class CorrectableSubmissionError extends Error {
|
|
@@ -12,7 +12,12 @@ function gatekeeperNonPassMessage(result) {
|
|
|
12
12
|
if (result.status === "bounce" || result.status === "escalate") {
|
|
13
13
|
return serializeReceipt(result.receipt);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
if (result.status === "transport_failure") {
|
|
16
|
+
const head = `门下省 ${result.status}(${result.stage}):${result.reason}`;
|
|
17
|
+
return result.submission === undefined
|
|
18
|
+
? head
|
|
19
|
+
: `${head}\n${serializeReceipt(result.submission)}`;
|
|
20
|
+
}
|
|
16
21
|
return `门下省 ${result.status}(${result.stage}):${result.reason}`;
|
|
17
22
|
}
|
|
18
23
|
/** Structured non-pass; `.result` is session-projected via tool_result, message feeds the model. */
|