@webpresso/opencode-plugin 3.1.12 → 3.1.13

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.
@@ -0,0 +1,645 @@
1
+ # Full reference moved from SKILL.md
2
+
3
+ > **Implementation Status: Production-Ready**
4
+ >
5
+ > Blueprint hardening and lifecycle infrastructure are production-ready:
6
+ >
7
+ > - Blueprint dependency parsing, format validation, and the lifecycle state
8
+ > machine with evidence-gated task completion (fully tested, in-package)
9
+ > batches independent tasks by dependency order and blocks dependents of
10
+ > failed tasks
11
+ >
12
+ > **Remaining gaps:** execution docs and wrappers must stay aligned with the currently shipped runtime and CLI surface.
13
+
14
+ # Plan Refinement Methodology
15
+
16
+ ## Core Principle
17
+
18
+ > **"A plan is only as strong as its weakest unchecked assumption — and only as fast as its coarsest task granularity."**
19
+
20
+ Every technology claim, file path, API assumption, and architecture decision in a blueprint must be verified against reality before implementation begins. Unverified plans create cascading failures during execution. Poorly structured plans serialize work that could run in parallel — wasting 10x the wall-clock time.
21
+
22
+ Refinement has two equally important goals:
23
+
24
+ 1. **Correctness** — Every claim is fact-checked, every edge case documented
25
+ 2. **Parallelizability** — Tasks are structured in Blueprint format with maximum independence for `/pll`
26
+ 3. **Simplicity and safety** — DRY, SOLID, YAGNI, KISS, and public package leak-prevention gates are applied before abstractions or release surfaces are approved
27
+
28
+ ## When to Use
29
+
30
+ **ALWAYS refine a plan when:**
31
+
32
+ - A new blueprint has been created from Q&A or brainstorming
33
+ - A blueprint references specific technologies, libraries, or APIs
34
+ - A blueprint makes assumptions about existing codebase structure
35
+ - A blueprint has cross-plan dependencies (upstream/downstream)
36
+ - Before moving a blueprint from `draft/` to `in-progress/`
37
+ - After significant codebase changes that may invalidate assumptions
38
+ - Tasks are too coarse for parallel execution (should be split)
39
+
40
+ **Don't use for:**
41
+
42
+ - Trivial single-task plans (just verify inline)
43
+ - Plans that are purely process/methodology (no code assumptions)
44
+ - Plans already verified and in execution
45
+
46
+ ## The Refinement Pipeline
47
+
48
+ ```
49
+ Blueprint (Draft/In-Progress)
50
+
51
+
52
+ ┌─────────────────────────────────┐
53
+ │ PHASE 1: Technology Fact-Check │ ← Web research + docs
54
+ │ - Library compatibility │
55
+ │ - API correctness │
56
+ │ - Version constraints │
57
+ │ - Runtime compatibility │
58
+ └──────────────┬──────────────────┘
59
+
60
+
61
+ ┌─────────────────────────────────┐
62
+ │ PHASE 2: Codebase Verification │ ← Grep/Read existing code
63
+ │ - File paths exist │
64
+ │ - APIs match signatures │
65
+ │ - Patterns match conventions │
66
+ │ - Dependencies available │
67
+ └──────────────┬──────────────────┘
68
+
69
+
70
+ ┌─────────────────────────────────┐
71
+ │ PHASE 3: Architecture Review │ ← Adversarial critique
72
+ │ - Race conditions │
73
+ │ - Echo loops │
74
+ │ - Error cascades │
75
+ │ - Concurrent access │
76
+ │ - Auth/session edge cases │
77
+ └──────────────┬──────────────────┘
78
+
79
+
80
+ ┌─────────────────────────────────┐
81
+ │ PHASE 4: Cross-Plan Alignment │ ← Read dependent blueprints
82
+ │ - Upstream deps still valid │
83
+ │ - Downstream plans updated │
84
+ │ - No contradictions │
85
+ │ - Shared decisions consistent │
86
+ └──────────────┬──────────────────┘
87
+
88
+
89
+ ┌─────────────────────────────────┐
90
+ │ PHASE 5: Blueprint Enforcement │ ← Structure for parallelism
91
+ │ - Task granularity audit │
92
+ │ - Dependency graph validation │
93
+ │ - File conflict detection │
94
+ │ - Wave optimization │
95
+ │ - TDD steps in every task │
96
+ └──────────────┬──────────────────┘
97
+
98
+
99
+ ┌─────────────────────────────────┐
100
+ │ PHASE 6: Apply & Consolidate │ ← Edit blueprint
101
+ │ - Apply all fixes (Fx tags) │
102
+ │ - Update Edge Cases table │
103
+ │ - Update Risks table │
104
+ │ - Update Technology Choices │
105
+ │ - Update cross-plan references │
106
+ │ - Rewrite tasks in Blueprint fmt│
107
+ └─────────────────────────────────┘
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Folded plan-review pipeline
113
+
114
+ `/autoplan` is folded into this skill. For non-trivial plans, run the plan review
115
+ lenses in the order that matches the risk: CEO/founder scope, design/UX,
116
+ engineering architecture, then DevEx/migration. Consolidate the reviews into
117
+ keep/change/drop decisions, unresolved taste calls, required tests, and a final
118
+ go/no-go. Do not edit implementation code during plan refinement.
119
+
120
+ ## Required Policy Gates
121
+
122
+ Apply these gates to every refined blueprint:
123
+
124
+ - **Engineering principles:** enforce `.agent/rules/engineering-principles.md`.
125
+ Reject speculative abstractions, unused extension seams, avoidable
126
+ dependencies, and designs that can be simpler without losing behavior.
127
+ - **Public package safety:** when a plan touches `package.json`, `files`, `bin`,
128
+ `exports`, package docs, catalog assets, generated agent surfaces, or release
129
+ workflows, enforce `.agent/rules/public-package-safety.md`. Require a
130
+ tarball/package-surface check and explicitly keep private content out.
131
+
132
+ If either gate fails, record the finding and simplify or quarantine the public
133
+ surface before execution.
134
+
135
+ ---
136
+
137
+ ## Phase 1: Technology Fact-Check
138
+
139
+ **Goal:** Verify every technology claim against official documentation and known issues.
140
+
141
+ ### What to Check
142
+
143
+ | Category | Check | How |
144
+ | ------------------------------ | ------------------------------------------- | ----------------------------------------------------- |
145
+ | **Library compatibility** | Does library X work with runtime Y? | Web search `"library-name" + "runtime-name" + issues` |
146
+ | **API correctness** | Does the API exist as described? | Read official docs via Context7 or WebFetch |
147
+ | **Version constraints** | Is the version available? Breaking changes? | npm registry, changelogs |
148
+ | **Native addon compatibility** | Does it compile for all targets? | Check Bun/Node/Deno compatibility |
149
+ | **Protocol correctness** | Is the wire protocol right? | Official docs (e.g., WebSocket subprotocols) |
150
+ | **Platform limits** | Are there timeout/memory/size limits? | Platform docs (e.g., Workers limits) |
151
+
152
+ ### Output Format
153
+
154
+ For each finding, assign:
155
+
156
+ - **ID**: F1, F2, F3...
157
+ - **Severity**: CRITICAL (blocks implementation), HIGH (causes bugs), MEDIUM (suboptimal), LOW (cosmetic)
158
+ - **Claim**: What the blueprint says
159
+ - **Reality**: What documentation/research shows
160
+ - **Fix**: Concrete change to the blueprint
161
+
162
+ ### Anti-Patterns
163
+
164
+ | Anti-Pattern | Why It's Wrong | Do This Instead |
165
+ | ------------------------------------- | --------------------------------- | ----------------------------------------- |
166
+ | "Library X should work" | Untested assumption | Verify with official docs + GitHub issues |
167
+ | Trusting AI knowledge of library APIs | Models hallucinate API signatures | Read actual docs via Context7/WebFetch |
168
+ | Assuming latest version compatibility | Breaking changes happen | Check specific version compatibility |
169
+ | Ignoring native addon constraints | Build failures in CI/CD | Test against all target runtimes |
170
+
171
+ ## Phase 2: Codebase Verification
172
+
173
+ **Goal:** Verify every file path, import, API reference, and pattern assumption against the actual codebase.
174
+
175
+ Use the lightest reliable inspection tool first: prefer `rg -n` for search, `sed -n` for exact line ranges, and only escalate to ad hoc scripts when the extraction genuinely needs structure across many files.
176
+
177
+ ### What to Check
178
+
179
+ | Category | Check | How |
180
+ | ---------------------- | ------------------------------------------ | --------------------------------------- |
181
+ | **File paths** | Do referenced files exist at stated paths? | `Glob` for patterns, `Read` for content |
182
+ | **API signatures** | Do functions have the expected parameters? | `Grep` for function definitions |
183
+ | **Import paths** | Are package exports available? | Read `package.json` exports field |
184
+ | **Existing patterns** | Does the codebase use the assumed pattern? | `Grep` for similar code |
185
+ | **Naming conventions** | Do new files follow existing naming? | `ls` existing directories |
186
+ | **Configuration** | Are config values/env vars available? | Read config files, `.env.example` |
187
+
188
+ ### Codebase Red Flags
189
+
190
+ - Blueprint says `targets/` but codebase uses `emitters/`
191
+ - Blueprint imports from `package/subpath` but package.json has no subpath export
192
+ - Blueprint extends a class that doesn't exist yet (timing dependency)
193
+ - Blueprint assumes a function returns X but it actually returns Y
194
+ - Blueprint references env var that isn't in any config
195
+
196
+ ## Phase 3: Architecture Review
197
+
198
+ **Goal:** Adversarial critique of the architecture — find every way it can break.
199
+
200
+ ### The Adversarial Checklist
201
+
202
+ Think like a hostile system trying to break the design:
203
+
204
+ #### Concurrency & Race Conditions
205
+
206
+ - [ ] What happens if two processes write simultaneously?
207
+ - [ ] What happens if operation A completes between steps of operation B?
208
+ - [ ] Is there a time-of-check-to-time-of-use (TOCTOU) gap?
209
+ - [ ] Can operations interleave in a way that corrupts state?
210
+
211
+ #### Echo Loops & Infinite Cycles
212
+
213
+ - [ ] If A triggers B which triggers A, what breaks the cycle?
214
+ - [ ] Is the cycle-break mechanism robust to timing variations?
215
+ - [ ] Can events batch in a way that bypasses the cycle-break?
216
+
217
+ #### Error Cascades
218
+
219
+ - [ ] If step N fails, do steps N+1...M still make sense?
220
+ - [ ] Can a partial failure leave the system in an inconsistent state?
221
+ - [ ] Is there a dead-letter queue for permanently failed operations?
222
+ - [ ] What happens after N retries? Is there a max?
223
+
224
+ #### Authentication & Sessions
225
+
226
+ - [ ] What happens when tokens expire during long operations?
227
+ - [ ] Is there a refresh mechanism? What if refresh also fails?
228
+ - [ ] Do WebSocket connections survive token rotation?
229
+
230
+ #### Data Integrity
231
+
232
+ - [ ] Can the ABA problem occur? (A→B→A looks like no change)
233
+ - [ ] Are soft deletes propagated correctly in both directions?
234
+ - [ ] What happens during schema changes with in-flight data? (Note: repos that prefer `db push` over migrations have different edge cases from migration-based repos.)
235
+ - [ ] Can orphaned records accumulate?
236
+
237
+ #### Platform Constraints
238
+
239
+ - [ ] Workers: 100s idle timeout, 30s CPU, 128MB memory
240
+ - [ ] SQLite: single-writer, no network FS, WAL checkpoint starvation
241
+ - [ ] WebSocket: protocol negotiation, heartbeat requirements
242
+ - [ ] File watchers: missed events during rapid bursts, git operations
243
+
244
+ ### Output: Severity Classification
245
+
246
+ | Severity | Definition | Example |
247
+ | -------- | ------------------------------------------------------ | ------------------------------------------ |
248
+ | CRITICAL | Will cause infinite loops, data loss, or build failure | Echo loop with no break mechanism |
249
+ | HIGH | Will cause bugs in normal usage | Duplicate outbox entries from dual process |
250
+ | MEDIUM | Will cause bugs in edge cases | Race condition during schema push |
251
+ | LOW | Suboptimal but functional | Unnecessary payload size |
252
+
253
+ ## Phase 4: Cross-Plan Alignment
254
+
255
+ **Goal:** Ensure the plan is coherent with all related blueprints.
256
+
257
+ ### What to Check
258
+
259
+ 1. **Upstream dependencies** — Are the interfaces/packages this plan depends on still designed the same way?
260
+ 2. **Downstream impacts** — Do plans that depend on this one need updating?
261
+ 3. **Shared decisions** — If two plans both chose a technology (e.g., Drizzle ORM), are they using compatible versions/patterns?
262
+ 4. **Non-goals consistency** — If plan A says "X is out of scope" and plan B says "depends on X from plan A", there's a contradiction.
263
+ 5. **Timeline consistency** — If plan A depends on plan B Phase 2, is plan B still structured with that phase?
264
+
265
+ ### Cross-Plan Update Protocol
266
+
267
+ When a fix in Plan A affects Plan B:
268
+
269
+ 1. Read Plan B in full
270
+ 2. Identify the specific section that needs updating
271
+ 3. Add a dated architecture note (not a rewrite)
272
+ 4. Add/update the cross-plan reference in both plans
273
+
274
+ ---
275
+
276
+ ## Phase 5: Blueprint Format Enforcement & Parallelization
277
+
278
+ > **"If `/pll` can't run 6-8 agents simultaneously, the plan is too coarse."**
279
+
280
+ **Goal:** Ensure every task follows Blueprint format and the dependency graph maximizes parallelism for `/pll` with Kahn's Algorithm.
281
+
282
+ The parallel orchestrator is production-ready. This phase ensures plans are structured to maximize parallel agent throughput.
283
+
284
+ ### Task Granularity Optimization (Parallel-First)
285
+
286
+ **Goal**: Maximize independent tasks while avoiding file conflicts and hidden dependencies.
287
+
288
+ **Rules of thumb**:
289
+
290
+ - **1 task = 1 file cluster** (touch 1–3 related files; split if >3 distinct areas)
291
+ - **No mixed concerns** (separate UI, data, and infra tasks)
292
+ - **Explicit dependencies only** (if a task needs outputs from another, list it in `Depends`)
293
+ - **Avoid shared-file contention** (if two tasks touch the same file, either merge or serialize)
294
+ - **Target wave size ≥ 6 tasks** for plans intended to run with 6–8 agents
295
+
296
+ **Split tasks when**:
297
+
298
+ - A task mixes **setup + implementation + refactor** in one block
299
+ - It touches **multiple packages** without a clear sequencing need
300
+ - It includes both **schema changes** and **feature code**
301
+ - It bundles **tests** for multiple components (split per component)
302
+
303
+ **Merge tasks when**:
304
+
305
+ - Two tasks always touch the **same files**
306
+ - One task is only **a tiny follow-up** (e.g., rename, lint fix) for another
307
+ - Dependencies create a chain with no parallelism
308
+
309
+ ### The Blueprint Task Template (Mandatory)
310
+
311
+ Every task MUST follow this exact structure:
312
+
313
+ ```markdown
314
+ #### [lane] Task X.Y: [Component Name]
315
+
316
+ **Status:** todo
317
+
318
+ **Depends:** Task 1.1, Task 1.2 (or "None" for Tier 0)
319
+
320
+ [Description paragraph — enough context for an independent agent to execute
321
+ without reading other tasks. Include: what, why, constraints, gotchas.]
322
+
323
+ **Files:**
324
+
325
+ - Create: `exact/path/to/file.ts`
326
+ - Create: `exact/path/to/file.test.ts`
327
+ - Modify: `exact/path/to/existing.ts`
328
+
329
+ **Steps (TDD):**
330
+
331
+ 1. Write failing test for [specific behavior]
332
+ 2. Run: `just test --file <path/to/test-file.test.ts>` — verify FAIL
333
+ 3. Implement minimal code to pass
334
+ 4. Run: `just test --file <path/to/test-file.test.ts>` — verify PASS
335
+ 5. Refactor if needed (complexity ≤ 8)
336
+ 6. Run: `just lint --file <changed-file.ts> <changed-test.ts>` and `just typecheck --file <changed-file.ts> <changed-test.ts>`
337
+
338
+ **Acceptance:**
339
+
340
+ - [ ] Test file created with failing test
341
+ - [ ] Implementation passes all tests
342
+ - [ ] `just lint --file <changed-files...>` passes
343
+ - [ ] `just typecheck --file <changed-files...>` passes
344
+ ```
345
+
346
+ Use `#### Task X.Y: ...` only when a lane prefix would add no value, but prefer lane-prefixed headers such as `[schema]`, `[backend]`, `[ui]`, `[infra]`, `[docs]`, or `[qa]`.
347
+
348
+ ### Project Conventions
349
+
350
+ These are enforced project conventions (with webpresso's conventions as the example):
351
+
352
+ | Convention | Rule | Rationale |
353
+ | -------------------- | ------------------------------------- | ------------------------------------------------------------------- |
354
+ | **Estimates** | Use t-shirt sizing ONLY (XS/S/M/L/XL) | No day/week estimates — too inaccurate and cause false expectations |
355
+ | **Database Changes** | Follow the repo's preferred workflow | e.g. `db push` before production launch, migrations after |
356
+
357
+ **Violations to flag:**
358
+
359
+ - Task says "1 day", "3 hours", "2 weeks" → Change to t-shirt size
360
+ - Task creates migration files or migration infrastructure when the repo prefers `db push` → Use the repo's chosen workflow
361
+ - References `just db-migrate` when the repo uses `db push` → Use `db push` (entity YAML → schema generation → push)
362
+
363
+ ### Blueprint Validation Checklist
364
+
365
+ Run this audit on every task in the blueprint:
366
+
367
+ | Check | Violation | Fix |
368
+ | --------------------------------- | ---------------------------------------------------- | ------------------------------------------------- |
369
+ | Has `**Depends:**` line? | Missing → `/pll` can't build DAG | Add explicit dependency or "None" |
370
+ | Has `**Files:**` section? | Missing → agents can't detect file conflicts | List every file touched (Create/Modify) |
371
+ | Has `**Steps (TDD):**`? | Missing → agents skip tests | Add TDD steps with exact `just` commands |
372
+ | Has `**Acceptance:**` checkboxes? | Missing → no completion criteria | Add testable acceptance criteria |
373
+ | Description self-contained? | References "see above" or "as described in Task X.Y" | Inline the context — each task runs independently |
374
+ | Files overlap with another task? | Two tasks modify same file → conflict in parallel | Merge tasks or add explicit `**Depends:**` |
375
+ | Uses t-shirt sizing? | Day/week estimates used | Replace with XS/S/M/L/XL |
376
+ | Follows repo DB workflow? | Diverges from repo's chosen workflow | Use repo's chosen workflow instead |
377
+
378
+ ### Granularity Rules
379
+
380
+ **The Goldilocks Zone:** Each task should be **XS-S size** (single focused change with tests). Smaller = overhead. Larger = blocks other work.
381
+
382
+ #### Too Coarse (Split It)
383
+
384
+ ```markdown
385
+ BAD: "Implement sync engine with push, pull, and connection manager"
386
+ ```
387
+
388
+ This is 3+ independent concerns. An agent working on this blocks 30+ minutes while push, pull, and connection could all run in parallel.
389
+
390
+ ```markdown
391
+ GOOD: Split into:
392
+ Task 3.1: Push engine (client-side) Depends: 2.3
393
+ Task 3.2: Pull engine (client-side) Depends: 1.2
394
+ Task 4.2: WebSocket auth proxy Depends: None
395
+ Task 5.1: Connection manager + orchestrator Depends: 3.1, 3.2, 4.1, 4.2
396
+ ```
397
+
398
+ #### Too Fine (Merge It)
399
+
400
+ ```markdown
401
+ BAD:
402
+ Task 1.1a: Create package.json for sync package
403
+ Task 1.1b: Create tsconfig.json for sync package
404
+ Task 1.1c: Add subpath exports to package.json
405
+ ```
406
+
407
+ These can't be tested independently and have no value as separate agent work.
408
+
409
+ ```markdown
410
+ GOOD: "Task 1.2: Scaffold sync package + local DB"
411
+ — package.json, tsconfig, exports, db client, tests — all one task
412
+ ```
413
+
414
+ ### Splitting Rules
415
+
416
+ | Signal | Action |
417
+ | -------------------------------------------- | ----------------------------------------- |
418
+ | Task touches 3+ unrelated files | Split into independent tasks |
419
+ | Task has "and" in the title | Split at the "and" |
420
+ | Task is M or larger | Split by concern (data layer, API, tests) |
421
+ | Two subtasks have no data dependency | They should be separate tasks |
422
+ | Task can't start until 3+ other tasks finish | Check if some deps are artificial |
423
+
424
+ ### Merging Rules
425
+
426
+ | Signal | Action |
427
+ | ------------------------------------------------- | -------------------------------------- |
428
+ | Task is XS with no tests | Merge with related task |
429
+ | Task creates a file that only one other task uses | Merge into that task |
430
+ | Three tasks all modify the same file | Merge or serialize them |
431
+ | Task has no test (pure config/scaffold) | Merge with the first task that uses it |
432
+
433
+ ### Dependency Graph Optimization
434
+
435
+ **Goal:** Maximize the width of each wave (more tasks in parallel = faster execution).
436
+
437
+ #### Wave Analysis
438
+
439
+ ```
440
+ Wave 0 (Tier 0): Tasks with no dependencies → All run in parallel
441
+ Wave 1 (Tier 1): Tasks depending only on Wave 0 → Run as Wave 0 completes
442
+ Wave 2 (Tier 2): Tasks depending on Wave 0+1 → Run as deps clear
443
+ ...
444
+ ```
445
+
446
+ **Metric: Critical path length** — The longest chain of sequential dependencies. This is the minimum wall-clock time regardless of how many agents you throw at it.
447
+
448
+ ### State-of-the-Art Parallelization Metrics (Required)
449
+
450
+ Use these metrics when refining or challenging a blueprint:
451
+
452
+ 1. **Ready Width (RW)**
453
+ - Number of runnable tasks at each wave.
454
+ - Target: first two waves should keep planned agents busy (for 6 agents, RW ≥ 6 in Wave 0 or Wave 1).
455
+
456
+ 2. **Critical Path Ratio (CPR)**
457
+ - `CPR = total_tasks / critical_path_length`
458
+ - Higher is better (more theoretical parallel speedup).
459
+ - Target: CPR ≥ 2.5 for parallel plans.
460
+
461
+ 3. **Dependency Density (DD)**
462
+ - `DD = total_dependency_edges / total_tasks`
463
+ - Lower is usually better (fewer coordination constraints).
464
+ - Target: DD ≤ 2.0 unless architecture requires strict sequencing.
465
+
466
+ 4. **Conflict Pressure (CP)**
467
+ - Count of same-file overlaps across tasks in the same wave.
468
+ - Hard target: CP = 0 for every wave.
469
+
470
+ If metrics miss target, refine task granularity or dependency design before execution.
471
+
472
+ #### Optimization Techniques
473
+
474
+ 1. **Break false dependencies.** If Task 2.1 "depends on" Task 1.2 but only needs the _interface_ (not the implementation), extract the interface into a Tier 0 task.
475
+
476
+ 2. **Parallelize within phases.** If Phase 2 has 3 tasks that all depend on Phase 1 but not on each other, they should all be in the same wave.
477
+
478
+ 3. **Front-load independent work.** Move tasks that don't depend on anything to Wave 0 — they start immediately.
479
+
480
+ 4. **Minimize the fan-in bottleneck.** If Task 5.1 depends on Tasks 3.1, 3.2, 4.1, and 4.2 — that's 4 tasks that must ALL complete before 5.1 starts. Ask: can any of 5.1's work start earlier?
481
+
482
+ #### File Conflict Detection
483
+
484
+ Two tasks running in parallel MUST NOT modify the same file. If they do:
485
+
486
+ 1. **Preferred:** Restructure so each task has its own files
487
+ 2. **Acceptable:** Add explicit `**Depends:**` to serialize them
488
+ 3. **Last resort:** Document the conflict in the Quick Reference table
489
+
490
+ ### Quick Reference Table (Required)
491
+
492
+ Every refined blueprint MUST include this table for `/pll`:
493
+
494
+ ```markdown
495
+ ## Quick Reference (Execution Waves)
496
+
497
+ | Wave | Tasks | Dependencies | Parallelizable | Effort (T-shirt) |
498
+ | ----------------- | --------------------------------- | ---------------- | -------------- | ---------------- |
499
+ | **Wave 0** | 1.1, 1.2, 1.3 | None | 3 agents | XS-S |
500
+ | **Wave 1** | 2.1, 2.2, 2.3 | Wave 0 | 3 agents | S-M |
501
+ | **Wave 2** | 3.1, 3.2, 4.2 | Wave 1 (partial) | 3 agents | S-M |
502
+ | **Wave 3** | 4.1, 5.1 | Wave 2 | 2 agents | M |
503
+ | **Wave 4** | 6.1 | Wave 3 | 1 agent | S |
504
+ | **Critical path** | 1.1 → 2.3 → 3.1 → 4.1 → 5.1 → 6.1 | — | 6 waves | L |
505
+
506
+ ### Parallel Metrics Snapshot (Required)
507
+
508
+ | Metric | Formula / Meaning | Target | Actual |
509
+ | ------ | ---------------------------------- | -------------------- | ------- |
510
+ | RW0 | Ready tasks in Wave 0 | ≥ planned agents / 2 | <value> |
511
+ | CPR | total_tasks / critical_path_length | ≥ 2.5 | <value> |
512
+ | DD | dependency_edges / total_tasks | ≤ 2.0 | <value> |
513
+ | CP | same-file overlaps per wave | 0 | <value> |
514
+
515
+ If any target misses, include a short "refinement delta" note describing task split/merge changes.
516
+ ```
517
+
518
+ ### Parallelization Score
519
+
520
+ Rate the plan's parallelizability:
521
+
522
+ | Score | Definition | Action |
523
+ | ----- | ------------------------------------- | ----------------------------------- |
524
+ | **A** | RW target met, CPR ≥ 2.5, CP = 0 | Ready for `/pll` |
525
+ | **B** | RW near target, CPR 2.0-2.49, CP = 0 | Improve dependencies before execute |
526
+ | **C** | CPR 1.5-1.99 or frequent narrow waves | Split coarse tasks, reduce fan-in |
527
+ | **D** | CPR < 1.5 or CP > 0 in planned waves | Must restructure before execution |
528
+
529
+ ### Self-Contained Task Test
530
+
531
+ For each task, ask: **"Can an agent execute this task with ONLY the task description, the codebase, and `just` commands?"**
532
+
533
+ If the answer is no, the task is missing context. Common fixes:
534
+
535
+ - Inline interface definitions (don't say "use the interface from Task 1.1")
536
+ - Include the schema/type the task needs to implement
537
+ - Specify exact import paths
538
+ - Include example input/output for test cases
539
+
540
+ ---
541
+
542
+ ## Phase 6: Apply & Consolidate
543
+
544
+ **Goal:** Write all fixes into the blueprint as a single coherent update.
545
+
546
+ ### Fix Tagging Convention
547
+
548
+ Every fix gets an `(Fx)` tag that appears:
549
+
550
+ 1. In the inline task where the fix is applied
551
+ 2. In the Edge Cases table
552
+ 3. In the Risks table (if applicable)
553
+ 4. In the Technology Choices table (if applicable)
554
+
555
+ This creates **traceability** — anyone reading the blueprint can trace why a particular decision was made back to the fact-check finding.
556
+
557
+ ### Required Updates
558
+
559
+ After applying all fixes, verify:
560
+
561
+ - [ ] **Blueprint format** — Every task has Depends, Files, Steps (TDD), Acceptance
562
+ - [ ] **Self-contained tasks** — Each task can be executed by an independent agent
563
+ - [ ] **Engineering principles** — DRY, SOLID, YAGNI, and KISS are applied; unnecessary abstractions, dependencies, and config are removed
564
+ - [ ] **Public package safety** — Plans that touch package or release surfaces include tarball/package-surface leak checks and denied-content exclusions
565
+ - [ ] **No file conflicts** — No two parallel tasks modify the same file
566
+ - [ ] **Quick Reference table** — Updated with correct waves and agent counts
567
+ - [ ] **Edge Cases table** — Every finding with severity ≥ MEDIUM has a row
568
+ - [ ] **Risks table** — Every finding with severity ≥ HIGH has a row with mitigation
569
+ - [ ] **Technology Choices table** — Any library/tool changes reflected
570
+ - [ ] **Key Decisions table** — Any decision changes reflected with rationale
571
+ - [ ] **Cross-Plan References** — Downstream plans updated if affected
572
+ - [ ] **Progress field** — Updated to note fact-check completion
573
+ - [ ] **Architecture diagram** — Updated if technology names changed
574
+
575
+ ### Verification Report
576
+
577
+ At the end, produce a summary:
578
+
579
+ ```markdown
580
+ ## Refinement Summary
581
+
582
+ | Metric | Value |
583
+ | ------------------------- | --------------------- |
584
+ | Findings total | 20 |
585
+ | Critical | 3 |
586
+ | High | 5 |
587
+ | Medium | 8 |
588
+ | Low | 4 |
589
+ | Fixes applied | 20/20 |
590
+ | Cross-plans updated | 2 |
591
+ | Edge cases documented | 15 |
592
+ | Risks documented | 12 |
593
+ | **Parallelization score** | B (5 tasks in Wave 0) |
594
+ | **Critical path** | 6 waves (~90 min) |
595
+ | **Max parallel agents** | 3 |
596
+ | **Total tasks** | 11 |
597
+ | **Blueprint compliant** | 11/11 |
598
+ ```
599
+
600
+ ---
601
+
602
+ ## Red Flags — STOP
603
+
604
+ Stop and escalate to the user if:
605
+
606
+ - A CRITICAL finding invalidates the core architecture (e.g., the chosen database doesn't work on the target runtime)
607
+ - Two findings contradict each other (fix A requires X, fix B requires not-X)
608
+ - A cross-plan dependency is broken and requires re-planning
609
+ - The number of CRITICAL + HIGH findings exceeds 10 (plan may need fundamental rethinking)
610
+ - A technology assumption affects more than 3 tasks (cascading rewrite needed)
611
+ - Parallelization score is **D** (1 task in Wave 0) — plan needs fundamental restructure
612
+
613
+ ## Parallel Agent Strategy
614
+
615
+ The refinement pipeline itself is designed for parallel execution:
616
+
617
+ | Agent | Phase | Tools | Focus |
618
+ | ------- | --------------------- | ----------------------------- | ---------------------------------- |
619
+ | Agent 1 | Technology Fact-Check | WebSearch, WebFetch, Context7 | Library docs, compatibility, APIs |
620
+ | Agent 2 | Codebase Verification | Grep, Glob, Read | File paths, existing code patterns |
621
+ | Agent 3 | Architecture Review | Read (blueprint only) | Adversarial critique, edge cases |
622
+
623
+ Agents 1-3 run in parallel. Phases 4-6 (Cross-Plan, Blueprint Enforcement, Apply) run sequentially after all agents complete.
624
+
625
+ ## Related Skills
626
+
627
+ - **plan** — Creating plans (this skill refines them)
628
+ - **question-flow** — Supported user-input pattern for plan clarification
629
+ - **testing-philosophy** — Test strategy validation within plans (integration-first, 85% mutation)
630
+ - **verify** — Evidence-based completion and post-implementation verification
631
+ - **systematic-debugging** — When refinement finds broken assumptions
632
+
633
+ ## Related Commands
634
+
635
+ - `wp blueprint new "<goal>" --complexity <size>` — Create a new blueprint (this skill refines it)
636
+ - `wp blueprint audit --all --strict` — Audit blueprint format/lifecycle before or after refinement
637
+ - `/pll` — Operator-facing parallel execution workflow for refined Blueprint-shaped work
638
+ - `/verify <target>` — Post-implementation quality gate
639
+ - `/soa <target>` — Apply SOA 2026 quality standards (TDD, complexity ≤8, mutation ≥85%)
640
+
641
+ **Parallel Execution:** Refined plans should execute through the current workflow surface while Blueprint remains the durable lifecycle source of truth via `wp blueprint start|task|finalize`. See `.agent/commands/pll.md` for the current operator guidance.
642
+
643
+ ## Planned eligibility verdict
644
+
645
+ Before declaring a blueprint planned-eligible, complete its Trust Dossier, evidence material claims, close material decisions, define Promotion Gates, and emit exactly one verdict: `planned-eligible` or `not-planned-eligible`. Reject speculative abstractions, unverifiable material claims, and "decide during implementation" placeholders. Blueprints implementing this gate before it lands may document that the dossier becomes required once the gate exists.