okstra 0.205.1 → 0.206.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/commands/lifecycle/install.mjs +1 -0
  2. package/dist/commands/lifecycle/install.mjs.map +1 -1
  3. package/docs/architecture.md +6 -6
  4. package/docs/contributor-change-matrix.md +2 -2
  5. package/docs/project-structure-overview.md +8 -5
  6. package/package.json +2 -3
  7. package/runtime/BUILD.json +2 -2
  8. package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
  9. package/runtime/prompts/lead/phase-routing.md +18 -0
  10. package/runtime/python/okstra_ctl/contract_graph.py +75 -10
  11. package/runtime/python/okstra_ctl/doctor.py +13 -3
  12. package/runtime/python/okstra_ctl/implementation_direction.py +9 -8
  13. package/runtime/python/okstra_ctl/next_phase.py +2 -2
  14. package/runtime/python/okstra_ctl/paths.py +14 -0
  15. package/runtime/python/okstra_ctl/phases/__init__.py +4 -0
  16. package/runtime/python/okstra_ctl/phases/catalog.py +216 -0
  17. package/runtime/python/okstra_ctl/phases/final_verification/__init__.py +4 -0
  18. package/runtime/python/okstra_ctl/phases/final_verification/entry.py +166 -0
  19. package/runtime/{prompts/profiles/final-verification.md → python/okstra_ctl/phases/final_verification/profile.md} +4 -4
  20. package/runtime/python/okstra_ctl/{report_html/view_models/final_verification.py → phases/final_verification/report.py} +12 -3
  21. package/{docs/task-process/final-verification.md → runtime/python/okstra_ctl/phases/final_verification/spec.md} +42 -25
  22. package/runtime/python/okstra_ctl/phases/final_verification/target.py +296 -0
  23. package/runtime/python/okstra_ctl/phases/final_verification/validation.py +190 -0
  24. package/runtime/python/okstra_ctl/phases/final_verification/wizard.py +38 -0
  25. package/runtime/python/okstra_ctl/profile_show.py +7 -1
  26. package/runtime/python/okstra_ctl/render_final_report.py +3 -2
  27. package/runtime/python/okstra_ctl/report_assembly.py +3 -3
  28. package/runtime/python/okstra_ctl/report_html/render.py +3 -2
  29. package/runtime/python/okstra_ctl/report_html/router.py +9 -33
  30. package/runtime/python/okstra_ctl/report_template_loader.py +35 -0
  31. package/runtime/python/okstra_ctl/report_views.py +17 -1
  32. package/runtime/python/okstra_ctl/run.py +46 -154
  33. package/runtime/python/okstra_ctl/stage_targets.py +9 -286
  34. package/runtime/python/okstra_ctl/user_response.py +199 -4
  35. package/runtime/python/okstra_ctl/verification_target.py +1 -1
  36. package/runtime/python/okstra_ctl/wizard/state.py +6 -2
  37. package/runtime/python/okstra_ctl/wizard/steps_plan.py +17 -15
  38. package/runtime/skills/okstra-user-response/SKILL.md +23 -4
  39. package/runtime/validators/validate-run.py +22 -185
  40. package/docs/task-process/README.md +0 -82
  41. package/docs/task-process/common-flow.md +0 -173
  42. package/docs/task-process/error-analysis.md +0 -103
  43. package/docs/task-process/implementation-option-selection.md +0 -70
  44. package/docs/task-process/implementation-planning.md +0 -180
  45. package/docs/task-process/implementation.md +0 -226
  46. package/docs/task-process/release-handoff.md +0 -220
  47. package/docs/task-process/requirements-discovery.md +0 -113
  48. /package/runtime/{prompts/profiles/final-verification.json → python/okstra_ctl/phases/final_verification/profile.json} +0 -0
  49. /package/runtime/{templates/reports/html/tasks → python/okstra_ctl/phases/final_verification/report_assets}/final-verification.template.html +0 -0
  50. /package/runtime/{templates/reports/md/tasks → python/okstra_ctl/phases/final_verification/report_assets}/final-verification.template.md +0 -0
@@ -1,173 +0,0 @@
1
- # okstra-run common flow
2
-
3
- ## Index
4
-
5
- - [1. One-line summary](#1-one-line-summary)
6
- - [2. Where the two entrypoints meet](#2-where-the-two-entrypoints-meet)
7
- - [3. wizard input collection flow](#3-wizard-input-collection-flow)
8
- - [4. render-bundle and prepare_task_bundle](#4-render-bundle-and-prepare_task_bundle)
9
- - [5. Okstra lead phase 1-7](#5-okstra-lead-phase-1-7)
10
- - [6. artifact layout](#6-artifact-layout)
11
- - [7. Common branching rules](#7-common-branching-rules)
12
- - [8. Inconsistencies to watch for](#8-inconsistencies-to-watch-for)
13
-
14
- ## 1. One-line summary
15
-
16
- `okstra-run` is not a "skill that decides questions on its own" but a thin loop that relays the `okstra wizard` JSON state machine to the user. Once input collection finishes, it calls `okstra render-bundle`, and that command builds the task bundle through `python3 -m okstra_ctl.run --render-only`. After that, the current Claude Code, Codex, or Antigravity session switches over to the host-native `Okstra lead`.
17
-
18
- ## 2. Where the two entrypoints meet
19
-
20
- ```mermaid
21
- flowchart LR
22
- subgraph InSession["supported host session"]
23
- A[okstra-run skill] --> B[okstra wizard]
24
- B --> C[okstra render-bundle<br/>forces --render-only]
25
- end
26
-
27
- subgraph Terminal["terminal path"]
28
- D[scripts/okstra.sh] --> E[CLI parse / prompt / confirm]
29
- end
30
-
31
- C --> P[prepare_task_bundle()]
32
- E --> P
33
- P --> G[task bundle artifacts]
34
- G --> H{launch mode}
35
- H -->|render-only| I[current host reads lead prompt]
36
- H -->|non-render-only| J[exec claude --session-id ...]
37
- ```
38
-
39
- The common principle is that `prepare_task_bundle()` is the single authority for task bundle creation. Neither the wizard nor the shell wrapper duplicates the path computation, manifest creation, or worktree creation logic.
40
-
41
- ## 3. wizard input collection flow
42
-
43
- ```mermaid
44
- stateDiagram-v2
45
- [*] --> VerifyRuntime: okstra ensure-installed / paths / check-project
46
- VerifyRuntime --> NewState: okstra wizard new-state-file
47
- NewState --> TaskPick: wizard init
48
- TaskPick --> BriefPath: brand-new task
49
- TaskPick --> TaskType: existing task
50
- BriefPath --> TaskGroup: new task, brief accepted
51
- TaskGroup --> TaskId
52
- TaskId --> TaskType
53
- TaskType --> BriefKeep: existing task with existing brief
54
- BriefKeep --> BriefPath: change
55
- BriefKeep --> BaseRef: keep
56
- TaskType --> BaseRef: no active worktree
57
- TaskType --> ImplementationExtras: implementation only
58
- BaseRef --> ImplementationExtras: implementation only
59
- BaseRef --> LeaderSession: non-implementation
60
- ImplementationExtras --> LeaderSession
61
- LeaderSession --> RoleSlots: one model screen per role
62
- RoleSlots --> OptionalInputs: directive / related / clarification
63
- OptionalInputs --> Confirm
64
- Confirm --> EditTarget: Edit
65
- EditTarget --> TaskType: rewind selected step
66
- Confirm --> Done: Proceed
67
- ```
68
-
69
- A new task receives its brief first. If the brief frontmatter has `task-group:` and `brief-id:`, the wizard shows the task group/id as recommended picks. An existing task shows the manifest's `workflow.nextRecommendedPhase.phase` as the recommended task-type, but only while that pointer's `status` is `ready`. Under any other status the recommended slot stays empty and the list falls back to rerunning `workflow.currentPhase` plus the full task-type choices. If an existing brief path exists it asks whether to keep or change it.
70
-
71
- ## 4. render-bundle and prepare_task_bundle
72
-
73
- ```mermaid
74
- sequenceDiagram
75
- participant Skill as okstra-run skill
76
- participant Node as okstra CLI
77
- participant Py as okstra_ctl.run
78
- participant FS as .okstra
79
- participant Home as ~/.okstra
80
-
81
- Skill->>Node: okstra wizard outcome
82
- Node-->>Skill: { renderArgs: ..., persistActions: ... }
83
- opt persistActions present
84
- Skill->>Node: okstra config set ...
85
- end
86
- Skill->>Node: okstra render-bundle --... --render-only
87
- Node->>Py: python3 -m okstra_ctl.run --render-only --...
88
- Py->>Py: validate profile, brief, task-type gates
89
- Py->>Home: reserve/reuse task worktree registry
90
- Py->>FS: write run-context and instruction-set
91
- Py->>FS: write task/run manifests, team-state, timeline, discovery
92
- Py->>Home: record_start status=prepared
93
- Py-->>Node: task root, instruction-set, rendered lead prompt
94
- Node-->>Skill: stdout
95
- Skill->>FS: read lead-execution-prompt.md
96
- ```
97
-
98
- The Node shim for `render-bundle` is [`src/commands/execute/render-bundle.mts`](../../src/commands/execute/render-bundle.mts). This shim attaches the `--workspace-root`, `--render-only`, and runtime resolution arguments directly. As a result, on the okstra-run path the initial run status starts at `prepared` and the task status starts at `ready-for-lead`.
99
-
100
- ## 5. Okstra lead phase 1-7
101
-
102
- ```mermaid
103
- flowchart TD
104
- P1[Phase 1<br/>task bundle intake] --> P2[Phase 2<br/>worker prompt preparation]
105
- P2 --> P3[Phase 3<br/>resolve persisted runners]
106
- P3 -->|native session| P4[Phase 4<br/>host-native dispatch]
107
- P3 -->|CLI wrapper| P5[Phase 4<br/>provider CLI dispatch]
108
- P4 --> C[Phase 5.5<br/>convergence]
109
- P5 --> C
110
- C --> P6[Phase 6<br/>report-writer synthesis]
111
- P6 --> PV{implementation-planning?}
112
- PV -->|yes| PBV[Plan-body verification]
113
- PV -->|no| P7[Phase 7<br/>persist + validate]
114
- PBV --> P7
115
- P7 --> Done[final report + manifests updated]
116
- ```
117
-
118
- The roles of the analysis workers and the report-writer are separated. `report-writer` is not a Phase 4/5 analysis worker but the Phase 6 final report author. Note, however, that `release-handoff` is a single-lead phase, so it deliberately does not follow this phase graph.
119
-
120
- ## 6. artifact layout
121
-
122
- ```mermaid
123
- flowchart TD
124
- Root["<PROJECT_ROOT>/.okstra/tasks/<group>/<task>/"] --> IS[instruction-set/]
125
- Root --> Runs[runs/<task-type>/]
126
- Root --> Hist[history/timeline.json]
127
- IS --> Profile[analysis-profile.md]
128
- IS --> Brief[task-brief.md]
129
- Runs --> Lead["prompts/lead-execution-prompt-*.md"]
130
- Runs --> Man[manifests/run-manifest-*.json]
131
- Runs --> Prompts[prompts/*-worker-prompt-*.md]
132
- Runs --> Results[worker-results/*.md]
133
- Runs --> Reports[reports/final-report-*.md<br/>reports/*.data.json<br/>reports/final-report-*.html]
134
- Runs --> State[state/*.json]
135
- Runs --> Status[status/final-status-*.json]
136
- Runs --> ImplStage[implementation/stage-N/...]
137
- Runs --> FvStage[final-verification/stage-N/...]
138
- Runs --> Carry[implementation/carry/stage-N.json]
139
- Runs --> Consumers[implementation-planning/consumers.jsonl]
140
- Root --> Handoff[release-handoff-input.md]
141
- ```
142
-
143
- `implementation` and single-stage `final-verification` isolate their run deliverables under `stage-<N>/`. The `implementation` carry sidecar and `consumers.jsonl` are cross-stage coordination ledgers, so they remain at the phase root. The runtime reads this ledger and the registry reservations as a Stage Lifecycle Snapshot to compute stage selection and handoff eligibility. `release-handoff` does not receive a brief; prepare generates `release-handoff-input.md`.
144
-
145
- `runtime/` is build output, so when you fix this flow you edit the sources `scripts/`, `skills/`, `agents/`, `prompts/`, `templates/`, `validators/` and refresh with `npm run build`.
146
-
147
- ## 7. Common branching rules
148
-
149
- ```mermaid
150
- flowchart TD
151
- T[task-type selected] --> W{active worktree in registry?}
152
- W -->|yes| Reuse[reuse existing worktree<br/>base-ref prompt skipped]
153
- W -->|no| Base[ask base-ref<br/>validate with git rev-parse]
154
- Base --> M[one screen per static role<br/>checkbox: models checked = instances<br/>single pick: fixed single role]
155
- Reuse --> M
156
- M --> O[directive / related / clarification]
157
- O --> Special{release-handoff?}
158
- Special -->|yes| PR[PR template override/scope]
159
- Special -->|no| Confirm
160
- PR --> Confirm
161
- ```
162
-
163
- Launch selection is role slots and model refs. The wizard does not show a provider roster multi-pick and does not fork on `Use defaults / Customize` for workers. A multi-instance role is one checkbox screen whose checked models become the instances (the wizard renders `--role-count` from that number); on the CLI, omitting `--role-count` keeps each static role at its profile **recommended** count within `min..max`. Duplicate model refs in the same role are rejected. `--workers` remains a CLI compatibility input only.
164
-
165
- Worktree rules differ per phase. From `requirements-discovery` through `implementation-planning`, the task-key worktree is reused. `implementation` uses the task-key worktree as an anchor but does the actual execution isolated one stage at a time in a stage-key (`stage-<N>`) worktree and the `runs/implementation/stage-<N>/` deliverables. `final-verification --stage N` reuses that implementation stage worktree as a read target, and whole-task mode auto-integrates the stage commits into the task-key worktree and then builds the verification target. The Stage Lifecycle Snapshot is a read-side view that does not change this storage structure.
166
-
167
- ## 8. Inconsistencies to watch for
168
-
169
- - The `okstra-run` wizard path passes only if the implementation approved plan already has an approval marker. `scripts/okstra.sh` has `--approve`, which can flip the checkbox with a CLI ack, but the current wizard `render_args()` has no `approve` flag.
170
- - `release-handoff` has no brief. Prepare cites the accepted final-verification report to build `release-handoff-input.md`, and the wizard's `handoff_stage_pick` or the CLI `--stages` fixes the whole-task/stage-group scope.
171
- - `release-handoff` is also a target for task worktree provisioning. A healthy handoff is safest when it reuses the implementation/final-verification results of the same task-key. Starting a new task creates a new worktree, which may be blocked at the profile's "an implementation commit must exist" entry gate.
172
- - `release-handoff` has no `Required workers:` block in its profile. The runtime also forces the worker roster to be empty.
173
- - No task-type starts the next lifecycle phase within a single run. "Proceed to the next step" is interpreted only as wrapping up the current phase's output.
@@ -1,103 +0,0 @@
1
- # error-analysis process
2
-
3
- ## Index
4
-
5
- - [1. Purpose](#1-purpose)
6
- - [2. okstra-run wizard flow](#2-okstra-run-wizard-flow)
7
- - [3. prepare_task_bundle handling](#3-prepare_task_bundle-handling)
8
- - [4. lead execution flow](#4-lead-execution-flow)
9
- - [5. Deliverables and prohibitions](#5-deliverables-and-prohibitions)
10
- - [6. Code reviewed](#6-code-reviewed)
11
-
12
- ## 1. Purpose
13
-
14
- `error-analysis` analyzes a reported error or incident to organize the symptom, trigger, root-cause candidate, reproduction gap, and validation path. It is not the phase that produces the fix itself or an implementation design.
15
-
16
- ## 2. okstra-run wizard flow
17
-
18
- ```mermaid
19
- flowchart TD
20
- Start[/okstra-run/] --> Common[common task identity flow]
21
- Common --> Type[task-type = error-analysis]
22
- Type --> Worktree{active worktree exists?}
23
- Worktree -->|yes| RoleCount[role-count min..max<br/>omit uses recommended; skip if min==max]
24
- Worktree -->|no| BaseRef[base-ref pick/text<br/>main recommended]
25
- BaseRef --> RoleCount
26
- RoleCount --> RoleModel[role-model provider/model per slot]
27
- RoleModel --> RoleAdd[min=0 roles via role-add only<br/>default skip]
28
- RoleAdd --> Extras[directive, related tasks, clarification]
29
- Extras --> Confirm
30
- Confirm --> Render[render-bundle --render-only]
31
- ```
32
-
33
- Launch selection uses role slots and model refs only: current-session lead is this session (listed on the confirmation summary), then each static role's count in `min..max` (default **recommended**; the count step is skipped when `min == max`), then one `provider/model` per slot. Roles with `min = 0` stay closed unless the user opens them with role-add (default skip). Duplicate model refs in the same role are rejected. There is no provider roster multi-pick and no `Use defaults / Customize` fork. Dynamic verifiers are not chosen at launch. `--workers` is a CLI compatibility input only, not a launch picker.
34
-
35
- ## 3. prepare_task_bundle handling
36
-
37
- ```mermaid
38
- sequenceDiagram
39
- participant Skill as okstra-run
40
- participant Wizard as okstra_ctl.wizard
41
- participant Run as prepare_task_bundle
42
- participant WT as worktree/provision.py
43
- participant Art as artifacts
44
-
45
- Skill->>Wizard: task-type error-analysis selected
46
- Wizard-->>Skill: workers/base-ref/model args
47
- Skill->>Run: render-bundle --render-only
48
- Run->>Run: canonical brief preflight
49
- Run->>Run: validate brief/profile
50
- Run->>Run: resolve worker roster
51
- Run->>WT: provision/reuse worktree
52
- Run->>Art: analysis-profile.md includes common contract
53
- Run->>Art: task-manifest workflow next=validated report route
54
- ```
55
-
56
- For canonical briefs, preflight runs before worker resolution, worktree provisioning, or report creation. A brief whose `reporter-confirmations` status is `pending` stops at this point; legacy briefs keep the compatibility path.
57
-
58
- The final report records its next phase in `errorAnalysis.routing.nextTaskType`. A credible cause uses `implementation-option-selection`; continued investigation uses `error-analysis`. When report validation passes, Phase 7 projects `workflow.nextRecommendedPhase` from that one field (`scripts/okstra_ctl/next_phase.py::project`) — a `ready` pointer naming it. A report that leaves the field empty leaves the pointer `pending`; there is no static fallback that supplies a phase the report did not author.
59
-
60
- ## 4. lead execution flow
61
-
62
- ```mermaid
63
- flowchart TD
64
- Intake[Phase 1 intake] --> Prompts[Phase 2 worker prompts]
65
- Prompts --> Team[Phase 3 TeamCreate]
66
- Team --> Dispatch[Phase 4/5 dispatch analysers]
67
- Dispatch --> Evidence[worker outputs<br/>root-cause hypotheses]
68
- Evidence --> Conv[Phase 5.5 convergence<br/>default maxRounds = 2]
69
- Conv --> Report[Phase 6 report-writer final report]
70
- Report --> Persist[Phase 7 persist + validate]
71
- ```
72
-
73
- The workers analyze the symptom and evidence independently. A finding two distinct role executions derived on their own is recorded as full consensus at Round 0 in both modes — independent co-derivation is already cross-verification, so the adversarial burden of proof applies to single-source claims. Evidence-backed counter-evidence classifies a finding `contested` in the round it lands and takes it out of the verification queue; later agreement can neither erase it nor cost another round. The report-writer does not analyze during Phase 4/5 but writes the final report in Phase 6.
74
-
75
- ## 5. Deliverables and prohibitions
76
-
77
- ```mermaid
78
- flowchart LR
79
- Symptom[Symptom] --> Hyp[Root-cause candidates]
80
- Hyp --> Gap[Reproduction gaps]
81
- Gap --> Validate[Validation path]
82
- Validate --> Next[Recommended next diagnostic/planning step]
83
- Hyp -. forbidden .-> Fix[Code fix in this run]
84
- ```
85
-
86
- The expected final-report content is:
87
-
88
- - evidence-backed cause analysis
89
- - uncertainty boundary
90
- - practical next diagnostic steps
91
- - if there is blocking uncertainty, `## 1. Clarification Items`, usually `Blocks=next-phase`
92
-
93
- For `error-analysis`, the structured `errorAnalysis` object is the source of truth for the verbatim symptom, reproduction status, `EA-NNN` cause candidates and their counter-evidence, the next diagnostic, and routing. Its shape is enforced by the final-report schema; `validators/validate-run.py::_validate_error_analysis_consistency` enforces the cross-field values — the routing target, a `leadingCauseId` naming a real cause candidate, the two `direction` fields agreeing with that target, and the single matching `phase-continuation` follow-up row. A route to `implementation-option-selection` needs a credible referenced leading cause and `begin-option-selection`. A route back to `error-analysis` needs the sharp next diagnostic and `continue-investigation`.
94
-
95
- What is prohibited is source edit, refactor, fix attempt, implementation design artifact, and running build/migration/deploy. Deferring ambiguity that could be answered from code or logs to a user question is also a defect per the profile.
96
-
97
- ## 6. Code reviewed
98
-
99
- - [`prompts/profiles/error-analysis.md`](../../prompts/profiles/error-analysis.md)
100
- - [`templates/reports/error-analysis-input.template.md`](../../templates/reports/error-analysis-input.template.md)
101
- - [`scripts/okstra_ctl/workflow.py`](../../scripts/okstra_ctl/workflow.py)
102
- - [`scripts/okstra_ctl/wizard/`](../../scripts/okstra_ctl/wizard/)
103
- - [`prompts/lead/okstra-lead-contract.md`](../../prompts/lead/okstra-lead-contract.md)
@@ -1,70 +0,0 @@
1
- # implementation-option-selection process
2
-
3
- ## Index
4
-
5
- - [1. Purpose](#1-purpose)
6
- - [2. Execution modes](#2-execution-modes)
7
- - [3. Prepare gates](#3-prepare-gates)
8
- - [4. Candidate validation and ranking](#4-candidate-validation-and-ranking)
9
- - [5. Direction confirmation and planning handoff](#5-direction-confirmation-and-planning-handoff)
10
- - [6. Forbidden actions](#6-forbidden-actions)
11
- - [7. Verified code](#7-verified-code)
12
-
13
- ## 1. Purpose
14
-
15
- `implementation-option-selection` is the read-only lifecycle phase between cause analysis and detailed planning. It decides which implementation mechanism and architecture boundary planning may realize. It does not name the exact file list, split stages, or prescribe test commands.
16
-
17
- Direction confirmation and detailed plan approval are independent user decisions. Confirming a direction permits planning to begin. It does not approve the plan or permit implementation.
18
-
19
- ## 2. Execution modes
20
-
21
- | Mode | Input | Output |
22
- |---|---|---|
23
- | `candidate-comparison` | Requirement ledger, cause evidence, code evidence, independently proposed raw candidates | At most three ranked valid directions and a separate user selection |
24
- | `preselected-validation` | A direction already fixed by upstream evidence or an explicit user instruction | One normalized and validated direction, or `blocked`; no alternative is generated |
25
-
26
- The normal analyser roster contains at least three analyser workers plus the report writer. Each analyser may propose at most three raw candidates. All analysers reassess the merged candidate set before ranking.
27
-
28
- ## 3. Prepare gates
29
-
30
- Prepare rejects the phase when the brief has no stable `EB-NNN`, `PB-NNN`, or `EO-NNN` requirement IDs. External Gates are not part of that denominator. Prepare also rejects a roster with fewer than three analysers.
31
-
32
- The phase reuses the task-key worktree and may inspect the code and prior task artifacts. It does not obtain a writable implementation-stage worktree.
33
-
34
- ## 4. Candidate validation and ranking
35
-
36
- Every displayed candidate has all of the following properties:
37
-
38
- - `coveragePercent == 100`
39
- - `scopePrecisionPercent == 100`
40
- - `coverageVerdict == exact`
41
- - no `unmappedCommitments`
42
- - no `contradictedRequirements`
43
- - supporting code or upstream evidence
44
- - at least two feasibility votes
45
- - no safety blocker or unresolved implementation-critical external fact
46
-
47
- The final report can display one, two, or three valid candidates. Rejected candidates remain in `candidateAudit` with their rejection reasons and cannot be selected. If no candidate is valid, the report uses `blocked` and planning cannot start.
48
-
49
- Ranking uses eight fixed criteria with per-run weights: requirement fit, architecture fit, change locality, implementation complexity, correctness risk, reversibility, verification cost, and rollout cost. Safety and exact-coverage failures override the weighted score.
50
-
51
- ## 5. Direction confirmation and planning handoff
52
-
53
- Comparison mode exports a `DIRECTION SELECTION` block in the user-response sidecar. Prepare validates the selected ID against the displayed candidates and binds the response to the report's sibling data JSON through its SHA-256 digest.
54
-
55
- A new planning run receives the selection report through `--selected-direction`. Prepare normalizes the validated choice into `instruction-set/selected-direction.json`. Planning cites that snapshot through `selectedDirectionRef` and writes `approved: false` until the user separately approves the detailed plan.
56
-
57
- If planning proves that the mechanism or architecture boundary cannot satisfy exact coverage, it emits `direction-invalidated` and routes back to `implementation-option-selection`. It never picks the next ranked direction automatically.
58
-
59
- ## 6. Forbidden actions
60
-
61
- This phase does not edit source code, run builds or tests, execute migrations, deploy, or call a write API. Candidate details do not contain exact file lists, stage maps, or test commands. Those details belong to `implementation-planning` after direction confirmation.
62
-
63
- ## 7. Verified code
64
-
65
- - [`prompts/profiles/implementation-option-selection.md`](../../prompts/profiles/implementation-option-selection.md)
66
- - [`prompts/duties/direction-selection-worker.json`](../../prompts/duties/direction-selection-worker.json)
67
- - [`scripts/okstra_ctl/implementation_options.py`](../../scripts/okstra_ctl/implementation_options.py)
68
- - [`scripts/okstra_ctl/implementation_direction.py`](../../scripts/okstra_ctl/implementation_direction.py)
69
- - [`scripts/okstra_ctl/exact_coverage.py`](../../scripts/okstra_ctl/exact_coverage.py)
70
- - [`validators/validate-run.py`](../../validators/validate-run.py)
@@ -1,180 +0,0 @@
1
- # implementation-planning process
2
-
3
- ## Index
4
-
5
- - [1. Purpose](#1-purpose)
6
- - [2. okstra-run wizard flow](#2-okstra-run-wizard-flow)
7
- - [3. prepare_task_bundle handling](#3-prepare_task_bundle-handling)
8
- - [4. lead execution flow](#4-lead-execution-flow)
9
- - [5. design preparation and final report gate](#5-design-preparation-and-final-report-gate)
10
- - [6. Forbidden actions](#6-forbidden-actions)
11
- - [7. Verified code](#7-verified-code)
12
-
13
- ## 1. Purpose
14
-
15
- `implementation-planning` realizes one direction that was already confirmed by `implementation-option-selection`. It turns that mechanism and architecture boundary into a file-level Stage Map, validation checklist, rollback strategy, and exact requirement-coverage map. The resulting detailed plan has its own approval gate; direction confirmation does not approve it.
16
-
17
- An existing plan without `planningContract: selected-direction` remains on the legacy candidate-plan contract for compatibility. A new planning run uses the selected-direction contract and does not generate or rank alternatives.
18
-
19
- ## 2. okstra-run wizard flow
20
-
21
- ```mermaid
22
- flowchart TD
23
- Start[/okstra-run/] --> Common[common task identity flow]
24
- Common --> Type[task-type = implementation-planning]
25
- Type --> Input{new plan or planning rerun?}
26
- Input -->|new| Direction[selected-direction report pick]
27
- Input -->|rerun| Prior[prior planning report via clarification-response]
28
- Direction --> Worktree{active task worktree?}
29
- Prior --> Worktree
30
- Worktree -->|yes| RoleCount[role-count min..max<br/>omit uses recommended]
31
- Worktree -->|no| BaseRef[base-ref pick/text]
32
- BaseRef --> RoleCount
33
- RoleCount --> RoleModel[role-model provider/model per slot]
34
- RoleModel --> Extras[directive, related tasks, clarification]
35
- Extras --> Confirm
36
- Confirm --> Render[render-bundle]
37
- ```
38
-
39
- For a new plan, the wizard asks for a validated option-selection report and passes it as `--selected-direction`. A planning clarification rerun passes its own prior report through `--clarification-response`. Launch selection uses role slots and model refs only: planner count in `min..max` (default recommended), then one `provider/model` per slot. Duplicate model refs in the same role are rejected. There is no provider roster multi-pick. The wizard currently does not ask about `--no-plan-verification`; on the okstra-run path, plan-body verification is prepared as enabled by default.
40
-
41
- ## 3. prepare_task_bundle handling
42
-
43
- ```mermaid
44
- sequenceDiagram
45
- participant W as wizard/render-bundle
46
- participant P as prepare_task_bundle
47
- participant R as render.py
48
- participant M as manifests
49
-
50
- W->>P: task-type=implementation-planning + selected-direction or prior planning report
51
- P->>P: validate profile/brief/base-ref
52
- P->>P: validate selection report, data digest, response, and selected option
53
- P->>M: write instruction-set/selected-direction.json
54
- P->>P: resolve profile workers + optional override
55
- P->>P: resolve model metadata
56
- P->>P: provision/reuse task worktree
57
- P->>R: _build_convergence_block()
58
- R-->>M: convergence.planBodyVerification.enabled=true
59
- P->>M: workflow nextRecommendedPhase inherited, ready lowered to pending
60
- P-->>W: prepared lead prompt
61
- ```
62
-
63
- Prepare rejects a new plan without a selected-direction report. Comparison mode requires a valid `DIRECTION SELECTION` sidecar, while preselected-validation mode uses the confirmed upstream direction without one. The normalized snapshot binds the source report, source-data digest, option ID, direction body, requirements, and invariants.
64
-
65
- The snapshot carries the selected direction, not the rest of that sidecar. The `C-NNN` rows the user answered on the option-selection report reach this run separately: prepare attaches the sidecars beside the selected-direction report as the run's `clarification-response.md`, the same attachment implementation gets from its approved plan.
66
-
67
- Prepare does not name the next phase. It carries the inherited `workflow.nextRecommendedPhase` forward and lowers a `ready` pointer to `pending`, because this run has not finished and a `ready` pointer would read as an invitation to start the following phase. The pointer becomes `ready` at `implementation` when Phase 7 projects an approvable plan (`outcome: plan-ready`, or a candidate-comparison plan with no `outcome`) and no approval blocker remains; `workflow.awaitingApproval` is then true until the user flips `frontmatter.approved`. A blocking plan-body gate or an open `Blocks=approval` row projects `blocked` instead, so inspect and the wizard ask the user to answer those rows rather than start implementation or loop planning.
68
-
69
- ## 4. lead execution flow
70
-
71
- ```mermaid
72
- flowchart TD
73
- P1[Phase 1 intake] --> P2[Phase 2 prompts]
74
- P2 --> P3[Phase 3 TeamCreate]
75
- P3 --> P4[Phase 4/5 analyser dispatch]
76
- P4 --> A[Worker results + Audit sidecar path]
77
- A --> G[Round 0 grouping]
78
- G --> C[Reducer queue + analyser-instance re-verification]
79
- C --> Critic[Optional critic gap reducer transition]
80
- Critic --> RW[Phase 6 report-writer narrative]
81
- RW --> Extract[Deterministic plan-item extraction]
82
- Extract --> PBV[Phase 6 sub-step<br/>Plan-body verifier round]
83
- PBV --> Gate{gate result}
84
- Gate -->|passed / passed-with-dissent| Approval[render plan decision approval control]
85
- Gate -->|blocked-by-disagreement / aborted-non-result| NoApproval[render blocked plan decision]
86
- Approval --> P7[Phase 7 persistence/finalization<br/>canonical Markdown render<br/>HTML render + validate-run<br/>via okstra report-finalize]
87
- NoApproval --> P7
88
- ```
89
-
90
- The artifact sequence is worker results and `Audit sidecar path` → Round 0 grouping → reducer-owned finding queue → analyser-instance re-verification → optional critic transition → report-writer narrative → deterministic plan-item extraction → plan-body verifier round → single report assembly → Phase 7 rendering and validation. Phase 7 calls `okstra report-finalize`; it collects usage into team state, assembles `data.json`, renders Markdown and HTML, materializes follow-ups, and runs `validate-run`. The reducer queues only non-consensus findings; it does not send every complete worker result to every other worker.
91
-
92
- Plan-body verification uses a different queue from Phase 5.5. Phase 5.5 verifies worker findings, and the Phase 6 sub-step re-verifies the consolidated plan body produced by the report-writer at the `P-*` plan-item level. The lead must create that queue through `okstra plan-items extract` and prove it is complete with `okstra plan-items validate` before dispatch.
93
-
94
- ## 5. design preparation and final report gate
95
-
96
- The lead deterministically detects domain contract, persistence schema, external interface, transaction/consistency, transformation mapping, lifecycle state machine, rollout/observability, and manual user test surface from the Stage Map. The report-writer does not ask the user starting from blanks; instead it first writes a concrete AI draft for each surface using known facts and evidence.
97
-
98
- The status of `designPreparation.items[]` does not forcibly pin completeness to a single stage.
99
-
100
- | Status | Meaning | Handling on implementation entry |
101
- |---|---|---|
102
- | `ready` | The implementation contract is sufficiently finalized within the planning snapshot | Proceed with that stage |
103
- | `provisional` | There is a reversible working assumption and guardrail, so it is safe to proceed now | Proceed with that stage, inject the assumption into the executor prompt, and re-confirm at the designated review point |
104
- | `blocked` | There is no safe default and it needs an external authorization, business policy, or destructive-change decision | Only the stage in this item's `stageRefs` waits for input or is replanned |
105
- | `not-applicable` | The surface found by the detector does not require a separate contract in this stage | Record a concrete reason and proceed |
106
-
107
- If there is no detected surface and no manual test input that changes the interface/acceptance, write `mode: no-design-inputs` with a concrete reason. So there is no need to create a formal empty document for a simple task.
108
-
109
- `manual-user-test` does not have to fully fix the execution method at planning time. If there is a safe default procedure even before seeing the actual diff, proceed with `provisional` and `ifStillOpen: follow-up`, and the implementation report finally owns the `implementation.manualUserTest` aligned to the actual change. Conversely, use `blocked` only when the stage cannot be safely completed without an acceptance method that only the user can provide.
110
-
111
- Tier 3 entries keep the following ownership and gate boundary. Planning records
112
- the executable check and prerequisites, but a live external verification stays
113
- with the user when Okstra cannot prove it in-session.
114
-
115
- | Entry policy | PASS | FAIL / MISSING / unavailable |
116
- |---|---|---|
117
- | `requires` contains `db`, `http`, or `external` | Evidence recorded | Advisory; user rerun method recorded; run continues |
118
- | `requires=[]` or `requires=[io]` | Evidence recorded | Blocking |
119
-
120
- These outcomes are enforced by
121
- `scripts/okstra_ctl/conformance.py::decide_conformance_gate` and
122
- `validators/validate-run.py::_validate_conformance`.
123
-
124
- Phase 7 deterministically creates a `design-prep-requests/` document filled with an AI proposal for each `provisional`/`blocked` item. When the user or wizard approves, edits, rejects, or holds the draft, only after confirmation does it append a new revision sidecar under `design-prep-inputs/`. This response does not modify the approved planning report.
125
-
126
- Plan approval and design-preparation status are independent gates. If plan-body verification passed, the plan itself can be approved even when there is a `blocked` item. The actual `implementation` preflight resolves only the items of the selected stage, and unrelated stages keep proceeding.
127
-
128
- ```mermaid
129
- flowchart LR
130
- Direction[Selected Direction Snapshot] --> Realize[Direction Realization]
131
- Realize --> Stages[Stage Map + Stage Exit/Validation]
132
- Stages --> Prep[Implementation Design Preparation]
133
- Prep --> Dep[Dependency / Migration Risk]
134
- Dep --> Val[Validation Checklist]
135
- Val --> Rb[Rollback Strategy]
136
- Rb --> Verify[Plan Body Verification]
137
- Verify --> Approval[YAML frontmatter approval]
138
- Approval --> Impl[Next run: implementation]
139
- ```
140
-
141
- The selected-direction branch verifies `P-Dir-1` before its stage, dependency, validation, rollback, requirement, preparation, and variation items. `P-Dir-1` proves that the plan preserves the selected mechanism, architecture boundary, invariants, and user constraints. The legacy branch continues to extract `P-Opt-*` from its option candidates.
142
-
143
- The detailed selected-direction plan retains these deliverable surfaces:
144
-
145
- - `Stage Map`
146
- - `Stage Exit Contract`
147
- - `Stage Validation`
148
- - `Dependency`
149
- - `Cross-Project Dependencies`
150
- - `Decision Drafts`
151
- - `Validation Checklist`
152
- - `Rollback`
153
- - `Requirement Coverage`
154
- - `Implementation Design Preparation`
155
-
156
- Approval is recorded as `frontmatter.approved: true` on the report record (`--approve` or the in-session wizard). A selected-direction plan has no `implementationOption` field and rejects `--implementation-option` before any approval-file mutation. If a `Blocks=approval` clarification row is unresolved, implementation prepare rejects the plan even when the record is approved. Existing candidate plans keep their legacy option field and execution behavior.
157
-
158
- `plan-ready` requires 100% requirement coverage, 100% scope precision, and no unmapped stage or file change. If the selected mechanism or boundary cannot meet those conditions, planning emits `direction-invalidated` without an executable Stage Map and routes back to `implementation-option-selection`. It does not choose another direction automatically.
159
-
160
- ## 6. Forbidden actions
161
-
162
- ```mermaid
163
- flowchart TD
164
- Plan[planning output] --> OK[reports/prompts/state/manifests only]
165
- Plan -. forbidden .-> Code[source code edit]
166
- Plan -. forbidden .-> Build[build/test/migration/deploy execution]
167
- Plan -. forbidden .-> ExternalDocs[docs/superpowers plans/specs write]
168
- Plan -. forbidden .-> NextPhase[start implementation in same run]
169
- ```
170
-
171
- This phase only produces the plan document. Code-level micro-optimization, source edit, build, migration, deployment, and any write outside the run artifact directory are forbidden.
172
-
173
- ## 7. Verified code
174
-
175
- - [`prompts/profiles/implementation-planning.md`](../../prompts/profiles/implementation-planning.md)
176
- - [`templates/reports/implementation-planning-input.template.md`](../../templates/reports/implementation-planning-input.template.md)
177
- - [`templates/reports/final-report-v2.template.md`](../../templates/reports/final-report-v2.template.md)
178
- - [`scripts/okstra_ctl/render.py`](../../scripts/okstra_ctl/render.py)
179
- - [`validators/validate-run.py`](../../validators/validate-run.py)
180
- - [`prompts/lead/okstra-lead-contract.md`](../../prompts/lead/okstra-lead-contract.md)