@webpresso/codex-plugin 3.1.3

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