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
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { spawnSync } from 'node:child_process'
|
|
3
|
+
import { hostname, tmpdir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { DatabaseSync } from 'node:sqlite'
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
7
|
+
import { createConvoyStore } from './store.js'
|
|
8
|
+
import type { ConvoyStore } from './store.js'
|
|
9
|
+
import { KNOWN_EVENT_TYPES } from './types.js'
|
|
10
|
+
import {
|
|
11
|
+
convoyDbPath,
|
|
12
|
+
eventCategories,
|
|
13
|
+
eventCategory,
|
|
14
|
+
findProjectRoot,
|
|
15
|
+
isProblemEvent,
|
|
16
|
+
isRunAlive,
|
|
17
|
+
overviewFrom,
|
|
18
|
+
readAllSessions,
|
|
19
|
+
readEngineSessions,
|
|
20
|
+
readEventsSince,
|
|
21
|
+
readOverview,
|
|
22
|
+
readOverviewParts,
|
|
23
|
+
readRun,
|
|
24
|
+
readRunInsights,
|
|
25
|
+
readRunSpec,
|
|
26
|
+
readRuns,
|
|
27
|
+
readSessions,
|
|
28
|
+
} from './read-model.js'
|
|
29
|
+
|
|
30
|
+
let root: string
|
|
31
|
+
let dbPath: string
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
root = realpathSync(mkdtempSync(join(tmpdir(), 'read-model-')))
|
|
35
|
+
mkdirSync(join(root, '.opencastle'), { recursive: true })
|
|
36
|
+
dbPath = convoyDbPath(root)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
rmSync(root, { recursive: true, force: true })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const T0 = '2026-10-01T10:00:00.000Z'
|
|
44
|
+
const T1 = '2026-10-01T10:00:05.000Z'
|
|
45
|
+
const T2 = '2026-10-01T10:01:05.000Z'
|
|
46
|
+
|
|
47
|
+
function task(store: ConvoyStore, convoyId: string, id: string, extra: { phase?: number; depends_on?: string[]; agent?: string } = {}): void {
|
|
48
|
+
store.insertTask({
|
|
49
|
+
id,
|
|
50
|
+
convoy_id: convoyId,
|
|
51
|
+
phase: extra.phase ?? 0,
|
|
52
|
+
prompt: `do ${id}`,
|
|
53
|
+
agent: extra.agent ?? 'developer',
|
|
54
|
+
adapter: null,
|
|
55
|
+
model: null,
|
|
56
|
+
timeout_ms: 60_000,
|
|
57
|
+
status: 'pending',
|
|
58
|
+
retries: 0,
|
|
59
|
+
max_retries: 0,
|
|
60
|
+
files: null,
|
|
61
|
+
depends_on: extra.depends_on ? JSON.stringify(extra.depends_on) : null,
|
|
62
|
+
gates: null,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Two runs written through the real store: an older finished one and a newer one in progress. */
|
|
67
|
+
function seed(): void {
|
|
68
|
+
const store = createConvoyStore(dbPath)
|
|
69
|
+
store.insertConvoy({ id: 'old', name: 'Old run', spec_hash: 'h', status: 'pending', branch: null, created_at: T0, spec_yaml: 'x' })
|
|
70
|
+
task(store, 'old', 'only')
|
|
71
|
+
store.updateTaskStatus('only', 'old', 'done', { started_at: T0, finished_at: T1, total_tokens: 100, cost_usd: 0.01 })
|
|
72
|
+
store.updateConvoyStatus('old', 'done', { started_at: T0, finished_at: T2, total_tokens: 100, total_cost_usd: 0.01 })
|
|
73
|
+
|
|
74
|
+
store.insertConvoy({ id: 'new', name: 'New run', spec_hash: 'h', status: 'pending', branch: 'feat/x', created_at: T1, spec_yaml: 'x' })
|
|
75
|
+
task(store, 'new', 'a')
|
|
76
|
+
task(store, 'new', 'b')
|
|
77
|
+
task(store, 'new', 'c', { phase: 1, depends_on: ['a', 'b'], agent: 'writer' })
|
|
78
|
+
store.updateConvoyStatus('new', 'running', { started_at: T1 })
|
|
79
|
+
store.insertWorker({ id: 'w-a', task_id: 'a', adapter: 'claude', pid: null, session_id: null, status: 'done', worktree: null, created_at: T1 })
|
|
80
|
+
store.updateTaskStatus('a', 'new', 'done', {
|
|
81
|
+
worker_id: 'w-a', started_at: T1, finished_at: T2, total_tokens: 45_812, cost_usd: 0.1234, model: 'claude-sonnet-4-5',
|
|
82
|
+
})
|
|
83
|
+
store.updateTaskStatus('b', 'new', 'failed', {
|
|
84
|
+
started_at: T1, finished_at: T2, total_tokens: 15, cost_usd: 0.001, model: 'claude',
|
|
85
|
+
output: Array.from({ length: 30 }, (_, i) => `line ${i + 1}`).join('\n'),
|
|
86
|
+
})
|
|
87
|
+
const ev = (type: string, data: unknown, taskId: string | null = null): void => {
|
|
88
|
+
store.insertEvent({ convoy_id: 'new', task_id: taskId, worker_id: null, type, data: JSON.stringify(data), created_at: T1 })
|
|
89
|
+
}
|
|
90
|
+
ev('convoy_started', { name: 'New run' })
|
|
91
|
+
ev('task_started', { worker_id: 'w-a' }, 'a')
|
|
92
|
+
ev('task_done', { exit_code: 0 }, 'a')
|
|
93
|
+
ev('built_in_gate_result', { gate: 'secret_scan', passed: false }, 'b')
|
|
94
|
+
ev('task_failed', { reason: 'error', exit_code: 1 }, 'b')
|
|
95
|
+
store.close()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function lock(pid: number, host: string, startedAt: string, heartbeat: string): void {
|
|
99
|
+
const db = new DatabaseSync(dbPath)
|
|
100
|
+
db.prepare('INSERT OR REPLACE INTO engine_lock (id, pid, hostname, started_at, last_heartbeat) VALUES (1, ?, ?, ?, ?)')
|
|
101
|
+
.run(pid, host, startedAt, heartbeat)
|
|
102
|
+
db.close()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
describe('with no database', () => {
|
|
106
|
+
it('reads as no runs, never throws, and creates nothing', () => {
|
|
107
|
+
expect(readRuns(root)).toEqual([])
|
|
108
|
+
expect(readRun(root, 'x')).toBeNull()
|
|
109
|
+
expect(readEventsSince(root, 'x', 0)).toEqual([])
|
|
110
|
+
expect(isRunAlive(root, 'x')).toBe(false)
|
|
111
|
+
expect(readSessions(root)).toEqual([])
|
|
112
|
+
expect(readdirSync(join(root, '.opencastle'))).toEqual([])
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
describe('runs', () => {
|
|
117
|
+
it('lists newest first with task counts, tokens and cost', () => {
|
|
118
|
+
seed()
|
|
119
|
+
const runs = readRuns(root)
|
|
120
|
+
expect(runs.map((r) => r.id)).toEqual(['new', 'old'])
|
|
121
|
+
const [current, old] = runs
|
|
122
|
+
expect(current).toMatchObject({
|
|
123
|
+
name: 'New run', status: 'running', branch: 'feat/x', tasks_total: 3, tasks_done: 1, tasks_failed: 1,
|
|
124
|
+
duration_ms: null, alive: false,
|
|
125
|
+
})
|
|
126
|
+
// Still running, so no run total yet: the sum of what tasks have recorded.
|
|
127
|
+
expect(current.tokens).toBe(45_827)
|
|
128
|
+
expect(current.cost_usd).toBeCloseTo(0.1244)
|
|
129
|
+
// This store records whether each cost is an estimate, and none of these is.
|
|
130
|
+
expect(current.cost_estimated).toBe(false)
|
|
131
|
+
expect(old).toMatchObject({ status: 'done', tokens: 100, cost_usd: 0.01, duration_ms: 65_000 })
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('honours the limit', () => {
|
|
135
|
+
seed()
|
|
136
|
+
expect(readRuns(root, 1).map((r) => r.id)).toEqual(['new'])
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('reads one run with its tasks, dependencies and failure reason', () => {
|
|
140
|
+
seed()
|
|
141
|
+
const run = readRun(root, 'new')!
|
|
142
|
+
expect(run.tasks.map((t) => t.id)).toEqual(['a', 'b', 'c'])
|
|
143
|
+
const [a, b, c] = run.tasks
|
|
144
|
+
expect(c.depends_on).toEqual(['a', 'b'])
|
|
145
|
+
expect(c.agent).toBe('writer')
|
|
146
|
+
expect(a).toMatchObject({ status: 'done', adapter: 'claude', model: 'claude-sonnet-4-5', duration_ms: 60_000, total_tokens: 45_812 })
|
|
147
|
+
expect(a.failure_reason).toBeNull()
|
|
148
|
+
// "claude" is the adapter name the engine wrote when no model was reported.
|
|
149
|
+
expect(b.model).toBeNull()
|
|
150
|
+
expect(b.failure_reason).toBe('error (exit 1)')
|
|
151
|
+
expect(b.error_tail!.split('\n')).toHaveLength(20)
|
|
152
|
+
expect(b.error_tail!.endsWith('line 30')).toBe(true)
|
|
153
|
+
expect(run.adapters).toEqual(['claude'])
|
|
154
|
+
expect(run.models).toEqual(['claude-sonnet-4-5'])
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('returns null for an unknown run', () => {
|
|
158
|
+
seed()
|
|
159
|
+
expect(readRun(root, 'nope')).toBeNull()
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('reports a skipped review as skipped, never as a pass', () => {
|
|
163
|
+
seed()
|
|
164
|
+
const store = createConvoyStore(dbPath)
|
|
165
|
+
store.updateTaskReview('a', 'new', { review_level: 'fast', review_verdict: 'skipped', review_tokens: 0, review_model: null })
|
|
166
|
+
store.close()
|
|
167
|
+
const [a, b] = readRun(root, 'new')!.tasks
|
|
168
|
+
expect(a).toMatchObject({ review_verdict: 'skipped', review_level: 'fast' })
|
|
169
|
+
expect(b.review_verdict).toBeNull()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('reads the spec and runtime a run was started with, for resume', () => {
|
|
173
|
+
seed()
|
|
174
|
+
expect(readRunSpec(root, 'new')).toEqual({ specYaml: 'x', adapter: null })
|
|
175
|
+
expect(readRunSpec(root, 'nope')).toBeNull()
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('does not write to the database it reads', () => {
|
|
179
|
+
seed()
|
|
180
|
+
const db = new DatabaseSync(dbPath)
|
|
181
|
+
const version = (db.prepare('PRAGMA user_version').get() as { user_version: number }).user_version
|
|
182
|
+
db.close()
|
|
183
|
+
const before = statSync(dbPath).mtimeMs
|
|
184
|
+
readRuns(root)
|
|
185
|
+
readRun(root, 'new')
|
|
186
|
+
readEventsSince(root, 'new', 0)
|
|
187
|
+
isRunAlive(root, 'new')
|
|
188
|
+
expect(statSync(dbPath).mtimeMs).toBe(before)
|
|
189
|
+
const after = new DatabaseSync(dbPath, { readOnly: true })
|
|
190
|
+
expect((after.prepare('PRAGMA user_version').get() as { user_version: number }).user_version).toBe(version)
|
|
191
|
+
after.close()
|
|
192
|
+
expect(readdirSync(join(root, '.opencastle')).filter((f) => f.endsWith('.bak'))).toEqual([])
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A database in the shape of store schema 4: no cost_usd_num, no cost flag, no
|
|
198
|
+
* cache counts, no adapter or review columns, no dlq or artifact tables. Written
|
|
199
|
+
* by hand, because the store migrates anything it opens to the current schema.
|
|
200
|
+
*/
|
|
201
|
+
function oldShapeDb(): DatabaseSync {
|
|
202
|
+
const db = new DatabaseSync(dbPath)
|
|
203
|
+
db.exec(`
|
|
204
|
+
CREATE TABLE convoy (id TEXT PRIMARY KEY, name TEXT NOT NULL, spec_hash TEXT NOT NULL, status TEXT NOT NULL,
|
|
205
|
+
branch TEXT, created_at TEXT NOT NULL, started_at TEXT, finished_at TEXT, spec_yaml TEXT NOT NULL,
|
|
206
|
+
total_tokens INTEGER, total_cost_usd TEXT, pipeline_id TEXT);
|
|
207
|
+
CREATE TABLE task (id TEXT NOT NULL, convoy_id TEXT NOT NULL, phase INTEGER NOT NULL, prompt TEXT NOT NULL,
|
|
208
|
+
agent TEXT NOT NULL, adapter TEXT, model TEXT, timeout_ms INTEGER, status TEXT NOT NULL, worker_id TEXT,
|
|
209
|
+
worktree TEXT, output TEXT, exit_code INTEGER, started_at TEXT, finished_at TEXT, retries INTEGER NOT NULL DEFAULT 0,
|
|
210
|
+
max_retries INTEGER NOT NULL DEFAULT 1, files TEXT, depends_on TEXT, prompt_tokens INTEGER,
|
|
211
|
+
completion_tokens INTEGER, total_tokens INTEGER, cost_usd TEXT, PRIMARY KEY (id, convoy_id));
|
|
212
|
+
CREATE TABLE worker (id TEXT PRIMARY KEY, task_id TEXT, adapter TEXT, pid INTEGER, session_id TEXT,
|
|
213
|
+
status TEXT, worktree TEXT, created_at TEXT, finished_at TEXT);
|
|
214
|
+
CREATE TABLE event (id INTEGER PRIMARY KEY AUTOINCREMENT, convoy_id TEXT, task_id TEXT, worker_id TEXT,
|
|
215
|
+
type TEXT NOT NULL, data TEXT, created_at TEXT NOT NULL);
|
|
216
|
+
PRAGMA user_version = 4;
|
|
217
|
+
`)
|
|
218
|
+
return db
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
describe('schemas it did not write', () => {
|
|
222
|
+
it('reads columns a newer engine added, and leaves absent ones undefined', () => {
|
|
223
|
+
const db = oldShapeDb()
|
|
224
|
+
db.exec(`INSERT INTO convoy (id, name, spec_hash, status, created_at, spec_yaml) VALUES ('new', 'New run', 'h', 'running', '${T1}', 'x')`)
|
|
225
|
+
db.exec(`INSERT INTO worker (id, task_id, adapter, status) VALUES ('w-a', 'a', 'claude', 'done')`)
|
|
226
|
+
db.exec(`INSERT INTO task (id, convoy_id, phase, prompt, agent, status, worker_id, total_tokens, cost_usd)
|
|
227
|
+
VALUES ('a', 'new', 0, 'p', 'developer', 'done', 'w-a', 10, '0.1'),
|
|
228
|
+
('b', 'new', 0, 'p', 'developer', 'failed', NULL, 5, '0.01')`)
|
|
229
|
+
// Before a newer engine adds anything, nothing claims a cost is or is not an estimate.
|
|
230
|
+
db.close()
|
|
231
|
+
expect(readRun(root, 'new')!.cost_estimated).toBeUndefined()
|
|
232
|
+
expect(readRun(root, 'new')!.tasks[0].cost_estimated).toBeUndefined()
|
|
233
|
+
|
|
234
|
+
const later = new DatabaseSync(dbPath)
|
|
235
|
+
later.exec('ALTER TABLE task ADD COLUMN cost_estimated INTEGER')
|
|
236
|
+
later.exec('ALTER TABLE task ADD COLUMN cache_read_tokens INTEGER')
|
|
237
|
+
later.exec('ALTER TABLE convoy ADD COLUMN adapter TEXT')
|
|
238
|
+
later.exec("UPDATE task SET cost_estimated = 1 WHERE id = 'b'")
|
|
239
|
+
later.exec("UPDATE task SET cost_estimated = 0, cache_read_tokens = 40000 WHERE id = 'a'")
|
|
240
|
+
later.exec("UPDATE convoy SET adapter = 'codex', status = 'interrupted' WHERE id = 'new'")
|
|
241
|
+
later.close()
|
|
242
|
+
|
|
243
|
+
const run = readRun(root, 'new')!
|
|
244
|
+
expect(run.status).toBe('interrupted')
|
|
245
|
+
expect(run.cost_estimated).toBe(true)
|
|
246
|
+
expect(run.adapters).toEqual(['claude', 'codex'])
|
|
247
|
+
const [a, b] = run.tasks
|
|
248
|
+
expect(a.cache_read_tokens).toBe(40_000)
|
|
249
|
+
expect(a.cache_write_tokens).toBeUndefined()
|
|
250
|
+
expect(a.review_verdict).toBeUndefined()
|
|
251
|
+
expect(a.cost_estimated).toBe(false)
|
|
252
|
+
expect(b.cost_estimated).toBe(true)
|
|
253
|
+
// An interrupted run is not alive, whatever the lock says.
|
|
254
|
+
const lockDb = new DatabaseSync(dbPath)
|
|
255
|
+
lockDb.exec('CREATE TABLE engine_lock (id INTEGER PRIMARY KEY, pid INTEGER, hostname TEXT, started_at TEXT, last_heartbeat TEXT)')
|
|
256
|
+
lockDb.close()
|
|
257
|
+
lock(process.pid, hostname(), T0, new Date().toISOString())
|
|
258
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
it('reads an old database without migrating it', () => {
|
|
262
|
+
const db = oldShapeDb()
|
|
263
|
+
db.exec(`INSERT INTO convoy VALUES ('v4', 'Legacy', 'h', 'done', NULL, '${T0}', '${T0}', '${T1}', 'x', 50, '0.5', NULL)`)
|
|
264
|
+
db.exec(`INSERT INTO task (id, convoy_id, phase, prompt, agent, status, total_tokens, cost_usd)
|
|
265
|
+
VALUES ('t', 'v4', 0, 'p', 'developer', 'done', 50, '0.5')`)
|
|
266
|
+
db.close()
|
|
267
|
+
|
|
268
|
+
expect(readRuns(root)).toMatchObject([{ id: 'v4', tokens: 50, cost_usd: 0.5, tasks_done: 1 }])
|
|
269
|
+
const run = readRun(root, 'v4')!
|
|
270
|
+
expect(run.tasks[0]).toMatchObject({ id: 't', cost_usd: 0.5, cache_read_tokens: undefined })
|
|
271
|
+
expect(isRunAlive(root, 'v4')).toBe(false)
|
|
272
|
+
|
|
273
|
+
const after = new DatabaseSync(dbPath, { readOnly: true })
|
|
274
|
+
expect((after.prepare('PRAGMA user_version').get() as { user_version: number }).user_version).toBe(4)
|
|
275
|
+
after.close()
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
it('reads an empty database file as no runs', () => {
|
|
279
|
+
writeFileSync(dbPath, '')
|
|
280
|
+
expect(readRuns(root)).toEqual([])
|
|
281
|
+
expect(readRun(root, 'x')).toBeNull()
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
describe('events', () => {
|
|
286
|
+
it('reads only what is newer than the cursor', () => {
|
|
287
|
+
seed()
|
|
288
|
+
const all = readEventsSince(root, 'new', 0)
|
|
289
|
+
expect(all.map((e) => e.type)).toEqual(['convoy_started', 'task_started', 'task_done', 'built_in_gate_result', 'task_failed'])
|
|
290
|
+
const later = readEventsSince(root, 'new', all[2].id)
|
|
291
|
+
expect(later.map((e) => e.type)).toEqual(['built_in_gate_result', 'task_failed'])
|
|
292
|
+
expect(readEventsSince(root, 'new', all[4].id)).toEqual([])
|
|
293
|
+
expect(readEventsSince(root, 'new', 0, 2)).toHaveLength(2)
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
it('parses data and marks problems', () => {
|
|
297
|
+
seed()
|
|
298
|
+
const [started, , , gate, failed] = readEventsSince(root, 'new', 0)
|
|
299
|
+
expect(started).toMatchObject({ category: 'run', problem: false, data: { name: 'New run' } })
|
|
300
|
+
expect(gate).toMatchObject({ category: 'check', problem: true, task_id: 'b' })
|
|
301
|
+
expect(failed).toMatchObject({ category: 'task', problem: true })
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
it('files every type the engine can emit under a real category', () => {
|
|
305
|
+
const uncategorised = [...KNOWN_EVENT_TYPES].filter((t) => eventCategory(t) === 'other')
|
|
306
|
+
expect(uncategorised).toEqual([])
|
|
307
|
+
const grouped = eventCategories()
|
|
308
|
+
expect(Object.values(grouped).flat().sort()).toEqual([...KNOWN_EVENT_TYPES].sort())
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
it('files gate results with the checks', () => {
|
|
312
|
+
expect(eventCategory('gate_result')).toBe('check')
|
|
313
|
+
expect(isProblemEvent('gate_result', { command: 'npm test', passed: false })).toBe(true)
|
|
314
|
+
expect(isProblemEvent('gate_result', { command: 'npm test', passed: true })).toBe(false)
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it('surfaces a review that blocked or reached no verdict, and not one that passed', () => {
|
|
318
|
+
expect(isProblemEvent('review_verdict', { level: 'fast', verdict: 'block' })).toBe(true)
|
|
319
|
+
expect(isProblemEvent('review_verdict', { level: 'fast', verdict: 'skipped' })).toBe(true)
|
|
320
|
+
expect(isProblemEvent('review_skipped', { level: 'fast', reason: 'no verdict' })).toBe(true)
|
|
321
|
+
expect(isProblemEvent('review_verdict', { level: 'auto-pass', verdict: 'pass' })).toBe(false)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('places types by their prefix, so ones added later land somewhere sensible', () => {
|
|
325
|
+
expect(eventCategory('task_interrupted')).toBe('task')
|
|
326
|
+
expect(eventCategory('convoy_interrupted')).toBe('run')
|
|
327
|
+
expect(eventCategory('merge_failed')).toBe('merge')
|
|
328
|
+
expect(isProblemEvent('convoy_interrupted', null)).toBe(true)
|
|
329
|
+
expect(isProblemEvent('task_done', { passed: true })).toBe(false)
|
|
330
|
+
expect(isProblemEvent('drift_check_result', { passed: false })).toBe(true)
|
|
331
|
+
})
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
describe('isRunAlive', () => {
|
|
335
|
+
const fresh = (): string => new Date().toISOString()
|
|
336
|
+
|
|
337
|
+
it('is false with no lock', () => {
|
|
338
|
+
seed()
|
|
339
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
it('is true while this host holds the lock with a live pid and a fresh heartbeat', () => {
|
|
343
|
+
seed()
|
|
344
|
+
lock(process.pid, hostname(), T0, fresh())
|
|
345
|
+
expect(isRunAlive(root, 'new')).toBe(true)
|
|
346
|
+
expect(readRuns(root).find((r) => r.id === 'new')!.alive).toBe(true)
|
|
347
|
+
const run = readRun(root, 'new')!
|
|
348
|
+
expect(run).toMatchObject({ alive: true, status: 'running', display_status: 'running' })
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
it('is false for a finished run, whoever holds the lock', () => {
|
|
352
|
+
seed()
|
|
353
|
+
lock(process.pid, hostname(), T0, fresh())
|
|
354
|
+
expect(isRunAlive(root, 'old')).toBe(false)
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
it('is false when the pid is dead on this host, even with a fresh heartbeat', () => {
|
|
358
|
+
seed()
|
|
359
|
+
const gone = spawnSync(process.execPath, ['-e', '']).pid!
|
|
360
|
+
lock(gone, hostname(), T0, fresh())
|
|
361
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it('is false when the heartbeat has stopped', () => {
|
|
365
|
+
seed()
|
|
366
|
+
lock(process.pid, hostname(), T0, new Date(Date.now() - 5 * 60_000).toISOString())
|
|
367
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
it('trusts a fresh heartbeat from another host, where the pid cannot be checked', () => {
|
|
371
|
+
seed()
|
|
372
|
+
lock(1, 'some-other-host', T0, fresh())
|
|
373
|
+
expect(isRunAlive(root, 'new')).toBe(true)
|
|
374
|
+
lock(1, 'some-other-host', T0, new Date(Date.now() - 5 * 60_000).toISOString())
|
|
375
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
it('does not lend a later run’s lock to one a crash left "running"', () => {
|
|
379
|
+
seed()
|
|
380
|
+
// The lock was taken after this run's last sign of life.
|
|
381
|
+
lock(process.pid, hostname(), '2026-10-02T00:00:00.000Z', fresh())
|
|
382
|
+
expect(isRunAlive(root, 'new')).toBe(false)
|
|
383
|
+
// A resume writes an event after taking the lock, and the run is alive again.
|
|
384
|
+
const db = new DatabaseSync(dbPath)
|
|
385
|
+
db.prepare("INSERT INTO event (convoy_id, type, data, created_at) VALUES ('new', 'convoy_resumed', NULL, ?)").run(fresh())
|
|
386
|
+
db.close()
|
|
387
|
+
expect(isRunAlive(root, 'new')).toBe(true)
|
|
388
|
+
})
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
describe('sessions', () => {
|
|
392
|
+
it('reads session records newest first and skips everything else', () => {
|
|
393
|
+
const logs = join(root, '.opencastle', 'logs')
|
|
394
|
+
mkdirSync(logs, { recursive: true })
|
|
395
|
+
writeFileSync(
|
|
396
|
+
join(logs, 'events.ndjson'),
|
|
397
|
+
[
|
|
398
|
+
JSON.stringify({ type: 'session', timestamp: T0, agent: 'Developer', task: 'first', outcome: 'success', duration_min: 3 }),
|
|
399
|
+
'not json',
|
|
400
|
+
JSON.stringify({ type: 'review', timestamp: T1, agent: 'Developer', verdict: 'pass' }),
|
|
401
|
+
JSON.stringify({ type: 'session', timestamp: T2, agent: 'Writer', task: 'second', outcome: 'partial', model: 'm' }),
|
|
402
|
+
'',
|
|
403
|
+
].join('\n'),
|
|
404
|
+
)
|
|
405
|
+
const sessions = readSessions(root)
|
|
406
|
+
expect(sessions.map((s) => s.task)).toEqual(['second', 'first'])
|
|
407
|
+
expect(sessions[0]).toMatchObject({ agent: 'Writer', outcome: 'partial', model: 'm', duration_min: null })
|
|
408
|
+
expect(sessions[1]).toMatchObject({ duration_min: 3, model: null })
|
|
409
|
+
expect(readSessions(root, 1)).toHaveLength(1)
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
describe('findProjectRoot', () => {
|
|
414
|
+
it('walks up to the nearest .opencastle directory', () => {
|
|
415
|
+
const deep = join(root, 'src', 'a', 'b')
|
|
416
|
+
mkdirSync(deep, { recursive: true })
|
|
417
|
+
expect(findProjectRoot(deep)).toBe(root)
|
|
418
|
+
expect(findProjectRoot(root)).toBe(root)
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
it('returns null when there is none above', () => {
|
|
422
|
+
const outside = realpathSync(mkdtempSync(join(tmpdir(), 'no-project-')))
|
|
423
|
+
try {
|
|
424
|
+
// tmpdir itself could sit under a project on a developer machine; only assert when it does not.
|
|
425
|
+
if (findProjectRoot(tmpdir()) === null) expect(findProjectRoot(outside)).toBeNull()
|
|
426
|
+
} finally {
|
|
427
|
+
rmSync(outside, { recursive: true, force: true })
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
// ── The dashboard's aggregates ──────────────────────────────────────────────
|
|
433
|
+
|
|
434
|
+
const D1 = '2026-10-01T09:00:00.000Z'
|
|
435
|
+
const D2 = '2026-10-02T09:00:00.000Z'
|
|
436
|
+
const at = (base: string, seconds: number): string => new Date(Date.parse(base) + seconds * 1000).toISOString()
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Three runs written through the real store, shaped like what the engine
|
|
440
|
+
* records now: a finished run whose first task failed a gate, was blocked by a
|
|
441
|
+
* review and passed on its third attempt, while the second auto-passed; a run
|
|
442
|
+
* whose only task failed for good; and one a crash left "running".
|
|
443
|
+
*/
|
|
444
|
+
function seedHistory(): void {
|
|
445
|
+
const store = createConvoyStore(dbPath)
|
|
446
|
+
const ev = (convoy: string, type: string, data: unknown, taskId: string | null = null, seconds = 0, base = D1): void => {
|
|
447
|
+
store.insertEvent({ convoy_id: convoy, task_id: taskId, worker_id: null, type, data: JSON.stringify(data), created_at: at(base, seconds) })
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
store.insertConvoy({ id: 'r1', name: 'Tags', spec_hash: 'h', status: 'pending', branch: 'convoy/tags', created_at: D1, spec_yaml: 'x' })
|
|
451
|
+
task(store, 'r1', 'a')
|
|
452
|
+
task(store, 'r1', 'b', { phase: 1, depends_on: ['a'], agent: 'writer' })
|
|
453
|
+
store.updateTaskStatus('a', 'r1', 'done', { started_at: at(D1, 1), finished_at: at(D1, 40), retries: 2, total_tokens: 1000, cost_usd: 0.5, model: 'claude-sonnet-5' })
|
|
454
|
+
store.updateTaskStatus('b', 'r1', 'done', { started_at: at(D1, 41), finished_at: at(D1, 50), total_tokens: 550, cost_usd: 0.25, model: 'claude-haiku-4-5', cost_estimated: 1 })
|
|
455
|
+
store.updateTaskReview('a', 'r1', { review_level: 'fast', review_verdict: 'pass', review_tokens: 250, review_model: 'claude-haiku-4-5' })
|
|
456
|
+
store.updateTaskReview('b', 'r1', { review_level: 'auto-pass', review_verdict: 'pass', review_tokens: 0, review_model: null })
|
|
457
|
+
store.updateConvoyStatus('r1', 'done', { started_at: D1, finished_at: at(D1, 60), total_tokens: 1550, total_cost_usd: 0.75, cost_estimated: true })
|
|
458
|
+
ev('r1', 'convoy_started', { name: 'Tags' })
|
|
459
|
+
ev('r1', 'task_started', { worker_id: 'w1', mechanism: 'worktree', adapter: 'claude', attempt: 1 }, 'a', 1)
|
|
460
|
+
ev('r1', 'gate_result', { command: 'npm run lint', passed: false, exit_code: 1, scope: 'task' }, 'a', 5)
|
|
461
|
+
ev('r1', 'task_retried', { previous_status: 'gate-failed', reason: 'Gate "npm run lint" failed (exit 1)', attempt: 2 }, 'a', 6)
|
|
462
|
+
ev('r1', 'task_started', { worker_id: 'w2', mechanism: 'worktree', adapter: 'claude', attempt: 2 }, 'a', 7)
|
|
463
|
+
ev('r1', 'gate_result', { command: 'npm run lint', passed: true, exit_code: 0, scope: 'task' }, 'a', 10)
|
|
464
|
+
ev('r1', 'review_verdict', { level: 'fast', verdict: 'block', tokens: 300, model: 'claude-haiku-4-5', feedback_length: 80 }, 'a', 12)
|
|
465
|
+
ev('r1', 'task_retried', { previous_status: 'review-blocked', reason: 'Remove the debug log', attempt: 3 }, 'a', 13)
|
|
466
|
+
ev('r1', 'task_started', { worker_id: 'w3', mechanism: 'worktree', adapter: 'claude', attempt: 3 }, 'a', 14)
|
|
467
|
+
ev('r1', 'review_verdict', { level: 'fast', verdict: 'pass', tokens: 250, model: 'claude-haiku-4-5', feedback_length: 0 }, 'a', 38)
|
|
468
|
+
ev('r1', 'contract_violation', { task_id: 'a', agent: 'developer', missing: ['__contract_block'], warnings: [] }, 'a', 39)
|
|
469
|
+
ev('r1', 'task_merged', { branch: 'convoy/tags', files: 3 }, 'a', 40)
|
|
470
|
+
ev('r1', 'delegation', { agent: 'developer', tier: 'standard', mechanism: 'convoy' }, 'a', 40)
|
|
471
|
+
ev('r1', 'session', { agent: 'developer', model: 'claude-sonnet-5', task: 'a', outcome: 'success', duration_min: 1, files_changed: 3, retries: 2, convoy_id: 'r1' }, 'a', 40)
|
|
472
|
+
ev('r1', 'task_started', { worker_id: 'w4', mechanism: 'worktree', adapter: 'claude', attempt: 1 }, 'b', 41)
|
|
473
|
+
ev('r1', 'built_in_gate_result', { gate: 'secret_scan', passed: true, output: '' }, 'b', 45)
|
|
474
|
+
ev('r1', 'review_verdict', { level: 'auto-pass', verdict: 'pass', tokens: 0, model: null, feedback_length: 0 }, 'b', 49)
|
|
475
|
+
ev('r1', 'task_merged', { branch: 'convoy/tags', files: 1 }, 'b', 50)
|
|
476
|
+
ev('r1', 'delegation', { agent: 'writer', tier: 'economy', mechanism: 'convoy' }, 'b', 50)
|
|
477
|
+
ev('r1', 'session', { agent: 'writer', model: 'claude-haiku-4-5', task: 'b', outcome: 'success', duration_min: 0, files_changed: 1, retries: 0, convoy_id: 'r1' }, 'b', 50)
|
|
478
|
+
ev('r1', 'gate_result', { command: 'npm test', passed: false, exit_code: 1, scope: 'convoy', output: '1 failing' }, null, 52)
|
|
479
|
+
ev('r1', 'gate_result', { command: 'npm test', passed: true, exit_code: 0, scope: 'convoy' }, null, 58)
|
|
480
|
+
ev('r1', 'secret_leak_prevented', { patterns: ['github_token'], context: 'event_redacted', original_type: 'task_failed' }, null, 59)
|
|
481
|
+
ev('r1', 'convoy_finished', { status: 'done' }, null, 60)
|
|
482
|
+
store.insertArtifact({ id: 'art-1', convoy_id: 'r1', task_id: 'a', name: 'src/tags.js', type: 'file', content: '', created_at: at(D1, 40) })
|
|
483
|
+
store.insertArtifact({ id: 'art-2', convoy_id: 'r1', task_id: 'b', name: 'summary', type: 'summary', content: 'Added tags', created_at: at(D1, 50) })
|
|
484
|
+
|
|
485
|
+
store.insertConvoy({ id: 'r2', name: 'Search', spec_hash: 'h', status: 'pending', branch: null, created_at: D2, spec_yaml: 'x' })
|
|
486
|
+
task(store, 'r2', 'c')
|
|
487
|
+
store.updateTaskStatus('c', 'r2', 'failed', { started_at: at(D2, 1), finished_at: at(D2, 100), model: 'claude', output: 'Error: boom' })
|
|
488
|
+
store.updateConvoyStatus('r2', 'failed', { started_at: D2, finished_at: at(D2, 120) })
|
|
489
|
+
ev('r2', 'task_started', { worker_id: 'w5', mechanism: 'worktree', adapter: 'codex', attempt: 1 }, 'c', 1, D2)
|
|
490
|
+
ev('r2', 'review_skipped', { level: 'fast', reason: 'the reviewer timed out' }, 'c', 90, D2)
|
|
491
|
+
ev('r2', 'task_failed', { reason: 'error', message: 'Error: boom\n at stub (x.js:1:1)', exit_code: 1 }, 'c', 100, D2)
|
|
492
|
+
store.insertDlqEntry({
|
|
493
|
+
id: 'dlq-1', convoy_id: 'r2', task_id: 'c', agent: 'developer', failure_type: 'error', error_output: 'Error: boom',
|
|
494
|
+
attempts: 1, tokens_spent: null, escalation_task_id: null, resolved: 0, resolution: null, created_at: at(D2, 100), resolved_at: null,
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
store.insertConvoy({ id: 'r3', name: 'Crashed', spec_hash: 'h', status: 'pending', branch: null, created_at: at(D2, 600), spec_yaml: 'x' })
|
|
498
|
+
task(store, 'r3', 'd')
|
|
499
|
+
store.updateTaskStatus('d', 'r3', 'running', { started_at: at(D2, 601) })
|
|
500
|
+
store.updateConvoyStatus('r3', 'running', { started_at: at(D2, 600) })
|
|
501
|
+
ev('r3', 'task_started', { worker_id: 'w6', mechanism: 'worktree', adapter: 'claude', attempt: 1 }, 'd', 601, D2)
|
|
502
|
+
store.close()
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
describe('display status', () => {
|
|
506
|
+
it('shows a run left "running" with nothing running it as interrupted, and its running task too', () => {
|
|
507
|
+
seedHistory()
|
|
508
|
+
const crashed = readRun(root, 'r3')!
|
|
509
|
+
expect(crashed).toMatchObject({ status: 'running', alive: false, display_status: 'interrupted' })
|
|
510
|
+
expect(crashed.tasks[0]).toMatchObject({ status: 'running', display_status: 'interrupted' })
|
|
511
|
+
expect(readRun(root, 'r1')!.display_status).toBe('done')
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
describe('the overview', () => {
|
|
516
|
+
it('counts every run, task, review and check from what the store holds', () => {
|
|
517
|
+
seedHistory()
|
|
518
|
+
const o = readOverview(root)
|
|
519
|
+
expect(o.runs).toEqual({ total: 3, alive: 0, by_status: { done: 1, failed: 1, interrupted: 1 }, ended: 3, done: 1, success_rate: 1 / 3 })
|
|
520
|
+
expect(o.duration).toEqual({ measured: 2, avg_ms: 90_000, p95_ms: 120_000, max_ms: 120_000 })
|
|
521
|
+
// Only r1 recorded tokens and cost; the others are not reported, not zero.
|
|
522
|
+
expect(o.tokens).toEqual({ total: 1550, runs_reported: 1, runs_not_reported: 2 })
|
|
523
|
+
expect(o.cost).toEqual({ total_usd: 0.75, estimated: true, runs_reported: 1, runs_not_reported: 2 })
|
|
524
|
+
expect(o.activity).toEqual([
|
|
525
|
+
{ date: '2026-10-01', total: 1, done: 1, failed: 0, interrupted: 0, other: 0 },
|
|
526
|
+
{ date: '2026-10-02', total: 2, done: 0, failed: 1, interrupted: 1, other: 0 },
|
|
527
|
+
])
|
|
528
|
+
expect(o.tasks).toEqual({ total: 4, retries: 2, by_status: { done: 2, failed: 1, interrupted: 1 } })
|
|
529
|
+
expect(o.agents).toEqual([
|
|
530
|
+
{ agent: 'developer', total: 3, done: 1, failed: 1, running: 0, other: 1 },
|
|
531
|
+
{ agent: 'writer', total: 1, done: 1, failed: 0, running: 0, other: 0 },
|
|
532
|
+
])
|
|
533
|
+
// "claude" names the runtime, not a model, so task c reads as not reported.
|
|
534
|
+
expect(o.models).toEqual([{ model: 'claude-haiku-4-5', tasks: 1 }, { model: 'claude-sonnet-5', tasks: 1 }])
|
|
535
|
+
expect(o.models_not_reported).toBe(2)
|
|
536
|
+
expect(o.tiers).toEqual([{ tier: 'economy', tasks: 1 }, { tier: 'standard', tasks: 1 }])
|
|
537
|
+
expect(o.tiers_not_recorded).toBe(2)
|
|
538
|
+
expect(o.mechanisms).toEqual([{ mechanism: 'worktree', attempts: 6 }])
|
|
539
|
+
expect(o.runtimes).toEqual([{ runtime: 'claude', attempts: 5 }, { runtime: 'codex', attempts: 1 }])
|
|
540
|
+
expect(o.reviews).toEqual({
|
|
541
|
+
ran: 2, passed: 1, blocked: 1, skipped: 1, auto_pass: 1, tokens: 550,
|
|
542
|
+
by_level: { fast: { pass: 1, block: 1 } }, models: { 'claude-haiku-4-5': 2 }, disputes: 0,
|
|
543
|
+
})
|
|
544
|
+
expect(o.checks).toEqual({
|
|
545
|
+
ran: 5, passed: 3, failed: 2,
|
|
546
|
+
gates: { passed: 2, failed: 2 }, built_in: { passed: 1, failed: 0 },
|
|
547
|
+
by_scope: { task: { passed: 2, failed: 1 }, convoy: { passed: 1, failed: 1 } },
|
|
548
|
+
warnings: 1, secrets_prevented: 1,
|
|
549
|
+
})
|
|
550
|
+
expect(o.dlq).toEqual({ entries: 1, unresolved: 1 })
|
|
551
|
+
expect(o.artifacts).toBe(2)
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
it('combines projects by their rows, so a percentile is over every run and not an average of averages', () => {
|
|
555
|
+
seedHistory()
|
|
556
|
+
const one = readOverviewParts(root)
|
|
557
|
+
const two = { ...one, runs: one.runs.map((r) => ({ ...r, id: `${r.id}-copy`, duration_ms: r.duration_ms === null ? null : r.duration_ms * 10 })) }
|
|
558
|
+
const both = overviewFrom([one, two])
|
|
559
|
+
expect(both.runs.total).toBe(6)
|
|
560
|
+
expect(both.duration).toEqual({ measured: 4, avg_ms: 495_000, p95_ms: 1_200_000, max_ms: 1_200_000 })
|
|
561
|
+
expect(both.reviews!.ran).toBe(4)
|
|
562
|
+
expect(both.checks!.ran).toBe(10)
|
|
563
|
+
expect(both.dlq).toEqual({ entries: 2, unresolved: 2 })
|
|
564
|
+
expect(both.tasks.total).toBe(8)
|
|
565
|
+
// Combining does not change the parts it was given.
|
|
566
|
+
expect(one.reviews!.ran).toBe(2)
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
it('is empty, with nothing claimed, for a project that has never run', () => {
|
|
570
|
+
const o = readOverview(root)
|
|
571
|
+
expect(o.runs.total).toBe(0)
|
|
572
|
+
expect(o.runs.success_rate).toBeNull()
|
|
573
|
+
expect(o.duration.avg_ms).toBeNull()
|
|
574
|
+
expect(o.tokens.total).toBeNull()
|
|
575
|
+
expect(o.cost.total_usd).toBeNull()
|
|
576
|
+
expect(o.reviews).toBeNull()
|
|
577
|
+
expect(o.dlq).toBeNull()
|
|
578
|
+
expect(readdirSync(join(root, '.opencastle'))).toEqual([])
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
it('reads an old database: what it never recorded is null, not zero', () => {
|
|
582
|
+
const db = oldShapeDb()
|
|
583
|
+
db.exec(`INSERT INTO convoy VALUES ('v4', 'Legacy', 'h', 'done', NULL, '${T0}', '${T0}', '${T1}', 'x', NULL, NULL, NULL)`)
|
|
584
|
+
db.exec(`INSERT INTO task (id, convoy_id, phase, prompt, agent, status, model) VALUES ('t', 'v4', 0, 'p', 'developer', 'done', 'claude')`)
|
|
585
|
+
db.exec('DROP TABLE event')
|
|
586
|
+
db.close()
|
|
587
|
+
const o = readOverview(root)
|
|
588
|
+
expect(o.runs).toMatchObject({ total: 1, done: 1, success_rate: 1 })
|
|
589
|
+
expect(o.tokens.total).toBeNull()
|
|
590
|
+
expect(o.cost).toMatchObject({ total_usd: null, estimated: undefined })
|
|
591
|
+
// No event table: reviews, checks and tiers are unknown, and no dlq or artifact table either.
|
|
592
|
+
expect(o.reviews).toBeNull()
|
|
593
|
+
expect(o.checks).toBeNull()
|
|
594
|
+
expect(o.tiers).toEqual([])
|
|
595
|
+
expect(o.tiers_not_recorded).toBe(1)
|
|
596
|
+
expect(o.dlq).toBeNull()
|
|
597
|
+
expect(o.artifacts).toBeNull()
|
|
598
|
+
expect(o.models_not_reported).toBe(1)
|
|
599
|
+
const ins = readRunInsights(root, 'v4')!
|
|
600
|
+
expect(ins).toMatchObject({ events_recorded: false, dlq: null, artifacts: null, reviews: [], checks: [] })
|
|
601
|
+
const after = new DatabaseSync(dbPath, { readOnly: true })
|
|
602
|
+
expect((after.prepare('PRAGMA user_version').get() as { user_version: number }).user_version).toBe(4)
|
|
603
|
+
after.close()
|
|
604
|
+
})
|
|
605
|
+
})
|
|
606
|
+
|
|
607
|
+
describe('run insights', () => {
|
|
608
|
+
it('ties each review and gate to the attempt it read, and numbers the checks on the merged result', () => {
|
|
609
|
+
seedHistory()
|
|
610
|
+
const ins = readRunInsights(root, 'r1')!
|
|
611
|
+
expect(ins.reviews.map((r) => [r.task_id, r.level, r.verdict, r.attempt, r.tokens])).toEqual([
|
|
612
|
+
['a', 'fast', 'block', 2, 300],
|
|
613
|
+
['a', 'fast', 'pass', 3, 250],
|
|
614
|
+
['b', 'auto-pass', 'pass', 1, 0],
|
|
615
|
+
])
|
|
616
|
+
expect(ins.checks.map((c) => [c.name, c.kind, c.scope, c.task_id, c.passed, c.attempt, c.round])).toEqual([
|
|
617
|
+
['npm run lint', 'gate', 'task', 'a', false, 1, null],
|
|
618
|
+
['npm run lint', 'gate', 'task', 'a', true, 2, null],
|
|
619
|
+
['secret_scan', 'built-in', 'task', 'b', true, 1, null],
|
|
620
|
+
['npm test', 'gate', 'convoy', null, false, null, 1],
|
|
621
|
+
['npm test', 'gate', 'convoy', null, true, null, 2],
|
|
622
|
+
])
|
|
623
|
+
expect(ins.checks[3]).toMatchObject({ exit_code: 1, output: '1 failing' })
|
|
624
|
+
expect(ins.review_stats).toMatchObject({ ran: 2, passed: 1, blocked: 1, auto_pass: 1, skipped: 0 })
|
|
625
|
+
expect(ins.tiers).toEqual([{ tier: 'economy', tasks: 1 }, { tier: 'standard', tasks: 1 }])
|
|
626
|
+
expect(ins.task_tiers).toEqual({ a: 'standard', b: 'economy' })
|
|
627
|
+
expect(ins.tiers_not_recorded).toBe(0)
|
|
628
|
+
expect(ins.starts).toEqual({ a: 3, b: 1 })
|
|
629
|
+
expect(ins.mechanisms).toEqual([{ mechanism: 'worktree', attempts: 4 }])
|
|
630
|
+
expect(ins.merges).toEqual({ a: 3, b: 1 })
|
|
631
|
+
expect(ins.retries.map((r) => [r.task_id, r.attempt, r.previous_status])).toEqual([['a', 2, 'gate-failed'], ['a', 3, 'review-blocked']])
|
|
632
|
+
expect(ins.warnings).toMatchObject([{ type: 'contract_violation', task_id: 'a', items: ['no output summary block in the answer'] }])
|
|
633
|
+
expect(ins.secrets_prevented).toMatchObject([{ context: 'event_redacted', patterns: ['github_token'] }])
|
|
634
|
+
expect(ins.artifacts).toEqual([
|
|
635
|
+
{ name: 'src/tags.js', type: 'file', task_id: 'a', created_at: at(D1, 40), size_bytes: 0 },
|
|
636
|
+
{ name: 'summary', type: 'summary', task_id: 'b', created_at: at(D1, 50), size_bytes: 10 },
|
|
637
|
+
])
|
|
638
|
+
expect(ins.dlq).toEqual([])
|
|
639
|
+
expect(ins.sessions.map((s) => [s.source, s.task, s.convoy_id])).toEqual([['convoy', 'b', 'r1'], ['convoy', 'a', 'r1']])
|
|
640
|
+
expect(ins.events_recorded).toBe(true)
|
|
641
|
+
})
|
|
642
|
+
|
|
643
|
+
it('reads the retry queue and a review that reached no verdict', () => {
|
|
644
|
+
seedHistory()
|
|
645
|
+
const ins = readRunInsights(root, 'r2')!
|
|
646
|
+
expect(ins.dlq).toEqual([{
|
|
647
|
+
id: 'dlq-1', task_id: 'c', agent: 'developer', failure_type: 'error', attempts: 1, tokens_spent: null,
|
|
648
|
+
resolved: false, resolution: null, created_at: at(D2, 100), resolved_at: null, error_tail: 'Error: boom',
|
|
649
|
+
}])
|
|
650
|
+
expect(ins.reviews_skipped).toMatchObject([{ task_id: 'c', level: 'fast', reason: 'the reviewer timed out', attempt: 1 }])
|
|
651
|
+
// The failure reads as what went wrong first, then the engine's code for it.
|
|
652
|
+
expect(readRun(root, 'r2')!.tasks[0].failure_reason).toBe('Error: boom (error, exit 1)')
|
|
653
|
+
expect(ins.review_stats).toMatchObject({ ran: 0, skipped: 1 })
|
|
654
|
+
expect(ins.runtimes).toEqual([{ runtime: 'codex', attempts: 1 }])
|
|
655
|
+
expect(ins.tiers_not_recorded).toBe(1)
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
it('is null for a run that does not exist', () => {
|
|
659
|
+
seedHistory()
|
|
660
|
+
expect(readRunInsights(root, 'nope')).toBeNull()
|
|
661
|
+
})
|
|
662
|
+
|
|
663
|
+
it('does not write to the database it reads', () => {
|
|
664
|
+
seedHistory()
|
|
665
|
+
const before = statSync(dbPath).mtimeMs
|
|
666
|
+
readOverview(root)
|
|
667
|
+
readRunInsights(root, 'r1')
|
|
668
|
+
readAllSessions(root)
|
|
669
|
+
expect(statSync(dbPath).mtimeMs).toBe(before)
|
|
670
|
+
})
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
describe('sessions from both sources', () => {
|
|
674
|
+
it('merges `opencastle log` records with the engine’s session events, newest first, each labelled', () => {
|
|
675
|
+
seedHistory()
|
|
676
|
+
const logs = join(root, '.opencastle', 'logs')
|
|
677
|
+
mkdirSync(logs, { recursive: true })
|
|
678
|
+
writeFileSync(join(logs, 'events.ndjson'), JSON.stringify({ type: 'session', timestamp: at(D1, 45), agent: 'Developer', task: 'by hand', outcome: 'success' }) + '\n')
|
|
679
|
+
const all = readAllSessions(root)
|
|
680
|
+
expect(all.map((s) => [s.source, s.task])).toEqual([['convoy', 'b'], ['log', 'by hand'], ['convoy', 'a']])
|
|
681
|
+
expect(all[1]).toMatchObject({ convoy_id: null, agent: 'Developer' })
|
|
682
|
+
expect(readEngineSessions(root, 'r2')).toEqual([])
|
|
683
|
+
expect(readAllSessions(root, 2)).toHaveLength(2)
|
|
684
|
+
})
|
|
685
|
+
})
|