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
|
@@ -65,6 +65,16 @@ function makeSpec(specOverrides = {}, taskOverrides = [{}]) {
|
|
|
65
65
|
...specOverrides,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
+
/** A non-terminal output stream that remembers what the engine printed. */
|
|
69
|
+
function captureOutput() {
|
|
70
|
+
const chunks = [];
|
|
71
|
+
return {
|
|
72
|
+
stream: { isTTY: false, write: (s) => { chunks.push(s); return true; } },
|
|
73
|
+
// Colour codes stripped, so assertions read like the terminal.
|
|
74
|
+
// eslint-disable-next-line no-control-regex
|
|
75
|
+
text: () => chunks.join('').replace(/\x1b\[[0-9;]*m/g, ''),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
68
78
|
/** Wraps createConvoyEngine with a default no-op _ensureBranch mock so tests never
|
|
69
79
|
* run real git branch operations. Callers can override _ensureBranch if needed. */
|
|
70
80
|
function makeEngine(opts) {
|
|
@@ -73,6 +83,8 @@ function makeEngine(opts) {
|
|
|
73
83
|
basePath: tmpDir, // ditto for the .opencastle/ ledgers
|
|
74
84
|
_ensureBranch: vi.fn().mockResolvedValue(undefined),
|
|
75
85
|
_convoyWorktreeDir: null,
|
|
86
|
+
handleSignals: false,
|
|
87
|
+
output: captureOutput().stream,
|
|
76
88
|
...opts,
|
|
77
89
|
});
|
|
78
90
|
}
|
|
@@ -145,7 +157,9 @@ describe('single task failure', () => {
|
|
|
145
157
|
expect(result.summary.failed).toBe(1);
|
|
146
158
|
expect(result.summary.done).toBe(0);
|
|
147
159
|
});
|
|
148
|
-
it('
|
|
160
|
+
it('leaves a session that already exited alone', async () => {
|
|
161
|
+
// kill() is for a session still running — a timeout or Ctrl+C. The old
|
|
162
|
+
// engine also called it after every failure, on a process already gone.
|
|
149
163
|
const adapter = makeAdapter();
|
|
150
164
|
adapter.execute.mockResolvedValue({ success: false, output: 'boom', exitCode: 1 });
|
|
151
165
|
const engine = makeEngine({
|
|
@@ -157,7 +171,26 @@ describe('single task failure', () => {
|
|
|
157
171
|
_mergeQueue: makeMergeQueue(),
|
|
158
172
|
});
|
|
159
173
|
await engine.run();
|
|
160
|
-
expect(adapter.kill).
|
|
174
|
+
expect(adapter.kill).not.toHaveBeenCalled();
|
|
175
|
+
});
|
|
176
|
+
it('prints the first line of the reason on the ✗ line', async () => {
|
|
177
|
+
const adapter = makeAdapter();
|
|
178
|
+
adapter.execute.mockResolvedValue({ success: false, output: 'TypeError: x is undefined\n at foo (a.ts:1)', exitCode: 1 });
|
|
179
|
+
const out = captureOutput();
|
|
180
|
+
const engine = makeEngine({
|
|
181
|
+
spec: makeSpec({}, [{ id: 'task-1', max_retries: 0 }]),
|
|
182
|
+
specYaml: 'name: test',
|
|
183
|
+
adapter,
|
|
184
|
+
dbPath,
|
|
185
|
+
output: out.stream,
|
|
186
|
+
_worktreeManager: makeWorktreeManager(),
|
|
187
|
+
_mergeQueue: makeMergeQueue(),
|
|
188
|
+
});
|
|
189
|
+
await engine.run();
|
|
190
|
+
const line = out.text().split('\n').find(l => l.includes('✗') && l.includes('[task-1]'));
|
|
191
|
+
expect(line).toContain('failed');
|
|
192
|
+
expect(line).toContain('TypeError: x is undefined');
|
|
193
|
+
expect(line).not.toContain('at foo');
|
|
161
194
|
});
|
|
162
195
|
});
|
|
163
196
|
// ── 3. Two-phase DAG ─────────────────────────────────────────────────────────
|
|
@@ -311,7 +344,9 @@ describe('on_failure:stop', () => {
|
|
|
311
344
|
expect(byId['task-b']).toBe('skipped');
|
|
312
345
|
expect(byId['task-c']).toBe('skipped');
|
|
313
346
|
});
|
|
314
|
-
it('
|
|
347
|
+
it('still retries a task up to max_retries — stop is about what happens after it fails for good', async () => {
|
|
348
|
+
// The spec builder's default was `stop`, and it used to turn off every
|
|
349
|
+
// retry in every generated plan.
|
|
315
350
|
const adapter = makeAdapter();
|
|
316
351
|
adapter.execute.mockResolvedValue({ success: false, output: 'fail', exitCode: 1 });
|
|
317
352
|
const spec = makeSpec({ on_failure: 'stop' }, [{ id: 'task-1', max_retries: 3 }]);
|
|
@@ -324,8 +359,35 @@ describe('on_failure:stop', () => {
|
|
|
324
359
|
_mergeQueue: makeMergeQueue(),
|
|
325
360
|
});
|
|
326
361
|
await engine.run();
|
|
327
|
-
|
|
328
|
-
|
|
362
|
+
expect(adapter.execute).toHaveBeenCalledTimes(4);
|
|
363
|
+
});
|
|
364
|
+
it('lets running tasks finish and starts nothing new once a task has failed for good', async () => {
|
|
365
|
+
const started = [];
|
|
366
|
+
const adapter = makeAdapter();
|
|
367
|
+
adapter.execute.mockImplementation(async (task) => {
|
|
368
|
+
started.push(task.id);
|
|
369
|
+
if (task.id === 'a-fails')
|
|
370
|
+
return { success: false, output: 'nope', exitCode: 1 };
|
|
371
|
+
await new Promise(r => setTimeout(r, 60));
|
|
372
|
+
return { success: true, output: 'ok', exitCode: 0 };
|
|
373
|
+
});
|
|
374
|
+
// Two slots: `fails` and `slow` start together; `later` is queued behind them.
|
|
375
|
+
const spec = makeSpec({ on_failure: 'stop', concurrency: 2 }, [
|
|
376
|
+
{ id: 'a-fails' },
|
|
377
|
+
{ id: 'b-slow' },
|
|
378
|
+
{ id: 'c-later' },
|
|
379
|
+
]);
|
|
380
|
+
const engine = makeEngine({
|
|
381
|
+
spec, specYaml: 'name: test', adapter, dbPath,
|
|
382
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
383
|
+
});
|
|
384
|
+
const result = await engine.run();
|
|
385
|
+
expect(started.sort()).toEqual(['a-fails', 'b-slow']);
|
|
386
|
+
const store = createConvoyStore(dbPath);
|
|
387
|
+
const byId = Object.fromEntries(store.getTasksByConvoy(result.convoyId).map(t => [t.id, t.status]));
|
|
388
|
+
store.close();
|
|
389
|
+
expect(byId).toEqual({ 'a-fails': 'failed', 'b-slow': 'done', 'c-later': 'skipped' });
|
|
390
|
+
expect(result.status).toBe('failed');
|
|
329
391
|
});
|
|
330
392
|
});
|
|
331
393
|
// ── 6. Task retry ─────────────────────────────────────────────────────────────
|
|
@@ -667,7 +729,8 @@ describe('worktree lifecycle (non-copilot)', () => {
|
|
|
667
729
|
expect(mergeQueue.merge).not.toHaveBeenCalled();
|
|
668
730
|
expect(wtManager.remove).toHaveBeenCalledOnce();
|
|
669
731
|
});
|
|
670
|
-
it('
|
|
732
|
+
it('fails the task, never running it in the user checkout, when worktree creation throws', async () => {
|
|
733
|
+
// It used to fall back to running the agent in basePath — the user's own tree.
|
|
671
734
|
const adapter = makeAdapter('developer');
|
|
672
735
|
const wtManager = makeWorktreeManager();
|
|
673
736
|
wtManager.create.mockRejectedValue(new Error('git worktree unavailable'));
|
|
@@ -680,33 +743,48 @@ describe('worktree lifecycle (non-copilot)', () => {
|
|
|
680
743
|
_worktreeManager: wtManager,
|
|
681
744
|
_mergeQueue: mergeQueue,
|
|
682
745
|
});
|
|
683
|
-
// Task should still succeed even without a worktree
|
|
684
746
|
const result = await engine.run();
|
|
685
|
-
expect(result.status).toBe('
|
|
686
|
-
expect(adapter.execute).
|
|
747
|
+
expect(result.status).toBe('failed');
|
|
748
|
+
expect(adapter.execute).not.toHaveBeenCalled();
|
|
687
749
|
});
|
|
688
|
-
it('task
|
|
750
|
+
it('fails the task and keeps its branch when the merge throws', async () => {
|
|
751
|
+
// A merge error used to be logged under --verbose, set `merged = true`, and
|
|
752
|
+
// delete the branch: the task read "done" and its work was gone.
|
|
689
753
|
const adapter = makeAdapter('developer');
|
|
690
754
|
const wtManager = makeWorktreeManager();
|
|
691
755
|
const mergeQueue = makeMergeQueue();
|
|
692
|
-
mergeQueue.merge.mockRejectedValue(new Error('
|
|
756
|
+
mergeQueue.merge.mockRejectedValue(new Error('cannot lock ref HEAD'));
|
|
757
|
+
const out = captureOutput();
|
|
693
758
|
const engine = makeEngine({
|
|
694
759
|
spec: makeSpec(),
|
|
695
760
|
specYaml: 'name: test',
|
|
696
761
|
adapter,
|
|
697
762
|
dbPath,
|
|
763
|
+
output: out.stream,
|
|
698
764
|
_worktreeManager: wtManager,
|
|
699
765
|
_mergeQueue: mergeQueue,
|
|
700
766
|
});
|
|
701
767
|
const result = await engine.run();
|
|
702
|
-
|
|
703
|
-
expect(
|
|
704
|
-
|
|
768
|
+
expect(result.status).toBe('failed');
|
|
769
|
+
expect(wtManager.remove).toHaveBeenCalledWith('/tmp/worktree-mock', { keepBranch: true });
|
|
770
|
+
const store = createConvoyStore(dbPath);
|
|
771
|
+
const task = store.getTask('task-1', result.convoyId);
|
|
772
|
+
const events = store.getEvents(result.convoyId);
|
|
773
|
+
store.close();
|
|
774
|
+
expect(task.status).toBe('failed');
|
|
775
|
+
expect(task.branch).toMatch(/^convoy-/);
|
|
776
|
+
expect(result.keptBranches).toEqual([{ taskId: 'task-1', branch: task.branch }]);
|
|
777
|
+
const mergeFailed = events.find(e => e.type === 'merge_failed');
|
|
778
|
+
expect(JSON.parse(mergeFailed.data)).toMatchObject({ branch: task.branch, error: 'cannot lock ref HEAD' });
|
|
779
|
+
// Said where the person will see it, not only under --verbose.
|
|
780
|
+
expect(out.text()).toContain('cannot lock ref HEAD');
|
|
781
|
+
expect(out.text()).toContain(task.branch);
|
|
705
782
|
});
|
|
706
783
|
});
|
|
707
|
-
// ── 10. Copilot
|
|
784
|
+
// ── 10. Copilot gets a worktree like every runtime ────────────────────────────
|
|
708
785
|
describe('copilot adapter', () => {
|
|
709
|
-
it('
|
|
786
|
+
it('runs in a worktree and is merged like any other runtime', async () => {
|
|
787
|
+
// Copilot used to skip worktrees and work in the shared directory, never merged.
|
|
710
788
|
const adapter = makeAdapter('copilot');
|
|
711
789
|
const wtManager = makeWorktreeManager();
|
|
712
790
|
const mergeQueue = makeMergeQueue();
|
|
@@ -720,9 +798,9 @@ describe('copilot adapter', () => {
|
|
|
720
798
|
});
|
|
721
799
|
const result = await engine.run();
|
|
722
800
|
expect(result.status).toBe('done');
|
|
723
|
-
expect(wtManager.create).
|
|
724
|
-
expect(mergeQueue.merge).
|
|
725
|
-
expect(
|
|
801
|
+
expect(wtManager.create).toHaveBeenCalledOnce();
|
|
802
|
+
expect(mergeQueue.merge).toHaveBeenCalledOnce();
|
|
803
|
+
expect(adapter.execute.mock.calls[0][1]).toMatchObject({ cwd: '/tmp/worktree-mock' });
|
|
726
804
|
});
|
|
727
805
|
});
|
|
728
806
|
// ── 11. Timeout handling ──────────────────────────────────────────────────────
|
|
@@ -747,7 +825,6 @@ describe('timeout handling', () => {
|
|
|
747
825
|
const result = await engine.run();
|
|
748
826
|
expect(result.status).toBe('failed');
|
|
749
827
|
expect(result.summary.timedOut).toBe(1);
|
|
750
|
-
expect(adapter.kill).toHaveBeenCalledOnce();
|
|
751
828
|
});
|
|
752
829
|
it('retries a timed-out task when retries remain', async () => {
|
|
753
830
|
const adapter = makeAdapter();
|
|
@@ -772,7 +849,7 @@ describe('timeout handling', () => {
|
|
|
772
849
|
expect(result.status).toBe('done');
|
|
773
850
|
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
774
851
|
});
|
|
775
|
-
it('
|
|
852
|
+
it('retries a timed-out task under on_failure: stop too', async () => {
|
|
776
853
|
const adapter = makeAdapter();
|
|
777
854
|
adapter.execute.mockResolvedValue({
|
|
778
855
|
_timedOut: true,
|
|
@@ -790,7 +867,7 @@ describe('timeout handling', () => {
|
|
|
790
867
|
});
|
|
791
868
|
const result = await engine.run();
|
|
792
869
|
expect(result.summary.timedOut).toBe(1);
|
|
793
|
-
expect(adapter.execute).
|
|
870
|
+
expect(adapter.execute).toHaveBeenCalledTimes(3);
|
|
794
871
|
});
|
|
795
872
|
});
|
|
796
873
|
// ── 12. Adapter without kill method ──────────────────────────────────────────
|
|
@@ -991,38 +1068,6 @@ describe('verbose mode', () => {
|
|
|
991
1068
|
const result = await engine.run();
|
|
992
1069
|
expect(result.status).toBe('done');
|
|
993
1070
|
});
|
|
994
|
-
it('logs verbose warning when worktree creation fails', async () => {
|
|
995
|
-
const adapter = makeAdapter('developer');
|
|
996
|
-
const wtManager = makeWorktreeManager();
|
|
997
|
-
wtManager.create.mockRejectedValue(new Error('no worktrees'));
|
|
998
|
-
const engine = makeEngine({
|
|
999
|
-
spec: makeSpec({}, [{ id: 'task-1' }]),
|
|
1000
|
-
specYaml: 'name: test',
|
|
1001
|
-
adapter,
|
|
1002
|
-
verbose: true,
|
|
1003
|
-
dbPath,
|
|
1004
|
-
_worktreeManager: wtManager,
|
|
1005
|
-
_mergeQueue: makeMergeQueue(),
|
|
1006
|
-
});
|
|
1007
|
-
const result = await engine.run();
|
|
1008
|
-
expect(result.status).toBe('done');
|
|
1009
|
-
});
|
|
1010
|
-
it('logs verbose warning when merge fails', async () => {
|
|
1011
|
-
const adapter = makeAdapter('developer');
|
|
1012
|
-
const mergeQueue = makeMergeQueue();
|
|
1013
|
-
mergeQueue.merge.mockRejectedValue(new Error('merge conflict'));
|
|
1014
|
-
const engine = makeEngine({
|
|
1015
|
-
spec: makeSpec({}, [{ id: 'task-1' }]),
|
|
1016
|
-
specYaml: 'name: test',
|
|
1017
|
-
adapter,
|
|
1018
|
-
verbose: true,
|
|
1019
|
-
dbPath,
|
|
1020
|
-
_worktreeManager: makeWorktreeManager(),
|
|
1021
|
-
_mergeQueue: mergeQueue,
|
|
1022
|
-
});
|
|
1023
|
-
const result = await engine.run();
|
|
1024
|
-
expect(result.status).toBe('done');
|
|
1025
|
-
});
|
|
1026
1071
|
});
|
|
1027
1072
|
// ── 16. msToTimeout branch coverage ──────────────────────────────────────────
|
|
1028
1073
|
describe('msToTimeout — timeout string representation', () => {
|
|
@@ -1108,11 +1153,10 @@ describe('per-task adapter resolution', () => {
|
|
|
1108
1153
|
expect(adapter.execute).toHaveBeenCalledOnce();
|
|
1109
1154
|
expect(getAdapter).not.toHaveBeenCalled();
|
|
1110
1155
|
});
|
|
1111
|
-
it('
|
|
1156
|
+
it('treats adapter: auto as the run’s own runtime, without detecting again', async () => {
|
|
1157
|
+
// `auto` used to re-run detection for every task and could land on a
|
|
1158
|
+
// runtime the user never chose.
|
|
1112
1159
|
const mainAdapter = makeAdapter('test');
|
|
1113
|
-
const autoAdapter = makeAdapter('claude-code');
|
|
1114
|
-
vi.mocked(detectAdapter).mockResolvedValue('claude-code');
|
|
1115
|
-
vi.mocked(getAdapter).mockResolvedValue(autoAdapter);
|
|
1116
1160
|
const spec = makeSpec({}, [{ adapter: 'auto' }]);
|
|
1117
1161
|
const engine = makeEngine({
|
|
1118
1162
|
spec,
|
|
@@ -1123,10 +1167,26 @@ describe('per-task adapter resolution', () => {
|
|
|
1123
1167
|
_mergeQueue: makeMergeQueue(),
|
|
1124
1168
|
});
|
|
1125
1169
|
await engine.run();
|
|
1126
|
-
expect(detectAdapter).toHaveBeenCalled();
|
|
1127
|
-
expect(getAdapter).
|
|
1128
|
-
expect(
|
|
1129
|
-
|
|
1170
|
+
expect(detectAdapter).not.toHaveBeenCalled();
|
|
1171
|
+
expect(getAdapter).not.toHaveBeenCalled();
|
|
1172
|
+
expect(mainAdapter.execute).toHaveBeenCalledOnce();
|
|
1173
|
+
});
|
|
1174
|
+
it('refuses an unknown per-task runtime before anything runs or is recorded', async () => {
|
|
1175
|
+
vi.mocked(getAdapter).mockRejectedValue(new Error('Unknown adapter "claud"'));
|
|
1176
|
+
const adapter = makeAdapter('test');
|
|
1177
|
+
const engine = makeEngine({
|
|
1178
|
+
spec: makeSpec({}, [{ id: 'a' }, { id: 'b', adapter: 'claud' }]),
|
|
1179
|
+
specYaml: 'name: test',
|
|
1180
|
+
adapter,
|
|
1181
|
+
dbPath,
|
|
1182
|
+
_worktreeManager: makeWorktreeManager(),
|
|
1183
|
+
_mergeQueue: makeMergeQueue(),
|
|
1184
|
+
});
|
|
1185
|
+
await expect(engine.run()).rejects.toThrow('Unknown adapter "claud"');
|
|
1186
|
+
expect(adapter.execute).not.toHaveBeenCalled();
|
|
1187
|
+
const store = createConvoyStore(dbPath);
|
|
1188
|
+
expect(store.getLatestConvoy()).toBeUndefined();
|
|
1189
|
+
store.close();
|
|
1130
1190
|
});
|
|
1131
1191
|
it('stores per-task adapter name in worker record', async () => {
|
|
1132
1192
|
const altAdapter = makeAdapter('alt-adapter');
|
|
@@ -1343,7 +1403,125 @@ describe('cost tracking', () => {
|
|
|
1343
1403
|
_mergeQueue: makeMergeQueue(),
|
|
1344
1404
|
});
|
|
1345
1405
|
const result = await engine.run();
|
|
1346
|
-
|
|
1406
|
+
// No cost reported and no model named: the tokens are real, the cost is
|
|
1407
|
+
// unknown, and the total says it is incomplete.
|
|
1408
|
+
expect(result.cost).toEqual({ total_tokens: 75, estimated: true });
|
|
1409
|
+
});
|
|
1410
|
+
it('records what the runtime reported: cost, model and cache tokens', async () => {
|
|
1411
|
+
const adapter = makeAdapter('claude');
|
|
1412
|
+
adapter.execute.mockResolvedValue({
|
|
1413
|
+
success: true,
|
|
1414
|
+
output: 'ok',
|
|
1415
|
+
exitCode: 0,
|
|
1416
|
+
usage: { prompt_tokens: 45_000, completion_tokens: 812, total_tokens: 45_812, cache_read_tokens: 40_000, cache_write_tokens: 4_000 },
|
|
1417
|
+
costUsd: 0.1234,
|
|
1418
|
+
model: 'claude-sonnet-4-6',
|
|
1419
|
+
});
|
|
1420
|
+
const engine = makeEngine({
|
|
1421
|
+
spec: makeSpec(), specYaml: 'name: test', adapter, dbPath,
|
|
1422
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1423
|
+
});
|
|
1424
|
+
const result = await engine.run();
|
|
1425
|
+
const store = createConvoyStore(dbPath);
|
|
1426
|
+
const task = store.getTasksByConvoy(result.convoyId)[0];
|
|
1427
|
+
const convoy = store.getConvoy(result.convoyId);
|
|
1428
|
+
store.close();
|
|
1429
|
+
expect(task).toMatchObject({
|
|
1430
|
+
total_tokens: 45_812,
|
|
1431
|
+
cache_read_tokens: 40_000,
|
|
1432
|
+
cache_write_tokens: 4_000,
|
|
1433
|
+
cost_usd: 0.1234,
|
|
1434
|
+
cost_estimated: 0,
|
|
1435
|
+
model: 'claude-sonnet-4-6',
|
|
1436
|
+
});
|
|
1437
|
+
expect(convoy.total_cost_usd).toBeCloseTo(0.1234);
|
|
1438
|
+
expect(convoy.cost_estimated).toBe(0);
|
|
1439
|
+
expect(convoy.adapter).toBe('claude');
|
|
1440
|
+
expect(result.cost).toEqual({ total_tokens: 45_812, total_cost_usd: 0.1234, estimated: false });
|
|
1441
|
+
});
|
|
1442
|
+
it('never prices by the adapter’s name, and flags an estimate as one', async () => {
|
|
1443
|
+
// "claude" is a runtime, not a model; pricing it as Sonnet produced figures
|
|
1444
|
+
// that looked measured and were not.
|
|
1445
|
+
const adapter = makeAdapter('claude');
|
|
1446
|
+
const engine = makeEngine({
|
|
1447
|
+
spec: makeSpec(), specYaml: 'name: test', adapter, dbPath,
|
|
1448
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1449
|
+
});
|
|
1450
|
+
const result = await engine.run();
|
|
1451
|
+
const store = createConvoyStore(dbPath);
|
|
1452
|
+
const task = store.getTasksByConvoy(result.convoyId)[0];
|
|
1453
|
+
const convoy = store.getConvoy(result.convoyId);
|
|
1454
|
+
store.close();
|
|
1455
|
+
expect(task.model).toBeNull();
|
|
1456
|
+
expect(task.cost_usd).toBeNull();
|
|
1457
|
+
expect(task.cost_estimated).toBe(1);
|
|
1458
|
+
expect(task.total_tokens).toBeGreaterThan(0);
|
|
1459
|
+
expect(convoy.cost_estimated).toBe(1);
|
|
1460
|
+
});
|
|
1461
|
+
it('prices the model it was asked for when the runtime reports tokens but no cost — marked estimated', async () => {
|
|
1462
|
+
const adapter = makeAdapter('codex');
|
|
1463
|
+
adapter.execute.mockResolvedValue({
|
|
1464
|
+
success: true, output: 'ok', exitCode: 0,
|
|
1465
|
+
usage: { prompt_tokens: 1_000_000, completion_tokens: 0, total_tokens: 1_000_000 },
|
|
1466
|
+
});
|
|
1467
|
+
const engine = makeEngine({
|
|
1468
|
+
spec: makeSpec({}, [{ id: 'task-1', model: 'gpt-4o' }]), specYaml: 'name: test', adapter, dbPath,
|
|
1469
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1470
|
+
});
|
|
1471
|
+
const result = await engine.run();
|
|
1472
|
+
const store = createConvoyStore(dbPath);
|
|
1473
|
+
const task = store.getTasksByConvoy(result.convoyId)[0];
|
|
1474
|
+
store.close();
|
|
1475
|
+
expect(task.cost_usd).toBeCloseTo(2.5);
|
|
1476
|
+
expect(task.cost_estimated).toBe(1);
|
|
1477
|
+
// The model is handed to the runtime as well.
|
|
1478
|
+
expect(adapter.execute.mock.calls[0][1]).toMatchObject({ model: 'gpt-4o' });
|
|
1479
|
+
});
|
|
1480
|
+
it('runs each agent on the runtime\'s model for its tier when the spec names none', async () => {
|
|
1481
|
+
const adapter = makeAdapter('claude');
|
|
1482
|
+
adapter.tierModels = { premium: 'opus', standard: 'sonnet', economy: 'haiku' };
|
|
1483
|
+
const engine = makeEngine({
|
|
1484
|
+
spec: makeSpec({}, [
|
|
1485
|
+
{ id: 'build', agent: 'developer' },
|
|
1486
|
+
{ id: 'design', agent: 'architect' },
|
|
1487
|
+
{ id: 'docs', agent: 'writer' },
|
|
1488
|
+
{ id: 'pinned', agent: 'developer', model: 'opus' },
|
|
1489
|
+
]),
|
|
1490
|
+
specYaml: 'name: test', adapter, dbPath,
|
|
1491
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1492
|
+
});
|
|
1493
|
+
await engine.run();
|
|
1494
|
+
const modelFor = (id) => adapter.execute.mock.calls.find((c) => c[0].id === id)?.[1]?.model;
|
|
1495
|
+
expect(modelFor('build')).toBe('sonnet');
|
|
1496
|
+
expect(modelFor('design')).toBe('opus');
|
|
1497
|
+
expect(modelFor('docs')).toBe('haiku');
|
|
1498
|
+
// A model the spec names always wins.
|
|
1499
|
+
expect(modelFor('pinned')).toBe('opus');
|
|
1500
|
+
});
|
|
1501
|
+
it('passes no model at all when the runtime declares no tier models', async () => {
|
|
1502
|
+
const adapter = makeAdapter('codex');
|
|
1503
|
+
const engine = makeEngine({
|
|
1504
|
+
spec: makeSpec({}, [{ id: 'build', agent: 'developer' }]), specYaml: 'name: test', adapter, dbPath,
|
|
1505
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1506
|
+
});
|
|
1507
|
+
await engine.run();
|
|
1508
|
+
expect(adapter.execute.mock.calls[0][1]).not.toHaveProperty('model');
|
|
1509
|
+
});
|
|
1510
|
+
it('adds up every attempt, not only the last', async () => {
|
|
1511
|
+
const adapter = makeAdapter();
|
|
1512
|
+
adapter.execute
|
|
1513
|
+
.mockResolvedValueOnce({ success: false, output: 'no', exitCode: 1, usage: { total_tokens: 100 }, costUsd: 0.01 })
|
|
1514
|
+
.mockResolvedValueOnce({ success: true, output: 'ok', exitCode: 0, usage: { total_tokens: 50 }, costUsd: 0.02 });
|
|
1515
|
+
const engine = makeEngine({
|
|
1516
|
+
spec: makeSpec({}, [{ id: 'task-1', max_retries: 1 }]), specYaml: 'name: test', adapter, dbPath,
|
|
1517
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
1518
|
+
});
|
|
1519
|
+
const result = await engine.run();
|
|
1520
|
+
const store = createConvoyStore(dbPath);
|
|
1521
|
+
const task = store.getTasksByConvoy(result.convoyId)[0];
|
|
1522
|
+
store.close();
|
|
1523
|
+
expect(task.total_tokens).toBe(150);
|
|
1524
|
+
expect(task.cost_usd).toBeCloseTo(0.03);
|
|
1347
1525
|
});
|
|
1348
1526
|
it('includes estimated cost in ConvoyResult when adapter returns no usage data', async () => {
|
|
1349
1527
|
const adapter = makeAdapter();
|
|
@@ -1409,123 +1587,104 @@ describe('cost tracking', () => {
|
|
|
1409
1587
|
});
|
|
1410
1588
|
// ── 22. Progress reporting (always-on output) ─────────────────────────────────
|
|
1411
1589
|
describe('progress reporting', () => {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
beforeEach(() => {
|
|
1415
|
-
writtenChunks = [];
|
|
1416
|
-
stdoutSpy = vi.spyOn(process.stdout, 'write').mockImplementation((data) => {
|
|
1417
|
-
writtenChunks.push(String(data));
|
|
1418
|
-
return true;
|
|
1419
|
-
});
|
|
1420
|
-
});
|
|
1421
|
-
afterEach(() => {
|
|
1422
|
-
stdoutSpy.mockRestore();
|
|
1423
|
-
});
|
|
1424
|
-
it('prints task start message without verbose flag', async () => {
|
|
1425
|
-
const adapter = makeAdapter();
|
|
1426
|
-
const engine = makeEngine({
|
|
1427
|
-
spec: makeSpec(),
|
|
1428
|
-
specYaml: 'name: test',
|
|
1429
|
-
adapter,
|
|
1430
|
-
dbPath,
|
|
1431
|
-
_worktreeManager: makeWorktreeManager(),
|
|
1432
|
-
_mergeQueue: makeMergeQueue(),
|
|
1433
|
-
});
|
|
1434
|
-
await engine.run();
|
|
1435
|
-
const written = writtenChunks.join('');
|
|
1436
|
-
expect(written).toContain('[task-1]');
|
|
1437
|
-
expect(written).toMatch(/▶/);
|
|
1438
|
-
});
|
|
1439
|
-
it('prints task completion with counter', async () => {
|
|
1440
|
-
const adapter = makeAdapter();
|
|
1441
|
-
const engine = makeEngine({
|
|
1442
|
-
spec: makeSpec(),
|
|
1443
|
-
specYaml: 'name: test',
|
|
1444
|
-
adapter,
|
|
1445
|
-
dbPath,
|
|
1446
|
-
_worktreeManager: makeWorktreeManager(),
|
|
1447
|
-
_mergeQueue: makeMergeQueue(),
|
|
1448
|
-
});
|
|
1449
|
-
await engine.run();
|
|
1450
|
-
const written = writtenChunks.join('');
|
|
1451
|
-
expect(written).toContain('[1/1]');
|
|
1452
|
-
expect(written).toMatch(/✓/);
|
|
1453
|
-
});
|
|
1454
|
-
it('prints task failure with counter', async () => {
|
|
1455
|
-
const adapter = makeAdapter();
|
|
1456
|
-
adapter.execute.mockResolvedValue({ success: false, output: 'boom', exitCode: 1 });
|
|
1457
|
-
const engine = makeEngine({
|
|
1458
|
-
spec: makeSpec({}, [{ id: 'task-1', max_retries: 0 }]),
|
|
1459
|
-
specYaml: 'name: test',
|
|
1460
|
-
adapter,
|
|
1461
|
-
dbPath,
|
|
1462
|
-
_worktreeManager: makeWorktreeManager(),
|
|
1463
|
-
_mergeQueue: makeMergeQueue(),
|
|
1464
|
-
});
|
|
1465
|
-
await engine.run();
|
|
1466
|
-
const written = writtenChunks.join('');
|
|
1467
|
-
expect(written).toContain('[1/1]');
|
|
1468
|
-
expect(written).toMatch(/✗/);
|
|
1469
|
-
});
|
|
1470
|
-
it('prints phase headers when tasks span multiple phases', async () => {
|
|
1471
|
-
const adapter = makeAdapter();
|
|
1472
|
-
const spec = makeSpec({}, [
|
|
1473
|
-
{ id: 'task-a', depends_on: [] },
|
|
1474
|
-
{ id: 'task-b', depends_on: ['task-a'] },
|
|
1475
|
-
]);
|
|
1476
|
-
const engine = makeEngine({
|
|
1590
|
+
function engineWith(out, spec, adapter) {
|
|
1591
|
+
return makeEngine({
|
|
1477
1592
|
spec,
|
|
1478
1593
|
specYaml: 'name: test',
|
|
1479
1594
|
adapter,
|
|
1480
1595
|
dbPath,
|
|
1596
|
+
output: out.stream,
|
|
1481
1597
|
_worktreeManager: makeWorktreeManager(),
|
|
1482
1598
|
_mergeQueue: makeMergeQueue(),
|
|
1483
1599
|
});
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1600
|
+
}
|
|
1601
|
+
it('prints a start line and a finish line for each task', async () => {
|
|
1602
|
+
const out = captureOutput();
|
|
1603
|
+
await engineWith(out, makeSpec(), makeAdapter()).run();
|
|
1604
|
+
const text = out.text();
|
|
1605
|
+
expect(text).toMatch(/▶ \[task-1\] developer/);
|
|
1606
|
+
expect(text).toMatch(/✓ \[task-1\] \(\d+ms\)/);
|
|
1607
|
+
});
|
|
1608
|
+
it('does not print phases as barriers', async () => {
|
|
1609
|
+
const out = captureOutput();
|
|
1610
|
+
const spec = makeSpec({}, [{ id: 'task-a' }, { id: 'task-b', depends_on: ['task-a'] }]);
|
|
1611
|
+
await engineWith(out, spec, makeAdapter()).run();
|
|
1612
|
+
expect(out.text()).not.toContain('Phase 1:');
|
|
1613
|
+
});
|
|
1614
|
+
it('prints no internal noise about missing output contracts', async () => {
|
|
1615
|
+
const out = captureOutput();
|
|
1616
|
+
await engineWith(out, makeSpec(), makeAdapter()).run();
|
|
1617
|
+
expect(out.text()).not.toContain('__contract_block');
|
|
1618
|
+
expect(out.text()).not.toContain('contract violation');
|
|
1619
|
+
});
|
|
1620
|
+
it('ends with the convoy id, the branch, the totals and the log path', async () => {
|
|
1621
|
+
const out = captureOutput();
|
|
1622
|
+
const adapter = makeAdapter();
|
|
1623
|
+
adapter.execute.mockResolvedValue({ success: true, output: 'ok', exitCode: 0, usage: { total_tokens: 1500 } });
|
|
1624
|
+
const result = await engineWith(out, makeSpec({ branch: 'feat/x' }), adapter).run();
|
|
1625
|
+
const text = out.text();
|
|
1626
|
+
expect(text).toContain(`Convoy: ${result.convoyId}`);
|
|
1627
|
+
expect(text).toContain('Branch: feat/x');
|
|
1628
|
+
expect(text).toContain('Merge: git merge feat/x');
|
|
1629
|
+
expect(text).toMatch(/Spent: 1\.5K tokens \(est\.\)/);
|
|
1630
|
+
expect(text).toContain(`${result.convoyId}.ndjson`);
|
|
1631
|
+
expect(result.logPath).toBe(join(tmpDir, 'logs', 'convoys', `${result.convoyId}.ndjson`));
|
|
1632
|
+
});
|
|
1633
|
+
it('names every task that is not done, with its reason, and how to resume', async () => {
|
|
1634
|
+
const out = captureOutput();
|
|
1635
|
+
const adapter = makeAdapter();
|
|
1636
|
+
adapter.execute.mockImplementation(async (task) => task.id === 'task-a' ? { success: false, output: 'compile error in a.ts', exitCode: 2 } : { success: true, output: 'ok', exitCode: 0 });
|
|
1637
|
+
const spec = makeSpec({}, [{ id: 'task-a' }, { id: 'task-b', depends_on: ['task-a'] }]);
|
|
1638
|
+
await engineWith(out, spec, adapter).run();
|
|
1639
|
+
const text = out.text();
|
|
1640
|
+
expect(text).toContain('• task-a (failed): compile error in a.ts');
|
|
1641
|
+
expect(text).toContain('• task-b (skipped): dependency "task-a" failed');
|
|
1642
|
+
expect(text).toContain('Resume with: opencastle convoy resume');
|
|
1488
1643
|
});
|
|
1489
1644
|
it('prints gate results with pass/fail indicators', async () => {
|
|
1490
|
-
const
|
|
1645
|
+
const out = captureOutput();
|
|
1491
1646
|
const spec = makeSpec({ gates: ['echo gate-ok', 'false'] }, [{ id: 'task-1' }]);
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
expect(written).toContain('echo gate-ok');
|
|
1504
|
-
expect(written).toContain('false');
|
|
1505
|
-
});
|
|
1506
|
-
it('prints retry messages when a task fails and is retried', async () => {
|
|
1647
|
+
await engineWith(out, spec, makeAdapter()).run();
|
|
1648
|
+
const text = out.text();
|
|
1649
|
+
expect(text).toContain('Gates:');
|
|
1650
|
+
expect(text).toContain('✓ echo gate-ok');
|
|
1651
|
+
expect(text).toContain('✗ false');
|
|
1652
|
+
// The summary names the gate that failed.
|
|
1653
|
+
expect(text).toContain('Gates: 1/2 passed');
|
|
1654
|
+
expect(text).toMatch(/• false \(exit 1\)/);
|
|
1655
|
+
});
|
|
1656
|
+
it('prints retries with their reason', async () => {
|
|
1657
|
+
const out = captureOutput();
|
|
1507
1658
|
const adapter = makeAdapter();
|
|
1508
1659
|
adapter.execute
|
|
1509
|
-
.
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1660
|
+
.mockResolvedValueOnce({ success: false, output: 'flaky network', exitCode: 1 })
|
|
1661
|
+
.mockResolvedValueOnce({ success: true, output: 'ok', exitCode: 0 });
|
|
1662
|
+
await engineWith(out, makeSpec({}, [{ id: 'task-1', max_retries: 1 }]), adapter).run();
|
|
1663
|
+
expect(out.text()).toContain('⟳ [task-1] failed, retry 1/1: flaky network');
|
|
1664
|
+
});
|
|
1665
|
+
it('keeps one status line, redrawn in place, on a terminal', async () => {
|
|
1666
|
+
const chunks = [];
|
|
1667
|
+
const tty = { isTTY: true, columns: 120, write: (s) => { chunks.push(s); return true; } };
|
|
1668
|
+
const adapter = makeAdapter();
|
|
1669
|
+
adapter.execute.mockImplementation(async () => {
|
|
1670
|
+
await new Promise(r => setTimeout(r, 20));
|
|
1515
1671
|
return { success: true, output: 'ok', exitCode: 0 };
|
|
1516
1672
|
});
|
|
1517
|
-
|
|
1518
|
-
spec: makeSpec({}, [{ id: '
|
|
1673
|
+
await makeEngine({
|
|
1674
|
+
spec: makeSpec({ concurrency: 2 }, [{ id: 'build-api' }, { id: 'write-tests' }, { id: 'docs' }]),
|
|
1519
1675
|
specYaml: 'name: test',
|
|
1520
1676
|
adapter,
|
|
1521
1677
|
dbPath,
|
|
1678
|
+
output: tty,
|
|
1522
1679
|
_worktreeManager: makeWorktreeManager(),
|
|
1523
1680
|
_mergeQueue: makeMergeQueue(),
|
|
1524
|
-
});
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1527
|
-
expect(
|
|
1528
|
-
expect(
|
|
1681
|
+
}).run();
|
|
1682
|
+
// eslint-disable-next-line no-control-regex
|
|
1683
|
+
const statuses = chunks.filter(ch => ch.startsWith('\r\x1b[2K') && ch.includes('▸')).map(ch => ch.replace(/\x1b\[[0-9;]*m/g, ''));
|
|
1684
|
+
expect(statuses.length).toBeGreaterThan(0);
|
|
1685
|
+
expect(statuses.some(s => /▸ build-api, write-tests · 1 queued · 0\/3 done/.test(s))).toBe(true);
|
|
1686
|
+
// Nothing of the status line is left once the run has ended.
|
|
1687
|
+
expect(chunks.join('')).not.toMatch(/▸[^\n]*$/);
|
|
1529
1688
|
});
|
|
1530
1689
|
});
|
|
1531
1690
|
// ── 23. Gate retry mechanism ──────────────────────────────────────────────────
|
|
@@ -1589,7 +1748,8 @@ describe('gate retry mechanism', () => {
|
|
|
1589
1748
|
// The second call should be the fix task
|
|
1590
1749
|
const fixCall = adapter.execute.mock.calls[1];
|
|
1591
1750
|
expect(fixCall[0].id).toBe('gate-fix-1');
|
|
1592
|
-
expect(fixCall[0].prompt).toContain('
|
|
1751
|
+
expect(fixCall[0].prompt).toContain('These checks failed after every task was merged');
|
|
1752
|
+
expect(fixCall[0].prompt).toContain('Command: false');
|
|
1593
1753
|
// Gates still fail after fix, so final status is gate-failed
|
|
1594
1754
|
expect(result.status).toBe('gate-failed');
|
|
1595
1755
|
});
|
|
@@ -1665,29 +1825,15 @@ function makeDiffStats(overrides = {}) {
|
|
|
1665
1825
|
};
|
|
1666
1826
|
}
|
|
1667
1827
|
describe('evaluateReviewLevel', () => {
|
|
1668
|
-
it('
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
const level = evaluateReviewLevel(makeTaskRecord(), makeDiffStats({ filePaths: ['src/auth/session.ts'] }));
|
|
1674
|
-
expect(level).toBe('panel');
|
|
1675
|
-
});
|
|
1676
|
-
it('routes to panel for security/ path', () => {
|
|
1677
|
-
const level = evaluateReviewLevel(makeTaskRecord(), makeDiffStats({ filePaths: ['security/policy.ts'] }));
|
|
1678
|
-
expect(level).toBe('panel');
|
|
1679
|
-
});
|
|
1680
|
-
it('routes to panel for security-expert agent', () => {
|
|
1681
|
-
const level = evaluateReviewLevel(makeTaskRecord({ agent: 'security-expert' }), makeDiffStats());
|
|
1682
|
-
expect(level).toBe('panel');
|
|
1683
|
-
});
|
|
1684
|
-
it('routes to panel for data-engineer agent', () => {
|
|
1685
|
-
const level = evaluateReviewLevel(makeTaskRecord({ agent: 'data-engineer' }), makeDiffStats());
|
|
1686
|
-
expect(level).toBe('panel');
|
|
1828
|
+
it('never picks a panel on its own — sensitive paths get a fast review, even when small', () => {
|
|
1829
|
+
// A panel is three reviewer sessions; only a spec that asks for one gets one.
|
|
1830
|
+
for (const filePaths of [['auth/session.ts'], ['src/auth/session.ts'], ['security/policy.ts']]) {
|
|
1831
|
+
expect(evaluateReviewLevel(makeTaskRecord(), makeDiffStats({ filePaths, linesChanged: 3, filesChanged: 1 }), undefined, true)).toBe('fast');
|
|
1832
|
+
}
|
|
1687
1833
|
});
|
|
1688
|
-
it('
|
|
1689
|
-
|
|
1690
|
-
expect(
|
|
1834
|
+
it('gives sensitive agents a fast review rather than waving them through', () => {
|
|
1835
|
+
expect(evaluateReviewLevel(makeTaskRecord({ agent: 'security-expert' }), makeDiffStats())).toBe('fast');
|
|
1836
|
+
expect(evaluateReviewLevel(makeTaskRecord({ agent: 'data-engineer' }), makeDiffStats())).toBe('fast');
|
|
1691
1837
|
});
|
|
1692
1838
|
it('routes to auto-pass for writer agent', () => {
|
|
1693
1839
|
const level = evaluateReviewLevel(makeTaskRecord({ agent: 'writer' }), makeDiffStats());
|
|
@@ -1709,9 +1855,9 @@ describe('evaluateReviewLevel', () => {
|
|
|
1709
1855
|
const level = evaluateReviewLevel(makeTaskRecord({ agent: 'developer' }), makeDiffStats({ linesChanged: 50, filesChanged: 3, filePaths: ['src/Feature.tsx', 'src/Feature.test.tsx', 'src/types.ts'] }));
|
|
1710
1856
|
expect(level).toBe('fast');
|
|
1711
1857
|
});
|
|
1712
|
-
it('custom heuristics:
|
|
1713
|
-
const level = evaluateReviewLevel(makeTaskRecord(), makeDiffStats({ filePaths: ['billing/invoice.ts'] }), { panel_paths: ['billing/'] });
|
|
1714
|
-
expect(level).toBe('
|
|
1858
|
+
it('custom heuristics: panel_paths mark a path sensitive', () => {
|
|
1859
|
+
const level = evaluateReviewLevel(makeTaskRecord(), makeDiffStats({ filePaths: ['billing/invoice.ts'], linesChanged: 2, filesChanged: 1 }), { panel_paths: ['billing/'] }, true);
|
|
1860
|
+
expect(level).toBe('fast');
|
|
1715
1861
|
});
|
|
1716
1862
|
it('custom heuristics: overrides auto_pass_agents', () => {
|
|
1717
1863
|
const level = evaluateReviewLevel(makeTaskRecord({ agent: 'designer' }), makeDiffStats(), { auto_pass_agents: ['designer'] });
|
|
@@ -1732,474 +1878,166 @@ describe('review pipeline', () => {
|
|
|
1732
1878
|
wtManager = makeWorktreeManager();
|
|
1733
1879
|
mergeQueue = makeMergeQueue();
|
|
1734
1880
|
});
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
spec: makeSpec({ defaults: { review: 'none' } }, [{ review: 'none' }]),
|
|
1881
|
+
function reviewEngine(spec, runner) {
|
|
1882
|
+
return makeEngine({
|
|
1883
|
+
spec,
|
|
1739
1884
|
specYaml: 'name: test',
|
|
1740
1885
|
adapter,
|
|
1741
1886
|
dbPath,
|
|
1742
1887
|
_worktreeManager: wtManager,
|
|
1743
1888
|
_mergeQueue: mergeQueue,
|
|
1744
|
-
_reviewRunner:
|
|
1889
|
+
...(runner ? { _reviewRunner: runner } : {}),
|
|
1745
1890
|
});
|
|
1746
|
-
|
|
1891
|
+
}
|
|
1892
|
+
function readTasks(convoyId) {
|
|
1893
|
+
const store = createConvoyStore(dbPath);
|
|
1894
|
+
const tasks = store.getTasksByConvoy(convoyId);
|
|
1895
|
+
const events = store.getEvents(convoyId);
|
|
1896
|
+
store.close();
|
|
1897
|
+
return { tasks, events };
|
|
1898
|
+
}
|
|
1899
|
+
it('task with review: none — reviewer not called, task succeeds', async () => {
|
|
1900
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 100, model: 'test' });
|
|
1901
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'none' } }, [{ review: 'none' }]), runner).run();
|
|
1747
1902
|
expect(result.status).toBe('done');
|
|
1748
|
-
expect(
|
|
1903
|
+
expect(runner).not.toHaveBeenCalled();
|
|
1749
1904
|
});
|
|
1750
|
-
it('fast review
|
|
1751
|
-
const
|
|
1752
|
-
const
|
|
1753
|
-
spec: makeSpec({ defaults: { review: 'fast' } }),
|
|
1754
|
-
specYaml: 'name: test',
|
|
1755
|
-
adapter,
|
|
1756
|
-
dbPath,
|
|
1757
|
-
_worktreeManager: wtManager,
|
|
1758
|
-
_mergeQueue: mergeQueue,
|
|
1759
|
-
_reviewRunner: mockReviewRunner,
|
|
1760
|
-
});
|
|
1761
|
-
const result = await engine.run();
|
|
1905
|
+
it('fast review is one reviewer session, and a pass lets the task merge', async () => {
|
|
1906
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 50, model: 'reviewer' });
|
|
1907
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }), runner).run();
|
|
1762
1908
|
expect(result.status).toBe('done');
|
|
1763
|
-
|
|
1764
|
-
expect(
|
|
1765
|
-
expect(
|
|
1766
|
-
});
|
|
1767
|
-
it('
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
});
|
|
1773
|
-
const mockReviewRunner = vi.fn()
|
|
1774
|
-
.mockResolvedValueOnce({ verdict: 'block', feedback: 'Missing tests', tokens: 50, model: 'reviewer' }) // round 1 stage 1 → block (short-circuits)
|
|
1775
|
-
.mockResolvedValueOnce({ verdict: 'pass', feedback: '', tokens: 50, model: 'reviewer' }) // round 2 stage 1 → pass
|
|
1776
|
-
.mockResolvedValueOnce({ verdict: 'pass', feedback: '', tokens: 50, model: 'reviewer' }); // round 2 stage 2 → pass
|
|
1777
|
-
const engine = makeEngine({
|
|
1778
|
-
spec: makeSpec({ defaults: { review: 'fast' } }, [{ max_retries: 1 }]),
|
|
1779
|
-
specYaml: 'name: test',
|
|
1780
|
-
adapter,
|
|
1781
|
-
dbPath,
|
|
1782
|
-
_worktreeManager: wtManager,
|
|
1783
|
-
_mergeQueue: mergeQueue,
|
|
1784
|
-
_reviewRunner: mockReviewRunner,
|
|
1785
|
-
});
|
|
1786
|
-
const result = await engine.run();
|
|
1909
|
+
expect(runner).toHaveBeenCalledTimes(1);
|
|
1910
|
+
expect(runner).toHaveBeenCalledWith(expect.objectContaining({ agent: 'developer' }), 'fast', 'default', expect.objectContaining({ cwd: '/tmp/worktree-mock', prompt: 'Prompt for task 1', canRunReadOnly: true }));
|
|
1911
|
+
expect(mergeQueue.merge).toHaveBeenCalledOnce();
|
|
1912
|
+
});
|
|
1913
|
+
it('a block with retries left re-runs the task with the feedback and its original prompt', async () => {
|
|
1914
|
+
const runner = vi.fn()
|
|
1915
|
+
.mockResolvedValueOnce({ verdict: 'block', feedback: 'Missing tests', tokens: 50, model: 'reviewer' })
|
|
1916
|
+
.mockResolvedValueOnce({ verdict: 'pass', feedback: '', tokens: 50, model: 'reviewer' });
|
|
1917
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }, [{ max_retries: 1 }]), runner).run();
|
|
1787
1918
|
expect(result.status).toBe('done');
|
|
1788
1919
|
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
1789
|
-
|
|
1790
|
-
expect(mockReviewRunner).toHaveBeenCalledTimes(3);
|
|
1791
|
-
// Prompt on second attempt should contain feedback
|
|
1920
|
+
expect(runner).toHaveBeenCalledTimes(2);
|
|
1792
1921
|
const secondPrompt = adapter.execute.mock.calls[1][0].prompt;
|
|
1793
1922
|
expect(secondPrompt).toContain('Missing tests');
|
|
1923
|
+
expect(secondPrompt).toContain('Prompt for task 1');
|
|
1794
1924
|
});
|
|
1795
|
-
it('
|
|
1796
|
-
const
|
|
1797
|
-
const
|
|
1798
|
-
spec: makeSpec({ defaults: { review: 'fast' } }, [{ max_retries: 0 }]),
|
|
1799
|
-
specYaml: 'name: test',
|
|
1800
|
-
adapter,
|
|
1801
|
-
dbPath,
|
|
1802
|
-
_worktreeManager: wtManager,
|
|
1803
|
-
_mergeQueue: mergeQueue,
|
|
1804
|
-
_reviewRunner: mockReviewRunner,
|
|
1805
|
-
});
|
|
1806
|
-
const result = await engine.run();
|
|
1925
|
+
it('a block with no retries left ends review-blocked', async () => {
|
|
1926
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'block', feedback: 'Insecure code', tokens: 50, model: 'reviewer' });
|
|
1927
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }, [{ max_retries: 0 }]), runner).run();
|
|
1807
1928
|
expect(result.status).toBe('failed');
|
|
1808
|
-
expect(result.
|
|
1809
|
-
|
|
1810
|
-
const store = createConvoyStore(dbPath);
|
|
1811
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
1812
|
-
store.close();
|
|
1813
|
-
expect(tasks[0].status).toBe('review-blocked');
|
|
1929
|
+
expect(readTasks(result.convoyId).tasks[0].status).toBe('review-blocked');
|
|
1930
|
+
expect(mergeQueue.merge).not.toHaveBeenCalled();
|
|
1814
1931
|
});
|
|
1815
|
-
it('
|
|
1816
|
-
|
|
1817
|
-
const
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1932
|
+
it('records a review that reached no verdict as skipped — never as a pass', async () => {
|
|
1933
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'skipped', feedback: 'the reviewer gave no verdict', tokens: 30, model: null });
|
|
1934
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }), runner).run();
|
|
1935
|
+
expect(result.status).toBe('done');
|
|
1936
|
+
const { tasks, events } = readTasks(result.convoyId);
|
|
1937
|
+
expect(tasks[0].review_verdict).toBe('skipped');
|
|
1938
|
+
expect(events.some(e => e.type === 'review_verdict')).toBe(false);
|
|
1939
|
+
const skipped = events.find(e => e.type === 'review_skipped');
|
|
1940
|
+
expect(JSON.parse(skipped.data)).toEqual({ level: 'fast', reason: 'the reviewer gave no verdict' });
|
|
1941
|
+
});
|
|
1942
|
+
it('uses the default reviewer when none is injected: the task’s runtime, read-only, in its worktree', async () => {
|
|
1943
|
+
adapter.execute.mockImplementation(async (task) => task.id.endsWith('-review')
|
|
1944
|
+
? { success: true, output: 'Looks fine.\n<!-- REVIEW_VERDICT { "verdict": "pass", "issues": [] } -->', exitCode: 0, usage: { total_tokens: 900 } }
|
|
1945
|
+
: { success: true, output: 'ok', exitCode: 0 });
|
|
1946
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } })).run();
|
|
1947
|
+
expect(result.status).toBe('done');
|
|
1948
|
+
const reviewCall = adapter.execute.mock.calls.find(([t]) => t.id === 'task-1-review');
|
|
1949
|
+
expect(reviewCall[1]).toMatchObject({ cwd: '/tmp/worktree-mock', permissionMode: 'plan' });
|
|
1950
|
+
expect(reviewCall[0].prompt).toContain('Prompt for task 1');
|
|
1951
|
+
const task = readTasks(result.convoyId).tasks[0];
|
|
1952
|
+
expect(task).toMatchObject({ review_level: 'fast', review_verdict: 'pass', review_tokens: 900 });
|
|
1953
|
+
});
|
|
1954
|
+
it('panel: three reviewers, majority wins', async () => {
|
|
1955
|
+
let n = 0;
|
|
1956
|
+
const runner = vi.fn().mockImplementation(() => {
|
|
1957
|
+
n++;
|
|
1958
|
+
return Promise.resolve(n === 3
|
|
1821
1959
|
? { verdict: 'block', feedback: 'Minor issue', tokens: 30, model: 'reviewer' }
|
|
1822
1960
|
: { verdict: 'pass', feedback: '', tokens: 30, model: 'reviewer' });
|
|
1823
1961
|
});
|
|
1824
|
-
const
|
|
1825
|
-
spec: makeSpec({ defaults: { review: 'panel' } }),
|
|
1826
|
-
specYaml: 'name: test',
|
|
1827
|
-
adapter,
|
|
1828
|
-
dbPath,
|
|
1829
|
-
_worktreeManager: wtManager,
|
|
1830
|
-
_mergeQueue: mergeQueue,
|
|
1831
|
-
_reviewRunner: mockReviewRunner,
|
|
1832
|
-
});
|
|
1833
|
-
const result = await engine.run();
|
|
1962
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'panel' } }), runner).run();
|
|
1834
1963
|
expect(result.status).toBe('done');
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
: { verdict: 'pass', feedback: '', tokens: 30, model: 'reviewer' });
|
|
1847
|
-
}
|
|
1848
|
-
return Promise.resolve({ verdict: 'pass', feedback: '', tokens: 30, model: 'reviewer' });
|
|
1849
|
-
});
|
|
1850
|
-
const engine = makeEngine({
|
|
1851
|
-
spec: makeSpec({ defaults: { review: 'panel' } }, [{ max_retries: 1 }]),
|
|
1852
|
-
specYaml: 'name: test',
|
|
1853
|
-
adapter,
|
|
1854
|
-
dbPath,
|
|
1855
|
-
_worktreeManager: wtManager,
|
|
1856
|
-
_mergeQueue: mergeQueue,
|
|
1857
|
-
_reviewRunner: mockReviewRunner,
|
|
1964
|
+
expect(runner).toHaveBeenCalledTimes(3);
|
|
1965
|
+
const task = readTasks(result.convoyId).tasks[0];
|
|
1966
|
+
expect(task).toMatchObject({ review_level: 'panel', review_verdict: 'pass', review_tokens: 90, panel_attempts: 1 });
|
|
1967
|
+
});
|
|
1968
|
+
it('panel: 2/3 block → retried with the blocking feedback', async () => {
|
|
1969
|
+
let n = 0;
|
|
1970
|
+
const runner = vi.fn().mockImplementation(() => {
|
|
1971
|
+
n++;
|
|
1972
|
+
return Promise.resolve(n <= 2
|
|
1973
|
+
? { verdict: 'block', feedback: 'Critical bug', tokens: 30, model: 'reviewer' }
|
|
1974
|
+
: { verdict: 'pass', feedback: '', tokens: 30, model: 'reviewer' });
|
|
1858
1975
|
});
|
|
1859
|
-
const result = await
|
|
1976
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'panel' } }, [{ max_retries: 1 }]), runner).run();
|
|
1860
1977
|
expect(result.status).toBe('done');
|
|
1861
1978
|
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
1862
|
-
|
|
1979
|
+
expect(runner).toHaveBeenCalledTimes(6);
|
|
1863
1980
|
const secondPrompt = adapter.execute.mock.calls[1][0].prompt;
|
|
1864
|
-
expect(secondPrompt).toContain('MUST-FIX');
|
|
1865
1981
|
expect(secondPrompt).toContain('Critical bug');
|
|
1866
1982
|
});
|
|
1867
|
-
it('
|
|
1868
|
-
const
|
|
1869
|
-
const
|
|
1870
|
-
spec: makeSpec({
|
|
1871
|
-
defaults: { review: 'fast', review_budget: 100, on_review_budget_exceeded: 'skip', reviewer_model: 'r1' },
|
|
1872
|
-
tasks: [
|
|
1873
|
-
{ id: 'task-1', prompt: 'Prompt 1', agent: 'developer', timeout: '30s', depends_on: [], files: [], description: '', max_retries: 0 },
|
|
1874
|
-
{ id: 'task-2', prompt: 'Prompt 2', agent: 'developer', timeout: '30s', depends_on: ['task-1'], files: [], description: '', max_retries: 0 },
|
|
1875
|
-
],
|
|
1876
|
-
}),
|
|
1877
|
-
specYaml: 'name: test',
|
|
1878
|
-
adapter,
|
|
1879
|
-
dbPath,
|
|
1880
|
-
_worktreeManager: wtManager,
|
|
1881
|
-
_mergeQueue: mergeQueue,
|
|
1882
|
-
_reviewRunner: mockReviewRunner,
|
|
1883
|
-
});
|
|
1884
|
-
const result = await engine.run();
|
|
1885
|
-
expect(result.status).toBe('done');
|
|
1886
|
-
// first task: budget not exceeded (0 < 100), two-stage review runs (2 calls, total 400 tokens)
|
|
1887
|
-
// second task: budget exceeded (400 >= 100), review skipped
|
|
1888
|
-
expect(mockReviewRunner).toHaveBeenCalledTimes(2);
|
|
1889
|
-
});
|
|
1890
|
-
it('auto route: developer agent with empty diff → auto-pass (no reviewer call)', async () => {
|
|
1891
|
-
// Given: 'auto' review setting, developer agent, empty diff (git will fail on mock path)
|
|
1892
|
-
const mockReviewRunner = vi.fn();
|
|
1893
|
-
const engine = makeEngine({
|
|
1894
|
-
spec: makeSpec({ defaults: { review: 'auto' } }),
|
|
1895
|
-
specYaml: 'name: test',
|
|
1896
|
-
adapter,
|
|
1897
|
-
dbPath,
|
|
1898
|
-
_worktreeManager: wtManager,
|
|
1899
|
-
_mergeQueue: mergeQueue,
|
|
1900
|
-
_reviewRunner: mockReviewRunner,
|
|
1901
|
-
});
|
|
1902
|
-
const result = await engine.run();
|
|
1983
|
+
it('auto route: developer agent with an empty diff → auto-pass, no reviewer', async () => {
|
|
1984
|
+
const runner = vi.fn();
|
|
1985
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'auto' } }), runner).run();
|
|
1903
1986
|
expect(result.status).toBe('done');
|
|
1904
|
-
expect(
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
_reviewRunner: mockReviewRunner,
|
|
1916
|
-
});
|
|
1917
|
-
const result = await engine.run();
|
|
1918
|
-
const store = createConvoyStore(dbPath);
|
|
1919
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
1920
|
-
store.close();
|
|
1921
|
-
expect(tasks[0].review_tokens).toBe(154); // two-stage: 77 (stage 1) + 77 (stage 2)
|
|
1922
|
-
expect(tasks[0].review_level).toBe('fast');
|
|
1923
|
-
expect(tasks[0].review_verdict).toBe('pass');
|
|
1987
|
+
expect(runner).not.toHaveBeenCalled();
|
|
1988
|
+
expect(readTasks(result.convoyId).tasks[0]).toMatchObject({ review_level: 'auto-pass', review_verdict: 'pass', review_model: null });
|
|
1989
|
+
});
|
|
1990
|
+
it('review tokens are tracked on the task and the reviewer cost is added to it', async () => {
|
|
1991
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 77, model: 'reviewer', costUsd: 0.05 });
|
|
1992
|
+
adapter.execute.mockResolvedValue({ success: true, output: 'ok', exitCode: 0, usage: { total_tokens: 10 }, costUsd: 0.1 });
|
|
1993
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }), runner).run();
|
|
1994
|
+
const task = readTasks(result.convoyId).tasks[0];
|
|
1995
|
+
expect(task.review_tokens).toBe(77);
|
|
1996
|
+
expect(task.cost_usd).toBeCloseTo(0.15);
|
|
1997
|
+
expect(result.cost?.total_tokens).toBe(87);
|
|
1924
1998
|
});
|
|
1925
1999
|
it('review_started and review_verdict events emitted', async () => {
|
|
1926
|
-
const
|
|
1927
|
-
const
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
dbPath,
|
|
1932
|
-
_worktreeManager: wtManager,
|
|
1933
|
-
_mergeQueue: mergeQueue,
|
|
1934
|
-
_reviewRunner: mockReviewRunner,
|
|
1935
|
-
});
|
|
1936
|
-
const result = await engine.run();
|
|
1937
|
-
const store = createConvoyStore(dbPath);
|
|
1938
|
-
const events = store.getEvents(result.convoyId);
|
|
1939
|
-
store.close();
|
|
1940
|
-
const startedEvent = events.find(e => e.type === 'review_started');
|
|
1941
|
-
const verdictEvent = events.find(e => e.type === 'review_verdict');
|
|
1942
|
-
expect(startedEvent).toBeDefined();
|
|
1943
|
-
expect(verdictEvent).toBeDefined();
|
|
2000
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 10, model: 'reviewer' });
|
|
2001
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'fast' } }), runner).run();
|
|
2002
|
+
const { events } = readTasks(result.convoyId);
|
|
2003
|
+
expect(events.find(e => e.type === 'review_started')).toBeDefined();
|
|
2004
|
+
expect(events.find(e => e.type === 'review_verdict')).toBeDefined();
|
|
1944
2005
|
});
|
|
1945
2006
|
it('review sessions do NOT count against concurrency limit', async () => {
|
|
1946
|
-
|
|
1947
|
-
const
|
|
1948
|
-
const engine = makeEngine({
|
|
1949
|
-
spec: makeSpec({ concurrency: 1, defaults: { review: 'fast' } }, [{ id: 'task-1' }, { id: 'task-2' }]),
|
|
1950
|
-
specYaml: 'name: test',
|
|
1951
|
-
adapter,
|
|
1952
|
-
dbPath,
|
|
1953
|
-
_worktreeManager: wtManager,
|
|
1954
|
-
_mergeQueue: mergeQueue,
|
|
1955
|
-
_reviewRunner: mockReviewRunner,
|
|
1956
|
-
});
|
|
1957
|
-
const result = await engine.run();
|
|
2007
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 10, model: 'reviewer' });
|
|
2008
|
+
const result = await reviewEngine(makeSpec({ concurrency: 1, defaults: { review: 'fast' } }, [{ id: 'task-1' }, { id: 'task-2' }]), runner).run();
|
|
1958
2009
|
expect(result.status).toBe('done');
|
|
1959
2010
|
expect(result.summary.done).toBe(2);
|
|
1960
2011
|
});
|
|
1961
|
-
it('
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
.mockResolvedValueOnce({ verdict: 'pass', feedback: '', tokens: 35, model: 'reviewer' }); // round 2 stage 2 → pass
|
|
1966
|
-
const engine = makeEngine({
|
|
1967
|
-
spec: makeSpec({ defaults: { review: 'fast' } }, [{ id: 'task-1', max_retries: 1 }]),
|
|
1968
|
-
specYaml: 'name: test',
|
|
1969
|
-
adapter,
|
|
1970
|
-
dbPath,
|
|
1971
|
-
_worktreeManager: wtManager,
|
|
1972
|
-
_mergeQueue: mergeQueue,
|
|
1973
|
-
_reviewRunner: mockReviewRunner,
|
|
1974
|
-
});
|
|
1975
|
-
const result = await engine.run();
|
|
1976
|
-
expect(result.status).toBe('done');
|
|
1977
|
-
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
1978
|
-
// Round 1: 1 call (block short-circuits). Round 2: 2 calls (stage 1 + stage 2). Total: 3
|
|
1979
|
-
expect(mockReviewRunner).toHaveBeenCalledTimes(3);
|
|
1980
|
-
const store = createConvoyStore(dbPath);
|
|
1981
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
1982
|
-
const events = store.getEvents(result.convoyId);
|
|
1983
|
-
store.close();
|
|
1984
|
-
const task = tasks[0];
|
|
1985
|
-
expect(task.review_level).toBe('fast');
|
|
1986
|
-
expect(task.review_verdict).toBe('pass');
|
|
1987
|
-
expect(task.retries).toBe(1);
|
|
1988
|
-
const reviewStartedEvents = events.filter(e => e.type === 'review_started');
|
|
1989
|
-
const reviewVerdictEvents = events.filter(e => e.type === 'review_verdict');
|
|
1990
|
-
expect(reviewStartedEvents.length).toBe(2);
|
|
1991
|
-
expect(reviewVerdictEvents.length).toBe(2);
|
|
1992
|
-
const firstVerdict = JSON.parse(reviewVerdictEvents[0].data);
|
|
1993
|
-
const secondVerdict = JSON.parse(reviewVerdictEvents[1].data);
|
|
1994
|
-
expect(firstVerdict['verdict']).toBe('block');
|
|
1995
|
-
expect(secondVerdict['verdict']).toBe('pass');
|
|
1996
|
-
});
|
|
1997
|
-
it('panel flow: 2/3 BLOCK first round → retry → 3/3 PASS second round → done', async () => {
|
|
1998
|
-
let reviewCallCount = 0;
|
|
1999
|
-
const mockReviewRunner = vi.fn().mockImplementation(() => {
|
|
2000
|
-
reviewCallCount++;
|
|
2001
|
-
// Round 1 (calls 1-3): BLOCK, BLOCK, PASS → majority block → retry
|
|
2002
|
-
if (reviewCallCount <= 3) {
|
|
2003
|
-
return Promise.resolve(reviewCallCount <= 2
|
|
2004
|
-
? { verdict: 'block', feedback: 'Critical issue', tokens: 20, model: 'reviewer' }
|
|
2005
|
-
: { verdict: 'pass', feedback: '', tokens: 20, model: 'reviewer' });
|
|
2006
|
-
}
|
|
2007
|
-
// Round 2 (calls 4-6): all PASS
|
|
2008
|
-
return Promise.resolve({ verdict: 'pass', feedback: '', tokens: 20, model: 'reviewer' });
|
|
2009
|
-
});
|
|
2010
|
-
const engine = makeEngine({
|
|
2011
|
-
spec: makeSpec({ defaults: { review: 'panel' } }, [{ id: 'task-1', max_retries: 1 }]),
|
|
2012
|
-
specYaml: 'name: test',
|
|
2013
|
-
adapter,
|
|
2014
|
-
dbPath,
|
|
2015
|
-
_worktreeManager: wtManager,
|
|
2016
|
-
_mergeQueue: mergeQueue,
|
|
2017
|
-
_reviewRunner: mockReviewRunner,
|
|
2018
|
-
});
|
|
2019
|
-
const result = await engine.run();
|
|
2020
|
-
expect(result.status).toBe('done');
|
|
2021
|
-
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
2022
|
-
// Two-stage panel round 1: 2 blocks ×1 call + 1 pass ×2 calls = 4 calls
|
|
2023
|
-
// Two-stage panel round 2: 3 pass ×2 calls = 6 calls. Total: 10
|
|
2024
|
-
expect(mockReviewRunner).toHaveBeenCalledTimes(10);
|
|
2025
|
-
const store = createConvoyStore(dbPath);
|
|
2026
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
2027
|
-
store.close();
|
|
2028
|
-
expect(tasks[0].review_verdict).toBe('pass');
|
|
2029
|
-
expect(tasks[0].panel_attempts).toBeGreaterThanOrEqual(1);
|
|
2030
|
-
});
|
|
2031
|
-
it('dispute: task dispute_id matches the dispute_opened event and panel_attempts is 3', async () => {
|
|
2032
|
-
const mockReviewRunner = vi.fn().mockResolvedValue({ verdict: 'block', feedback: 'broken', tokens: 5, model: 'r' });
|
|
2033
|
-
const engine = makeEngine({
|
|
2034
|
-
spec: makeSpec({ defaults: { review: 'panel' } }, [{ id: 'task-1', max_retries: 3 }]),
|
|
2035
|
-
specYaml: 'name: test',
|
|
2036
|
-
adapter,
|
|
2037
|
-
dbPath,
|
|
2038
|
-
_worktreeManager: wtManager,
|
|
2039
|
-
_mergeQueue: mergeQueue,
|
|
2040
|
-
_reviewRunner: mockReviewRunner,
|
|
2041
|
-
});
|
|
2042
|
-
const result = await engine.run();
|
|
2043
|
-
const store = createConvoyStore(dbPath);
|
|
2044
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
2045
|
-
const events = store.getEvents(result.convoyId);
|
|
2046
|
-
store.close();
|
|
2012
|
+
it('dispute: three blocked panels open a dispute whose id matches the task', async () => {
|
|
2013
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'block', feedback: 'broken', tokens: 5, model: 'r' });
|
|
2014
|
+
const result = await reviewEngine(makeSpec({ defaults: { review: 'panel' } }, [{ id: 'task-1', max_retries: 3 }]), runner).run();
|
|
2015
|
+
const { tasks, events } = readTasks(result.convoyId);
|
|
2047
2016
|
const task = tasks[0];
|
|
2048
2017
|
expect(task.status).toBe('disputed');
|
|
2049
2018
|
expect(task.dispute_id).not.toBeNull();
|
|
2050
2019
|
expect(task.panel_attempts).toBe(3);
|
|
2051
|
-
const
|
|
2052
|
-
expect(disputeEvent).toBeDefined();
|
|
2053
|
-
const eventData = JSON.parse(disputeEvent.data);
|
|
2054
|
-
// Verify the dispute_id on the task record matches the one in the event
|
|
2020
|
+
const eventData = JSON.parse(events.find(e => e.type === 'dispute_opened').data);
|
|
2055
2021
|
expect(eventData['dispute_id']).toBe(task.dispute_id);
|
|
2056
2022
|
expect(eventData['panel_attempts']).toBe(3);
|
|
2057
2023
|
});
|
|
2058
|
-
it('review budget
|
|
2059
|
-
const
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const result = await engine.run();
|
|
2073
|
-
const store = createConvoyStore(dbPath);
|
|
2074
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
2075
|
-
store.close();
|
|
2076
|
-
const byId = Object.fromEntries(tasks.map(t => [t.id, t.status]));
|
|
2024
|
+
it('review budget spent with skip — later reviews are recorded as skipped, not passed', async () => {
|
|
2025
|
+
const runner = vi.fn().mockResolvedValue({ verdict: 'pass', feedback: '', tokens: 200, model: 'reviewer' });
|
|
2026
|
+
const spec = makeSpec({ defaults: { review: 'fast', review_budget: 100, on_review_budget_exceeded: 'skip' } }, [{ id: 'task-1' }, { id: 'task-2', depends_on: ['task-1'] }]);
|
|
2027
|
+
const result = await reviewEngine(spec, runner).run();
|
|
2028
|
+
expect(result.status).toBe('done');
|
|
2029
|
+
expect(runner).toHaveBeenCalledTimes(1);
|
|
2030
|
+
const byId = Object.fromEntries(readTasks(result.convoyId).tasks.map(t => [t.id, t.review_verdict]));
|
|
2031
|
+
expect(byId).toEqual({ 'task-1': 'pass', 'task-2': 'skipped' });
|
|
2032
|
+
});
|
|
2033
|
+
it('review budget spent with stop: the task is review-blocked and nothing new starts', async () => {
|
|
2034
|
+
const runner = vi.fn();
|
|
2035
|
+
const spec = makeSpec({ defaults: { review: 'fast', review_budget: 0, on_review_budget_exceeded: 'stop' } }, [{ id: 'task-1' }, { id: 'task-2', depends_on: ['task-1'] }]);
|
|
2036
|
+
const result = await reviewEngine(spec, runner).run();
|
|
2037
|
+
const byId = Object.fromEntries(readTasks(result.convoyId).tasks.map(t => [t.id, t.status]));
|
|
2077
2038
|
expect(byId['task-1']).toBe('review-blocked');
|
|
2078
2039
|
expect(byId['task-2']).toBe('skipped');
|
|
2079
|
-
expect(
|
|
2080
|
-
});
|
|
2081
|
-
it('review budget exceeded: downgrade auto-passes task without calling reviewer', async () => {
|
|
2082
|
-
const mockReviewRunner = vi.fn();
|
|
2083
|
-
const engine = makeEngine({
|
|
2084
|
-
spec: makeSpec({ defaults: { review: 'fast', review_budget: 0, on_review_budget_exceeded: 'downgrade' } }),
|
|
2085
|
-
specYaml: 'name: test',
|
|
2086
|
-
adapter,
|
|
2087
|
-
dbPath,
|
|
2088
|
-
_worktreeManager: wtManager,
|
|
2089
|
-
_mergeQueue: mergeQueue,
|
|
2090
|
-
_reviewRunner: mockReviewRunner,
|
|
2091
|
-
});
|
|
2092
|
-
const result = await engine.run();
|
|
2093
|
-
expect(result.status).toBe('done');
|
|
2094
|
-
expect(mockReviewRunner).not.toHaveBeenCalled();
|
|
2095
|
-
const store = createConvoyStore(dbPath);
|
|
2096
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
2097
|
-
store.close();
|
|
2098
|
-
expect(tasks[0].review_verdict).toBe('pass');
|
|
2099
|
-
expect(tasks[0].review_level).toBe('fast');
|
|
2100
|
-
});
|
|
2101
|
-
});
|
|
2102
|
-
// ── Drift detection ───────────────────────────────────────────────────────────
|
|
2103
|
-
describe('drift detection', () => {
|
|
2104
|
-
let adapter;
|
|
2105
|
-
let wtManager;
|
|
2106
|
-
let mergeQueue;
|
|
2107
|
-
beforeEach(() => {
|
|
2108
|
-
adapter = makeAdapter('copilot');
|
|
2109
|
-
wtManager = makeWorktreeManager();
|
|
2110
|
-
mergeQueue = makeMergeQueue();
|
|
2111
|
-
});
|
|
2112
|
-
it('detect_drift=true triggers drift check and retries on low confidence', async () => {
|
|
2113
|
-
// Call sequence: main task → drift check (low score) → main task retry
|
|
2114
|
-
const driftRetryOutput = [
|
|
2115
|
-
'done retry',
|
|
2116
|
-
'<!-- OUTPUT_CONTRACT',
|
|
2117
|
-
'{ "files_changed": ["src/foo.ts"], "tests_added": ["src/foo.test.ts"], "summary": "done" }',
|
|
2118
|
-
'-->',
|
|
2119
|
-
].join('\n');
|
|
2120
|
-
adapter.execute
|
|
2121
|
-
.mockResolvedValueOnce({ success: true, output: 'done', exitCode: 0 })
|
|
2122
|
-
.mockResolvedValueOnce({ success: true, output: '{"score": 0.3, "explanation": "uncertain"}', exitCode: 0 })
|
|
2123
|
-
.mockResolvedValueOnce({ success: true, output: driftRetryOutput, exitCode: 0 });
|
|
2124
|
-
const engine = makeEngine({
|
|
2125
|
-
spec: makeSpec({ defaults: { detect_drift: true } }, [{ id: 'task-1', max_retries: 1 }]),
|
|
2126
|
-
specYaml: 'name: test',
|
|
2127
|
-
adapter,
|
|
2128
|
-
dbPath,
|
|
2129
|
-
_worktreeManager: wtManager,
|
|
2130
|
-
_mergeQueue: mergeQueue,
|
|
2131
|
-
});
|
|
2132
|
-
const result = await engine.run();
|
|
2133
|
-
expect(result.status).toBe('done');
|
|
2134
|
-
expect(result.summary.done).toBe(1);
|
|
2135
|
-
expect(adapter.execute).toHaveBeenCalledTimes(3);
|
|
2136
|
-
// Verify drift_score and drift_retried stored
|
|
2137
|
-
const store = createConvoyStore(dbPath);
|
|
2138
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
2139
|
-
store.close();
|
|
2140
|
-
expect(tasks[0].drift_score).toBe(0.3);
|
|
2141
|
-
expect(tasks[0].drift_retried).toBe(1);
|
|
2142
|
-
});
|
|
2143
|
-
it('detect_drift=true does NOT re-check on drift retry (drift_retried=1)', async () => {
|
|
2144
|
-
// On second execution drift_retried=1 so no third call for drift check
|
|
2145
|
-
adapter.execute
|
|
2146
|
-
.mockResolvedValueOnce({ success: true, output: 'done', exitCode: 0 })
|
|
2147
|
-
.mockResolvedValueOnce({ success: true, output: '{"score": 0.9, "explanation": "confident"}', exitCode: 0 });
|
|
2148
|
-
const engine = makeEngine({
|
|
2149
|
-
spec: makeSpec({ defaults: { detect_drift: true } }),
|
|
2150
|
-
specYaml: 'name: test',
|
|
2151
|
-
adapter,
|
|
2152
|
-
dbPath,
|
|
2153
|
-
_worktreeManager: wtManager,
|
|
2154
|
-
_mergeQueue: mergeQueue,
|
|
2155
|
-
});
|
|
2156
|
-
const result = await engine.run();
|
|
2157
|
-
expect(result.status).toBe('done');
|
|
2158
|
-
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
2159
|
-
});
|
|
2160
|
-
it('drift_check_result and drift_detected events emitted when drifted', async () => {
|
|
2161
|
-
adapter.execute
|
|
2162
|
-
.mockResolvedValueOnce({ success: true, output: 'done', exitCode: 0 })
|
|
2163
|
-
.mockResolvedValueOnce({ success: true, output: '{"score": 0.2, "explanation": "very unsure"}', exitCode: 0 })
|
|
2164
|
-
.mockResolvedValueOnce({ success: true, output: 'done', exitCode: 0 });
|
|
2165
|
-
const engine = makeEngine({
|
|
2166
|
-
spec: makeSpec({ defaults: { detect_drift: true } }, [{ id: 'task-1', max_retries: 1 }]),
|
|
2167
|
-
specYaml: 'name: test',
|
|
2168
|
-
adapter,
|
|
2169
|
-
dbPath,
|
|
2170
|
-
_worktreeManager: wtManager,
|
|
2171
|
-
_mergeQueue: mergeQueue,
|
|
2172
|
-
});
|
|
2173
|
-
const result = await engine.run();
|
|
2174
|
-
const store = createConvoyStore(dbPath);
|
|
2175
|
-
const events = store.getEvents(result.convoyId);
|
|
2176
|
-
store.close();
|
|
2177
|
-
expect(events.some(e => e.type === 'drift_check_result')).toBe(true);
|
|
2178
|
-
expect(events.some(e => e.type === 'drift_detected')).toBe(true);
|
|
2179
|
-
});
|
|
2180
|
-
it('non-copilot adapter skips drift detection (returns done without extra call)', async () => {
|
|
2181
|
-
// adapter name is 'test-adapter' — not a streaming adapter; drift check should be skipped
|
|
2182
|
-
const nonStreamingAdapter = makeAdapter('test-adapter');
|
|
2183
|
-
nonStreamingAdapter.execute.mockResolvedValue({ success: true, output: 'ok', exitCode: 0 });
|
|
2184
|
-
// Suppress the stderr warning
|
|
2185
|
-
const stderrSpy = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
2186
|
-
try {
|
|
2187
|
-
const engine = makeEngine({
|
|
2188
|
-
spec: makeSpec({ defaults: { detect_drift: true } }),
|
|
2189
|
-
specYaml: 'name: test',
|
|
2190
|
-
adapter: nonStreamingAdapter,
|
|
2191
|
-
dbPath,
|
|
2192
|
-
_worktreeManager: wtManager,
|
|
2193
|
-
_mergeQueue: mergeQueue,
|
|
2194
|
-
});
|
|
2195
|
-
const result = await engine.run();
|
|
2196
|
-
expect(result.status).toBe('done');
|
|
2197
|
-
// Only 1 call: main task (no drift check call) because non-streaming adapter
|
|
2198
|
-
expect(nonStreamingAdapter.execute).toHaveBeenCalledTimes(1);
|
|
2199
|
-
}
|
|
2200
|
-
finally {
|
|
2201
|
-
stderrSpy.mockRestore();
|
|
2202
|
-
}
|
|
2040
|
+
expect(runner).not.toHaveBeenCalled();
|
|
2203
2041
|
});
|
|
2204
2042
|
});
|
|
2205
2043
|
// ── Dispute protocol ──────────────────────────────────────────────────────────
|
|
@@ -2310,42 +2148,6 @@ describe('dispute protocol', () => {
|
|
|
2310
2148
|
expect(byId['task-2']).toBe('done');
|
|
2311
2149
|
});
|
|
2312
2150
|
});
|
|
2313
|
-
// ── File-based injection ───────────────────────────────────────────────────
|
|
2314
|
-
describe('file-based injection', () => {
|
|
2315
|
-
it('picks up tasks from inject file and ingests them', async () => {
|
|
2316
|
-
const adapter = makeAdapter();
|
|
2317
|
-
adapter.execute.mockResolvedValue({ success: true, output: 'ok', exitCode: 0 });
|
|
2318
|
-
const spec = makeSpec({ concurrency: 1 }, [
|
|
2319
|
-
{ id: 'task-1', prompt: 'Original task', timeout: '5s' },
|
|
2320
|
-
]);
|
|
2321
|
-
const engine = makeEngine({
|
|
2322
|
-
spec,
|
|
2323
|
-
specYaml: 'name: test',
|
|
2324
|
-
adapter,
|
|
2325
|
-
dbPath,
|
|
2326
|
-
basePath: tmpDir,
|
|
2327
|
-
_worktreeManager: makeWorktreeManager(),
|
|
2328
|
-
_mergeQueue: makeMergeQueue(),
|
|
2329
|
-
});
|
|
2330
|
-
const result = await engine.run();
|
|
2331
|
-
expect(result.summary.done).toBeGreaterThanOrEqual(1);
|
|
2332
|
-
});
|
|
2333
|
-
it('respects convoy_id path traversal guard', async () => {
|
|
2334
|
-
const adapter = makeAdapter();
|
|
2335
|
-
const spec = makeSpec();
|
|
2336
|
-
const engine = makeEngine({
|
|
2337
|
-
spec,
|
|
2338
|
-
specYaml: 'name: test',
|
|
2339
|
-
adapter,
|
|
2340
|
-
dbPath,
|
|
2341
|
-
basePath: tmpDir,
|
|
2342
|
-
_worktreeManager: makeWorktreeManager(),
|
|
2343
|
-
_mergeQueue: makeMergeQueue(),
|
|
2344
|
-
});
|
|
2345
|
-
const result = await engine.run();
|
|
2346
|
-
expect(result.status).toBe('done');
|
|
2347
|
-
});
|
|
2348
|
-
});
|
|
2349
2151
|
describe('NDJSON recovery', () => {
|
|
2350
2152
|
it('truncates partial trailing line in NDJSON file', () => {
|
|
2351
2153
|
const convoyId = 'convoy-ndjson-1';
|
|
@@ -2665,8 +2467,17 @@ describe('swarm mode (concurrency: auto)', () => {
|
|
|
2665
2467
|
expect(result.summary.done).toBe(4);
|
|
2666
2468
|
expect(maxConcurrent).toBeLessThanOrEqual(2);
|
|
2667
2469
|
});
|
|
2668
|
-
it('
|
|
2470
|
+
it('runs at most four at once when the spec gives no number', async () => {
|
|
2669
2471
|
const adapter = makeAdapter();
|
|
2472
|
+
let maxConcurrent = 0;
|
|
2473
|
+
let current = 0;
|
|
2474
|
+
adapter.execute.mockImplementation(async () => {
|
|
2475
|
+
current++;
|
|
2476
|
+
maxConcurrent = Math.max(maxConcurrent, current);
|
|
2477
|
+
await new Promise(r => setTimeout(r, 20));
|
|
2478
|
+
current--;
|
|
2479
|
+
return { success: true, output: 'ok', exitCode: 0 };
|
|
2480
|
+
});
|
|
2670
2481
|
const spec = makeSpec({ concurrency: 'auto' }, Array.from({ length: 10 }, (_, i) => ({
|
|
2671
2482
|
id: `task-${i + 1}`,
|
|
2672
2483
|
prompt: `Task ${i + 1}`,
|
|
@@ -2682,6 +2493,7 @@ describe('swarm mode (concurrency: auto)', () => {
|
|
|
2682
2493
|
const result = await engine.run();
|
|
2683
2494
|
expect(result.status).toBe('done');
|
|
2684
2495
|
expect(result.summary.done).toBe(10);
|
|
2496
|
+
expect(maxConcurrent).toBe(4);
|
|
2685
2497
|
});
|
|
2686
2498
|
});
|
|
2687
2499
|
// ── Step retry context prepending ───────────────────────────────────────────
|
|
@@ -2713,9 +2525,12 @@ describe('step retry context prepending', () => {
|
|
|
2713
2525
|
_mergeQueue: makeMergeQueue(),
|
|
2714
2526
|
});
|
|
2715
2527
|
await engine.run();
|
|
2716
|
-
// First call
|
|
2717
|
-
expect(capturedPrompts[0]).
|
|
2718
|
-
|
|
2528
|
+
// First call: the step, inside the shared context and the task's role
|
|
2529
|
+
expect(capturedPrompts[0]).toContain('### Instructions\nstep prompt text');
|
|
2530
|
+
expect(capturedPrompts[0]).toContain('# Convoy: Test Convoy');
|
|
2531
|
+
expect(capturedPrompts[0]).toContain('You are the developer agent for this task.');
|
|
2532
|
+
expect(capturedPrompts[0]).not.toContain('Previous attempt failed.');
|
|
2533
|
+
// Second call (retry) adds the failure context
|
|
2719
2534
|
expect(capturedPrompts[1]).toContain('Previous attempt failed.');
|
|
2720
2535
|
expect(capturedPrompts[1]).toContain('Exit code: 2');
|
|
2721
2536
|
expect(capturedPrompts[1]).toContain('step error detail');
|
|
@@ -3017,11 +2832,11 @@ describe('circuit breaker', () => {
|
|
|
3017
2832
|
adapter.execute
|
|
3018
2833
|
.mockResolvedValueOnce({ success: false, output: 'err', exitCode: 1 })
|
|
3019
2834
|
.mockResolvedValue({ success: true, output: 'ok', exitCode: 0 });
|
|
3020
|
-
// threshold=
|
|
3021
|
-
//
|
|
2835
|
+
// threshold=1: one failure opens the circuit before task-2 and task-3 start.
|
|
2836
|
+
// (Each failure used to be counted twice, and this test was written around that.)
|
|
3022
2837
|
const spec = makeSpec({
|
|
3023
2838
|
on_failure: 'continue',
|
|
3024
|
-
defaults: { circuit_breaker: { threshold:
|
|
2839
|
+
defaults: { circuit_breaker: { threshold: 1, cooldown_ms: 999_999_999 } },
|
|
3025
2840
|
}, [
|
|
3026
2841
|
{ id: 'task-1', agent: 'developer', max_retries: 0 },
|
|
3027
2842
|
{ id: 'task-2', agent: 'developer', max_retries: 0 },
|
|
@@ -3041,6 +2856,30 @@ describe('circuit breaker', () => {
|
|
|
3041
2856
|
// task-2 and task-3 should be skipped by the circuit breaker
|
|
3042
2857
|
expect(result.summary.skipped).toBeGreaterThanOrEqual(2);
|
|
3043
2858
|
});
|
|
2859
|
+
it('hands the task to the fallback agent instead of skipping it', async () => {
|
|
2860
|
+
const adapter = makeAdapter();
|
|
2861
|
+
adapter.execute
|
|
2862
|
+
.mockResolvedValueOnce({ success: false, output: 'err', exitCode: 1 })
|
|
2863
|
+
.mockResolvedValue({ success: true, output: 'ok', exitCode: 0 });
|
|
2864
|
+
const spec = makeSpec({
|
|
2865
|
+
on_failure: 'continue',
|
|
2866
|
+
concurrency: 1,
|
|
2867
|
+
defaults: { circuit_breaker: { threshold: 1, cooldown_ms: 999_999_999, fallback_agent: 'architect' } },
|
|
2868
|
+
}, [
|
|
2869
|
+
{ id: 'task-1', agent: 'developer', max_retries: 0 },
|
|
2870
|
+
{ id: 'task-2', agent: 'developer', max_retries: 0 },
|
|
2871
|
+
]);
|
|
2872
|
+
const engine = makeEngine({
|
|
2873
|
+
spec, specYaml: 'name: test', adapter, dbPath,
|
|
2874
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
2875
|
+
});
|
|
2876
|
+
const result = await engine.run();
|
|
2877
|
+
// task-2 ran, as the fallback agent, and was not skipped.
|
|
2878
|
+
expect(adapter.execute).toHaveBeenCalledTimes(2);
|
|
2879
|
+
const second = adapter.execute.mock.calls[1][0];
|
|
2880
|
+
expect(second).toMatchObject({ id: 'task-2', agent: 'architect' });
|
|
2881
|
+
expect(result.summary.skipped ?? 0).toBe(0);
|
|
2882
|
+
});
|
|
3044
2883
|
it('records success and persists closed circuit state to store', async () => {
|
|
3045
2884
|
const adapter = makeAdapter();
|
|
3046
2885
|
const spec = makeSpec({
|
|
@@ -3067,12 +2906,13 @@ describe('circuit breaker', () => {
|
|
|
3067
2906
|
it('records failure and persists open circuit state to store after threshold', async () => {
|
|
3068
2907
|
const adapter = makeAdapter();
|
|
3069
2908
|
adapter.execute.mockResolvedValue({ success: false, output: 'err', exitCode: 1 });
|
|
3070
|
-
// threshold=2
|
|
2909
|
+
// threshold=2, two failures: counted once each, the second opens it
|
|
3071
2910
|
const spec = makeSpec({
|
|
3072
2911
|
on_failure: 'continue',
|
|
3073
2912
|
defaults: { circuit_breaker: { threshold: 2, cooldown_ms: 999_999_999 } },
|
|
3074
2913
|
}, [
|
|
3075
2914
|
{ id: 'task-f1', agent: 'developer', max_retries: 0 },
|
|
2915
|
+
{ id: 'task-f2', agent: 'developer', max_retries: 0 },
|
|
3076
2916
|
]);
|
|
3077
2917
|
const engine = makeEngine({
|
|
3078
2918
|
spec,
|
|
@@ -3199,39 +3039,27 @@ describe('createEventEmitter callsite safety', () => {
|
|
|
3199
3039
|
});
|
|
3200
3040
|
});
|
|
3201
3041
|
// ── Contract retry ────────────────────────────────────────────────────────────
|
|
3202
|
-
describe('contract
|
|
3203
|
-
it('
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
'<!-- OUTPUT_CONTRACT',
|
|
3207
|
-
'{ "files_changed": ["src/foo.ts"], "tests_added": ["src/foo.test.ts"], "summary": "implemented" }',
|
|
3208
|
-
'-->',
|
|
3209
|
-
].join('\n');
|
|
3042
|
+
describe('output contract', () => {
|
|
3043
|
+
it('only warns about a missing contract — the task is never run again', async () => {
|
|
3044
|
+
// The re-run used to happen after the first attempt had already merged:
|
|
3045
|
+
// two tasks produced four agent sessions and four commits.
|
|
3210
3046
|
const adapter = makeAdapter();
|
|
3211
|
-
adapter.execute
|
|
3212
|
-
|
|
3213
|
-
.mockResolvedValueOnce({ success: true, output: validContractOutput, exitCode: 0 });
|
|
3047
|
+
adapter.execute.mockResolvedValue({ success: true, output: 'no contract here', exitCode: 0 });
|
|
3048
|
+
const mergeQueue = makeMergeQueue();
|
|
3214
3049
|
const engine = makeEngine({
|
|
3215
3050
|
spec: makeSpec({}, [{ agent: 'developer', max_retries: 1 }]),
|
|
3216
3051
|
specYaml: 'name: test',
|
|
3217
3052
|
adapter,
|
|
3218
3053
|
dbPath,
|
|
3219
3054
|
_worktreeManager: makeWorktreeManager(),
|
|
3220
|
-
_mergeQueue:
|
|
3055
|
+
_mergeQueue: mergeQueue,
|
|
3221
3056
|
});
|
|
3222
3057
|
const result = await engine.run();
|
|
3223
3058
|
expect(result.status).toBe('done');
|
|
3224
|
-
expect(adapter.execute).toHaveBeenCalledTimes(
|
|
3225
|
-
|
|
3226
|
-
const secondPrompt = adapter.execute.mock.calls[1][0].prompt;
|
|
3227
|
-
expect(secondPrompt).toContain('OUTPUT_CONTRACT');
|
|
3228
|
-
expect(secondPrompt).toContain('Missing fields');
|
|
3229
|
-
const store = createConvoyStore(dbPath);
|
|
3230
|
-
const tasks = store.getTasksByConvoy(result.convoyId);
|
|
3231
|
-
store.close();
|
|
3232
|
-
expect(tasks[0].status).toBe('done');
|
|
3059
|
+
expect(adapter.execute).toHaveBeenCalledTimes(1);
|
|
3060
|
+
expect(mergeQueue.merge).toHaveBeenCalledTimes(1);
|
|
3233
3061
|
});
|
|
3234
|
-
it('emits contract_violation and marks done
|
|
3062
|
+
it('emits contract_violation and marks done', async () => {
|
|
3235
3063
|
const adapter = makeAdapter();
|
|
3236
3064
|
adapter.execute.mockResolvedValue({ success: true, output: 'no contract here', exitCode: 0 });
|
|
3237
3065
|
const engine = makeEngine({
|
|
@@ -3420,4 +3248,196 @@ describe('permission mode', () => {
|
|
|
3420
3248
|
});
|
|
3421
3249
|
});
|
|
3422
3250
|
// ── Compaction continuation ───────────────────────────────────────────────────
|
|
3251
|
+
// ── Scheduler: a ready queue, not phase barriers ──────────────────────────────
|
|
3252
|
+
describe('ready-queue scheduler', () => {
|
|
3253
|
+
it('runs the audit’s demo in about 6s, not 8.6s', async () => {
|
|
3254
|
+
// slow 6s, fast1 1s, fast2 (after fast1) 1s, indep 1s, two slots. With
|
|
3255
|
+
// phase barriers fast2 waited for slow: 6 + 1 + 1 ≈ 8.6s measured. With a
|
|
3256
|
+
// ready queue it starts the moment fast1 is done, and the run takes as
|
|
3257
|
+
// long as its slowest task.
|
|
3258
|
+
vi.useFakeTimers();
|
|
3259
|
+
try {
|
|
3260
|
+
const durations = { slow: 6000, fast1: 1000, fast2: 1000, indep: 1000 };
|
|
3261
|
+
const timeline = {};
|
|
3262
|
+
const adapter = makeAdapter();
|
|
3263
|
+
adapter.execute.mockImplementation(async (task) => {
|
|
3264
|
+
const start = Date.now();
|
|
3265
|
+
await new Promise(r => setTimeout(r, durations[task.id]));
|
|
3266
|
+
timeline[task.id] = { start, end: Date.now() };
|
|
3267
|
+
return { success: true, output: 'ok', exitCode: 0 };
|
|
3268
|
+
});
|
|
3269
|
+
const spec = makeSpec({ concurrency: 2 }, [
|
|
3270
|
+
{ id: 'slow' },
|
|
3271
|
+
{ id: 'fast1' },
|
|
3272
|
+
{ id: 'fast2', depends_on: ['fast1'] },
|
|
3273
|
+
{ id: 'indep' },
|
|
3274
|
+
]);
|
|
3275
|
+
const t0 = Date.now();
|
|
3276
|
+
let finished = false;
|
|
3277
|
+
const run = makeEngine({
|
|
3278
|
+
spec, specYaml: 'name: test', adapter, dbPath,
|
|
3279
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3280
|
+
}).run().finally(() => { finished = true; });
|
|
3281
|
+
while (!finished)
|
|
3282
|
+
await vi.advanceTimersByTimeAsync(50);
|
|
3283
|
+
const result = await run;
|
|
3284
|
+
const total = Date.now() - t0;
|
|
3285
|
+
expect(result.status).toBe('done');
|
|
3286
|
+
expect(total).toBeGreaterThanOrEqual(6000);
|
|
3287
|
+
expect(total).toBeLessThan(6500);
|
|
3288
|
+
// fast2 ran while slow was still running.
|
|
3289
|
+
expect(timeline.fast2.start).toBeLessThan(timeline.slow.end);
|
|
3290
|
+
expect(timeline.fast2.start - t0).toBeLessThan(1500);
|
|
3291
|
+
}
|
|
3292
|
+
finally {
|
|
3293
|
+
vi.useRealTimers();
|
|
3294
|
+
}
|
|
3295
|
+
});
|
|
3296
|
+
it('never runs a task next to a running task whose files overlap, though both are ready', async () => {
|
|
3297
|
+
// `writer` becomes ready while `owner` still holds src/ — the dynamic form
|
|
3298
|
+
// of the per-phase partition check, which only compared tasks in one phase.
|
|
3299
|
+
const timeline = {};
|
|
3300
|
+
const adapter = makeAdapter();
|
|
3301
|
+
adapter.execute.mockImplementation(async (task) => {
|
|
3302
|
+
const start = Date.now();
|
|
3303
|
+
await new Promise(r => setTimeout(r, task.id === 'owner' ? 120 : 10));
|
|
3304
|
+
timeline[task.id] = { start, end: Date.now() };
|
|
3305
|
+
return { success: true, output: 'ok', exitCode: 0 };
|
|
3306
|
+
});
|
|
3307
|
+
const spec = makeSpec({ concurrency: 3 }, [
|
|
3308
|
+
{ id: 'owner', files: ['src/'] },
|
|
3309
|
+
{ id: 'gate', files: [] },
|
|
3310
|
+
{ id: 'writer', files: ['src/api.ts'], depends_on: ['gate'] },
|
|
3311
|
+
]);
|
|
3312
|
+
// Real (empty) directories: tasks with files are symlink-scanned in their worktree.
|
|
3313
|
+
const wt = makeWorktreeManager();
|
|
3314
|
+
wt.create.mockImplementation(async (id) => {
|
|
3315
|
+
const dir = join(tmpDir, 'wt', id);
|
|
3316
|
+
mkdirSync(dir, { recursive: true });
|
|
3317
|
+
return dir;
|
|
3318
|
+
});
|
|
3319
|
+
const result = await makeEngine({
|
|
3320
|
+
spec, specYaml: 'name: test', adapter, dbPath,
|
|
3321
|
+
_worktreeManager: wt, _mergeQueue: makeMergeQueue(),
|
|
3322
|
+
}).run();
|
|
3323
|
+
expect(result.status).toBe('done');
|
|
3324
|
+
expect(timeline.writer.start).toBeGreaterThanOrEqual(timeline.owner.end);
|
|
3325
|
+
});
|
|
3326
|
+
it('refuses a plan whose same-phase tasks overlap, before recording anything', async () => {
|
|
3327
|
+
const adapter = makeAdapter();
|
|
3328
|
+
const engine = makeEngine({
|
|
3329
|
+
spec: makeSpec({}, [{ id: 'a', files: ['src/'] }, { id: 'b', files: ['src/x.ts'] }]),
|
|
3330
|
+
specYaml: 'name: test', adapter, dbPath,
|
|
3331
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3332
|
+
});
|
|
3333
|
+
await expect(engine.run()).rejects.toThrow('File partition conflicts detected');
|
|
3334
|
+
const store = createConvoyStore(dbPath);
|
|
3335
|
+
expect(store.getLatestConvoy()).toBeUndefined();
|
|
3336
|
+
store.close();
|
|
3337
|
+
expect(adapter.execute).not.toHaveBeenCalled();
|
|
3338
|
+
});
|
|
3339
|
+
});
|
|
3340
|
+
// ── Resume resets everything retry did ────────────────────────────────────────
|
|
3341
|
+
describe('resume resets every unfinished task', () => {
|
|
3342
|
+
it('reopens failed, timed-out, gate-failed, review-blocked, disputed, interrupted and skipped tasks', async () => {
|
|
3343
|
+
const convoyId = 'convoy-mixed';
|
|
3344
|
+
const statuses = ['done', 'failed', 'timed-out', 'gate-failed', 'review-blocked', 'disputed', 'running', 'assigned', 'skipped'];
|
|
3345
|
+
const seeder = createConvoyStore(dbPath);
|
|
3346
|
+
seeder.insertConvoy({ id: convoyId, name: 'Mixed', spec_hash: 'x', status: 'failed', branch: 'feat/mixed', created_at: new Date().toISOString(), spec_yaml: 'name: m' });
|
|
3347
|
+
for (const status of statuses) {
|
|
3348
|
+
seeder.insertTask({
|
|
3349
|
+
id: `t-${status}`, convoy_id: convoyId, phase: 0, prompt: `p ${status}`, agent: 'developer', adapter: null, model: null,
|
|
3350
|
+
timeout_ms: 30_000, status, retries: 1, max_retries: 1, files: null, depends_on: null, gates: null,
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3353
|
+
seeder.close();
|
|
3354
|
+
const adapter = makeAdapter();
|
|
3355
|
+
const result = await makeEngine({
|
|
3356
|
+
spec: makeSpec({ concurrency: 4 }, statuses.map(s => ({ id: `t-${s}` }))),
|
|
3357
|
+
specYaml: 'name: test', adapter, dbPath,
|
|
3358
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3359
|
+
}).resume(convoyId);
|
|
3360
|
+
expect(result.status).toBe('done');
|
|
3361
|
+
const ran = adapter.execute.mock.calls.map(([t]) => t.id).sort();
|
|
3362
|
+
expect(ran).toEqual(statuses.filter(s => s !== 'done').map(s => `t-${s}`).sort());
|
|
3363
|
+
const store = createConvoyStore(dbPath);
|
|
3364
|
+
const events = store.getEvents(convoyId).filter(e => e.type === 'task_retried');
|
|
3365
|
+
store.close();
|
|
3366
|
+
expect(events).toHaveLength(8);
|
|
3367
|
+
});
|
|
3368
|
+
it('retryFailed with task ids brings the dependents a failure skipped along', async () => {
|
|
3369
|
+
const convoyId = 'convoy-chain';
|
|
3370
|
+
const seeder = createConvoyStore(dbPath);
|
|
3371
|
+
seeder.insertConvoy({ id: convoyId, name: 'Chain', spec_hash: 'x', status: 'done', branch: 'feat/chain', created_at: new Date().toISOString(), spec_yaml: 'name: c' });
|
|
3372
|
+
const task = (id, status, deps = []) => seeder.insertTask({
|
|
3373
|
+
id, convoy_id: convoyId, phase: deps.length, prompt: id, agent: 'developer', adapter: null, model: null,
|
|
3374
|
+
timeout_ms: 30_000, status, retries: 0, max_retries: 0, files: null, depends_on: deps.length ? JSON.stringify(deps) : null, gates: null,
|
|
3375
|
+
});
|
|
3376
|
+
task('a', 'failed');
|
|
3377
|
+
task('b', 'skipped', ['a']);
|
|
3378
|
+
task('c', 'skipped', ['b']);
|
|
3379
|
+
task('other', 'failed');
|
|
3380
|
+
seeder.close();
|
|
3381
|
+
const engine = makeEngine({
|
|
3382
|
+
spec: makeSpec({}, [{ id: 'a' }]), specYaml: 'name: test', adapter: makeAdapter(), dbPath,
|
|
3383
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3384
|
+
});
|
|
3385
|
+
await engine.retryFailed(convoyId, ['a']);
|
|
3386
|
+
const store = createConvoyStore(dbPath);
|
|
3387
|
+
const byId = Object.fromEntries(store.getTasksByConvoy(convoyId).map(t => [t.id, t.status]));
|
|
3388
|
+
store.close();
|
|
3389
|
+
expect(byId).toEqual({ a: 'pending', b: 'pending', c: 'pending', other: 'failed' });
|
|
3390
|
+
});
|
|
3391
|
+
});
|
|
3392
|
+
// ── Telemetry ─────────────────────────────────────────────────────────────────
|
|
3393
|
+
describe('telemetry', () => {
|
|
3394
|
+
it('records the agent’s real tier, not a hard-coded "standard"', async () => {
|
|
3395
|
+
const result = await makeEngine({
|
|
3396
|
+
spec: makeSpec({}, [{ id: 'sec', agent: 'security-expert' }, { id: 'doc', agent: 'writer' }]),
|
|
3397
|
+
specYaml: 'name: test', adapter: makeAdapter(), dbPath,
|
|
3398
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3399
|
+
}).run();
|
|
3400
|
+
const store = createConvoyStore(dbPath);
|
|
3401
|
+
const tiers = Object.fromEntries(store.getEvents(result.convoyId)
|
|
3402
|
+
.filter(e => e.type === 'delegation')
|
|
3403
|
+
.map(e => [e.task_id, JSON.parse(e.data).tier]));
|
|
3404
|
+
store.close();
|
|
3405
|
+
expect(tiers).toEqual({ sec: 'premium', doc: 'economy' });
|
|
3406
|
+
});
|
|
3407
|
+
it('counts a failure once toward the circuit breaker', async () => {
|
|
3408
|
+
const adapter = makeAdapter();
|
|
3409
|
+
adapter.execute.mockResolvedValue({ success: false, output: 'err', exitCode: 1 });
|
|
3410
|
+
const result = await makeEngine({
|
|
3411
|
+
spec: makeSpec({ defaults: { circuit_breaker: { threshold: 5 } } }, [{ id: 'only', max_retries: 0 }]),
|
|
3412
|
+
specYaml: 'name: test', adapter, dbPath,
|
|
3413
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3414
|
+
}).run();
|
|
3415
|
+
const store = createConvoyStore(dbPath);
|
|
3416
|
+
const state = JSON.parse(store.getConvoy(result.convoyId).circuit_state);
|
|
3417
|
+
store.close();
|
|
3418
|
+
expect(state.developer.failures).toBe(1);
|
|
3419
|
+
});
|
|
3420
|
+
it('masks a secret in a failure before it reaches the task row, the DLQ and the ledger', async () => {
|
|
3421
|
+
gates._setAllowlistConfigPath('/nonexistent/secret-scan-config.yml');
|
|
3422
|
+
gates._resetAllowlistCache();
|
|
3423
|
+
const token = 'ghp_' + 'abcdefghijklmnopqrstuvwxyz0123456789AB';
|
|
3424
|
+
const adapter = makeAdapter();
|
|
3425
|
+
adapter.execute.mockResolvedValue({ success: false, output: `auth failed with token ${token}`, exitCode: 1 });
|
|
3426
|
+
const result = await makeEngine({
|
|
3427
|
+
spec: makeSpec({}, [{ id: 'leaky', max_retries: 0 }]),
|
|
3428
|
+
specYaml: 'name: test', adapter, dbPath,
|
|
3429
|
+
_worktreeManager: makeWorktreeManager(), _mergeQueue: makeMergeQueue(),
|
|
3430
|
+
}).run();
|
|
3431
|
+
const store = createConvoyStore(dbPath);
|
|
3432
|
+
const task = store.getTask('leaky', result.convoyId);
|
|
3433
|
+
const dlq = store.listDlqEntries(result.convoyId);
|
|
3434
|
+
const events = store.getEvents(result.convoyId);
|
|
3435
|
+
store.close();
|
|
3436
|
+
expect(task.output).not.toContain(token);
|
|
3437
|
+
expect(dlq).toHaveLength(1);
|
|
3438
|
+
expect(dlq[0].error_output).not.toContain(token);
|
|
3439
|
+
expect(JSON.stringify(events)).not.toContain(token);
|
|
3440
|
+
expect(readFileSync(join(tmpDir, '.opencastle', 'AGENT-FAILURES.md'), 'utf8')).not.toContain(token);
|
|
3441
|
+
});
|
|
3442
|
+
});
|
|
3423
3443
|
//# sourceMappingURL=engine.test.js.map
|