@open-agent-toolkit/cli 0.1.54 → 0.1.59

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 (45) hide show
  1. package/assets/agents/oat-phase-implementer.md +195 -238
  2. package/assets/docs/cli-utilities/configuration.md +7 -6
  3. package/assets/docs/contributing/index.md +1 -0
  4. package/assets/docs/contributing/smoke-testing.md +284 -0
  5. package/assets/docs/provider-sync/providers.md +11 -11
  6. package/assets/docs/provider-sync/scope-and-surface.md +2 -2
  7. package/assets/docs/workflows/projects/dispatch-ceiling.md +29 -26
  8. package/assets/docs/workflows/projects/evidence-layers.md +123 -0
  9. package/assets/docs/workflows/projects/implementation-execution.md +160 -406
  10. package/assets/docs/workflows/projects/index.md +8 -0
  11. package/assets/docs/workflows/projects/orchestration-model.md +190 -0
  12. package/assets/docs/workflows/projects/programmatic-execution.md +137 -0
  13. package/assets/docs/workflows/projects/review-flavors.md +129 -0
  14. package/assets/docs/workflows/skills/repo-improve.md +14 -0
  15. package/assets/public-package-versions.json +4 -4
  16. package/assets/skills/oat-agent-instructions-analyze/references/docs/provider-reference.md +5 -4
  17. package/assets/skills/oat-agent-instructions-apply/references/docs/provider-reference.md +5 -4
  18. package/assets/skills/oat-dispatch-subagents/SKILL.md +6 -1
  19. package/assets/skills/oat-dispatch-subagents/references/record-schema.md +5 -0
  20. package/assets/skills/oat-project-dispatch-subagents/SKILL.md +37 -15
  21. package/assets/skills/oat-project-implement/SKILL.md +63 -1904
  22. package/assets/skills/oat-project-implement/references/completion-and-closeout.md +431 -0
  23. package/assets/skills/oat-project-implement/references/dispatch-and-dry-run.md +715 -0
  24. package/assets/skills/oat-project-implement/references/phase-execution.md +270 -0
  25. package/assets/skills/oat-project-implement/references/plan-and-resume.md +279 -0
  26. package/assets/skills/oat-project-import-plan/SKILL.md +16 -8
  27. package/assets/skills/oat-project-plan/SKILL.md +15 -7
  28. package/assets/skills/oat-project-plan-writing/SKILL.md +74 -40
  29. package/assets/skills/oat-project-quick-start/SKILL.md +16 -8
  30. package/assets/skills/oat-project-review-provide/SKILL.md +8 -5
  31. package/assets/skills/oat-repo-improve/SKILL.md +17 -2
  32. package/assets/skills/oat-repo-improve/references/audit-playbook.md +6 -0
  33. package/assets/skills/oat-worktree-bootstrap/SKILL.md +22 -12
  34. package/assets/skills/oat-worktree-bootstrap/references/worktree-conventions.md +8 -8
  35. package/assets/skills/oat-worktree-bootstrap-auto/SKILL.md +233 -44
  36. package/dist/commands/docs/index-generate/index.d.ts.map +1 -1
  37. package/dist/commands/docs/index-generate/index.js +10 -5
  38. package/dist/commands/doctor/index.d.ts.map +1 -1
  39. package/dist/commands/doctor/index.js +7 -4
  40. package/dist/commands/gate/index.d.ts +9 -1
  41. package/dist/commands/gate/index.d.ts.map +1 -1
  42. package/dist/commands/gate/index.js +62 -2
  43. package/dist/commands/project/dispatch-ceiling/index.js +2 -2
  44. package/package.json +4 -4
  45. package/assets/skills/oat-worktree-bootstrap-auto/scripts/bootstrap.sh +0 -236
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: oat-project-implement
3
- version: 2.0.36
4
- description: Use when plan.md is ready for execution. Dispatches phase coordinators that select one exact target-pinned worker per task; supports bounded fix loops and plan-declared worktree-isolated parallel phases.
3
+ version: 2.0.40
4
+ description: Use when plan.md is ready for execution. Dispatches one phase implementer per phase, owns independent phase review and bounded fix routing, and supports plan-declared worktree-isolated parallel phases.
5
5
  oat_gateable: true
6
6
  argument-hint: '[--retry-limit <N>] [--dry-run]'
7
7
  disable-model-invocation: true
@@ -17,6 +17,24 @@ Execute the implementation plan task-by-task with full state tracking.
17
17
 
18
18
  **Required:** Complete implementation plan. If missing, run the `oat-project-plan` skill first.
19
19
 
20
+ ## Shared Subagent Dispatch Contract
21
+
22
+ Before resolving or launching any phase implementer, optional nested worker,
23
+ fix continuation, or reviewer, read and follow
24
+ `.agents/skills/oat-project-dispatch-subagents/SKILL.md`. The project adapter
25
+ resolves lifecycle scope and then requires
26
+ `.agents/skills/oat-dispatch-subagents/SKILL.md` for provider-neutral
27
+ selection, recovery, and evidence. This explicit two-skill load is mandatory;
28
+ do not rely on ambient skill discovery. This implementation skill retains
29
+ lifecycle sequencing, verification, integration, and approval-aware final
30
+ closeout.
31
+ Correctness must not require a provider restart or hot reload.
32
+
33
+ After resolving `ACTIVE_PROVIDER`, read exactly one active-provider reference
34
+ from `.agents/skills/oat-dispatch-subagents/references/`
35
+ (`provider-cursor.md`, `provider-codex.md`, or `provider-claude.md`). Do not
36
+ merge provider mechanics.
37
+
20
38
  ## Mode Assertion
21
39
 
22
40
  **OAT MODE: Implementation**
@@ -102,1911 +120,52 @@ PROJECTS_ROOT="${PROJECTS_ROOT%/}"
102
120
 
103
121
  **If `PROJECT_PATH` is valid:** derive `{project-name}` as the directory name (basename of the path).
104
122
 
105
- ### Step 0.5: Capability Detection and Tier Selection
106
-
107
- **Mandatory target-first order:** Complete Dispatch Policy Preflight and resolve
108
- the concrete managed Codex target before probing generic agent availability or
109
- locking Tier 1/Tier 2. A concrete target takes precedence over tier selection:
110
- first send the exact registered role through native dispatch. Only a native
111
- role-selection rejection permits an explicitly pinned fresh Codex child. If
112
- neither exact route is possible, inline execution is allowed only with verified
113
- equivalent current-host model and effort controls; otherwise block before work
114
- starts. Explicit inherit/default and documented managed-uncapped reviewer
115
- behavior remain the only base-role exceptions.
116
-
117
- For a concrete managed Codex role, first send the resolver-returned Codex
118
- variant through the native spawn API as `agent_type`. Spawn acceptance plus the
119
- constructed launcher payload is configured invocation evidence; independent
120
- runtime telemetry or agent self-report is not required. Launch a fresh Codex
121
- child pinned to the resolver-returned model and effort with canonical role
122
- instructions only after a native role-selection rejection as defined below. If
123
- that fresh child cannot be launched, fail closed and block; never substitute
124
- the coordinator or base role.
125
-
126
- Use base `oat-phase-implementer` only for the allowed exceptions above:
127
- explicit inherit/default behavior. It is never a managed task-worker fallback.
128
-
129
- Detect whether native subagent dispatch is available. The detection logic follows the same pattern used by `oat-project-review-provide` but produces a two-tier outcome (no fresh-session tier — this skill runs autonomously and cannot block on user-initiated fresh sessions mid-run).
130
-
131
- Detection logic:
132
-
133
- - If the host is Claude Code, check Task-tool availability with `subagent_type: "oat-phase-implementer"` and `subagent_type: "oat-reviewer"`. Available → Tier 1.
134
- - If the host is Cursor, use Cursor-native invocation. Available → Tier 1.
135
- - If the host is Codex multi-agent, verify `[features] multi_agent = true` and whether `spawn_agent` requires explicit authorization.
136
- - Codex Tier 1 dispatches for `oat-phase-implementer` and `oat-reviewer` must use self-contained scope packets and fresh context. Do not rely on forked full-thread context when pinning a specialized OAT role.
137
- - Available without auth Tier 1.
138
- - Available with auth required fail closed. You MUST ask the user once at skill start before selecting Tier 2 or starting implementation work:
139
-
140
- ```
141
- This OAT implementation skill normally delegates phase implementation and review to subagents. Authorize subagent delegation for this run?
142
-
143
- Yes authorizes both oat-phase-implementer and oat-reviewer across every phase in this run.
144
- ```
145
-
146
- - Approved → Tier 1.
147
- - Declined → Tier 2.
148
-
149
- - If the host does not resolve either generic agent, first attempt the exact
150
- registered role natively for any concrete managed target. Use the explicitly
151
- pinned fresh-child route only after a native role-selection rejection. Select
152
- Tier 2 only when inline execution is allowed by the target-first rule above.
153
-
154
- **Approval scope rule:** this Tier selection applies to both phase implementation and checkpoint review. Do not infer a mixed mode from conversational emphasis on review checkpoints. If the user has not explicitly approved Tier 1 for the run, stay Tier 2 throughout. Mixed mode is only valid when the user explicitly requests it.
155
-
156
- **Codex fail-closed rule:** after this skill is invoked, "user did not separately ask for subagents" is not a valid Tier 2 reason. If Codex can spawn agents but requires explicit user authorization, the implementation MUST NOT continue until the delegation question above is answered. Tier 2 is allowed only when:
157
-
158
- - `user declined delegation`
159
- - `spawn_agent unavailable`
160
- - `required agent role unresolved`
161
-
162
- Report the selected tier to the user:
163
-
164
- ```
165
- [preflight] Checking subagent availability…
166
- → oat-phase-implementer + oat-reviewer: {available | authorization required | not resolved}
167
- → Selected: Tier {1 | 2} — {Subagents | Inline}
168
- → Reason: {authorized | available without auth | user declined delegation | spawn_agent unavailable | required agent role unresolved}
169
- ```
170
-
171
- Do not print `[0/N]` for this preflight step. The implementation denominator is not established by capability detection; use the literal `[preflight]` label above.
172
-
173
- **Hard pre-work guard:** before any code edit, test run, or implementation commit, print the selected tier and reason. If Tier 2 is selected, the reason must be one of the three allowed Tier 2 reasons above. Do not run tests, edit files, or create implementation commits until Step 0.5 has completed and the tier report has been printed.
174
-
175
- **Tier is locked for the remainder of the run only after the dispatch target is resolved.** Subsequent coordinator, task-worker, fix, and review dispatches use the same tier. Tier controls mechanics only: every managed task worker still resolves its own exact target beneath the recorded project or phase named maximum. No mid-run downgrade is allowed.
176
-
177
- **Recovery if Step 0.5 was skipped:** If implementation work has already started inline before completing Step 0.5, STOP immediately. Preserve any work in progress, complete or revert to a clean task boundary, and re-run Step 0.5 before continuing. Do not silently continue in Tier 2.
178
-
179
- **Codex authorization example:**
180
-
181
- ```
182
- User invokes: $oat-project-implement
183
- Detected: Codex multi-agent support available; explicit authorization required.
184
- Expected: ask "This OAT implementation skill normally delegates phase implementation and review to subagents. Authorize subagent delegation for this run?"
185
- If approved: Selected: Tier 1 — Subagents
186
- Forbidden: Selected: Tier 2 — Inline because the user did not separately mention subagents.
187
- ```
188
-
189
- **Native role-selection rejection:** This means the native host explicitly
190
- reports that the requested `agent_type` is unsupported, unknown, unregistered,
191
- or rejected before the child or agent starts. Missing runtime telemetry,
192
- missing agent self-report, a timeout after spawn acceptance, or any terminal
193
- result from an accepted child — including `BLOCKED` — is not role
194
- unavailability and is not a native role-selection rejection. Self-report is
195
- optional diagnostic data and cannot populate or overwrite launcher-owned
196
- `target`, `model_axis`, or `effort_axis` fields. An accepted child cannot
197
- trigger the fresh pinned-child or CLI fallback. If an accepted native reviewer
198
- later times out, retry the same already-selected native `agent_type` route. The
199
- fresh pinned-child route is eligible only when the original native attempt
200
- received explicit pre-start role-selection rejection; a timeout after native
201
- spawn acceptance never changes routes.
202
-
203
- **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.
204
-
205
- ### Dispatch Policy Preflight
206
-
207
- Before any phase work, resolve and print the OAT dispatch policy. This is a
208
- preflight gate, not a mid-run question.
209
-
210
- Use the CLI resolver as the source of truth. The command name remains
211
- `dispatch-ceiling` for compatibility, but the returned contract is dispatch
212
- policy:
213
-
214
- ```bash
215
- oat project dispatch-ceiling resolve --provider <active-provider> --preflight --report-scope implementation-preflight --report-action implementation --json
216
- ```
217
-
218
- If `oat` is not in PATH, use:
219
-
220
- ```bash
221
- pnpm run cli -- project dispatch-ceiling resolve --provider <active-provider> --preflight --report-scope implementation-preflight --report-action implementation --json
222
- ```
223
-
224
- Resolution order:
225
-
226
- 1. Config keys `workflow.dispatchPolicy.mode` / `workflow.dispatchPolicy.policy` (local > shared > user)
227
- 2. Compatibility config keys `workflow.dispatchCeiling.providers.<provider>` (local > shared > user)
228
- 3. Project `state.md` frontmatter key `oat_dispatch_policy`
229
- 4. Legacy project `state.md` frontmatter key `oat_dispatch_ceiling`
230
- 5. Interactive implementation preflight prompt (below)
231
- 6. Non-interactive unresolved: block before work starts
232
-
233
- **JSON response shape** (from `--json`):
234
-
235
- ```json
236
- {
237
- "status": "resolved",
238
- "provider": "codex",
239
- "value": "high",
240
- "policyMode": "managed",
241
- "policy": "balanced",
242
- "source": "project-state",
243
- "preset": "balanced",
244
- "unresolved": false,
245
- "providerDefaultEffort": "medium",
246
- "providers": {
247
- "codex": {
248
- "value": "high",
249
- "mode": "enforced",
250
- "mechanism": "pinned-variant",
251
- "dispatchArgs": {
252
- "variant": "oat-phase-implementer-gpt-5-6-terra-high"
253
- },
254
- "verifyOnDispatch": false,
255
- "selection": {
256
- "role": "implementer",
257
- "preferredValue": null,
258
- "selectedValue": "high",
259
- "capped": false,
260
- "selectionMode": "capped",
261
- "policyMode": "managed",
262
- "policy": "balanced"
263
- }
264
- }
265
- }
266
- }
267
- ```
268
-
269
- Read `providers.<active-provider>` for the concrete dispatch controls. The
270
- `dispatchArgs` field carries the provider-specific argument to pass through
271
- (Codex: `variant` name; Claude: `model` string). For implementer/fix dispatch,
272
- pass `--preferred <preferred-effort>` and use `selection.selectedValue` as the
273
- selected axis value when it is present. Never re-derive these from the policy
274
- label or a ceiling-only variant - the resolver is the single compilation/join
275
- point.
276
-
277
- Print before phase work:
278
-
279
- ```text
280
- OAT Dispatch Tier: balanced (codex, managed capped — pinned-variant)
281
- Resolved cap: high
282
- Source: project state
283
- Provider default effort: medium
284
- Note: OAT will use resolver-returned materialized Codex role names up to high. Base/unpinned roles resolve through the provider default only for explicit inherit/default behavior or the documented managed-uncapped reviewer exception.
285
- ```
286
-
287
- If no policy resolves and the session is interactive, present the dispatch
288
- policy prompt once before starting work:
289
-
290
- Print the unresolved-policy heading, then generate the choice text from
291
- canonical CLI metadata immediately before presenting it:
292
-
293
- ```bash
294
- oat project dispatch-ceiling choices --format markdown
295
- ```
296
-
297
- Do not hand-type the dispatch policy menu or omit canonical choices. If the CLI
298
- is unavailable in this environment, derive the same labels and descriptions from
299
- `packages/cli/src/config/dispatch-policy-options.ts`; include every managed
300
- policy returned by `VALID_MANAGED_DISPATCH_POLICIES` plus `Uncapped`, `Inherit
301
- Host Defaults`, and `Leave Unresolved`.
302
-
303
- At minimum, preserve these semantics in any fallback text:
304
-
305
- - `Uncapped`: OAT still manages dispatch selection, but stores no maximum cap.
306
- It is not host/default behavior and must not be represented by absent policy
307
- state.
308
- - `Inherit Host Defaults`: OAT does not choose model or effort controls; the
309
- executing host/provider owns implementation, fix, and review defaults.
310
- - `Leave Unresolved`: planning/preflight deferral only. It records no runtime
311
- policy and is not a runnable implementation setting. Implementation preflight
312
- must block until a policy resolves.
313
-
314
- OAT applies managed policies where the provider exposes a reliable mechanism
315
- (Codex: pinned variants; Claude: Task model parameter). Other providers may
316
- treat managed policies as advisory.
317
-
318
- **Managed capped policy selection** persists only `mode: managed`, the named
319
- maximum `policy`, and `source`. The named maximum leaves lower configured
320
- candidates eligible; do not copy compiled provider/model targets into project
321
- state. On selection, print the named maximum before proceeding.
322
-
323
- **Uncapped** persists explicit managed uncapped state. OAT still manages
324
- dispatch selection. It does not write provider caps, and it must not be
325
- represented by leaving dispatch policy state absent.
326
-
327
- **Inherit Host Defaults** persists explicit inherit/default state. Use this only
328
- when the user wants OAT to leave implementation, fix, and review model/effort
329
- controls to the executing host/provider. OAT does not choose model or effort in
330
- this mode.
331
-
332
- **Leave Unresolved** records no runtime policy for implementation. Stop before
333
- phase work and report the unresolved state; Implementation preflight must block
334
- until a policy resolves.
335
-
336
- Persist in project `state.md` frontmatter using the normalized shape:
337
-
338
- ```yaml
339
- oat_dispatch_policy:
340
- mode: managed
341
- policy: balanced
342
- source: project-state
343
- ```
344
-
345
- For `Uncapped`:
346
-
347
- ```yaml
348
- oat_dispatch_policy:
349
- mode: managed
350
- policy: uncapped
351
- source: project-state
352
- ```
353
-
354
- For `Inherit Host Defaults`:
355
-
356
- ```yaml
357
- oat_dispatch_policy:
358
- mode: inherit
359
- source: project-state
360
- ```
361
-
362
- If no policy resolves and `OAT_NON_INTERACTIVE=1` or no user-response channel
363
- exists, rerun the resolver with non-interactive behavior and stop before work
364
- starts if it blocks:
365
-
366
- ```bash
367
- oat project dispatch-ceiling resolve --provider <active-provider> --preflight --non-interactive --report-scope implementation-preflight --report-action implementation
368
- ```
369
-
370
- ```text
371
- BLOCKED: Codex dispatch policy is unresolved in non-interactive mode.
372
- Set workflow.dispatchPolicy.mode/workflow.dispatchPolicy.policy, workflow.dispatchCeiling.providers.codex, oat_dispatch_policy, or legacy oat_dispatch_ceiling.
373
- ```
374
-
375
- Dry-run mode must report the unresolved policy and planned behavior without
376
- modifying project state.
377
-
378
- ### Runtime dispatch selection
379
-
380
- Before coordinator bootstrap and before each task-worker, fix, or review
381
- dispatch, choose and log runtime controls. Resolve these controls before
382
- applying Tier 1/Tier 2 mechanics. A coordinator target never becomes a task
383
- target: managed tasks use an exact resolver candidate beneath the recorded
384
- project or phase named ceiling. Inline execution must preserve equivalent
385
- controls or use a documented exception.
386
-
387
- Use these inputs:
388
-
389
- - resolved dispatch policy, source, and provider-specific selection
390
- - phase ID and the current bounded task scope
391
- - optional `## Dispatch Profile` row in `plan.md`
392
- - host-exposed provider controls, by axis
393
- - prior outcomes for the phase, including review results and failed retries
394
-
395
- Route selection is part of runtime dispatch selection when the resolver returns
396
- an ordered matrix route:
397
-
398
- - Start every implementation/fix scope at route level `0` unless the plan's
399
- `## Dispatch Profile` names a different starting route level for that
400
- phase/task. Level `0` is the route floor.
401
- - Pass `--escalation-level <route-level>` on implementer/fix resolver calls.
402
- Single-axis providers ignore this flag and keep their normal capped `min()`
403
- behavior.
404
- - Read `providers.<provider>.target` and `providers.<provider>.selection.target`
405
- from resolver JSON when present. A target with `crossHarness: true` is an
406
- explicit deferred cross-harness target: log it as advisory and do not invent a
407
- same-harness fallback.
408
- - On repeated review failure or retry-loop escalation, advance by one route
409
- entry before retrying, up to the last available route entry and within
410
- `oat_orchestration_retry_limit`.
411
-
412
- #### Dispatch Report V1 contract
413
-
414
- Every implementation, fix, and review resolver invocation MUST pass explicit
415
- report context:
416
-
417
- - implementation: `--report-scope <phase-or-task> --report-action implementation`
418
- - fix: `--report-scope <phase-or-task> --report-action fix`
419
- - review: `--report-scope <phase-or-review-scope> --report-action review`
420
-
421
- Require `dispatchReport.schemaVersion: 1` in the completed resolver JSON before
422
- dispatch. Consume the report as the human/audit source: render the versioned
423
- block with `formatDispatchReport(dispatchReport)` semantics, and derive the
424
- formal compatibility line only through
425
- `formatDispatchStamp(dispatchReport)` / `toDispatchStampRecord(dispatchReport)`.
426
- Never hand-assemble a second `Dispatch:` schema from policy labels, role names,
427
- candidate strings, or target names.
428
-
429
- The exact provider invocation remains authoritative in
430
- `providers.<provider>.dispatchArgs` and `providers.<provider>.selection.target`;
431
- the report does not replace or weaken target-pinned dispatch. Add independently
432
- observed runtime identity to `dispatchReport.runtimeIdentity` only when such an
433
- observation exists. Requested/configured controls are not runtime observation.
434
- For gate-originated review, keep `dispatchReport.gateInvocation`, existing
435
- work-producer `diversity`, and reviewer `runtimeIdentity` as three distinct
436
- facts; producer stamps or self-report never overwrite configured invocation.
437
-
438
- Axis states:
439
-
440
- - `selected:<value>` - host exposes the axis and the orchestrator chose a value.
441
- - `provider-default` - Codex base/unpinned role follows configured/provider default effort.
442
- - `inherited` - host/API explicitly inherits the parent setting and OAT can trust that behavior.
443
- - `not-applicable` - this host/API has no meaningful per-dispatch concept for that axis.
444
- - `host-auto` - exceptional; the host uses that axis internally but OAT cannot read or pin it.
445
-
446
- Codex rules:
447
-
448
- **Managed Codex execution invariant:** When the resolver returns a model+effort
449
- target, the resolver-returned Codex variant from
450
- `providers.codex.dispatchArgs.variant` must first be sent through the native
451
- spawn API as `agent_type`. Spawn acceptance plus the launcher payload is
452
- configured invocation evidence with launcher-selected/config-declared
453
- provenance. If and only if the host returns a native role-selection rejection,
454
- launch a fresh Codex child with the resolver target's explicit model, reasoning
455
- effort, and canonical role instructions from
456
- `.agents/agents/oat-phase-implementer.md` or
457
- `.agents/agents/oat-reviewer.md`. Missing runtime telemetry or agent self-report
458
- is not role unavailability, and an accepted child result such as `BLOCKED`
459
- cannot trigger fallback. Workflow correctness must not require provider restart
460
- or hot reload. A managed base role is forbidden when a concrete target was
461
- requested; never silently downgrade to it. Base roles remain valid only for
462
- explicit inherit/default behavior and the documented managed-uncapped reviewer
463
- fallback.
464
-
465
- 1. Codex effort order is `low < medium < high < xhigh < max`.
466
- 2. Classify preferred effort from scope:
467
- - `low`: trivial docs-only, narrow single-file, or mechanical changes
468
- - `medium`: normal multi-file implementation and moderate integration risk
469
- - `high`: broad architecture, security/auth/redaction boundaries, subtle state behavior, or repeated substantive review failures
470
- - `xhigh`: highest-risk work that requires a capped policy to allow xhigh or a managed `Uncapped` policy to select it
471
- - `max`: exceptional frontier work whose risk or cross-cutting scope justifies the first-class maximum reasoning control
472
- 3. For capped managed implementer/fix work, selected effort is `min(preferred, resolved_cap)`.
473
- 4. For managed `Uncapped` implementer/fix work, selected effort is the preferred effort with no cap.
474
- 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.
475
- 6. For managed capped task-worker/fix dispatch, choose an exact configured candidate. For implementation, call `oat project dispatch-ceiling resolve --provider codex --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <model> --candidate-effort <effort> --escalation-level <route-level> --report-scope <task-id> --report-action implementation --json`. For a bounded fix, use `oat project dispatch-ceiling resolve --provider codex --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <model> --candidate-effort <effort> --escalation-level <route-level> --report-scope <task-id> --report-action fix --json`. Read `providers.codex.dispatchArgs.variant` and `providers.codex.selection.target`; never reuse the coordinator role or a cap-only variant. `--preferred` remains compatibility behavior outside the exact task-worker path.
476
- 7. For review dispatch: call `oat project dispatch-ceiling resolve --provider codex --role reviewer --report-scope <phase-or-review-scope> --report-action review --json`; read `providers.codex.dispatchArgs.variant` and `providers.codex.selection.target`.
477
- - Capped managed policy: reviewer targets the configured cap for deterministic quality gate behavior.
478
- - Managed `Uncapped`: no reviewer target exists; use base/unpinned reviewer fallback and log `selectionMode=no-review-target`, `selectedValue=null`, and `effort_axis=provider-default`.
479
- - Inherit/default: no reviewer target exists; use base/unpinned reviewer fallback and log `selectionMode=inherit-default`, `selectedValue=null`, and `effort_axis=provider-default`.
480
- 8. Codex payload-first assertion applies whenever the resolver returns a materialized model+effort target. If `providers.codex.dispatchArgs.variant` is present, the actual `spawn_agent` payload MUST first use it as native `agent_type`; when that variant came from a Codex model+effort target, log `model_axis=selected:<model>` and `effort_axis=selected:<effort>` from resolver output and the constructed launcher payload. Spawn acceptance is sufficient configured invocation evidence. Missing telemetry or self-report does not make the variant unusable. If native role selection explicitly rejects the variant, use the explicitly pinned fresh-child route or block. Use the base role and log provider-default only for explicit inherit/default behavior or the documented managed-uncapped reviewer exception. Always derive `model_axis` and `effort_axis` from resolver output, not from legacy role-name parsing or agent self-report.
481
- 9. Do not use top-level per-call `reasoning_effort` as the standard OAT selected-effort path; dogfooding showed that path can be inconsistent.
482
-
483
- Claude rules:
484
-
485
- - Claude policy selection is model-based: `haiku < sonnet < opus < fable`.
486
- - Implementer/fix dispatch: classify the preferred model (`haiku`, `sonnet`, `opus`, or `fable`) and pass it to the resolver as `--preferred <preferred-model>`.
487
- - Capped managed policy: the resolver selects `min(preferred, resolved_cap)`.
488
- - Managed `Uncapped`: the resolver selects the preferred model with no cap.
489
- - Inherit/default: the resolver returns no selected model; omit `model` so Claude Code inherits host/default behavior.
490
- - Review dispatch:
491
- - Capped managed policy: target the configured policy cap directly.
492
- - Managed `Uncapped` or inherit/default: no reviewer target exists; omit `model` and log inherited/default model behavior.
493
- - For managed capped task-worker/fix dispatch, call `oat project dispatch-ceiling resolve --provider claude --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <model> --orchestrator-tier <current-orchestrator-tier> --escalation-level <route-level> --report-scope <task-id> --report-action implementation --json` for implementation. For a bounded fix, call `oat project dispatch-ceiling resolve --provider claude --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <model> --orchestrator-tier <current-orchestrator-tier> --escalation-level <route-level> --report-scope <task-id> --report-action fix --json`. For review dispatch, call the resolver with `--role reviewer --report-scope <phase-or-review-scope> --report-action review --json` and no candidate flags. Read `providers.claude.dispatchArgs.model` and pass it exactly on the actual Task invocation.
494
- - Pass `model: "<value>"` when `model_axis=selected:<value>` on the Task tool call.
495
- - Keep `effort_axis=not-applicable`; Claude Code has no separate per-dispatch effort axis.
496
-
497
- Cursor rules:
498
-
499
- - Treat every configured Cursor candidate string as opaque. Do not normalize it
500
- or infer capability from its spelling.
501
- - For managed capped task-worker/fix dispatch, call
502
- `oat project dispatch-ceiling resolve --provider cursor --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <opaque-model> --report-scope <task-id> --report-action implementation --json`
503
- for implementation. For a bounded fix, call
504
- `oat project dispatch-ceiling resolve --provider cursor --role implementer --ceiling-tier <project-or-phase-tier> --candidate-model <opaque-model> --report-scope <task-id> --report-action fix --json`.
505
- - Require `providers.cursor.dispatchArgs.model` and pass that exact byte-for-byte
506
- string as the actual Cursor invocation model. If the host cannot apply it,
507
- fail closed.
508
-
509
- Payload-first invariant:
510
-
511
- - Build the actual host dispatch argument map before logging.
512
- - Do not emit `selected:<value>` unless the host invocation contains the corresponding role/model selection.
513
- - For every coordinator, task-worker, fix, and review launch, record `target`,
514
- `model_axis`, and `effort_axis` from resolver output and the actual launcher
515
- payload after payload construction.
516
- - Those fields are launcher-owned. Agent self-report cannot populate or
517
- overwrite them; it may only be retained separately as optional diagnostics.
518
- - Derive `Dispatch target` and `Effort axis` / `Model axis` from the payload.
519
- - After the payload is built, append the compatibility stamp returned from
520
- `formatDispatchStamp(dispatchReport)` to Dispatch Notes for every
521
- implementation, fix, and review dispatch. The derived line retains the p01
522
- grammar exactly:
523
- `Dispatch: scope=<phase-or-task> action=<implementation|fix|review> role=<implementer|fix|reviewer> producer=<slug|unknown> provenance=<declared|observed|inferred|unknown> model_axis=<axis> effort_axis=<axis> dispatch_policy=<policy|unknown> dispatch_ceiling=<value|none> target=<target|unknown>`.
524
- Populate the report from the completed resolver and actual host arguments.
525
- Only independently observed or otherwise supported runtime evidence may
526
- populate runtime producer identity. Codex materialized model+effort variants
527
- retain selected model/effort controls while keeping runtime identity
528
- not-reported unless evidence exists. Do not write prose-only, hand-built, or
529
- legacy comma-separated stamp forms.
530
-
531
- Human-facing dispatch display rules:
532
-
533
- - Lead with route, OAT dispatch tier, requested controls, configured defaults, and runtime confirmation. These are the fields humans use to understand what OAT asked for and what the host appears to be running.
534
- - Do not headline `producer=unknown` or `provenance=unknown`. Those values are
535
- audit fields for the formal stamp, not the primary status. Put unknown
536
- producer/provenance only in `Dispatch stamp:` or in a low-priority note after
537
- the route and runtime confirmation.
538
- - Separate requested controls from configured defaults. For example, a Codex
539
- materialized role may request `model_axis=selected:<model>` and
540
- `effort_axis=selected:<effort>` while the provider default effort remains a
541
- separate fallback/default fact.
542
- - Separate configured policy/cap from runtime confirmation. A resolver payload
543
- can declare a target before the host has confirmed it; an observed mismatch
544
- must be called out as `Runtime confirmation: mismatch:<detail>` and handled as
545
- an orchestration deviation.
546
- - Keep the `Dispatch stamp: Dispatch: ...` line parseable and grammar-stable.
547
- Do not move display-only prose into the formal stamp.
548
-
549
- Structured dispatch log:
550
-
551
- ```text
552
- OAT Dispatch: Phase {phase_id} {implementation | fix | review}
553
- Host: {Claude Code | Codex | Cursor | other host}
554
- Route: {route label or target path | none}; level={0 | 1 | ... | none}
555
- Requested controls: {model=<value|none>, effort=<value|none>, target=<value|unknown>}
556
- Configured defaults: {provider default effort/model | unknown | not-applicable}
557
- Runtime confirmation: {observed:<slug> | declared:<slug> | not-observable | mismatch:<detail>}
558
- Preferred effort: {low | medium | high | xhigh | max | provider-default | not-applicable}
559
- OAT Dispatch Tier: {economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped}
560
- Resolved cap: {resolved cap value | none}
561
- Selected effort: {low | medium | high | xhigh | max | provider-default | not-applicable}
562
- Policy source: {repo config | project state | preflight prompt}
563
- Provider default effort: {value | unknown | not-applicable}
564
- Selection mode: {capped | uncapped | review-target | no-review-target | inherit-default}
565
- Route level: {0 | 1 | ... | none}
566
- Model axis: { selected:<value> | inherited | not-applicable | host-auto }
567
- Effort axis: { selected:<value> | provider-default | inherited | not-applicable | host-auto }
568
- Dispatch target: {host-specific subagent/role/tool target}
569
- Dispatch stamp: Dispatch: scope=<phase-or-task> action=<implementation|fix|review> role=<implementer|fix|reviewer> producer=<slug|unknown> provenance=<declared|observed|inferred|unknown> model_axis=<axis> effort_axis=<axis> dispatch_policy=<policy|unknown> dispatch_ceiling=<value|none> target=<target|unknown>
570
- Rationale: {short rationale grounded in phase scope and any policy cap/uncapped/default behavior}
571
- ```
572
-
573
- Codex capped example:
574
-
575
- ```text
576
- OAT Dispatch: Phase p02 implementation
577
- Host: Codex
578
- Route: codex/implementer/gpt-5.6-sol/medium; level=0
579
- Requested controls: model=gpt-5.6-sol, effort=medium, target=oat-phase-implementer-gpt-5-6-sol-medium
580
- Configured defaults: provider default effort=high
581
- Runtime confirmation: declared:gpt-5.6-sol/medium
582
- Preferred effort: high
583
- OAT Dispatch Tier: economy
584
- Resolved cap: medium
585
- Selected effort: medium
586
- Policy source: repo config
587
- Provider default effort: high
588
- Selection mode: capped
589
- Model axis: selected:gpt-5.6-sol
590
- Effort axis: selected:medium
591
- Dispatch target: oat-phase-implementer-gpt-5-6-sol-medium
592
- Rationale: normal multi-file implementation; high preferred due to integration risk, capped by configured policy.
593
- ```
594
-
595
- Codex uncapped implementer example:
596
-
597
- ```text
598
- OAT Dispatch: Phase p02 implementation
599
- Host: Codex
600
- Route: codex/implementer/gpt-5.6-terra/xhigh; level=0
601
- Requested controls: model=gpt-5.6-terra, effort=xhigh, target=oat-phase-implementer-gpt-5-6-terra-xhigh
602
- Configured defaults: provider default effort=medium
603
- Runtime confirmation: declared:gpt-5.6-terra/xhigh
604
- Preferred effort: xhigh
605
- OAT Dispatch Tier: uncapped
606
- Resolved cap: none
607
- Selected effort: xhigh
608
- Policy source: project state
609
- Provider default effort: medium
610
- Selection mode: uncapped
611
- Model axis: selected:gpt-5.6-terra
612
- Effort axis: selected:xhigh
613
- Dispatch target: oat-phase-implementer-gpt-5-6-terra-xhigh
614
- 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.
615
- ```
616
-
617
- Codex capped reviewer example:
618
-
619
- ```text
620
- OAT Dispatch: Phase p02 review
621
- Host: Codex
622
- Route: codex/reviewer/gpt-5.6-terra/xhigh; level=0
623
- Requested controls: model=gpt-5.6-terra, effort=xhigh, target=oat-reviewer-gpt-5-6-terra-xhigh
624
- Configured defaults: provider default effort=medium
625
- Runtime confirmation: declared:gpt-5.6-terra/xhigh
626
- Preferred effort: high
627
- OAT Dispatch Tier: high
628
- Resolved cap: xhigh
629
- Selected effort: xhigh
630
- Policy source: project state
631
- Provider default effort: medium
632
- Selection mode: review-target
633
- Model axis: selected:gpt-5.6-terra
634
- Effort axis: selected:xhigh
635
- Dispatch target: oat-reviewer-gpt-5-6-terra-xhigh
636
- Rationale: reviewer runs at the configured policy cap for deterministic quality gate behavior.
637
- ```
638
-
639
- Codex inherit/default fallback example:
640
-
641
- ```text
642
- OAT Dispatch: Phase p02 review
643
- Host: Codex
644
- Route: none; level=none
645
- Requested controls: model=none, effort=provider-default, target=oat-reviewer
646
- Configured defaults: provider default effort=medium
647
- Runtime confirmation: not-observable
648
- Preferred effort: provider-default
649
- OAT Dispatch Tier: inherit host defaults
650
- Resolved cap: none
651
- Selected effort: provider-default
652
- Policy source: project state
653
- Provider default effort: medium
654
- Selection mode: inherit-default
655
- Model axis: inherited
656
- Effort axis: provider-default
657
- Dispatch target: oat-reviewer
658
- Rationale: explicit inherit/default policy; base unpinned role follows Codex provider default.
659
- ```
660
-
661
- Generic sidecar/explorer dispatch:
662
-
663
- - Built-in or generic sidecars such as `explorer` are not OAT-managed implementer, reviewer, or fix roles.
664
- - If a sidecar spawn payload does not explicitly pin a reliable effort/model control, log `Preferred effort: provider-default`, `Selected effort: provider-default`, and `Effort axis: provider-default`.
665
- - Do not classify a generic sidecar as `Preferred effort: low|medium|high|xhigh|max` unless the actual host invocation contains the corresponding reliable selection. If the host has no reliable effort control for that sidecar, use provider-default wording instead.
666
- - Sidecar outputs are advisory context only. Implementation work and review/fix gates still follow the OAT-managed dispatch rules above.
667
-
668
- Codex generic explorer example:
669
-
670
- ```text
671
- OAT Dispatch: p02-t10 sidecar exploration
672
- Host: Codex
673
- Route: sidecar/explorer; level=none
674
- Requested controls: model=none, effort=provider-default, target=explorer
675
- Configured defaults: provider default effort=xhigh
676
- Runtime confirmation: not-observable
677
- Preferred effort: provider-default
678
- OAT Dispatch Tier: high
679
- Resolved cap: xhigh
680
- Selected effort: provider-default
681
- Policy source: project state
682
- Provider default effort: xhigh
683
- Model axis: inherited
684
- Effort axis: provider-default
685
- Dispatch target: explorer
686
- Rationale: read-only sidecar exploration; generic explorer payload does not pin an OAT-managed effort variant.
687
- ```
688
-
689
- Include resolved dispatch context in scope packets when known:
690
-
691
- ```yaml
692
- model_axis: { selected:<value> | inherited | not-applicable | host-auto }
693
- effort_axis:
694
- {
695
- selected:<value> | provider-default | inherited | not-applicable | host-auto,
696
- }
697
- dispatch_ceiling: { resolved ceiling value }
698
- dispatch_policy:
699
- {
700
- economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped,
701
- }
702
- ceiling_source: { repo config | project state | preflight prompt }
703
- policy_source: { repo config | project state | preflight prompt }
704
- provider_default_effort: { value | unknown | not-applicable }
705
- dispatch_route_level:
706
- { integer route level; omit when no ordered route is in play }
707
- dispatch_target:
708
- { resolver target or host-specific dispatch target; omit if unknown }
709
- dispatch_stamp: { exact `Dispatch: ...` line written to Dispatch Notes }
710
- dispatch_rationale: { short rationale }
711
- ```
712
-
713
- ### Dispatch Policy Enforcement Log
714
-
715
- After each phase dispatch (implementation, fix, or review), append one enforcement
716
- log line. The log reflects the `mode` and `mechanism` returned by
717
- `oat project dispatch-ceiling resolve` — do not compute these yourself.
718
-
719
- **Three-state log format:**
720
-
721
- ```text
722
- Dispatch policy: {policy}; selected={selected value | none}; cap={value | none} ({provider}, {mode} — {mechanism detail})
723
- ```
724
-
725
- **Log examples (matching resolver output):**
726
-
727
- ```text
728
- Dispatch policy: balanced; selected=xhigh; cap=xhigh (codex, enforced — variant oat-phase-implementer-gpt-5-6-terra-xhigh)
729
- Dispatch policy: high; selected=high; cap=high (codex, enforced — variant oat-reviewer-gpt-5-6-sol-high)
730
- Dispatch policy: frontier; selected=max; cap=max (codex, enforced — variant oat-reviewer-gpt-5-6-sol-max)
731
- Dispatch policy: uncapped; selected=xhigh; cap=none (codex, enforced — variant oat-phase-implementer-gpt-5-6-terra-xhigh)
732
- Dispatch policy: inherit host defaults; selected=none; cap=none (codex, advisory — base role follows provider default)
733
- Dispatch policy: balanced; selected=sonnet; cap=sonnet (claude, enforced — Task model arg)
734
- Dispatch policy: frontier; selected=fable; cap=fable (claude, enforced — Task model arg)
735
- Cursor opaque model-string example: Dispatch policy: frontier; selected=gpt-5.6-sol-max; cap=gpt-5.6-sol-max (cursor, enforced — model arg gpt-5.6-sol-max)
736
- Dispatch policy: unresolved; selected=none; cap=none (codex, advisory — policy set but no value resolved)
737
- ```
738
-
739
- **Verify-on-upgrade (`verifyOnDispatch: true`):**
740
-
741
- When the resolver returns `providers.<provider>.verifyOnDispatch: true`, the
742
- requested tier is above the orchestrator tier (an upgrade request). Before
743
- logging `enforced`, confirm the actual model/tier used by the dispatched agent.
744
- If the provider honored the request, log `enforced`. If it did not:
745
-
746
- ```text
747
- Dispatch policy: high; selected=opus; cap=opus (claude, advisory — provider did not honor upgrade; ran sonnet)
748
- ```
749
-
750
- **`enforced`** — the adapter compiled concrete dispatch args and the provider
751
- accepted them. Log value + provider + mechanism detail (variant name or "Task
752
- model arg").
753
-
754
- **`advisory`** — the adapter supports the policy but no concrete value resolved,
755
- the policy intentionally inherits provider defaults, or the provider is known
756
- but could not be verified. Log with note "policy set but no value resolved",
757
- "base role follows provider default", or "provider did not honor upgrade; ran
758
- \<tier\>".
759
-
760
- **`unsupported`** — the provider has no registered adapter. Log with note "no
761
- adapter; informational". Never block on unsupported — dispatch follows provider
762
- defaults.
763
-
764
- ### Dry-Run Mode
765
-
766
- When the skill is invoked with `--dry-run`:
767
-
768
- 1. Perform Steps 0–2 fully (resolve project, capability detection, read plan, validate metadata, build schedule).
769
- 2. Skip all phase dispatches, merges, and artifact writes.
770
- 3. Output the execution plan:
771
-
772
- ```
773
- OAT ▸ IMPLEMENT (dry-run)
774
-
775
- Project: {PROJECT_PATH}
776
- Tier: {1 | 2}
777
- Retry: {N}
778
-
779
- Schedule:
780
- [1] p01 (sequential)
781
- [2] p02, p03 (parallel group, worktrees)
782
- [3] p04 (sequential)
783
-
784
- Worktrees that would be created:
785
- - {project-name}/p02
786
- - {project-name}/p03
787
-
788
- No commits, no artifact writes.
789
- ```
790
-
791
- 4. Exit without modifying any files.
792
-
793
- ### Step 1: Check Plan Complete
794
-
795
- ```bash
796
- cat "$PROJECT_PATH/plan.md" | head -10 | grep "oat_status:"
797
- ```
798
-
799
- **Required frontmatter:**
800
-
801
- - `oat_status: complete`
802
- - `oat_ready_for: oat-project-implement`
803
-
804
- **If not complete:** Block and ask user to finish plan first.
805
-
806
- ### Step 1.5: Resumption Detection
807
-
808
- If `{PROJECT_PATH}/implementation.md` already contains orchestration run entries, we may be resuming an interrupted run.
809
-
810
- 1. Read `implementation.md` and find the most recent `### Run N` entry.
811
- 2. Compare its phases-passed / phases-failed / phases-stopped counts against the plan's phase list.
812
- 3. If there are phases in the plan that are not yet covered by any run entry, those are the resume targets.
813
- 4. Read `state.md` for `oat_current_task` to cross-check the expected resume point.
814
- 5. Read `git log` to verify the most recent bookkeeping commit matches the last reported state.
815
-
816
- **Detected state reconciliation:**
817
-
818
- - If there is an in-flight phase (implementer committed but no review verdict in implementation.md), re-dispatch the reviewer for that phase's current HEAD.
819
- - If there are un-cleaned worktrees from a prior parallel group, list them and ask the user whether to resume or clean up:
820
-
821
- ```
822
- Found un-cleaned worktrees from a prior run:
823
- - ../worktrees/{name}/p02 — verdict was: excluded
824
- - ../worktrees/{name}/p03 — verdict was: pass, not merged
825
-
826
- Resume (merge pending verdicts into orchestration branch) or clean up?
827
- ```
828
-
829
- 6. Once resume target is identified, continue from that phase with the normal per-phase flow.
830
-
831
- **On first-ever invocation** (no prior run entries), skip resumption detection and proceed to Step 2.
832
-
833
- ### Step 2: Read Plan Document
834
-
835
- Read `"$PROJECT_PATH/plan.md"` completely to understand:
836
-
837
- - All phases and tasks
838
- - File changes per task
839
- - Verification commands
840
- - Commit messages
841
-
842
- ### Step 2.1: Validate Parallelism Metadata
843
-
844
- Invoke the CLI validator to check plan.md parallelism metadata:
845
-
846
- ```bash
847
- oat project validate-plan --project-path "${PROJECT_PATH}"
848
- ```
849
-
850
- (If `oat` is not in PATH, use: `pnpm run cli -- project validate-plan --project-path "${PROJECT_PATH}"`)
851
-
852
- The command validates:
853
-
854
- - `oat_plan_parallel_groups` is either missing / empty (meaning fully sequential, no check needed) or a nested array of phase ID strings.
855
- - Every referenced phase ID exists in the plan.
856
- - No phase ID appears in more than one group.
857
- - No singleton groups (each group must contain at least 2 phases).
858
-
859
- **Reactions:**
860
-
861
- - Exit code 0 → validation passed; continue to Step 2.2.
862
- - Non-zero exit code → STOP immediately. Surface the validator's stderr output to the user. Do not silently fall back to sequential — the plan must be fixed first.
863
-
864
- The validation contract is enforced by the CLI command and unit-tested there; the skill is just the consumer.
865
-
866
- ### Step 2.2: Build Execution Schedule
867
-
868
- From the phase list and the validated parallel groups, build an execution schedule:
869
-
870
- - Phases not listed in any group form singleton entries (run sequentially).
871
- - Each parallel group forms a multi-phase entry (run concurrently in worktrees).
872
- - Schedule entries execute in plan order.
873
-
874
- Example:
875
-
876
- - Plan phases: p01, p02, p03, p04, p05
877
- - `oat_plan_parallel_groups: [["p02", "p03"], ["p04", "p05"]]`
878
- - Schedule: `[p01]` → `[p02, p03]` (group) → `[p04, p05]` (group)
879
-
880
- ### Step 2.5: Confirm Plan HiLL Checkpoints
881
-
882
- Read `oat_plan_hill_phases` from `"$PROJECT_PATH/plan.md"` frontmatter when present and validate it.
883
-
884
- - **Valid format:** JSON-like array of phase IDs (e.g., `["p01","p03"]`)
885
- - **Allowed pre-confirmation state:** field missing entirely on the first implementation run
886
- - **Invalid format examples:** scalar string, malformed array, unknown phase IDs
887
-
888
- Determine whether this is a first implementation run:
889
-
890
- - If `"$PROJECT_PATH/implementation.md"` does not exist, treat as first run.
891
- - If it exists but still has template placeholders and no completed task evidence, treat as first run.
892
-
893
- #### Workflow preference check (before prompting)
894
-
895
- Before presenting the checkpoint prompt to the user, check if a workflow preference has been configured:
896
-
897
- ```bash
898
- HILL_DEFAULT=$(oat config get workflow.hillCheckpointDefault 2>/dev/null || true)
899
- ```
900
-
901
- - **If `HILL_DEFAULT` is `every`:** Skip the prompt. Write `oat_plan_hill_phases: []` to plan.md frontmatter. Print: `HiLL checkpoints: every phase (from workflow.hillCheckpointDefault)`. Continue to Touchpoint A.
902
- - **If `HILL_DEFAULT` is `final`:** Skip the prompt. Determine the final phase ID from plan.md (e.g., `p05`) and write `oat_plan_hill_phases: ["<final_phase_id>"]` to plan.md frontmatter. Print: `HiLL checkpoints: final phase only (from workflow.hillCheckpointDefault)`. Continue to Touchpoint A.
903
- - **If unset, empty, or invalid:** Fall through to the standard prompt behavior below.
904
-
905
- This preference check only applies on first runs — resuming implementations should trust the existing `oat_plan_hill_phases` value in plan.md (or repair as bookkeeping drift).
906
-
907
- Prompt behavior:
908
-
909
- - **If first run:** always present a complete phase-by-phase summary and confirm checkpoint phases before any task execution. A missing `oat_plan_hill_phases` value is the normal unconfirmed state; if a value is already present, treat it as a provisional value to confirm rather than as final.
910
- - **If resuming and `oat_plan_hill_phases` is valid:** do not re-ask; print active checkpoint config and continue.
911
- - **If resuming and `oat_plan_hill_phases` is missing/invalid:** treat this as bookkeeping drift, because implementation should already have written the confirmed value before prior task execution. Ask the user to repair the checkpoint configuration before continuing.
912
-
913
- Required prompt shape for first-run confirmation:
914
-
915
- 1. Open with plan framing:
916
- - `This plan has {phase_count} phases. Final phase: {final_phase_id}.`
917
- 2. Briefly summarize every plan phase in order:
918
- - `p01 — {short phase summary}`
919
- - `p02 — {short phase summary}`
920
- - ...
921
- - Never omit this summary, even if the plan has only one phase or `oat_plan_hill_phases` already contains a provisional value.
922
- 3. Ask the checkpoint question using exactly three options:
923
- - `Which checkpoint behavior do you want?`
924
- - `1. Stop after each phase (default)`
925
- - `2. Stop after specific phases, e.g. p02, p05`
926
- - `3. Stop only after the final phase is completed`
927
- 4. Map the options to stored values:
928
- - `1` -> `[]`
929
- - `2` -> user-specified array such as `["p02","p05"]`
930
- - `3` -> `["p07"]` (replace `p07` with the actual final phase ID for this plan)
931
- 5. If a provisional `oat_plan_hill_phases` value already exists, mention it after presenting the three options, but still require the user to choose or confirm one of them.
932
-
933
- When user confirms/changes:
934
-
935
- - Update `"$PROJECT_PATH/plan.md"` frontmatter `oat_plan_hill_phases` to the confirmed value before executing tasks.
936
- - Keep the value stable for the rest of the run unless the user explicitly requests a change.
937
-
938
- #### Auto-Review at HiLL Checkpoints (Touchpoint A)
939
-
940
- After checkpoint behavior is confirmed, resolve auto-review preference:
941
-
942
- 1. Read `workflow.autoReviewAtHillCheckpoints` via `oat config get workflow.autoReviewAtHillCheckpoints`. This uses local > shared > user resolution and falls back to legacy `.oat/config.json` `autoReviewAtCheckpoints` when the workflow key is unset.
943
- 2. **If config explicitly `true`:** Skip the prompt. Write `oat_auto_review_at_hill_checkpoints: true` to plan.md frontmatter. Print: "Auto-review at HiLL checkpoints: enabled (from workflow.autoReviewAtHillCheckpoints)."
944
- 3. **If config explicitly `false`:** Skip the prompt. Write `oat_auto_review_at_hill_checkpoints: false` to plan.md frontmatter. Print: "Auto-review at HiLL checkpoints: disabled (from workflow.autoReviewAtHillCheckpoints)."
945
- 4. **If config is unset:** Add one question after the checkpoint choice:
946
- ```
947
- 4. Auto-review at HiLL checkpoints?
948
- - yes: automatically run the lifecycle review when a HiLL checkpoint phase completes
949
- - no (default): manual lifecycle review triggering
950
- ```
951
- 5. Write `oat_auto_review_at_hill_checkpoints: true|false` to plan.md frontmatter alongside `oat_plan_hill_phases`.
952
-
953
- This setting controls only the extra `oat-project-review-provide` lifecycle review at HiLL checkpoints. It does not control Tier 1 phase gate reviews; Tier 1 always runs `oat-reviewer` after each phase.
954
-
955
- **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.
956
-
957
- ### Step 2.6: Validate Optional Phase Review Gate
958
-
959
- Read `oat_phase_review_gate` from `"$PROJECT_PATH/plan.md"` frontmatter when present.
960
-
961
- 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.
962
-
963
- Valid shape:
964
-
965
- ```yaml
966
- oat_phase_review_gate:
967
- enabled: true
968
- phases: [] # empty or omitted = every implementation phase
969
- review_type: code
970
- exit_nonzero_on: important
971
- ```
972
-
973
- Validation rules:
974
-
975
- - Missing, `null`, or `enabled: false` means disabled.
976
- - `enabled: true` activates the gate.
977
- - `phases` is optional. If missing or empty (`[]`), run after every implementation phase. If populated, every value must be a known plan phase ID.
978
- - `review_type` is optional and defaults to `code`. This skill only supports `code` phase gates; any other value is invalid for implementation phase execution.
979
- - `exit_nonzero_on` is optional and defaults to `important`. Allowed values: `critical`, `important`, `medium`, `minor`.
980
-
981
- If the setting is invalid, stop before task execution and ask the user to repair `plan.md`. Do not silently disable a malformed gate.
982
-
983
- This setting is independent from HiLL checkpoints:
984
-
985
- - It does not pause when the gate passes.
986
- - It does not append to `oat_hill_completed`.
987
- - It does not alter `oat_plan_hill_phases` or `oat_auto_review_at_hill_checkpoints`.
988
- - It uses the existing gate target config; do not hardcode `--target` in reusable plan execution unless the user explicitly asks for manual/debug routing.
989
-
990
- ### Step 3: Check Implementation State
991
-
992
- Check if implementation already started:
993
-
994
- ```bash
995
- cat "$PROJECT_PATH/implementation.md" 2>/dev/null | head -20
996
- ```
997
-
998
- **If exists and has progress:**
999
-
1000
- - Read `oat_current_task_id` from frontmatter (e.g., "p01-t03" or "prev1-t01")
1001
- - **Revision task recognition:** `p-revN` phases and `prevN-tNN` task IDs are treated identically to standard `pNN` phases and `pNN-tNN` tasks for execution purposes. The implement skill does not need special handling — it just follows the plan sequentially.
1002
- - Validate the task pointer:
1003
- - If `oat_current_task_id` points at a task already marked `completed` in the body, advance to the **next incomplete** task (first `pending` / `in_progress` / `blocked` entry).
1004
- - If all tasks are completed, skip ahead to finalization (Step 11+).
1005
- - **Always resume** from the resolved task. Print `Resuming from {task_id}.` Do not prompt.
1006
- - **Fresh start is an explicit override only.** If the user invoked the skill with `fresh=true` (argument), warn `Starting fresh — this will overwrite implementation.md. Any draft logs will be lost.` and proceed with fresh initialization. Do not offer fresh start interactively; it is a rare edge case reserved for corrupt state or deliberate plan rewrites.
1007
-
1008
- **Stale-state reconciliation (approval required):**
1009
-
1010
- - Before executing tasks, cross-check `plan.md` Reviews status with `implementation.md` + `state.md`.
1011
- - If `plan.md` shows a scope as `passed` but `implementation.md` / `state.md` still says "awaiting re-review" (or leaves `oat_current_task_id` / `oat_current_task` as `null` while future plan tasks are still incomplete), treat this as bookkeeping drift.
1012
- - Resolve the next task from plan order (first incomplete non-review task after the passed scope), then ask:
1013
- - "Detected bookkeeping drift: review is passed in plan.md, but state artifacts still show awaiting re-review. Update artifacts and continue from {next_task_id}?"
1014
- - Only if the user approves:
1015
- - Update `implementation.md` frontmatter `oat_current_task_id: {next_task_id}`
1016
- - Update `state.md` frontmatter `oat_current_task: {next_task_id}` and refresh stale "awaiting re-review" wording
1017
- - Update implementation review notes "Next" guidance to continue implementation (not re-review)
1018
- - If the user declines:
1019
- - Do not auto-edit bookkeeping; pause and ask whether to proceed manually or stop.
1020
-
1021
- **If doesn't exist:**
1022
-
1023
- - Initialize from template (Step 4)
1024
-
1025
- **Important:** Never overwrite an existing `implementation.md` without explicit user confirmation (and warn that draft logs will be lost).
1026
-
1027
- ### Step 4: Initialize Implementation Document
1028
-
1029
- Copy template: `.oat/templates/implementation.md` → `"$PROJECT_PATH/implementation.md"`
1030
-
1031
- Update frontmatter:
1032
-
1033
- ```yaml
1034
- ---
1035
- oat_status: in_progress
1036
- oat_ready_for: null
1037
- oat_blockers: []
1038
- oat_last_updated: { today }
1039
- oat_current_task_id: p01-t01 # Stable task ID from plan
1040
- ---
1041
- ```
1042
-
1043
- Initialize project state so other skills (e.g., `oat-project-progress`) reflect that implementation has started:
1044
-
1045
- - In `"$PROJECT_PATH/state.md"` frontmatter:
1046
- - `oat_phase: implement`
1047
- - `oat_phase_status: in_progress`
1048
- - `oat_current_task: p01-t01`
1049
- - `oat_project_state_updated: "{ISO 8601 UTC timestamp}"`
1050
-
1051
- ### Step 5: Per-Phase Execution
1052
-
1053
- For each phase `pNN` in the plan (or each phase in a plan-declared parallel
1054
- worktree group), dispatch exactly one phase coordinator. The coordinator reads
1055
- the phase once and dispatches one exact task worker per task. It must not
1056
- implement ordinary plan tasks in its own context.
1057
-
1058
- #### Resolve the Task Maximum
1059
-
1060
- Before coordinator dispatch, read the project named ceiling from
1061
- `state.md:oat_dispatch_policy.policy`. Then inspect the optional plan
1062
- `## Dispatch Profile` row for this phase:
1063
-
1064
- 1. An explicit phase `economy`, `balanced`, `high`, or `frontier` narrows the
1065
- project maximum and sets `task_ceiling_source: phase`.
1066
- 2. Blank, absent, or `auto` uses the project maximum and sets
1067
- `task_ceiling_source: project`.
1068
- 3. Reject an unknown tier or a phase tier above the project tier.
1069
- 4. `uncapped` and explicit inherit/default retain their existing policy
1070
- semantics and have no named `--ceiling-tier`; never synthesize one.
1071
-
1072
- The project or phase named ceiling is a maximum, not the coordinator target or
1073
- an exact family preference. Under High, lower configured Economy, Balanced, and
1074
- High candidates remain available for different tasks.
1075
-
1076
- #### Build and Dispatch Phase Scope
1077
-
1078
- ```yaml
1079
- project: {PROJECT_PATH}
1080
- phase: {pNN}
1081
- mode: implement
1082
- artifact_paths:
1083
- plan: {PROJECT_PATH}/plan.md
1084
- design: {PROJECT_PATH}/design.md
1085
- spec: {PROJECT_PATH}/spec.md
1086
- implementation: {PROJECT_PATH}/implementation.md
1087
- discovery: {PROJECT_PATH}/discovery.md
1088
- workflow_mode: {spec-driven|quick|import}
1089
- active_provider: {codex|claude|cursor|other}
1090
- project_ceiling_tier: {named project maximum; omit when none}
1091
- phase_ceiling_tier: {explicit narrower phase maximum; omit for auto/blank}
1092
- task_ceiling_tier: {effective project or phase named ceiling}
1093
- task_ceiling_source: {project|phase}
1094
- commit_convention: {from plan.md}
1095
- coordinator_target: {resolver-selected coordinator target}
1096
- ```
1097
-
1098
- Tier 1 uses the already resolved exact coordinator role/model payload and sends
1099
- the Phase Scope. A concrete Codex coordinator uses
1100
- `providers.codex.dispatchArgs.variant` first as native `agent_type`. After the
1101
- host accepts the spawn, record the coordinator `target`, `model_axis`, and
1102
- `effort_axis` from resolver output and that constructed launcher payload; do not
1103
- wait for or accept a coordinator self-report as proof. Only an actual native
1104
- role-selection rejection permits the fresh child pinned to the resolver's model
1105
- and effort with canonical coordinator instructions. An accepted coordinator
1106
- that later returns `BLOCKED` has produced a coordinator outcome and cannot
1107
- trigger fallback. Claude and Cursor coordinator calls pass their exact resolver
1108
- model argument.
1109
-
1110
- Tier 2 may run the coordinator instructions in the current context only when
1111
- that context can still dispatch every exact task worker. Tier 2 never permits
1112
- the coordinator to edit ordinary task files. If no exact worker route exists,
1113
- block before phase work.
1114
-
1115
- #### Per-Task Coordinator Contract
1116
-
1117
- For each task in dependency order, the coordinator must:
1118
-
1119
- 1. Classify only that bounded task and choose one configured candidate at or
1120
- below `task_ceiling_tier`.
1121
- 2. Call the exact candidate resolver with the invocation-only named maximum:
1122
-
1123
- ```bash
1124
- oat project dispatch-ceiling resolve \
1125
- --provider <active-provider> \
1126
- --role implementer \
1127
- --ceiling-tier <project-or-phase-named-tier> \
1128
- --candidate-model <exact-model> \
1129
- --report-scope <task-id> \
1130
- --report-action implementation \
1131
- --project-path "$PROJECT_PATH" \
1132
- --json
1133
- ```
1134
-
1135
- Codex also passes `--candidate-effort <exact-effort>`. The returned top-level
1136
- `source` must be `invocation`; `providers.<provider>.cellSource` continues to
1137
- identify the config layer that owns the candidate definition. This command
1138
- is read-only and must never persist its override.
1139
-
1140
- 3. Build the actual provider invocation before logging:
1141
- - Codex first uses `providers.codex.dispatchArgs.variant` as native
1142
- `agent_type`. Spawn acceptance establishes the configured invocation; only
1143
- a native role-selection rejection permits the exact fresh pinned-child
1144
- model/effort route.
1145
- - Claude passes `providers.claude.dispatchArgs.model` as the actual Task
1146
- `model`.
1147
- - Cursor passes `providers.cursor.dispatchArgs.model` byte-for-byte as the
1148
- actual invocation model. Treat the string as opaque and never normalize or
1149
- infer capability from it.
1150
- - After construction, record the task-worker `target`, `model_axis`, and
1151
- `effort_axis` from resolver output and the launcher payload. Missing worker
1152
- telemetry or self-report is not unavailability, and self-report cannot
1153
- replace those launcher-owned values.
1154
- 4. Send one bounded Task Scope, never the full phase task list:
1155
-
1156
- ```yaml
1157
- mode: task-worker
1158
- task_id: { one pNN-tNN ID }
1159
- task_name: { task title }
1160
- task_plan: { only this task's steps }
1161
- file_boundary: { only this task's files }
1162
- verification: { only this task's verification commands }
1163
- commit_convention: { exact expected task commit }
1164
- ceiling_tier: { effective named maximum }
1165
- ceiling_source: { project|phase }
1166
- dispatch_target: { resolver-returned exact target }
1167
- dispatch_args: { complete actual provider payload }
1168
- ```
1169
-
1170
- 5. Dispatch one exact task worker and wait for its terminal result before the
1171
- next task. Workers in the same worktree run serially; task fan-out is
1172
- forbidden. Parallelism remains limited to plan-declared phase/worktree
1173
- groups.
1174
- 6. Verify the worker's task ID, result, tests, file boundary, clean worktree,
1175
- and reported commit against `git rev-parse HEAD` and the pre-task HEAD. A
1176
- worker must contribute exactly one verified task commit.
1177
- 7. Record each task's exact target, result, and commit in the returned **Task
1178
- Dispatch Summary**, then perform phase-wide verification and integration
1179
- self-review without editing ordinary task files.
1180
-
1181
- If a candidate is missing or absent, exceeds or is above the named ceiling, or
1182
- cannot be invoked with exact controls, fail closed and block the phase. Never
1183
- fall back or downgrade to the coordinator target, base role, or inferred
1184
- provider default. A transient retry reuses the same complete provider payload;
1185
- a substantive escalation re-resolves within the same named maximum and bounded
1186
- retry limit.
1187
-
1188
- #### Handling Coordinator Status
1189
-
1190
- - **DONE:** verify the Task Dispatch Summary, then proceed to phase review.
1191
- - **DONE_WITH_CONCERNS:** correctness concerns require a new bounded exact fix
1192
- worker before review; advisory concerns are recorded.
1193
- - **NEEDS_CONTEXT:** supply only the missing context and retry within the bound.
1194
- - **BLOCKED:** stop and surface the phase, task, exact target, and reason. Do not
1195
- proceed to later phases.
1196
-
1197
- ### Per-Phase Review
1198
-
1199
- After the implementer returns DONE (or DONE_WITH_CONCERNS without correctness concerns), dispatch the reviewer for the phase.
1200
-
1201
- **Dispatch:**
1202
-
1203
- - Use the same tier that was selected at start.
1204
- - For Codex with a capped managed policy, first dispatch the materialized reviewer role returned in `providers.codex.dispatchArgs.variant` as native `agent_type` for deterministic quality gates. After spawn acceptance, record the review `target`, `model_axis`, and `effort_axis` from resolver output and the constructed launcher payload; reviewer self-report cannot populate or overwrite them.
1205
- - Only if the exact registered reviewer role receives a native role-selection rejection may the launcher start a fresh Codex child with explicit model, reasoning effort, and canonical role instructions from `.agents/agents/oat-reviewer.md`; never substitute the managed base role and never require restart/hot reload. Missing reviewer telemetry or self-report is not a rejection, and an accepted reviewer that later returns `BLOCKED` cannot trigger fallback.
1206
- - 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.
1207
- - For Claude Code with a capped managed policy, require `providers.claude.dispatchArgs.model` and pass that exact value as the review `model`; managed `Uncapped` or inherit/default mode omits `model` because no reviewer target exists. Always keep `effort_axis=not-applicable`.
1208
- - For Cursor with a concrete managed reviewer target, require `providers.cursor.dispatchArgs.model` and pass that exact opaque, unnormalized string as the actual review invocation's `model` argument.
1209
- - Build the actual provider invocation before logging the reviewer target. If the host cannot apply the required Claude or Cursor model argument, fail closed or block unless inline execution has verified equivalent current-host controls.
1210
- - Tier 1: dispatch the selected reviewer target via provider-native subagent mechanism with Review Scope:
1211
-
1212
- ```
1213
- project: {PROJECT_PATH}
1214
- type: code
1215
- scope: {pNN}
1216
- commits: {base_sha}..{head_sha}
1217
- files_changed: {optional hint from implementer's report}
1218
- workflow_mode: {from state.md}
1219
- artifact_paths: {same as Phase Scope}
1220
- tasks_in_scope: {list of pNN-tNN IDs in the phase}
1221
- dispatch_policy: {economy | balanced | high | frontier | uncapped | inherit host defaults | legacy capped}
1222
- dispatch_ceiling: {resolved cap value | null}
1223
- policy_source: {repo config | project state | preflight prompt}
1224
- ceiling_source: {repo config | project state | preflight prompt} # compatibility alias for policy_source
1225
- provider_default_effort: {value | unknown | not-applicable}
1226
- model_axis: { selected:<value> | inherited | not-applicable | host-auto }
1227
- effort_axis: {selected:<Codex value> | provider-default | not-applicable}
1228
- dispatch_rationale: {capped reviewer target | uncapped/inherit reviewer fallback}
1229
- ```
1230
-
1231
- - 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.
1232
- - For Codex Tier 1 review dispatches, use the materialized Codex role name from `providers.codex.dispatchArgs.variant` only when the resolver returns a reviewer variant for a capped managed policy. A Codex materialized reviewer role selected from a model+effort target must carry `model_axis=selected:<model>` and `effort_axis=selected:<effort>` from resolver output. Use base `oat-reviewer` only when the resolver returns no `dispatchArgs.variant` for managed `Uncapped`, inherit/default mode, or provider-default fallback, and log `effort_axis=provider-default`. For Claude Code, pass `model: providers.claude.dispatchArgs.model` for a concrete managed reviewer and never pass a per-review effort override. For Cursor, pass `model: providers.cursor.dispatchArgs.model` byte-for-byte for a concrete managed reviewer.
1233
- - Treat the commit range as authoritative for review scope. `files_changed` is optional orientation metadata only.
1234
- - If a 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 target-preserving review dispatch as failed for this phase. When the original native reviewer spawn was accepted, retry the same already-selected native `agent_type` route within the retry bound; do not switch that timed-out reviewer to a fresh pinned child. The fresh pinned-child route is eligible only when the original native attempt received explicit pre-start role-selection rejection. Retry an already-selected pinned fresh-child route or complete Claude/Cursor invocation payload without changing routes, preserving the exact model argument; never downgrade a timed-out managed reviewer to unpinned inline execution.
1235
-
1236
- - Tier 2: read `.agents/agents/oat-reviewer.md` and review inline only with verified equivalent current-host model and effort controls, explicit inherit/default behavior, or the documented managed-uncapped reviewer behavior. Otherwise block.
1237
-
1238
- **Verdict outcomes:**
1239
-
1240
- Parse the reviewer's confirmation for verdict + finding severities. Map to pass / fail:
1241
-
1242
- - **pass:** zero Critical and zero Important findings.
1243
- - **fail:** one or more Critical or Important findings.
1244
- - **blocked:** An accepted reviewer `BLOCKED` terminal blocks this phase review.
1245
- It does not invoke fallback and must not be interpreted as a pass due to
1246
- absent findings. Stop and surface the review target and blocker reason.
1247
-
1248
- Medium / Minor findings do not block the phase but are recorded.
1249
-
1250
- #### Bounded Fix Loop
1251
-
1252
- On reviewer verdict `fail`, run a bounded fix loop.
1253
-
1254
- 1. Read `oat_orchestration_retry_limit` from `state.md` frontmatter (default: `2`, range 0–5).
1255
- 2. For each retry (up to the limit):
1256
- a. Convert Critical/Important findings into bounded fix scopes associated with one planned task/file boundary at a time. Do not hand one worker the full phase finding list.
1257
- b. Reuse the phase coordinator in `fix` mode. It selects an exact candidate under the same project or phase named ceiling with `--ceiling-tier`, then emits one Task Scope per bounded fix. Codex first uses `providers.codex.dispatchArgs.variant` as native `agent_type`; only a native role-selection rejection permits the exact fresh-child fallback. Claude and Cursor pass their exact `providers.<provider>.dispatchArgs.model` value on the actual invocation. After constructing the launcher payload, record the fix `target`, `model_axis`, and `effort_axis` from that payload and resolver output. Missing fix-worker telemetry or self-report is not unavailability, and an accepted fix worker — including one that returns `BLOCKED` — cannot trigger fallback. Every fix worker writes the formal `Dispatch: scope=<phase-or-task> action=fix role=fix producer=<slug|unknown> provenance=<declared|observed|inferred|unknown> model_axis=<axis> effort_axis=<axis> dispatch_policy=<policy|unknown> dispatch_ceiling=<value|none> target=<target|unknown>` stamp before execution.
1258
- c. Receive and verify each fix result and commit. The coordinator must not apply fixes itself, and Tier 2 does not authorize inline task edits.
1259
- d. Re-dispatch the reviewer with the updated commit range.
1260
- e. Parse the new verdict.
1261
- f. If pass → exit the loop successfully.
1262
- g. If fail and retries remain → continue.
1263
- h. If fail and retries exhausted → exit the loop with terminal verdict `failed`.
1264
-
1265
- **Terminal `failed` handling:**
1266
-
1267
- - **Sequential mode:** STOP the run. Surface to user with phase ID, unresolved findings, review artifact path. Do not proceed to subsequent phases.
1268
- - **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.
1269
-
1270
- ### Optional External Phase Review Gate
1271
-
1272
- After the standard per-phase reviewer passes and after the required phase bookkeeping commit is cleanly recorded, check `oat_phase_review_gate`.
1273
-
1274
- If the gate is enabled and the current phase is selected:
1275
-
1276
- 1. Run the gate from the orchestration branch with the active project path:
1277
-
1278
- ```bash
1279
- oat --json gate review \
1280
- --project "$PROJECT_PATH" \
1281
- --review-type code \
1282
- --review-scope "{pNN}" \
1283
- --exit-nonzero-on "{threshold}" \
1284
- '$oat-project-review-provide code {pNN}'
1285
- ```
1286
-
1287
- - `{threshold}` comes from `oat_phase_review_gate.exit_nonzero_on` (default: `important`).
1288
- - `{pNN}` is the completed phase ID.
1289
- - Do not pass `--target` in normal execution; the existing gate config selects the cross-provider target.
1290
- - The gate CLI injects gate context into the review prompt. The produced review artifact must use `oat_review_invocation: gate`.
1291
-
1292
- 2. Parse the JSON result. Before invoking review-receive, all three receive-eligibility conditions must hold: `status` is `ok` or `blocked`, the envelope explicitly sets `receiveEligible: true`, and `handoff` is non-null. A missing or contradictory field is an operational failure even when `artifactPath` is present. The gate verdict (`exit_nonzero_on: {threshold}`) decides whether the phase **stops**; it does not decide whether sub-threshold findings are ignored. Once eligibility is established, the produced artifact must be **consumed** — passing gate artifacts are not left unprocessed at the top level of `reviews/`.
1293
- - With eligibility established, `status: "ok"` / exit code `0` means the phase gate passed at the configured threshold, so the phase does not stop. 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.
1294
- - With eligibility established, `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.
1295
- - Any other status, or 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.
1296
-
1297
- 3. If `oat-project-review-receive` adds fix tasks (blocking gate, or a sweep address-now fix that revealed a Critical/Important concern):
1298
- - Return to task execution for the newly added review-fix tasks.
1299
- - After fixes land, re-run the standard per-phase reviewer and this external phase gate for the same phase.
1300
- - Continue only after both the standard reviewer and the external phase gate pass.
1301
- - 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.
1302
-
1303
- 4. If the judgment sweep (passing gate) records only deferrals/rejections and no blocking fix tasks, record the receive result and continue.
1304
-
1305
- 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.
1306
-
1307
- ### Parallel Group Execution
1308
-
1309
- When the current schedule entry is a multi-phase group, execute as follows.
1310
-
1311
- **Tier 2 degradation:** If Tier 2 was selected at skill start, Tier 2 cannot run concurrent subagents. Degrade the group to sequential target-preserving execution on the orchestration branch. Do not create worktrees. For every phase, retain the exact role or pinned fresh child; inline is permitted only by the verified-equivalent-controls or documented-exception guard. Proceed through the per-phase loop in plan order.
1312
-
1313
- **Tier 1 parallel execution:**
1314
-
1315
- 1. **Bootstrap worktrees:** for each phase in the group, invoke `oat-worktree-bootstrap-auto` with branch name `{project-name}/{pNN}` and base = orchestration branch.
1316
-
1317
- > ⚠️ **CRITICAL — DO NOT substitute host-native worktree primitives.** Bootstrap MUST go through `oat-worktree-bootstrap-auto` with an explicit `--base` set to the current orchestration branch HEAD (capture `EXPECTED_HEAD=$(git rev-parse HEAD)` from the orchestration cwd before dispatching). Do not use Claude Code's `Agent({ isolation: "worktree" })`, Cursor's equivalent, or any other host-native isolation primitive in lieu of this skill — those mechanisms may use the primary repo's checkout (often `main`) as the base regardless of the orchestrator's current branch, silently producing a worktree that cannot see prior phase commits and forcing the entire group to degrade to sequential.
1318
- - If **any** bootstrap fails, cancel any worktrees that bootstrapped successfully for this group and degrade the whole group to sequential target-preserving execution. Log the degradation reason to `implementation.md` Outstanding Items.
1319
-
1320
- 2. **Verify worktree HEAD before dispatch (base-mismatch gate):** After bootstrap, verify each worktree is at the expected orchestration HEAD. From the orchestration cwd, capture `EXPECTED_HEAD=$(git rev-parse HEAD)` _before_ invoking bootstrap. After bootstrap, for each new worktree path, run `git -C {worktree-path} rev-parse HEAD` and confirm it matches `EXPECTED_HEAD`, or run `git -C {worktree-path} merge-base --is-ancestor "$EXPECTED_HEAD" HEAD` and confirm it succeeds (exit 0). If either check fails for any phase, treat the bootstrap as failed for that phase, cancel any successful sibling worktrees in this group, and degrade the entire group to sequential target-preserving execution — same mechanism as a primary bootstrap failure. Log the mismatch to `implementation.md` Outstanding Items, including the observed and expected SHAs (`expected={EXPECTED_HEAD}, observed={observed-head-sha}, phase={pNN}, worktree={path}`).
1321
-
1322
- 3. **Concurrent phase dispatch:** for each successfully bootstrapped worktree (passing the base-mismatch gate above), dispatch one `oat-phase-implementer` coordinator with the worktree as its working directory. Coordinators may run concurrently across these plan-declared phase worktrees, but every coordinator dispatches its own task workers serially in that one worktree. The outer orchestration loop retains review and bounded-fix handling.
1323
-
1324
- 4. **Wait for all phases:** do not proceed until every phase in the group reports a terminal verdict (pass or excluded).
1325
-
1326
- 5. **Fan-in reconciliation (merge back in plan order):**
1327
-
1328
- For each phase in the group, in plan order (p02 before p03, etc.), if its verdict is pass:
1329
-
1330
- a. Attempt `git merge --no-ff {project-name}/{pNN} -m "merge({pNN}): {summary from implementer}"`.
1331
- b. If merge produces conflicts, abort the merge and attempt cherry-pick of the phase's commits.
1332
- c. If cherry-pick also produces conflicts, dispatch an inline conflict-resolution subagent via the Task tool. The orchestrator MUST NOT read the conflicted files itself — delegate to the subagent. Use this dispatch shape:
1333
-
1334
- ```
1335
- Task (general-purpose subagent):
1336
- description: "Resolve merge conflict for phase {pNN}"
1337
- prompt: |
1338
- You are resolving a git merge conflict during parallel-phase fan-in.
1339
-
1340
- Phase: {pNN}
1341
- Orchestration branch: {orchestration-branch}
1342
- Worktree: {worktree-path}
1343
- Conflicted files: {list from git status}
1344
- Project artifacts:
1345
- plan: {PROJECT_PATH}/plan.md
1346
- design: {PROJECT_PATH}/design.md
1347
- spec: {PROJECT_PATH}/spec.md
1348
-
1349
- Steps:
1350
- 1. Read each conflicted file. Parse conflict markers (<<<<<<<, =======, >>>>>>>).
1351
- 2. Read the project artifacts to understand intent from both sides.
1352
- 3. Apply a resolution that preserves intent from both sides where possible.
1353
- 4. Remove conflict markers. Save files.
1354
- 5. Stage resolved files with `git add <files>`.
1355
- 6. Run integration verification: `pnpm test && pnpm lint && pnpm type-check`.
1356
- 7. If all pass: commit with `merge({pNN}): resolved conflict during fan-in`.
1357
- 8. If any step fails: do NOT commit. Return with the appropriate status.
1358
-
1359
- Return format (end of response):
1360
- status: RESOLVED | UNRESOLVABLE | VERIFICATION_FAILED
1361
- reasoning: <2-4 sentence summary of what you did or why you stopped>
1362
- commit: <sha if RESOLVED, else null>
1363
- ```
1364
-
1365
- d. Parse the subagent's return status: - `RESOLVED` → subagent has committed the merge; orchestrator proceeds to integration verification (Step 6) and the next phase in the group. - `UNRESOLVABLE` or `VERIFICATION_FAILED` → STOP the run. Surface to user with phase ID, conflicting files, worktree path, subagent's reasoning summary. Do not merge remaining phases.
1366
-
1367
- **Tier 2 conflict exception:** In Tier 2 runs, parallel groups already degrade to sequential, so fan-in conflicts do not arise from this code path. If a conflict surfaces from another operation, inline resolution is allowed only when the current-host controls satisfy the same verified-equivalence or documented-exception guard; otherwise stop for a target-preserving route.
1368
-
1369
- 6. **Integration verification after each merge:**
1370
-
1371
- After each successful merge, run project verification (tests, lint, type-check). If verification fails:
1372
- - Attempt a tractable fix (missing import, trivial type error). If the fix succeeds and verification passes, commit the fix.
1373
- - If the fix is not tractable → revert the merge, STOP the run. Surface to user.
1374
-
1375
- 7. **Worktree cleanup:**
1376
-
1377
- For phases that merged successfully and passed integration verification, clean up the worktree using the existing worktree cleanup mechanism (e.g., `git worktree remove`).
1378
-
1379
- For phases that were excluded (fix-loop exhausted), preserve the worktree and log its path in `implementation.md` Outstanding Items.
1380
-
1381
- 8. **Bookkeeping commit** after the group completes. Then run any selected external phase review gates. After those gates pass, perform the HiLL checkpoint check.
1382
-
1383
- ### Step 7: Artifact Updates After Each Phase (or Group)
1384
-
1385
- After each phase (sequential) or each parallel group (multi-phase) completes, update the tracking artifacts before moving on.
1386
-
1387
- **`implementation.md`:**
1388
-
1389
- Append a new entry to the `## Orchestration Runs` section between the `<!-- orchestration-runs-start -->` and `<!-- orchestration-runs-end -->` markers. Format:
1390
-
1391
- ```markdown
1392
- ### Run {N} — {YYYY-MM-DD HH:MM}
1393
-
1394
- **Branch:** {orchestration-branch}
1395
- **Tier:** {1 | 2}
1396
- **Policy:** merge-strategy=merge, retry-limit={N}
1397
- **Phases:** {N} executed, {N} passed, {N} failed, {N} stopped
1398
-
1399
- #### Phase Outcomes
1400
-
1401
- | Phase | Implementer | Review | Fix Iterations | Disposition |
1402
- | ----- | ----------- | ------ | -------------- | ----------- | ------- | -------- | -------- |
1403
- | pNN | {status} | {pass | fail} | N/{limit} | {merged | excluded | stopped} |
1404
-
1405
- #### Parallel Groups
1406
-
1407
- - Group {N} [{phase list}]: worktree-based, merged in order
1408
- - {singleton phases}: sequential
1409
-
1410
- #### Dispatch Notes
1411
-
1412
- - Dispatch stamps: {formal `Dispatch: ...` records, plus route level and escalation rationale when applicable}
1413
-
1414
- #### Outstanding Items
1415
-
1416
- - {None | list of excluded phases with review paths and worktree paths}
1417
-
1418
- #### Artifact / Design Deltas
1419
-
1420
- Run-scoped snapshot only. The durable record is `## Deviations from Plan / Design`; consolidate any non-`None` entries there at the next phase boundary.
1421
-
1422
- | Task / Review | Source Artifact | Planned / Documented | Actual / Accepted | Reason | Source of Truth | Follow-up |
1423
- | ----------------------------- | ----------------------------------- | ------------------------------- | -------------------------------------- | ---------------------------- | ------------------------- | ------------------------------------------- |
1424
- | {task_id/review_id or `None`} | {spec.md/design.md/plan.md section} | {planned behavior/taxonomy/API} | {actual shipped behavior/taxonomy/API} | {why divergence is accepted} | {implementation/artifact} | {artifact update task or explicit deferral} |
1425
- ```
1426
-
1427
- Append only — never overwrite prior run entries.
1428
-
1429
- **`plan.md` review table:**
1430
-
1431
- For each phase that completed:
1432
-
1433
- - Pass on first try → set phase row to `passed` with date + review artifact path.
1434
- - Pass after fixes → set to `fixes_added` → `fixes_completed` → `passed` (match existing lifecycle).
1435
- - Fix-loop exhausted → leave at `fixes_added` with "excluded" note in the artifact link.
1436
- - `final` review row is never touched by this skill.
1437
-
1438
- **`state.md`:**
1439
-
1440
- - Update `oat_current_task` to the next un-run task ID (or the final task if run complete).
1441
- - Update `oat_last_commit` to the bookkeeping commit SHA about to be made.
1442
- - Update `oat_project_state_updated` to current ISO 8601 UTC timestamp.
1443
- - If `oat_execution_mode: subagent-driven` is present, remove the key.
1444
- - If the user supplied a `--retry-limit` override, persist as `oat_orchestration_retry_limit`.
1445
-
1446
- **Bookkeeping commit (mandatory):**
1447
-
1448
- ```bash
1449
- oat state refresh
1450
- git add {PROJECT_PATH}/implementation.md {PROJECT_PATH}/state.md {PROJECT_PATH}/plan.md
1451
- git commit -m "chore(oat): bookkeeping after {pNN} {pass|fail}"
1452
- ```
1453
-
1454
- 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 the HiLL checkpoint. A non-final checkpoint pauses at this boundary; defer a final-phase checkpoint to **Final HiLL Closeout Sequence** after final verification, final review, and any configured pre-approval steps succeed.
1455
-
1456
- ### Step 8: Check Plan Phase Completion
1457
-
1458
- When all tasks in current plan phase complete (e.g., all p01-\* tasks done):
1459
-
1460
- **Update frontmatter:**
1461
-
1462
- ```yaml
1463
- oat_current_task_id: { first_task_of_next_phase } # e.g., p02-t01
1464
- ```
1465
-
1466
- **Plan phase checkpoint:**
1467
- At the end of each plan phase (p01, p02, etc.), check `oat_plan_hill_phases` in plan.md to decide whether to pause:
1468
-
1469
- - **If `oat_plan_hill_phases` is empty (`[]`):** Pause after every phase (default behavior after confirmation).
1470
- - **If `oat_plan_hill_phases` has values:** Pause only after completing a listed phase.
1471
- - Example: `["p01", "p04"]` → pause after p01 completes and after p04 completes; skip p02, p03.
1472
- - Example: `["p03"]` where p03 is the last phase → run all phases without pausing, then pause after p03 (end of implementation).
1473
- - **If `oat_plan_hill_phases` is missing at a phase boundary:** treat this as bookkeeping drift and stop to repair it before continuing, because the confirmation should already have been written during the first implementation run.
1474
-
1475
- **Key semantic: listed phases are where you stop AFTER completing them, not before.** `["p03"]` means "complete p03, then pause" — not "pause before starting p03."
1476
-
1477
- **Auto-review at HiLL checkpoints (Touchpoint B):**
1478
-
1479
- Before pausing at a checkpoint, check if auto-review is enabled:
1480
-
1481
- 1. Read `oat_auto_review_at_hill_checkpoints` from plan.md frontmatter. If not present, fall back to legacy `oat_auto_review_at_checkpoints`. If neither is present, fall back to `oat config get workflow.autoReviewAtHillCheckpoints` (which itself falls back to legacy `.oat/config.json` `autoReviewAtCheckpoints` when unset).
1482
-
1483
- 2. If enabled and this is a checkpoint phase:
1484
- a. **Determine review scope:** Find the highest completed implementation phase already covered by a **`passed`** code-review row in plan.md Reviews table. Count only whole-phase scopes: `pNN` or `pNN-pMM`. Ignore task scopes (`pNN-tNN`) and rows with `fixes_added` or `fixes_completed` because those reviews did not pass and must be re-covered. Scope = every implementation phase after that passed coverage through the current phase, inclusive. If no earlier passed whole-phase review exists, start from the first implementation phase. Use `pNN-pMM` when the scope spans multiple phases. If this is the final implementation phase checkpoint, run `oat-project-review-provide code final`; use scope `final` and do not run a duplicate final phase-only lifecycle review, because Tier 1 already runs the standard per-phase reviewer before the final checkpoint branch.
1485
- - Example: prior passed row `p01`, current checkpoint `p03` → review `p02-p03`
1486
- - Example: no prior passed whole-phase review, current checkpoint `p03` → review `p01-p03`
1487
- - Example: current checkpoint is the last implementation phase → review `final`
1488
- b. **Spawn subagent review:** `oat-project-review-provide code {scope}` — instruct it to include `oat_review_invocation: auto` in the review artifact frontmatter.
1489
- c. **Auto-invoke review-receive:** `oat-project-review-receive` — operates in auto-disposition mode when `oat_review_invocation: auto` is present:
1490
- - Critical/Important/Medium: convert to fix tasks (same as manual)
1491
- - Minor: auto-convert to fix tasks unless clearly out of scope
1492
- - No user prompts for disposition
1493
- d. **If fix tasks added:** continue implementing automatically (no checkpoint pause — return to Step 5 for the new fix tasks)
1494
- e. **If scope passed:** proceed to the checkpoint pause below
1495
-
1496
- 3. If disabled: skip directly to the checkpoint pause.
1497
-
1498
- When pausing at a non-final checkpoint:
1499
-
1500
- - Output phase summary (tasks completed, commits made)
1501
- - Ask user: "Phase {N} ({phase_name}) complete. Continue to next phase?"
1502
- - Wait for user approval before proceeding to next plan phase
1503
-
1504
- **Final checkpoint deferral:** If the current phase is the final implementation
1505
- phase and it is configured as a HiLL checkpoint, do not ask the generic
1506
- "Continue to next phase?" question. Final checkpoint auto-review above still
1507
- runs exactly as written, including `oat-project-review-provide code final` and
1508
- its no-duplicate-final-review rule. Then continue through Steps 9–14. Final
1509
- approval occurs only in **Final HiLL Closeout Sequence**, after final review and
1510
- the stored pre-approval sequence complete.
1511
-
1512
- **Restart safety (required):**
1513
-
1514
- - At the end of each task and at each phase boundary, ensure `implementation.md` is persisted and internally consistent:
1515
- - `oat_current_task_id` points at the next task to do (or `null` when complete)
1516
- - Phase status sections match the progress overview table
1517
- - The implementation log reflects what was actually completed
1518
-
1519
- **Phase summaries (required):**
1520
-
1521
- - When a plan phase completes (p01, p02, etc.), update the "Phase Summary" section in `implementation.md` for that phase:
1522
- - Outcome (behavior-level)
1523
- - Key files touched (paths)
1524
- - Verification run
1525
- - Notable decisions/deviations
1526
-
1527
- **Design/artifact deltas (required when present):**
1528
-
1529
- - If a completed task intentionally diverged from `spec.md`, `design.md`, or `plan.md`, update the `## Deviations from Plan / Design` table in `implementation.md`.
1530
- - For existing project artifacts, treat any `## Deviations...` heading as the deviations section; migrate to the preferred `## Deviations from Plan / Design` heading and table shape when already touching the section.
1531
- - Each delta must include: the affected source artifact/section, the planned/documented expectation, the actual shipped implementation, the reason the divergence is accepted, the current source of truth, and any follow-up artifact update task or explicit deferral.
1532
- - If the implementation is now source of truth and the design/spec/plan is stale, write that directly. Do not treat the stale artifact as a no-op just because code is correct.
1533
- - If no deltas exist for the phase, do not invent one; leave the table unchanged.
1534
-
1535
- **Bookkeeping commit (required):**
1536
-
1537
- **DO NOT SKIP.** This commit prevents state drift across sessions.
1538
-
1539
- After phase summary and task pointer advancement, refresh the repo dashboard when available and commit all modified project tracking files:
1540
-
1541
- ```bash
1542
- oat state refresh
1543
- git add "$PROJECT_PATH/implementation.md" "$PROJECT_PATH/state.md" "$PROJECT_PATH/plan.md"
1544
- git diff --cached --quiet || git commit -m "chore(oat): update tracking artifacts for {phase} completion"
1545
- ```
1546
-
1547
- Do not use `git add -A` or glob patterns. Only commit the three project artifacts listed above; `.oat/state.md` is a generated, gitignored dashboard.
1548
-
1549
- **Note on HiLL types:**
1550
-
1551
- - **Workflow HiLL** (`oat_hill_checkpoints` in state.md): Gates between workflow phases (discovery → spec → design → plan → implement). Checked by oat-project-progress router.
1552
- - **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. A checkpoint on the final implementation phase is deferred to final closeout so final verification, final review, and configured pre-approval work finish before explicit approval.
1553
- - **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.
1554
-
1555
- **Revision phase completion handling:**
1556
-
1557
- When all tasks in a `p-revN` phase complete (revision phases created by `oat-project-revise`):
1558
-
1559
- 1. Set `oat_phase_status: pr_open` (not `complete` — the PR is still open for further review)
1560
- 2. Set `oat_current_task: null`
1561
- 3. Invoke `oat-project-summary` to update summary.md if it exists (implement owns summary re-generation at revision phase completion, not the revise skill)
1562
- 4. Update next milestone: "Revision complete. Push changes to update PR. Run `oat-project-revise` for more feedback or `oat-project-complete` when approved."
1563
- 5. Push changes to update the PR branch
1564
-
1565
- This is different from regular phase completion — revision phases return to `pr_open` instead of continuing to the next phase, because the user needs to decide whether more revisions are needed.
1566
-
1567
- ### Step 9: Repeat Until Complete
1568
-
1569
- Continue Steps 5-8 until all plan phases complete.
1570
-
1571
- **Batch execution:**
1572
-
1573
- - Default: Execute tasks one at a time
1574
- - If user requests: Execute N tasks before checking in
1575
- - Stop at configured plan phase boundaries for review
1576
-
1577
- ### Step 10: Handle Blockers
1578
-
1579
- If a task cannot be completed:
1580
-
1581
- **Mark as blocked:**
1582
-
1583
- ```yaml
1584
- oat_blockers:
1585
- - task_id: { task_id } # e.g., p01-t03
1586
- reason: '{description}'
1587
- since: { date }
1588
- ```
1589
-
1590
- **Update task status:**
1591
-
1592
- ```markdown
1593
- ### Task {task_id}: {Task Name}
1594
-
1595
- **Status:** blocked
1596
- **Blocker:** {description}
1597
- ```
1598
-
1599
- **Notify user:**
1600
-
1601
- ```
1602
- Task {task_id} blocked: {reason}
1603
-
1604
- Options:
1605
- 1. Resolve blocker and continue
1606
- 2. Skip task (mark as deferred)
1607
- 3. Modify plan to address blocker
1608
- ```
1609
-
1610
- ### Step 11: Mark Implementation Complete
1611
-
1612
- When all plan tasks are complete (i.e., there is no next incomplete `pNN-tNN` task):
1613
-
1614
- **Update "Final Summary" (required):**
1615
-
1616
- - Before requesting final review / running `oat-project-pr-final`, update the `## Final Summary (for PR/docs)` section in `"$PROJECT_PATH/implementation.md"`:
1617
- - What shipped (capabilities, behavior-level)
1618
- - Key files/modules touched
1619
- - Verification performed (tests/lint/typecheck/build/manual)
1620
- - Design deltas (if any)
1621
- - This should reflect **what was actually implemented**, including any deviations from design and any review-fix work.
1622
-
1623
- Update frontmatter:
1624
-
1625
- ```yaml
1626
- ---
1627
- oat_status: complete
1628
- oat_ready_for: null
1629
- oat_blockers: []
1630
- oat_last_updated: { today }
1631
- oat_current_task_id: null
1632
- ---
1633
- ```
1634
-
1635
- **Important:** `oat_current_task_id` should never point at an already-completed task. If all tasks are done, set it to `null` and proceed to the final review gate.
1636
-
1637
- ### Step 12: Update Project State
1638
-
1639
- Update `"$PROJECT_PATH/state.md"` so other skills reflect task completion and review gating:
1640
-
1641
- **Frontmatter updates:**
1642
-
1643
- - `oat_current_task: null`
1644
- - `oat_last_commit: {final_commit_sha}`
1645
- - `oat_blockers: []`
1646
- - `oat_phase: implement`
1647
- - `oat_phase_status: in_progress` (until final review passes)
1648
- - `oat_project_state_updated: "{ISO 8601 UTC timestamp}"`
1649
- - **If** `"implement"` is in `oat_hill_checkpoints`: append `"implement"` to `oat_hill_completed` array
1650
-
1651
- **Note:** Only append to `oat_hill_completed` when the phase is configured as a HiLL gate.
1652
-
1653
- Update content:
1654
-
1655
- ```markdown
1656
- ## Current Phase
1657
-
1658
- Implementation - Tasks complete; awaiting final review.
1659
-
1660
- ## Progress
1661
-
1662
- - ✓ Discovery complete
1663
- - ✓ Specification complete
1664
- - ✓ Design complete
1665
- - ✓ Plan complete
1666
- - ✓ Implementation tasks complete
1667
- - ⧗ Awaiting final review
1668
- ```
1669
-
1670
- **Bookkeeping commit (required):**
1671
-
1672
- **DO NOT SKIP.** This commit prevents state drift across sessions.
1673
-
1674
- After updating state.md to reflect implementation completion, refresh the repo dashboard when available and commit all modified project tracking files:
1675
-
1676
- ```bash
1677
- oat state refresh
1678
- git add "$PROJECT_PATH/implementation.md" "$PROJECT_PATH/state.md" "$PROJECT_PATH/plan.md"
1679
- git diff --cached --quiet || git commit -m "chore(oat): update tracking artifacts for implementation complete"
1680
- ```
1681
-
1682
- Do not use `git add -A` or glob patterns. Only commit the three project artifacts listed above; `.oat/state.md` is a generated, gitignored dashboard.
1683
-
1684
- ### Step 13: Final Verification
1685
-
1686
- Run project-wide verification:
1687
-
1688
- ```bash
1689
- # Run tests
1690
- pnpm test
1691
-
1692
- # Run lint
1693
- pnpm lint
1694
-
1695
- # Run type check
1696
- pnpm type-check
1697
-
1698
- # Run build
1699
- pnpm build
1700
- ```
1701
-
1702
- All must pass before proceeding.
1703
-
1704
- ### Step 14: Trigger Final Review
1705
-
1706
- **At the final plan phase boundary, a code review is required before PR.**
1707
-
1708
- An accepted reviewer `BLOCKED` terminal blocks final review. It does not invoke
1709
- fallback and must not be interpreted as a pass due to absent findings. Stop and
1710
- surface the review target and blocker reason.
1711
-
1712
- Before requesting final review, ensure the latest project-artifact bookkeeping is already committed. Review should evaluate the implementation state as it actually stands on the branch, not a half-tracked working tree.
1713
-
1714
- Check if final review already completed (preferred source of truth: plan.md Reviews table):
1715
-
1716
- ```bash
1717
- FINAL_ROW=$(grep -E "^\\|\\s*final\\s*\\|" "$PROJECT_PATH/plan.md" 2>/dev/null | head -1)
1718
- echo "$FINAL_ROW"
1719
- ```
1720
-
1721
- **If final review row exists and status is `passed`:**
1722
-
1723
- - Example row:
1724
- - `| final | code | passed | 2026-01-28 | reviews/final-review-2026-01-28T140322Z.md |`
1725
- - Check:
1726
-
1727
- ```bash
1728
- echo "$FINAL_ROW" | grep -qE "^\\|\\s*final\\s*\\|.*\\|\\s*passed\\s*\\|" && echo "passed"
1729
- ```
1730
-
1731
- - Continue to Step 15 (final closeout)
1732
-
1733
- **If final review is not marked `passed`:**
1734
-
1735
- - Tell user: "All tasks complete. Final review required before PR."
1736
-
1737
- **Workflow preference check (before prompting):**
1738
-
1739
- First resolve the final reviewer target with the same target-first contract as
1740
- per-phase review. A concrete managed Codex target must first send its exact
1741
- registered reviewer as native `agent_type`; only a native role-selection
1742
- rejection permits an explicitly pinned fresh child. Spawn acceptance plus the
1743
- launcher payload supplies configured invocation evidence, so missing telemetry,
1744
- missing self-report, or a later `BLOCKED` result cannot trigger fallback. Record
1745
- the final review `target`, `model_axis`, and `effort_axis` from resolver output
1746
- and the constructed launcher payload, never from reviewer self-report. A
1747
- concrete managed Claude or Cursor target must put
1748
- `providers.claude.dispatchArgs.model` or
1749
- `providers.cursor.dispatchArgs.model` respectively into the actual provider
1750
- invocation as the exact `model` argument; Cursor strings remain opaque. On
1751
- timeout or retry, preserve the already-selected route as well as its complete
1752
- invocation payload: an accepted native reviewer retries the same native
1753
- `agent_type`, while a fresh pinned-child route is eligible only when the
1754
- original native attempt received explicit pre-start role-selection rejection.
1755
- Preserve the exact model argument. If the host cannot apply the required role or
1756
- model argument, fail closed or block unless verified equivalent current-host
1757
- controls permit inline execution. The preference below chooses only among
1758
- routes that preserve that target; it cannot authorize generic inline or base
1759
- execution. Inline remains available only with verified equivalent current-host
1760
- controls or an allowed explicit inherit/default or managed-uncapped reviewer
1761
- base-role exception.
1762
-
1763
- ```bash
1764
- REVIEW_MODEL=$(oat config get workflow.reviewExecutionModel 2>/dev/null || true)
1765
- ```
1766
-
1767
- - **If `REVIEW_MODEL` is `subagent`:** Print `Review execution: subagent (from workflow.reviewExecutionModel).` Dispatch the review subagent directly via the Task tool. No prompt.
1768
- - **If `REVIEW_MODEL` is `inline`:** Honor it only when the inline route satisfies the verified-equivalent-controls or documented-exception guard. Otherwise use the exact/pinned route or block. When allowed, print `Review execution: inline (from workflow.reviewExecutionModel).` and run the review in-context per `oat-project-review-provide`.
1769
- - **If `REVIEW_MODEL` is `fresh-session`:** This is a **soft preference with escape hatch** because the agent cannot run the review in a fresh session on the user's behalf. Print the guidance block below, then handle the user's response per the three outcomes listed after it.
1770
- - **If unset or invalid:** Fall through to the standard 3-tier prompt below.
1771
-
1772
- **Fresh-session guidance block (print when `REVIEW_MODEL` is `fresh-session`):**
1773
-
1774
- ```
1775
- Per your config (workflow.reviewExecutionModel: fresh-session), your
1776
- preference is to run the review in a fresh session.
1777
-
1778
- Run `oat-project-review-provide code final` in a separate session, then
1779
- resume this session when the review is complete.
1780
-
1781
- If you'd like to review here instead:
1782
- 1) subagent
1783
- 2) inline
1784
-
1785
- Enter 1 or 2 to run the review here, or press Enter to wait.
1786
- ```
1787
-
1788
- **Fresh-session response outcomes:**
1789
-
1790
- - User enters `1` → dispatch the subagent review (same behavior as `REVIEW_MODEL=subagent`).
1791
- - User enters `2` → apply the same guarded inline behavior as `REVIEW_MODEL=inline`; this choice does not waive managed target controls.
1792
- - User presses Enter (or equivalent no-input confirmation) → pause the session and wait for the fresh-session review to complete before continuing.
1793
-
1794
- **Standard prompt (when preference is unset):**
1795
-
1796
- Offer review options (3-tier capability model):
1797
-
1798
- ```
1799
- Implementation complete. Final review required.
1800
-
1801
- Review options:
1802
- 1. Run review in this session via a subagent (recommended if provider supported)
1803
- 2. Run review in a fresh session and return to this session to receive review
1804
- 3. Run review inline when current-host controls are verified equivalent
1805
-
1806
- To run in a separate session use: oat-project-review-provide code final
1807
- ```
1808
-
1809
- **After user chooses:**
1810
-
1811
- - If subagent (option 1): Agent spawns the review via Task tool — no command needed from user
1812
- - If fresh session (option 2): User runs `oat-project-review-provide code final` in a separate session, then returns here
1813
- - If inline (option 3): Agent first verifies equivalent current-host controls or an allowed exception, then executes the review per `oat-project-review-provide`; otherwise it uses the exact/pinned route or blocks
1814
- - After review: User runs `oat-project-review-receive` to process findings
1815
- - If Critical/Important findings: Fix tasks added, re-run the `oat-project-implement` skill
1816
- - Loop until final review passes (max 3 cycles per oat-project-review-receive)
1817
-
1818
- **After final review is marked `passed`:**
1819
-
1820
- - Record the passed final review and keep the project in implementation closeout.
1821
- - Do not append `"implement"` to `oat_hill_completed`, set
1822
- `oat_phase_status: complete`, or offer the normal next-step prompt yet.
1823
- - Continue to **Final HiLL Closeout Sequence**.
1824
-
1825
- ### Step 15: Final HiLL Closeout Sequence
1826
-
1827
- The final-closeout orchestrator owns this sequence after the rebased phase
1828
- coordinator has finished. Do not move lifecycle sequencing into task workers or
1829
- weaken exact target selection for child dispatches.
1830
-
1831
- Identify the final implementation phase from the plan. A final HiLL checkpoint
1832
- exists when `oat_plan_hill_phases` is `[]` (every phase) or when it explicitly
1833
- contains that final phase ID. Defer only a checkpoint on the final implementation
1834
- phase; non-final checkpoint behavior remains unchanged.
1835
-
1836
- Run final verification (Step 13). Final review must be `passed` before any
1837
- pre-approval dispatch. If final checkpoint auto-review is enabled, Step 8 has
1838
- already run `oat-project-review-provide code final`; do not run a duplicate
1839
- final review here.
1840
-
1841
- Read the effective `workflow.postImplementSequence` once. For a configured
1842
- legacy or structured preference, normalize legacy values before snapshotting:
1843
- `wait` → `{ preApproval: [], postApproval: [] }`, `summary` →
1844
- `{ preApproval: ["summary"], postApproval: [] }`, `pr` → `{ preApproval:
1845
- ["summary", "pr"], postApproval: [] }`, and `docs-pr` → `{ preApproval:
1846
- ["summary", "document", "pr"], postApproval: [] }`.
1847
-
1848
- Persist this immutable state before dispatching a child:
1849
-
1850
- ```yaml
1851
- oat_post_implement_sequence:
1852
- status: pre_approval # pre_approval | awaiting_approval | post_approval | failed | complete
1853
- final_phase: pNN
1854
- pre_approval: [summary, document, pr]
1855
- pre_approval_completed: []
1856
- approval: pending # pending | approved | not_required
1857
- post_approval: []
1858
- post_approval_completed: []
1859
- failure: null
1860
- ```
1861
-
1862
- The snapshot is immutable for this closeout: never re-resolve
1863
- `workflow.postImplementSequence` while it is incomplete. Iterate
1864
- `pre_approval` and `post_approval` in their stored array order; do not sort or
1865
- substitute a vocabulary order. Resume from the first incomplete stored step,
1866
- including a partially completed noncanonical order.
1867
-
1868
- For every pending `summary`, `document`, or `pr`, dispatch respectively
1869
- `oat-project-summary`, `oat-project-document`, or `oat-project-pr-final`.
1870
- Every `summary`, `document`, and `pr` child receives the authoritative snapshot
1871
- and must merge state updates without replacing `oat_post_implement_sequence`.
1872
- Re-read and verify the snapshot after every child returns before recording step
1873
- success. If a child removed or altered it, restore the authoritative snapshot,
1874
- record that step as failed, and stop with the boundary, failed step, and exact
1875
- resume command: `oat-project-implement`.
1876
-
1877
- Commit each completed step before dispatching the next step. On failure, persist
1878
- `status: failed`, the boundary, the failed step, and concise recovery context.
1879
- A pre-approval failure leaves `approval: pending`; a post-approval failure
1880
- retains `approval: approved`. Fail fast with the boundary, failed step, and
1881
- exact resume command: `oat-project-implement`.
1882
-
1883
- 1. Dispatch incomplete `pre_approval` steps in stored order.
1884
- 2. When they succeed and a final checkpoint exists, commit `status:
1885
- awaiting_approval` with `approval: pending` before asking for final HiLL
1886
- approval.
1887
- 3. Record explicit approval as `approval: approved` and `status: post_approval`
1888
- before any post-approval dispatch. Then dispatch incomplete `post_approval`
1889
- steps in stored order.
1890
- 4. A decline or defer keeps `status: awaiting_approval` and `approval: pending`;
1891
- record neither approval nor failure and run no post-approval step. State the
1892
- boundary and exact resume command: `oat-project-implement`.
1893
- 5. If no final checkpoint exists, commit `approval: not_required` before
1894
- post-approval dispatch. `approval: not_required` is valid only when no final
1895
- checkpoint exists.
1896
- 6. After all stored steps finish, commit `status: complete`. Only then complete
1897
- implementation state, append the configured final HiLL completion, and
1898
- continue to the existing next-step behavior.
1899
-
1900
- If the preference is unset, do not create a sequence snapshot. When the
1901
- preference is unset, retain the existing next-step prompt only after final
1902
- approval when a final checkpoint is configured.
1903
-
1904
- ### Step 16: Prompt for Next Steps
1905
-
1906
- Run the standard next-step prompt only when
1907
- `workflow.postImplementSequence` was unset and no sequence snapshot was
1908
- created. It occurs after final approval when a final checkpoint is configured.
1909
- A configured legacy or structured preference has already completed through
1910
- **Final HiLL Closeout Sequence**; do not re-dispatch its steps here. When the
1911
- completed snapshot came from configured `wait`, print
1912
- `Post-implementation: wait (from workflow.postImplementSequence). Run
1913
- follow-up skills manually when ready.` and exit without auto-chaining.
1914
-
1915
- **Standard prompt (when preference is unset):**
1916
-
1917
- ```
1918
- Final review passed for {project-name}.
1919
-
1920
- All tasks complete and verified. Next steps:
1921
-
1922
- 1. Generate project summary (oat-project-summary)
1923
- 2. Sync documentation (oat-project-document) — if applicable
1924
- 3. Create final PR (oat-project-pr-final)
1925
-
1926
- Options:
1927
- a. Run all three in sequence now
1928
- b. Run summary + PR only (skip docs)
1929
- c. Exit (run individually later)
1930
-
1931
- Choose:
1932
- ```
1933
-
1934
- **If user chooses sequence (a or b):**
1935
-
1936
- 1. Invoke `oat-project-summary` to generate summary.md
1937
- 2. If docs selected: invoke `oat-project-document`
1938
- 3. Invoke `oat-project-pr-final` — this sets `oat_phase_status: pr_open` and guides to revise/complete
1939
-
1940
- Do not route directly to `oat-project-complete`. The `pr_open` status set by pr-final is the proper entry to the revision/completion flow.
1941
-
1942
- **If user chooses exit (c):**
1943
-
1944
- Tell user: "Run the skills individually when ready: oat-project-summary → oat-project-document → oat-project-pr-final"
1945
-
1946
- ### Step 17: Output Summary
1947
-
1948
- ```
1949
- Implementation complete for {project-name}.
1950
-
1951
- Summary:
1952
- - Phases: {N} completed
1953
- - Tasks: {N} completed
1954
- - Commits: {N} created
1955
-
1956
- Final verification:
1957
- - Tests: ✓ passing
1958
- - Lint: ✓ clean
1959
- - Types: ✓ valid
1960
- - Build: ✓ success
1961
-
1962
- Final review:
1963
- - Status: ✓ passed
1964
- - Artifact: reviews/final-review-{timestamp}.md
1965
-
1966
- Next: Create PR or run the oat-project-pr-final skill (when available)
1967
- ```
1968
-
1969
- ### Gate Execution
1970
-
1971
- Before reporting this skill as complete, run the configured gate as the final step:
1972
-
1973
- 1. Resolve the gate for this skill:
1974
-
1975
- ```bash
1976
- oat gate resolve <this-skill> --json
1977
- ```
1978
-
1979
- If the command returns JSON `null`, no gate is configured; the skill is complete.
1980
-
1981
- 2. Export the resolved project path into the command shell:
1982
-
1983
- ```bash
1984
- export PROJECT_PATH
1985
- ```
1986
-
1987
- If the resolved command invokes `oat gate review`, the configured review command must already include `--project "$PROJECT_PATH"` and must not include `--target <id>`. A valid reusable shape is `oat gate review --project "$PROJECT_PATH" ...`. If the declaration is missing, stop and migrate the stored gate command; do not inject or append arguments at execution time.
1988
-
1989
- 3. Execute the resolved command exactly as configured. Capture stdout, stderr, the exit code, and the structured JSON result. A zero exit code means the review passed its threshold, but it does not by itself authorize artifact receipt or complete the handoff.
1990
-
1991
- 4. Review-artifact handoff:
1992
- - Parse the structured gate result. An exit code or artifact path alone never authorizes `oat-project-review-receive`.
1993
- - Invoke receive only when all three conditions hold: `status` is `ok` or `blocked`, the envelope explicitly sets `receiveEligible: true`, and a non-null `handoff` confirms the artifact was corroborated.
1994
- - `receiveEligible: false` is a hard stop even when `artifactPath` is present. Never receive `targeting_correlation_failed`; correct the project/run routing and run a new gate.
1995
- - Keep `artifact_validation_failed` outside receive until the artifact is corrected and the gate successfully revalidates it. Treat `review_failed`, unknown statuses, null handoffs, and contradictory eligibility fields as operational failures.
1996
- - `blocked` exits nonzero but is receive-eligible; `ok` exits zero and still requires durable receive disposition. Route by structured status and eligibility, not by exit code.
1997
-
1998
- 5. If the command exits nonzero, use `description` to orient the next steps and handle `onFailure`:
1999
- - `block`: read gate feedback, remediate, and re-run the gate up to `maxAttempts` attempts (default `2`). If attempts are exhausted, escalate to the human with accumulated feedback and append that feedback to `implementation.md`. Treat a launch failure, missing CLI, or no eligible runtime as escalation-biased and do not spend it as a remediation attempt.
2000
- - `prompt`: surface the gate failure and ask the human how to proceed.
2001
- - `warn`: record the gate failure and continue.
2002
-
2003
- 6. Runtime selection note (V1): the step runs the gate `command` as-is and reads no OAT runtime env var. By default, `oat gate review` and `oat gate cross-provider-exec` resolve the current host from built-in `hostDetectionCommand`s and avoid the same runtime when no exact target is supplied. Reusable lifecycle skill-gate commands must not include `--target <id>` so independent review stays provider-neutral. Use explicit targets only for manual/debug commands or deliberate local/user-specific overrides; do not hardcode provider/model targets in bundled skill guidance or shared lifecycle gate examples.
123
+ ### Route Loading Contract
124
+
125
+ Do not read every implementation reference at skill start. Load exactly one
126
+ route when execution reaches it, complete that route, then return here to select
127
+ the next route. The shared dispatch skill and its one active-provider reference
128
+ remain mandatory before any launch.
129
+
130
+ | When | Read |
131
+ | ---------------------------------------------------------------------------------------- | --------------------------------------- |
132
+ | After resolving the active project; before capability, tier, or dispatch resolution | `references/dispatch-and-dry-run.md` |
133
+ | After dispatch preflight succeeds; before plan validation or resume | `references/plan-and-resume.md` |
134
+ | When the next incomplete phase or parallel group is ready | `references/phase-execution.md` |
135
+ | Only after phase execution completes, or when handling a terminal blocker/final closeout | `references/completion-and-closeout.md` |
136
+
137
+ Rules:
138
+
139
+ - Never preload a later route "for context."
140
+ - Re-enter this router after each route reaches its terminal condition.
141
+ - A phase implementer receives only its Phase Scope and role contract; it does
142
+ not receive these root-workflow references.
143
+ - Optional nested workers receive only their bounded scope and relevant
144
+ repository context.
145
+ - Reviewers receive only the bounded review scope, commit range, allowed files,
146
+ and review artifact contract. They do not read this implementation skill.
147
+ - Preserve every invariant in the routed references; progressive disclosure
148
+ changes loading order, not behavior.
149
+
150
+ ### Execution Order
151
+
152
+ 1. Resolve the active project below.
153
+ 2. Load `references/dispatch-and-dry-run.md`; stop there for a completed dry run.
154
+ 3. Load `references/plan-and-resume.md` and resolve the next execution boundary.
155
+ 4. Load `references/phase-execution.md` once per ready phase/group, returning to
156
+ the plan/resume route until all phases complete.
157
+ 5. Load `references/completion-and-closeout.md` only for blockers, completion,
158
+ final verification/review, approval sequencing, and handoff.
2004
159
 
2005
160
  ## Success Criteria
2006
161
 
2007
- - One exact target-pinned worker executed each task in dependency order
2008
- - The phase coordinator did not implement ordinary task work in its own context
2009
- - Same-worktree task workers ran serially; only plan-declared phase worktrees ran in parallel
162
+ - One exact target-pinned phase implementer directly executed each phase's
163
+ tasks in dependency order
164
+ - Each planned task produced exactly one verified bounded commit
165
+ - Root dispatched exactly one accepted phase reviewer per review round
166
+ - Blocking findings returned to the original phase handle when resumable
167
+ - Optional nested dispatch was absent by default and fully evidenced when used
168
+ - Only plan-declared phase worktrees ran in parallel
2010
169
  - TDD discipline followed
2011
170
  - Each task result and commit was verified against HEAD and its file boundary
2012
171
  - Implementation.md tracks all progress