@lumenflow/cli 3.20.0 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/chunk-2D2VOCA4.js +37 -0
  2. package/dist/chunk-2D5KFYGX.js +284 -0
  3. package/dist/chunk-2GXVIN57.js +14072 -0
  4. package/dist/chunk-2MQ7HZWZ.js +26 -0
  5. package/dist/chunk-2UFQ3A3C.js +643 -0
  6. package/dist/chunk-3RG5ZIWI.js +10 -0
  7. package/dist/chunk-4N74J3UT.js +15 -0
  8. package/dist/chunk-5GTOXFYR.js +392 -0
  9. package/dist/chunk-5VY6MQMC.js +240 -0
  10. package/dist/chunk-67XVPMRY.js +1297 -0
  11. package/dist/chunk-6HO4GWJE.js +164 -0
  12. package/dist/chunk-6W5XHWYV.js +1890 -0
  13. package/dist/chunk-6X4EMYJQ.js +64 -0
  14. package/dist/chunk-6XYXI2NQ.js +772 -0
  15. package/dist/chunk-7ANSOV6Q.js +285 -0
  16. package/dist/chunk-A624LFLB.js +1380 -0
  17. package/dist/chunk-ADN5NHG4.js +126 -0
  18. package/dist/chunk-B7YJYJKG.js +33 -0
  19. package/dist/chunk-CCLHCPKG.js +210 -0
  20. package/dist/chunk-CK36VROC.js +1584 -0
  21. package/dist/chunk-D3UOFRSB.js +81 -0
  22. package/dist/chunk-DFR4DJBM.js +230 -0
  23. package/dist/chunk-DSYBDHYH.js +79 -0
  24. package/dist/chunk-DWMLTXKQ.js +1176 -0
  25. package/dist/chunk-E3REJTAJ.js +28 -0
  26. package/dist/chunk-EA3IVO64.js +633 -0
  27. package/dist/chunk-EK2AKZKD.js +55 -0
  28. package/dist/chunk-ELD7JTTT.js +343 -0
  29. package/dist/chunk-EX6TT2XI.js +195 -0
  30. package/dist/chunk-EXINSFZE.js +82 -0
  31. package/dist/chunk-EZ6ZBYBM.js +510 -0
  32. package/dist/chunk-FBKAPTJ2.js +16 -0
  33. package/dist/chunk-FVLV5RYH.js +1118 -0
  34. package/dist/chunk-GDNSBQVK.js +2485 -0
  35. package/dist/chunk-GPQHMBNN.js +278 -0
  36. package/dist/chunk-GTFJB67L.js +68 -0
  37. package/dist/chunk-HANJXVKW.js +1127 -0
  38. package/dist/chunk-HEVS5YLD.js +269 -0
  39. package/dist/chunk-HMEVZKPQ.js +9 -0
  40. package/dist/chunk-HRGSYNLM.js +3511 -0
  41. package/dist/chunk-ISZR5N4K.js +60 -0
  42. package/dist/chunk-J6SUPR2C.js +226 -0
  43. package/dist/chunk-JERYVEIZ.js +244 -0
  44. package/dist/chunk-JHHWGL2N.js +87 -0
  45. package/dist/chunk-JONWQUB5.js +775 -0
  46. package/dist/chunk-K2DIWWDM.js +1766 -0
  47. package/dist/chunk-KY4PGL5V.js +969 -0
  48. package/dist/chunk-L737LQ4C.js +1285 -0
  49. package/dist/chunk-LFTWYIB2.js +497 -0
  50. package/dist/chunk-LV47RFNJ.js +41 -0
  51. package/dist/chunk-MKSAITI7.js +15 -0
  52. package/dist/chunk-MZ7RKIX4.js +212 -0
  53. package/dist/chunk-NAP6CFSO.js +84 -0
  54. package/dist/chunk-ND6MY37M.js +16 -0
  55. package/dist/chunk-NMG736UR.js +683 -0
  56. package/dist/chunk-NRAXROED.js +32 -0
  57. package/dist/chunk-NRIZR3A7.js +690 -0
  58. package/dist/chunk-NX43BG3M.js +233 -0
  59. package/dist/chunk-O645XLSI.js +297 -0
  60. package/dist/chunk-OMJD6A3S.js +235 -0
  61. package/dist/chunk-QB6SJD4T.js +430 -0
  62. package/dist/chunk-QFSTL4J3.js +276 -0
  63. package/dist/chunk-QLGDFMFX.js +212 -0
  64. package/dist/chunk-RIAAGL2E.js +13 -0
  65. package/dist/chunk-RWO5XMZ6.js +86 -0
  66. package/dist/chunk-RXRKBBSM.js +149 -0
  67. package/dist/chunk-RZOZMML6.js +363 -0
  68. package/dist/chunk-U7I7FS7T.js +113 -0
  69. package/dist/chunk-UI42RODY.js +717 -0
  70. package/dist/chunk-UTVMVSCO.js +519 -0
  71. package/dist/chunk-V6OJGLBA.js +1746 -0
  72. package/dist/chunk-W2JHVH7D.js +152 -0
  73. package/dist/chunk-WD3Y7VQN.js +280 -0
  74. package/dist/chunk-WOCTQ5MS.js +303 -0
  75. package/dist/chunk-WZR3ZUNN.js +696 -0
  76. package/dist/chunk-XGI665H7.js +150 -0
  77. package/dist/chunk-XKY65P2T.js +304 -0
  78. package/dist/chunk-Y4CQZY65.js +57 -0
  79. package/dist/chunk-YFEXKLVE.js +194 -0
  80. package/dist/chunk-YHO3HS5X.js +287 -0
  81. package/dist/chunk-YLS7AZSX.js +738 -0
  82. package/dist/chunk-ZE473AO6.js +49 -0
  83. package/dist/chunk-ZF747T3O.js +644 -0
  84. package/dist/chunk-ZHCZHZH3.js +43 -0
  85. package/dist/chunk-ZZNZX2XY.js +87 -0
  86. package/dist/constants-7QAP3VQ4.js +23 -0
  87. package/dist/dist-IY3UUMWK.js +33 -0
  88. package/dist/init-templates.js +30 -22
  89. package/dist/init-templates.js.map +1 -1
  90. package/dist/invariants-runner-W5RGHCSU.js +27 -0
  91. package/dist/lane-lock-6J36HD5O.js +35 -0
  92. package/dist/mem-checkpoint-core-EANG2GVN.js +14 -0
  93. package/dist/mem-signal-core-2LZ2WYHW.js +19 -0
  94. package/dist/memory-store-OLB5FO7K.js +18 -0
  95. package/dist/service-6BYCOCO5.js +13 -0
  96. package/dist/spawn-policy-resolver-NTSZYQ6R.js +17 -0
  97. package/dist/spawn-task-builder-R4E2BHSW.js +22 -0
  98. package/dist/wu-done-pr-WLFFFEPJ.js +25 -0
  99. package/dist/wu-done-validation-3J5E36FE.js +30 -0
  100. package/dist/wu-duplicate-id-detector-5S7JHELK.js +232 -0
  101. package/dist/wu-spawn-strategy-resolver.js +18 -5
  102. package/dist/wu-spawn-strategy-resolver.js.map +1 -1
  103. package/package.json +8 -8
  104. package/packs/agent-runtime/.turbo/turbo-build.log +1 -1
  105. package/packs/agent-runtime/.turbo/turbo-typecheck.log +4 -0
  106. package/packs/agent-runtime/package.json +1 -1
  107. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  108. package/packs/sidekick/.turbo/turbo-test.log +12 -0
  109. package/packs/sidekick/.turbo/turbo-typecheck.log +4 -0
  110. package/packs/sidekick/package.json +1 -1
  111. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  112. package/packs/software-delivery/.turbo/turbo-typecheck.log +4 -0
  113. package/packs/software-delivery/package.json +1 -1
  114. package/templates/core/.lumenflow/constraints.md.template +68 -3
  115. package/templates/core/LUMENFLOW.md.template +26 -26
  116. package/templates/core/_frameworks/lumenflow/wu-sizing-guide.md.template +1 -3
  117. package/templates/core/ai/onboarding/agent-safety-card.md.template +14 -4
  118. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +96 -0
  119. package/templates/core/ai/onboarding/quick-ref-commands.md.template +23 -22
  120. package/templates/core/ai/onboarding/rapid-prototyping.md +2 -1
  121. package/templates/core/ai/onboarding/starting-prompt.md.template +3 -3
  122. package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +69 -1
@@ -491,7 +491,7 @@ Only use these patterns after you have confirmed the work is no longer one coher
491
491
 
492
492
  **Heading:** Default Triggers (Deviations require written justification in WU notes)
493
493
 
494
- If you hit ANY of these triggers during a session, you MUST perform a Standard Session Handoff (see [session-handoff.md](./agent/onboarding/session-handoff.md)):
494
+ If you hit ANY of these triggers during a session, you MUST perform a Standard Session Handoff:
495
495
 
496
496
  - **Token Limit:** Context usage hits **50% (Warning)** or **80% (Critical)**.
497
497
  - **Tool Volume:** **50+ tool calls** in current session.
@@ -619,9 +619,7 @@ This is a case study in genuinely non-atomic work. Do not generalize it into "mu
619
619
 
620
620
  ## 8. Related Documentation
621
621
 
622
- - [session-handoff.md](./agent/onboarding/session-handoff.md) — Mid-WU checkpoint protocol
623
622
  - [agent-safety-card.md](./agent/onboarding/agent-safety-card.md) — Quick reference safety thresholds
624
- - [parallel-session-optimization.md](./agent/onboarding/parallel-session-optimization.md) — Running 4-6 WUs concurrently
625
623
  - [agent-invocation-guide.md](./agent/onboarding/agent-invocation-guide.md) — Orchestrator-worker patterns
626
624
  - [LumenFlow Agent Capsule](./lumenflow-agent-capsule.md) — Full LumenFlow framework
627
625
  - [Canonical Lifecycle Map](./lumenflow-agent-capsule.md) — Command-mode matrix and handoff points
@@ -35,6 +35,8 @@ Quick reference for AI agents working in LumenFlow projects.
35
35
 
36
36
  | Action | Why |
37
37
  | ------------------------------------ | --------------------------------- |
38
+ | Run `--help` before first use | Prevents retry cascades |
39
+ | Check lanes before `wu:create` | Lane names are project-specific |
38
40
  | Read WU spec first | Understand scope |
39
41
  | cd to worktree after claim | Isolation |
40
42
  | Write tests before code | TDD |
@@ -75,13 +77,21 @@ Audit logs:
75
77
 
76
78
  ## Error Handling
77
79
 
78
- ### Max 3 Attempts
80
+ ### Max 3 Attempts (Constraint 10 — Non-Negotiable)
79
81
 
80
- If same error happens 3 times:
82
+ If the same operation fails 3 times: **STOP. Do not retry.**
83
+
84
+ Retry loops create cascading mess (orphaned commits, diverged branches, locked lanes)
85
+ that the user must clean up manually.
81
86
 
82
87
  1. Stop trying
83
- 2. Document what happened
84
- 3. Ask for help
88
+ 2. Summarise all 3 attempts and their errors
89
+ 3. Present your diagnosis and options to the user
90
+ 4. Wait for direction
91
+
92
+ **What counts as "same operation":** Retrying `wu:create` with slightly different flags
93
+ after each validation error is one operation failing multiple times. The fix is `--help`,
94
+ not guess-and-retry.
85
95
 
86
96
  ### Gate Failures
87
97
 
@@ -344,6 +344,102 @@ See the [WU Sizing Guide](../../wu-sizing-guide.md) section 1.5 for the full con
344
344
 
345
345
  ---
346
346
 
347
+ ## Mistake 14: Not Running --help Before First Use
348
+
349
+ ### Wrong
350
+
351
+ ```bash
352
+ # Agent guesses wu:create flags, misses required ones
353
+ pnpm wu:create --lane "Portal: UI" --title "Add feature" --description "..."
354
+ # Error: Unknown parent lane "Portal"
355
+
356
+ pnpm wu:create --lane "Experience: Auth" --title "Add feature" --description "..."
357
+ # Error: --test-paths-manual is required
358
+
359
+ pnpm wu:create --lane "Experience: Auth" --title "Add feature" --description "..." --test-paths-manual "..."
360
+ # Error: --spec-refs is required for type: feature
361
+
362
+ pnpm wu:create --lane "Experience: Auth" --title "Add feature" --description "..." --test-paths-manual "..." --spec-refs "..."
363
+ # Error: plan already exists
364
+
365
+ # Six attempts later, agent has burned context and user patience
366
+ ```
367
+
368
+ ### Right
369
+
370
+ ```bash
371
+ # Run --help ONCE before first use
372
+ pnpm wu:create --help
373
+ # Now you know every required flag, valid lane format, and option
374
+
375
+ # First attempt succeeds
376
+ pnpm wu:create --lane "Experience: Auth" --title "Add feature" \
377
+ --description "..." --acceptance "..." \
378
+ --code-paths "src/..." --test-paths-unit "src/..." \
379
+ --test-paths-manual "..." --spec-refs "..." --exposure ui
380
+ ```
381
+
382
+ **Rule:** `--help` before first use is mandatory (see AGENTS.md rule #2). One `--help` call prevents an entire retry cascade. If you still fail after reading `--help`, that's a real problem worth escalating — not a reason to guess again.
383
+
384
+ ---
385
+
386
+ ## Mistake 15: Guessing Lane Names
387
+
388
+ ### Wrong
389
+
390
+ ```bash
391
+ # Agent invents a lane name that doesn't exist
392
+ pnpm wu:create --lane "Portal: UI" --title "..."
393
+ # Error: Unknown parent lane: "Portal"
394
+ ```
395
+
396
+ ### Right
397
+
398
+ ```bash
399
+ # Check what lanes exist first
400
+ pnpm lane:status
401
+
402
+ # Or infer the right lane from file paths
403
+ pnpm wu:infer-lane --paths "src/app/clients/[slug]/client-portal.tsx" \
404
+ --desc "Add light mode to client portal"
405
+
406
+ # Then use the suggested lane
407
+ pnpm wu:create --lane "Experience: Auth" --title "..."
408
+ ```
409
+
410
+ **Rule:** Lane names are project-specific and defined in `workspace.yaml`. Never guess them. Run `pnpm lane:status` or `pnpm wu:infer-lane` to discover valid lanes before creating a WU.
411
+
412
+ ---
413
+
414
+ ## Mistake 16: Retry Loops Instead of Escalating
415
+
416
+ ### Wrong
417
+
418
+ ```
419
+ Attempt 1: wu:create fails (wrong lane) → try different lane
420
+ Attempt 2: wu:create fails (missing field) → add field
421
+ Attempt 3: wu:create fails (missing another field) → add field
422
+ Attempt 4: wu:create fails (stale plan) → delete plan, retry
423
+ Attempt 5: wu:create fails (inode exhaustion) → try to diagnose
424
+ Attempt 6: wu:create fails (inode exhaustion) → ask user to clean up
425
+ # Agent has burned 20 minutes on what should have been a 30-second operation
426
+ ```
427
+
428
+ ### Right
429
+
430
+ ```
431
+ Attempt 1: wu:create fails → read the error carefully
432
+ Attempt 2: wu:create fails → try the fix the error suggested
433
+ Attempt 3: wu:create fails → STOP. Escalate to user:
434
+
435
+ "wu:create has failed 3 times. Errors were: [X], [Y], [Z].
436
+ Root cause appears to be [diagnosis]. Would you like me to [option]?"
437
+ ```
438
+
439
+ **Rule:** See [Constraint 10](../../../../../.lumenflow/constraints.md) — stop and escalate after 3 failures. Retry loops create cascading mess (orphaned commits, diverged branches, locked lanes) that the user then has to clean up manually.
440
+
441
+ ---
442
+
347
443
  ## Quick Checklist
348
444
 
349
445
  Before starting any WU:
@@ -36,7 +36,7 @@ Run `--help` first, then run the real command with explicit flags.
36
36
  | Tooling Operations | `pnpm lumenflow:upgrade --help` | `pnpm lumenflow:upgrade --latest` |
37
37
  | WU Lifecycle | `pnpm wu:claim --help` | `pnpm wu:claim --id WU-1561 --lane "Operations: Tooling"` |
38
38
  | WU Maintenance | `pnpm wu:recover --help` | `pnpm wu:recover --id WU-1561` |
39
- | Gates & Quality | `pnpm gates --help` | `pnpm gates --docs-only` |
39
+ | Gates & Quality | `pnpm gates --help` | `pnpm gates:docs` |
40
40
  | Memory & Sessions | `pnpm mem:checkpoint --help` | `pnpm mem:checkpoint --wu WU-1561` |
41
41
  | State Management | `pnpm state:doctor --help` | `pnpm state:doctor --json` |
42
42
  | Repo-Only Scripts | `pnpm docs:validate --help` | `pnpm docs:validate` |
@@ -178,27 +178,28 @@ without explicit human instruction.**
178
178
 
179
179
  ## Gates & Quality
180
180
 
181
- | Command | Description |
182
- | ------------------------------------------------------------------ | ----------------------------------------------- |
183
- | `pnpm gates` | Run all quality gates |
184
- | `pnpm gates --docs-only` | Run gates for docs changes |
185
- | `pnpm format` | Format all files (Prettier) |
186
- | `pnpm format:check` | Check formatting without changes |
187
- | `pnpm lint` | Run ESLint |
188
- | `pnpm typecheck` | Run TypeScript type checking |
189
- | `pnpm test` | Run all tests (Vitest) |
190
- | `pnpm spec:linter` | Validate WU specs (all) ¹ |
191
- | `pnpm lane:health` | Check lane config health |
192
- | `pnpm lane:suggest --output workspace.lanes.yaml` | Generate a workspace lane-definition snippet |
193
- | `pnpm lane:status` | Show lane lifecycle status |
194
- | `pnpm lane:setup` | Create/update draft lane config |
195
- | `pnpm lane:validate` | Validate lane draft artifacts |
196
- | `pnpm lane:lock` | Lock lane lifecycle for WU create |
197
- | `pnpm lane:edit --name <L>` | Edit lane definition (rename, wip-limit, paths) |
198
- | `pnpm gate:co-change --add --name <N> --trigger <G> --require <G>` | Add co-change gate rule |
199
- | `pnpm gate:co-change --remove --name <N>` | Remove co-change gate rule |
200
- | `pnpm gate:co-change --edit --name <N> --severity <S>` | Edit co-change gate rule |
201
- | `pnpm gate:co-change --list` | List all co-change rules (built-in + custom) |
181
+ | Command | Description |
182
+ | ------------------------------------------------------------------ | ---------------------------------------------------- |
183
+ | `pnpm gates` | Run all quality gates |
184
+ | `pnpm gates:docs` | Preferred docs-only alias (`pnpm gates --docs-only`) |
185
+ | `pnpm gates --docs-only` | Equivalent flag form for docs-only gates |
186
+ | `pnpm format` | Format all files (Prettier) |
187
+ | `pnpm format:check` | Check formatting without changes |
188
+ | `pnpm lint` | Run ESLint |
189
+ | `pnpm typecheck` | Run TypeScript type checking |
190
+ | `pnpm test` | Run all tests (Vitest) |
191
+ | `pnpm spec:linter` | Validate WU specs (all) ¹ |
192
+ | `pnpm lane:health` | Check lane config health |
193
+ | `pnpm lane:suggest --output workspace.lanes.yaml` | Generate a workspace lane-definition snippet |
194
+ | `pnpm lane:status` | Show lane lifecycle status |
195
+ | `pnpm lane:setup` | Create/update draft lane config |
196
+ | `pnpm lane:validate` | Validate lane draft artifacts |
197
+ | `pnpm lane:lock` | Lock lane lifecycle for WU create |
198
+ | `pnpm lane:edit --name <L>` | Edit lane definition (rename, wip-limit, paths) |
199
+ | `pnpm gate:co-change --add --name <N> --trigger <G> --require <G>` | Add co-change gate rule |
200
+ | `pnpm gate:co-change --remove --name <N>` | Remove co-change gate rule |
201
+ | `pnpm gate:co-change --edit --name <N> --severity <S>` | Edit co-change gate rule |
202
+ | `pnpm gate:co-change --list` | List all co-change rules (built-in + custom) |
202
203
 
203
204
  ¹ **Script aliases:** `spec:linter` and `tasks:validate` are pnpm script aliases
204
205
  for `wu:validate --all`. They are not standalone CLI commands.
@@ -73,7 +73,8 @@ For documentation changes, use the fast path:
73
73
 
74
74
  ```bash
75
75
  # Skip lint/typecheck/tests for docs
76
- pnpm gates --docs-only
76
+ pnpm gates:docs
77
+ # Equivalent flag form: pnpm gates --docs-only
77
78
  ```
78
79
 
79
80
  ---
@@ -197,7 +197,7 @@ LUMENFLOW_CLOUD=1 pnpm wu:claim --id WU-XXXX --lane "Lane Name"
197
197
  These are the mistakes agents make most often. Memorize these before reading anything else:
198
198
 
199
199
  1. **wu:done deletes the worktree.** After it completes, your shell CWD is invalid. Immediately `cd` back to the project root.
200
- 2. **When wu:done fails with a non-fast-forward error, just rerun it.** It has built-in auto-rebase. Never manually `git rebase` on main.
200
+ 2. **When wu:done reports branch drift or a non-fast-forward error, rerun it from main.** It auto-rebases by default when it can. Never manually `git rebase` on main.
201
201
  3. **Always run `--help` before first use of any command.** Don't guess flags — 30 seconds reading help saves 5 minutes of failed attempts.
202
202
  4. **Never `pnpm update @lumenflow/*` directly.** Use `pnpm lumenflow:upgrade --latest` (uses micro-worktree isolation).
203
203
  5. **State files are auto-generated.** Never manually edit `wu-events.jsonl`, `backlog.md`, or `status.md` — lifecycle commands manage them.
@@ -459,11 +459,11 @@ cd <project-root> && pnpm wu:done --id WU-XXX --skip-gates \
459
459
 
460
460
  Do not use `git stash`, switch local main, or otherwise mutate main just to prove a pre-existing failure.
461
461
 
462
- ### Scenario 6: wu:done fails with non-fast-forward error
462
+ ### Scenario 6: wu:done reports branch drift or a non-fast-forward error
463
463
 
464
464
  **Cause:** Another agent or process pushed to main between your fetch and push (race condition).
465
465
 
466
- **Fix:** Just rerun `wu:done`. It has built-in auto-rebase that handles this cleanly.
466
+ **Fix:** Rerun `wu:done` from main. It has built-in auto-rebase for this case. If the rerun still fails with a real conflict, resolve the conflict in the worktree, rerun `wu:prep` if needed, then return to main and rerun `wu:done`.
467
467
 
468
468
  ```bash
469
469
  # WRONG - never manually rebase main
@@ -65,6 +65,9 @@ cd /path/to/main && pnpm wu:done --id WU-XXX
65
65
  # 3. Report success with the wu:done output
66
66
  ```
67
67
 
68
+ If `wu:done` reports branch drift, parallel completions, or a non-fast-forward push, rerun it from
69
+ main. It auto-rebases by default when possible. Do not manually rebase `main`.
70
+
68
71
  ---
69
72
 
70
73
  ## What wu:prep Does (WU-1223)
@@ -80,7 +83,7 @@ When you run `pnpm wu:prep --id WU-XXX` from a worktree:
80
83
  When you run `pnpm wu:done --id WU-XXX` from main:
81
84
 
82
85
  1. Validates you're in main checkout (errors if in worktree)
83
- 2. Fast-forward merges the lane branch to main
86
+ 2. Merges the lane branch to main and may auto-rebase first if parallel work landed
84
87
  3. Creates the done stamp
85
88
  4. Updates status and backlog docs
86
89
  5. Removes the worktree
@@ -125,6 +128,71 @@ Feature WUs **must** include `spec_refs` (use `pnpm wu:create --plan` if the pla
125
128
 
126
129
  ---
127
130
 
131
+ ### "non-fast-forward" or "branch is behind main"
132
+
133
+ If `wu:done` reports branch drift or a non-fast-forward push, another completion landed while your
134
+ WU was in progress.
135
+
136
+ ```bash
137
+ # Retry from main first
138
+ cd /path/to/main
139
+ pnpm wu:done --id WU-XXX
140
+ ```
141
+
142
+ - If the rerun succeeds, you are done.
143
+ - If the rerun reports an auto-rebase conflict, return to the worktree, resolve the conflict there,
144
+ rerun `pnpm wu:prep --id WU-XXX` if needed, then retry `wu:done` from main.
145
+ - Do **not** manually `git rebase` the main checkout.
146
+
147
+ ---
148
+
149
+ ## wu:create Failure Recovery
150
+
151
+ `wu:create` uses a micro-worktree to commit the spec atomically. If it fails mid-transaction
152
+ (rebase conflict, disk full, inode exhaustion, network error), it can leave main in an
153
+ inconsistent state.
154
+
155
+ ### Symptoms
156
+
157
+ - `git log` shows main is ahead of `origin/main` by 1 commit (the orphaned spec commit)
158
+ - `wu:delete` fails because main can't fast-forward
159
+ - Subsequent `wu:create` or `wu:claim` operations fail
160
+
161
+ ### Recovery
162
+
163
+ **Step 1: Check the divergence**
164
+
165
+ ```bash
166
+ git log --oneline origin/main..main
167
+ # If you see a single spec commit like "docs: create wu-XXX for ...", that's the orphan
168
+ ```
169
+
170
+ **Step 2: Ask the user to discard the orphaned commit**
171
+
172
+ Agents cannot run `git reset --hard` (forbidden command). Present this to the user:
173
+
174
+ ```
175
+ wu:create failed mid-transaction and left an orphaned spec commit on main.
176
+ Main is now 1 ahead of origin/main. The safe fix is:
177
+
178
+ git fetch origin && git reset --hard origin/main
179
+
180
+ This discards only the failed spec commit. No other work is lost.
181
+ Shall I proceed after you run this?
182
+ ```
183
+
184
+ **Step 3: After user resets main, retry wu:create**
185
+
186
+ Do NOT attempt to recover by rebasing, cherry-picking, or manually editing state files.
187
+ The clean path is: discard the orphan, retry the command.
188
+
189
+ ### Prevention
190
+
191
+ - Run `wu:create --help` before first use to avoid validation failures that trigger retries
192
+ - If `wu:create` fails, check `git log --oneline -3` before retrying — if the spec commit
193
+ landed locally but wasn't pushed, you already have an orphan
194
+ - After 3 failed attempts, stop and escalate (Constraint 10)
195
+
128
196
  ---
129
197
 
130
198
  ## Cloud / Branch-PR Mode