opencode-swarm-plugin 0.43.0 → 0.44.1

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 (208) hide show
  1. package/bin/cass.characterization.test.ts +422 -0
  2. package/bin/swarm.serve.test.ts +6 -4
  3. package/bin/swarm.test.ts +68 -0
  4. package/bin/swarm.ts +81 -8
  5. package/dist/compaction-prompt-scoring.js +139 -0
  6. package/dist/contributor-tools.d.ts +42 -0
  7. package/dist/contributor-tools.d.ts.map +1 -0
  8. package/dist/eval-capture.js +12811 -0
  9. package/dist/hive.d.ts.map +1 -1
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7728 -62590
  13. package/dist/plugin.js +23833 -78695
  14. package/dist/sessions/agent-discovery.d.ts +59 -0
  15. package/dist/sessions/agent-discovery.d.ts.map +1 -0
  16. package/dist/sessions/index.d.ts +10 -0
  17. package/dist/sessions/index.d.ts.map +1 -0
  18. package/dist/swarm-orchestrate.d.ts.map +1 -1
  19. package/dist/swarm-prompts.d.ts.map +1 -1
  20. package/dist/swarm-review.d.ts.map +1 -1
  21. package/package.json +17 -5
  22. package/.changeset/swarm-insights-data-layer.md +0 -63
  23. package/.hive/analysis/eval-failure-analysis-2025-12-25.md +0 -331
  24. package/.hive/analysis/session-data-quality-audit.md +0 -320
  25. package/.hive/eval-results.json +0 -483
  26. package/.hive/issues.jsonl +0 -138
  27. package/.hive/memories.jsonl +0 -729
  28. package/.opencode/eval-history.jsonl +0 -327
  29. package/.turbo/turbo-build.log +0 -9
  30. package/CHANGELOG.md +0 -2255
  31. package/SCORER-ANALYSIS.md +0 -598
  32. package/docs/analysis/subagent-coordination-patterns.md +0 -902
  33. package/docs/analysis-socratic-planner-pattern.md +0 -504
  34. package/docs/planning/ADR-001-monorepo-structure.md +0 -171
  35. package/docs/planning/ADR-002-package-extraction.md +0 -393
  36. package/docs/planning/ADR-003-performance-improvements.md +0 -451
  37. package/docs/planning/ADR-004-message-queue-features.md +0 -187
  38. package/docs/planning/ADR-005-devtools-observability.md +0 -202
  39. package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +0 -168
  40. package/docs/planning/ADR-008-worker-handoff-protocol.md +0 -293
  41. package/docs/planning/ADR-009-oh-my-opencode-patterns.md +0 -353
  42. package/docs/planning/ROADMAP.md +0 -368
  43. package/docs/semantic-memory-cli-syntax.md +0 -123
  44. package/docs/swarm-mail-architecture.md +0 -1147
  45. package/docs/testing/context-recovery-test.md +0 -470
  46. package/evals/ARCHITECTURE.md +0 -1189
  47. package/evals/README.md +0 -768
  48. package/evals/compaction-prompt.eval.ts +0 -149
  49. package/evals/compaction-resumption.eval.ts +0 -289
  50. package/evals/coordinator-behavior.eval.ts +0 -307
  51. package/evals/coordinator-session.eval.ts +0 -154
  52. package/evals/evalite.config.ts.bak +0 -15
  53. package/evals/example.eval.ts +0 -31
  54. package/evals/fixtures/compaction-cases.ts +0 -350
  55. package/evals/fixtures/compaction-prompt-cases.ts +0 -311
  56. package/evals/fixtures/coordinator-sessions.ts +0 -328
  57. package/evals/fixtures/decomposition-cases.ts +0 -105
  58. package/evals/lib/compaction-loader.test.ts +0 -248
  59. package/evals/lib/compaction-loader.ts +0 -320
  60. package/evals/lib/data-loader.evalite-test.ts +0 -289
  61. package/evals/lib/data-loader.test.ts +0 -345
  62. package/evals/lib/data-loader.ts +0 -281
  63. package/evals/lib/llm.ts +0 -115
  64. package/evals/scorers/compaction-prompt-scorers.ts +0 -145
  65. package/evals/scorers/compaction-scorers.ts +0 -305
  66. package/evals/scorers/coordinator-discipline.evalite-test.ts +0 -539
  67. package/evals/scorers/coordinator-discipline.ts +0 -325
  68. package/evals/scorers/index.test.ts +0 -146
  69. package/evals/scorers/index.ts +0 -328
  70. package/evals/scorers/outcome-scorers.evalite-test.ts +0 -27
  71. package/evals/scorers/outcome-scorers.ts +0 -349
  72. package/evals/swarm-decomposition.eval.ts +0 -121
  73. package/examples/commands/swarm.md +0 -745
  74. package/examples/plugin-wrapper-template.ts +0 -2426
  75. package/examples/skills/hive-workflow/SKILL.md +0 -212
  76. package/examples/skills/skill-creator/SKILL.md +0 -223
  77. package/examples/skills/swarm-coordination/SKILL.md +0 -292
  78. package/global-skills/cli-builder/SKILL.md +0 -344
  79. package/global-skills/cli-builder/references/advanced-patterns.md +0 -244
  80. package/global-skills/learning-systems/SKILL.md +0 -644
  81. package/global-skills/skill-creator/LICENSE.txt +0 -202
  82. package/global-skills/skill-creator/SKILL.md +0 -352
  83. package/global-skills/skill-creator/references/output-patterns.md +0 -82
  84. package/global-skills/skill-creator/references/workflows.md +0 -28
  85. package/global-skills/swarm-coordination/SKILL.md +0 -995
  86. package/global-skills/swarm-coordination/references/coordinator-patterns.md +0 -235
  87. package/global-skills/swarm-coordination/references/strategies.md +0 -138
  88. package/global-skills/system-design/SKILL.md +0 -213
  89. package/global-skills/testing-patterns/SKILL.md +0 -430
  90. package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +0 -586
  91. package/opencode-swarm-plugin-0.30.7.tgz +0 -0
  92. package/opencode-swarm-plugin-0.31.0.tgz +0 -0
  93. package/scripts/cleanup-test-memories.ts +0 -346
  94. package/scripts/init-skill.ts +0 -222
  95. package/scripts/migrate-unknown-sessions.ts +0 -349
  96. package/scripts/validate-skill.ts +0 -204
  97. package/src/agent-mail.ts +0 -1724
  98. package/src/anti-patterns.test.ts +0 -1167
  99. package/src/anti-patterns.ts +0 -448
  100. package/src/compaction-capture.integration.test.ts +0 -257
  101. package/src/compaction-hook.test.ts +0 -838
  102. package/src/compaction-hook.ts +0 -1204
  103. package/src/compaction-observability.integration.test.ts +0 -139
  104. package/src/compaction-observability.test.ts +0 -187
  105. package/src/compaction-observability.ts +0 -324
  106. package/src/compaction-prompt-scorers.test.ts +0 -475
  107. package/src/compaction-prompt-scoring.ts +0 -300
  108. package/src/dashboard.test.ts +0 -611
  109. package/src/dashboard.ts +0 -462
  110. package/src/error-enrichment.test.ts +0 -403
  111. package/src/error-enrichment.ts +0 -219
  112. package/src/eval-capture.test.ts +0 -1015
  113. package/src/eval-capture.ts +0 -929
  114. package/src/eval-gates.test.ts +0 -306
  115. package/src/eval-gates.ts +0 -218
  116. package/src/eval-history.test.ts +0 -508
  117. package/src/eval-history.ts +0 -214
  118. package/src/eval-learning.test.ts +0 -378
  119. package/src/eval-learning.ts +0 -360
  120. package/src/eval-runner.test.ts +0 -223
  121. package/src/eval-runner.ts +0 -402
  122. package/src/export-tools.test.ts +0 -476
  123. package/src/export-tools.ts +0 -257
  124. package/src/hive.integration.test.ts +0 -2241
  125. package/src/hive.ts +0 -1628
  126. package/src/index.ts +0 -935
  127. package/src/learning.integration.test.ts +0 -1815
  128. package/src/learning.ts +0 -1079
  129. package/src/logger.test.ts +0 -189
  130. package/src/logger.ts +0 -135
  131. package/src/mandate-promotion.test.ts +0 -473
  132. package/src/mandate-promotion.ts +0 -239
  133. package/src/mandate-storage.integration.test.ts +0 -601
  134. package/src/mandate-storage.test.ts +0 -578
  135. package/src/mandate-storage.ts +0 -794
  136. package/src/mandates.ts +0 -540
  137. package/src/memory-tools.test.ts +0 -195
  138. package/src/memory-tools.ts +0 -344
  139. package/src/memory.integration.test.ts +0 -334
  140. package/src/memory.test.ts +0 -158
  141. package/src/memory.ts +0 -527
  142. package/src/model-selection.test.ts +0 -188
  143. package/src/model-selection.ts +0 -68
  144. package/src/observability-tools.test.ts +0 -359
  145. package/src/observability-tools.ts +0 -871
  146. package/src/output-guardrails.test.ts +0 -438
  147. package/src/output-guardrails.ts +0 -381
  148. package/src/pattern-maturity.test.ts +0 -1160
  149. package/src/pattern-maturity.ts +0 -525
  150. package/src/planning-guardrails.test.ts +0 -491
  151. package/src/planning-guardrails.ts +0 -438
  152. package/src/plugin.ts +0 -23
  153. package/src/post-compaction-tracker.test.ts +0 -251
  154. package/src/post-compaction-tracker.ts +0 -237
  155. package/src/query-tools.test.ts +0 -636
  156. package/src/query-tools.ts +0 -324
  157. package/src/rate-limiter.integration.test.ts +0 -466
  158. package/src/rate-limiter.ts +0 -774
  159. package/src/replay-tools.test.ts +0 -496
  160. package/src/replay-tools.ts +0 -240
  161. package/src/repo-crawl.integration.test.ts +0 -441
  162. package/src/repo-crawl.ts +0 -610
  163. package/src/schemas/cell-events.test.ts +0 -347
  164. package/src/schemas/cell-events.ts +0 -807
  165. package/src/schemas/cell.ts +0 -257
  166. package/src/schemas/evaluation.ts +0 -166
  167. package/src/schemas/index.test.ts +0 -199
  168. package/src/schemas/index.ts +0 -286
  169. package/src/schemas/mandate.ts +0 -232
  170. package/src/schemas/swarm-context.ts +0 -115
  171. package/src/schemas/task.ts +0 -161
  172. package/src/schemas/worker-handoff.test.ts +0 -302
  173. package/src/schemas/worker-handoff.ts +0 -131
  174. package/src/skills.integration.test.ts +0 -1192
  175. package/src/skills.test.ts +0 -643
  176. package/src/skills.ts +0 -1549
  177. package/src/storage.integration.test.ts +0 -341
  178. package/src/storage.ts +0 -884
  179. package/src/structured.integration.test.ts +0 -817
  180. package/src/structured.test.ts +0 -1046
  181. package/src/structured.ts +0 -762
  182. package/src/swarm-decompose.test.ts +0 -188
  183. package/src/swarm-decompose.ts +0 -1302
  184. package/src/swarm-deferred.integration.test.ts +0 -157
  185. package/src/swarm-deferred.test.ts +0 -38
  186. package/src/swarm-insights.test.ts +0 -214
  187. package/src/swarm-insights.ts +0 -459
  188. package/src/swarm-mail.integration.test.ts +0 -970
  189. package/src/swarm-mail.ts +0 -739
  190. package/src/swarm-orchestrate.integration.test.ts +0 -282
  191. package/src/swarm-orchestrate.test.ts +0 -548
  192. package/src/swarm-orchestrate.ts +0 -3084
  193. package/src/swarm-prompts.test.ts +0 -1270
  194. package/src/swarm-prompts.ts +0 -2077
  195. package/src/swarm-research.integration.test.ts +0 -701
  196. package/src/swarm-research.test.ts +0 -698
  197. package/src/swarm-research.ts +0 -472
  198. package/src/swarm-review.integration.test.ts +0 -285
  199. package/src/swarm-review.test.ts +0 -879
  200. package/src/swarm-review.ts +0 -709
  201. package/src/swarm-strategies.ts +0 -407
  202. package/src/swarm-worktree.test.ts +0 -501
  203. package/src/swarm-worktree.ts +0 -575
  204. package/src/swarm.integration.test.ts +0 -2377
  205. package/src/swarm.ts +0 -38
  206. package/src/tool-adapter.integration.test.ts +0 -1221
  207. package/src/tool-availability.ts +0 -461
  208. package/tsconfig.json +0 -28
@@ -1,539 +0,0 @@
1
- /**
2
- * Tests for coordinator-discipline scorers
3
- */
4
- import { describe, expect, it } from "bun:test";
5
- import type { CoordinatorSession } from "../../src/eval-capture.js";
6
- import {
7
- overallDiscipline,
8
-
9
- reviewThoroughness,
10
- spawnEfficiency,
11
- timeToFirstSpawn,
12
- violationCount,
13
- } from "./coordinator-discipline.js";
14
-
15
- describe("violationCount", () => {
16
- it("scores 1.0 for zero violations", async () => {
17
- const session: CoordinatorSession = {
18
- session_id: "test-session",
19
- epic_id: "test-epic",
20
- start_time: "2025-01-01T00:00:00Z",
21
- end_time: "2025-01-01T01:00:00Z",
22
- events: [
23
- {
24
- session_id: "test-session",
25
- epic_id: "test-epic",
26
- timestamp: "2025-01-01T00:00:00Z",
27
- event_type: "DECISION",
28
- decision_type: "strategy_selected",
29
- payload: { strategy: "file-based" },
30
- },
31
- ],
32
- };
33
-
34
- const result = await violationCount({
35
- output: JSON.stringify(session),
36
- expected: {},
37
- input: undefined,
38
- });
39
-
40
- expect(result.score).toBe(1.0);
41
- expect(result.message).toContain("0 violations");
42
- });
43
-
44
- it("decreases score by 0.2 per violation", () => {
45
- const session: CoordinatorSession = {
46
- session_id: "test-session",
47
- epic_id: "test-epic",
48
- start_time: "2025-01-01T00:00:00Z",
49
- end_time: "2025-01-01T01:00:00Z",
50
- events: [
51
- {
52
- session_id: "test-session",
53
- epic_id: "test-epic",
54
- timestamp: "2025-01-01T00:00:10Z",
55
- event_type: "VIOLATION",
56
- violation_type: "coordinator_edited_file",
57
- payload: { file: "test.ts" },
58
- },
59
- {
60
- session_id: "test-session",
61
- epic_id: "test-epic",
62
- timestamp: "2025-01-01T00:00:20Z",
63
- event_type: "VIOLATION",
64
- violation_type: "coordinator_ran_tests",
65
- payload: { command: "bun test" },
66
- },
67
- ],
68
- };
69
-
70
- const result = violationCount.scorer({
71
- output: JSON.stringify(session),
72
- expected: {},
73
- });
74
-
75
- expect(result.score).toBe(0.6); // 1.0 - 0.2 * 2
76
- expect(result.message).toContain("2 violations");
77
- });
78
-
79
- it("floors score at 0.0 for many violations", () => {
80
- const session: CoordinatorSession = {
81
- session_id: "test-session",
82
- epic_id: "test-epic",
83
- start_time: "2025-01-01T00:00:00Z",
84
- events: Array.from({ length: 10 }, (_, i) => ({
85
- session_id: "test-session",
86
- epic_id: "test-epic",
87
- timestamp: `2025-01-01T00:00:${String(i).padStart(2, "0")}Z`,
88
- event_type: "VIOLATION" as const,
89
- violation_type: "coordinator_edited_file" as const,
90
- payload: { file: `test${i}.ts` },
91
- })),
92
- };
93
-
94
- const result = violationCount.scorer({
95
- output: JSON.stringify(session),
96
- expected: {},
97
- });
98
-
99
- expect(result.score).toBe(0.0);
100
- expect(result.message).toContain("10 violations");
101
- });
102
- });
103
-
104
- describe("spawnEfficiency", () => {
105
- it("scores 1.0 when all subtasks have workers spawned", () => {
106
- const session: CoordinatorSession = {
107
- session_id: "test-session",
108
- epic_id: "test-epic",
109
- start_time: "2025-01-01T00:00:00Z",
110
- events: [
111
- {
112
- session_id: "test-session",
113
- epic_id: "test-epic",
114
- timestamp: "2025-01-01T00:00:00Z",
115
- event_type: "DECISION",
116
- decision_type: "decomposition_complete",
117
- payload: { subtask_count: 3 },
118
- },
119
- {
120
- session_id: "test-session",
121
- epic_id: "test-epic",
122
- timestamp: "2025-01-01T00:00:10Z",
123
- event_type: "DECISION",
124
- decision_type: "worker_spawned",
125
- payload: { bead_id: "bd-1" },
126
- },
127
- {
128
- session_id: "test-session",
129
- epic_id: "test-epic",
130
- timestamp: "2025-01-01T00:00:20Z",
131
- event_type: "DECISION",
132
- decision_type: "worker_spawned",
133
- payload: { bead_id: "bd-2" },
134
- },
135
- {
136
- session_id: "test-session",
137
- epic_id: "test-epic",
138
- timestamp: "2025-01-01T00:00:30Z",
139
- event_type: "DECISION",
140
- decision_type: "worker_spawned",
141
- payload: { bead_id: "bd-3" },
142
- },
143
- ],
144
- };
145
-
146
- const result = spawnEfficiency.scorer({
147
- output: JSON.stringify(session),
148
- expected: {},
149
- });
150
-
151
- expect(result.score).toBe(1.0);
152
- expect(result.message).toContain("3/3");
153
- });
154
-
155
- it("scores less than 1.0 when some workers not spawned", () => {
156
- const session: CoordinatorSession = {
157
- session_id: "test-session",
158
- epic_id: "test-epic",
159
- start_time: "2025-01-01T00:00:00Z",
160
- events: [
161
- {
162
- session_id: "test-session",
163
- epic_id: "test-epic",
164
- timestamp: "2025-01-01T00:00:00Z",
165
- event_type: "DECISION",
166
- decision_type: "decomposition_complete",
167
- payload: { subtask_count: 4 },
168
- },
169
- {
170
- session_id: "test-session",
171
- epic_id: "test-epic",
172
- timestamp: "2025-01-01T00:00:10Z",
173
- event_type: "DECISION",
174
- decision_type: "worker_spawned",
175
- payload: { bead_id: "bd-1" },
176
- },
177
- {
178
- session_id: "test-session",
179
- epic_id: "test-epic",
180
- timestamp: "2025-01-01T00:00:20Z",
181
- event_type: "DECISION",
182
- decision_type: "worker_spawned",
183
- payload: { bead_id: "bd-2" },
184
- },
185
- ],
186
- };
187
-
188
- const result = spawnEfficiency.scorer({
189
- output: JSON.stringify(session),
190
- expected: {},
191
- });
192
-
193
- expect(result.score).toBe(0.5); // 2/4
194
- expect(result.message).toContain("2/4");
195
- });
196
-
197
- it("returns 0 when no decomposition event found", () => {
198
- const session: CoordinatorSession = {
199
- session_id: "test-session",
200
- epic_id: "test-epic",
201
- start_time: "2025-01-01T00:00:00Z",
202
- events: [
203
- {
204
- session_id: "test-session",
205
- epic_id: "test-epic",
206
- timestamp: "2025-01-01T00:00:10Z",
207
- event_type: "DECISION",
208
- decision_type: "worker_spawned",
209
- payload: { bead_id: "bd-1" },
210
- },
211
- ],
212
- };
213
-
214
- const result = spawnEfficiency.scorer({
215
- output: JSON.stringify(session),
216
- expected: {},
217
- });
218
-
219
- expect(result.score).toBe(0);
220
- expect(result.message).toContain("No decomposition");
221
- });
222
- });
223
-
224
- describe("reviewThoroughness", () => {
225
- it("scores 1.0 when all workers have reviews", () => {
226
- const session: CoordinatorSession = {
227
- session_id: "test-session",
228
- epic_id: "test-epic",
229
- start_time: "2025-01-01T00:00:00Z",
230
- events: [
231
- {
232
- session_id: "test-session",
233
- epic_id: "test-epic",
234
- timestamp: "2025-01-01T00:00:00Z",
235
- event_type: "OUTCOME",
236
- outcome_type: "subtask_success",
237
- payload: { bead_id: "bd-1" },
238
- },
239
- {
240
- session_id: "test-session",
241
- epic_id: "test-epic",
242
- timestamp: "2025-01-01T00:00:10Z",
243
- event_type: "OUTCOME",
244
- outcome_type: "subtask_success",
245
- payload: { bead_id: "bd-2" },
246
- },
247
- {
248
- session_id: "test-session",
249
- epic_id: "test-epic",
250
- timestamp: "2025-01-01T00:00:20Z",
251
- event_type: "DECISION",
252
- decision_type: "review_completed",
253
- payload: { bead_id: "bd-1" },
254
- },
255
- {
256
- session_id: "test-session",
257
- epic_id: "test-epic",
258
- timestamp: "2025-01-01T00:00:30Z",
259
- event_type: "DECISION",
260
- decision_type: "review_completed",
261
- payload: { bead_id: "bd-2" },
262
- },
263
- ],
264
- };
265
-
266
- const result = reviewThoroughness.scorer({
267
- output: JSON.stringify(session),
268
- expected: {},
269
- });
270
-
271
- expect(result.score).toBe(1.0);
272
- expect(result.message).toContain("2/2");
273
- });
274
-
275
- it("scores less than 1.0 when some workers missing reviews", () => {
276
- const session: CoordinatorSession = {
277
- session_id: "test-session",
278
- epic_id: "test-epic",
279
- start_time: "2025-01-01T00:00:00Z",
280
- events: [
281
- {
282
- session_id: "test-session",
283
- epic_id: "test-epic",
284
- timestamp: "2025-01-01T00:00:00Z",
285
- event_type: "OUTCOME",
286
- outcome_type: "subtask_success",
287
- payload: { bead_id: "bd-1" },
288
- },
289
- {
290
- session_id: "test-session",
291
- epic_id: "test-epic",
292
- timestamp: "2025-01-01T00:00:10Z",
293
- event_type: "OUTCOME",
294
- outcome_type: "subtask_success",
295
- payload: { bead_id: "bd-2" },
296
- },
297
- {
298
- session_id: "test-session",
299
- epic_id: "test-epic",
300
- timestamp: "2025-01-01T00:00:20Z",
301
- event_type: "DECISION",
302
- decision_type: "review_completed",
303
- payload: { bead_id: "bd-1" },
304
- },
305
- ],
306
- };
307
-
308
- const result = reviewThoroughness.scorer({
309
- output: JSON.stringify(session),
310
- expected: {},
311
- });
312
-
313
- expect(result.score).toBe(0.5); // 1/2
314
- expect(result.message).toContain("1/2");
315
- });
316
-
317
- it("returns 1.0 when no workers finished", () => {
318
- const session: CoordinatorSession = {
319
- session_id: "test-session",
320
- epic_id: "test-epic",
321
- start_time: "2025-01-01T00:00:00Z",
322
- events: [
323
- {
324
- session_id: "test-session",
325
- epic_id: "test-epic",
326
- timestamp: "2025-01-01T00:00:00Z",
327
- event_type: "DECISION",
328
- decision_type: "strategy_selected",
329
- payload: { strategy: "file-based" },
330
- },
331
- ],
332
- };
333
-
334
- const result = reviewThoroughness.scorer({
335
- output: JSON.stringify(session),
336
- expected: {},
337
- });
338
-
339
- expect(result.score).toBe(1.0);
340
- expect(result.message).toContain("No finished workers");
341
- });
342
- });
343
-
344
- describe("timeToFirstSpawn", () => {
345
- it("normalizes time to 0-1 range (faster is better)", () => {
346
- // 30 seconds to first spawn
347
- const session: CoordinatorSession = {
348
- session_id: "test-session",
349
- epic_id: "test-epic",
350
- start_time: "2025-01-01T00:00:00Z",
351
- events: [
352
- {
353
- session_id: "test-session",
354
- epic_id: "test-epic",
355
- timestamp: "2025-01-01T00:00:00Z",
356
- event_type: "DECISION",
357
- decision_type: "decomposition_complete",
358
- payload: { subtask_count: 3 },
359
- },
360
- {
361
- session_id: "test-session",
362
- epic_id: "test-epic",
363
- timestamp: "2025-01-01T00:00:30Z",
364
- event_type: "DECISION",
365
- decision_type: "worker_spawned",
366
- payload: { bead_id: "bd-1" },
367
- },
368
- ],
369
- };
370
-
371
- const result = timeToFirstSpawn.scorer({
372
- output: JSON.stringify(session),
373
- expected: {},
374
- });
375
-
376
- // 30s should score around 0.95 (fast spawn)
377
- expect(result.score).toBeGreaterThan(0.9);
378
- expect(result.message).toContain("30000ms");
379
- });
380
-
381
- it("returns 0 when no worker spawned", () => {
382
- const session: CoordinatorSession = {
383
- session_id: "test-session",
384
- epic_id: "test-epic",
385
- start_time: "2025-01-01T00:00:00Z",
386
- events: [
387
- {
388
- session_id: "test-session",
389
- epic_id: "test-epic",
390
- timestamp: "2025-01-01T00:00:00Z",
391
- event_type: "DECISION",
392
- decision_type: "decomposition_complete",
393
- payload: { subtask_count: 3 },
394
- },
395
- ],
396
- };
397
-
398
- const result = timeToFirstSpawn.scorer({
399
- output: JSON.stringify(session),
400
- expected: {},
401
- });
402
-
403
- expect(result.score).toBe(0);
404
- expect(result.message).toContain("No worker spawned");
405
- });
406
-
407
- it("returns 0 when no decomposition event", () => {
408
- const session: CoordinatorSession = {
409
- session_id: "test-session",
410
- epic_id: "test-epic",
411
- start_time: "2025-01-01T00:00:00Z",
412
- events: [
413
- {
414
- session_id: "test-session",
415
- epic_id: "test-epic",
416
- timestamp: "2025-01-01T00:00:10Z",
417
- event_type: "DECISION",
418
- decision_type: "worker_spawned",
419
- payload: { bead_id: "bd-1" },
420
- },
421
- ],
422
- };
423
-
424
- const result = timeToFirstSpawn.scorer({
425
- output: JSON.stringify(session),
426
- expected: {},
427
- });
428
-
429
- expect(result.score).toBe(0);
430
- expect(result.message).toContain("No decomposition");
431
- });
432
- });
433
-
434
- describe("overallDiscipline", () => {
435
- it("computes weighted composite score", () => {
436
- // Perfect session
437
- const session: CoordinatorSession = {
438
- session_id: "test-session",
439
- epic_id: "test-epic",
440
- start_time: "2025-01-01T00:00:00Z",
441
- events: [
442
- {
443
- session_id: "test-session",
444
- epic_id: "test-epic",
445
- timestamp: "2025-01-01T00:00:00Z",
446
- event_type: "DECISION",
447
- decision_type: "decomposition_complete",
448
- payload: { subtask_count: 2 },
449
- },
450
- {
451
- session_id: "test-session",
452
- epic_id: "test-epic",
453
- timestamp: "2025-01-01T00:00:10Z",
454
- event_type: "DECISION",
455
- decision_type: "worker_spawned",
456
- payload: { bead_id: "bd-1" },
457
- },
458
- {
459
- session_id: "test-session",
460
- epic_id: "test-epic",
461
- timestamp: "2025-01-01T00:00:20Z",
462
- event_type: "DECISION",
463
- decision_type: "worker_spawned",
464
- payload: { bead_id: "bd-2" },
465
- },
466
- {
467
- session_id: "test-session",
468
- epic_id: "test-epic",
469
- timestamp: "2025-01-01T00:10:00Z",
470
- event_type: "OUTCOME",
471
- outcome_type: "subtask_success",
472
- payload: { bead_id: "bd-1" },
473
- },
474
- {
475
- session_id: "test-session",
476
- epic_id: "test-epic",
477
- timestamp: "2025-01-01T00:10:10Z",
478
- event_type: "OUTCOME",
479
- outcome_type: "subtask_success",
480
- payload: { bead_id: "bd-2" },
481
- },
482
- {
483
- session_id: "test-session",
484
- epic_id: "test-epic",
485
- timestamp: "2025-01-01T00:10:20Z",
486
- event_type: "DECISION",
487
- decision_type: "review_completed",
488
- payload: { bead_id: "bd-1" },
489
- },
490
- {
491
- session_id: "test-session",
492
- epic_id: "test-epic",
493
- timestamp: "2025-01-01T00:10:30Z",
494
- event_type: "DECISION",
495
- decision_type: "review_completed",
496
- payload: { bead_id: "bd-2" },
497
- },
498
- ],
499
- };
500
-
501
- const result = overallDiscipline.scorer({
502
- output: JSON.stringify(session),
503
- expected: {},
504
- });
505
-
506
- // Perfect session should score very high (close to 1.0)
507
- expect(result.score).toBeGreaterThan(0.95);
508
- expect(result.message).toContain("Overall");
509
- });
510
-
511
- it("includes breakdown in message", () => {
512
- const session: CoordinatorSession = {
513
- session_id: "test-session",
514
- epic_id: "test-epic",
515
- start_time: "2025-01-01T00:00:00Z",
516
- events: [
517
- {
518
- session_id: "test-session",
519
- epic_id: "test-epic",
520
- timestamp: "2025-01-01T00:00:00Z",
521
- event_type: "DECISION",
522
- decision_type: "strategy_selected",
523
- payload: { strategy: "file-based" },
524
- },
525
- ],
526
- };
527
-
528
- const result = overallDiscipline.scorer({
529
- output: JSON.stringify(session),
530
- expected: {},
531
- });
532
-
533
- expect(result.message).toContain("Violations:");
534
- expect(result.message).toContain("Spawn:");
535
- expect(result.message).toContain("Review:");
536
- expect(result.message).toContain("Speed:");
537
- });
538
- });
539
-