owflow 0.5.0 → 0.6.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.
@@ -1,54 +1,62 @@
1
1
  ---
2
2
  name: owflow:performance
3
- description: Orchestrates performance optimization workflows using static code analysis to identify bottlenecks (N+1 queries, missing indexes, O(n^2) algorithms, blocking I/O, memory leaks). Accepts optional user-provided profiling data. Reuses standard specification, planning, implementation, and verification phases.
4
- argument-hint: "[task description]"
3
+ description: Performance workflow dispatcher. Initializes/resumes performance tasks, derives the next step from state, and hands off to the matching /owflow:performance-* subskill. Static-analysis-first bottleneck identification (N+1 queries, missing indexes, O(n^2) algorithms, blocking I/O, memory leaks) with optional user-provided profiling data.
4
+ argument-hint: "[task description | task-path] [--from=<step-slug>]"
5
5
  user-invocable: true
6
6
  ---
7
7
 
8
- # Performance Orchestrator
8
+ # Performance Dispatcher
9
9
 
10
- Static-analysis-first performance optimization workflow. Identifies bottlenecks by reading code, then uses the standard specification/planning/implementation/verification pipeline to fix them.
10
+ Entry point for performance tasks in **assisted mode**: initialize (or resume) the task, derive the next pending step from `orchestrator-state.yml`, print the matching subskill command, and STOP. Each `/owflow:performance-*` subskill runs its steps with fresh context — the explicit invocation IS the step gate. The dispatcher owns only initialization (task directory, state, six task items) and the drop-only resume trim; every task artifact is produced by the subskills (see [Task Structure](#task-structure)).
11
11
 
12
- Gates follow the shared contract in [Gate Contract](../orchestrator-framework/references/gate-contract.md).
12
+ Performance state uses descriptive step slugs in `completed_phases` / `failed_phases` / `auto_fix_attempts`: `codebase-analysed`, `bottlenecks-identified`, `spec-written`, `spec-audited` (conditional), `plan-created`, `implementation-done`, `options-chosen`, `verification-done`, `task-completed`. The routing table below maps slugs to subskills.
13
+
14
+ For the all-in-one loop with in-session `question` gates, use `/owflow:goal-performance`.
15
+
16
+ Gates follow the shared contract in the [Gate Contract](../orchestrator-framework/references/gate-contract.md), with the [dispatcher exception](../orchestrator-framework/references/gate-contract.md#exceptions).
13
17
 
14
18
  ## Entry Gate
15
19
 
16
- **BEFORE executing any phase, you MUST complete these steps:**
20
+ **BEFORE deriving the handoff, complete these steps:**
21
+
22
+ ### Step 1: Load Framework Patterns
23
+
24
+ **Read the framework reference files NOW using the Read tool:**
17
25
 
18
- ### Argument resolution
26
+ 1. The [Dispatcher & Handoff Pattern](../orchestrator-framework/references/dispatcher-handoff.md) governs this skill.
27
+ 2. The [Delegation Rules](../orchestrator-framework/references/delegation-rules.md) bound what subskills delegate.
28
+ 3. The [Orchestrator Patterns](../orchestrator-framework/references/orchestrator-patterns.md) define state schema, initialization, and context passing.
19
29
 
20
- - **Performance issue description provided** → use it as the task description.
21
- - **Task path / identifier** (directory under `.owflow/tasks/performance/`) → resume mode: read `orchestrator-state.yml`, find the first incomplete phase (`--from=PHASE` overrides), validate existing artifacts, then continue from there.
22
- - **Nothing provided** → ask via `question`: "What is slow or performance-constrained? Describe the symptom (endpoint, page, job), expected vs actual behavior, and any profiling data you have." — collect the description, plus optional profiling data paths, before proceeding.
30
+ ### Step 2: Resolve the Argument
23
31
 
24
- ### Prerequisites
32
+ **If the argument is a task path or identifier** (a directory, or a directory name under `.owflow/tasks/performance/`) → **resume mode**:
25
33
 
26
- | Required for this skill | Where verified | Produced by |
27
- | ----------------------- | ----------------------------------------------------- | ---------------------------- |
28
- | State file exists | `<task-path>/orchestrator-state.yml` (resume mode) | prior `/owflow:performance` run |
34
+ 1. Read `orchestrator-state.yml`.
35
+ 2. **Resume validation (drop-only)** — before `completed_phases` is trusted, validate every entry against the two-kind resume table below; an entry whose marker is missing is DROPPED. The path never repairs or re-keys state.
36
+ 3. Derive the next handoff with the Routing Table below.
37
+ 4. `--from=<step-slug>` overrides the derived step — validate the target's upstream conditions exist (per the routing table and the target subskill's Entry Gate), else use `question` to confirm or cancel. An unknown slug → print the 9 accepted slugs and STOP.
38
+ 5. Missing state file → print: `No performance task found at <path>. Run /owflow:performance <description> to start a task from scratch.` and STOP.
29
39
 
30
- On resume, if the state file is missing → print: `No performance task found at <path>. Run /owflow:performance <description> to start from scratch.` and STOP. Validate expected artifacts for completed phases (remove entries with missing artifacts).
40
+ **If the argument is a performance issue description** (any other free text) → new task.
31
41
 
32
- ### Execution steps
42
+ **If nothing is provided** → ask via `question`: "What is slow or performance-constrained? Describe the symptom (endpoint, page, job), expected vs actual behavior, and any profiling data you have." — collect the description, plus optional profiling data paths, then WAIT. Never guess or auto-pick a task.
33
43
 
34
- 1. **Load framework patterns** — Read `../orchestrator-framework/references/orchestrator-patterns.md` NOW: delegation rules, interactive mode, state schema, initialization, context passing, issue resolution.
35
- 2. **Initialize workflow:**
36
- 1. **Create Task Items**: Use `TaskCreate` for all phases (see Phase Configuration), then set dependencies with `TaskUpdate addBlockedBy`
37
- 2. **Create Task Directory**: `.owflow/tasks/performance/YYYY-MM-DD-task-name/`
38
- 3. **Create Subdirectories**: `analysis/`, `analysis/user-profiling-data/`, `implementation/`, `verification/`
39
- 4. **Initialize State**: Create `orchestrator-state.yml` with performance context
40
- - **CRITICAL**: Use the `verify_template` tool immediately after creation to check YAML validity against `orchestrator-state-performance.yml`.
41
- 5. **Discover project documentation**: Read `.owflow/docs/INDEX.md` (if exists), extract ALL file paths from the "Project Documentation" section — includes predefined docs AND any user-added project docs. Store as `project_context.project_doc_paths` in state.
44
+ ### Step 3: Initialize (new task)
45
+
46
+ 1. **Create Task Directory**: `.owflow/tasks/performance/YYYY-MM-DD-task-name/` (3-5 kebab-case words from the description)
47
+ 2. **Create Subdirectories**: `analysis/`, `analysis/user-profiling-data/`, `implementation/`, `verification/`
48
+ 3. **Initialize State**: create `orchestrator-state.yml` from the performance template — `task.title` / `task.description` from the description, `task.status: in_progress`, `orchestrator.task_path`, `orchestrator.entry_point: "performance"` (template/bootstrap mechanic). Discover project documentation: read `.owflow/docs/INDEX.md` (if exists), extract ALL file paths from the "Project Documentation" section, and store them as `performance_context.project_doc_paths` in state.
49
+ - **CRITICAL**: use the `verify_template` tool immediately after creation to check YAML validity against `orchestrator-state-performance.yml`.
50
+ 4. **Create Task Items**: use `TaskCreate` for the six subskill handoffs (one item each, per the Task Configuration table), then set the execution order with `TaskUpdate addBlockedBy` (analyze → spec → plan → implement → verify → finalize). Record every created item's id in `orchestrator.task_ids` — the `goal-performance` wrapper updates these same ids at each hop instead of creating its own. On resume, refresh the already-evidenced items instead of re-creating them.
42
51
 
43
52
  **Output**:
44
53
 
45
54
  ```
46
- Performance Orchestrator Started
55
+ 🚀 Performance Dispatcher
47
56
 
48
57
  Task: [performance issue description]
49
58
  Directory: [task-path]
50
-
51
- Starting Phase 1: Codebase Analysis...
59
+ Next step: [step name]
52
60
  ```
53
61
 
54
62
  ---
@@ -72,358 +80,178 @@ Use for:
72
80
 
73
81
  1. **Static Analysis First**: Read code to detect patterns. Don't try to run profiling tools.
74
82
  2. **User Data Welcome**: Incorporate user-provided profiling data when available
75
- 3. **Reuse Standard Phases**: Use proven specification/planning/implementation/verification pipeline
83
+ 3. **Subskill Pipeline**: The optimization pipeline is the six `/owflow:performance-*` subskills — analyze → spec → plan → implement → verify → finalize — not inline phases; this dispatcher only routes.
76
84
  4. **Conservative Estimates**: Provide improvement ranges, not false precision
77
85
  5. **Practical Optimizations**: Focus on patterns the agent CAN detect and fix
78
86
 
79
87
  ---
80
88
 
81
- ## Phase Configuration
82
-
83
- | Phase | content | activeForm | Agent/Skill |
84
- | ----- | -------------------------------------------- | ------------------------------------------------- | ---------------------------- |
85
- | 1 | "Analyze codebase" | "Analyzing codebase" | codebase-analyzer |
86
- | 2 | "Analyze performance bottlenecks" | "Analyzing performance bottlenecks" | bottleneck-analyzer |
87
- | 3 | "Gather requirements & create specification" | "Gathering requirements & creating specification" | specification-creator |
88
- | 4 | "Audit specification" | "Auditing specification" | spec-auditor (conditional) |
89
- | 5 | "Plan implementation" | "Planning implementation" | implementation-planner |
90
- | 6 | "Execute implementation" | "Executing implementation" | implementation-plan-executor |
91
- | 7 | "Prompt verification options" | "Prompting verification options" | Direct |
92
- | 8 | "Verify implementation & resolve issues" | "Verifying implementation" | implementation-verifier |
93
- | 9 | "Finalize workflow" | "Finalizing workflow" | Direct |
94
-
95
- ---
96
-
97
- ## Workflow Phases
98
-
99
- ### Phase 1: Codebase Analysis & Clarifications
100
-
101
- **Purpose**: Comprehensive codebase exploration for performance context, followed by scope/requirements clarification
102
- **Execute**:
103
-
104
- 1. Skill tool - `codebase-analyzer`
105
- 2. Update state with analysis results
106
- 3. Direct - use question for max 5 critical clarifying questions about performance concerns, hotspots, and optimization goals
107
- 4. Save clarifications to `analysis/clarifications.md`
108
- **Output**: `analysis/codebase-analysis.md`, `analysis/clarifications.md`
109
- **State**: Update `performance_context.phase_summaries.codebase_analysis`, `task_context.clarifications_resolved`
110
-
111
- Pass `task_type="enhancement"` and the performance-focused description. The codebase-analyzer adaptively selects parallel Explore agents based on task complexity. For performance tasks, the description should guide agents toward: database query patterns, hot code paths, I/O operations, caching layers, connection management, schema/migration files.
112
-
113
- → **AUTO-CONTINUE** — Do NOT end turn, do NOT prompt user. Proceed immediately to Phase 2.
114
-
115
- ---
116
-
117
- ### Phase 2: Static Performance Analysis
118
-
119
- **Purpose**: Identify bottlenecks through static code analysis + optional user profiling data
120
- **Execute**: Task tool - `bottleneck-analyzer` subagent
121
- **Output**: `analysis/performance-analysis.md`
122
- **State**: Update `performance_context.bottlenecks_identified`, `performance_context.user_data_available`, `performance_context.bottleneck_priorities`
123
-
124
- **Process**:
125
-
126
- 1. Check if `analysis/user-profiling-data/` contains any files
127
- 2. If empty, use question:
128
- - Question: "Do you have profiling data to provide (flame graphs, APM screenshots, slow query logs)?"
129
- - Options: "Yes, let me add files to analysis/user-profiling-data/" | "No, proceed with static analysis only"
130
- 3. If user chooses to add files, wait for them, then proceed
131
-
132
- **ANTI-PATTERN — DO NOT DO THIS:**
133
-
134
- - ❌ "Let me analyze the bottlenecks myself..." — STOP. Delegate to bottleneck-analyzer.
135
- - ❌ "I'll grep for N+1 patterns..." — STOP. Delegate to bottleneck-analyzer.
136
-
137
- **INVOKE NOW** — Task tool call:
138
-
139
- 4. Task tool - `bottleneck-analyzer` subagent
140
-
141
- **Context to pass**: task_path, description, codebase analysis summary from Phase 1, user data paths (if any)
142
-
143
- **SELF-CHECK**: Did you just invoke the Task tool with `bottleneck-analyzer`? Or did you start analyzing code yourself? If the latter, STOP and invoke the Task tool.
144
-
145
- → Pause
146
-
147
- question - "Performance analysis complete. [N] bottlenecks identified ([P0 count] P0, [P1 count] P1). Continue to specification?"
148
-
149
- ---
150
-
151
- ### Phase 3: Requirements & Specification
152
-
153
- > **Phase gate**: Requires `question` confirmation from Phase 2 before executing.
154
-
155
- **Purpose**: Gather optimization requirements and create specification
156
- **Output**: `analysis/requirements.md`, `implementation/spec.md`
157
- **State**: Update `performance_context.phase_summaries.specification`
158
-
159
- **Part A — Requirements Gathering (inline)**:
160
-
161
- 1. Present bottleneck summary from Phase 2 to user
162
- 2. Use question for optimization priorities:
163
- - Which bottleneck priorities to address? (All P0+P1, P0 only, specific ones)
164
- - Any constraints? (backward compatibility, memory limits, no new dependencies)
165
- - Performance targets? (specific response time goals, if known)
166
- 3. Save gathered requirements to `analysis/requirements.md` with: performance issue description, bottleneck analysis summary, optimization priorities, constraints, targets
167
-
168
- **Part B — Specification Creation (subagent)**:
169
-
170
- 📋 **Standards Discovery**: Read `.owflow/docs/INDEX.md` before creating spec.
171
-
172
- **ANTI-PATTERN — DO NOT DO THIS:**
173
-
174
- - ❌ "Let me create the specification..." — STOP. Delegate to specification-creator.
175
- - ❌ "I'll write the spec based on the analysis..." — STOP. Delegate to specification-creator.
176
-
177
- **INVOKE NOW** — Task tool call:
178
-
179
- 4. Task tool - `specification-creator` subagent
180
-
181
- **Context to pass**: task_path, task_type="performance", task_description, requirements_path (analysis/requirements.md), project_context_paths (INDEX.md + project_doc_paths from state — all discovered project docs), phase_summaries (codebase_analysis, bottleneck_analysis)
182
-
183
- **SELF-CHECK**: Did you just invoke the Task tool with `specification-creator`? Or did you start writing spec.md yourself? If the latter, STOP and invoke the Task tool.
184
-
185
- **Part C — Diagram Refinement (Skill, content-preserving)**:
186
-
187
- 5. Invoke Skill tool: `diagrams-mermaid` to refine `implementation/spec.md`
188
- 6. Add diagrams that clarify bottleneck flows and optimization boundaries without replacing specification text.
189
- 7. If context for a diagram is missing, document gaps and avoid speculative dependencies.
190
-
191
- → Pause
192
-
193
- question - Display executive summary before asking. Read `implementation/spec.md` and extract: optimization targets, approach chosen, number of changes planned, expected impact. Format as brief overview then "Continue to specification audit?"
194
-
195
- ---
196
-
197
- ### Phase 4: Specification Audit (Conditional)
198
-
199
- > **Phase gate**: Requires `question` confirmation from Phase 3 before executing.
200
-
201
- **Purpose**: Independent review of optimization specification
202
- **Execute**: Task tool - `spec-auditor` subagent
203
- **Output**: `verification/spec-audit.md`
204
- **State**: Update `options.spec_audit_enabled`
205
-
206
- **Run if**: >5 optimizations planned, spec >50 lines, or user requests
207
- **Skip if**: Simple optimization (1-3 changes)
208
-
209
- question to decide - "Run specification audit?"
210
-
211
- → Pause
212
-
213
- question - Display executive summary before asking. Read `verification/spec-audit.md` and extract: overall verdict, issue counts by severity, top findings. Format as brief overview then "Continue to implementation planning?"
214
-
215
- ---
216
-
217
- ### Phase 5: Implementation Planning
218
-
219
- > **Phase gate**: Requires `question` confirmation from Phase 4 before executing.
220
-
221
- **Purpose**: Break optimization specification into implementation steps
222
-
223
- 📋 **Standards Discovery**: Read `.owflow/docs/INDEX.md` before planning.
224
-
225
- **ANTI-PATTERN — DO NOT DO THIS:**
226
-
227
- - ❌ "Let me create the implementation plan..." — STOP. Delegate to implementation-planner.
228
- - ❌ "I'll break this into optimization steps..." — STOP. Delegate to implementation-planner.
229
-
230
- **INVOKE NOW** — Task tool call:
231
-
232
- **Execute**: Task tool - `implementation-planner` subagent
233
- **Output**: `implementation/implementation-plan.md`
234
- **State**: Update task groups and dependencies
235
-
236
- **Context to pass**: task_path, task_type="performance", task_description, phase_summaries (specification, bottleneck_analysis, codebase_analysis)
237
-
238
- **SELF-CHECK**: Did you just invoke the Task tool with `implementation-planner`? Or did you start writing the plan yourself? If the latter, STOP and invoke the Task tool.
89
+ ## Task Configuration
239
90
 
240
- **Post-plan diagram refinement (Skill, content-preserving)**:
91
+ One task item per subskill handoff (`TaskCreate` at init; ordered with `addBlockedBy`):
241
92
 
242
- - Invoke Skill tool: `diagrams-mermaid` for `implementation/implementation-plan.md`
243
- - Add one compact optimization execution flow (task-group dependency or state flow).
244
- - Keep plan steps authoritative; diagrams are explanatory additions only.
245
-
246
- → Pause
247
-
248
- question - Display executive summary before asking. Read `implementation/implementation-plan.md` and extract: number of task groups, total steps, key dependencies, optimization sequence. Format as brief overview then "Continue to implementation?"
93
+ | Subskill | Slugs owned (frozen) | Task item content | Engine(s) |
94
+ | --- | --- | --- | --- |
95
+ | `performance-analyze` | `codebase-analysed`, `bottlenecks-identified` | "Analyze codebase & bottlenecks" | Skill `codebase-analyzer`; Task `bottleneck-analyzer` |
96
+ | `performance-spec` | `spec-written`, `spec-audited` (conditional) | "Gather requirements & create specification" | Task `specification-creator`; Task `spec-auditor`; Skill `diagrams-mermaid` |
97
+ | `performance-plan` | `plan-created` | "Plan implementation" | Task `implementation-planner`; Skill `diagrams-mermaid` |
98
+ | `performance-implement` | `implementation-done` | "Execute implementation" | Skill `implementation-plan-executor` |
99
+ | `performance-verify` | `options-chosen`, `verification-done` | "Verify implementation & resolve issues" | Skill `implementation-verifier` |
100
+ | `performance-finalize` | `task-completed` | "Finalize workflow" | Direct (inline-legal) |
249
101
 
250
102
  ---
251
103
 
252
- ### Phase 6: Implementation
253
-
254
- > **Phase gate**: Requires `question` confirmation from Phase 5 before executing.
255
-
256
- **Purpose**: Execute the optimization plan
257
-
258
- 📋 **Standards Discovery**: Implementation reads `.owflow/docs/INDEX.md` continuously.
259
-
260
- **ANTI-PATTERN — DO NOT DO THIS:**
261
-
262
- - ❌ "Let me implement this directly..." — STOP. Delegate to implementation-plan-executor.
263
- - ❌ "This is simple enough to code inline..." — STOP. Simplicity is NOT a reason to skip delegation.
264
-
265
- **INVOKE NOW** — Skill tool call:
266
-
267
- **Execute**: Skill tool - `implementation-plan-executor`
268
- **Output**: Implemented optimizations, `implementation/work-log.md`
269
- **State**: Update implementation progress, extract phase_summaries.implementation
270
-
271
- **SELF-CHECK**: Did you just invoke the Skill tool with `implementation-plan-executor`? Or did you start writing code yourself? If the latter, STOP immediately and invoke the Skill tool instead.
272
-
273
- **⚠️ POST-IMPLEMENTATION CONTINUATION** — After the skill completes and returns control:
274
-
275
- 1. Read `orchestrator-state.yml` to confirm you are the orchestrator
276
- 2. Update state: add Phase 6 to `completed_phases`
277
- 3. Proceed to Phase 7
278
-
279
- → Pause
280
-
281
- question - Display executive summary before asking. Extract from `phase_summaries.implementation` and `implementation/work-log.md`: optimizations applied, files changed, test results, any known issues. Format as brief overview then "Continue to verification?"
104
+ ## Routing Table (completed_phases → next subskill)
105
+
106
+ Every row is evaluated in order; the first matching row wins. **Every condition includes the absence of its own slug(s)** (the absence clause), the evaluation order is **total** (a fallback row closes it), and **the first-missing-slug heuristic is retired** for this table — see the routing rules below.
107
+
108
+ | # | Subskill (slugs owned) | Routes here when | Handoff command |
109
+ | --- | --- | --- | --- |
110
+ | 1 | `performance-analyze` (`codebase-analysed`, `bottlenecks-identified`) | new task, OR `codebase-analysed` absent, OR (`codebase-analysed` present AND `bottlenecks-identified` absent) | `/owflow:performance-analyze <task-path>` |
111
+ | 2 | `performance-spec` (`spec-written`, `spec-audited`) | `bottlenecks-identified` complete AND [ (`spec-written` absent) OR (`spec-audited` absent AND (`options.spec_audit_enabled` is **null OR `true`**)) ] | `/owflow:performance-spec <task-path>` |
112
+ | 3 | **`performance-plan`** (`plan-created`) | **`spec-written` complete AND `options.spec_audit_enabled` is non-null — the audit decision is settled — AND `plan-created` absent.** Never `spec-audited`. | `/owflow:performance-plan <task-path>` |
113
+ | 4 | `performance-implement` (`implementation-done`) | `plan-created` complete AND `implementation-done` absent | `/owflow:performance-implement <task-path>` |
114
+ | 5 | `performance-verify` (`options-chosen`, `verification-done`) | `implementation-done` complete AND [ `options-chosen` absent OR `verification-done` absent ] | `/owflow:performance-verify <task-path>` |
115
+ | 6 | `performance-finalize` (`task-completed`) | `verification-done` complete AND `task-completed` absent | `/owflow:performance-finalize <task-path>` |
116
+ | T | terminal | `task-completed` complete (validated by `task.status: completed`) → **no handoff**; report the task as done | — |
117
+ | F | **fallback** | **no row above matched** (anomalous state — e.g. `SW ∧ SA ∧ spec_audit_enabled: null`, or slugs present out of order after a hand-edited state). Report the state that failed to route, then route to `/owflow:performance-analyze <task-path>` | `/owflow:performance-analyze <task-path>` |
118
+
119
+ **Routing rules, normative.** These four sentences ship verbatim in the dispatcher; they are the guard's defense against its own simplification:
120
+
121
+ 1. **Absence clause** — each row that *advances* the pipeline requires its own slugs to be absent from `completed_phases` (rows 1, 2, 3, 4, 6; row 5 is a re-entry row and requires only the sub-step it owns to be outstanding). No row ever fires on the strength of its own slug already being present.
122
+ 2. **Row 2 re-enters `performance-spec` while the audit decision is undecided** (`spec_audit_enabled` null) *and* when it is decided-yes with no `spec-audited` slug; `performance-spec`'s own skip/resume rule settles it — re-ask only while the decision is `null`, never once it is non-null.
123
+ 3. **Row 3 requires a settled decision** (`spec_audit_enabled` non-null), never the `spec-audited` slug. Audit-skipped therefore falls through to row 3 instead of looping.
124
+ 4. **The first-missing-slug heuristic used by both shipped dispatchers is retired for this table** (`development/SKILL.md:87`, `research/SKILL.md:100`) and must not be reintroduced — the conditional audit makes row 2 a three-way disjunction. Any edit that collapses rows 2–3 back to a single "first missing slug" rule reintroduces the audit-skip resume loop.
125
+
126
+ **Why the fallback exists, stated honestly.** Its purpose is **totality**: a total routing function never leaves the user without a command. Its destination is row 1's destination, and that destination is **not** guaranteed to block — row 1 can only fail when `codebase-analysed` ∧ `bottlenecks-identified` are both recorded, which means both analyze marker artifacts exist, so `performance-analyze`'s Entry Gate would *pass*. F therefore guarantees a defined, reported destination; it does not itself guarantee that a prerequisite check will stop the flow. The states F actually catches are the unreachable-by-design ones (`spec-written` ∧ `spec-audited` with the decision `null`) and hand-edited states — in both cases re-running analyze is the safe, reversible move.
127
+
128
+ Every reachable state routes to exactly one handoff:
129
+
130
+ | Reachable state | Matching row | Handoff |
131
+ | --- | --- | --- |
132
+ | new task, or analyze step 1 done (`codebase-analysed` absent) | 1 | `performance-analyze` |
133
+ | analyze done, `bottlenecks-identified` absent | 1 | `performance-analyze` |
134
+ | **spec step 1 done, audit decision still `null`** | **2** | **`performance-spec` (asks the audit decision)** |
135
+ | audit decided `true`, `spec-audited` absent | 2 | `performance-spec` (audit sub-step) |
136
+ | audit ran (`spec-audited` present, decision `true`) | 3 | `performance-plan` |
137
+ | audit skipped (decision `false`, no `spec-audited`) | 3 | `performance-plan` |
138
+ | `plan-created` present, `implementation-done` absent | 4 | `performance-implement` |
139
+ | `implementation-done` present, `options-chosen` absent | 5 | `performance-verify` (asks options) |
140
+ | `options-chosen` present, `verification-done` absent | 5 | `performance-verify` (idempotence rule) |
141
+ | `verification-done` present, `task-completed` absent | 6 | `performance-finalize` |
142
+ | all 9 slugs, `task.status: completed` | T | none — done |
143
+ | anomalous (unreachable-by-design, e.g. `SW ∧ SA` with decision `null`; or slugs out of order) | F | `performance-analyze`, with the failing state reported |
144
+
145
+ Row 2's two-part condition is what makes the audit a first-class routable outcome in **all three** directions: `null` → stays in `performance-spec` to settle the decision; `true` + `spec-audited` missing → routes into the audit sub-step; `false`, or `true` + `spec-audited` present → falls through to row 3.
146
+
147
+ ### Resume Validation — the two-kind table
148
+
149
+ Applied on every resume, before `completed_phases` is trusted (`gate-contract.md:28`). An entry whose marker is missing is dropped; artifacts beat state.
150
+
151
+ | Slug | Validated against | Kind |
152
+ | --- | --- | --- |
153
+ | `codebase-analysed` | `analysis/codebase-analysis.md` | file |
154
+ | `bottlenecks-identified` | `analysis/performance-analysis.md` | file |
155
+ | `spec-written` | `implementation/spec.md` | file |
156
+ | `spec-audited` | `verification/spec-audit.md` | file (conditional) |
157
+ | `plan-created` | `implementation/implementation-plan.md` | file |
158
+ | `implementation-done` | `implementation/work-log.md` | file |
159
+ | `options-chosen` | at least one non-null `orchestrator.options.*` review flag | **state predicate — vacuous, see note** |
160
+ | `verification-done` | `verification/implementation-verification.md` | file |
161
+ | `task-completed` | `task.status: completed` | **state predicate** |
162
+
163
+ **The `options-chosen` predicate is vacuous against this template — recorded, not fixed (Known Limitation #11).** The template ships `code_review_enabled: true`, `pragmatic_review_enabled: true` and `reality_check_enabled: true`, so "at least one non-null `options.*` review flag" is true on a **brand-new** state, before the user has chosen anything. The predicate therefore never drops a stale `options-chosen` entry, and the safeguard is delivered by other means: `performance-verify` owns the slug, its Entry Gate routes on the slug itself, and its idempotence rule governs the re-entry. Narrowing the predicate to a value the template cannot pre-satisfy would require a dedicated marker artifact — new scope, and D1 is settled, so it is **recorded as Known Limitation #11** instead. `task-completed`'s predicate (`task.status: completed` against a `pending` default) *does* discriminate and is sound.
282
164
 
283
165
  ---
284
166
 
285
- ### Phase 7: Verification Options
167
+ ## Checklist Waivers (routing-only dispatcher)
286
168
 
287
- > **Phase gate**: Requires `question` confirmation from Phase 6 before executing.
169
+ This dispatcher records explicit, named waivers against [Orchestrator Creation Checklist](../orchestrator-framework/references/orchestrator-creation-checklist.md) items written for a monolith-shaped orchestrator with inline phases; a routing-only dispatcher cannot satisfy them because it executes no phase bodies and delegates nothing:
288
170
 
289
- **Purpose**: Determine which verification checks to run
290
- **Execute**: Direct - use question for options
291
- **Output**: Updated state with verification options
292
- **State**: Set `options.code_review_enabled`, `options.pragmatic_review_enabled`, `options.production_check_enabled`, `options.reality_check_enabled`
293
-
294
- **Always enabled**: Reality check, pragmatic review
295
- **Auto-set**: `skip_test_suite: true` (full test suite already passed during implementation phase; cleared before re-verification if fixes are applied)
296
-
297
- question with multiselect - "Which additional verification checks?"
298
-
299
- - "Code review" (recommended)
300
- - "Production readiness check"
301
-
302
- → Pause
303
-
304
- question - "Options selected. Continue to Phase 8?"
171
+ | Checklist item | Disposition | Why |
172
+ | --- | --- | --- |
173
+ | `:16` Phase structure (Purpose / Execute / Output / State / Transition per phase) | Waived | No phase bodies here — the 6 subskills own Execute/Output/State, and Entry/Exit Gates own transitions. |
174
+ | `:17` Delegation enforcement (ANTI-PATTERN / INVOKE NOW / SELF-CHECK per delegated phase) | Waived | The dispatcher spawns no subagents; delegation blocks live in the subskills that delegate. |
175
+ | `:18` POST-CONTINUATION blocks | Waived | No Skill-tool phase runs here; each subskill appends its own slugs. |
176
+ | `:19` Context passing (accumulated context in subagent prompts) | Waived by the same clause as `:17` | Unsatisfiable for the same reason: no subagents are spawned here. |
177
+ | `:20` Context extraction (per-phase `phase_summaries`) | Waived | Extraction happens per step inside the subskills. |
178
+ | `:21` Decision gates (`decisions_needed` presented via `question`) | Waived | The dispatcher receives none; the subskills own their decision questions. |
179
+ | `:22` `question` at every `→ Pause` | Waived | No `→ Pause` transitions exist — routing prints one command and STOPS; the explicit invocation is the gate. |
180
+ | `:25` Auto-recovery table | Waived | Retries are owned per subskill (each `performance-*` SKILL.md carries its own `## Recovery` table). |
181
+ | `:24` TaskCreate initialization | **Satisfied, not waived** | The dispatcher creates the six task items with `addBlockedBy` at init and records their ids in `orchestrator.task_ids`; the wrapper only updates those ids. |
305
182
 
306
183
  ---
307
184
 
308
- ### Phase 8: Verification & Issue Resolution
309
-
310
- > **Phase gate**: Requires `question` confirmation from Phase 7 before executing.
311
-
312
- **Purpose**: Comprehensive implementation verification with user-driven fix cycles
313
- **Output**: `verification/implementation-verification.md`, optional review reports
314
- **State**: Update `verification_context`
315
-
316
- **Execute**:
317
-
318
- **Step 1**: Invoke Skill tool - `implementation-verifier`
319
-
320
- **Step 2**: Display detailed issue breakdown grouped by category and severity (critical/warning/info), listing location, description, and fixability for each.
321
-
322
- **Step 3**: Gate on verification status:
323
-
324
- - `status: passed` → skip to Pause
325
- - `status: passed_with_issues` or `failed` → enter user-driven fix loop (Step 4)
326
-
327
- **Step 4**: User-driven fix loop (max 3 iterations):
328
-
329
- 1. Present all critical + warning issues as a numbered list
330
- 2. question — "Which issues should I fix?" with options: "Fix all fixable issues" / "Let me choose specific issues" / "Skip fixes, proceed as-is"
331
- 3. Fix selected issues
332
- 4. After fixes: set `skip_test_suite: false` (code changed, tests must re-run)
333
- 5. question — "Re-run verification to check fixes?" with options: "Yes, re-run verification" / "No, proceed to next phase"
334
- 6. If re-run → re-invoke `implementation-verifier` → return to Step 2
185
+ ## Exit Gate (adapted for dispatch mode)
335
186
 
336
- → Pause
187
+ After deriving the handoff, present the results box, ask how to proceed, then hand off accordingly (see the [dispatcher exception](../orchestrator-framework/references/gate-contract.md)). The results box IS the handoff block. Never auto-invoke the subskill.
337
188
 
338
- question - Display executive summary: total issues found, issues fixed, issues remaining by severity. Then "Continue to finalization?"
339
-
340
- ---
341
-
342
- ### Phase 9: Finalization → Exit Gate
343
-
344
- > **Phase gate**: Requires `question` confirmation from Phase 8 before executing.
345
-
346
- **Purpose**: Present optimization results, confirm correctness with the user, and close the workflow (Exit Gate contract, [Gate Contract](../orchestrator-framework/references/gate-contract.md))
347
- **Execute**: Direct - create summary, update state, guide commit
348
- **Output**: Workflow summary
349
- **State**: Set `task.status: completed`
350
-
351
- **Process**:
352
-
353
- 1. Create workflow summary (bottlenecks found, optimizations implemented, verification result)
354
- 2. Update task status to "completed"
355
- 3. **Results box**:
189
+ ### Results box
356
190
 
357
191
  ```markdown
358
- ## ✅ PERFORMANCE WORKFLOW COMPLETE — <task name>
192
+ ## ✅ PERFORMANCE TASK READY — <task name>
359
193
 
360
- **Bottlenecks found** — [count by severity]
361
- **Optimizations applied** — [count + key ones]
362
- **Verification** — [final verdict]
363
- **Estimated improvement** — [range from analysis]
194
+ **Task** — [performance issue description]
195
+ **Directory** — `<task-path>`
196
+ **Next step** — [subskill + slug(s)]
197
+ [Resume note: completed steps / fresh task]
364
198
 
365
- **Artifacts**
366
- - `analysis/performance-analysis.md`
367
- - `implementation/work-log.md`
368
- - `verification/implementation-verification.md`
199
+ **Next ▸** `/owflow:performance-<subskill> <task-path>`
369
200
  ```
370
201
 
371
- 4. **Results-acceptance question** — use `question` — "Are these results correct?" with options:
372
- - **Accept** — workflow is complete; print next steps below.
373
- - **Adjust** — re-run the affected phase (additional optimizations, re-verification) with the user's corrections, then re-present the results box.
374
- - **Discuss** — walk through bottleneck findings, optimization rationale, and measurement caveats in more depth; then re-ask.
375
- - **Stop here** — print the resume command (`/owflow:performance <task-path>`) and end.
202
+ ### Acceptance question
376
203
 
377
- 5. **Next steps (after Accept)** — performance-specific guidance:
378
- - Run the application and verify improvements manually
379
- - Consider profiling with runtime tools to measure actual impact
380
- - Monitor production metrics after deployment
381
- - Address remaining P2/P3 bottlenecks if needed
382
- - `/owflow:standards-update "<lesson learned>"` — capture optimization patterns as standards
204
+ Use `question` — "Task ready. How would you like to proceed?" with options:
383
205
 
384
- → End of workflow
206
+ - **Hand off to /owflow:performance-<subskill>** — the user invokes the suggested command (the dispatcher copies it to chat for convenience). Execution starts in a fresh context.
207
+ - **Switch to autonomous mode** — run the remaining steps in one session: `/owflow:goal-performance <task-path>`.
208
+ - **Adjust** — task set-up or derivation is wrong (wrong description, wrong task, wrong `--from`); re-run the affected step, re-present the results box.
209
+ - **Stop here** — print the resume command (`/owflow:performance <task-path>`) and end.
385
210
 
386
- ---
211
+ ### Handoff message
212
+
213
+ On Accept (hand off choice), print, then STOP:
387
214
 
388
- ## Domain Context (State Extensions)
215
+ ```
216
+ ✓ Performance task ready at <task-path>
389
217
 
390
- Performance-specific fields in `orchestrator-state.yml`:
218
+ Next step:
219
+ → /owflow:performance-<subskill> <task-path>
391
220
 
392
- Refer to the template [src/templates/orchestrator-state-performance.yml](../../templates/orchestrator-state-performance.yml).
221
+ Other options:
222
+ /owflow:goal-performance <task-path> — run remaining steps in one loop
223
+ /owflow:performance --from=<step-slug> <task-path> — jump to a specific step
224
+ ```
393
225
 
394
226
  ---
395
227
 
396
228
  ## Task Structure
397
229
 
230
+ The dispatcher creates the directory skeleton at init; every artifact below is produced by the subskill named in the comments:
231
+
398
232
  ```
399
233
  .owflow/tasks/performance/YYYY-MM-DD-task-name/
400
- ├── orchestrator-state.yml
234
+ ├── orchestrator-state.yml # dispatcher (init) + every subskill (per-step writes)
401
235
  ├── analysis/
402
- │ ├── codebase-analysis.md # Phase 1
403
- │ ├── performance-analysis.md # Phase 2
404
- │ ├── user-profiling-data/ # Optional user-provided data
405
- │ └── requirements.md # Phase 3
236
+ │ ├── codebase-analysis.md # performance-analyze (codebase-analysed)
237
+ │ ├── clarifications.md # performance-analyze
238
+ │ ├── performance-analysis.md # performance-analyze (bottlenecks-identified)
239
+ │ ├── requirements.md # performance-spec
240
+ │ └── user-profiling-data/ # optional user-provided data
406
241
  ├── implementation/
407
- │ ├── spec.md # Phase 3
408
- │ ├── implementation-plan.md # Phase 5
409
- │ └── work-log.md # Phase 6
242
+ │ ├── spec.md # performance-spec (spec-written)
243
+ │ ├── implementation-plan.md # performance-plan (plan-created)
244
+ │ └── work-log.md # performance-implement (implementation-done)
410
245
  └── verification/
411
- ├── spec-audit.md # Phase 4 (conditional)
412
- └── implementation-verification.md # Phase 8
246
+ ├── spec-audit.md # performance-spec (spec-audited, conditional)
247
+ └── implementation-verification.md # performance-verify (verification-done)
413
248
  ```
414
249
 
415
250
  ---
416
251
 
417
252
  ## Auto-Recovery
418
253
 
419
- | Phase | Max Attempts | Strategy |
420
- | ----- | ------------ | ------------------------------------------ |
421
- | 1 | 2 | Expand search scope, prompt user for hints |
422
- | 2 | 2 | Re-analyze with broader patterns, ask user |
423
- | 3 | 2 | Regenerate spec with adjusted requirements |
424
- | 5 | 2 | Regenerate plan |
425
- | 6 | 5 | Fix syntax, imports, tests |
426
- | 8 | 3 | Fix-then-reverify cycles |
254
+ Retries are owned by each subskill (each `/owflow:performance-*` SKILL.md carries its own `## Recovery` table).
427
255
 
428
256
  ---
429
257
 
@@ -432,6 +260,8 @@ Refer to the template [src/templates/orchestrator-state-performance.yml](../../t
432
260
  Invoked via:
433
261
 
434
262
  - `/owflow:performance [description]` (new)
435
- - `/owflow:performance [task-path] [--from=PHASE]` (resume)
263
+ - `/owflow:performance [task-path] [--from=<step-slug>]` (resume)
264
+
265
+ Alternative: `/owflow:goal-performance <task-path>` — same task lifecycle, all subskills invoked in one session with `question` gates.
436
266
 
437
267
  Task directory: `.owflow/tasks/performance/YYYY-MM-DD-task-name/`