@akagilnc/pi-workflow-roles 0.1.3749 → 0.1.3771

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 (49) hide show
  1. package/CLAUDE.md +4 -0
  2. package/README.md +3 -2
  3. package/README.zh-CN.md +3 -2
  4. package/dist/acp-host/production-host.js +1389 -751
  5. package/dist/collector-config.js +0 -1
  6. package/dist/collector-github.js +199 -2
  7. package/dist/collector-identity.js +128 -41
  8. package/dist/collector-ledger.js +38 -9
  9. package/dist/collector-receipt.js +19 -7
  10. package/dist/collector-role.js +330 -369
  11. package/dist/collector-target.js +169 -0
  12. package/dist/collector-tool-schemas.js +51 -14
  13. package/dist/package-contracts/collector-output.js +32 -0
  14. package/dist/package-contracts/terminating-infrastructure.js +13 -12
  15. package/dist/pi/role-turn-host.js +1 -2
  16. package/dist/public-cli/github-remote.js +45 -0
  17. package/dist/public-cli/invocation.js +53 -54
  18. package/dist/public-cli/main.js +615 -148
  19. package/dist/public-cli/option-definitions.js +6 -4
  20. package/dist/public-cli/run-lifecycle.js +3 -3
  21. package/dist/public-cli/settlement.js +83 -6
  22. package/dist/role-runtime.js +137 -7
  23. package/dist/submission-correctable-error.js +24 -0
  24. package/extensions/role-runtime.ts +0 -1
  25. package/package.json +1 -1
  26. package/souls/coder.md +11 -6
  27. package/souls/fixer.md +10 -9
  28. package/src/acp-host/role-envelope.ts +8 -22
  29. package/src/collector-config.ts +0 -1
  30. package/src/collector-github.ts +236 -2
  31. package/src/collector-identity.ts +148 -40
  32. package/src/collector-ledger.ts +48 -10
  33. package/src/collector-receipt.ts +33 -14
  34. package/src/collector-role.ts +376 -450
  35. package/src/collector-target.ts +207 -0
  36. package/src/collector-tool-schemas.ts +62 -15
  37. package/src/host-contracts.ts +2 -1
  38. package/src/package-contracts/collector-output.ts +72 -0
  39. package/src/package-contracts/terminating-infrastructure.ts +24 -13
  40. package/src/pi/role-turn-host.ts +1 -2
  41. package/src/public-cli/cli.ts +10 -1
  42. package/src/public-cli/collector-run.ts +3 -2
  43. package/src/public-cli/github-remote.ts +45 -0
  44. package/src/public-cli/invocation.ts +60 -59
  45. package/src/public-cli/option-definitions.ts +6 -4
  46. package/src/public-cli/run-lifecycle.ts +2 -2
  47. package/src/public-cli/settlement.ts +82 -6
  48. package/src/role-runtime.ts +166 -13
  49. package/src/submission-correctable-error.ts +38 -0
@@ -4,11 +4,18 @@ import type { CollectorLedger, CollectorRequestAttempt } from "./collector-ledge
4
4
  import {
5
5
  enrichCollectorFindings,
6
6
  extractCollectorEvidenceIdentityGroups,
7
+ extractCollectorUnfinishedReasons,
7
8
  type ExtractedCollectorIdentityGroup,
8
9
  } from "./collector-identity.ts";
9
- import { validateAcceptedCollectorReceipt, type CollectorEvidenceRecord as ReceiptEvidenceRecord } from "./package-contracts/collector-output.ts";
10
+ import {
11
+ validateAcceptedCollectorReceipt,
12
+ type CollectorEvidenceRecord as ReceiptEvidenceRecord,
13
+ type CollectorReceipt as PackageCollectorReceipt,
14
+ type CollectorSubmissionProjection,
15
+ } from "./package-contracts/collector-output.ts";
10
16
 
11
17
  export { validateAcceptedCollectorReceipt };
18
+ export type { CollectorSubmissionProjection };
12
19
 
13
20
  /**
14
21
  * #641 chain① receipt-local evidence projection: machine identity, integrity
@@ -17,17 +24,15 @@ export { validateAcceptedCollectorReceipt };
17
24
  */
18
25
  export type CollectorReceiptEvidenceRecord = ReceiptEvidenceRecord;
19
26
 
20
- export type CollectorReceipt = {
21
- host: "github.com";
22
- repository: string;
23
- prNumber: number;
24
- manifestDigest: string;
25
- activationTime: string;
26
- deadlineTime: string;
27
- finalObservationTime: string;
28
- finalSnapshotId: string;
29
- targetHead: string;
27
+ /**
28
+ * #676 C: single authority for receipt shape is package-contracts/collector-output.
29
+ * Production builder always emits the full projection object and concrete prState;
30
+ * package leaf keeps those optional so old volumes stay readable.
31
+ */
32
+ export type CollectorReceipt = PackageCollectorReceipt & {
33
+ prState: string;
30
34
  groups: ExtractedCollectorIdentityGroup[];
35
+ submissionProjection: CollectorSubmissionProjection;
31
36
  requestAttempts: CollectorRequestAttempt[];
32
37
  snapshots: CollectorSnapshot[];
33
38
  evidenceRecords: CollectorReceiptEvidenceRecord[];
@@ -45,6 +50,9 @@ export function buildCollectorReceipt(
45
50
  if (ledger.unresolvedTransportFailure) fail("Collector cannot output while a transport failure is unrecovered");
46
51
  if (ledger.latestCompleteSnapshotId === undefined) fail("Collector output requires a complete final snapshot");
47
52
  if (ledger.activationTime === undefined || ledger.deadlineTime === undefined) fail("Collector output requires activation timeline");
53
+ if (ledger.config.prNumber === undefined) {
54
+ fail("Collector output requires a bound PR target; call ak_collector_bind_target first or pass --pr");
55
+ }
48
56
 
49
57
  if (clock !== undefined) ledger.assertOutputObservationLaw(clock);
50
58
  else if (ledger.observedGeneration !== ledger.mutationGeneration ||
@@ -54,7 +62,7 @@ export function buildCollectorReceipt(
54
62
 
55
63
  const finalSnapshot = ledger.getSnapshot(ledger.latestCompleteSnapshotId);
56
64
  if (finalSnapshot === undefined || !finalSnapshot.complete) fail("Collector final snapshot is incomplete");
57
- if (finalSnapshot.prState !== "OPEN") fail("Collector final snapshot PR state is not OPEN");
65
+ // #676 D6: closed/merged still deliver collected materials; status is a fact on the receipt.
58
66
 
59
67
  const evidenceRecords: CollectorEvidenceRecord[] = [...ledger.allEvidence()];
60
68
  const snapshots = [...ledger.allSnapshots()];
@@ -71,7 +79,7 @@ export function buildCollectorReceipt(
71
79
  const groups = extractCollectorEvidenceIdentityGroups(evidenceRecords, finalSnapshot.headOid);
72
80
  // #641 chain①: the collector LLM submits findings as pointer refs; the runtime
73
81
  // enriches each with the machine locator from the same stored record.
74
- enrichCollectorFindings({
82
+ const findingsProjection = enrichCollectorFindings({
75
83
  candidate: candidateRaw,
76
84
  records: evidenceRecords,
77
85
  groups,
@@ -80,7 +88,6 @@ export function buildCollectorReceipt(
80
88
  prNumber: ledger.config.prNumber,
81
89
  });
82
90
  for (const group of groups) {
83
- if (group.attendance !== true) fail("Collector group lacks attendance");
84
91
  for (const material of group.materials) {
85
92
  if (material.evidenceId === undefined || !evidenceIndex.has(material.evidenceId)) fail("Collector material lacks a receipt-local evidence ref");
86
93
  }
@@ -88,11 +95,21 @@ export function buildCollectorReceipt(
88
95
  if (finding.source.evidenceId === undefined || !evidenceIndex.has(finding.source.evidenceId)) fail("Collector finding lacks a receipt-local evidence ref");
89
96
  }
90
97
  }
98
+ const unfinished = extractCollectorUnfinishedReasons(candidateRaw);
99
+ const submissionProjection: CollectorSubmissionProjection = {
100
+ findingsSource: findingsProjection.findingsSource,
101
+ findingsProjectedCount: findingsProjection.findingsProjectedCount,
102
+ findingsUnprojected: findingsProjection.findingsUnprojected,
103
+ unfinishedReasonsSource: unfinished.source,
104
+ unfinishedReasonsProjectedCount: unfinished.reasons?.length ?? 0,
105
+ unfinishedReasonsUnprojected: unfinished.unprojected,
106
+ };
91
107
 
92
108
  return {
93
109
  host: COLLECTOR_HOST,
94
110
  repository: ledger.config.repository.canonical,
95
111
  prNumber: ledger.config.prNumber,
112
+ prState: finalSnapshot.prState,
96
113
  manifestDigest: ledger.config.manifest.digest,
97
114
  activationTime: ledger.activationTime.toISOString(),
98
115
  deadlineTime: ledger.deadlineTime.toISOString(),
@@ -100,6 +117,8 @@ export function buildCollectorReceipt(
100
117
  finalSnapshotId: finalSnapshot.snapshotId,
101
118
  targetHead: finalSnapshot.headOid,
102
119
  groups,
120
+ ...(unfinished.reasons === undefined ? {} : { unfinishedReasons: unfinished.reasons }),
121
+ submissionProjection,
103
122
  requestAttempts: [...ledger.requestAttempts()],
104
123
  snapshots,
105
124
  evidenceRecords: evidenceRecords.map(toReceiptEvidenceRecord),