@akagilnc/pi-workflow-roles 0.1.2383 → 0.1.2402

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 (57) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/audit-escalation.js +0 -13
  4. package/dist/compliance-transport.js +28 -5
  5. package/dist/doctor-contracts.js +2 -9
  6. package/dist/dossier-resolution.js +21 -2
  7. package/dist/engine-detour-tool.js +10 -35
  8. package/dist/evidence-child-executor.js +12 -4
  9. package/dist/merger-contracts.js +2 -8
  10. package/dist/navigator-attendance.js +1 -9
  11. package/dist/navigator-invocation-identity.js +16 -4
  12. package/dist/notary-contracts.js +7 -25
  13. package/dist/package-contracts/judge-output.js +1 -4
  14. package/dist/package-contracts/reviewer-output.js +1 -7
  15. package/dist/package-contracts/terminating-tools.js +6 -11
  16. package/dist/public-cli/main.js +125 -475
  17. package/package.json +1 -1
  18. package/scripts/build-package.mjs +1 -2
  19. package/src/analyst-gate-cycles-read.ts +5 -8
  20. package/src/analyst-metric-families/acceptance-success-rework.ts +3 -6
  21. package/src/audit-escalation.ts +0 -25
  22. package/src/collector-role.ts +1 -8
  23. package/src/compliance-transport.ts +38 -6
  24. package/src/doctor-auditor.ts +3 -3
  25. package/src/doctor-contracts.ts +3 -18
  26. package/src/doctor-role.ts +1 -5
  27. package/src/dossier-resolution.ts +25 -4
  28. package/src/engine-detour-tool.ts +16 -51
  29. package/src/evidence-child-executor.ts +12 -4
  30. package/src/factory-board.ts +2 -4
  31. package/src/gatekeeper-role.ts +33 -43
  32. package/src/judge-auditor.ts +3 -3
  33. package/src/judge-role.ts +1 -8
  34. package/src/merger-contracts.ts +3 -17
  35. package/src/merger-role.ts +1 -8
  36. package/src/navigator-attendance.ts +1 -14
  37. package/src/navigator-invocation-identity.ts +34 -13
  38. package/src/notary-contracts.ts +9 -43
  39. package/src/notary-role.ts +3 -5
  40. package/src/package-contracts/judge-output.ts +2 -17
  41. package/src/package-contracts/reviewer-output.ts +2 -21
  42. package/src/package-contracts/terminating-tools.ts +5 -14
  43. package/src/package-contracts/worker-output.ts +2 -10
  44. package/src/public-cli/doctor-run.ts +0 -2
  45. package/src/public-cli/fixer-run.ts +0 -15
  46. package/src/public-cli/judge-run.ts +0 -16
  47. package/src/public-cli/notary-run.ts +1 -1
  48. package/src/public-cli/one-shot-dispatch.ts +1 -1
  49. package/src/public-cli/reviewer-run.ts +0 -15
  50. package/src/public-cli/settlement.ts +110 -368
  51. package/src/public-cli/terminal.ts +3 -71
  52. package/src/reviewer-auditor.ts +3 -3
  53. package/src/reviewer-role.ts +2 -11
  54. package/src/role-runtime.ts +43 -37
  55. package/src/worker-role.ts +2 -14
  56. package/dist/engine-labor-fallback.js +0 -136
  57. package/src/engine-labor-fallback.ts +0 -270
@@ -1,11 +1,5 @@
1
1
  /** Package-owned Reviewer intent and runtime-receipt leaves — no role registration surface. */
2
2
 
3
- import {
4
- seatFallbackBaseStatus,
5
- seatFallbackStatusHasLawfulEvidence,
6
- type SeatFallbackTaintedStatus,
7
- type WithEngineLaborFallback,
8
- } from "../engine-labor-fallback.ts";
9
3
  import type { ReviewerAcceptedEvidence, ReviewerFailureClassification, ReviewerWorkspaceDisposition } from "../reviewer-execution-ledger.ts";
10
4
 
11
5
  export const REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
@@ -36,7 +30,7 @@ export type RuntimeReviewerAcceptedBatch = Readonly<{
36
30
  }>;
37
31
  /** Honest Spec-child disposition on the receipt face. */
38
32
  export type RuntimeReviewerSpecDisposition = "launched" | "skipped-missing";
39
- type RuntimeReviewerReceiptV2Clean = Readonly<{
33
+ export type RuntimeReviewerReceiptV2 = Readonly<{
40
34
  version: 2;
41
35
  status: "completed" | "refused";
42
36
  diagnostic?: string;
@@ -55,14 +49,6 @@ type RuntimeReviewerReceiptV2Clean = Readonly<{
55
49
  target?: ReviewerAcceptedEvidence["target"];
56
50
  }>;
57
51
  }>;
58
- /** Clean runtime receipt or seat-fallback tainted accepted receipt (ADR 0071). */
59
- export type RuntimeReviewerReceiptV2 =
60
- | RuntimeReviewerReceiptV2Clean
61
- | WithEngineLaborFallback<
62
- Omit<RuntimeReviewerReceiptV2Clean, "status"> & {
63
- status: SeatFallbackTaintedStatus<"completed" | "refused">;
64
- }
65
- >;
66
52
 
67
53
  function isRecord(value: unknown): value is Record<string, unknown> {
68
54
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -102,10 +88,6 @@ export function validateReviewerIntent(output: unknown): ReviewerIntent {
102
88
  /** Validate runtime-owned facts at their real identity seams (target pins + plain text). */
103
89
  export function validateRuntimeReviewerReceipt(output: unknown): RuntimeReviewerReceiptV2 {
104
90
  const status = read(output, "status");
105
- // ADR 0071: tainted top-level status requires latch-shaped engineLaborFallback evidence.
106
- if (typeof status === "string" && !seatFallbackStatusHasLawfulEvidence(status, output)) {
107
- throw new Error("Reviewer receipt has no recognized execution discriminator");
108
- }
109
91
  const acceptedBatch = read(output, "acceptedBatch");
110
92
  const identities = read(output, "identities");
111
93
  const construction = read(identities, "construction");
@@ -173,8 +155,7 @@ export function projectReviewerIntentToReceipt(intentValue: unknown, receiptValu
173
155
  const intent = validateReviewerIntent(intentValue);
174
156
  const receipt = validateRuntimeReviewerReceipt(receiptValue);
175
157
  const receiptStatus = String(receipt.status);
176
- const receiptBase = seatFallbackBaseStatus(receiptStatus);
177
- if (receiptBase !== intent.status || (intent.status === "completed" ? receipt.diagnostic !== undefined : receipt.diagnostic !== intent.diagnostic)) {
158
+ if (receiptStatus !== intent.status || (intent.status === "completed" ? receipt.diagnostic !== undefined : receipt.diagnostic !== intent.diagnostic)) {
178
159
  throw new Error("Reviewer intent and runtime receipt disagree");
179
160
  }
180
161
  return receipt;
@@ -25,10 +25,6 @@ import {
25
25
  type RuntimeReviewerReceiptV2,
26
26
  } from "./reviewer-output.ts";
27
27
  import { isAuditEscalationResult } from "../audit-escalation.ts";
28
- import {
29
- seatFallbackBaseStatus,
30
- seatFallbackStatusHasLawfulEvidence,
31
- } from "../engine-labor-fallback.ts";
32
28
  import { DOCTOR_OUTPUT_TOOL_NAME, validateDoctorSubmissionShape, validateRecordedDoctorOutput, type DoctorOutput, type DoctorSubmission } from "../doctor-contracts.ts";
33
29
  import { MERGER_ACCEPTED_TEXT, MERGER_OUTPUT_TOOL_NAME, validateMergerOutput, type MergerOutput } from "../merger-contracts.ts";
34
30
  import { NOTARY_ACCEPTED_TEXT, NOTARY_OUTPUT_TOOL_NAME, validateRecordedNotaryOutput, type NotaryOutput } from "../notary-contracts.ts";
@@ -168,19 +164,14 @@ export function validateAcceptedDetails(
168
164
  [COLLECTOR_OUTPUT_TOOL]: [],
169
165
  [DOCTOR_OUTPUT_TOOL_NAME]: ["completed", "refused"],
170
166
  [MERGER_OUTPUT_TOOL_NAME]: ["completed", "escalate"],
171
- [NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce", "incomplete"],
167
+ [NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
172
168
  };
173
169
  const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
174
- const baseDiscriminator = typeof discriminator === "string" ? seatFallbackBaseStatus(discriminator) : discriminator;
175
- // ADR 0071: `-by-fallback` is not independently lawful — require latch-shaped evidence.
176
- const taintedWithoutEvidence =
177
- typeof discriminator === "string" &&
178
- !seatFallbackStatusHasLawfulEvidence(discriminator, details);
170
+ const baseDiscriminator = discriminator;
179
171
  const runtimeBindingMissing =
180
172
  (toolName === DOCTOR_OUTPUT_TOOL_NAME && baseDiscriminator === "completed" && !(candidate?.cost !== null && typeof candidate?.cost === "object")) ||
181
173
  (toolName === REVIEWER_OUTPUT_TOOL_NAME && candidate?.version !== 2);
182
174
  if (
183
- taintedWithoutEvidence ||
184
175
  runtimeBindingMissing ||
185
176
  (!collectorDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator as string)))
186
177
  ) {
@@ -219,12 +210,12 @@ export function validateAcceptedLifecycle(
219
210
  const details = validateAcceptedDetails(toolName, detailsValue);
220
211
  if (toolName === DOCTOR_OUTPUT_TOOL_NAME) {
221
212
  const testimony = validateDoctorSubmissionShape(argumentsValue);
222
- if (seatFallbackBaseStatus(String(testimony.status)) === "refused") {
213
+ if ((String(testimony.status)) === "refused") {
223
214
  if (!deepEqual(testimony, details)) throw new Error("accepted tool lifecycle details mismatch");
224
215
  return details;
225
216
  }
226
217
  const receipt = details as DoctorOutput & { cost?: unknown };
227
- if (seatFallbackBaseStatus(String(receipt.status)) !== "completed") {
218
+ if ((String(receipt.status)) !== "completed") {
228
219
  throw new Error("accepted tool lifecycle details mismatch");
229
220
  }
230
221
  const { cost: _runtimeCost, ...projected } = receipt;
@@ -253,7 +244,7 @@ export function acceptedFacts(toolName: TerminatingToolName, details: AcceptedDe
253
244
  case MERGER_OUTPUT_TOOL_NAME: {
254
245
  const output = details as unknown as Record<string, unknown>;
255
246
  const status = output.status as string;
256
- return { status, ...(seatFallbackBaseStatus(status) === "completed" && typeof output.mergeCommitId === "string" ? { commit: output.mergeCommitId } : {}) };
247
+ return { status, ...(status === "completed" && typeof output.mergeCommitId === "string" ? { commit: output.mergeCommitId } : {}) };
257
248
  }
258
249
  case COLLECTOR_OUTPUT_TOOL:
259
250
  return { status: "collected" };
@@ -15,24 +15,16 @@ export type {
15
15
  } from "./fixer-output.ts";
16
16
  export { fixerPrerequisiteSchema, fixerPrerequisitesSchema, parseFixerPrerequisites, validateFixerPrerequisites } from "./fixer-packet.ts";
17
17
  export type { FixerInvocationInput, FixerPrerequisite } from "./fixer-packet.ts";
18
- import type { WithEngineLaborFallback } from "../engine-labor-fallback.ts";
19
18
  import { validateFixerOutput, type FixerOutput } from "./fixer-output.ts";
20
19
 
21
20
  export const CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
22
21
  export const CODER_ACCEPTED_TEXT = "Coder report accepted";
23
22
  export type WorkerRoleLabel = "Coder" | "Fixer";
24
- type CoderOutputClean =
23
+ export type CoderOutput =
25
24
  | { status: "planned"; report: string }
26
25
  | { status: "completed" | "refused"; report: string }
27
26
  | { status: "unfinished"; report: string; remainingScope: string; reason?: string };
28
- /** Clean submission shape or seat-fallback tainted accepted receipt (ADR 0071). */
29
- export type CoderOutput =
30
- | CoderOutputClean
31
- | WithEngineLaborFallback<CoderOutputClean>;
32
- export type WorkerOutput =
33
- | CoderOutput
34
- | FixerOutput
35
- | WithEngineLaborFallback<FixerOutput>;
27
+ export type WorkerOutput = CoderOutput | FixerOutput;
36
28
 
37
29
  export function validateAcceptedCoderDetails(output: unknown): CoderOutput {
38
30
  return output as CoderOutput;
@@ -21,7 +21,6 @@ import {
21
21
  } from "./one-shot-dispatch.ts";
22
22
  import {
23
23
  presentStructuralRejection,
24
- trySettleComplianceAuditIncompleteTerminalResult,
25
24
  trySettleDoctorTerminalResult,
26
25
  } from "./settlement.ts";
27
26
  import type { CliIo } from "./cli-io.ts";
@@ -122,7 +121,6 @@ export async function runPublicDoctor(
122
121
  trySettle: trySettleDoctorTerminalResult,
123
122
  shouldPresentSettled: (terminal) =>
124
123
  isLawfulTypedTerminalOutcome(terminal.roleOutcome),
125
- trySettleSecondary: trySettleComplianceAuditIncompleteTerminalResult,
126
124
  },
127
125
  ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
128
126
  });
@@ -70,7 +70,6 @@ import {
70
70
  explicitInternalKnownFailureClassificationInput,
71
71
  settleFailureTerminalResult,
72
72
  trySettleFixerTerminalResult,
73
- trySettleComplianceAuditIncompleteTerminalResult,
74
73
  } from "./settlement.ts";
75
74
  import type { CliIo } from "./cli-io.ts";
76
75
  import type {
@@ -390,20 +389,6 @@ async function dispatchAdmittedFixer(input: {
390
389
  };
391
390
  }
392
391
 
393
- const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
394
- if (auditIncomplete !== undefined) {
395
- await markRunTerminal(admitted.runDirectory).catch(() => undefined);
396
- if (auditIncomplete.roleOutcome.kind === "failure") {
397
- presentFailureTerminal(auditIncomplete, io);
398
- } else {
399
- io.stdout(formatTerminalResult(auditIncomplete));
400
- }
401
- return {
402
- exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
403
- admitted,
404
- terminal: auditIncomplete,
405
- };
406
- }
407
392
 
408
393
  const credentialFailure = postRunMissingCredentialFailure(
409
394
  result,
@@ -64,7 +64,6 @@ import {
64
64
  readEngineDetourInfrastructureFailure,
65
65
  settleJudgeFailureTerminalResult,
66
66
  trySettleJudgeTerminalResult,
67
- trySettleComplianceAuditIncompleteTerminalResult,
68
67
  } from "./settlement.ts";
69
68
  import type { CliIo } from "./cli-io.ts";
70
69
  import type {
@@ -370,21 +369,6 @@ async function dispatchAdmittedJudge(input: {
370
369
  };
371
370
  }
372
371
 
373
- const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
374
- if (auditIncomplete !== undefined) {
375
- await markRunTerminal(admitted.runDirectory).catch(() => undefined);
376
- if (auditIncomplete.roleOutcome.kind === "failure") {
377
- presentFailureTerminal(auditIncomplete, io);
378
- } else {
379
- io.stdout(formatTerminalResult(auditIncomplete));
380
- }
381
- return {
382
- exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
383
- admitted,
384
- terminal: auditIncomplete,
385
- };
386
- }
387
-
388
372
  // Prefer engine-detour infrastructure failure already on the session principal
389
373
  // over a later secondary provider-stop after abort (#357 T2 / collector-isomorphic).
390
374
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(
@@ -109,7 +109,7 @@ export async function runPublicNotary(
109
109
  extraArgs,
110
110
  adapters: {
111
111
  trySettle: trySettleNotaryTerminalResult,
112
- // Accepted receipts and residual incomplete share one present path.
112
+ // Accepted receipts and failure terminals both present via shared path.
113
113
  shouldPresentSettled: () => true,
114
114
  },
115
115
  ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
@@ -59,7 +59,7 @@ export type OneShotRunEnv = {
59
59
  /**
60
60
  * Role-specific settlement hooks. Lifecycle coordination stays in this module.
61
61
  * - Doctor: present only lawful typed outcomes; optional compliance-audit secondary.
62
- * - Notary: present any settled terminal (accepted + residual incomplete).
62
+ * - Notary: present any settled terminal (accepted or failure).
63
63
  */
64
64
  export type OneShotSettlementAdapters<A extends AdmittedRoleInvocation> = {
65
65
  trySettle: (admitted: A) => Promise<TerminalResult | undefined>;
@@ -72,7 +72,6 @@ import {
72
72
  readEngineDetourInfrastructureFailure,
73
73
  settleFailureTerminalResult,
74
74
  trySettleReviewerTerminalResult,
75
- trySettleComplianceAuditIncompleteTerminalResult,
76
75
  } from "./settlement.ts";
77
76
  import type { CliIo } from "./cli-io.ts";
78
77
  import type {
@@ -398,20 +397,6 @@ async function dispatchAdmittedReviewer(input: {
398
397
  };
399
398
  }
400
399
 
401
- const auditIncomplete = await trySettleComplianceAuditIncompleteTerminalResult(admitted);
402
- if (auditIncomplete !== undefined) {
403
- await markRunTerminal(admitted.runDirectory).catch(() => undefined);
404
- if (auditIncomplete.roleOutcome.kind === "failure") {
405
- presentFailureTerminal(auditIncomplete, io);
406
- } else {
407
- io.stdout(formatTerminalResult(auditIncomplete));
408
- }
409
- return {
410
- exitCode: exitCodeForTerminalOutcome(auditIncomplete.roleOutcome),
411
- admitted,
412
- terminal: auditIncomplete,
413
- };
414
- }
415
400
 
416
401
  // Prefer engine-detour infrastructure failure already on the session principal
417
402
  // over a later secondary knownFailure / provider-stop after abort (#357 T2 / #378).