cool-workflow 0.1.78

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 (193) hide show
  1. package/.claude-plugin/plugin.json +20 -0
  2. package/.codex-plugin/mcp.json +10 -0
  3. package/.codex-plugin/plugin.json +38 -0
  4. package/.mcp.json +10 -0
  5. package/LICENSE +24 -0
  6. package/README.md +638 -0
  7. package/apps/architecture-review/app.json +51 -0
  8. package/apps/architecture-review/workflow.js +116 -0
  9. package/apps/end-to-end-golden-path/app.json +30 -0
  10. package/apps/end-to-end-golden-path/workflow.js +33 -0
  11. package/apps/pr-review-fix-ci/app.json +59 -0
  12. package/apps/pr-review-fix-ci/workflow.js +90 -0
  13. package/apps/release-cut/app.json +54 -0
  14. package/apps/release-cut/workflow.js +82 -0
  15. package/apps/research-synthesis/app.json +50 -0
  16. package/apps/research-synthesis/workflow.js +76 -0
  17. package/apps/workflow-app-framework-demo/app.json +29 -0
  18. package/apps/workflow-app-framework-demo/workflow.js +44 -0
  19. package/dist/agent-config.js +223 -0
  20. package/dist/candidate-scoring.js +715 -0
  21. package/dist/capability-core.js +630 -0
  22. package/dist/capability-dispatcher.js +86 -0
  23. package/dist/capability-registry.js +523 -0
  24. package/dist/cli.js +1276 -0
  25. package/dist/collaboration.js +727 -0
  26. package/dist/commit.js +570 -0
  27. package/dist/contract-migration.js +234 -0
  28. package/dist/coordinator.js +1163 -0
  29. package/dist/daemon.js +44 -0
  30. package/dist/dispatch.js +201 -0
  31. package/dist/drive.js +503 -0
  32. package/dist/error-feedback.js +415 -0
  33. package/dist/evidence-grounding.js +179 -0
  34. package/dist/evidence-reasoning.js +733 -0
  35. package/dist/execution-backend.js +1279 -0
  36. package/dist/harness.js +61 -0
  37. package/dist/mcp-server.js +1615 -0
  38. package/dist/multi-agent-eval.js +857 -0
  39. package/dist/multi-agent-host.js +764 -0
  40. package/dist/multi-agent-operator-ux.js +537 -0
  41. package/dist/multi-agent-trust.js +366 -0
  42. package/dist/multi-agent.js +1173 -0
  43. package/dist/node-snapshot.js +270 -0
  44. package/dist/observability.js +922 -0
  45. package/dist/operator-ux.js +971 -0
  46. package/dist/orchestrator/audit-operations.js +182 -0
  47. package/dist/orchestrator/candidate-operations.js +117 -0
  48. package/dist/orchestrator/cli-options.js +288 -0
  49. package/dist/orchestrator/collaboration-operations.js +86 -0
  50. package/dist/orchestrator/feedback-operations.js +81 -0
  51. package/dist/orchestrator/host-operations.js +78 -0
  52. package/dist/orchestrator/lifecycle-operations.js +462 -0
  53. package/dist/orchestrator/migration-operations.js +44 -0
  54. package/dist/orchestrator/multi-agent-operations.js +362 -0
  55. package/dist/orchestrator/report.js +369 -0
  56. package/dist/orchestrator/topology-operations.js +84 -0
  57. package/dist/orchestrator.js +874 -0
  58. package/dist/pipeline-contract.js +92 -0
  59. package/dist/pipeline-runner.js +285 -0
  60. package/dist/reclamation.js +882 -0
  61. package/dist/result-normalize.js +194 -0
  62. package/dist/run-export.js +64 -0
  63. package/dist/run-registry.js +1347 -0
  64. package/dist/run-state-schema.js +67 -0
  65. package/dist/sandbox-profile.js +471 -0
  66. package/dist/scheduler.js +266 -0
  67. package/dist/scheduling.js +184 -0
  68. package/dist/schema-validate.js +98 -0
  69. package/dist/state-explosion.js +1213 -0
  70. package/dist/state-migrations.js +463 -0
  71. package/dist/state-node.js +301 -0
  72. package/dist/state.js +308 -0
  73. package/dist/telemetry-attestation.js +156 -0
  74. package/dist/telemetry-ledger.js +145 -0
  75. package/dist/topology.js +527 -0
  76. package/dist/triggers.js +159 -0
  77. package/dist/trust-audit.js +475 -0
  78. package/dist/types/blackboard.js +2 -0
  79. package/dist/types/boundary.js +29 -0
  80. package/dist/types/candidate.js +2 -0
  81. package/dist/types/collaboration.js +2 -0
  82. package/dist/types/core.js +2 -0
  83. package/dist/types/drive.js +10 -0
  84. package/dist/types/error-feedback.js +2 -0
  85. package/dist/types/evidence-reasoning.js +2 -0
  86. package/dist/types/execution-backend.js +2 -0
  87. package/dist/types/multi-agent.js +2 -0
  88. package/dist/types/observability.js +2 -0
  89. package/dist/types/pipeline.js +2 -0
  90. package/dist/types/reclamation.js +8 -0
  91. package/dist/types/result.js +2 -0
  92. package/dist/types/run-registry.js +2 -0
  93. package/dist/types/run.js +2 -0
  94. package/dist/types/sandbox.js +2 -0
  95. package/dist/types/schedule.js +2 -0
  96. package/dist/types/state-node.js +2 -0
  97. package/dist/types/topology.js +2 -0
  98. package/dist/types/trust.js +2 -0
  99. package/dist/types/workbench.js +2 -0
  100. package/dist/types/worker.js +2 -0
  101. package/dist/types/workflow-app.js +2 -0
  102. package/dist/types.js +43 -0
  103. package/dist/verifier-registry.js +46 -0
  104. package/dist/verifier.js +78 -0
  105. package/dist/version.js +8 -0
  106. package/dist/workbench-host.js +172 -0
  107. package/dist/workbench.js +190 -0
  108. package/dist/worker-isolation.js +1028 -0
  109. package/dist/workflow-api.js +98 -0
  110. package/dist/workflow-app-framework.js +626 -0
  111. package/docs/agent-delegation-drive.7.md +190 -0
  112. package/docs/agent-framework.md +176 -0
  113. package/docs/candidate-scoring.7.md +106 -0
  114. package/docs/canonical-workflow-apps.7.md +137 -0
  115. package/docs/capability-topology-registry.7.md +168 -0
  116. package/docs/cli-mcp-parity.7.md +373 -0
  117. package/docs/contract-migration-tooling.7.md +123 -0
  118. package/docs/control-plane-scheduling.7.md +110 -0
  119. package/docs/coordinator-blackboard.7.md +183 -0
  120. package/docs/dogfood/architecture-review-cool-workflow.md +16 -0
  121. package/docs/dogfood-one-real-repo.7.md +168 -0
  122. package/docs/durable-state-and-locking.7.md +107 -0
  123. package/docs/end-to-end-golden-path.7.md +117 -0
  124. package/docs/error-feedback.7.md +153 -0
  125. package/docs/evidence-adoption-reasoning-chain.7.md +270 -0
  126. package/docs/execution-backends.7.md +300 -0
  127. package/docs/getting-started.md +99 -0
  128. package/docs/index.md +41 -0
  129. package/docs/mcp-app-surface.7.md +235 -0
  130. package/docs/multi-agent-cli-mcp-surface.7.md +265 -0
  131. package/docs/multi-agent-eval-replay-harness.7.md +302 -0
  132. package/docs/multi-agent-operator-ux.7.md +314 -0
  133. package/docs/multi-agent-runtime-core.7.md +231 -0
  134. package/docs/multi-agent-topologies.7.md +103 -0
  135. package/docs/multi-agent-trust-policy-audit.7.md +154 -0
  136. package/docs/node-snapshot-diff-replay.7.md +135 -0
  137. package/docs/observability-cost-accounting.7.md +194 -0
  138. package/docs/operator-ux.7.md +180 -0
  139. package/docs/pipeline-runner.7.md +136 -0
  140. package/docs/project-index.md +261 -0
  141. package/docs/real-execution-backends.7.md +142 -0
  142. package/docs/release-and-migration.7.md +280 -0
  143. package/docs/release-tooling.7.md +159 -0
  144. package/docs/routines.md +48 -0
  145. package/docs/run-registry-control-plane.7.md +312 -0
  146. package/docs/run-retention-reclamation.7.md +191 -0
  147. package/docs/sandbox-profiles.7.md +137 -0
  148. package/docs/scheduled-tasks.md +80 -0
  149. package/docs/security-trust-hardening.7.md +117 -0
  150. package/docs/state-explosion-management.7.md +264 -0
  151. package/docs/state-node.7.md +96 -0
  152. package/docs/team-collaboration.7.md +207 -0
  153. package/docs/unix-principles.md +192 -0
  154. package/docs/verifier-gated-commit.7.md +140 -0
  155. package/docs/web-desktop-workbench.7.md +215 -0
  156. package/docs/worker-isolation.7.md +167 -0
  157. package/docs/workflow-app-framework.7.md +274 -0
  158. package/manifest/README.md +43 -0
  159. package/manifest/plugin.manifest.json +316 -0
  160. package/manifest/pricing.policy.json +14 -0
  161. package/package.json +79 -0
  162. package/scripts/agents/claude-p-agent.js +104 -0
  163. package/scripts/agents/claude-p-agent.sh +9 -0
  164. package/scripts/agents/cw-attest-keygen.js +55 -0
  165. package/scripts/agents/cw-attest-wrap.js +143 -0
  166. package/scripts/block-unapproved-tag.sh +39 -0
  167. package/scripts/bump-version.js +249 -0
  168. package/scripts/canonical-apps.js +171 -0
  169. package/scripts/cw.js +4 -0
  170. package/scripts/dist-drift-check.js +79 -0
  171. package/scripts/dogfood-architecture-review.js +237 -0
  172. package/scripts/dogfood-release.js +624 -0
  173. package/scripts/forward-ref-docs.js +73 -0
  174. package/scripts/gen-manifests.js +232 -0
  175. package/scripts/golden-path.js +300 -0
  176. package/scripts/mcp-server.js +4 -0
  177. package/scripts/new-feature.js +121 -0
  178. package/scripts/parity-check.js +213 -0
  179. package/scripts/release-check.js +118 -0
  180. package/scripts/release-flow.js +272 -0
  181. package/scripts/release-gate.sh +85 -0
  182. package/scripts/sync-project-index.js +387 -0
  183. package/scripts/validate-run-state-schema.js +126 -0
  184. package/scripts/verify-container-selfref.js +64 -0
  185. package/scripts/version-sync-check.js +237 -0
  186. package/skills/cool-workflow/SKILL.md +162 -0
  187. package/skills/cool-workflow/references/commands.md +282 -0
  188. package/tsconfig.json +16 -0
  189. package/ui/workbench/app.css +76 -0
  190. package/ui/workbench/app.js +159 -0
  191. package/ui/workbench/index.html +32 -0
  192. package/workflows/architecture-review.workflow.js +84 -0
  193. package/workflows/research-synthesis.workflow.js +47 -0
@@ -0,0 +1,475 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TRUST_AUDIT_SCHEMA_VERSION = void 0;
7
+ exports.ensureTrustAudit = ensureTrustAudit;
8
+ exports.recordTrustAuditEvent = recordTrustAuditEvent;
9
+ exports.recordSandboxPathDecision = recordSandboxPathDecision;
10
+ exports.recordSandboxPolicyDecision = recordSandboxPolicyDecision;
11
+ exports.recordHostAttestation = recordHostAttestation;
12
+ exports.listTrustAuditEvents = listTrustAuditEvents;
13
+ exports.searchAuditEvents = searchAuditEvents;
14
+ exports.summarizeTrustAudit = summarizeTrustAudit;
15
+ exports.refreshTrustAudit = refreshTrustAudit;
16
+ exports.workerTrustAudit = workerTrustAudit;
17
+ exports.normalizeEvidence = normalizeEvidence;
18
+ exports.evidenceProvenance = evidenceProvenance;
19
+ exports.validateAcceptanceRationale = validateAcceptanceRationale;
20
+ exports.buildAcceptanceRationale = buildAcceptanceRationale;
21
+ const node_fs_1 = __importDefault(require("node:fs"));
22
+ const node_path_1 = __importDefault(require("node:path"));
23
+ const state_1 = require("./state");
24
+ const evidence_grounding_1 = require("./evidence-grounding");
25
+ exports.TRUST_AUDIT_SCHEMA_VERSION = 1;
26
+ function ensureTrustAudit(run) {
27
+ const auditDir = auditRoot(run);
28
+ node_fs_1.default.mkdirSync(auditDir, { recursive: true });
29
+ run.paths.auditDir = auditDir;
30
+ const audit = {
31
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
32
+ eventLogPath: node_path_1.default.join(auditDir, "events.jsonl"),
33
+ summaryPath: node_path_1.default.join(auditDir, "summary.json"),
34
+ indexPath: node_path_1.default.join(auditDir, "index.json")
35
+ };
36
+ run.audit = audit;
37
+ if (!node_fs_1.default.existsSync(audit.eventLogPath))
38
+ node_fs_1.default.writeFileSync(audit.eventLogPath, "", "utf8");
39
+ return audit;
40
+ }
41
+ function recordTrustAuditEvent(run, input) {
42
+ const audit = ensureTrustAudit(run);
43
+ const event = compact({
44
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
45
+ id: createEventId(run, input.kind),
46
+ createdAt: new Date().toISOString(),
47
+ runId: run.id,
48
+ kind: input.kind,
49
+ decision: input.decision,
50
+ source: input.source,
51
+ actor: input.actor,
52
+ workerId: input.workerId,
53
+ taskId: input.taskId,
54
+ nodeId: input.nodeId,
55
+ feedbackIds: input.feedbackIds?.filter(Boolean).sort(),
56
+ candidateId: input.candidateId,
57
+ scoreId: input.scoreId,
58
+ selectionId: input.selectionId,
59
+ commitId: input.commitId,
60
+ multiAgentRunId: input.multiAgentRunId,
61
+ agentRoleId: input.agentRoleId,
62
+ agentGroupId: input.agentGroupId,
63
+ agentMembershipId: input.agentMembershipId,
64
+ agentFanoutId: input.agentFanoutId,
65
+ agentFaninId: input.agentFaninId,
66
+ blackboardId: input.blackboardId,
67
+ blackboardTopicId: input.blackboardTopicId,
68
+ blackboardMessageId: input.blackboardMessageId,
69
+ blackboardContextId: input.blackboardContextId,
70
+ blackboardArtifactRefId: input.blackboardArtifactRefId,
71
+ blackboardSnapshotId: input.blackboardSnapshotId,
72
+ coordinatorDecisionId: input.coordinatorDecisionId,
73
+ topologyId: input.topologyId,
74
+ topologyRunId: input.topologyRunId,
75
+ sandboxProfileId: input.sandboxProfileId || input.policySnapshot?.id,
76
+ policyRef: input.policyRef || (input.policySnapshot?.id ? `run.sandboxProfiles.${input.policySnapshot.id}` : undefined),
77
+ multiAgentPolicyRef: input.policyRef,
78
+ policySnapshot: redactPolicy(input.policySnapshot),
79
+ normalizedPath: input.normalizedPath ? node_path_1.default.resolve(input.normalizedPath) : undefined,
80
+ command: input.command,
81
+ networkTarget: input.networkTarget,
82
+ envVars: input.envVars ? unique(input.envVars.map(String)).sort() : undefined,
83
+ evidence: normalizeEvidence(run, input.evidence || [], {
84
+ source: input.source,
85
+ workerId: input.workerId,
86
+ taskId: input.taskId,
87
+ resultNodeId: input.nodeId
88
+ }),
89
+ evidenceRefs: unique(input.evidenceRefs || []).sort(),
90
+ parentEventIds: unique(input.parentEventIds || []).sort(),
91
+ metadata: scrubMetadata(input.metadata || {})
92
+ });
93
+ // DURABLE append (v0.1.40 self-audit P1): the audit log is the one artifact
94
+ // whose loss breaks audit-completeness, so fsync it before returning — never a
95
+ // bare appendFileSync, which can drop the last event on power loss.
96
+ (0, state_1.durableAppendFileSync)(audit.eventLogPath, `${JSON.stringify(event)}\n`);
97
+ refreshTrustAudit(run);
98
+ return event;
99
+ }
100
+ function recordSandboxPathDecision(run, input) {
101
+ return recordTrustAuditEvent(run, {
102
+ kind: input.kind || "sandbox.path",
103
+ decision: input.decision,
104
+ source: input.source || "cw-validated",
105
+ workerId: input.workerId,
106
+ taskId: input.taskId,
107
+ sandboxProfileId: input.sandboxProfileId,
108
+ policySnapshot: input.policySnapshot,
109
+ normalizedPath: input.target,
110
+ feedbackIds: input.feedbackIds,
111
+ metadata: input.metadata
112
+ });
113
+ }
114
+ function recordSandboxPolicyDecision(run, input) {
115
+ return recordTrustAuditEvent(run, {
116
+ ...input,
117
+ source: input.source || "cw-validated"
118
+ });
119
+ }
120
+ function recordHostAttestation(run, input) {
121
+ return recordTrustAuditEvent(run, {
122
+ ...input,
123
+ kind: input.kind || "sandbox.host-attestation",
124
+ decision: "recorded",
125
+ source: "host-attested"
126
+ });
127
+ }
128
+ function listTrustAuditEvents(run) {
129
+ const audit = ensureTrustAudit(run);
130
+ if (!node_fs_1.default.existsSync(audit.eventLogPath))
131
+ return [];
132
+ return node_fs_1.default
133
+ .readFileSync(audit.eventLogPath, "utf8")
134
+ .split(/\n/g)
135
+ .map((line) => line.trim())
136
+ .filter(Boolean)
137
+ .map((line) => JSON.parse(line))
138
+ .sort(compareEvents);
139
+ }
140
+ /** Search audit events by kind, worker, or candidate (v0.1.65).
141
+ * Filters are AND-ed; empty filters match all. */
142
+ function searchAuditEvents(run, filters) {
143
+ let events = listTrustAuditEvents(run);
144
+ if (filters.kind)
145
+ events = events.filter((e) => e.kind === filters.kind);
146
+ if (filters.workerId)
147
+ events = events.filter((e) => e.workerId === filters.workerId);
148
+ if (filters.candidateId)
149
+ events = events.filter((e) => e.candidateId === filters.candidateId);
150
+ if (filters.limit && filters.limit > 0)
151
+ events = events.slice(0, filters.limit);
152
+ return events;
153
+ }
154
+ function summarizeTrustAudit(run) {
155
+ const audit = ensureTrustAudit(run);
156
+ const events = readEvents(audit.eventLogPath);
157
+ const summary = {
158
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
159
+ runId: run.id,
160
+ generatedAt: new Date().toISOString(),
161
+ eventCount: events.length,
162
+ eventLogPath: audit.eventLogPath,
163
+ indexPath: audit.indexPath,
164
+ summaryPath: audit.summaryPath,
165
+ byKind: countBy(events, (event) => event.kind),
166
+ byDecision: countBy(events, (event) => event.decision),
167
+ bySource: countBy(events, (event) => event.source),
168
+ bySandboxProfile: countBy(events.filter((event) => event.sandboxProfileId), (event) => event.sandboxProfileId || "none"),
169
+ workers: workerRows(events, run),
170
+ candidates: candidateRows(events, run),
171
+ commits: commitRows(events, run),
172
+ multiAgent: {
173
+ runs: run.multiAgent?.runs.length || 0,
174
+ roles: run.multiAgent?.roles.length || 0,
175
+ groups: run.multiAgent?.groups.length || 0,
176
+ memberships: run.multiAgent?.memberships.length || 0,
177
+ fanouts: run.multiAgent?.fanouts.length || 0,
178
+ fanins: run.multiAgent?.fanins.length || 0,
179
+ events: events.filter((event) => Boolean(event.multiAgentRunId ||
180
+ event.agentRoleId ||
181
+ event.agentGroupId ||
182
+ event.agentMembershipId ||
183
+ event.agentFanoutId ||
184
+ event.agentFaninId)).length
185
+ },
186
+ blackboard: {
187
+ boards: run.blackboard?.boards.length || 0,
188
+ topics: run.blackboard?.topics.length || 0,
189
+ messages: run.blackboard?.messages.length || 0,
190
+ contexts: run.blackboard?.contexts.length || 0,
191
+ artifacts: run.blackboard?.artifacts.length || 0,
192
+ snapshots: run.blackboard?.snapshots.length || 0,
193
+ decisions: run.blackboard?.decisions.length || 0,
194
+ events: events.filter((event) => Boolean(event.blackboardId ||
195
+ event.blackboardTopicId ||
196
+ event.blackboardMessageId ||
197
+ event.blackboardContextId ||
198
+ event.blackboardArtifactRefId ||
199
+ event.blackboardSnapshotId ||
200
+ event.coordinatorDecisionId)).length
201
+ },
202
+ topologies: {
203
+ runs: run.topologies?.runs.length || 0,
204
+ events: events.filter((event) => Boolean(event.topologyId || event.topologyRunId || event.kind.startsWith("topology."))).length
205
+ },
206
+ multiAgentTrust: {
207
+ rolePolicies: events.filter((event) => event.kind === "multi-agent.role-policy").length,
208
+ permissionDecisions: events.filter((event) => event.kind === "multi-agent.permission").length,
209
+ blackboardWrites: events.filter((event) => event.kind === "blackboard.write").length,
210
+ messageProvenance: events.filter((event) => event.kind === "blackboard.message-provenance").length,
211
+ judgeRationales: events.filter((event) => event.kind === "judge.rationale").length,
212
+ panelDecisions: events.filter((event) => event.kind === "judge.panel-decision").length,
213
+ policyViolations: events.filter((event) => event.kind === "policy.violation").length
214
+ }
215
+ };
216
+ // Durable (v0.1.40 self-audit P1): the summary/index are the read-side view of
217
+ // the audit log; persist them durably so a crash can't leave them pointing past
218
+ // the last durably-appended event.
219
+ (0, state_1.writeJson)(audit.summaryPath, summary, { durable: true });
220
+ (0, state_1.writeJson)(audit.indexPath, {
221
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
222
+ runId: run.id,
223
+ events: events.map((event) => ({
224
+ id: event.id,
225
+ createdAt: event.createdAt,
226
+ kind: event.kind,
227
+ decision: event.decision,
228
+ source: event.source,
229
+ workerId: event.workerId,
230
+ taskId: event.taskId,
231
+ candidateId: event.candidateId,
232
+ selectionId: event.selectionId,
233
+ commitId: event.commitId,
234
+ multiAgentRunId: event.multiAgentRunId,
235
+ agentRoleId: event.agentRoleId,
236
+ agentGroupId: event.agentGroupId,
237
+ agentMembershipId: event.agentMembershipId,
238
+ agentFanoutId: event.agentFanoutId,
239
+ agentFaninId: event.agentFaninId,
240
+ blackboardId: event.blackboardId,
241
+ blackboardTopicId: event.blackboardTopicId,
242
+ blackboardMessageId: event.blackboardMessageId,
243
+ blackboardContextId: event.blackboardContextId,
244
+ blackboardArtifactRefId: event.blackboardArtifactRefId,
245
+ blackboardSnapshotId: event.blackboardSnapshotId,
246
+ coordinatorDecisionId: event.coordinatorDecisionId,
247
+ topologyId: event.topologyId,
248
+ topologyRunId: event.topologyRunId,
249
+ sandboxProfileId: event.sandboxProfileId,
250
+ policyRef: event.policyRef,
251
+ multiAgentPolicyRef: event.multiAgentPolicyRef
252
+ }))
253
+ }, { durable: true });
254
+ run.audit = audit;
255
+ return summary;
256
+ }
257
+ function refreshTrustAudit(run) {
258
+ const audit = {
259
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
260
+ eventLogPath: node_path_1.default.join(auditRoot(run), "events.jsonl"),
261
+ summaryPath: node_path_1.default.join(auditRoot(run), "summary.json"),
262
+ indexPath: node_path_1.default.join(auditRoot(run), "index.json")
263
+ };
264
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(audit.eventLogPath), { recursive: true });
265
+ if (!node_fs_1.default.existsSync(audit.eventLogPath))
266
+ node_fs_1.default.writeFileSync(audit.eventLogPath, "", "utf8");
267
+ run.audit = audit;
268
+ return summarizeTrustAudit(run);
269
+ }
270
+ function workerTrustAudit(run, workerId) {
271
+ return { workerId, events: listTrustAuditEvents(run).filter((event) => event.workerId === workerId) };
272
+ }
273
+ function normalizeEvidence(run, evidence, provenance) {
274
+ const baseDirs = [run.cwd, run.paths.runDir].filter(Boolean);
275
+ return evidence.map((entry) => ({
276
+ ...entry,
277
+ // Auto-compute confidence tier from locator shape + (in strict mode) filesystem.
278
+ // "verified" is never auto-assigned — requires explicit host attestation (v0.1.55).
279
+ confidence: entry.confidence || (0, evidence_grounding_1.computeEvidenceConfidence)(entry.locator || entry.path || entry.summary, baseDirs),
280
+ // Extract actual file content for file-style evidence locators (v0.1.74).
281
+ contentPreview: entry.contentPreview || ((entry.locator || entry.path) ? (0, evidence_grounding_1.extractEvidenceContent)(entry.locator || entry.path || "", baseDirs) : undefined),
282
+ provenance: {
283
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
284
+ runId: run.id,
285
+ source: provenance.source || entry.provenance?.source || "runtime-derived",
286
+ workerId: provenance.workerId || entry.provenance?.workerId,
287
+ taskId: provenance.taskId || entry.provenance?.taskId,
288
+ resultNodeId: provenance.resultNodeId || entry.provenance?.resultNodeId,
289
+ verifierNodeId: provenance.verifierNodeId || entry.provenance?.verifierNodeId,
290
+ candidateId: provenance.candidateId || entry.provenance?.candidateId,
291
+ scoreId: provenance.scoreId || entry.provenance?.scoreId,
292
+ selectionId: provenance.selectionId || entry.provenance?.selectionId,
293
+ commitId: provenance.commitId || entry.provenance?.commitId,
294
+ parentEvidenceIds: unique([...(entry.provenance?.parentEvidenceIds || []), ...(provenance.parentEvidenceIds || [])]).sort(),
295
+ auditEventIds: unique([...(entry.provenance?.auditEventIds || []), ...(provenance.auditEventIds || [])]).sort(),
296
+ note: provenance.note || entry.provenance?.note
297
+ }
298
+ }));
299
+ }
300
+ function evidenceProvenance(run, options = {}) {
301
+ const events = listTrustAuditEvents(run).filter((event) => {
302
+ if (options.candidateId && event.candidateId !== options.candidateId)
303
+ return false;
304
+ if (options.commitId && event.commitId !== options.commitId)
305
+ return false;
306
+ if (options.workerId && event.workerId !== options.workerId)
307
+ return false;
308
+ return true;
309
+ });
310
+ const evidence = [];
311
+ for (const node of run.nodes || [])
312
+ evidence.push(...(node.evidence || []));
313
+ for (const candidate of run.candidates || [])
314
+ evidence.push(...(candidate.evidence || []));
315
+ for (const selection of run.candidateSelections || [])
316
+ evidence.push(...(selection.evidence || []));
317
+ for (const commit of run.commits || [])
318
+ evidence.push(...(commit.evidence || []));
319
+ const filtered = evidence.filter((entry) => {
320
+ if (options.candidateId && entry.provenance?.candidateId !== options.candidateId)
321
+ return false;
322
+ if (options.commitId && entry.provenance?.commitId !== options.commitId)
323
+ return false;
324
+ if (options.workerId && entry.provenance?.workerId !== options.workerId)
325
+ return false;
326
+ return true;
327
+ });
328
+ return { runId: run.id, evidence: filtered, events };
329
+ }
330
+ function validateAcceptanceRationale(rationale) {
331
+ if (!rationale)
332
+ return ["acceptance rationale is missing"];
333
+ const failures = [];
334
+ if (!rationale.selectedCandidateId)
335
+ failures.push("selected candidate id is missing");
336
+ if (!rationale.scoreId)
337
+ failures.push("score id is missing");
338
+ if (!rationale.verifierNodeId)
339
+ failures.push("verifier node id is missing");
340
+ if (!rationale.evidenceCount)
341
+ failures.push("evidence count is zero");
342
+ if (!rationale.workerId)
343
+ failures.push("worker id is missing");
344
+ if (!rationale.sandboxProfileId)
345
+ failures.push("sandbox profile id is missing");
346
+ if (rationale.commitGateResult !== "passed")
347
+ failures.push("commit gate result is not passed");
348
+ return failures;
349
+ }
350
+ function buildAcceptanceRationale(input) {
351
+ return {
352
+ schemaVersion: exports.TRUST_AUDIT_SCHEMA_VERSION,
353
+ selectedCandidateId: input.selectedCandidateId,
354
+ scoreId: input.scoreId,
355
+ scoreCriteria: input.scoreCriteria,
356
+ verifierNodeId: input.verifierNodeId,
357
+ evidenceCount: input.evidenceCount || 0,
358
+ sandboxProfileId: input.sandboxProfileId,
359
+ workerId: input.workerId,
360
+ commitGateResult: input.commitGateResult,
361
+ auditEventIds: unique(input.auditEventIds || []).sort()
362
+ };
363
+ }
364
+ function auditRoot(run) {
365
+ return run.paths.auditDir || node_path_1.default.join(run.paths.runDir, "audit");
366
+ }
367
+ function readEvents(eventLogPath) {
368
+ if (!node_fs_1.default.existsSync(eventLogPath))
369
+ return [];
370
+ return node_fs_1.default
371
+ .readFileSync(eventLogPath, "utf8")
372
+ .split(/\n/g)
373
+ .map((line) => line.trim())
374
+ .filter(Boolean)
375
+ .map((line) => JSON.parse(line))
376
+ .sort(compareEvents);
377
+ }
378
+ function workerRows(events, run) {
379
+ const workerIds = unique([...(run.workers || []).map((worker) => worker.id), ...events.map((event) => event.workerId || "")]).sort();
380
+ return workerIds.filter(Boolean).map((workerId) => {
381
+ const worker = (run.workers || []).find((entry) => entry.id === workerId);
382
+ const scoped = events.filter((event) => event.workerId === workerId);
383
+ return {
384
+ workerId,
385
+ taskId: worker?.taskId || scoped.find((event) => event.taskId)?.taskId,
386
+ sandboxProfileId: worker?.sandboxProfileId || scoped.find((event) => event.sandboxProfileId)?.sandboxProfileId,
387
+ decisions: countBy(scoped, (event) => event.decision),
388
+ denied: scoped.filter((event) => event.decision === "denied" || event.decision === "rejected").length,
389
+ feedbackIds: unique(scoped.flatMap((event) => event.feedbackIds || [])).sort()
390
+ };
391
+ });
392
+ }
393
+ function candidateRows(events, run) {
394
+ const ids = unique([...(run.candidates || []).map((candidate) => candidate.id), ...events.map((event) => event.candidateId || "")]).sort();
395
+ return ids.filter(Boolean).map((candidateId) => {
396
+ const candidate = (run.candidates || []).find((entry) => entry.id === candidateId);
397
+ const selections = (run.candidateSelections || []).filter((selection) => selection.candidateId === candidateId);
398
+ const scoped = events.filter((event) => event.candidateId === candidateId);
399
+ return {
400
+ candidateId,
401
+ scoreIds: unique([...(candidate?.scores || []), ...scoped.map((event) => event.scoreId || "")]).filter(Boolean).sort(),
402
+ selectionIds: unique([...selections.map((selection) => selection.id), ...scoped.map((event) => event.selectionId || "")]).filter(Boolean).sort(),
403
+ evidenceCount: candidate?.evidence.length || scoped.flatMap((event) => event.evidence || []).length
404
+ };
405
+ });
406
+ }
407
+ function commitRows(events, run) {
408
+ const ids = unique([...(run.commits || []).map((commit) => commit.id), ...events.map((event) => event.commitId || "")]).sort();
409
+ return ids.filter(Boolean).map((commitId) => {
410
+ const commit = (run.commits || []).find((entry) => entry.id === commitId);
411
+ return {
412
+ commitId,
413
+ verifierGated: Boolean(commit?.verifierGated),
414
+ candidateId: commit?.candidateId,
415
+ selectionId: commit?.selectionId,
416
+ evidenceCount: commit?.evidence?.length || 0,
417
+ rationale: commit?.acceptanceRationale
418
+ };
419
+ });
420
+ }
421
+ function createEventId(run, kind) {
422
+ const stamp = new Date().toISOString().replace(/[-:]/g, "").replace(/\..+/, "Z");
423
+ const count = readEvents(node_path_1.default.join(auditRoot(run), "events.jsonl")).length + 1;
424
+ return `audit-${(0, state_1.safeFileName)(kind)}-${stamp}-${String(count).padStart(4, "0")}`;
425
+ }
426
+ function redactPolicy(policy) {
427
+ if (!policy)
428
+ return undefined;
429
+ return {
430
+ ...policy,
431
+ env: {
432
+ inherit: Boolean(policy.env.inherit),
433
+ expose: unique((policy.env.expose || []).map(String)).sort(),
434
+ deny: policy.env.deny ? unique(policy.env.deny.map(String)).sort() : undefined
435
+ },
436
+ metadata: scrubMetadata(policy.metadata || {})
437
+ };
438
+ }
439
+ function scrubMetadata(value) {
440
+ const result = {};
441
+ for (const [key, entry] of Object.entries(value)) {
442
+ if (entry === undefined)
443
+ continue;
444
+ if (/secret|token|password|credential|authorization|api[_-]?key/i.test(key)) {
445
+ result[key] = "[redacted]";
446
+ }
447
+ else if (Array.isArray(entry)) {
448
+ result[key] = entry.map((item) => (typeof item === "string" && item.includes("=") ? item.split("=")[0] : item));
449
+ }
450
+ else if (entry && typeof entry === "object") {
451
+ result[key] = scrubMetadata(entry);
452
+ }
453
+ else {
454
+ result[key] = entry;
455
+ }
456
+ }
457
+ return Object.keys(result).length ? result : undefined;
458
+ }
459
+ function compact(value) {
460
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
461
+ }
462
+ function countBy(items, key) {
463
+ const counts = {};
464
+ for (const item of items) {
465
+ const value = key(item);
466
+ counts[value] = (counts[value] || 0) + 1;
467
+ }
468
+ return counts;
469
+ }
470
+ function unique(values) {
471
+ return Array.from(new Set(values.filter(Boolean)));
472
+ }
473
+ function compareEvents(left, right) {
474
+ return left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id);
475
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // One-way executor boundary (Track 3) — the red line AS A TYPE, not a convention.
3
+ //
4
+ // CW delegates execution and only ever receives structured DATA back from the
5
+ // executor: the canonical ExecutionResultEnvelope (and the usage record riding
6
+ // on it). Nothing callable crosses the boundary in either direction — no model
7
+ // client, no SDK handle, no callback an orchestration layer could use to reach
8
+ // a raw model API. Until now that was enforced by the red-line smoke (no SDK in
9
+ // package.json, no SDK import / API-URL literal in src). This module welds the
10
+ // same guarantee into the TYPE LAYER so an attempt to sneak a callable across
11
+ // the boundary fails AT COMPILE TIME — there is no entry point to discipline
12
+ // away.
13
+ //
14
+ // `OneWayData<T>` recursively maps a type to itself iff it is plain data:
15
+ // - primitives (string/number/boolean/null/undefined) pass through;
16
+ // - `unknown` passes through AS OPAQUE DATA — it cannot be invoked without an
17
+ // explicit cast, and a cast is exactly the kind of code the red-line smoke
18
+ // catches as text;
19
+ // - arrays/objects recurse (optionality and readonly preserved);
20
+ // - ANY function type poisons to `never`, so `T extends OneWayData<T>` fails
21
+ // and the build breaks. Class instances (ChildProcess, an SDK client, Date)
22
+ // fail the same way through their methods.
23
+ //
24
+ // The exported `MustBeOneWay<...>` aliases below are the welds: adding a
25
+ // callable field anywhere inside a boundary type breaks `npm run build`. The
26
+ // negative-fixture smoke (one-way-boundary-smoke.js) proves the failure mode
27
+ // stays real (a violating fixture must NOT compile) and that these welds stay
28
+ // present in source.
29
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ // Agent Delegation Drive (v0.1.38) — result types for the `run --drive` auto-advance
3
+ // loop. The loop is a THIN orchestrator over the EXISTING verbs (plan / dispatch /
4
+ // recordWorkerOutput / commit) + the v0.1.37 scheduler; it introduces no second
5
+ // runner/queue. These are plain, deterministic projections of run state.
6
+ //
7
+ // DETERMINISM: every payload is derivable from the run state + an injected `now`.
8
+ // No now-derived NUMERIC field (counts come from state); only ISO timestamps may be
9
+ // now-derived (the parity probe strips them).
10
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // Run Retention & Provable Reclamation (v0.1.39) — type contracts.
3
+ //
4
+ // Reclamation frees disk WITHOUT violating the audit/replay moat. It is a
5
+ // VERIFIABLE, append-only state transition: freeing bytes leaves behind a
6
+ // hash-chained tombstone proving what was freed is reconstructable-or-worthless
7
+ // and that the audit-essential subset is sealed. See docs/run-retention-reclamation.7.md.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/types.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // Barrel for the workflow type system. The declarations were split out of a
3
+ // single 3k-line types.ts into domain files under ./types/; importers keep
4
+ // importing from "./types" unchanged. Pure types — no runtime cost.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./types/core"), exports);
21
+ __exportStar(require("./types/workflow-app"), exports);
22
+ __exportStar(require("./types/result"), exports);
23
+ __exportStar(require("./types/trust"), exports);
24
+ __exportStar(require("./types/state-node"), exports);
25
+ __exportStar(require("./types/pipeline"), exports);
26
+ __exportStar(require("./types/error-feedback"), exports);
27
+ __exportStar(require("./types/sandbox"), exports);
28
+ __exportStar(require("./types/execution-backend"), exports);
29
+ __exportStar(require("./types/boundary"), exports);
30
+ __exportStar(require("./types/drive"), exports);
31
+ __exportStar(require("./types/multi-agent"), exports);
32
+ __exportStar(require("./types/topology"), exports);
33
+ __exportStar(require("./types/blackboard"), exports);
34
+ __exportStar(require("./types/worker"), exports);
35
+ __exportStar(require("./types/candidate"), exports);
36
+ __exportStar(require("./types/evidence-reasoning"), exports);
37
+ __exportStar(require("./types/run"), exports);
38
+ __exportStar(require("./types/schedule"), exports);
39
+ __exportStar(require("./types/run-registry"), exports);
40
+ __exportStar(require("./types/reclamation"), exports);
41
+ __exportStar(require("./types/workbench"), exports);
42
+ __exportStar(require("./types/observability"), exports);
43
+ __exportStar(require("./types/collaboration"), exports);