opencastle 0.36.1 → 0.37.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.
Files changed (107) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/convoy/engine.d.ts.map +1 -1
  3. package/dist/cli/convoy/engine.js +0 -7
  4. package/dist/cli/convoy/engine.js.map +1 -1
  5. package/dist/cli/convoy/engine.test.js +0 -1
  6. package/dist/cli/convoy/engine.test.js.map +1 -1
  7. package/dist/cli/convoy/event-emission.test.d.ts +2 -0
  8. package/dist/cli/convoy/event-emission.test.d.ts.map +1 -0
  9. package/dist/cli/convoy/event-emission.test.js +73 -0
  10. package/dist/cli/convoy/event-emission.test.js.map +1 -0
  11. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  12. package/dist/cli/convoy/event-schemas.js +0 -25
  13. package/dist/cli/convoy/event-schemas.js.map +1 -1
  14. package/dist/cli/convoy/events.test.js +2 -2
  15. package/dist/cli/convoy/events.test.js.map +1 -1
  16. package/dist/cli/convoy/last-run.d.ts +53 -0
  17. package/dist/cli/convoy/last-run.d.ts.map +1 -0
  18. package/dist/cli/convoy/last-run.js +54 -0
  19. package/dist/cli/convoy/last-run.js.map +1 -0
  20. package/dist/cli/convoy/last-run.test.d.ts +2 -0
  21. package/dist/cli/convoy/last-run.test.d.ts.map +1 -0
  22. package/dist/cli/convoy/last-run.test.js +110 -0
  23. package/dist/cli/convoy/last-run.test.js.map +1 -0
  24. package/dist/cli/convoy/spec-types.d.ts +8 -2
  25. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  26. package/dist/cli/convoy/store.d.ts +3 -2
  27. package/dist/cli/convoy/store.d.ts.map +1 -1
  28. package/dist/cli/convoy/store.js +33 -8
  29. package/dist/cli/convoy/store.js.map +1 -1
  30. package/dist/cli/convoy/store.test.js +76 -13
  31. package/dist/cli/convoy/store.test.js.map +1 -1
  32. package/dist/cli/convoy/types.d.ts +0 -35
  33. package/dist/cli/convoy/types.d.ts.map +1 -1
  34. package/dist/cli/convoy/types.js +0 -4
  35. package/dist/cli/convoy/types.js.map +1 -1
  36. package/dist/cli/convoy-args.test.d.ts +2 -0
  37. package/dist/cli/convoy-args.test.d.ts.map +1 -0
  38. package/dist/cli/convoy-args.test.js +132 -0
  39. package/dist/cli/convoy-args.test.js.map +1 -0
  40. package/dist/cli/convoy-cmd.d.ts +25 -0
  41. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  42. package/dist/cli/convoy-cmd.js +155 -19
  43. package/dist/cli/convoy-cmd.js.map +1 -1
  44. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  45. package/dist/cli/run/adapters/codex.js +8 -1
  46. package/dist/cli/run/adapters/codex.js.map +1 -1
  47. package/dist/cli/run/adapters/permission-modes.d.ts +20 -0
  48. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -0
  49. package/dist/cli/run/adapters/permission-modes.js +82 -0
  50. package/dist/cli/run/adapters/permission-modes.js.map +1 -0
  51. package/dist/cli/run/adapters/permission-modes.test.d.ts +2 -0
  52. package/dist/cli/run/adapters/permission-modes.test.d.ts.map +1 -0
  53. package/dist/cli/run/adapters/permission-modes.test.js +95 -0
  54. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -0
  55. package/dist/cli/run/schema.d.ts.map +1 -1
  56. package/dist/cli/run/schema.js +69 -0
  57. package/dist/cli/run/schema.js.map +1 -1
  58. package/dist/cli/run/schema.test.js +62 -0
  59. package/dist/cli/run/schema.test.js.map +1 -1
  60. package/dist/cli/run-dry-run.test.d.ts +2 -0
  61. package/dist/cli/run-dry-run.test.d.ts.map +1 -0
  62. package/dist/cli/run-dry-run.test.js +83 -0
  63. package/dist/cli/run-dry-run.test.js.map +1 -0
  64. package/dist/cli/run-executor-flags.test.d.ts +2 -0
  65. package/dist/cli/run-executor-flags.test.d.ts.map +1 -0
  66. package/dist/cli/run-executor-flags.test.js +31 -0
  67. package/dist/cli/run-executor-flags.test.js.map +1 -0
  68. package/dist/cli/run.d.ts +40 -0
  69. package/dist/cli/run.d.ts.map +1 -1
  70. package/dist/cli/run.js +198 -24
  71. package/dist/cli/run.js.map +1 -1
  72. package/dist/orchestrator/plugins/hetzner/config.d.ts +3 -0
  73. package/dist/orchestrator/plugins/hetzner/config.d.ts.map +1 -0
  74. package/dist/orchestrator/plugins/hetzner/config.js +20 -0
  75. package/dist/orchestrator/plugins/hetzner/config.js.map +1 -0
  76. package/dist/orchestrator/plugins/index.d.ts.map +1 -1
  77. package/dist/orchestrator/plugins/index.js +2 -0
  78. package/dist/orchestrator/plugins/index.js.map +1 -1
  79. package/package.json +1 -1
  80. package/src/cli/convoy/TELEMETRY.md +0 -2
  81. package/src/cli/convoy/engine.test.ts +0 -1
  82. package/src/cli/convoy/engine.ts +0 -7
  83. package/src/cli/convoy/event-emission.test.ts +79 -0
  84. package/src/cli/convoy/event-schemas.ts +0 -25
  85. package/src/cli/convoy/events.test.ts +2 -2
  86. package/src/cli/convoy/last-run.test.ts +130 -0
  87. package/src/cli/convoy/last-run.ts +87 -0
  88. package/src/cli/convoy/spec-types.ts +8 -2
  89. package/src/cli/convoy/store.test.ts +87 -13
  90. package/src/cli/convoy/store.ts +40 -12
  91. package/src/cli/convoy/types.ts +0 -10
  92. package/src/cli/convoy-args.test.ts +156 -0
  93. package/src/cli/convoy-cmd.ts +162 -19
  94. package/src/cli/run/adapters/codex.ts +9 -1
  95. package/src/cli/run/adapters/permission-modes.test.ts +114 -0
  96. package/src/cli/run/adapters/permission-modes.ts +89 -0
  97. package/src/cli/run/schema.test.ts +72 -0
  98. package/src/cli/run/schema.ts +71 -0
  99. package/src/cli/run-dry-run.test.ts +97 -0
  100. package/src/cli/run-executor-flags.test.ts +38 -0
  101. package/src/cli/run.ts +242 -29
  102. package/src/dashboard/dist/index.html +1 -1
  103. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  104. package/src/dashboard/src/pages/index.astro +1 -1
  105. package/src/orchestrator/plugins/hetzner/SKILL.md +96 -0
  106. package/src/orchestrator/plugins/hetzner/config.ts +21 -0
  107. package/src/orchestrator/plugins/index.ts +2 -0
@@ -0,0 +1,114 @@
1
+ /**
2
+ * A permission mode is honoured or refused, never dropped.
3
+ *
4
+ * The defect: `--permission-mode` was validated against the enum, stored on the
5
+ * spec, threaded through four call sites in the engine, handed to the adapter —
6
+ * and read by one of the five. A run told to hold its workers to `plan` wrote
7
+ * files anyway, on `codex`, `cursor`, `opencode` and `copilot` alike.
8
+ */
9
+ import { describe, it, expect } from 'vitest'
10
+ import {
11
+ ADAPTER_PERMISSION_MODES,
12
+ codexSandboxFor,
13
+ supportsPermissionMode,
14
+ permissionModeError,
15
+ } from './permission-modes.js'
16
+ import { PERMISSION_MODES } from '../../convoy/spec-types.js'
17
+
18
+ describe('the capability table', () => {
19
+ it('covers every registered adapter', () => {
20
+ for (const name of ['claude', 'codex', 'cursor', 'opencode', 'copilot']) {
21
+ expect(ADAPTER_PERMISSION_MODES[name], `${name} declares no modes`).toBeDefined()
22
+ }
23
+ })
24
+
25
+ it('names only modes that exist in the enum', () => {
26
+ for (const [adapter, modes] of Object.entries(ADAPTER_PERMISSION_MODES)) {
27
+ for (const mode of modes) {
28
+ expect(PERMISSION_MODES, `${adapter} declares unknown mode ${mode}`).toContain(mode)
29
+ }
30
+ }
31
+ })
32
+
33
+ it('lets claude and codex carry the whole enum', () => {
34
+ expect([...ADAPTER_PERMISSION_MODES.claude].sort()).toEqual([...PERMISSION_MODES].sort())
35
+ expect([...ADAPTER_PERMISSION_MODES.codex].sort()).toEqual([...PERMISSION_MODES].sort())
36
+ })
37
+
38
+ it('does not claim read-only or bypass for the runtimes that have no such flag', () => {
39
+ for (const name of ['cursor', 'opencode', 'copilot']) {
40
+ expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('plan')
41
+ expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('default')
42
+ expect(ADAPTER_PERMISSION_MODES[name]).not.toContain('bypassPermissions')
43
+ }
44
+ })
45
+ })
46
+
47
+ describe('codexSandboxFor', () => {
48
+ it('leaves the default run exactly as it was', () => {
49
+ // acceptEdits is the default mode, and workspace-write is what the adapter
50
+ // has always passed. This fix must not change an unconfigured run.
51
+ expect(codexSandboxFor(undefined)).toBe('workspace-write')
52
+ expect(codexSandboxFor('acceptEdits')).toBe('workspace-write')
53
+ })
54
+
55
+ it('makes a worker read-only when it was told to write nothing', () => {
56
+ expect(codexSandboxFor('default')).toBe('read-only')
57
+ expect(codexSandboxFor('plan')).toBe('read-only')
58
+ })
59
+
60
+ it('widens the sandbox only when explicitly asked', () => {
61
+ expect(codexSandboxFor('bypassPermissions')).toBe('danger-full-access')
62
+ })
63
+
64
+ it('treats the do-not-ask modes as ordinary edit access', () => {
65
+ expect(codexSandboxFor('auto')).toBe('workspace-write')
66
+ expect(codexSandboxFor('dontAsk')).toBe('workspace-write')
67
+ })
68
+
69
+ it('never returns the same sandbox for plan and bypassPermissions', () => {
70
+ // The shipped behaviour: both were workspace-write, because the value was
71
+ // hardcoded and the mode never read.
72
+ expect(codexSandboxFor('plan')).not.toBe(codexSandboxFor('bypassPermissions'))
73
+ })
74
+ })
75
+
76
+ describe('supportsPermissionMode', () => {
77
+ it('accepts every mode on the adapters that map them all', () => {
78
+ for (const mode of PERMISSION_MODES) {
79
+ expect(supportsPermissionMode('claude', mode)).toBe(true)
80
+ expect(supportsPermissionMode('codex', mode)).toBe(true)
81
+ }
82
+ })
83
+
84
+ it('refuses a mode the runtime cannot express', () => {
85
+ expect(supportsPermissionMode('cursor', 'plan')).toBe(false)
86
+ expect(supportsPermissionMode('opencode', 'default')).toBe(false)
87
+ expect(supportsPermissionMode('copilot', 'bypassPermissions')).toBe(false)
88
+ })
89
+
90
+ it('accepts what those runtimes actually do', () => {
91
+ expect(supportsPermissionMode('cursor', 'acceptEdits')).toBe(true)
92
+ expect(supportsPermissionMode('opencode', 'dontAsk')).toBe(true)
93
+ })
94
+
95
+ it('does not second-guess an adapter it has never heard of', () => {
96
+ expect(supportsPermissionMode('some-future-adapter', 'plan')).toBe(true)
97
+ })
98
+ })
99
+
100
+ describe('permissionModeError', () => {
101
+ it('is null when the mode can be honoured', () => {
102
+ expect(permissionModeError('claude', 'plan')).toBeNull()
103
+ expect(permissionModeError('codex', 'bypassPermissions')).toBeNull()
104
+ })
105
+
106
+ it('names the adapter, the mode, and a way forward', () => {
107
+ const msg = permissionModeError('cursor', 'plan')!
108
+ expect(msg).toContain('cursor')
109
+ expect(msg).toContain('plan')
110
+ expect(msg).toContain('acceptEdits')
111
+ // A refusal with no alternative is just a wall.
112
+ expect(msg).toMatch(/claude|codex/)
113
+ })
114
+ })
@@ -0,0 +1,89 @@
1
+ import { PERMISSION_MODES } from '../../convoy/spec-types.js'
2
+ import type { PermissionMode } from '../../convoy/spec-types.js'
3
+
4
+ /**
5
+ * Which permission modes each adapter can actually honour.
6
+ *
7
+ * `--permission-mode` was validated against the enum, stored on the spec,
8
+ * threaded through four call sites in the engine, handed to the adapter — and
9
+ * then read by exactly one of the five. On `codex`, `cursor`, `opencode` and
10
+ * `copilot` it was accepted in full and dropped, so a run asked to hold a worker
11
+ * to `plan` went ahead and wrote files, saying nothing.
12
+ *
13
+ * Silently ignoring an authority setting is the worst of the three options. The
14
+ * other two are honouring it and refusing it, and this table is what decides
15
+ * which of those happens: a mode listed here is honoured by that adapter, and a
16
+ * mode absent from it is refused before the run starts, naming the alternatives.
17
+ *
18
+ * `ExecuteOptions.permissionMode` used to carry a note saying adapters that
19
+ * cannot express a mode ignore it. They no longer may.
20
+ */
21
+
22
+ /** Every mode, for an adapter that maps the whole enum. */
23
+ const ALL: readonly PermissionMode[] = PERMISSION_MODES
24
+
25
+ /**
26
+ * The modes that all mean "do the work without asking".
27
+ *
28
+ * `cursor --force`, `opencode`'s unattended run, and the Copilot SDK session
29
+ * with `onPermissionRequest` approving everything are each exactly this and
30
+ * nothing else: there is no flag on any of them for read-only or for a wider
31
+ * grant. They accept the modes that describe what they already do, and refuse
32
+ * the ones that would be a lie.
33
+ */
34
+ const EDITS_ONLY: readonly PermissionMode[] = ['acceptEdits', 'auto', 'dontAsk']
35
+
36
+ export const ADAPTER_PERMISSION_MODES: Record<string, readonly PermissionMode[]> = {
37
+ // Passed straight through as `--permission-mode`.
38
+ claude: ALL,
39
+ // Mapped onto the sandbox setting — see `codexSandboxFor`.
40
+ codex: ALL,
41
+ cursor: EDITS_ONLY,
42
+ opencode: EDITS_ONLY,
43
+ copilot: EDITS_ONLY,
44
+ }
45
+
46
+ /**
47
+ * The sandbox `codex exec -s` should run under for a given mode.
48
+ *
49
+ * `acceptEdits` keeps `workspace-write`, which is what the adapter has always
50
+ * passed, so the default run is byte-for-byte what it was. The other modes stop
51
+ * being silently equal to it.
52
+ */
53
+ export function codexSandboxFor(mode: PermissionMode | undefined): string {
54
+ switch (mode) {
55
+ // "writes nothing unattended" and "plan only" are both read-only to codex.
56
+ case 'default':
57
+ case 'plan':
58
+ return 'read-only'
59
+ case 'bypassPermissions':
60
+ return 'danger-full-access'
61
+ // acceptEdits, auto, dontAsk, and no mode at all.
62
+ default:
63
+ return 'workspace-write'
64
+ }
65
+ }
66
+
67
+ /** True when `adapter` can honour `mode`. Unknown adapters are not second-guessed. */
68
+ export function supportsPermissionMode(adapter: string, mode: PermissionMode): boolean {
69
+ const supported = ADAPTER_PERMISSION_MODES[adapter]
70
+ if (!supported) return true
71
+ return supported.includes(mode)
72
+ }
73
+
74
+ /**
75
+ * The refusal message for a mode an adapter cannot honour, or null when it can.
76
+ *
77
+ * Returned rather than printed so the caller decides where it goes — `run`
78
+ * prints it and exits before any worker starts.
79
+ */
80
+ export function permissionModeError(adapter: string, mode: PermissionMode): string | null {
81
+ if (supportsPermissionMode(adapter, mode)) return null
82
+ const supported = ADAPTER_PERMISSION_MODES[adapter] ?? []
83
+ return (
84
+ `The "${adapter}" adapter cannot honour permission mode "${mode}".\n` +
85
+ ` It supports: ${supported.join(', ')}\n` +
86
+ ` Use one of those, or run with --adapter claude or --adapter codex, ` +
87
+ `which support every mode.`
88
+ )
89
+ }
@@ -2117,3 +2117,75 @@ describe('branch is validated where it enters', () => {
2117
2117
  expect(validateSpec(withBranch(42)).valid).toBe(false)
2118
2118
  })
2119
2119
  })
2120
+
2121
+ /**
2122
+ * A key nobody reads is almost always a misspelling of one somebody does.
2123
+ *
2124
+ * The defect: `built_in_gates` type-checked each known field and rejected
2125
+ * nothing unrecognised, so `no_ops: false` validated clean and left the no-op
2126
+ * gate armed — the author believing they had turned it off. Under `defaults`,
2127
+ * only keys already known to be retired were flagged, so `permision_mode: plan`
2128
+ * went through in silence and ran with the default authority.
2129
+ */
2130
+ describe('unrecognised spec keys', () => {
2131
+ const withDefaults = (defaults: Record<string, unknown>) => ({
2132
+ name: 'S',
2133
+ version: 1,
2134
+ tasks: [{ id: 't', agent: 'developer', prompt: 'p', files: ['src/'] }],
2135
+ defaults,
2136
+ })
2137
+
2138
+ it('rejects a misspelled built-in gate rather than arming it', () => {
2139
+ const { valid, errors } = validateSpec(withDefaults({ built_in_gates: { no_ops: false } }))
2140
+ expect(valid).toBe(false)
2141
+ expect(errors.join('\n')).toContain('no_ops')
2142
+ // The message has to say what the real names are.
2143
+ expect(errors.join('\n')).toContain('no_op')
2144
+ })
2145
+
2146
+ it('accepts every gate the engine actually switches on', () => {
2147
+ const { valid, errors } = validateSpec(
2148
+ withDefaults({
2149
+ built_in_gates: {
2150
+ secret_scan: true,
2151
+ blast_radius: 'auto',
2152
+ dependency_audit: false,
2153
+ regression_test: false,
2154
+ browser_test: false,
2155
+ no_op: false,
2156
+ tdd_check: { mode: 'block' },
2157
+ gate_timeout: 120,
2158
+ },
2159
+ }),
2160
+ )
2161
+ expect(errors).toEqual([])
2162
+ expect(valid).toBe(true)
2163
+ })
2164
+
2165
+ it('warns on a misspelled default without failing an otherwise fine spec', () => {
2166
+ const { valid, warnings = [] } = validateSpec(withDefaults({ permision_mode: 'plan' }))
2167
+ expect(warnings.join('\n')).toContain('permision_mode')
2168
+ // A warning, so a spec that is otherwise fine still runs.
2169
+ expect(valid).toBe(true)
2170
+ })
2171
+
2172
+ it('stays quiet about every default something reads', () => {
2173
+ const { warnings } = validateSpec(
2174
+ withDefaults({
2175
+ timeout: '30m',
2176
+ max_retries: 2,
2177
+ review: 'fast',
2178
+ permission_mode: 'acceptEdits',
2179
+ circuit_breaker: { threshold: 3, cooldown_ms: 1000 },
2180
+ detect_drift: true,
2181
+ max_concurrent_reviews: 2,
2182
+ }),
2183
+ )
2184
+ expect(warnings).toEqual([])
2185
+ })
2186
+
2187
+ it('keeps the more specific message for a key that was retired', () => {
2188
+ const { warnings = [] } = validateSpec(withDefaults({ snippets: true }))
2189
+ expect(warnings.join('\n')).toContain('folded into skills')
2190
+ })
2191
+ })
@@ -135,6 +135,63 @@ const RETIRED_DEFAULTS: Record<string, string> = {
135
135
  snippets: 'snippets were folded into skills',
136
136
  }
137
137
 
138
+ /**
139
+ * Every key under `defaults` that something reads.
140
+ *
141
+ * The reasoning above applied only to keys we knew had been retired, so a key
142
+ * that was simply *misspelled* went through in silence: `permision_mode: plan`
143
+ * validated clean and ran with the default authority. Warning on anything
144
+ * unrecognised extends the same rule to the mistake people actually make.
145
+ *
146
+ * A warning rather than an error, for the reason already stated — a spec that
147
+ * is otherwise fine should not stop running because this list fell behind the
148
+ * engine. The retired keys keep their own more specific message.
149
+ */
150
+ const KNOWN_DEFAULTS = new Set([
151
+ 'adapter',
152
+ 'agent',
153
+ 'browser_test',
154
+ 'built_in_gates',
155
+ 'circuit_breaker',
156
+ 'detect_drift',
157
+ 'max_concurrent_reviews',
158
+ 'max_retries',
159
+ 'max_swarm_concurrency',
160
+ 'mcp_approve_all',
161
+ 'mcp_server_approval_timeout',
162
+ 'mcp_servers',
163
+ 'model',
164
+ 'on_dispute',
165
+ 'on_review_budget_exceeded',
166
+ 'permission_mode',
167
+ 'review',
168
+ 'review_budget',
169
+ 'review_heuristics',
170
+ 'review_stages',
171
+ 'reviewer_model',
172
+ 'timeout',
173
+ ...Object.keys(RETIRED_DEFAULTS),
174
+ ])
175
+
176
+ /**
177
+ * Every gate `defaults.built_in_gates` can switch.
178
+ *
179
+ * An error, not a warning, because this set is closed — the engine switches on
180
+ * exactly these names — and because getting it wrong is how a gate the author
181
+ * meant to turn off stays on, or one they meant to turn on never runs.
182
+ * `no_ops: false` was accepted and the no-op gate stayed armed.
183
+ */
184
+ const KNOWN_BUILT_IN_GATES = new Set([
185
+ 'secret_scan',
186
+ 'blast_radius',
187
+ 'dependency_audit',
188
+ 'regression_test',
189
+ 'browser_test',
190
+ 'no_op',
191
+ 'tdd_check',
192
+ 'gate_timeout',
193
+ ])
194
+
138
195
  export function validateSpec(spec: unknown): ValidationResult {
139
196
  const errors: string[] = []
140
197
  const warnings: string[] = []
@@ -202,6 +259,11 @@ export function validateSpec(spec: unknown): ValidationResult {
202
259
  for (const [key, why] of Object.entries(RETIRED_DEFAULTS)) {
203
260
  if (d[key] !== undefined) warnings.push(`\`defaults.${key}\` is ignored — ${why}`)
204
261
  }
262
+ // A key nobody reads is almost always a misspelling of one somebody does.
263
+ for (const key of Object.keys(d)) {
264
+ if (KNOWN_DEFAULTS.has(key)) continue
265
+ warnings.push(`\`defaults.${key}\` is not a setting anything reads — check the spelling`)
266
+ }
205
267
  if (d.timeout !== undefined && isNaN(parseTimeout(d.timeout as string))) {
206
268
  errors.push(
207
269
  '`defaults.timeout` must be in format: <number><s|m|h> (e.g. "10m")'
@@ -290,6 +352,15 @@ export function validateSpec(spec: unknown): ValidationResult {
290
352
  errors.push('`defaults.built_in_gates` must be an object')
291
353
  } else {
292
354
  const bg = d.built_in_gates as Record<string, unknown>
355
+ // Closed set: a name the engine does not switch on is a gate the
356
+ // author thinks they configured and did not.
357
+ for (const key of Object.keys(bg)) {
358
+ if (KNOWN_BUILT_IN_GATES.has(key)) continue
359
+ errors.push(
360
+ `\`defaults.built_in_gates.${key}\` is not a gate — one of: ` +
361
+ [...KNOWN_BUILT_IN_GATES].join(', '),
362
+ )
363
+ }
293
364
  const boolOrAutoFields = ['secret_scan', 'blast_radius', 'dependency_audit', 'regression_test', 'browser_test', 'no_op'] as const
294
365
  // tdd_check can be boolean or object (TDDGateConfig)
295
366
  if (bg.tdd_check !== undefined && typeof bg.tdd_check !== 'boolean' && (typeof bg.tdd_check !== 'object' || Array.isArray(bg.tdd_check) || bg.tdd_check === null)) {
@@ -0,0 +1,97 @@
1
+ /**
2
+ * `--dry-run` on the paths that already had state to act on.
3
+ *
4
+ * The defect: `opts.dryRun` was read only on the fresh-run path, so
5
+ * `convoy run --retry-failed --dry-run` and `--resume --dry-run` accepted the
6
+ * flag and then executed agents against the user's repository for real. The one
7
+ * flag people reach for to find out what will happen was the one that changed
8
+ * nothing.
9
+ */
10
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
11
+ import {
12
+ printRunDryRun,
13
+ RETRYABLE_TASK_STATUSES,
14
+ RESUMABLE_TASK_STATUSES,
15
+ } from './run.js'
16
+
17
+ function task(id: string, status: string, agent = 'developer') {
18
+ return { id, agent, status }
19
+ }
20
+
21
+ let out: string[]
22
+ beforeEach(() => {
23
+ out = []
24
+ vi.spyOn(console, 'log').mockImplementation((...a: unknown[]) => {
25
+ out.push(a.join(' '))
26
+ })
27
+ })
28
+ afterEach(() => {
29
+ vi.restoreAllMocks()
30
+ })
31
+
32
+ const text = (): string => out.join('\n')
33
+
34
+ describe('retryable and resumable status sets', () => {
35
+ it('reopens exactly the statuses the engine reopens', () => {
36
+ // engine.retryFailed's own list — kept here so a change to one is a change
37
+ // to a shared constant rather than a silent divergence.
38
+ expect([...RETRYABLE_TASK_STATUSES]).toEqual([
39
+ 'failed',
40
+ 'gate-failed',
41
+ 'timed-out',
42
+ 'review-blocked',
43
+ 'disputed',
44
+ ])
45
+ })
46
+
47
+ it('resumes the unfinished statuses, and never a done one', () => {
48
+ expect([...RESUMABLE_TASK_STATUSES]).toEqual(['pending', 'assigned', 'running'])
49
+ expect(RESUMABLE_TASK_STATUSES).not.toContain('done')
50
+ })
51
+ })
52
+
53
+ describe('printRunDryRun', () => {
54
+ it('says plainly that nothing will be executed', () => {
55
+ printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', [task('a', 'failed')], RETRYABLE_TASK_STATUSES)
56
+ expect(text()).toContain('[dry-run] Nothing will be executed.')
57
+ })
58
+
59
+ it('lists only the tasks the verb would touch', () => {
60
+ const tasks = [
61
+ task('build', 'done'),
62
+ task('test', 'failed'),
63
+ task('docs', 'gate-failed', 'writer'),
64
+ task('ship', 'pending'),
65
+ ]
66
+ printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', tasks, RETRYABLE_TASK_STATUSES)
67
+ const s = text()
68
+ expect(s).toContain('Would re-run 2 of 4 task(s)')
69
+ expect(s).toContain('test')
70
+ expect(s).toContain('docs')
71
+ // A finished task and a not-yet-started one are not retries.
72
+ expect(s).not.toMatch(/^\s+build/m)
73
+ expect(s).not.toMatch(/^\s+ship/m)
74
+ })
75
+
76
+ it('shows each task with its agent and status, so the plan can be checked', () => {
77
+ printRunDryRun('resume', 'Convoy (Resume)', 'My Run', [task('api', 'pending', 'architect')], RESUMABLE_TASK_STATUSES)
78
+ expect(text()).toMatch(/api.*architect.*pending/)
79
+ })
80
+
81
+ it('reports an empty work set rather than printing an empty list', () => {
82
+ printRunDryRun('resume', 'Convoy (Resume)', 'My Run', [task('a', 'done')], RESUMABLE_TASK_STATUSES)
83
+ const s = text()
84
+ expect(s).toContain('No unfinished tasks')
85
+ expect(s).toContain('pending, assigned, running')
86
+ })
87
+
88
+ it('uses the verb the user typed when there is nothing to retry', () => {
89
+ printRunDryRun('retry', 'Convoy (Retry Failed)', 'My Run', [task('a', 'done')], RETRYABLE_TASK_STATUSES)
90
+ expect(text()).toContain('No failed tasks to retry.')
91
+ })
92
+
93
+ it('names the run, so a preview cannot be mistaken for another one', () => {
94
+ printRunDryRun('resume', 'Pipeline (Resume)', 'Checkout Rework', [], RESUMABLE_TASK_STATUSES)
95
+ expect(text()).toContain('Pipeline (Resume): Checkout Rework')
96
+ })
97
+ })
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A flag is refused when the spec's executor will never read it.
3
+ *
4
+ * The defect: `--report-dir` is consumed where `createReporter` is called, which
5
+ * is the legacy path alone. For a `version: 1` spec — what every generated spec
6
+ * is — it was parsed, resolved against cwd, and never handed to the engine,
7
+ * which has no report directory at all. `convoy run -f spec.yml --report-dir
8
+ * ./out` exited 0 with ./out empty. `--watch` and its companions had the mirror
9
+ * problem: they live inside the engine branch, so a legacy or pipeline spec
10
+ * accepted them and ran once.
11
+ */
12
+ import { describe, it, expect } from 'vitest'
13
+ import { specExecutor } from './run.js'
14
+ import type { TaskSpec } from './convoy/spec-types.js'
15
+
16
+ const base = { name: 'S', concurrency: 1, tasks: [{ id: 't', agent: 'developer' }] }
17
+
18
+ const spec = (over: Record<string, unknown> = {}): TaskSpec =>
19
+ ({ ...base, ...over }) as unknown as TaskSpec
20
+
21
+ describe('specExecutor', () => {
22
+ it('sends a version 2 spec with a convoy chain to the pipeline orchestrator', () => {
23
+ expect(specExecutor(spec({ version: 2, depends_on_convoy: ['a.yml'] }))).toBe('pipeline')
24
+ })
25
+
26
+ it('sends a version 1 spec to the convoy engine', () => {
27
+ expect(specExecutor(spec({ version: 1 }))).toBe('engine')
28
+ })
29
+
30
+ it('sends a spec with no version to the legacy executor', () => {
31
+ expect(specExecutor(spec())).toBe('legacy')
32
+ })
33
+
34
+ it('puts a generated spec on the engine, which is why --report-dir mattered', () => {
35
+ // buildConvoyYaml always writes `version: 1`.
36
+ expect(specExecutor(spec({ version: 1, defaults: { timeout: '30m' } }))).toBe('engine')
37
+ })
38
+ })