opencastle 1.3.1 → 1.4.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.
- package/README.md +16 -10
- package/bin/cli.mjs +8 -9
- package/dist/cli/agent-roster.test.js +0 -48
- package/dist/cli/agent-roster.test.js.map +1 -1
- package/dist/cli/boundary.test.js +9 -7
- package/dist/cli/boundary.test.js.map +1 -1
- package/dist/cli/convoy/artifacts.d.ts +9 -2
- package/dist/cli/convoy/artifacts.d.ts.map +1 -1
- package/dist/cli/convoy/artifacts.js +13 -10
- package/dist/cli/convoy/artifacts.js.map +1 -1
- package/dist/cli/convoy/artifacts.test.js +4 -2
- package/dist/cli/convoy/artifacts.test.js.map +1 -1
- package/dist/cli/convoy/engine.d.ts +53 -23
- package/dist/cli/convoy/engine.d.ts.map +1 -1
- package/dist/cli/convoy/engine.git.test.d.ts +2 -0
- package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
- package/dist/cli/convoy/engine.git.test.js +435 -0
- package/dist/cli/convoy/engine.git.test.js.map +1 -0
- package/dist/cli/convoy/engine.js +1746 -2305
- package/dist/cli/convoy/engine.js.map +1 -1
- package/dist/cli/convoy/engine.test.js +698 -678
- package/dist/cli/convoy/engine.test.js.map +1 -1
- package/dist/cli/convoy/event-schemas.d.ts +2 -0
- package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
- package/dist/cli/convoy/event-schemas.js +59 -57
- package/dist/cli/convoy/event-schemas.js.map +1 -1
- package/dist/cli/convoy/events.d.ts +4 -1
- package/dist/cli/convoy/events.d.ts.map +1 -1
- package/dist/cli/convoy/events.js +69 -84
- package/dist/cli/convoy/events.js.map +1 -1
- package/dist/cli/convoy/events.test.js +50 -9
- package/dist/cli/convoy/events.test.js.map +1 -1
- package/dist/cli/convoy/gates.d.ts +9 -4
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +29 -14
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/convoy/isolation.d.ts +32 -6
- package/dist/cli/convoy/isolation.d.ts.map +1 -1
- package/dist/cli/convoy/isolation.js +72 -34
- package/dist/cli/convoy/isolation.js.map +1 -1
- package/dist/cli/convoy/isolation.test.js +66 -42
- package/dist/cli/convoy/isolation.test.js.map +1 -1
- package/dist/cli/convoy/lock.d.ts.map +1 -1
- package/dist/cli/convoy/lock.js +25 -10
- package/dist/cli/convoy/lock.js.map +1 -1
- package/dist/cli/convoy/lock.test.js +12 -0
- package/dist/cli/convoy/lock.test.js.map +1 -1
- package/dist/cli/convoy/merge.d.ts +21 -4
- package/dist/cli/convoy/merge.d.ts.map +1 -1
- package/dist/cli/convoy/merge.js +69 -53
- package/dist/cli/convoy/merge.js.map +1 -1
- package/dist/cli/convoy/merge.test.js +23 -1
- package/dist/cli/convoy/merge.test.js.map +1 -1
- package/dist/cli/convoy/progress.d.ts +35 -0
- package/dist/cli/convoy/progress.d.ts.map +1 -0
- package/dist/cli/convoy/progress.js +103 -0
- package/dist/cli/convoy/progress.js.map +1 -0
- package/dist/cli/convoy/progress.test.d.ts +2 -0
- package/dist/cli/convoy/progress.test.d.ts.map +1 -0
- package/dist/cli/convoy/progress.test.js +53 -0
- package/dist/cli/convoy/progress.test.js.map +1 -0
- package/dist/cli/convoy/read-model.d.ts +468 -0
- package/dist/cli/convoy/read-model.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.js +1132 -0
- package/dist/cli/convoy/read-model.js.map +1 -0
- package/dist/cli/convoy/read-model.test.d.ts +2 -0
- package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.test.js +609 -0
- package/dist/cli/convoy/read-model.test.js.map +1 -0
- package/dist/cli/convoy/redact.d.ts +34 -0
- package/dist/cli/convoy/redact.d.ts.map +1 -0
- package/dist/cli/convoy/redact.js +66 -0
- package/dist/cli/convoy/redact.js.map +1 -0
- package/dist/cli/convoy/redact.test.d.ts +2 -0
- package/dist/cli/convoy/redact.test.d.ts.map +1 -0
- package/dist/cli/convoy/redact.test.js +43 -0
- package/dist/cli/convoy/redact.test.js.map +1 -0
- package/dist/cli/convoy/reviewer.d.ts +65 -0
- package/dist/cli/convoy/reviewer.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.js +141 -0
- package/dist/cli/convoy/reviewer.js.map +1 -0
- package/dist/cli/convoy/reviewer.test.d.ts +2 -0
- package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.test.js +96 -0
- package/dist/cli/convoy/reviewer.test.js.map +1 -0
- package/dist/cli/convoy/schedule.d.ts +30 -0
- package/dist/cli/convoy/schedule.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.js +111 -0
- package/dist/cli/convoy/schedule.js.map +1 -0
- package/dist/cli/convoy/schedule.test.d.ts +2 -0
- package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.test.js +45 -0
- package/dist/cli/convoy/schedule.test.js.map +1 -0
- package/dist/cli/convoy/spec-builder.d.ts +120 -30
- package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
- package/dist/cli/convoy/spec-builder.js +438 -114
- package/dist/cli/convoy/spec-builder.js.map +1 -1
- package/dist/cli/convoy/spec-builder.test.js +419 -435
- package/dist/cli/convoy/spec-builder.test.js.map +1 -1
- package/dist/cli/convoy/spec-types.d.ts +46 -92
- package/dist/cli/convoy/spec-types.d.ts.map +1 -1
- package/dist/cli/convoy/store.d.ts +6 -1
- package/dist/cli/convoy/store.d.ts.map +1 -1
- package/dist/cli/convoy/store.js +111 -15
- package/dist/cli/convoy/store.js.map +1 -1
- package/dist/cli/convoy/store.test.js +59 -13
- package/dist/cli/convoy/store.test.js.map +1 -1
- package/dist/cli/convoy/types.d.ts +76 -113
- package/dist/cli/convoy/types.d.ts.map +1 -1
- package/dist/cli/convoy/types.js +6 -13
- package/dist/cli/convoy/types.js.map +1 -1
- package/dist/cli/convoy/worktree.d.ts +88 -3
- package/dist/cli/convoy/worktree.d.ts.map +1 -1
- package/dist/cli/convoy/worktree.js +282 -56
- package/dist/cli/convoy/worktree.js.map +1 -1
- package/dist/cli/convoy/worktree.test.js +132 -1
- package/dist/cli/convoy/worktree.test.js.map +1 -1
- package/dist/cli/convoy-args.test.js +9 -27
- package/dist/cli/convoy-args.test.js.map +1 -1
- package/dist/cli/convoy-cmd.d.ts +31 -6
- package/dist/cli/convoy-cmd.d.ts.map +1 -1
- package/dist/cli/convoy-cmd.js +150 -201
- package/dist/cli/convoy-cmd.js.map +1 -1
- package/dist/cli/convoy-cmd.test.d.ts +2 -0
- package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
- package/dist/cli/convoy-cmd.test.js +144 -0
- package/dist/cli/convoy-cmd.test.js.map +1 -0
- package/dist/cli/dashboard.d.ts +24 -11
- package/dist/cli/dashboard.d.ts.map +1 -1
- package/dist/cli/dashboard.js +241 -303
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/dashboard.test.d.ts +2 -0
- package/dist/cli/dashboard.test.d.ts.map +1 -0
- package/dist/cli/dashboard.test.js +340 -0
- package/dist/cli/dashboard.test.js.map +1 -0
- package/dist/cli/dispatcher.test.js +35 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +3 -3
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/log.d.ts +39 -0
- package/dist/cli/log.d.ts.map +1 -1
- package/dist/cli/log.js +267 -93
- package/dist/cli/log.js.map +1 -1
- package/dist/cli/log.test.d.ts +2 -0
- package/dist/cli/log.test.d.ts.map +1 -0
- package/dist/cli/log.test.js +208 -0
- package/dist/cli/log.test.js.map +1 -0
- package/dist/cli/nearest.d.ts +18 -0
- package/dist/cli/nearest.d.ts.map +1 -0
- package/dist/cli/nearest.js +38 -0
- package/dist/cli/nearest.js.map +1 -0
- package/dist/cli/nearest.test.d.ts +2 -0
- package/dist/cli/nearest.test.d.ts.map +1 -0
- package/dist/cli/nearest.test.js +24 -0
- package/dist/cli/nearest.test.js.map +1 -0
- package/dist/cli/pipeline.d.ts +61 -0
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.flow.test.d.ts +2 -0
- package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
- package/dist/cli/pipeline.flow.test.js +524 -0
- package/dist/cli/pipeline.flow.test.js.map +1 -0
- package/dist/cli/pipeline.js +471 -690
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/plan.d.ts +82 -31
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +167 -507
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/plan.test.d.ts +2 -0
- package/dist/cli/plan.test.d.ts.map +1 -0
- package/dist/cli/plan.test.js +158 -0
- package/dist/cli/plan.test.js.map +1 -0
- package/dist/cli/run/adapters/agent-process.d.ts +82 -0
- package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.js +224 -0
- package/dist/cli/run/adapters/agent-process.js.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.js +159 -0
- package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
- package/dist/cli/run/adapters/claude.d.ts +53 -2
- package/dist/cli/run/adapters/claude.d.ts.map +1 -1
- package/dist/cli/run/adapters/claude.js +147 -171
- package/dist/cli/run/adapters/claude.js.map +1 -1
- package/dist/cli/run/adapters/claude.test.js +197 -254
- package/dist/cli/run/adapters/claude.test.js.map +1 -1
- package/dist/cli/run/adapters/codex.d.ts +25 -2
- package/dist/cli/run/adapters/codex.d.ts.map +1 -1
- package/dist/cli/run/adapters/codex.js +113 -81
- package/dist/cli/run/adapters/codex.js.map +1 -1
- package/dist/cli/run/adapters/codex.test.js +116 -95
- package/dist/cli/run/adapters/codex.test.js.map +1 -1
- package/dist/cli/run/adapters/copilot.d.ts +35 -1
- package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
- package/dist/cli/run/adapters/copilot.js +104 -287
- package/dist/cli/run/adapters/copilot.js.map +1 -1
- package/dist/cli/run/adapters/copilot.test.js +122 -282
- package/dist/cli/run/adapters/copilot.test.js.map +1 -1
- package/dist/cli/run/adapters/cursor.d.ts +25 -7
- package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/run/adapters/cursor.js +103 -156
- package/dist/cli/run/adapters/cursor.js.map +1 -1
- package/dist/cli/run/adapters/cursor.test.js +106 -218
- package/dist/cli/run/adapters/cursor.test.js.map +1 -1
- package/dist/cli/run/adapters/index.d.ts +34 -5
- package/dist/cli/run/adapters/index.d.ts.map +1 -1
- package/dist/cli/run/adapters/index.js +147 -21
- package/dist/cli/run/adapters/index.js.map +1 -1
- package/dist/cli/run/adapters/index.test.d.ts +2 -0
- package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/index.test.js +129 -0
- package/dist/cli/run/adapters/index.test.js.map +1 -0
- package/dist/cli/run/adapters/opencode.d.ts +25 -9
- package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/run/adapters/opencode.js +136 -152
- package/dist/cli/run/adapters/opencode.js.map +1 -1
- package/dist/cli/run/adapters/opencode.test.js +99 -218
- package/dist/cli/run/adapters/opencode.test.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
- package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
- package/dist/cli/run/adapters/permission-modes.js +113 -37
- package/dist/cli/run/adapters/permission-modes.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.test.js +55 -40
- package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
- package/dist/cli/run/platform.d.ts +52 -0
- package/dist/cli/run/platform.d.ts.map +1 -0
- package/dist/cli/run/platform.js +207 -0
- package/dist/cli/run/platform.js.map +1 -0
- package/dist/cli/run/platform.test.d.ts +2 -0
- package/dist/cli/run/platform.test.d.ts.map +1 -0
- package/dist/cli/run/platform.test.js +119 -0
- package/dist/cli/run/platform.test.js.map +1 -0
- package/dist/cli/run/schema.d.ts +6 -8
- package/dist/cli/run/schema.d.ts.map +1 -1
- package/dist/cli/run/schema.js +44 -68
- package/dist/cli/run/schema.js.map +1 -1
- package/dist/cli/run/schema.test.js +59 -279
- package/dist/cli/run/schema.test.js.map +1 -1
- package/dist/cli/run.d.ts +34 -56
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +379 -1132
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/run.test.d.ts +2 -0
- package/dist/cli/run.test.d.ts.map +1 -0
- package/dist/cli/run.test.js +318 -0
- package/dist/cli/run.test.js.map +1 -0
- package/dist/cli/team-config.d.ts.map +1 -1
- package/dist/cli/team-config.js +2 -21
- package/dist/cli/team-config.js.map +1 -1
- package/dist/cli/tiers.test.js +4 -13
- package/dist/cli/tiers.test.js.map +1 -1
- package/package.json +3 -10
- package/src/cli/agent-roster.test.ts +0 -55
- package/src/cli/boundary.test.ts +9 -7
- package/src/cli/convoy/TELEMETRY.md +131 -125
- package/src/cli/convoy/artifacts.test.ts +4 -2
- package/src/cli/convoy/artifacts.ts +13 -12
- package/src/cli/convoy/engine.git.test.ts +462 -0
- package/src/cli/convoy/engine.test.ts +817 -850
- package/src/cli/convoy/engine.ts +1864 -2596
- package/src/cli/convoy/event-schemas.ts +63 -59
- package/src/cli/convoy/events.test.ts +58 -9
- package/src/cli/convoy/events.ts +69 -91
- package/src/cli/convoy/gates.ts +31 -12
- package/src/cli/convoy/isolation.test.ts +76 -43
- package/src/cli/convoy/isolation.ts +100 -38
- package/src/cli/convoy/lock.test.ts +16 -0
- package/src/cli/convoy/lock.ts +25 -8
- package/src/cli/convoy/merge.test.ts +25 -1
- package/src/cli/convoy/merge.ts +74 -61
- package/src/cli/convoy/progress.test.ts +59 -0
- package/src/cli/convoy/progress.ts +121 -0
- package/src/cli/convoy/read-model.test.ts +685 -0
- package/src/cli/convoy/read-model.ts +1469 -0
- package/src/cli/convoy/redact.test.ts +49 -0
- package/src/cli/convoy/redact.ts +73 -0
- package/src/cli/convoy/reviewer.test.ts +112 -0
- package/src/cli/convoy/reviewer.ts +196 -0
- package/src/cli/convoy/schedule.test.ts +56 -0
- package/src/cli/convoy/schedule.ts +109 -0
- package/src/cli/convoy/spec-builder.test.ts +460 -464
- package/src/cli/convoy/spec-builder.ts +460 -129
- package/src/cli/convoy/spec-types.ts +46 -108
- package/src/cli/convoy/store.test.ts +64 -13
- package/src/cli/convoy/store.ts +143 -33
- package/src/cli/convoy/types.ts +59 -71
- package/src/cli/convoy/worktree.test.ts +140 -1
- package/src/cli/convoy/worktree.ts +311 -61
- package/src/cli/convoy-args.test.ts +10 -30
- package/src/cli/convoy-cmd.test.ts +163 -0
- package/src/cli/convoy-cmd.ts +173 -216
- package/src/cli/dashboard/dashboard.css +2086 -0
- package/src/cli/dashboard/dashboard.js +1687 -0
- package/src/cli/dashboard/index.html +307 -0
- package/src/cli/dashboard.test.ts +382 -0
- package/src/cli/dashboard.ts +243 -339
- package/src/cli/dispatcher.test.ts +36 -2
- package/src/cli/docs-accuracy.test.ts +3 -3
- package/src/cli/log.test.ts +228 -0
- package/src/cli/log.ts +302 -83
- package/src/cli/nearest.test.ts +27 -0
- package/src/cli/nearest.ts +38 -0
- package/src/cli/pipeline.flow.test.ts +607 -0
- package/src/cli/pipeline.ts +544 -759
- package/src/cli/plan.test.ts +193 -0
- package/src/cli/plan.ts +209 -545
- package/src/cli/run/adapters/agent-process.test.ts +175 -0
- package/src/cli/run/adapters/agent-process.ts +252 -0
- package/src/cli/run/adapters/claude.test.ts +205 -260
- package/src/cli/run/adapters/claude.ts +151 -162
- package/src/cli/run/adapters/codex.test.ts +120 -100
- package/src/cli/run/adapters/codex.ts +115 -91
- package/src/cli/run/adapters/copilot.test.ts +135 -306
- package/src/cli/run/adapters/copilot.ts +105 -274
- package/src/cli/run/adapters/cursor.test.ts +111 -220
- package/src/cli/run/adapters/cursor.ts +105 -156
- package/src/cli/run/adapters/index.test.ts +148 -0
- package/src/cli/run/adapters/index.ts +168 -20
- package/src/cli/run/adapters/opencode.test.ts +106 -227
- package/src/cli/run/adapters/opencode.ts +139 -151
- package/src/cli/run/adapters/permission-modes.test.ts +63 -41
- package/src/cli/run/adapters/permission-modes.ts +118 -37
- package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
- package/src/cli/run/platform.test.ts +128 -0
- package/src/cli/run/platform.ts +213 -0
- package/src/cli/run/schema.test.ts +62 -344
- package/src/cli/run/schema.ts +48 -78
- package/src/cli/run.test.ts +351 -0
- package/src/cli/run.ts +366 -1151
- package/src/cli/team-config.ts +2 -21
- package/src/cli/tiers.test.ts +4 -17
- package/src/orchestrator/agents/team-lead.agent.md +1 -1
- package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
- package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
- package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
- package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
- package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
- package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
- package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
- package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
- package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
- package/dist/cli/convoy/dag-analysis.d.ts +0 -39
- package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.js +0 -279
- package/dist/cli/convoy/dag-analysis.js.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
- package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.js +0 -289
- package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
- package/dist/cli/convoy/formula.d.ts +0 -19
- package/dist/cli/convoy/formula.d.ts.map +0 -1
- package/dist/cli/convoy/formula.js +0 -142
- package/dist/cli/convoy/formula.js.map +0 -1
- package/dist/cli/convoy/formula.test.d.ts +0 -2
- package/dist/cli/convoy/formula.test.d.ts.map +0 -1
- package/dist/cli/convoy/formula.test.js +0 -342
- package/dist/cli/convoy/formula.test.js.map +0 -1
- package/dist/cli/convoy/health.d.ts +0 -34
- package/dist/cli/convoy/health.d.ts.map +0 -1
- package/dist/cli/convoy/health.js +0 -123
- package/dist/cli/convoy/health.js.map +0 -1
- package/dist/cli/convoy/health.test.d.ts +0 -2
- package/dist/cli/convoy/health.test.d.ts.map +0 -1
- package/dist/cli/convoy/health.test.js +0 -448
- package/dist/cli/convoy/health.test.js.map +0 -1
- package/dist/cli/convoy/last-run.d.ts +0 -53
- package/dist/cli/convoy/last-run.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.js +0 -54
- package/dist/cli/convoy/last-run.js.map +0 -1
- package/dist/cli/convoy/last-run.test.d.ts +0 -2
- package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.test.js +0 -110
- package/dist/cli/convoy/last-run.test.js.map +0 -1
- package/dist/cli/convoy/pipeline.d.ts +0 -41
- package/dist/cli/convoy/pipeline.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.js +0 -414
- package/dist/cli/convoy/pipeline.js.map +0 -1
- package/dist/cli/convoy/pipeline.test.d.ts +0 -2
- package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.test.js +0 -837
- package/dist/cli/convoy/pipeline.test.js.map +0 -1
- package/dist/cli/convoy/review-stages.d.ts +0 -9
- package/dist/cli/convoy/review-stages.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.js +0 -134
- package/dist/cli/convoy/review-stages.js.map +0 -1
- package/dist/cli/convoy/review-stages.test.d.ts +0 -2
- package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.test.js +0 -197
- package/dist/cli/convoy/review-stages.test.js.map +0 -1
- package/dist/cli/run/executor.d.ts +0 -15
- package/dist/cli/run/executor.d.ts.map +0 -1
- package/dist/cli/run/executor.js +0 -249
- package/dist/cli/run/executor.js.map +0 -1
- package/dist/cli/run/executor.test.d.ts +0 -2
- package/dist/cli/run/executor.test.d.ts.map +0 -1
- package/dist/cli/run/executor.test.js +0 -297
- package/dist/cli/run/executor.test.js.map +0 -1
- package/dist/cli/run/reporter.d.ts +0 -10
- package/dist/cli/run/reporter.d.ts.map +0 -1
- package/dist/cli/run/reporter.js +0 -142
- package/dist/cli/run/reporter.js.map +0 -1
- package/dist/cli/run-dry-run.test.d.ts +0 -2
- package/dist/cli/run-dry-run.test.d.ts.map +0 -1
- package/dist/cli/run-dry-run.test.js +0 -83
- package/dist/cli/run-dry-run.test.js.map +0 -1
- package/dist/cli/run-executor-flags.test.d.ts +0 -2
- package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
- package/dist/cli/run-executor-flags.test.js +0 -31
- package/dist/cli/run-executor-flags.test.js.map +0 -1
- package/dist/cli/run-finish.test.d.ts +0 -2
- package/dist/cli/run-finish.test.d.ts.map +0 -1
- package/dist/cli/run-finish.test.js +0 -77
- package/dist/cli/run-finish.test.js.map +0 -1
- package/dist/cli/watch.d.ts +0 -15
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js +0 -277
- package/dist/cli/watch.js.map +0 -1
- package/dist/dashboard/scripts/etl.d.ts +0 -10
- package/dist/dashboard/scripts/etl.d.ts.map +0 -1
- package/dist/dashboard/scripts/etl.js +0 -141
- package/dist/dashboard/scripts/etl.js.map +0 -1
- package/src/cli/convoy/dag-analysis.test.ts +0 -349
- package/src/cli/convoy/dag-analysis.ts +0 -367
- package/src/cli/convoy/formula.test.ts +0 -404
- package/src/cli/convoy/formula.ts +0 -174
- package/src/cli/convoy/health.test.ts +0 -519
- package/src/cli/convoy/health.ts +0 -189
- package/src/cli/convoy/last-run.test.ts +0 -130
- package/src/cli/convoy/last-run.ts +0 -87
- package/src/cli/convoy/pipeline.test.ts +0 -999
- package/src/cli/convoy/pipeline.ts +0 -492
- package/src/cli/convoy/review-stages.test.ts +0 -235
- package/src/cli/convoy/review-stages.ts +0 -166
- package/src/cli/run/executor.test.ts +0 -338
- package/src/cli/run/executor.ts +0 -292
- package/src/cli/run/reporter.ts +0 -160
- package/src/cli/run-dry-run.test.ts +0 -97
- package/src/cli/run-executor-flags.test.ts +0 -38
- package/src/cli/run-finish.test.ts +0 -91
- package/src/cli/watch.ts +0 -295
- package/src/dashboard/astro.config.mjs +0 -6
- package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
- package/src/dashboard/dist/data/.gitkeep +0 -0
- package/src/dashboard/dist/data/convoy-list.json +0 -1
- package/src/dashboard/dist/data/overall-stats.json +0 -29
- package/src/dashboard/dist/index.html +0 -1963
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
- package/src/dashboard/package-lock.json +0 -6
- package/src/dashboard/public/data/.gitkeep +0 -0
- package/src/dashboard/public/data/convoy-list.json +0 -1
- package/src/dashboard/public/data/overall-stats.json +0 -29
- package/src/dashboard/public/icon-192.png +0 -0
- package/src/dashboard/scripts/etl.test.ts +0 -166
- package/src/dashboard/scripts/etl.ts +0 -170
- package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
- package/src/dashboard/scripts/generate-demo-db.ts +0 -529
- package/src/dashboard/scripts/integration-test.ts +0 -504
- package/src/dashboard/scripts/verify-demo-data.sh +0 -51
- package/src/dashboard/seed-data/delegations.ndjson +0 -35
- package/src/dashboard/seed-data/events.ndjson +0 -104
- package/src/dashboard/seed-data/panels.ndjson +0 -13
- package/src/dashboard/seed-data/reviews.ndjson +0 -6
- package/src/dashboard/seed-data/sessions.ndjson +0 -50
- package/src/dashboard/src/env.d.ts +0 -1
- package/src/dashboard/src/layouts/Layout.astro +0 -25
- package/src/dashboard/src/pages/index.astro +0 -2313
- package/src/dashboard/src/styles/dashboard.css +0 -2943
- package/src/dashboard/tsconfig.json +0 -6
- /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, rmSync } from 'node:fs'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
5
|
-
import { createConvoyStore } from './store.js'
|
|
6
|
-
import type { ConvoyStore } from './store.js'
|
|
7
|
-
import type { ConvoyEventEmitter } from './events.js'
|
|
8
|
-
import { createHealthMonitor, detectDrift } from './health.js'
|
|
9
|
-
import type { HealthMonitorOptions } from './health.js'
|
|
10
|
-
import type { AgentAdapter } from './spec-types.js'
|
|
11
|
-
|
|
12
|
-
// ── fixtures ──────────────────────────────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
const CONVOY_ID = 'convoy-1'
|
|
15
|
-
|
|
16
|
-
type EmittedEvent = {
|
|
17
|
-
type: string
|
|
18
|
-
data?: Record<string, unknown>
|
|
19
|
-
ids?: { convoy_id?: string; task_id?: string; worker_id?: string }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let tmpDir: string
|
|
23
|
-
let dbPath: string
|
|
24
|
-
let store: ConvoyStore
|
|
25
|
-
let emittedEvents: EmittedEvent[]
|
|
26
|
-
let mockEvents: ConvoyEventEmitter
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
tmpDir = mkdtempSync(join(tmpdir(), 'health-test-'))
|
|
30
|
-
dbPath = join(tmpDir, 'test.db')
|
|
31
|
-
store = createConvoyStore(dbPath)
|
|
32
|
-
emittedEvents = []
|
|
33
|
-
mockEvents = {
|
|
34
|
-
emit(type, data, ids) {
|
|
35
|
-
emittedEvents.push({ type, data, ids })
|
|
36
|
-
},
|
|
37
|
-
close() {},
|
|
38
|
-
}
|
|
39
|
-
store.insertConvoy({
|
|
40
|
-
id: CONVOY_ID,
|
|
41
|
-
name: 'Test Convoy',
|
|
42
|
-
spec_hash: 'abc123',
|
|
43
|
-
status: 'running',
|
|
44
|
-
branch: null,
|
|
45
|
-
created_at: new Date().toISOString(),
|
|
46
|
-
spec_yaml: 'name: test',
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
afterEach(() => {
|
|
51
|
-
store.close()
|
|
52
|
-
rmSync(tmpDir, { recursive: true, force: true })
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
function makeOptions(overrides: Partial<HealthMonitorOptions> = {}): HealthMonitorOptions {
|
|
56
|
-
return { store, events: mockEvents, convoyId: CONVOY_ID, ...overrides }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function makeTask(
|
|
60
|
-
overrides: Partial<Parameters<ConvoyStore['insertTask']>[0]> = {},
|
|
61
|
-
): Parameters<ConvoyStore['insertTask']>[0] {
|
|
62
|
-
return {
|
|
63
|
-
id: 'task-1',
|
|
64
|
-
convoy_id: CONVOY_ID,
|
|
65
|
-
phase: 0,
|
|
66
|
-
prompt: 'Do something',
|
|
67
|
-
agent: 'developer',
|
|
68
|
-
adapter: null,
|
|
69
|
-
model: null,
|
|
70
|
-
timeout_ms: 60_000,
|
|
71
|
-
status: 'running' as const,
|
|
72
|
-
retries: 0,
|
|
73
|
-
max_retries: 1,
|
|
74
|
-
files: null,
|
|
75
|
-
depends_on: null,
|
|
76
|
-
gates: null as string | null,
|
|
77
|
-
...overrides,
|
|
78
|
-
} as Parameters<ConvoyStore['insertTask']>[0]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function makeWorker(
|
|
82
|
-
overrides: Partial<Parameters<ConvoyStore['insertWorker']>[0]> = {},
|
|
83
|
-
): Parameters<ConvoyStore['insertWorker']>[0] {
|
|
84
|
-
return {
|
|
85
|
-
id: 'worker-1',
|
|
86
|
-
task_id: 'task-1',
|
|
87
|
-
adapter: 'copilot',
|
|
88
|
-
pid: null,
|
|
89
|
-
session_id: null,
|
|
90
|
-
status: 'running' as const,
|
|
91
|
-
worktree: null,
|
|
92
|
-
created_at: new Date().toISOString(),
|
|
93
|
-
...overrides,
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Insert a running task linked to a worker. */
|
|
98
|
-
function setupRunning(
|
|
99
|
-
taskOverrides: Partial<Parameters<ConvoyStore['insertTask']>[0]> = {},
|
|
100
|
-
workerOverrides: Partial<Parameters<ConvoyStore['insertWorker']>[0]> = {},
|
|
101
|
-
) {
|
|
102
|
-
store.insertTask(makeTask(taskOverrides))
|
|
103
|
-
store.insertWorker(makeWorker(workerOverrides))
|
|
104
|
-
store.updateTaskStatus('task-1', CONVOY_ID, 'running', { worker_id: 'worker-1' })
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** ISO timestamp `msAgo` milliseconds in the past. */
|
|
108
|
-
function msBefore(msAgo: number): string {
|
|
109
|
-
return new Date(Date.now() - msAgo).toISOString()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ── creation ──────────────────────────────────────────────────────────────────
|
|
113
|
-
|
|
114
|
-
describe('createHealthMonitor', () => {
|
|
115
|
-
it('returns an object with start, stop, and check methods', () => {
|
|
116
|
-
const monitor = createHealthMonitor(makeOptions())
|
|
117
|
-
expect(typeof monitor.start).toBe('function')
|
|
118
|
-
expect(typeof monitor.stop).toBe('function')
|
|
119
|
-
expect(typeof monitor.check).toBe('function')
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
it('accepts custom intervalMs and stuckFactor without error', () => {
|
|
123
|
-
expect(() =>
|
|
124
|
-
createHealthMonitor(makeOptions({ intervalMs: 5_000, stuckFactor: 3 })),
|
|
125
|
-
).not.toThrow()
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('accepts an onKill callback', () => {
|
|
129
|
-
expect(() => createHealthMonitor(makeOptions({ onKill: () => {} }))).not.toThrow()
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
// ── start/stop lifecycle ──────────────────────────────────────────────────────
|
|
134
|
-
|
|
135
|
-
describe('start/stop lifecycle', () => {
|
|
136
|
-
it('start() does not throw', () => {
|
|
137
|
-
const monitor = createHealthMonitor(makeOptions())
|
|
138
|
-
expect(() => monitor.start()).not.toThrow()
|
|
139
|
-
monitor.stop()
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
it('stop() after start() does not throw', () => {
|
|
143
|
-
const monitor = createHealthMonitor(makeOptions())
|
|
144
|
-
monitor.start()
|
|
145
|
-
expect(() => monitor.stop()).not.toThrow()
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('stop() without start() does not throw (idempotent)', () => {
|
|
149
|
-
const monitor = createHealthMonitor(makeOptions())
|
|
150
|
-
expect(() => monitor.stop()).not.toThrow()
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
it('calling start() twice does not create duplicate intervals', () => {
|
|
154
|
-
vi.useFakeTimers()
|
|
155
|
-
try {
|
|
156
|
-
setupRunning()
|
|
157
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: new Date().toISOString() })
|
|
158
|
-
const monitor = createHealthMonitor(makeOptions({ intervalMs: 1_000 }))
|
|
159
|
-
monitor.start()
|
|
160
|
-
monitor.start() // second call is no-op
|
|
161
|
-
vi.advanceTimersByTime(1_000)
|
|
162
|
-
// Only one interval fires; fresh heartbeat → zero events
|
|
163
|
-
expect(emittedEvents).toHaveLength(0)
|
|
164
|
-
monitor.stop()
|
|
165
|
-
} finally {
|
|
166
|
-
vi.useRealTimers()
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('check() is invoked on each timer tick after start()', () => {
|
|
171
|
-
vi.useFakeTimers()
|
|
172
|
-
try {
|
|
173
|
-
setupRunning({ timeout_ms: 60_000, max_retries: 5 })
|
|
174
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
175
|
-
const monitor = createHealthMonitor(makeOptions({ intervalMs: 1_000, stuckFactor: 2 }))
|
|
176
|
-
monitor.start()
|
|
177
|
-
vi.advanceTimersByTime(1_000)
|
|
178
|
-
expect(store.getTask('task-1', CONVOY_ID)!.status).toBe('pending')
|
|
179
|
-
monitor.stop()
|
|
180
|
-
} finally {
|
|
181
|
-
vi.useRealTimers()
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
// ── check() no-op cases ───────────────────────────────────────────────────────
|
|
187
|
-
|
|
188
|
-
describe('check() no-op cases', () => {
|
|
189
|
-
it('does nothing when no tasks exist for the convoy', () => {
|
|
190
|
-
createHealthMonitor(makeOptions()).check()
|
|
191
|
-
expect(emittedEvents).toHaveLength(0)
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
it('does nothing when all tasks are pending', () => {
|
|
195
|
-
store.insertTask(makeTask({ status: 'pending' }))
|
|
196
|
-
createHealthMonitor(makeOptions()).check()
|
|
197
|
-
expect(emittedEvents).toHaveLength(0)
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('does nothing when all tasks are done', () => {
|
|
201
|
-
store.insertTask(makeTask({ status: 'done' }))
|
|
202
|
-
createHealthMonitor(makeOptions()).check()
|
|
203
|
-
expect(emittedEvents).toHaveLength(0)
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
it('does nothing when all tasks are failed', () => {
|
|
207
|
-
store.insertTask(makeTask({ status: 'failed' }))
|
|
208
|
-
createHealthMonitor(makeOptions()).check()
|
|
209
|
-
expect(emittedEvents).toHaveLength(0)
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
it('does nothing for a running task with no worker_id', () => {
|
|
213
|
-
store.insertTask(makeTask()) // worker_id stays NULL (insertTask always sets NULL)
|
|
214
|
-
createHealthMonitor(makeOptions()).check()
|
|
215
|
-
expect(emittedEvents).toHaveLength(0)
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
it('does nothing for a running task when the worker record is not found', () => {
|
|
219
|
-
store.insertTask(makeTask())
|
|
220
|
-
store.updateTaskStatus('task-1', CONVOY_ID, 'running', { worker_id: 'ghost-worker' })
|
|
221
|
-
createHealthMonitor(makeOptions()).check()
|
|
222
|
-
expect(emittedEvents).toHaveLength(0)
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
it('does nothing for a running task with fresh heartbeat and no pid', () => {
|
|
226
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
227
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: new Date().toISOString() })
|
|
228
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
229
|
-
expect(emittedEvents).toHaveLength(0)
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
it('does nothing for a running task with no heartbeat and no pid', () => {
|
|
233
|
-
setupRunning() // no heartbeat set, no pid → neither check fires
|
|
234
|
-
createHealthMonitor(makeOptions()).check()
|
|
235
|
-
expect(emittedEvents).toHaveLength(0)
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
// ── stuck detection ───────────────────────────────────────────────────────────
|
|
240
|
-
|
|
241
|
-
describe('stuck detection', () => {
|
|
242
|
-
function setupStuck(
|
|
243
|
-
taskOverrides: Partial<Parameters<ConvoyStore['insertTask']>[0]> = {},
|
|
244
|
-
) {
|
|
245
|
-
setupRunning({ timeout_ms: 60_000, ...taskOverrides })
|
|
246
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
it('resets task to pending and increments retries when retries < max_retries', () => {
|
|
250
|
-
setupStuck({ retries: 0, max_retries: 1 })
|
|
251
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
252
|
-
const task = store.getTask('task-1', CONVOY_ID)!
|
|
253
|
-
expect(task.status).toBe('pending')
|
|
254
|
-
expect(task.retries).toBe(1)
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
it('marks worker as killed with a finished_at timestamp', () => {
|
|
258
|
-
setupStuck()
|
|
259
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
260
|
-
const worker = store.getWorker('worker-1')!
|
|
261
|
-
expect(worker.status).toBe('killed')
|
|
262
|
-
expect(worker.finished_at).not.toBeNull()
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
it('marks task as failed when retries >= max_retries', () => {
|
|
266
|
-
setupStuck({ retries: 1, max_retries: 1 })
|
|
267
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
268
|
-
expect(store.getTask('task-1', CONVOY_ID)!.status).toBe('failed')
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
it('does NOT trigger when heartbeat is within the stuck threshold', () => {
|
|
272
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
273
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(1_000) })
|
|
274
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
275
|
-
expect(emittedEvents).toHaveLength(0)
|
|
276
|
-
expect(store.getTask('task-1', CONVOY_ID)!.status).toBe('running')
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
it('also catches tasks in assigned status', () => {
|
|
280
|
-
store.insertTask(makeTask({ timeout_ms: 60_000 }))
|
|
281
|
-
store.insertWorker(makeWorker())
|
|
282
|
-
store.updateTaskStatus('task-1', CONVOY_ID, 'assigned', { worker_id: 'worker-1' })
|
|
283
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
284
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
285
|
-
const status = store.getTask('task-1', CONVOY_ID)!.status
|
|
286
|
-
expect(['pending', 'failed']).toContain(status)
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
it('skips zombie check when stuck is already detected', () => {
|
|
290
|
-
setupStuck()
|
|
291
|
-
store.updateWorkerStatus('worker-1', 'running', { pid: 12_345 })
|
|
292
|
-
const killSpy = vi.spyOn(process, 'kill')
|
|
293
|
-
try {
|
|
294
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
295
|
-
expect(killSpy).not.toHaveBeenCalled()
|
|
296
|
-
expect(emittedEvents[0].data?.reason).toBe('stuck')
|
|
297
|
-
} finally {
|
|
298
|
-
killSpy.mockRestore()
|
|
299
|
-
}
|
|
300
|
-
})
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
// ── zombie detection ──────────────────────────────────────────────────────────
|
|
304
|
-
|
|
305
|
-
describe('zombie detection', () => {
|
|
306
|
-
function setupZombie(
|
|
307
|
-
taskOverrides: Partial<Parameters<ConvoyStore['insertTask']>[0]> = {},
|
|
308
|
-
) {
|
|
309
|
-
setupRunning(taskOverrides, { pid: 999_999_999, status: 'running' })
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
it('resets task to pending and increments retries when retries < max_retries', () => {
|
|
313
|
-
setupZombie({ retries: 0, max_retries: 1 })
|
|
314
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
315
|
-
throw Object.assign(new Error('ESRCH'), { code: 'ESRCH' })
|
|
316
|
-
})
|
|
317
|
-
try {
|
|
318
|
-
createHealthMonitor(makeOptions()).check()
|
|
319
|
-
const task = store.getTask('task-1', CONVOY_ID)!
|
|
320
|
-
expect(task.status).toBe('pending')
|
|
321
|
-
expect(task.retries).toBe(1)
|
|
322
|
-
} finally {
|
|
323
|
-
killSpy.mockRestore()
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
it('marks worker as killed with a finished_at timestamp', () => {
|
|
328
|
-
setupZombie()
|
|
329
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
330
|
-
throw new Error('ESRCH')
|
|
331
|
-
})
|
|
332
|
-
try {
|
|
333
|
-
createHealthMonitor(makeOptions()).check()
|
|
334
|
-
const worker = store.getWorker('worker-1')!
|
|
335
|
-
expect(worker.status).toBe('killed')
|
|
336
|
-
expect(worker.finished_at).not.toBeNull()
|
|
337
|
-
} finally {
|
|
338
|
-
killSpy.mockRestore()
|
|
339
|
-
}
|
|
340
|
-
})
|
|
341
|
-
|
|
342
|
-
it('marks task as failed when retries >= max_retries', () => {
|
|
343
|
-
setupZombie({ retries: 1, max_retries: 1 })
|
|
344
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
345
|
-
throw new Error('ESRCH')
|
|
346
|
-
})
|
|
347
|
-
try {
|
|
348
|
-
createHealthMonitor(makeOptions()).check()
|
|
349
|
-
expect(store.getTask('task-1', CONVOY_ID)!.status).toBe('failed')
|
|
350
|
-
} finally {
|
|
351
|
-
killSpy.mockRestore()
|
|
352
|
-
}
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
it('does NOT trigger when process is still alive', () => {
|
|
356
|
-
setupRunning({}, { pid: process.pid, status: 'running' })
|
|
357
|
-
// Real process.kill(process.pid, 0) must succeed — no mock needed
|
|
358
|
-
createHealthMonitor(makeOptions()).check()
|
|
359
|
-
expect(emittedEvents).toHaveLength(0)
|
|
360
|
-
expect(store.getTask('task-1', CONVOY_ID)!.status).toBe('running')
|
|
361
|
-
})
|
|
362
|
-
|
|
363
|
-
it('does NOT trigger when worker status is not running (e.g. spawned)', () => {
|
|
364
|
-
setupRunning({}, { pid: 999_999_999, status: 'spawned' })
|
|
365
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
366
|
-
throw new Error('ESRCH')
|
|
367
|
-
})
|
|
368
|
-
try {
|
|
369
|
-
createHealthMonitor(makeOptions()).check()
|
|
370
|
-
expect(emittedEvents).toHaveLength(0)
|
|
371
|
-
} finally {
|
|
372
|
-
killSpy.mockRestore()
|
|
373
|
-
}
|
|
374
|
-
})
|
|
375
|
-
|
|
376
|
-
it('does NOT call process.kill when pid is null', () => {
|
|
377
|
-
setupRunning({}, { pid: null })
|
|
378
|
-
const killSpy = vi.spyOn(process, 'kill')
|
|
379
|
-
try {
|
|
380
|
-
createHealthMonitor(makeOptions()).check()
|
|
381
|
-
expect(killSpy).not.toHaveBeenCalled()
|
|
382
|
-
} finally {
|
|
383
|
-
killSpy.mockRestore()
|
|
384
|
-
}
|
|
385
|
-
})
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
// ── onKill callback ───────────────────────────────────────────────────────────
|
|
389
|
-
|
|
390
|
-
describe('onKill callback', () => {
|
|
391
|
-
it('is called with workerId and taskId on stuck detection', () => {
|
|
392
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
393
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
394
|
-
const onKill = vi.fn()
|
|
395
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2, onKill })).check()
|
|
396
|
-
expect(onKill).toHaveBeenCalledOnce()
|
|
397
|
-
expect(onKill).toHaveBeenCalledWith('worker-1', 'task-1')
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
it('is called with workerId and taskId on zombie detection', () => {
|
|
401
|
-
setupRunning({}, { pid: 999_999_999, status: 'running' })
|
|
402
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
403
|
-
throw new Error('ESRCH')
|
|
404
|
-
})
|
|
405
|
-
try {
|
|
406
|
-
const onKill = vi.fn()
|
|
407
|
-
createHealthMonitor(makeOptions({ onKill })).check()
|
|
408
|
-
expect(onKill).toHaveBeenCalledOnce()
|
|
409
|
-
expect(onKill).toHaveBeenCalledWith('worker-1', 'task-1')
|
|
410
|
-
} finally {
|
|
411
|
-
killSpy.mockRestore()
|
|
412
|
-
}
|
|
413
|
-
})
|
|
414
|
-
|
|
415
|
-
it('does not throw when onKill is not provided', () => {
|
|
416
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
417
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
418
|
-
expect(() => createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()).not.toThrow()
|
|
419
|
-
})
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
// ── event emission ────────────────────────────────────────────────────────────
|
|
423
|
-
|
|
424
|
-
describe('event emission', () => {
|
|
425
|
-
it('emits worker_killed with reason stuck on stuck detection', () => {
|
|
426
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
427
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
428
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
429
|
-
expect(emittedEvents).toHaveLength(1)
|
|
430
|
-
expect(emittedEvents[0].type).toBe('worker_killed')
|
|
431
|
-
expect(emittedEvents[0].data?.reason).toBe('stuck')
|
|
432
|
-
expect(emittedEvents[0].data?.worker_id).toBe('worker-1')
|
|
433
|
-
expect(emittedEvents[0].data?.task_id).toBe('task-1')
|
|
434
|
-
})
|
|
435
|
-
|
|
436
|
-
it('emits worker_killed with reason zombie on zombie detection', () => {
|
|
437
|
-
setupRunning({}, { pid: 999_999_999, status: 'running' })
|
|
438
|
-
const killSpy = vi.spyOn(process, 'kill').mockImplementation((): true => {
|
|
439
|
-
throw new Error('ESRCH')
|
|
440
|
-
})
|
|
441
|
-
try {
|
|
442
|
-
createHealthMonitor(makeOptions()).check()
|
|
443
|
-
expect(emittedEvents).toHaveLength(1)
|
|
444
|
-
expect(emittedEvents[0].type).toBe('worker_killed')
|
|
445
|
-
expect(emittedEvents[0].data?.reason).toBe('zombie')
|
|
446
|
-
} finally {
|
|
447
|
-
killSpy.mockRestore()
|
|
448
|
-
}
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
it('includes convoy_id, task_id, worker_id in emitted event ids', () => {
|
|
452
|
-
setupRunning({ timeout_ms: 60_000 })
|
|
453
|
-
store.updateWorkerStatus('worker-1', 'running', { last_heartbeat: msBefore(200_000) })
|
|
454
|
-
createHealthMonitor(makeOptions({ stuckFactor: 2 })).check()
|
|
455
|
-
const { ids } = emittedEvents[0]
|
|
456
|
-
expect(ids?.convoy_id).toBe(CONVOY_ID)
|
|
457
|
-
expect(ids?.task_id).toBe('task-1')
|
|
458
|
-
expect(ids?.worker_id).toBe('worker-1')
|
|
459
|
-
})
|
|
460
|
-
})
|
|
461
|
-
|
|
462
|
-
// ── detectDrift ───────────────────────────────────────────────────────────────
|
|
463
|
-
|
|
464
|
-
describe('detectDrift', () => {
|
|
465
|
-
function makeTaskRecord(adapterName: string | null = null) {
|
|
466
|
-
store.insertTask(makeTask({ id: 'drift-task', adapter: adapterName }))
|
|
467
|
-
return store.getTask('drift-task', CONVOY_ID)!
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
function makeAgentAdapter(name: string, output: string): AgentAdapter {
|
|
471
|
-
return {
|
|
472
|
-
name,
|
|
473
|
-
isAvailable: vi.fn().mockResolvedValue(true),
|
|
474
|
-
execute: vi.fn().mockResolvedValue({ success: true, output, exitCode: 0 }),
|
|
475
|
-
} as unknown as AgentAdapter
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
it('non-streaming adapter returns score 1.0, drifted=false, and emits a warning', async () => {
|
|
479
|
-
const taskRecord = makeTaskRecord(null)
|
|
480
|
-
const adapter = makeAgentAdapter('vscode', 'ok')
|
|
481
|
-
const stderrSpy = vi.spyOn(process.stderr, 'write').mockImplementation(() => true)
|
|
482
|
-
try {
|
|
483
|
-
const result = await detectDrift(taskRecord, adapter)
|
|
484
|
-
expect(result.score).toBe(1.0)
|
|
485
|
-
expect(result.drifted).toBe(false)
|
|
486
|
-
expect(result.explanation).toContain('non-streaming adapter')
|
|
487
|
-
expect(stderrSpy).toHaveBeenCalledWith(expect.stringContaining('drift detection skipped'))
|
|
488
|
-
} finally {
|
|
489
|
-
stderrSpy.mockRestore()
|
|
490
|
-
}
|
|
491
|
-
})
|
|
492
|
-
|
|
493
|
-
it('streaming adapter with high confidence score returns drifted=false', async () => {
|
|
494
|
-
const taskRecord = makeTaskRecord('copilot')
|
|
495
|
-
const adapter = makeAgentAdapter('copilot', '{"score": 0.95, "explanation": "very confident"}')
|
|
496
|
-
const result = await detectDrift(taskRecord, adapter)
|
|
497
|
-
expect(result.score).toBe(0.95)
|
|
498
|
-
expect(result.drifted).toBe(false)
|
|
499
|
-
expect(result.explanation).toBe('very confident')
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
it('streaming adapter with low confidence score returns drifted=true', async () => {
|
|
503
|
-
const taskRecord = makeTaskRecord('copilot')
|
|
504
|
-
const adapter = makeAgentAdapter('copilot', '{"score": 0.4, "explanation": "not confident"}')
|
|
505
|
-
const result = await detectDrift(taskRecord, adapter)
|
|
506
|
-
expect(result.score).toBe(0.4)
|
|
507
|
-
expect(result.drifted).toBe(true)
|
|
508
|
-
expect(result.threshold).toBe(0.8)
|
|
509
|
-
})
|
|
510
|
-
|
|
511
|
-
it('parse failure returns score 0.5 and drifted=true (below default threshold)', async () => {
|
|
512
|
-
const taskRecord = makeTaskRecord('copilot')
|
|
513
|
-
const adapter = makeAgentAdapter('copilot', 'I cannot rate myself')
|
|
514
|
-
const result = await detectDrift(taskRecord, adapter)
|
|
515
|
-
expect(result.score).toBe(0.5)
|
|
516
|
-
expect(result.drifted).toBe(true)
|
|
517
|
-
expect(result.explanation).toContain('Could not parse')
|
|
518
|
-
})
|
|
519
|
-
})
|