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