@open-agent-toolkit/cli 0.1.41 → 0.1.43

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 (47) hide show
  1. package/assets/agents/oat-phase-implementer.md +13 -9
  2. package/assets/agents/oat-reviewer.md +16 -12
  3. package/assets/docs/cli-utilities/configuration.md +51 -35
  4. package/assets/docs/cli-utilities/workflow-gates.md +55 -0
  5. package/assets/docs/reference/cli-reference.md +1 -1
  6. package/assets/docs/reference/oat-directory-structure.md +26 -24
  7. package/assets/docs/workflows/projects/artifacts.md +22 -0
  8. package/assets/docs/workflows/projects/dispatch-ceiling.md +128 -85
  9. package/assets/docs/workflows/projects/hill-checkpoints.md +2 -0
  10. package/assets/docs/workflows/projects/implementation-execution.md +70 -46
  11. package/assets/docs/workflows/projects/index.md +2 -2
  12. package/assets/docs/workflows/projects/lifecycle.md +17 -2
  13. package/assets/docs/workflows/projects/reviews.md +17 -0
  14. package/assets/public-package-versions.json +4 -4
  15. package/assets/skills/oat-project-implement/SKILL.md +256 -95
  16. package/assets/skills/oat-project-plan/SKILL.md +60 -29
  17. package/assets/skills/oat-project-plan-writing/SKILL.md +10 -10
  18. package/assets/skills/oat-project-quick-start/SKILL.md +60 -29
  19. package/assets/skills/oat-project-review-provide/SKILL.md +25 -13
  20. package/assets/skills/oat-project-review-receive/SKILL.md +20 -10
  21. package/assets/skills/oat-review-provide/SKILL.md +14 -12
  22. package/assets/skills/oat-review-provide/references/review-artifact-template.md +1 -1
  23. package/assets/templates/plan.md +4 -4
  24. package/assets/templates/state.md +7 -3
  25. package/dist/commands/config/index.d.ts.map +1 -1
  26. package/dist/commands/config/index.js +66 -3
  27. package/dist/commands/gate/index.d.ts.map +1 -1
  28. package/dist/commands/gate/index.js +15 -3
  29. package/dist/commands/project/dispatch-ceiling/index.d.ts.map +1 -1
  30. package/dist/commands/project/dispatch-ceiling/index.js +296 -49
  31. package/dist/commands/review/latest.d.ts.map +1 -1
  32. package/dist/commands/review/latest.js +5 -2
  33. package/dist/commands/shared/frontmatter.d.ts +11 -0
  34. package/dist/commands/shared/frontmatter.d.ts.map +1 -1
  35. package/dist/commands/shared/frontmatter.js +15 -0
  36. package/dist/config/dispatch-ceiling-preset.d.ts +37 -1
  37. package/dist/config/dispatch-ceiling-preset.d.ts.map +1 -1
  38. package/dist/config/dispatch-ceiling-preset.js +20 -0
  39. package/dist/config/oat-config.d.ts +10 -1
  40. package/dist/config/oat-config.d.ts.map +1 -1
  41. package/dist/config/oat-config.js +20 -1
  42. package/dist/config/resolve.d.ts.map +1 -1
  43. package/dist/config/resolve.js +4 -0
  44. package/dist/providers/ceiling/registry.d.ts.map +1 -1
  45. package/dist/providers/ceiling/registry.js +6 -1
  46. package/dist/providers/codex/codec/sync-extension.js +1 -1
  47. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: oat-project-implement
3
- version: 2.0.24
3
+ version: 2.0.27
4
4
  description: Use when plan.md is ready for execution. Dispatches phase-level subagents with bounded fix loops; supports plan-declared parallel phase groups with worktree-isolated execution and ordered fan-in.
5
5
  oat_gateable: true
6
6
  argument-hint: '[--retry-limit <N>] [--dry-run]'
@@ -163,12 +163,14 @@ Forbidden: Selected: Tier 2 — Inline because the user did not separately menti
163
163
 
164
164
  **Legacy state migration:** If `state.md` contains `oat_execution_mode: subagent-driven`, silently ignore it. On the next bookkeeping write, remove that key. Do not redirect to `oat-project-subagent-implement` — that skill is deprecated.
165
165
 
166
- ### Dispatch Ceiling Preflight
166
+ ### Dispatch Policy Preflight
167
167
 
168
- Before any phase work, resolve and print the OAT dispatch ceiling. This is a
168
+ Before any phase work, resolve and print the OAT dispatch policy. This is a
169
169
  preflight gate, not a mid-run question.
170
170
 
171
- Use the CLI resolver as the source of truth:
171
+ Use the CLI resolver as the source of truth. The command name remains
172
+ `dispatch-ceiling` for compatibility, but the returned contract is dispatch
173
+ policy:
172
174
 
173
175
  ```bash
174
176
  oat project dispatch-ceiling resolve --provider <active-provider> --preflight --json
@@ -182,10 +184,12 @@ pnpm run cli -- project dispatch-ceiling resolve --provider <active-provider> --
182
184
 
183
185
  Resolution order:
184
186
 
185
- 1. Config keys `workflow.dispatchCeiling.providers.<provider>` (local > shared > user)
186
- 2. Project `state.md` frontmatter key `oat_dispatch_ceiling`
187
- 3. Interactive implementation preflight prompt (below)
188
- 4. Non-interactive unresolved: block before work starts
187
+ 1. Config keys `workflow.dispatchPolicy.mode` / `workflow.dispatchPolicy.policy` (local > shared > user)
188
+ 2. Compatibility config keys `workflow.dispatchCeiling.providers.<provider>` (local > shared > user)
189
+ 3. Project `state.md` frontmatter key `oat_dispatch_policy`
190
+ 4. Legacy project `state.md` frontmatter key `oat_dispatch_ceiling`
191
+ 5. Interactive implementation preflight prompt (below)
192
+ 6. Non-interactive unresolved: block before work starts
189
193
 
190
194
  **JSON response shape** (from `--json`):
191
195
 
@@ -194,6 +198,8 @@ Resolution order:
194
198
  "status": "resolved",
195
199
  "provider": "codex",
196
200
  "value": "high",
201
+ "policyMode": "managed",
202
+ "policy": "balanced",
197
203
  "source": "project-state",
198
204
  "preset": "balanced",
199
205
  "unresolved": false,
@@ -209,7 +215,10 @@ Resolution order:
209
215
  "role": "implementer",
210
216
  "preferredValue": null,
211
217
  "selectedValue": "high",
212
- "capped": false
218
+ "capped": false,
219
+ "selectionMode": "capped",
220
+ "policyMode": "managed",
221
+ "policy": "balanced"
213
222
  }
214
223
  }
215
224
  }
@@ -220,58 +229,88 @@ Read `providers.<active-provider>` for the concrete dispatch controls. The
220
229
  `dispatchArgs` field carries the provider-specific argument to pass through
221
230
  (Codex: `variant` name; Claude: `model` string). For implementer/fix dispatch,
222
231
  pass `--preferred <preferred-effort>` and use `selection.selectedValue` as the
223
- selected axis value. Never re-derive these from the preset label or a ceiling-only
224
- variant the resolver is the single compilation/join point.
232
+ selected axis value when it is present. Never re-derive these from the policy
233
+ label or a ceiling-only variant - the resolver is the single compilation/join
234
+ point.
225
235
 
226
236
  Print before phase work:
227
237
 
228
238
  ```text
229
- Dispatch ceiling: high (codex, enforced — pinned-variant)
230
- Source: project state | Preset: balanced
239
+ Dispatch policy: balanced (codex, managed capped — pinned-variant)
240
+ Resolved cap: high
241
+ Source: project state
231
242
  Provider default effort: medium
232
- Note: OAT will use pinned subagent variants up to high. Base/unpinned roles resolve through the provider default.
243
+ Note: OAT will use pinned subagent variants up to high. Base/unpinned roles resolve through the provider default only on fallback paths.
233
244
  ```
234
245
 
235
- If no ceiling resolves and the session is interactive, present the preset
236
- prompt once before starting work:
246
+ If no policy resolves and the session is interactive, present the dispatch
247
+ policy prompt once before starting work:
237
248
 
238
249
  ```text
239
- No dispatch ceiling is configured for this project.
250
+ No dispatch policy is configured for this project.
240
251
 
241
- Set the dispatch ceilingthe maximum subagent tier OAT may use.
252
+ Set the dispatch policyhow OAT should choose subagent model/effort controls.
242
253
 
243
- 1. Balanced (recommended) — Codex: high · Claude: sonnet
244
- 2. Maximum — Codex: xhigh · Claude: opus (reviews always run at this tier)
245
- 3. Cost-conscious — Codex: medium · Claude: sonnet
246
- 4. Advanced set per provider
247
- 5. No ceiling
254
+ Managed capped policies:
255
+ 1. Economy — Codex: medium · Claude: sonnet
256
+ 2. Balanced — Codex: high · Claude: sonnet (recommended)
257
+ 3. High Codex: xhigh · Claude: opus
258
+ 4. Frontier — Codex: xhigh · Claude: fable
248
259
 
249
- OAT applies this where the provider exposes a reliable mechanism (Codex: pinned
250
- variants; Claude: Task model parameter). Other providers may treat it as advisory.
260
+ Managed uncapped:
261
+ 5. Uncapped OAT selects the preferred implementer/fix target without a stored maximum cap.
262
+
263
+ Host defaults:
264
+ 6. Inherit Host Defaults — OAT does not select model/effort controls.
265
+
266
+ OAT applies managed policies where the provider exposes a reliable mechanism
267
+ (Codex: pinned variants; Claude: Task model parameter). Other providers may
268
+ treat managed policies as advisory.
251
269
  ```
252
270
 
253
- **Preset selection** persists `preset` + compiled per-provider values. On
254
- selection, print the exact compiled result (e.g., "Ceiling set: balanced
255
- Codex: high · Claude: sonnet") before proceeding.
271
+ **Managed capped policy selection (options 1-4)** persists `mode: managed`,
272
+ `policy`, and the compiled provider targets. On selection, print the exact
273
+ compiled result (e.g., "Dispatch policy set: balanced -> Codex: high · Claude:
274
+ sonnet") before proceeding.
256
275
 
257
- **Advanced (option 4)** prompts for each provider's value individually, then
258
- persists `providers` + `source` only no `preset` key.
276
+ **Uncapped (option 5)** persists explicit managed uncapped state. It does not
277
+ write provider caps, and it must not be represented by leaving dispatch policy
278
+ state absent.
259
279
 
260
- **No ceiling (option 5)** leaves `oat_dispatch_ceiling` unset; implementer
261
- subagents run at provider defaults.
280
+ **Inherit Host Defaults (option 6)** persists explicit inherit/default state.
281
+ Use this only when the user wants OAT to leave implementation, fix, and review
282
+ model/effort controls to the executing host/provider.
262
283
 
263
284
  Persist in project `state.md` frontmatter using the normalized shape:
264
285
 
265
286
  ```yaml
266
- oat_dispatch_ceiling:
267
- preset: balanced # omit when Advanced was chosen
287
+ oat_dispatch_policy:
288
+ mode: managed
289
+ policy: balanced
268
290
  providers:
269
291
  codex: high
270
292
  claude: sonnet
271
293
  source: project-state
272
294
  ```
273
295
 
274
- If no ceiling resolves and `OAT_NON_INTERACTIVE=1` or no user-response channel
296
+ For `Uncapped`:
297
+
298
+ ```yaml
299
+ oat_dispatch_policy:
300
+ mode: managed
301
+ policy: uncapped
302
+ source: project-state
303
+ ```
304
+
305
+ For `Inherit Host Defaults`:
306
+
307
+ ```yaml
308
+ oat_dispatch_policy:
309
+ mode: inherit
310
+ source: project-state
311
+ ```
312
+
313
+ If no policy resolves and `OAT_NON_INTERACTIVE=1` or no user-response channel
275
314
  exists, rerun the resolver with non-interactive behavior and stop before work
276
315
  starts if it blocks:
277
316
 
@@ -280,11 +319,11 @@ oat project dispatch-ceiling resolve --provider <active-provider> --preflight --
280
319
  ```
281
320
 
282
321
  ```text
283
- BLOCKED: Codex dispatch ceiling is unresolved in non-interactive mode.
284
- Set workflow.dispatchCeiling.providers.codex in .oat/config.json or oat_dispatch_ceiling in project state.
322
+ BLOCKED: Codex dispatch policy is unresolved in non-interactive mode.
323
+ Set workflow.dispatchPolicy.mode/workflow.dispatchPolicy.policy, workflow.dispatchCeiling.providers.codex, oat_dispatch_policy, or legacy oat_dispatch_ceiling.
285
324
  ```
286
325
 
287
- Dry-run mode must report the unresolved ceiling and planned behavior without
326
+ Dry-run mode must report the unresolved policy and planned behavior without
288
327
  modifying project state.
289
328
 
290
329
  ### Runtime dispatch selection
@@ -296,7 +335,7 @@ dispatch selection decides model/effort controls for the specific work.
296
335
 
297
336
  Use these inputs:
298
337
 
299
- - resolved dispatch ceiling and source
338
+ - resolved dispatch policy, source, and provider-specific selection
300
339
  - phase ID and phase scope
301
340
  - optional `## Dispatch Profile` row in `plan.md`
302
341
  - host-exposed provider controls, by axis
@@ -317,18 +356,28 @@ Codex rules:
317
356
  - `low`: trivial docs-only, narrow single-file, or mechanical changes
318
357
  - `medium`: normal multi-file implementation and moderate integration risk
319
358
  - `high`: broad architecture, security/auth/redaction boundaries, subtle state behavior, or repeated substantive review failures
320
- - `xhigh`: highest-risk work that requires the configured ceiling to allow xhigh
321
- 3. Selected effort is `min(preferred, resolved_ceiling)` for implementer/fix work.
322
- 4. For implementer/fix dispatch: call `oat project dispatch-ceiling resolve --provider codex --role implementer --preferred <preferred-effort>`; read `providers.codex.selection.selectedValue` and `providers.codex.dispatchArgs.variant` for the selected role name (e.g., `oat-phase-implementer-medium`). The resolver caps the preferred effort against the ceiling; never pass a ceiling-only implementer variant when `selection.selectedValue` is lower.
323
- 5. For review dispatch: call `oat project dispatch-ceiling resolve --provider codex --role reviewer`; read `providers.codex.dispatchArgs.variant` for the reviewer role name (e.g., `oat-reviewer-high`). Reviewer always targets the ceiling for deterministic quality gate behavior.
324
- 6. Use base/unpinned Codex roles only as a fallback or explicit provider-default choice. Log `Selected effort: provider-default`, display provider default effort when known, and do not describe this as parent-ceiling inheritance.
325
- 7. Do not use top-level per-call `reasoning_effort` as the standard OAT selected-effort path; dogfooding showed that path can be inconsistent.
359
+ - `xhigh`: highest-risk work that requires a capped policy to allow xhigh or a managed `Uncapped` policy to select it
360
+ 3. For capped managed implementer/fix work, selected effort is `min(preferred, resolved_cap)`.
361
+ 4. For managed `Uncapped` implementer/fix work, selected effort is the preferred effort with no cap.
362
+ 5. For inherit/default mode, the resolver returns no selected dispatch args. Use the base/unpinned Codex role, log `Selected effort: provider-default`, display provider default effort when known, and do not describe this as managed uncapped behavior.
363
+ 6. For implementer/fix dispatch: call `oat project dispatch-ceiling resolve --provider codex --role implementer --preferred <preferred-effort>`; read `providers.codex.selection.selectedValue` and `providers.codex.dispatchArgs.variant` for the selected role name (e.g., `oat-phase-implementer-medium`). Never pass a cap-only implementer variant when `selection.selectedValue` is lower.
364
+ 7. For review dispatch: call `oat project dispatch-ceiling resolve --provider codex --role reviewer`; read `providers.codex.dispatchArgs.variant`.
365
+ - Capped managed policy: reviewer targets the configured cap for deterministic quality gate behavior.
366
+ - Managed `Uncapped`: no reviewer target exists; use base/unpinned reviewer fallback and log `selectionMode=no-review-target`, `selectedValue=null`, and `effort_axis=provider-default`.
367
+ - Inherit/default: no reviewer target exists; use base/unpinned reviewer fallback and log `selectionMode=inherit-default`, `selectedValue=null`, and `effort_axis=provider-default`.
368
+ 8. Codex payload-first assertion applies only when the resolver returns a pinned variant. If `effort_axis=selected:<value>`, the actual `spawn_agent` payload MUST use the matching pinned `agent_type`. If the resolver returns no variant, use the base role and log provider-default.
369
+ 9. Do not use top-level per-call `reasoning_effort` as the standard OAT selected-effort path; dogfooding showed that path can be inconsistent.
326
370
 
327
371
  Claude rules:
328
372
 
329
- - Claude ceiling is model-based: `haiku < sonnet < opus`.
330
- - Implementer/fix dispatch: classify the preferred model (`haiku`, `sonnet`, or `opus`) and pass it to the resolver as `--preferred <preferred-model>`. The resolver selects the lowest sufficient model capped by the resolved Claude ceiling (`min(preferred, ceiling)`).
331
- - Review dispatch: target the resolved Claude ceiling directly.
373
+ - Claude policy selection is model-based: `haiku < sonnet < opus < fable`.
374
+ - Implementer/fix dispatch: classify the preferred model (`haiku`, `sonnet`, `opus`, or `fable`) and pass it to the resolver as `--preferred <preferred-model>`.
375
+ - Capped managed policy: the resolver selects `min(preferred, resolved_cap)`.
376
+ - Managed `Uncapped`: the resolver selects the preferred model with no cap.
377
+ - Inherit/default: the resolver returns no selected model; omit `model` so Claude Code inherits host/default behavior.
378
+ - Review dispatch:
379
+ - Capped managed policy: target the configured policy cap directly.
380
+ - Managed `Uncapped` or inherit/default: no reviewer target exists; omit `model` and log inherited/default model behavior.
332
381
  - For implementer/fix dispatch, call `oat project dispatch-ceiling resolve --provider claude --role implementer --preferred <preferred-model> --orchestrator-tier <current-orchestrator-tier>`; for review dispatch, call the same resolver with `--role reviewer` and no `--preferred`. Read `providers.claude.selection.selectedValue` and `providers.claude.dispatchArgs.model` for the selected model string to pass. Pass `--orchestrator-tier` so the resolver can flag above-orchestrator upgrade requests and set `verifyOnDispatch` correctly.
333
382
  - Pass `model: "<value>"` when `model_axis=selected:<value>` on the Task tool call.
334
383
  - Keep `effort_axis=not-applicable`; Claude Code has no separate per-dispatch effort axis.
@@ -345,14 +394,16 @@ Structured dispatch log:
345
394
  OAT Dispatch: Phase {phase_id} {implementation | fix | review}
346
395
  Host: {Claude Code | Codex | Cursor | other host}
347
396
  Preferred effort: {low | medium | high | xhigh | provider-default | not-applicable}
348
- Dispatch ceiling: {resolved ceiling value}
397
+ Dispatch policy: {economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped}
398
+ Resolved cap: {resolved cap value | none}
349
399
  Selected effort: {low | medium | high | xhigh | provider-default | not-applicable}
350
- Ceiling source: {repo config | project state | preflight prompt}
400
+ Policy source: {repo config | project state | preflight prompt}
351
401
  Provider default effort: {value | unknown | not-applicable}
402
+ Selection mode: {capped | uncapped | review-target | no-review-target | inherit-default}
352
403
  Model axis: { selected:<value> | inherited | not-applicable | host-auto }
353
404
  Effort axis: { selected:<value> | provider-default | inherited | not-applicable | host-auto }
354
405
  Dispatch target: {host-specific subagent/role/tool target}
355
- Rationale: {short rationale grounded in phase scope and any ceiling cap}
406
+ Rationale: {short rationale grounded in phase scope and any policy cap/uncapped/default behavior}
356
407
  ```
357
408
 
358
409
  Codex capped example:
@@ -361,46 +412,70 @@ Codex capped example:
361
412
  OAT Dispatch: Phase p02 implementation
362
413
  Host: Codex
363
414
  Preferred effort: high
364
- Dispatch ceiling: medium
415
+ Dispatch policy: economy
416
+ Resolved cap: medium
365
417
  Selected effort: medium
366
- Ceiling source: repo config
418
+ Policy source: repo config
367
419
  Provider default effort: high
420
+ Selection mode: capped
368
421
  Model axis: inherited
369
422
  Effort axis: selected:medium
370
423
  Dispatch target: oat-phase-implementer-medium
371
- Rationale: normal multi-file implementation; high preferred due to integration risk, capped by configured ceiling.
424
+ Rationale: normal multi-file implementation; high preferred due to integration risk, capped by configured policy.
372
425
  ```
373
426
 
374
- Codex reviewer example:
427
+ Codex uncapped implementer example:
428
+
429
+ ```text
430
+ OAT Dispatch: Phase p02 implementation
431
+ Host: Codex
432
+ Preferred effort: xhigh
433
+ Dispatch policy: uncapped
434
+ Resolved cap: none
435
+ Selected effort: xhigh
436
+ Policy source: project state
437
+ Provider default effort: medium
438
+ Selection mode: uncapped
439
+ Model axis: inherited
440
+ Effort axis: selected:xhigh
441
+ Dispatch target: oat-phase-implementer-xhigh
442
+ Rationale: high-risk phase; managed uncapped policy allows the preferred pinned variant. Actual host support for upward effort selection must be verified by the dispatching host.
443
+ ```
444
+
445
+ Codex capped reviewer example:
375
446
 
376
447
  ```text
377
448
  OAT Dispatch: Phase p02 review
378
449
  Host: Codex
379
450
  Preferred effort: high
380
- Dispatch ceiling: high
381
- Selected effort: high
382
- Ceiling source: project state
451
+ Dispatch policy: high
452
+ Resolved cap: xhigh
453
+ Selected effort: xhigh
454
+ Policy source: project state
383
455
  Provider default effort: medium
456
+ Selection mode: review-target
384
457
  Model axis: inherited
385
- Effort axis: selected:high
386
- Dispatch target: oat-reviewer-high
387
- Rationale: reviewer runs at the configured ceiling for deterministic quality gate behavior.
458
+ Effort axis: selected:xhigh
459
+ Dispatch target: oat-reviewer-xhigh
460
+ Rationale: reviewer runs at the configured policy cap for deterministic quality gate behavior.
388
461
  ```
389
462
 
390
- Codex base/unpinned fallback example:
463
+ Codex inherit/default fallback example:
391
464
 
392
465
  ```text
393
466
  OAT Dispatch: Phase p02 review
394
467
  Host: Codex
395
468
  Preferred effort: provider-default
396
- Dispatch ceiling: high
469
+ Dispatch policy: inherit host defaults
470
+ Resolved cap: none
397
471
  Selected effort: provider-default
398
- Ceiling source: project state
472
+ Policy source: project state
399
473
  Provider default effort: medium
474
+ Selection mode: inherit-default
400
475
  Model axis: inherited
401
476
  Effort axis: provider-default
402
477
  Dispatch target: oat-reviewer
403
- Rationale: base unpinned role fallback; effective effort follows Codex provider default.
478
+ Rationale: explicit inherit/default policy; base unpinned role follows Codex provider default.
404
479
  ```
405
480
 
406
481
  Generic sidecar/explorer dispatch:
@@ -416,9 +491,10 @@ Codex generic explorer example:
416
491
  OAT Dispatch: p02-t10 sidecar exploration
417
492
  Host: Codex
418
493
  Preferred effort: provider-default
419
- Dispatch ceiling: xhigh
494
+ Dispatch policy: high
495
+ Resolved cap: xhigh
420
496
  Selected effort: provider-default
421
- Ceiling source: project state
497
+ Policy source: project state
422
498
  Provider default effort: xhigh
423
499
  Model axis: inherited
424
500
  Effort axis: provider-default
@@ -435,12 +511,17 @@ effort_axis:
435
511
  selected:<value> | provider-default | inherited | not-applicable | host-auto,
436
512
  }
437
513
  dispatch_ceiling: { resolved ceiling value }
514
+ dispatch_policy:
515
+ {
516
+ economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped,
517
+ }
438
518
  ceiling_source: { repo config | project state | preflight prompt }
519
+ policy_source: { repo config | project state | preflight prompt }
439
520
  provider_default_effort: { value | unknown | not-applicable }
440
521
  dispatch_rationale: { short rationale }
441
522
  ```
442
523
 
443
- ### Dispatch Ceiling Enforcement Log
524
+ ### Dispatch Policy Enforcement Log
444
525
 
445
526
  After each phase dispatch (implementation, fix, or review), append one enforcement
446
527
  log line. The log reflects the `mode` and `mechanism` returned by
@@ -449,18 +530,20 @@ log line. The log reflects the `mode` and `mechanism` returned by
449
530
  **Three-state log format:**
450
531
 
451
532
  ```text
452
- Dispatch ceiling: {value} ({provider}, {mode} — {mechanism detail})
533
+ Dispatch policy: {policy}; selected={selected value | none}; cap={value | none} ({provider}, {mode} — {mechanism detail})
453
534
  ```
454
535
 
455
536
  **Log examples (matching resolver output):**
456
537
 
457
538
  ```text
458
- Dispatch ceiling: high (codex, enforced — variant oat-phase-implementer-high)
459
- Dispatch ceiling: high (codex, enforced — variant oat-reviewer-high)
460
- Dispatch ceiling: sonnet (claude, enforced — Task model arg)
461
- Dispatch ceiling: opus (claude, enforcedTask model arg)
462
- Dispatch ceiling: high (cursor, unsupportedno adapter; informational)
463
- Dispatch ceiling: unresolved (codex, advisoryceiling set but no value resolved)
539
+ Dispatch policy: balanced; selected=high; cap=high (codex, enforced — variant oat-phase-implementer-high)
540
+ Dispatch policy: high; selected=xhigh; cap=xhigh (codex, enforced — variant oat-reviewer-xhigh)
541
+ Dispatch policy: uncapped; selected=xhigh; cap=none (codex, enforced — variant oat-phase-implementer-xhigh)
542
+ Dispatch policy: inherit host defaults; selected=none; cap=none (codex, advisorybase role follows provider default)
543
+ Dispatch policy: balanced; selected=sonnet; cap=sonnet (claude, enforcedTask model arg)
544
+ Dispatch policy: frontier; selected=fable; cap=fable (claude, enforcedTask model arg)
545
+ Dispatch policy: high; selected=none; cap=high (cursor, unsupported — no adapter; informational)
546
+ Dispatch policy: unresolved; selected=none; cap=none (codex, advisory — policy set but no value resolved)
464
547
  ```
465
548
 
466
549
  **Verify-on-upgrade (`verifyOnDispatch: true`):**
@@ -471,16 +554,18 @@ logging `enforced`, confirm the actual model/tier used by the dispatched agent.
471
554
  If the provider honored the request, log `enforced`. If it did not:
472
555
 
473
556
  ```text
474
- Dispatch ceiling: opus (claude, advisory — provider did not honor upgrade; ran sonnet)
557
+ Dispatch policy: high; selected=opus; cap=opus (claude, advisory — provider did not honor upgrade; ran sonnet)
475
558
  ```
476
559
 
477
560
  **`enforced`** — the adapter compiled concrete dispatch args and the provider
478
561
  accepted them. Log value + provider + mechanism detail (variant name or "Task
479
562
  model arg").
480
563
 
481
- **`advisory`** — the adapter supports the ceiling but no concrete value resolved,
482
- or the provider is known but could not be verified. Log with note "ceiling set
483
- but no value resolved" or "provider did not honor upgrade; ran \<tier\>".
564
+ **`advisory`** — the adapter supports the policy but no concrete value resolved,
565
+ the policy intentionally inherits provider defaults, or the provider is known
566
+ but could not be verified. Log with note "policy set but no value resolved",
567
+ "base role follows provider default", or "provider did not honor upgrade; ran
568
+ \<tier\>".
484
569
 
485
570
  **`unsupported`** — the provider has no registered adapter. Log with note "no
486
571
  adapter; informational". Never block on unsupported — dispatch follows provider
@@ -679,6 +764,39 @@ This setting controls only the extra `oat-project-review-provide` lifecycle revi
679
764
 
680
765
  **On resume:** If `oat_auto_review_at_hill_checkpoints` is already present in plan.md frontmatter, skip Touchpoint A entirely — do not re-ask, do not re-read config, do not print the auto-review note. The stored value is authoritative. If only legacy `oat_auto_review_at_checkpoints` is present, treat it as authoritative for this run and write the new `oat_auto_review_at_hill_checkpoints` key on the next plan frontmatter update.
681
766
 
767
+ ### Step 2.6: Validate Optional Phase Review Gate
768
+
769
+ Read `oat_phase_review_gate` from `"$PROJECT_PATH/plan.md"` frontmatter when present.
770
+
771
+ This is the plan-level `phaseReviewGate` setting: an optional, non-pausing external lifecycle review gate that runs after a phase's standard per-phase self-review passes. It uses the existing `oat gate review` target configuration to run a cross-provider review, then maps the produced review artifact to a blocking/non-blocking gate result.
772
+
773
+ Valid shape:
774
+
775
+ ```yaml
776
+ oat_phase_review_gate:
777
+ enabled: true
778
+ phases: [] # empty or omitted = every implementation phase
779
+ review_type: code
780
+ exit_nonzero_on: important
781
+ ```
782
+
783
+ Validation rules:
784
+
785
+ - Missing, `null`, or `enabled: false` means disabled.
786
+ - `enabled: true` activates the gate.
787
+ - `phases` is optional. If missing or empty (`[]`), run after every implementation phase. If populated, every value must be a known plan phase ID.
788
+ - `review_type` is optional and defaults to `code`. This skill only supports `code` phase gates; any other value is invalid for implementation phase execution.
789
+ - `exit_nonzero_on` is optional and defaults to `important`. Allowed values: `critical`, `important`, `medium`, `minor`.
790
+
791
+ If the setting is invalid, stop before task execution and ask the user to repair `plan.md`. Do not silently disable a malformed gate.
792
+
793
+ This setting is independent from HiLL checkpoints:
794
+
795
+ - It does not pause when the gate passes.
796
+ - It does not append to `oat_hill_completed`.
797
+ - It does not alter `oat_plan_hill_phases` or `oat_auto_review_at_hill_checkpoints`.
798
+ - It uses the existing gate target config; do not hardcode `--target` in reusable plan execution unless the user explicitly asks for manual/debug routing.
799
+
682
800
  ### Step 3: Check Implementation State
683
801
 
684
802
  Check if implementation already started:
@@ -763,8 +881,10 @@ For each phase `pNN` in the plan (or each phase in the current parallel group),
763
881
  workflow_mode: {from state.md or plan.md frontmatter}
764
882
  model_axis: {selected:<value> | inherited | not-applicable | host-auto; omit if unknown}
765
883
  effort_axis: {selected:<value> | provider-default | inherited | not-applicable | host-auto; omit if unknown}
766
- dispatch_ceiling: {resolved ceiling value; omit if unknown}
767
- ceiling_source: {repo config | project state | preflight prompt; omit if unknown}
884
+ dispatch_policy: {economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped; omit if unknown}
885
+ dispatch_ceiling: {resolved cap value; omit if none or unknown}
886
+ policy_source: {repo config | project state | preflight prompt; omit if unknown}
887
+ ceiling_source: {repo config | project state | preflight prompt; omit if unknown; compatibility alias for policy_source}
768
888
  provider_default_effort: {value | unknown | not-applicable; omit if unknown}
769
889
  dispatch_rationale: {short rationale; omit if unknown}
770
890
  ```
@@ -815,8 +935,8 @@ Escalate the runtime dispatch control when there is evidence that the current co
815
935
  When escalation is needed:
816
936
 
817
937
  1. If a stronger available control exists, re-dispatch at the next stronger control and include the reason in the scope packet. The escalation ladder is provider-specific:
818
- - **Codex:** `selected:low -> selected:medium -> selected:high -> selected:xhigh`, capped by the resolved Codex dispatch ceiling.
819
- - **Claude Code:** `selected:haiku -> selected:sonnet -> selected:opus`, capped by the resolved Claude dispatch ceiling.
938
+ - **Codex:** `selected:low -> selected:medium -> selected:high -> selected:xhigh`, capped by the resolved managed cap when one exists; managed `Uncapped` may select up to the preferred value; inherit/default mode has no OAT escalation control.
939
+ - **Claude Code:** `selected:haiku -> selected:sonnet -> selected:opus -> selected:fable`, capped by the resolved managed cap when one exists; managed `Uncapped` may select up to the preferred model; inherit/default mode has no OAT escalation control.
820
940
  2. Count the escalation redispatch against the existing bounded retry budget. Escalation changes the control; it does not create extra retry attempts.
821
941
  3. Record a compact note in `implementation.md` when practical:
822
942
  - `Dispatch: p03 escalated to model_axis=selected:opus, effort_axis=not-applicable after repeated review failures.` (Claude Code)
@@ -835,8 +955,9 @@ After the implementer returns DONE (or DONE_WITH_CONCERNS without correctness co
835
955
  **Dispatch:**
836
956
 
837
957
  - Use the same tier that was selected at start.
838
- - For Codex, dispatch the reviewer variant matching the resolved ceiling (`oat-reviewer-low|medium|high|xhigh`) for deterministic quality gates.
839
- - For Claude Code, cap any selected review model by the resolved Claude ceiling and keep `effort_axis=not-applicable`.
958
+ - For Codex with a capped managed policy, dispatch the reviewer variant matching the resolved cap (`oat-reviewer-low|medium|high|xhigh`) for deterministic quality gates.
959
+ - For Codex with managed `Uncapped` or inherit/default mode, no reviewer target exists; use base `oat-reviewer`, log `effort_axis=provider-default`, and explain that the base role follows the provider default.
960
+ - For Claude Code with a capped managed policy, pass the resolved cap as the review `model`; managed `Uncapped` or inherit/default mode omits `model` because no reviewer target exists. Always keep `effort_axis=not-applicable`.
840
961
  - Tier 1: dispatch the selected reviewer target via provider-native subagent mechanism with Review Scope:
841
962
 
842
963
  ```
@@ -848,16 +969,18 @@ After the implementer returns DONE (or DONE_WITH_CONCERNS without correctness co
848
969
  workflow_mode: {from state.md}
849
970
  artifact_paths: {same as Phase Scope}
850
971
  tasks_in_scope: {list of pNN-tNN IDs in the phase}
851
- dispatch_ceiling: {resolved ceiling value}
852
- ceiling_source: {repo config | project state | preflight prompt}
972
+ dispatch_policy: {economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped}
973
+ dispatch_ceiling: {resolved cap value | null}
974
+ policy_source: {repo config | project state | preflight prompt}
975
+ ceiling_source: {repo config | project state | preflight prompt} # compatibility alias for policy_source
853
976
  provider_default_effort: {value | unknown | not-applicable}
854
- model_axis: inherited
855
- effort_axis: selected:{resolved Codex ceiling} # on Codex; use not-applicable on Claude Code
856
- dispatch_rationale: reviewer runs at the configured ceiling for deterministic quality gate behavior
977
+ model_axis: {inherited | selected:<Claude model>}
978
+ effort_axis: {selected:<Codex value> | provider-default | not-applicable}
979
+ dispatch_rationale: {capped reviewer target | uncapped/inherit reviewer fallback}
857
980
  ```
858
981
 
859
982
  - For Codex Tier 1 dispatches, send the Review Scope block as a self-contained packet and keep fresh context (`fork_context: false`). The reviewer is expected to reconstruct context from git state and the OAT artifacts listed above.
860
- - For Codex Tier 1 review dispatches, use `agent_type: "oat-reviewer-low|medium|high|xhigh"` matching the resolved ceiling. Use base `oat-reviewer` only as a provider-default fallback and log `effort_axis=provider-default`. For Claude Code review dispatches, do not pass a per-review effort override because the effort axis is not applicable; if selecting a model, cap it by the resolved Claude ceiling.
983
+ - For Codex Tier 1 review dispatches, use `agent_type: "oat-reviewer-low|medium|high|xhigh"` only when the resolver returns a pinned reviewer variant for a capped managed policy. Use base `oat-reviewer` for managed `Uncapped`, inherit/default mode, or provider-default fallback, and log `effort_axis=provider-default`. For Claude Code review dispatches, do not pass a per-review effort override because the effort axis is not applicable; pass `model` only when the resolver returns a selected review model.
861
984
  - Treat the commit range as authoritative for review scope. `files_changed` is optional orientation metadata only.
862
985
  - If a Codex reviewer does not return a terminal result on the first wait, poll once more. If it still has not concluded, send one concise nudge to return immediately with current findings. If the reviewer still does not conclude, treat the Tier 1 review dispatch as failed for this phase and perform the review inline instead of waiting indefinitely.
863
986
 
@@ -892,6 +1015,43 @@ On reviewer verdict `fail`, run a bounded fix loop.
892
1015
  - **Sequential mode:** STOP the run. Surface to user with phase ID, unresolved findings, review artifact path. Do not proceed to subsequent phases.
893
1016
  - **Parallel group mode:** mark the phase `excluded`. Do not merge its worktree. Continue the remaining phases in the group. Report in Outstanding Items after the group completes.
894
1017
 
1018
+ ### Optional External Phase Review Gate
1019
+
1020
+ After the standard per-phase reviewer passes and after the required phase bookkeeping commit is cleanly recorded, check `oat_phase_review_gate`.
1021
+
1022
+ If the gate is enabled and the current phase is selected:
1023
+
1024
+ 1. Run the gate from the orchestration branch with the active project path:
1025
+
1026
+ ```bash
1027
+ oat --json gate review \
1028
+ --project "$PROJECT_PATH" \
1029
+ --review-type code \
1030
+ --review-scope "{pNN}" \
1031
+ --exit-nonzero-on "{threshold}" \
1032
+ '$oat-project-review-provide code {pNN}'
1033
+ ```
1034
+
1035
+ - `{threshold}` comes from `oat_phase_review_gate.exit_nonzero_on` (default: `important`).
1036
+ - `{pNN}` is the completed phase ID.
1037
+ - Do not pass `--target` in normal execution; the existing gate config selects the cross-provider target.
1038
+ - The gate CLI injects gate context into the review prompt. The produced review artifact must use `oat_review_invocation: gate`.
1039
+
1040
+ 2. Parse the JSON result. The gate verdict (`exit_nonzero_on: {threshold}`) decides whether the phase **stops**; it does not decide whether sub-threshold findings are ignored. Either way the produced artifact must be **consumed** — passing gate artifacts are not left unprocessed at the top level of `reviews/`.
1041
+ - `status: "ok"` / exit code `0` means the phase gate passed at the configured threshold, so the phase does not stop. Still run `oat-project-review-receive` for the reported artifact path in non-pausing **judgment-sweep** mode (pass gate-passed context so receive selects sweep disposition). The sweep makes a per-finding judgment for each Medium/Minor — defer to final (default), address now (small/contained/low-risk fixes only), or reject with rationale — writes those durable dispositions into `implementation.md`, and archives the artifact. Then continue without pausing. Address-now fixes from a passing gate do **not** re-trigger the standard reviewer or re-gate the phase.
1042
+ - `status: "blocked"` / non-zero exit due to review findings means blocking findings exist. Run `oat-project-review-receive` for the reported artifact path (blocking disposition) before treating the gate review as consumed.
1043
+ - A non-zero exit caused by target execution failure, artifact validation failure, or missing review artifact is an operational failure. Stop and surface the gate output; do not continue as if the gate passed.
1044
+
1045
+ 3. If `oat-project-review-receive` adds fix tasks (blocking gate, or a sweep address-now fix that revealed a Critical/Important concern):
1046
+ - Return to task execution for the newly added review-fix tasks.
1047
+ - After fixes land, re-run the standard per-phase reviewer and this external phase gate for the same phase.
1048
+ - Continue only after both the standard reviewer and the external phase gate pass.
1049
+ - Bound these gate block → fix → re-gate rounds by `oat_orchestration_retry_limit` (from `state.md`, default `2`). If the limit is exhausted with the gate still blocking, apply the same terminal handling as the standard bounded fix loop: **sequential mode** stops the run and surfaces the phase ID, unresolved findings, and artifact path; **parallel group mode** marks the phase `excluded` and reports it in Outstanding Items.
1050
+
1051
+ 4. If the judgment sweep (passing gate) records only deferrals/rejections and no blocking fix tasks, record the receive result and continue.
1052
+
1053
+ For a parallel group, run selected phase gates after fan-in and bookkeeping, one gate per successfully merged phase in plan order. If a phase gate blocks, stop the schedule and process that gate's review before starting later schedule entries.
1054
+
895
1055
  ### Parallel Group Execution
896
1056
 
897
1057
  When the current schedule entry is a multi-phase group, execute as follows.
@@ -966,7 +1126,7 @@ When the current schedule entry is a multi-phase group, execute as follows.
966
1126
 
967
1127
  For phases that were excluded (fix-loop exhausted), preserve the worktree and log its path in `implementation.md` Outstanding Items.
968
1128
 
969
- 8. **Bookkeeping commit** after the group completes. Then HiLL checkpoint check.
1129
+ 8. **Bookkeeping commit** after the group completes. Then run any selected external phase review gates. After those gates pass, perform the HiLL checkpoint check.
970
1130
 
971
1131
  ### Step 7: Artifact Updates After Each Phase (or Group)
972
1132
 
@@ -1039,7 +1199,7 @@ git add {PROJECT_PATH}/implementation.md {PROJECT_PATH}/state.md {PROJECT_PATH}/
1039
1199
  git commit -m "chore(oat): bookkeeping after {pNN} {pass|fail}"
1040
1200
  ```
1041
1201
 
1042
- Then check HiLL checkpoint — if the phase ID is in `oat_plan_hill_phases`, pause for user approval before continuing.
1202
+ Then run the optional external phase review gate for the completed phase when `oat_phase_review_gate` selects it. After the gate passes or is skipped, check HiLL checkpoint — if the phase ID is in `oat_plan_hill_phases`, pause for user approval before continuing.
1043
1203
 
1044
1204
  ### Step 8: Check Plan Phase Completion
1045
1205
 
@@ -1130,6 +1290,7 @@ Do not use `git add -A` or glob patterns. Only commit the three project artifact
1130
1290
 
1131
1291
  - **Workflow HiLL** (`oat_hill_checkpoints` in state.md): Gates between workflow phases (discovery → spec → design → plan → implement). Checked by oat-project-progress router.
1132
1292
  - **Plan phase checkpoints** (`oat_plan_hill_phases` in plan.md): Gates at plan phase boundaries during implementation. `[]` means pause after every phase; a populated array pauses only after listed phases. The field may be absent only before the first implementation-run confirmation. Listed phases are where you stop AFTER completing them.
1293
+ - **Phase review gate** (`oat_phase_review_gate` in plan.md): Optional non-pausing external review gate after a completed phase passes the standard reviewer. Missing/disabled means skip; `phases: []` means gate every implementation phase. Passing gates continue automatically; blocking gates are received/fixed before execution proceeds.
1133
1294
 
1134
1295
  **Revision phase completion handling:**
1135
1296
 
@@ -1296,7 +1457,7 @@ echo "$FINAL_ROW"
1296
1457
  **If final review row exists and status is `passed`:**
1297
1458
 
1298
1459
  - Example row:
1299
- - `| final | code | passed | 2026-01-28 | reviews/final-review-2026-01-28.md |`
1460
+ - `| final | code | passed | 2026-01-28 | reviews/final-review-2026-01-28T140322Z.md |`
1300
1461
  - Check:
1301
1462
  ```bash
1302
1463
  echo "$FINAL_ROW" | grep -qE "^\\|\\s*final\\s*\\|.*\\|\\s*passed\\s*\\|" && echo "passed"
@@ -1446,7 +1607,7 @@ Final verification:
1446
1607
 
1447
1608
  Final review:
1448
1609
  - Status: ✓ passed
1449
- - Artifact: reviews/final-review-{date}.md
1610
+ - Artifact: reviews/final-review-{timestamp}.md
1450
1611
 
1451
1612
  Next: Create PR or run the oat-project-pr-final skill (when available)
1452
1613
  ```