@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.
Files changed (162) hide show
  1. package/CLAUDE.md +1 -1
  2. package/dist/acp-host/production-host.js +2389 -6018
  3. package/dist/analyst-gate-cycles-read.js +15 -19
  4. package/dist/audit-escalation.js +16 -46
  5. package/dist/auditor-dossier-tool.js +7 -62
  6. package/dist/collector-identity.js +0 -157
  7. package/dist/collector-ledger.js +2 -42
  8. package/dist/compliance-transport.js +40 -14
  9. package/dist/diarist-contracts.js +2 -40
  10. package/dist/doctor-contracts.js +39 -108
  11. package/dist/doctor-evidence.js +1 -5
  12. package/dist/engine-detour-tool.js +1 -1
  13. package/dist/gatekeeper-role.js +49 -38
  14. package/dist/headless-host/production-host.js +4814 -8450
  15. package/dist/host-contracts.js +0 -5
  16. package/dist/merger-contracts.js +4 -6
  17. package/dist/navigator-attendance.js +30 -52
  18. package/dist/navigator-invocation-identity.js +0 -1
  19. package/dist/navigator-public-session.js +2 -1
  20. package/dist/notary-contracts.js +4 -10
  21. package/dist/package-contracts/auditor-output.js +5 -23
  22. package/dist/package-contracts/fixer-output.js +25 -49
  23. package/dist/package-contracts/gatekeeper-output.js +3 -13
  24. package/dist/package-contracts/navigator-output.js +4 -7
  25. package/dist/package-contracts/reviewer-output.js +1 -95
  26. package/dist/package-contracts/terminating-tools.js +33 -144
  27. package/dist/package-contracts/worker-output.js +1 -3
  28. package/dist/public-cli/auto-resume.js +30 -68
  29. package/dist/public-cli/case-dossier-delivery.js +5 -17
  30. package/dist/public-cli/diarist-run.js +9 -4
  31. package/dist/public-cli/inspector-run.js +2 -8
  32. package/dist/public-cli/instruction-seat-run.js +3 -7
  33. package/dist/public-cli/invocation.js +5 -2
  34. package/dist/public-cli/main.js +6068 -6964
  35. package/dist/public-cli/notary-run.js +1 -8
  36. package/dist/public-cli/post-admission.js +314 -113
  37. package/dist/public-cli/run-lifecycle.js +14 -38
  38. package/dist/public-cli/settlement.js +209 -390
  39. package/dist/public-cli/terminal.js +51 -45
  40. package/dist/public-role-summons.js +1 -12
  41. package/dist/reviewer-dispatch.js +12 -258
  42. package/dist/submission-correctable-error.js +0 -12
  43. package/dist/submission-errors.js +6 -1
  44. package/dist/submission-ledger.js +125 -168
  45. package/dist/ticket-provenance-contracts.js +2 -49
  46. package/dist/ticket-provenance.js +82 -31
  47. package/extensions/role-runtime.ts +1 -6
  48. package/package.json +1 -1
  49. package/resources/836-deleted-machine-instruction-inventory.md +18 -0
  50. package/src/acp-host/role-turn-host.ts +8 -3
  51. package/src/analyst-gate-cycles-read.ts +17 -29
  52. package/src/audit-escalation.ts +20 -50
  53. package/src/auditor-dossier-tool.ts +5 -103
  54. package/src/canonical-skill-binding.ts +3 -2
  55. package/src/collector-identity.ts +0 -179
  56. package/src/collector-ledger.ts +3 -46
  57. package/src/collector-role.ts +32 -61
  58. package/src/collector-tool-schemas.ts +20 -14
  59. package/src/compliance-transport.ts +55 -17
  60. package/src/countersign-role.ts +17 -8
  61. package/src/diarist-contracts.ts +3 -36
  62. package/src/diarist-role.ts +13 -7
  63. package/src/diarist.ts +4 -16
  64. package/src/doctor-contracts.ts +73 -94
  65. package/src/doctor-evidence.ts +1 -1
  66. package/src/doctor-role.ts +3 -3
  67. package/src/engine-detour-tool.ts +4 -1
  68. package/src/external-host-turn-loop.ts +9 -3
  69. package/src/gatekeeper-pass-envelope.ts +7 -12
  70. package/src/gatekeeper-role.ts +56 -50
  71. package/src/gleaner-left-role.ts +4 -2
  72. package/src/headless-host/role-turn-host.ts +4 -5
  73. package/src/host-contracts.ts +3 -8
  74. package/src/judge-role.ts +19 -13
  75. package/src/merger-contracts.ts +10 -6
  76. package/src/merger-role.ts +1 -5
  77. package/src/navigator-attendance.ts +37 -74
  78. package/src/navigator-invocation-identity.ts +0 -6
  79. package/src/navigator-public-session.ts +2 -1
  80. package/src/notary-contracts.ts +7 -10
  81. package/src/package-contracts/auditor-output.ts +4 -21
  82. package/src/package-contracts/fixer-output.ts +34 -52
  83. package/src/package-contracts/gatekeeper-output.ts +5 -22
  84. package/src/package-contracts/navigator-output.ts +7 -7
  85. package/src/package-contracts/reviewer-output.ts +2 -150
  86. package/src/package-contracts/terminating-tools.ts +32 -147
  87. package/src/package-contracts/worker-output.ts +0 -1
  88. package/src/pi/adapter.ts +3 -8
  89. package/src/public-cli/auto-resume.ts +41 -94
  90. package/src/public-cli/case-dossier-delivery.ts +5 -15
  91. package/src/public-cli/countersign-run.ts +14 -6
  92. package/src/public-cli/diarist-run.ts +11 -9
  93. package/src/public-cli/inspector-run.ts +2 -18
  94. package/src/public-cli/instruction-seat-run.ts +3 -17
  95. package/src/public-cli/invocation.ts +5 -2
  96. package/src/public-cli/merger-run.ts +1 -1
  97. package/src/public-cli/notary-run.ts +1 -18
  98. package/src/public-cli/post-admission.ts +385 -115
  99. package/src/public-cli/run-lifecycle.ts +13 -44
  100. package/src/public-cli/settlement.ts +314 -562
  101. package/src/public-cli/terminal.ts +66 -72
  102. package/src/public-role-summons.ts +5 -30
  103. package/src/reviewer-dispatch.ts +29 -331
  104. package/src/reviewer-role.ts +16 -83
  105. package/src/role-envelope.ts +16 -24
  106. package/src/role-runtime-dependencies.ts +1 -6
  107. package/src/role-runtime.ts +65 -201
  108. package/src/submission-correctable-error.ts +0 -14
  109. package/src/submission-errors.ts +6 -1
  110. package/src/submission-ledger.ts +187 -187
  111. package/src/ticket-provenance-contracts.ts +4 -60
  112. package/src/ticket-provenance.ts +98 -32
  113. package/src/worker-role.ts +35 -36
  114. package/dist/activation-ledger-session.js +0 -105
  115. package/dist/activation-ledger.js +0 -139
  116. package/dist/activation-trace.js +0 -33
  117. package/dist/atomic-write.js +0 -23
  118. package/dist/auditor-role.js +0 -12
  119. package/dist/canonical-skill-binding.js +0 -61
  120. package/dist/collector-handbook.js +0 -142
  121. package/dist/collector-receipt.js +0 -107
  122. package/dist/collector-role.js +0 -566
  123. package/dist/collector-tool-schemas.js +0 -107
  124. package/dist/countersign-role.js +0 -28
  125. package/dist/diarist-role.js +0 -44
  126. package/dist/diarist.js +0 -66
  127. package/dist/doctor-role.js +0 -75
  128. package/dist/fixer-bash-seatbelt.js +0 -13
  129. package/dist/gatekeeper-pass-envelope.js +0 -77
  130. package/dist/gleaner-left-role.js +0 -26
  131. package/dist/inspector-role.js +0 -29
  132. package/dist/judge-role.js +0 -104
  133. package/dist/merger-role.js +0 -55
  134. package/dist/navigator-role.js +0 -12
  135. package/dist/notary-role.js +0 -134
  136. package/dist/oauth-keepalive.js +0 -158
  137. package/dist/pi/adapter.js +0 -223
  138. package/dist/reviewer-agent.js +0 -122
  139. package/dist/reviewer-child-executor.js +0 -194
  140. package/dist/reviewer-construction.js +0 -103
  141. package/dist/reviewer-execution-ledger.js +0 -166
  142. package/dist/reviewer-failure-diagnostic.js +0 -17
  143. package/dist/reviewer-role.js +0 -159
  144. package/dist/reviewer-scope-prompt.js +0 -21
  145. package/dist/reviewer-settlement.js +0 -66
  146. package/dist/reviewer-workspace.js +0 -132
  147. package/dist/role-runtime.js +0 -1604
  148. package/dist/stderr-jsonl.js +0 -26
  149. package/dist/tool-execution-observation.js +0 -141
  150. package/dist/worker-role.js +0 -345
  151. package/dist/worker-submission-gates.js +0 -305
  152. package/src/collector-receipt.ts +0 -140
  153. package/src/diagnostic-tail.ts +0 -18
  154. package/src/reviewer-agent.ts +0 -135
  155. package/src/reviewer-child-executor.ts +0 -252
  156. package/src/reviewer-construction.ts +0 -195
  157. package/src/reviewer-execution-ledger.ts +0 -212
  158. package/src/reviewer-failure-diagnostic.ts +0 -18
  159. package/src/reviewer-scope-prompt.ts +0 -24
  160. package/src/reviewer-settlement.ts +0 -74
  161. package/src/reviewer-workspace.ts +0 -105
  162. package/src/shape-unreadable-failure.ts +0 -49
@@ -1,4 +1,3 @@
1
- import { Type } from "typebox";
2
1
  /**
3
2
  * Thrown activation failure with a production-owned typed cause.
4
3
  * Prefer this over ad-hoc Error property tags so settlement retains typed identity.
@@ -16,7 +15,3 @@ export class ExplicitInternalActivationError extends Error {
16
15
  }
17
16
  }
18
17
  }
19
- /** Local replacement for Pi AI's convenience constructor. */
20
- export function stringEnum(values, options = {}) {
21
- return Type.Union(values.map((value) => Type.Literal(value)), options);
22
- }
@@ -13,9 +13,10 @@ const mergerInputSchema = Type.Object({
13
13
  resolutionScope: Type.Array(Type.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
14
14
  authorizedChecks: Type.Array(checkSchema)
15
15
  }, { additionalProperties: false });
16
+ const MERGER_STATUS_DESCRIPTION = "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
16
17
  const mergerOutputVariants = Type.Union([
17
- Type.Object({ status: Type.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
18
- Type.Object({ status: Type.Literal("escalate", { description: "escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type.String({ minLength: 1, description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
18
+ Type.Object({ status: Type.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
19
+ Type.Object({ status: Type.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type.String({ description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
19
20
  ]);
20
21
  const mergerOutputSchema = withInfrastructureFailureDeclaration(openToolObjectFromUnion(mergerOutputVariants));
21
22
  const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
@@ -53,10 +54,7 @@ function validateMergerInput(value) {
53
54
  return deepFreeze(structuredClone({ attemptId: value.attemptId.trim(), targetObjectId: asString(value.targetObjectId), sourceObjectId: asString(value.sourceObjectId), materials, expectedConflictPaths: asStringArray(value.expectedConflictPaths), resolutionScope: asStringArray(value.resolutionScope), authorizedChecks }));
54
55
  }
55
56
  function validateMergerOutput(value) {
56
- if (!record(value)) throw new Error("\u5408\u5E76\u56DE\u6267\u65E0\u5DF2\u8BC6\u522B\u7684\u6267\u884C\u5224\u522B");
57
- const status = typeof value.status === "string" ? value.status : void 0;
58
- if (status === "completed" || status === "escalate") return structuredClone(value);
59
- throw new Error("\u5408\u5E76\u56DE\u6267\u65E0\u5DF2\u8BC6\u522B\u7684\u6267\u884C\u5224\u522B");
57
+ return value;
60
58
  }
61
59
  export {
62
60
  MERGER_ACCEPTED_TEXT,
@@ -88,19 +88,14 @@ function targetIsValid(value) {
88
88
  function normalizeTarget(value) {
89
89
  if (!exactRecord(value)) return void 0;
90
90
  const role = typeof value.role === "string" ? value.role.trim() : "";
91
- if (!targetRoles.has(role)) return void 0;
92
- const metadata = packagedRoleMetadata(role);
93
- if (metadata === void 0) return void 0;
91
+ if (role === "") return void 0;
94
92
  if (value.phase === void 0 || value.phase === null) {
95
93
  return { role, phase: null };
96
94
  }
97
95
  if (value.phase === "plan" || value.phase === "apply") {
98
- if (metadata.phases.includes(value.phase)) {
99
- return { role, phase: value.phase };
100
- }
101
- return { role, phase: null };
96
+ return { role, phase: value.phase };
102
97
  }
103
- return void 0;
98
+ return { role, phase: null };
104
99
  }
105
100
  function normalizeMatches(value) {
106
101
  if (!exactRecord(value)) return void 0;
@@ -130,12 +125,14 @@ function normalizeCandidate(value) {
130
125
  const matches = normalizeMatches(value.matches);
131
126
  const id = typeof value.id === "string" && value.id.trim() !== "" ? value.id : void 0;
132
127
  const reason = typeof value.reason === "string" && value.reason.trim() !== "" ? value.reason : void 0;
128
+ const command = typeof value.command === "string" ? value.command : void 0;
133
129
  return {
134
130
  ...id === void 0 ? {} : { id },
135
131
  ...matches === void 0 ? {} : { matches },
136
132
  ...route === void 0 || route.length === 0 ? {} : { route },
137
133
  ...next === void 0 ? {} : { next },
138
- ...reason === void 0 ? {} : { reason }
134
+ ...reason === void 0 ? {} : { reason },
135
+ ...command === void 0 ? {} : { command }
139
136
  };
140
137
  }
141
138
  function normalizePrepareOutput(value) {
@@ -151,9 +148,6 @@ function routeText(route) {
151
148
  function targetText(target) {
152
149
  return target.phase === null ? target.role : `${target.role} ${target.phase}`;
153
150
  }
154
- function oneLine(value) {
155
- return value.split(/\r?\n/, 1)[0].trim();
156
- }
157
151
  function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
158
152
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
159
153
  if (provenance === "placeholder") return subjectRoot;
@@ -211,16 +205,20 @@ function selectNavigatorCandidate(candidates, settlement) {
211
205
  return { candidate: unbound, matchedToSettlement: false };
212
206
  }
213
207
  function formatNavigatorReport(report) {
214
- const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [`\u8DEF\u4E66\u8BFB\u53D6\u5931\u8D25\uFF1A${oneLine(report.routePlaybookReadFailure)}`];
208
+ const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [`\u8DEF\u4E66\u8BFB\u53D6\u5931\u8D25\uFF1A${report.routePlaybookReadFailure}`];
215
209
  if (report.disposition === "no-advice") return playbookFailure.join("\n");
216
- if (report.disposition === "unavailable") return [...playbookFailure, `\u5BFC\u822A\u4E0D\u53EF\u7528\uFF1A${oneLine(report.unavailableReason ?? "\u672A\u80FD\u5B8C\u6210\u5BFC\u822A\u51C6\u5907")}`].join("\n");
217
- if (report.disposition === "arrival") return [...playbookFailure, oneLine(report.arrivalMessage ?? "\u5DF2\u5230\u8FBE\u76EE\u7684\u5730")].join("\n");
210
+ if (report.disposition === "unavailable") {
211
+ return [...playbookFailure, ...report.unavailableReason ? [report.unavailableReason] : []].join("\n");
212
+ }
213
+ if (report.disposition === "arrival") {
214
+ return [...playbookFailure, ...report.arrivalMessage ? [report.arrivalMessage] : []].join("\n");
215
+ }
218
216
  return [
219
217
  ...playbookFailure,
220
218
  ...report.route === void 0 ? [] : [`\u8DEF\u7EBF\uFF1A${routeText(report.route)}`],
221
- `\u4E0B\u4E00\u6B65\uFF1A${targetText(report.next)}`,
222
- ...report.reason === void 0 || report.reason.trim() === "" ? [] : [`\u7406\u7531\uFF1A${oneLine(report.reason)}`],
223
- ...report.command === void 0 || report.command.trim() === "" ? [] : [`\u547D\u4EE4\uFF1A${oneLine(report.command)}`]
219
+ ...report.next === void 0 ? [] : [`\u4E0B\u4E00\u6B65\uFF1A${targetText(report.next)}`],
220
+ ...report.reason === void 0 || report.reason.trim() === "" ? [] : [`\u7406\u7531\uFF1A${report.reason}`],
221
+ ...report.command === void 0 || report.command.trim() === "" ? [] : [`\u547D\u4EE4\uFF1A${report.command}`]
224
222
  ].join("\n");
225
223
  }
226
224
  function settlementNavigationFromEvent(event) {
@@ -234,30 +232,6 @@ function settlementNavigationFromEvent(event) {
234
232
  ...event.command === void 0 ? {} : { command: event.command }
235
233
  };
236
234
  }
237
- function appendNavigatorReportToContent(content, reportText) {
238
- if (reportText === "") return content.slice();
239
- const parts = content.slice();
240
- for (let index = parts.length - 1; index >= 0; index -= 1) {
241
- const part = parts[index];
242
- if (part !== void 0 && part.type === "text" && typeof part.text === "string") {
243
- parts[index] = { ...part, type: "text", text: `${part.text}
244
- ${reportText}` };
245
- return parts;
246
- }
247
- }
248
- return [...parts, { type: "text", text: reportText }];
249
- }
250
- function decorateSettlementWithNavigation(event, presentation) {
251
- if (presentation === void 0) return void 0;
252
- if (settlementNavigationFromEvent(presentation.event) === void 0) return void 0;
253
- const { routePlaybookReadFailure: _advisoryFailure, ...receiptReport } = presentation.report;
254
- const reportText = formatNavigatorReport(receiptReport);
255
- if (reportText === "") return void 0;
256
- return {
257
- content: appendNavigatorReportToContent(event.content, reportText),
258
- details: event.details
259
- };
260
- }
261
235
  function createNavigatorAttendance(options) {
262
236
  let preparation;
263
237
  let sessionReady;
@@ -367,12 +341,17 @@ ${text}
367
341
  let output;
368
342
  let prepareBatchRejected = false;
369
343
  outputSink = (value) => {
370
- if (prepareBatchRejected || output !== void 0) {
371
- output = void 0;
372
- prepareBatchRejected = true;
373
- throw new Error("Navigator preparation must submit exactly one typed candidate batch");
344
+ if (output === void 0) {
345
+ output = value;
346
+ return;
374
347
  }
375
- output = value;
348
+ const prior2 = output.candidates;
349
+ const next = value.candidates;
350
+ const merged = [
351
+ ...Array.isArray(prior2) ? prior2 : prior2 === void 0 ? [] : [prior2],
352
+ ...Array.isArray(next) ? next : next === void 0 ? [] : [next]
353
+ ];
354
+ output = { ...value, candidates: merged };
376
355
  };
377
356
  const tool = createNavigatorPrepareTool((value) => {
378
357
  outputSink?.(value);
@@ -418,7 +397,7 @@ ${text}
418
397
  if (exactRecord(prior) && Array.isArray(prior.route) && prior.route.every((target) => targetIsValid(target))) {
419
398
  previousRoute = prior.route.map((target) => ({ role: target.role, phase: target.phase }));
420
399
  }
421
- const publicSettlementHistory = activeSession.entries().filter((entry) => exactRecord(entry) && entry.type === "custom" && entry.customType === SETTLEMENT_ENTRY && exactRecord(entry.data)).slice(-8).map((entry) => entry.data);
400
+ const publicSettlementHistory = activeSession.entries().filter((entry) => exactRecord(entry) && entry.type === "custom" && entry.customType === SETTLEMENT_ENTRY && exactRecord(entry.data)).map((entry) => entry.data);
422
401
  const projection = {
423
402
  subjectKey,
424
403
  subject,
@@ -618,7 +597,7 @@ ${helpContext}
618
597
  preparationFailure ??= error;
619
598
  }
620
599
  }
621
- report = preparationFailure === void 0 ? { disposition: "arrival", arrivalMessage: settlement.message ?? "\u5DF2\u5230\u8FBE\u76EE\u7684\u5730" } : unavailable(invocationId, preparationFailure);
600
+ report = preparationFailure === void 0 ? { disposition: "arrival", ...settlement.message === void 0 ? {} : { arrivalMessage: settlement.message } } : unavailable(invocationId, preparationFailure);
622
601
  } else if (preparation === void 0) {
623
602
  report = unavailable(invocationId, "Navigator preparation did not start");
624
603
  } else {
@@ -642,12 +621,12 @@ ${helpContext}
642
621
  } else {
643
622
  const selectedRoute = selectedCandidate.route;
644
623
  const routeChanged = selectedRoute !== void 0 && !routeEqual(previousRoute, selectedRoute);
645
- const command = renderPublicAkRoleCommand(selectedCandidate.next);
624
+ const command = typeof selectedCandidate.command === "string" && selectedCandidate.command.trim() !== "" ? selectedCandidate.command : renderPublicAkRoleCommand(selectedCandidate.next);
646
625
  report = {
647
626
  disposition: "recommendation",
648
627
  ...routeChanged ? { route: selectedRoute } : {},
649
628
  next: selectedCandidate.next,
650
- ...selectedCandidate.reason === void 0 ? {} : { reason: oneLine(selectedCandidate.reason) },
629
+ ...selectedCandidate.reason === void 0 ? {} : { reason: selectedCandidate.reason },
651
630
  ...command === void 0 ? {} : { command }
652
631
  };
653
632
  if (selectedRoute !== void 0) {
@@ -714,7 +693,6 @@ export {
714
693
  createNativeNavigatorSessionFactory,
715
694
  createNavigatorAttendance,
716
695
  createNavigatorPrepareTool,
717
- decorateSettlementWithNavigation,
718
696
  formatNavigatorReport,
719
697
  navigatorModelSettingPath,
720
698
  navigatorProviderFailure,
@@ -87,7 +87,6 @@ function markerMatchesExpectedIdentity(marker, expected) {
87
87
  function classifyPackagedRoleTerminalResult(message) {
88
88
  if (typeof message.toolName !== "string") return { kind: "nonterminal" };
89
89
  if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName)) return { kind: "nonterminal" };
90
- if (typeof message.details === "object" && message.details !== null && message.details.submissionDisposition === "pending-round-closure") return { kind: "nonterminal" };
91
90
  const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
92
91
  const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
93
92
  if (message.isError === true) {
@@ -8,6 +8,7 @@ import {
8
8
  parseNavigatorModelSetting,
9
9
  resolveNavigatorSeatSelection
10
10
  } from "./navigator-session-contracts.js";
11
+ import { lastRolePayloadRecord } from "./public-cli/terminal.js";
11
12
  function providerFailureFromPublicTerminal(outcome) {
12
13
  const facts = outcome.decisiveFacts;
13
14
  const secondary = typeof facts.secondaryEvidence === "object" && facts.secondaryEvidence !== null ? facts.secondaryEvidence : void 0;
@@ -100,7 +101,7 @@ function createNativeNavigatorSessionFactory() {
100
101
  if (outcome.kind !== "accepted") {
101
102
  return;
102
103
  }
103
- const candidates = outcome.decisiveFacts.candidates;
104
+ const candidates = lastRolePayloadRecord(outcome.payloads ?? [])?.candidates;
104
105
  if (!Array.isArray(candidates)) {
105
106
  return;
106
107
  }
@@ -37,12 +37,7 @@ function isRecord(value) {
37
37
  return typeof value === "object" && value !== null && !Array.isArray(value);
38
38
  }
39
39
  function projectLawfulNotaryOutput(value) {
40
- if (!isRecord(value)) return void 0;
41
- const status = typeof value.status === "string" ? value.status : void 0;
42
- if (status === "bounce" || status === "pass" || status === "escalate") {
43
- return value;
44
- }
45
- return void 0;
40
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
46
41
  }
47
42
  function retainNotarySubmission(value) {
48
43
  if (value === void 0) return { missing: "arguments" };
@@ -53,11 +48,10 @@ function retainNotarySubmission(value) {
53
48
  }
54
49
  }
55
50
  function validateRecordedNotaryOutput(value) {
56
- const projected = projectLawfulNotaryOutput(value);
57
- if (projected === void 0) {
58
- throw new Error("Notary output has no recognized execution discriminator");
51
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
52
+ throw new Error("Notary output is not an object");
59
53
  }
60
- return projected;
54
+ return value;
61
55
  }
62
56
  export {
63
57
  NOTARY_ACCEPTED_TEXT,
@@ -24,30 +24,12 @@ export const auditorOutputSchema = withInfrastructureFailureDeclaration(openTool
24
24
  function isRecord(value) {
25
25
  return typeof value === "object" && value !== null && !Array.isArray(value);
26
26
  }
27
+ /** #836: no field drop — original object is the receipt. */
27
28
  export function projectLawfulAuditorOutput(value) {
28
- if (!isRecord(value))
29
- return undefined;
30
- if (value.status === "pass")
31
- return { status: "pass" };
32
- if (value.status === "bounce") {
33
- return {
34
- status: "bounce",
35
- ...(Object.hasOwn(value, "violations") ? { violations: value.violations } : {}),
36
- };
37
- }
38
- if (value.status === "escalate") {
39
- return {
40
- status: "escalate",
41
- ...(Object.hasOwn(value, "conflicts") ? { conflicts: value.conflicts } : {}),
42
- ...(Object.hasOwn(value, "decisionGate") ? { decisionGate: value.decisionGate } : {}),
43
- };
44
- }
45
- return undefined;
29
+ return isRecord(value) ? value : undefined;
46
30
  }
47
31
  export function validateRecordedAuditorOutput(value) {
48
- const projected = projectLawfulAuditorOutput(value);
49
- if (projected === undefined) {
50
- throw new Error("Auditor output has no recognized execution discriminator");
51
- }
52
- return projected;
32
+ if (!isRecord(value))
33
+ throw new Error("Auditor output is not an object");
34
+ return value;
53
35
  }
@@ -1,41 +1,41 @@
1
1
  import { Type } from "typebox";
2
- import { FIXER_PREREQUISITE_ID_PATTERN } from "./fixer-packet.js";
3
2
  import { openToolObjectFromUnion } from "../open-tool-schema.js";
4
3
  import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
5
4
  const FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
6
5
  const FIXER_ACCEPTED_TEXT = "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7";
7
- const nonblankTransportString = Type.String({ minLength: 1 });
8
- const authorityBlockerSchema = Type.Object({ cause: Type.Literal("authority_violation"), evidence: nonblankTransportString });
9
- const prerequisiteBlockerSchema = Type.Object({ cause: Type.Literal("prerequisite_unmet"), prerequisiteId: Type.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }), evidence: nonblankTransportString });
6
+ const transportString = Type.String();
7
+ const authorityBlockerSchema = Type.Object({ cause: Type.Optional(Type.Literal("authority_violation")), evidence: Type.Optional(transportString) });
8
+ const prerequisiteBlockerSchema = Type.Object({ cause: Type.Optional(Type.Literal("prerequisite_unmet")), prerequisiteId: Type.Optional(transportString), evidence: Type.Optional(transportString) });
10
9
  const blockerSchema = Type.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
11
- const exceptionSchema = Type.Object({ where: nonblankTransportString, reason: nonblankTransportString });
10
+ const exceptionSchema = Type.Object({ where: Type.Optional(transportString), reason: Type.Optional(transportString) });
12
11
  const testEvidenceSchema = Type.Object({
13
- contract: Type.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" }),
14
- minimumNecessaryCost: Type.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" }),
15
- measuredDuration: Type.String({ minLength: 1, description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" })
12
+ contract: Type.Optional(Type.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
13
+ minimumNecessaryCost: Type.Optional(Type.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
14
+ measuredDuration: Type.Optional(Type.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
16
15
  }, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
17
16
  const completedClassResultSchema = Type.Object({
18
- name: nonblankTransportString,
19
- disposition: Type.Literal("completed"),
20
- searchScope: nonblankTransportString,
21
- exceptions: Type.Array(exceptionSchema),
22
- commitSha: nonblankTransportString
17
+ name: Type.Optional(transportString),
18
+ disposition: Type.Optional(Type.Literal("completed")),
19
+ searchScope: Type.Optional(transportString),
20
+ exceptions: Type.Optional(Type.Array(exceptionSchema)),
21
+ commitSha: Type.Optional(transportString)
23
22
  });
24
23
  const refusedClassResultSchema = Type.Object({
25
- name: nonblankTransportString,
26
- disposition: Type.Literal("refused"),
27
- remainingScope: nonblankTransportString,
28
- blocker: blockerSchema
24
+ name: Type.Optional(transportString),
25
+ disposition: Type.Optional(Type.Literal("refused")),
26
+ remainingScope: Type.Optional(transportString),
27
+ blocker: Type.Optional(blockerSchema)
29
28
  });
30
29
  const classResultSchema = Type.Union([completedClassResultSchema, refusedClassResultSchema]);
31
- const completedClassResultsSchema = Type.Array(completedClassResultSchema, { minItems: 1 });
30
+ const completedClassResultsSchema = Type.Array(completedClassResultSchema);
31
+ const FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
32
32
  const fixerOutputVariants = Type.Union([
33
- Type.Object({ status: Type.Literal("planned", { description: "planned \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
34
- Type.Object({ status: Type.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ minLength: 1, description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
35
- Type.Object({ status: Type.Literal("unfinished", { description: "unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type.Optional(Type.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type.Optional(Type.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type.Optional(testEvidenceSchema) }),
36
- Type.Object({ status: Type.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) }),
37
- Type.Object({ status: Type.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
38
- Type.Object({ status: Type.Literal("partially_completed", { description: "partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) })
33
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
34
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
35
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type.Optional(Type.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type.Optional(Type.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type.Optional(testEvidenceSchema) }),
36
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) }),
37
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
38
+ Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) })
39
39
  ]);
40
40
  const fixerOutputSchema = withInfrastructureFailureDeclaration(
41
41
  openToolObjectFromUnion(fixerOutputVariants)
@@ -43,33 +43,9 @@ const fixerOutputSchema = withInfrastructureFailureDeclaration(
43
43
  function validateFixerOutput(value, _phase) {
44
44
  return value;
45
45
  }
46
- function safeProperty(value, property) {
47
- if (value === null || typeof value !== "object") return void 0;
48
- try {
49
- return value[property];
50
- } catch {
51
- return void 0;
52
- }
53
- }
54
- function validateFixerOutputForPacket(value, phase, packet) {
55
- const output = validateFixerOutput(value, phase);
56
- const declaredIds = new Set(packet.prerequisites.map((entry) => entry.id));
57
- const topLevelBlocker = safeProperty(output, "blocker");
58
- const classResults = safeProperty(output, "classResults");
59
- const blockers = topLevelBlocker === void 0 ? Array.isArray(classResults) ? classResults.map((entry) => safeProperty(entry, "blocker")) : [] : [topLevelBlocker];
60
- for (const blocker of blockers) {
61
- if (safeProperty(blocker, "cause") !== "prerequisite_unmet") continue;
62
- const prerequisiteId = safeProperty(blocker, "prerequisiteId");
63
- if (typeof prerequisiteId === "string" && !declaredIds.has(prerequisiteId)) {
64
- throw new Error("Fixer output violates blocker.prerequisiteId declared-prerequisite constraint");
65
- }
66
- }
67
- return output;
68
- }
69
46
  export {
70
47
  FIXER_ACCEPTED_TEXT,
71
48
  FIXER_OUTPUT_TOOL_NAME,
72
49
  fixerOutputSchema,
73
- validateFixerOutput,
74
- validateFixerOutputForPacket
50
+ validateFixerOutput
75
51
  };
@@ -27,21 +27,11 @@ function asStringArray(value) {
27
27
  return value.filter((item) => typeof item === "string");
28
28
  }
29
29
  function projectLawfulGatekeeperOutput(value) {
30
- if (!isRecord(value)) return void 0;
31
- if (value.status === "pass") {
32
- return Array.isArray(value.findings) ? { status: "pass", findings: asStringArray(value.findings) } : { status: "pass" };
33
- }
34
- if (value.status === "dispatch" && (value.officer === "inspector" || value.officer === "notary")) {
35
- return { status: "dispatch", officer: value.officer };
36
- }
37
- return void 0;
30
+ return isRecord(value) ? value : void 0;
38
31
  }
39
32
  function validateRecordedGatekeeperOutput(value) {
40
- const projected = projectLawfulGatekeeperOutput(value);
41
- if (projected === void 0) {
42
- throw new Error("Gatekeeper output has no recognized execution discriminator");
43
- }
44
- return projected;
33
+ if (!isRecord(value)) throw new Error("Gatekeeper output is not an object");
34
+ return value;
45
35
  }
46
36
  export {
47
37
  GATEKEEPER_ACCEPTED_TEXT,
@@ -19,16 +19,13 @@ function isRecord(value) {
19
19
  return typeof value === "object" && value !== null && !Array.isArray(value);
20
20
  }
21
21
  function projectLawfulNavigatorOutput(value) {
22
- if (!isRecord(value) || !Array.isArray(value.candidates)) return void 0;
23
- if (value.status !== "advice") return void 0;
24
- return { status: "advice", candidates: value.candidates.filter(isRecord) };
22
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
25
23
  }
26
24
  function validateRecordedNavigatorOutput(value) {
27
- const projected = projectLawfulNavigatorOutput(value);
28
- if (projected === void 0) {
29
- throw new Error("Navigator output has no recognized execution discriminator");
25
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
26
+ throw new Error("Navigator output is not an object");
30
27
  }
31
- return projected;
28
+ return value;
32
29
  }
33
30
  export {
34
31
  NAVIGATOR_ACCEPTED_TEXT,
@@ -1,104 +1,10 @@
1
1
  const REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
2
2
  const REVIEWER_ACCEPTED_TEXT = "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7";
3
- function isRecord(value) {
4
- return typeof value === "object" && value !== null && !Array.isArray(value);
5
- }
6
- function read(value, key) {
7
- if (!isRecord(value)) return void 0;
8
- try {
9
- return value[key];
10
- } catch {
11
- return void 0;
12
- }
13
- }
14
- function readAmendments(output) {
15
- const amendments = read(output, "amendments");
16
- if (!isRecord(amendments)) return void 0;
17
- const slots = {};
18
- for (const axis of ["standards", "spec"]) {
19
- const value = read(amendments, axis);
20
- if (typeof value === "string") slots[axis] = value;
21
- }
22
- if (slots.standards === void 0 && slots.spec === void 0) return void 0;
23
- return Object.freeze(slots);
24
- }
25
3
  function validateReviewerIntent(output) {
26
- const status = read(output, "status");
27
- const amendments = readAmendments(output);
28
- if (status === "completed") {
29
- return amendments === void 0 ? { status } : { status, amendments };
30
- }
31
- if (status === "refused") {
32
- return amendments === void 0 ? { status, diagnostic: read(output, "diagnostic") } : { status, diagnostic: read(output, "diagnostic"), amendments };
33
- }
34
- throw new Error("Reviewer output has no recognized execution intent");
35
- }
36
- function validateRuntimeReviewerReceipt(output) {
37
- const status = read(output, "status");
38
- const acceptedBatch = read(output, "acceptedBatch");
39
- const identities = read(output, "identities");
40
- const construction = read(identities, "construction");
41
- const target = read(identities, "target");
42
- const reports = read(output, "reports");
43
- const outcomes = read(output, "outcomes");
44
- const legs = read(acceptedBatch, "legs");
45
- if (acceptedBatch !== void 0 || construction !== void 0 || target !== void 0) {
46
- if (!isRecord(acceptedBatch) || !isRecord(construction) || !isRecord(target) || !Array.isArray(legs))
47
- throw new Error("Incomplete Reviewer accepted-batch identity");
48
- const objectFormat = read(target, "objectFormat");
49
- const objectId = (value) => typeof value === "string" && new RegExp(objectFormat === "sha1" ? "^[0-9a-f]{40}$" : "^[0-9a-f]{64}$").test(value);
50
- const refs = read(target, "refs");
51
- const skillText = read(read(identities, "canonicalSkill"), "text");
52
- if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !isRecord(refs) || Object.values(refs).some((ref) => !isRecord(ref) || !objectId(read(ref, "objectId")) || read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId"))))
53
- throw new Error("Invalid Reviewer construction or target identity");
54
- const expectedAxes = legs.map((leg) => read(leg, "axis"));
55
- if (expectedAxes[0] !== "standards" || expectedAxes.length === 2 && expectedAxes[1] !== "spec" || expectedAxes.length < 1 || expectedAxes.length > 2)
56
- throw new Error("Invalid Reviewer accepted-leg projection");
57
- if (!isRecord(outcomes) || !isRecord(reports)) throw new Error("Accepted Reviewer batch lacks outcomes or reports");
58
- const outcomeAxes = Object.keys(outcomes).filter((axis) => axis === "standards" || axis === "spec");
59
- if (outcomeAxes.length !== expectedAxes.length || outcomeAxes.some((axis, index) => axis !== expectedAxes[index]))
60
- throw new Error("Reviewer outcomes must exactly cover accepted legs in canonical order");
61
- for (const [index, axisValue] of expectedAxes.entries()) {
62
- const axis = axisValue;
63
- const outcome = read(outcomes, axis);
64
- if (!isRecord(outcome)) throw new Error("Reviewer accepted leg lacks outcome");
65
- const expectedPrompt = read(read(legs[index], "prompt"), "text");
66
- const actualPrompt = read(read(outcome, "prompt"), "text");
67
- if (expectedPrompt !== actualPrompt) throw new Error("Reviewer outcome prompt disagrees with accepted leg");
68
- const status2 = read(outcome, "status");
69
- const report = read(reports, axis);
70
- if (status2 === "successful" && report === void 0)
71
- throw new Error("Successful Reviewer outcome lacks report");
72
- if (status2 === "failed" && report !== void 0) throw new Error("Failed Reviewer outcome cannot bind a report");
73
- }
74
- const specDisposition = read(output, "specDisposition");
75
- if (specDisposition === "launched") {
76
- if (expectedAxes.length !== 2 || expectedAxes[0] !== "standards" || expectedAxes[1] !== "spec") {
77
- throw new Error("Reviewer specDisposition launched requires Standards+Spec accepted legs");
78
- }
79
- } else if (specDisposition === "skipped-missing") {
80
- if (expectedAxes.length !== 1 || expectedAxes[0] !== "standards") {
81
- throw new Error("Reviewer specDisposition skipped-missing requires Standards-only accepted legs");
82
- }
83
- } else if (specDisposition !== void 0) {
84
- throw new Error("Invalid Reviewer specDisposition");
85
- }
86
- }
87
4
  return output;
88
5
  }
89
- function projectReviewerIntentToReceipt(intentValue, receiptValue) {
90
- const intent = validateReviewerIntent(intentValue);
91
- const receipt = validateRuntimeReviewerReceipt(receiptValue);
92
- const receiptStatus = String(receipt.status);
93
- if (receiptStatus !== intent.status || (intent.status === "completed" ? receipt.diagnostic !== void 0 : receipt.diagnostic !== intent.diagnostic)) {
94
- throw new Error("Reviewer intent and runtime receipt disagree");
95
- }
96
- return receipt;
97
- }
98
6
  export {
99
7
  REVIEWER_ACCEPTED_TEXT,
100
8
  REVIEWER_OUTPUT_TOOL_NAME,
101
- projectReviewerIntentToReceipt,
102
- validateReviewerIntent,
103
- validateRuntimeReviewerReceipt
9
+ validateReviewerIntent
104
10
  };