cool-workflow 0.1.80 → 0.1.81

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 (110) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/README.md +42 -2
  4. package/apps/architecture-review/app.json +1 -1
  5. package/apps/architecture-review-fast/app.json +1 -1
  6. package/apps/end-to-end-golden-path/app.json +1 -1
  7. package/apps/pr-review-fix-ci/app.json +1 -1
  8. package/apps/release-cut/app.json +1 -1
  9. package/apps/research-synthesis/app.json +1 -1
  10. package/dist/agent-config.js +21 -7
  11. package/dist/candidate-scoring.js +42 -22
  12. package/dist/capability-core.js +94 -17
  13. package/dist/capability-registry.js +138 -171
  14. package/dist/cli.js +90 -100
  15. package/dist/collaboration.js +5 -6
  16. package/dist/commit.js +20 -6
  17. package/dist/compare.js +18 -0
  18. package/dist/coordinator/classify.js +45 -0
  19. package/dist/coordinator/paths.js +42 -0
  20. package/dist/coordinator/util.js +129 -0
  21. package/dist/coordinator.js +127 -300
  22. package/dist/dispatch.js +35 -0
  23. package/dist/drive.js +7 -7
  24. package/dist/error-feedback.js +8 -4
  25. package/dist/evidence-reasoning.js +1 -1
  26. package/dist/execution-backend/agent.js +331 -0
  27. package/dist/execution-backend/probes.js +96 -0
  28. package/dist/execution-backend/util.js +47 -0
  29. package/dist/execution-backend.js +67 -420
  30. package/dist/mcp-server.js +34 -173
  31. package/dist/multi-agent/graph.js +84 -0
  32. package/dist/multi-agent/helpers.js +145 -0
  33. package/dist/multi-agent/paths.js +22 -0
  34. package/dist/multi-agent-eval/format.js +194 -0
  35. package/dist/multi-agent-eval/normalize.js +51 -0
  36. package/dist/multi-agent-eval.js +39 -244
  37. package/dist/multi-agent-host.js +0 -19
  38. package/dist/multi-agent.js +125 -314
  39. package/dist/node-snapshot.js +3 -3
  40. package/dist/observability/format.js +61 -0
  41. package/dist/observability/intake.js +98 -0
  42. package/dist/observability.js +14 -160
  43. package/dist/operator-ux/format.js +364 -0
  44. package/dist/operator-ux.js +22 -363
  45. package/dist/orchestrator/report.js +8 -0
  46. package/dist/orchestrator.js +25 -8
  47. package/dist/reclamation.js +26 -21
  48. package/dist/run-export.js +138 -14
  49. package/dist/run-registry/derive.js +172 -0
  50. package/dist/run-registry/format.js +124 -0
  51. package/dist/run-registry/gc.js +251 -0
  52. package/dist/run-registry/policy.js +16 -0
  53. package/dist/run-registry/queue.js +116 -0
  54. package/dist/run-registry.js +78 -593
  55. package/dist/run-state-schema.js +1 -0
  56. package/dist/sandbox-profile.js +43 -2
  57. package/dist/state-explosion/format.js +159 -0
  58. package/dist/state-explosion/helpers.js +82 -0
  59. package/dist/state-explosion.js +65 -283
  60. package/dist/state-node.js +19 -4
  61. package/dist/telemetry-attestation.js +55 -0
  62. package/dist/telemetry-demo.js +15 -3
  63. package/dist/telemetry-ledger.js +60 -15
  64. package/dist/topology.js +25 -8
  65. package/dist/triggers.js +33 -14
  66. package/dist/trust-audit.js +145 -33
  67. package/dist/version.js +1 -1
  68. package/dist/worker-isolation/helpers.js +51 -0
  69. package/dist/worker-isolation/paths.js +46 -0
  70. package/dist/worker-isolation.js +39 -115
  71. package/docs/agent-delegation-drive.7.md +13 -0
  72. package/docs/cli-mcp-parity.7.md +4 -0
  73. package/docs/contract-migration-tooling.7.md +2 -0
  74. package/docs/control-plane-scheduling.7.md +2 -0
  75. package/docs/dogfood/resume-drive-real-agent-2026-06-14.md +40 -0
  76. package/docs/durable-state-and-locking.7.md +4 -0
  77. package/docs/evidence-adoption-reasoning-chain.7.md +2 -0
  78. package/docs/execution-backends.7.md +2 -0
  79. package/docs/index.md +1 -0
  80. package/docs/launch/launch-kit.md +46 -23
  81. package/docs/launch/pre-launch-checklist.md +14 -14
  82. package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
  83. package/docs/multi-agent-eval-replay-harness.7.md +2 -0
  84. package/docs/multi-agent-operator-ux.7.md +2 -0
  85. package/docs/multi-agent-trust-policy-audit.7.md +27 -0
  86. package/docs/node-snapshot-diff-replay.7.md +2 -0
  87. package/docs/observability-cost-accounting.7.md +2 -0
  88. package/docs/project-index.md +18 -5
  89. package/docs/real-execution-backends.7.md +2 -0
  90. package/docs/release-and-migration.7.md +4 -0
  91. package/docs/release-tooling.7.md +2 -0
  92. package/docs/run-registry-control-plane.7.md +54 -8
  93. package/docs/run-retention-reclamation.7.md +4 -0
  94. package/docs/state-explosion-management.7.md +2 -0
  95. package/docs/team-collaboration.7.md +2 -0
  96. package/docs/trust-model.md +267 -0
  97. package/docs/vendor-manifest-loadability.7.md +43 -0
  98. package/docs/web-desktop-workbench.7.md +2 -0
  99. package/manifest/plugin.manifest.json +1 -1
  100. package/package.json +4 -2
  101. package/scripts/agents/builtin-templates.json +7 -0
  102. package/scripts/bump-version.js +5 -11
  103. package/scripts/canonical-apps-list.js +64 -0
  104. package/scripts/canonical-apps.js +19 -4
  105. package/scripts/dogfood-release.js +1 -1
  106. package/scripts/golden-path.js +4 -4
  107. package/scripts/parity-check.js +5 -0
  108. package/scripts/release-check.js +5 -1
  109. package/scripts/version-sync-check.js +5 -8
  110. package/dist/capability-dispatcher.js +0 -86
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GRAPH_VIEWS = exports.DEFAULT_STATE_EXPLOSION_THRESHOLDS = exports.STATE_EXPLOSION_SCHEMA_VERSION = void 0;
6
+ exports.stateExplosionReportLines = exports.formatBlackboardDigest = exports.formatCompactGraph = exports.formatStateExplosionReport = exports.fingerprintStrings = exports.GRAPH_VIEWS = exports.DEFAULT_STATE_EXPLOSION_THRESHOLDS = exports.STATE_EXPLOSION_SCHEMA_VERSION = void 0;
7
7
  exports.computeStateSize = computeStateSize;
8
8
  exports.summarizeBlackboardDigest = summarizeBlackboardDigest;
9
9
  exports.buildCompactGraph = buildCompactGraph;
@@ -13,13 +13,7 @@ exports.maybeCompactRun = maybeCompactRun;
13
13
  exports.refreshStateExplosionSummaries = refreshStateExplosionSummaries;
14
14
  exports.loadStateExplosionSummaryIndex = loadStateExplosionSummaryIndex;
15
15
  exports.showStateExplosionSummary = showStateExplosionSummary;
16
- exports.formatStateExplosionReport = formatStateExplosionReport;
17
- exports.formatCompactGraph = formatCompactGraph;
18
- exports.formatBlackboardDigest = formatBlackboardDigest;
19
- exports.stateExplosionReportLines = stateExplosionReportLines;
20
16
  exports.normalizeStateExplosionForEval = normalizeStateExplosionForEval;
21
- exports.fingerprintStrings = fingerprintStrings;
22
- const node_crypto_1 = __importDefault(require("node:crypto"));
23
17
  const node_fs_1 = __importDefault(require("node:fs"));
24
18
  const node_path_1 = __importDefault(require("node:path"));
25
19
  const state_1 = require("./state");
@@ -27,6 +21,7 @@ const coordinator_1 = require("./coordinator");
27
21
  const multi_agent_operator_ux_1 = require("./multi-agent-operator-ux");
28
22
  const trust_audit_1 = require("./trust-audit");
29
23
  const evidence_reasoning_1 = require("./evidence-reasoning");
24
+ const helpers_1 = require("./state-explosion/helpers");
30
25
  exports.STATE_EXPLOSION_SCHEMA_VERSION = 1;
31
26
  exports.DEFAULT_STATE_EXPLOSION_THRESHOLDS = {
32
27
  graphNodes: 40,
@@ -178,11 +173,11 @@ function summarizeBlackboardDigest(run, blackboardId) {
178
173
  label: `${topic.title} (${topicMessages.length} messages, ${topic.contextIds.length} contexts, ${topic.artifactRefIds.length} artifacts)`,
179
174
  status: topic.status,
180
175
  sourceIds: [topic.id, ...topicMessages.map((m) => m.id)],
181
- evidenceRefs: unique(topicMessages.flatMap((m) => m.linkedEvidenceRefs || [])),
176
+ evidenceRefs: (0, helpers_1.unique)(topicMessages.flatMap((m) => m.linkedEvidenceRefs || [])),
182
177
  expansionCommand: `node scripts/cw.js blackboard message list ${run.id} --topic ${topic.id}`
183
178
  };
184
179
  })
185
- .sort(byId);
180
+ .sort(helpers_1.byId);
186
181
  const threadSummaries = topics
187
182
  .map((topic) => {
188
183
  const topicMessages = messages
@@ -194,23 +189,23 @@ function summarizeBlackboardDigest(run, blackboardId) {
194
189
  label: `${topic.title}: ${topicMessages.length} messages${last ? `; latest by ${last.author.kind}:${last.author.id}` : ""}`,
195
190
  status: topic.status,
196
191
  sourceIds: topicMessages.map((m) => m.id),
197
- evidenceRefs: unique(topicMessages.flatMap((m) => m.linkedEvidenceRefs || [])),
192
+ evidenceRefs: (0, helpers_1.unique)(topicMessages.flatMap((m) => m.linkedEvidenceRefs || [])),
198
193
  expansionCommand: `node scripts/cw.js blackboard message list ${run.id} --topic ${topic.id}`
199
194
  };
200
195
  })
201
196
  .filter((entry) => entry.sourceIds.length)
202
- .sort(byId);
197
+ .sort(helpers_1.byId);
203
198
  const unresolvedQuestions = contexts
204
199
  .filter((c) => c.kind === "question" && c.status === "open")
205
200
  .map((c) => ({
206
201
  id: c.id,
207
- label: `${c.key}: ${truncate(c.value)}`,
202
+ label: `${c.key}: ${(0, helpers_1.truncate)(c.value)}`,
208
203
  status: c.status,
209
204
  sourceIds: [c.id],
210
- evidenceRefs: unique([...(c.evidenceRefs || []), ...(c.artifactRefIds || [])]),
205
+ evidenceRefs: (0, helpers_1.unique)([...(c.evidenceRefs || []), ...(c.artifactRefIds || [])]),
211
206
  expansionCommand: `node scripts/cw.js blackboard message post ${run.id} --topic ${c.topicId} --body "<answer with evidence>"`
212
207
  }))
213
- .sort(byId);
208
+ .sort(helpers_1.byId);
214
209
  const conflicts = contexts
215
210
  .filter((c) => c.status === "conflicting" || (c.conflictingContextIds || []).length)
216
211
  .map((c) => ({
@@ -218,30 +213,30 @@ function summarizeBlackboardDigest(run, blackboardId) {
218
213
  label: `${c.key} conflicts with ${(c.conflictingContextIds || []).join(", ") || "another value"}`,
219
214
  status: c.status,
220
215
  sourceIds: [c.id, ...(c.conflictingContextIds || [])],
221
- evidenceRefs: unique([...(c.evidenceRefs || []), ...(c.artifactRefIds || [])]),
216
+ evidenceRefs: (0, helpers_1.unique)([...(c.evidenceRefs || []), ...(c.artifactRefIds || [])]),
222
217
  expansionCommand: `node scripts/cw.js coordinator decision ${run.id} --kind conflict-resolution --outcome accepted --subject ${c.id} --reason "<reason>"`
223
218
  }))
224
- .sort(byId);
219
+ .sort(helpers_1.byId);
225
220
  const decisionEntries = decisions
226
221
  .map((d) => ({
227
222
  id: d.id,
228
- label: `${d.kind}:${d.outcome} ${truncate(d.reason)}`,
223
+ label: `${d.kind}:${d.outcome} ${(0, helpers_1.truncate)(d.reason)}`,
229
224
  status: d.status,
230
225
  sourceIds: [d.id, ...(d.subjectIds || [])],
231
- evidenceRefs: unique([...(d.evidenceRefs || []), ...(d.artifactRefIds || [])]),
226
+ evidenceRefs: (0, helpers_1.unique)([...(d.evidenceRefs || []), ...(d.artifactRefIds || [])]),
232
227
  expansionCommand: `node scripts/cw.js node show ${run.id} ${run.id}:coordinator:decision:${d.id}`
233
228
  }))
234
- .sort(byId);
229
+ .sort(helpers_1.byId);
235
230
  const artifactEntries = artifacts
236
231
  .map((a) => ({
237
232
  id: a.id,
238
233
  label: `${a.kind} ${a.locator || a.path || a.id}`,
239
234
  status: a.status,
240
235
  sourceIds: [a.id],
241
- evidenceRefs: unique(a.evidenceRefs || []),
236
+ evidenceRefs: (0, helpers_1.unique)(a.evidenceRefs || []),
242
237
  expansionCommand: `node scripts/cw.js blackboard artifact list ${run.id}`
243
238
  }))
244
- .sort(byId);
239
+ .sort(helpers_1.byId);
245
240
  const adoptedEvidence = artifacts
246
241
  .filter((a) => a.status === "active")
247
242
  .map((a) => ({
@@ -249,42 +244,42 @@ function summarizeBlackboardDigest(run, blackboardId) {
249
244
  label: `${a.kind} ${a.locator || a.path || a.id}`,
250
245
  status: a.status,
251
246
  sourceIds: [a.id],
252
- evidenceRefs: unique([a.locator || a.path || a.id, ...(a.evidenceRefs || [])]),
247
+ evidenceRefs: (0, helpers_1.unique)([a.locator || a.path || a.id, ...(a.evidenceRefs || [])]),
253
248
  expansionCommand: `node scripts/cw.js audit blackboard ${run.id} --json`
254
249
  }))
255
- .sort(byId);
250
+ .sort(helpers_1.byId);
256
251
  const missingEvidence = (summary.missingEvidence || [])
257
252
  .map((reason, index) => ({
258
- id: `missing:${index}:${slug(reason)}`,
253
+ id: `missing:${index}:${(0, helpers_1.slug)(reason)}`,
259
254
  label: reason,
260
255
  status: "missing",
261
256
  sourceIds: [],
262
257
  evidenceRefs: [],
263
258
  expansionCommand: `node scripts/cw.js multi-agent failures ${run.id}`
264
259
  }))
265
- .sort(byId);
260
+ .sort(helpers_1.byId);
266
261
  const policyViolations = decisions
267
262
  .filter((d) => d.outcome === "rejected" || d.outcome === "blocked" || d.outcome === "conflicting")
268
263
  .map((d) => ({
269
264
  id: `policy:${d.id}`,
270
- label: `${d.kind}:${d.outcome} ${truncate(d.reason)}`,
265
+ label: `${d.kind}:${d.outcome} ${(0, helpers_1.truncate)(d.reason)}`,
271
266
  status: d.status,
272
267
  sourceIds: [d.id],
273
- evidenceRefs: unique(d.evidenceRefs || []),
268
+ evidenceRefs: (0, helpers_1.unique)(d.evidenceRefs || []),
274
269
  expansionCommand: `node scripts/cw.js audit policy ${run.id} --json`
275
270
  }))
276
- .sort(byId);
271
+ .sort(helpers_1.byId);
277
272
  const judgeRationale = messages
278
273
  .filter((m) => (m.tags || []).includes("judge-rationale") || Boolean(m.metadata?.judgeRationale))
279
274
  .map((m) => ({
280
275
  id: `judge:${m.id}`,
281
- label: `${m.author.kind}:${m.author.id} ${truncate(m.body)}`,
276
+ label: `${m.author.kind}:${m.author.id} ${(0, helpers_1.truncate)(m.body)}`,
282
277
  status: m.status,
283
278
  sourceIds: [m.id],
284
- evidenceRefs: unique(m.linkedEvidenceRefs || []),
279
+ evidenceRefs: (0, helpers_1.unique)(m.linkedEvidenceRefs || []),
285
280
  expansionCommand: `node scripts/cw.js audit judge ${run.id} --json`
286
281
  }))
287
- .sort(byId);
282
+ .sort(helpers_1.byId);
288
283
  const recentChanges = [...messages, ...contexts, ...artifacts, ...decisions]
289
284
  .map((record) => ({
290
285
  id: record.id,
@@ -302,30 +297,30 @@ function summarizeBlackboardDigest(run, blackboardId) {
302
297
  evidenceRefs: [],
303
298
  expansionCommand: `node scripts/cw.js node show ${run.id} ${record.id}`
304
299
  }))
305
- .sort(byId);
300
+ .sort(helpers_1.byId);
306
301
  const highSignal = [
307
302
  ...conflicts,
308
303
  ...unresolvedQuestions,
309
304
  ...policyViolations,
310
305
  ...missingEvidence
311
- ].sort(byId);
312
- const sourceRecordIds = unique([
306
+ ].sort(helpers_1.byId);
307
+ const sourceRecordIds = (0, helpers_1.unique)([
313
308
  ...topics.map((t) => t.id),
314
309
  ...messages.map((m) => m.id),
315
310
  ...contexts.map((c) => c.id),
316
311
  ...artifacts.map((a) => a.id),
317
312
  ...decisions.map((d) => d.id)
318
313
  ]);
319
- const evidenceRefs = unique([
314
+ const evidenceRefs = (0, helpers_1.unique)([
320
315
  ...messages.flatMap((m) => m.linkedEvidenceRefs || []),
321
316
  ...artifacts.flatMap((a) => [a.locator || a.path || a.id, ...(a.evidenceRefs || [])]),
322
317
  ...contexts.flatMap((c) => c.evidenceRefs || [])
323
318
  ]);
324
- const trustAuditEventRefs = unique([
319
+ const trustAuditEventRefs = (0, helpers_1.unique)([
325
320
  ...messages.flatMap((m) => m.linkedAuditEventIds || []),
326
321
  ...artifacts.flatMap((a) => a.trustAuditEventIds || [])
327
322
  ]);
328
- const fingerprint = fingerprintRecords([...topics, ...messages, ...contexts, ...artifacts, ...decisions]);
323
+ const fingerprint = (0, helpers_1.fingerprintRecords)([...topics, ...messages, ...contexts, ...artifacts, ...decisions]);
329
324
  return {
330
325
  schemaVersion: exports.STATE_EXPLOSION_SCHEMA_VERSION,
331
326
  runId: run.id,
@@ -336,7 +331,7 @@ function summarizeBlackboardDigest(run, blackboardId) {
336
331
  sourceFingerprint: fingerprint,
337
332
  includedCount: topicRollups.length + conflicts.length + unresolvedQuestions.length + decisionEntries.length + artifactEntries.length,
338
333
  omittedCount: Math.max(0, messages.length - threadSummaries.length),
339
- importantRefs: unique([
334
+ importantRefs: (0, helpers_1.unique)([
340
335
  ...conflicts.map((c) => c.id),
341
336
  ...unresolvedQuestions.map((q) => q.id),
342
337
  ...policyViolations.map((p) => p.id)
@@ -385,7 +380,7 @@ function buildCompactGraphWithContext(run, view, options, context) {
385
380
  const protectedIds = new Set(critical);
386
381
  // Failures, blocked, rejected, conflicting nodes are always preserved.
387
382
  for (const node of full.nodes) {
388
- if (isProtectedStatus(node.status))
383
+ if ((0, helpers_1.isProtectedStatus)(node.status))
389
384
  protectedIds.add(node.id);
390
385
  }
391
386
  // v0.1.26: reasoning steps are on the critical path and must never be collapsed
@@ -397,7 +392,7 @@ function buildCompactGraphWithContext(run, view, options, context) {
397
392
  if (failure.linked)
398
393
  protectedIds.add(failure.linked);
399
394
  }
400
- const parents = parentMap(full.edges);
395
+ const parents = (0, helpers_1.parentMap)(full.edges);
401
396
  const parentOf = (id) => parents.get(id);
402
397
  let scopeNodes = full.nodes;
403
398
  let scopeEdges = full.edges;
@@ -459,9 +454,9 @@ function buildCompactGraphWithContext(run, view, options, context) {
459
454
  }
460
455
  const members = scopeNodes.filter((node) => ids.includes(node.id));
461
456
  const internalEdges = scopeEdges.filter((edge) => ids.includes(edge.from) && ids.includes(edge.to));
462
- const syntheticId = `${run.id}:summary:${slug(key)}`;
463
- const dominant = dominantStatus(members.map((m) => m.status));
464
- const blocked = members.find((m) => isProtectedStatus(m.status));
457
+ const syntheticId = `${run.id}:summary:${(0, helpers_1.slug)(key)}`;
458
+ const dominant = (0, helpers_1.dominantStatus)(members.map((m) => m.status));
459
+ const blocked = members.find((m) => (0, helpers_1.isProtectedStatus)(m.status));
465
460
  synthetic.push({
466
461
  id: syntheticId,
467
462
  kind: "summary",
@@ -518,14 +513,14 @@ function buildCompactGraphWithContext(run, view, options, context) {
518
513
  function finalizeGraphRecord(run, view, options, full, built) {
519
514
  const collapsedNodeCount = built.syntheticNodes.reduce((acc, syn) => acc + syn.collapsedNodeCount, 0);
520
515
  const collapsedEdgeCount = built.syntheticNodes.reduce((acc, syn) => acc + syn.collapsedEdgeCount, 0);
521
- const blockedReasons = unique([
516
+ const blockedReasons = (0, helpers_1.unique)([
522
517
  ...built.operator.failures.map((f) => `${f.kind} ${f.id}: ${f.reason}`),
523
518
  ...built.syntheticNodes.filter((s) => s.blockedReason).map((s) => s.blockedReason)
524
519
  ]);
525
520
  return {
526
521
  schemaVersion: exports.STATE_EXPLOSION_SCHEMA_VERSION,
527
522
  runId: run.id,
528
- id: `graph-${view}${options.focus ? `:focus:${slug(options.focus)}` : ""}`,
523
+ id: `graph-${view}${options.focus ? `:focus:${(0, helpers_1.slug)(options.focus)}` : ""}`,
529
524
  scope: "run",
530
525
  view,
531
526
  focus: options.focus,
@@ -542,7 +537,7 @@ function finalizeGraphRecord(run, view, options, full, built) {
542
537
  nodes: built.nodes,
543
538
  edges: built.edges,
544
539
  sourceRecordIds: full.nodes.map((n) => n.id).sort(),
545
- sourceFingerprint: fingerprintStrings(full.nodes.map((n) => `${n.id}:${n.status}`)),
540
+ sourceFingerprint: (0, helpers_1.fingerprintStrings)(full.nodes.map((n) => `${n.id}:${n.status}`)),
546
541
  includedCount: built.nodes.length,
547
542
  omittedCount: collapsedNodeCount,
548
543
  importantRefs: built.critical,
@@ -558,7 +553,6 @@ function finalizeGraphRecord(run, view, options, full, built) {
558
553
  }
559
554
  function collapseRuleFor(view) {
560
555
  return {
561
- collapse: true,
562
556
  bucketBy: (node, parentOf) => {
563
557
  switch (node.kind) {
564
558
  case "blackboard-message":
@@ -613,7 +607,7 @@ function filterByView(run, view, full, operator, protectedIds) {
613
607
  ids.add(failure.linked);
614
608
  }
615
609
  for (const node of full.nodes)
616
- if (isProtectedStatus(node.status))
610
+ if ((0, helpers_1.isProtectedStatus)(node.status))
617
611
  ids.add(node.id);
618
612
  ids.add(`${run.id}:run`);
619
613
  break;
@@ -703,7 +697,7 @@ function criticalPathNodeIds(run, operator) {
703
697
  if (failure.linked)
704
698
  ids.push(failure.linked);
705
699
  }
706
- return unique(ids);
700
+ return (0, helpers_1.unique)(ids);
707
701
  }
708
702
  function bfsNeighborhood(focus, nodes, edges, depth) {
709
703
  const adjacency = new Map();
@@ -759,7 +753,7 @@ function buildOperatorDigestWithContext(run, thresholds, context) {
759
753
  count: syn.collapsedNodeCount,
760
754
  expansionCommand: syn.expansionCommand
761
755
  }));
762
- const expansionCommands = unique([
756
+ const expansionCommands = (0, helpers_1.unique)([
763
757
  `node scripts/cw.js multi-agent graph ${run.id} --view full --json`,
764
758
  `node scripts/cw.js blackboard message list ${run.id} --topic <topic-id>`,
765
759
  `node scripts/cw.js multi-agent graph ${run.id} --view critical-path`,
@@ -772,7 +766,7 @@ function buildOperatorDigestWithContext(run, thresholds, context) {
772
766
  id: "operator-digest",
773
767
  scope: "run",
774
768
  sourceRecordIds: compact.sourceRecordIds,
775
- sourceFingerprint: fingerprintStrings([
769
+ sourceFingerprint: (0, helpers_1.fingerprintStrings)([
776
770
  compact.sourceFingerprint,
777
771
  blackboard.sourceFingerprint,
778
772
  String(stateSize.total)
@@ -780,8 +774,8 @@ function buildOperatorDigestWithContext(run, thresholds, context) {
780
774
  includedCount: compact.compactNodeCount,
781
775
  omittedCount: compact.collapsedNodeCount,
782
776
  importantRefs: compact.criticalPath,
783
- evidenceRefs: unique(adopted.map((e) => e.ref || e.id)),
784
- trustAuditEventRefs: [],
777
+ evidenceRefs: (0, helpers_1.unique)(adopted.map((e) => e.ref || e.id)),
778
+ trustAuditEventRefs: (0, helpers_1.unique)(blackboard.trustAuditEventRefs),
785
779
  generatedAt: new Date().toISOString(),
786
780
  status: "valid",
787
781
  deterministic: true,
@@ -814,7 +808,7 @@ function buildOperatorDigestWithContext(run, thresholds, context) {
814
808
  events: trust?.totalEvents || 0,
815
809
  policyViolations: blackboard.policyViolations.length,
816
810
  judgeRationales: blackboard.judgeRationale.length,
817
- entries: unique([
811
+ entries: (0, helpers_1.unique)([
818
812
  ...blackboard.policyViolations.map((p) => p.id),
819
813
  ...blackboard.judgeRationale.map((j) => j.id)
820
814
  ])
@@ -836,7 +830,7 @@ function buildStateExplosionReportWithContext(run, options, context) {
836
830
  const criticalPathGraph = buildCompactGraphWithContext(run, "critical-path", { thresholds }, context);
837
831
  const blackboardDigest = blackboardDigestFor(run, context);
838
832
  const operatorDigest = buildOperatorDigestWithContext(run, thresholds, context);
839
- const currentFingerprint = fingerprintStrings([
833
+ const currentFingerprint = (0, helpers_1.fingerprintStrings)([
840
834
  compactGraph.sourceFingerprint,
841
835
  blackboardDigest.sourceFingerprint,
842
836
  operatorDigest.sourceFingerprint,
@@ -933,12 +927,6 @@ function refreshStateExplosionSummaries(run, options = {}) {
933
927
  writeRecord(record.id, record, "run", record.sourceFingerprint, record.compactNodeCount, record.collapsedNodeCount);
934
928
  }
935
929
  const stateSize = stateSizeFor(run, thresholds, context);
936
- const indexFingerprint = fingerprintStrings([
937
- operatorDigest.sourceFingerprint,
938
- blackboardDigest.sourceFingerprint,
939
- ...graphRecords.map((r) => r.sourceFingerprint),
940
- String(stateSize.total)
941
- ]);
942
930
  const compactGraph = buildCompactGraphWithContext(run, "compact", { thresholds }, context);
943
931
  const reportPath = node_path_1.default.join(dir, "state-explosion-report.json");
944
932
  const index = {
@@ -946,8 +934,8 @@ function refreshStateExplosionSummaries(run, options = {}) {
946
934
  runId: run.id,
947
935
  id: "multi-agent-summary-index",
948
936
  scope: "run",
949
- sourceRecordIds: unique([...blackboardDigest.sourceRecordIds, ...operatorDigest.sourceRecordIds]),
950
- sourceFingerprint: fingerprintStrings([
937
+ sourceRecordIds: (0, helpers_1.unique)([...blackboardDigest.sourceRecordIds, ...operatorDigest.sourceRecordIds]),
938
+ sourceFingerprint: (0, helpers_1.fingerprintStrings)([
951
939
  compactGraph.sourceFingerprint,
952
940
  blackboardDigest.sourceFingerprint,
953
941
  operatorDigest.sourceFingerprint,
@@ -970,7 +958,6 @@ function refreshStateExplosionSummaries(run, options = {}) {
970
958
  reportPath
971
959
  }
972
960
  };
973
- void indexFingerprint;
974
961
  (0, state_1.writeJson)(index.paths.indexPath, index);
975
962
  const report = buildStateExplosionReportWithContext(run, { thresholds, index }, context);
976
963
  (0, state_1.writeJson)(reportPath, report);
@@ -1023,175 +1010,19 @@ function showStateExplosionSummary(run, options = {}) {
1023
1010
  }
1024
1011
  return report;
1025
1012
  }
1026
- // ---------------------------------------------------------------------------
1027
- // Human formatting
1028
- // ---------------------------------------------------------------------------
1029
- function formatStateExplosionReport(report) {
1030
- const lines = [];
1031
- const size = report.stateSize;
1032
- lines.push(`State Explosion Report: ${report.runId}`);
1033
- lines.push(`Freshness: ${report.freshness.status}${report.freshness.staleScopes.length ? ` (stale: ${report.freshness.staleScopes.join(", ")})` : ""}`);
1034
- lines.push("");
1035
- lines.push("State Size");
1036
- lines.push(` records=${size.total}; graph nodes=${size.graphNodes}; graph edges=${size.graphEdges}; messages=${size.messages}; compaction=${size.compactionRecommended ? "recommended" : "not needed"}`);
1037
- for (const reason of size.reasons)
1038
- lines.push(` - ${reason}`);
1039
- lines.push("");
1040
- lines.push("Compact Graph");
1041
- lines.push(` full=${report.compactGraph.fullNodeCount} nodes/${report.compactGraph.fullEdgeCount} edges -> compact=${report.compactGraph.compactNodeCount} nodes/${report.compactGraph.compactEdgeCount} edges`);
1042
- if (report.compactGraph.collapsedNodeCount > 0) {
1043
- lines.push(` Graph compacted: ${report.compactGraph.collapsedNodeCount} nodes collapsed into ${report.compactGraph.syntheticNodes.length} summary nodes`);
1044
- }
1045
- for (const syn of report.compactGraph.syntheticNodes) {
1046
- lines.push(` [${syn.dominantStatus}] ${syn.id} collapses ${syn.collapsedNodeCount} nodes/${syn.collapsedEdgeCount} edges${syn.blockedReason ? ` blocked=${syn.blockedReason}` : ""}; expand: ${syn.expansionCommand}`);
1047
- }
1048
- lines.push("");
1049
- lines.push("Blackboard Digest");
1050
- lines.push(` topics=${report.blackboardDigest.topicRollups.length}; threads=${report.blackboardDigest.threadSummaries.length}; unresolved=${report.blackboardDigest.unresolvedQuestions.length}; conflicts=${report.blackboardDigest.conflicts.length}; decisions=${report.blackboardDigest.decisions.length}; artifacts=${report.blackboardDigest.artifacts.length}`);
1051
- for (const topic of report.blackboardDigest.topicRollups.slice(0, 20))
1052
- lines.push(` - ${topic.label}; expand: ${topic.expansionCommand}`);
1053
- lines.push("");
1054
- lines.push("Critical Path");
1055
- if (!report.criticalPathGraph.criticalPath.length)
1056
- lines.push(" none");
1057
- for (const id of report.criticalPathGraph.criticalPath.slice(0, 40))
1058
- lines.push(` -> ${id}`);
1059
- lines.push("");
1060
- lines.push("Failures / Blockers");
1061
- if (!report.operatorDigest.failures.length)
1062
- lines.push(" none");
1063
- for (const failure of report.operatorDigest.failures.slice(0, 30))
1064
- lines.push(` [${failure.status}] ${failure.kind} ${failure.id}: ${failure.reason}; next=${failure.nextCommand}`);
1065
- lines.push("");
1066
- lines.push("Evidence Digest");
1067
- lines.push(` adopted=${report.operatorDigest.evidenceDigest.adopted}; missing=${report.operatorDigest.evidenceDigest.missing}; rejected=${report.operatorDigest.evidenceDigest.rejected}`);
1068
- lines.push("");
1069
- lines.push("Trust / Policy Digest");
1070
- lines.push(` events=${report.operatorDigest.trustDigest.events}; policyViolations=${report.operatorDigest.trustDigest.policyViolations}; judgeRationales=${report.operatorDigest.trustDigest.judgeRationales}`);
1071
- for (const violation of report.blackboardDigest.policyViolations.slice(0, 20))
1072
- lines.push(` [policy] ${violation.label}; expand: ${violation.expansionCommand}`);
1073
- lines.push("");
1074
- lines.push("Hidden Source Records");
1075
- if (!report.hiddenSourceRecords.length)
1076
- lines.push(" none (all records shown)");
1077
- for (const hidden of report.hiddenSourceRecords)
1078
- lines.push(` ${hidden.kind}: ${hidden.count} records hidden; expand: ${hidden.expansionCommand}`);
1079
- lines.push("");
1080
- lines.push("Expansion Commands");
1081
- for (const command of report.expansionCommands)
1082
- lines.push(` ${command}`);
1083
- lines.push("");
1084
- lines.push("Next Action");
1085
- lines.push(` ${report.nextAction}`);
1086
- return lines.join("\n");
1087
- }
1088
- function formatCompactGraph(graph) {
1089
- const lines = [];
1090
- lines.push(`Compact Graph (${graph.view}): ${graph.runId}`);
1091
- lines.push(` full=${graph.fullNodeCount} nodes/${graph.fullEdgeCount} edges -> view=${graph.compactNodeCount} nodes/${graph.compactEdgeCount} edges`);
1092
- if (graph.collapsedNodeCount > 0) {
1093
- lines.push(` Graph compacted: ${graph.collapsedNodeCount} nodes collapsed into ${graph.syntheticNodes.length} summary nodes`);
1094
- }
1095
- lines.push("");
1096
- lines.push("Critical Path");
1097
- if (!graph.criticalPath.length)
1098
- lines.push(" none");
1099
- for (const id of graph.criticalPath.slice(0, 40))
1100
- lines.push(` -> ${id}`);
1101
- lines.push("");
1102
- lines.push("Summary Nodes");
1103
- if (!graph.syntheticNodes.length)
1104
- lines.push(" none");
1105
- for (const syn of graph.syntheticNodes) {
1106
- lines.push(` [${syn.dominantStatus}] ${syn.id}: ${syn.collapsedNodeCount} nodes / ${syn.collapsedEdgeCount} edges${syn.blockedReason ? ` blocked=${syn.blockedReason}` : ""}`);
1107
- lines.push(` expand: ${syn.expansionCommand}`);
1108
- }
1109
- lines.push("");
1110
- lines.push("Blockers");
1111
- if (!graph.blockedReasons.length)
1112
- lines.push(" none");
1113
- for (const reason of graph.blockedReasons.slice(0, 20))
1114
- lines.push(` ${reason}`);
1115
- lines.push("");
1116
- lines.push("Nodes");
1117
- for (const node of graph.nodes.slice(0, 80)) {
1118
- lines.push(` [${node.status}] ${node.kind} ${node.id}${node.synthetic ? ` (summary of ${node.synthetic.collapsedNodeCount})` : ""}`);
1119
- }
1120
- if (graph.nodes.length > 80)
1121
- lines.push(` ... ${graph.nodes.length - 80} more`);
1122
- lines.push("");
1123
- lines.push("Next Action");
1124
- lines.push(` ${graph.nextAction}`);
1125
- return lines.join("\n");
1126
- }
1127
- function formatBlackboardDigest(record) {
1128
- const lines = [];
1129
- lines.push(`Blackboard Digest: ${record.runId}${record.blackboardId ? ` (${record.blackboardId})` : ""}`);
1130
- lines.push(` freshness=${record.status}; included=${record.includedCount}; omitted=${record.omittedCount}`);
1131
- const section = (title, entries) => {
1132
- lines.push("");
1133
- lines.push(title);
1134
- if (!entries.length) {
1135
- lines.push(" none");
1136
- return;
1137
- }
1138
- for (const entry of entries.slice(0, 25))
1139
- lines.push(` [${entry.status}] ${entry.label}; expand: ${entry.expansionCommand}`);
1140
- if (entries.length > 25)
1141
- lines.push(` ... ${entries.length - 25} more`);
1142
- };
1143
- section("Topic Rollups", record.topicRollups);
1144
- section("Thread Summaries", record.threadSummaries);
1145
- section("Unresolved Questions", record.unresolvedQuestions);
1146
- section("Conflicts", record.conflicts);
1147
- section("Decisions", record.decisions);
1148
- section("Artifacts", record.artifacts);
1149
- section("Adopted Evidence", record.adoptedEvidence);
1150
- section("Missing Evidence", record.missingEvidence);
1151
- section("Policy Violations", record.policyViolations);
1152
- section("Judge Rationale", record.judgeRationale);
1153
- section("Recent Changes", record.recentChanges);
1154
- section("High-Signal Records", record.highSignal);
1155
- lines.push("");
1156
- lines.push("Next Action");
1157
- lines.push(` ${record.nextAction}`);
1158
- return lines.join("\n");
1159
- }
1160
- function stateExplosionReportLines(report) {
1161
- // Markdown lines for inclusion in the run report.md State Size section.
1162
- const size = report.stateSize;
1163
- const lines = [
1164
- `- Records: ${size.total}; graph nodes: ${size.graphNodes}; graph edges: ${size.graphEdges}; messages: ${size.messages}`,
1165
- `- Compaction: ${size.compactionRecommended ? "recommended" : "not needed"}`,
1166
- `- Summary freshness: ${report.freshness.status}`
1167
- ];
1168
- for (const reason of size.reasons)
1169
- lines.push(` - ${reason}`);
1170
- if (report.compactGraph.collapsedNodeCount > 0) {
1171
- lines.push(`- Graph compacted: ${report.compactGraph.collapsedNodeCount} nodes collapsed into ${report.compactGraph.syntheticNodes.length} summary nodes`);
1172
- lines.push(` - Use: \`node scripts/cw.js multi-agent graph ${report.runId} --view full --json\``);
1173
- }
1174
- if (report.hiddenSourceRecords.length) {
1175
- for (const hidden of report.hiddenSourceRecords) {
1176
- lines.push(`- Hidden ${hidden.kind}: ${hidden.count} records; expand: \`${hidden.expansionCommand}\``);
1177
- }
1178
- }
1179
- lines.push(`- Next: \`${report.nextAction}\``);
1180
- return lines;
1181
- }
1182
1013
  function normalizeStateExplosionForEval(run) {
1183
1014
  const report = buildStateExplosionReport(run);
1184
1015
  const graph = report.compactGraph;
1185
1016
  return {
1186
1017
  summaryFreshness: [
1187
- stableLine({
1018
+ (0, helpers_1.stableLine)({
1188
1019
  compactionRecommended: report.stateSize.compactionRecommended,
1189
1020
  total: report.stateSize.total,
1190
1021
  deterministic: graph.deterministic
1191
1022
  })
1192
1023
  ],
1193
1024
  compactGraphShape: [
1194
- stableLine({
1025
+ (0, helpers_1.stableLine)({
1195
1026
  view: graph.view,
1196
1027
  fullNodeCount: graph.fullNodeCount,
1197
1028
  fullEdgeCount: graph.fullEdgeCount,
@@ -1207,7 +1038,7 @@ function normalizeStateExplosionForEval(run) {
1207
1038
  })
1208
1039
  ],
1209
1040
  blackboardDigest: [
1210
- stableLine({
1041
+ (0, helpers_1.stableLine)({
1211
1042
  topics: report.blackboardDigest.topicRollups.length,
1212
1043
  threads: report.blackboardDigest.threadSummaries.length,
1213
1044
  unresolved: report.blackboardDigest.unresolvedQuestions.map((q) => q.id),
@@ -1219,9 +1050,9 @@ function normalizeStateExplosionForEval(run) {
1219
1050
  missingEvidence: report.blackboardDigest.missingEvidence.map((m) => m.label)
1220
1051
  })
1221
1052
  ],
1222
- criticalPath: graph.criticalPath.map((id) => stripRunId(run, id)).sort(),
1053
+ criticalPath: graph.criticalPath.map((id) => (0, helpers_1.stripRunId)(run, id)).sort(),
1223
1054
  evidenceDigest: [
1224
- stableLine({
1055
+ (0, helpers_1.stableLine)({
1225
1056
  adopted: report.operatorDigest.evidenceDigest.adopted,
1226
1057
  missing: report.operatorDigest.evidenceDigest.missing,
1227
1058
  rejected: report.operatorDigest.evidenceDigest.rejected
@@ -1231,62 +1062,13 @@ function normalizeStateExplosionForEval(run) {
1231
1062
  };
1232
1063
  }
1233
1064
  // ---------------------------------------------------------------------------
1234
- // Helpers
1065
+ // Helpers + human formatting now live in sibling modules (FreeBSD-audit carve).
1066
+ // Re-exported below so every importer of this module stays byte-unchanged.
1235
1067
  // ---------------------------------------------------------------------------
1236
- function isProtectedStatus(status) {
1237
- return ["failed", "blocked", "rejected", "conflicting"].includes(status);
1238
- }
1239
- function dominantStatus(statuses) {
1240
- for (const priority of ["failed", "blocked", "rejected", "conflicting", "running", "pending"]) {
1241
- if (statuses.includes(priority))
1242
- return priority;
1243
- }
1244
- return statuses[0] || "completed";
1245
- }
1246
- function parentMap(edges) {
1247
- const parents = new Map();
1248
- for (const edge of edges) {
1249
- if (!parents.has(edge.to))
1250
- parents.set(edge.to, edge.from);
1251
- }
1252
- return parents;
1253
- }
1254
- function fingerprintRecords(records) {
1255
- return fingerprintStrings(records.map((r) => `${r.id}:${r.status || ""}`).sort());
1256
- }
1257
- function fingerprintStrings(values) {
1258
- const hash = node_crypto_1.default.createHash("sha256");
1259
- hash.update(JSON.stringify([...values].sort()));
1260
- return `sha256:${hash.digest("hex").slice(0, 32)}`;
1261
- }
1262
- function stableLine(value) {
1263
- return JSON.stringify(sortKeys(value));
1264
- }
1265
- function sortKeys(value) {
1266
- if (Array.isArray(value))
1267
- return value.map(sortKeys);
1268
- if (value && typeof value === "object") {
1269
- const record = value;
1270
- const result = {};
1271
- for (const key of Object.keys(record).sort())
1272
- result[key] = sortKeys(record[key]);
1273
- return result;
1274
- }
1275
- return value;
1276
- }
1277
- function stripRunId(run, id) {
1278
- return id.startsWith(`${run.id}:`) ? id.slice(run.id.length + 1) : id;
1279
- }
1280
- function unique(values) {
1281
- return Array.from(new Set(values.filter(Boolean))).sort();
1282
- }
1283
- function byId(a, b) {
1284
- return a.id.localeCompare(b.id);
1285
- }
1286
- function truncate(value) {
1287
- const single = value.replace(/\s+/g, " ").trim();
1288
- return single.length > 80 ? `${single.slice(0, 77)}...` : single;
1289
- }
1290
- function slug(value) {
1291
- return value.replace(/[^a-zA-Z0-9._:-]/g, "-");
1292
- }
1068
+ var helpers_2 = require("./state-explosion/helpers");
1069
+ Object.defineProperty(exports, "fingerprintStrings", { enumerable: true, get: function () { return helpers_2.fingerprintStrings; } });
1070
+ var format_1 = require("./state-explosion/format");
1071
+ Object.defineProperty(exports, "formatStateExplosionReport", { enumerable: true, get: function () { return format_1.formatStateExplosionReport; } });
1072
+ Object.defineProperty(exports, "formatCompactGraph", { enumerable: true, get: function () { return format_1.formatCompactGraph; } });
1073
+ Object.defineProperty(exports, "formatBlackboardDigest", { enumerable: true, get: function () { return format_1.formatBlackboardDigest; } });
1074
+ Object.defineProperty(exports, "stateExplosionReportLines", { enumerable: true, get: function () { return format_1.stateExplosionReportLines; } });