@lumenflow/cli 3.19.0 → 3.21.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 (36) hide show
  1. package/dist/gates-runners.js +5 -4
  2. package/dist/gates-runners.js.map +1 -1
  3. package/dist/gates-utils.js +71 -0
  4. package/dist/gates-utils.js.map +1 -1
  5. package/dist/init-templates.js +30 -22
  6. package/dist/init-templates.js.map +1 -1
  7. package/dist/wu-prune.js +2 -2
  8. package/dist/wu-prune.js.map +1 -1
  9. package/dist/wu-verify.js +22 -17
  10. package/dist/wu-verify.js.map +1 -1
  11. package/package.json +8 -8
  12. package/packs/agent-runtime/.turbo/turbo-build.log +1 -1
  13. package/packs/agent-runtime/package.json +1 -1
  14. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  15. package/packs/sidekick/README.md +118 -113
  16. package/packs/sidekick/manifest-schema.ts +15 -228
  17. package/packs/sidekick/manifest.ts +107 -7
  18. package/packs/sidekick/manifest.yaml +199 -1
  19. package/packs/sidekick/package.json +4 -1
  20. package/packs/sidekick/policy-factory.ts +38 -0
  21. package/packs/sidekick/tool-impl/channel-tools.ts +99 -0
  22. package/packs/sidekick/tool-impl/memory-tools.ts +86 -1
  23. package/packs/sidekick/tool-impl/routine-tools.ts +156 -2
  24. package/packs/sidekick/tool-impl/storage.ts +6 -5
  25. package/packs/sidekick/tool-impl/task-tools.ts +186 -4
  26. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  27. package/packs/software-delivery/package.json +1 -1
  28. package/templates/core/.lumenflow/constraints.md.template +68 -3
  29. package/templates/core/LUMENFLOW.md.template +26 -26
  30. package/templates/core/_frameworks/lumenflow/wu-sizing-guide.md.template +3 -5
  31. package/templates/core/ai/onboarding/agent-safety-card.md.template +14 -4
  32. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +96 -0
  33. package/templates/core/ai/onboarding/quick-ref-commands.md.template +50 -39
  34. package/templates/core/ai/onboarding/rapid-prototyping.md +2 -1
  35. package/templates/core/ai/onboarding/starting-prompt.md.template +5 -4
  36. package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +69 -1
@@ -258,7 +258,7 @@ For the full worktree lifecycle (parallel execution, bootstrap, isolation guaran
258
258
  ## Definition of Done
259
259
 
260
260
  - Acceptance criteria satisfied
261
- - Gates green (`pnpm gates` or `pnpm gates --docs-only`)
261
+ - Gates green (`pnpm gates` or `pnpm gates:docs`; `pnpm gates --docs-only` is the equivalent flag form)
262
262
  - WU YAML status = `done`
263
263
  - `.lumenflow/stamps/WU-<id>.done` exists
264
264
  - **wu:done has been run** (not just documented as "to do")
@@ -269,31 +269,31 @@ For the full worktree lifecycle (parallel execution, bootstrap, isolation guaran
269
269
 
270
270
  > **Complete CLI reference (100+ commands):** See [quick-ref-commands.md]({{QUICK_REF_LINK}}). Always run `<command> --help` for the authoritative option list.
271
271
 
272
- | Command | Description |
273
- | ------------------------- | ----------------------------------------------------------------------- |
274
- | `pnpm wu:create` | Create new WU spec |
275
- | `pnpm wu:claim` | Claim WU, update canonical state, create worktree |
276
- | `pnpm wu:prep` | Run gates in worktree, prep for wu:done |
277
- | `pnpm wu:done` | Complete WU (merge, stamp, cleanup) |
278
- | `pnpm wu:status` | Show WU status, location, and valid commands |
279
- | `pnpm wu:recover` | Analyze and fix WU state inconsistencies |
280
- | `pnpm wu:block` | Block WU (transitions to blocked, frees lane) |
281
- | `pnpm wu:unblock` | Unblock WU (transitions to in_progress) |
282
- | `pnpm wu:release` | Release orphaned WU (in_progress to ready for reclaim) |
283
- | `pnpm wu:brief` | **MANDATORY after wu:claim.** Generate handoff prompt + record evidence |
284
- | `pnpm wu:delegate` | Generate prompt + record lineage + brief hash attestation |
285
- | `pnpm wu:escalate` | Show or resolve WU escalation status |
286
- | `pnpm wu:verify` | Verify WU completion (stamp, commit, clean tree) |
287
- | `pnpm wu:delete` | Delete WU spec and cleanup |
288
- | `pnpm gates` | Run quality gates (`--docs-only` for docs WUs) |
289
- | `pnpm lumenflow:commands` | List all public commands (primary + alias + legacy) |
290
- | `pnpm docs:generate` | Regenerate CLI/config reference docs from source |
291
- | `pnpm docs:validate` | Verify generated docs are up-to-date |
292
- | `pnpm lane:status` | Show lane lifecycle status + next step |
293
- | `pnpm lane:setup` | Create/update draft lane artifacts |
294
- | `pnpm lane:validate` | Validate lane artifacts before lock |
295
- | `pnpm lane:lock` | Lock lane lifecycle for delivery WUs |
296
- | `pnpm mem:checkpoint` | Save memory checkpoint |
272
+ | Command | Description |
273
+ | ------------------------- | ------------------------------------------------------------------------------- |
274
+ | `pnpm wu:create` | Create new WU spec |
275
+ | `pnpm wu:claim` | Claim WU, update canonical state, create worktree |
276
+ | `pnpm wu:prep` | Run gates in worktree, prep for wu:done |
277
+ | `pnpm wu:done` | Complete WU (merge, stamp, cleanup) |
278
+ | `pnpm wu:status` | Show WU status, location, and valid commands |
279
+ | `pnpm wu:recover` | Analyze and fix WU state inconsistencies |
280
+ | `pnpm wu:block` | Block WU (transitions to blocked, frees lane) |
281
+ | `pnpm wu:unblock` | Unblock WU (transitions to in_progress) |
282
+ | `pnpm wu:release` | Release orphaned WU (in_progress to ready for reclaim) |
283
+ | `pnpm wu:brief` | **MANDATORY after wu:claim.** Generate handoff prompt + record evidence |
284
+ | `pnpm wu:delegate` | Generate prompt + record lineage + brief hash attestation |
285
+ | `pnpm wu:escalate` | Show or resolve WU escalation status |
286
+ | `pnpm wu:verify` | Verify WU completion (stamp, commit, clean tree) |
287
+ | `pnpm wu:delete` | Delete WU spec and cleanup |
288
+ | `pnpm gates` | Run quality gates (`pnpm gates:docs` for docs WUs; `--docs-only` is equivalent) |
289
+ | `pnpm lumenflow:commands` | List all public commands (primary + alias + legacy) |
290
+ | `pnpm docs:generate` | Regenerate CLI/config reference docs from source |
291
+ | `pnpm docs:validate` | Verify generated docs are up-to-date |
292
+ | `pnpm lane:status` | Show lane lifecycle status + next step |
293
+ | `pnpm lane:setup` | Create/update draft lane artifacts |
294
+ | `pnpm lane:validate` | Validate lane artifacts before lock |
295
+ | `pnpm lane:lock` | Lock lane lifecycle for delivery WUs |
296
+ | `pnpm mem:checkpoint` | Save memory checkpoint |
297
297
 
298
298
  Commands include **context-aware validation** that checks location, WU status, and git state. When validation fails, commands provide copy-paste ready fix commands. Configure in `workspace.yaml` under `software_delivery.experimental.context_validation`.
299
299
  The Starlight CLI reference page is intentionally curated to primary commands; use `pnpm lumenflow:commands` for complete discovery.
@@ -102,7 +102,7 @@ Documentation WUs (`type: documentation`) have relaxed file count thresholds bec
102
102
  id: WU-XXX
103
103
  type: documentation
104
104
  code_paths:
105
- - docs/operations/_frameworks/lumenflow/*.md
105
+ - {{DOCS_OPERATIONS_PATH}}/_frameworks/lumenflow/*.md
106
106
  - docs/01-product/*.md
107
107
  ```
108
108
 
@@ -320,7 +320,7 @@ The tooling operates in two modes:
320
320
  ```
321
321
  [wu:create] WARNING (WU-100): sizing: estimated_files (30) exceeds Simple
322
322
  threshold (20). Consider adding exception_type/exception_reason or splitting
323
- the WU. See docs/operations/_frameworks/lumenflow/wu-sizing-guide.md.
323
+ the WU. See {{DOCS_OPERATIONS_PATH}}/_frameworks/lumenflow/wu-sizing-guide.md.
324
324
  ```
325
325
 
326
326
  **Strict mode (`--strict-sizing`):** `wu:brief` supports a `--strict-sizing` flag that blocks when:
@@ -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` |
@@ -143,9 +143,9 @@ you want to refresh docs without upgrading packages (e.g., after manually editin
143
143
  | `pnpm approval:request --type <type> --subject <json>` | Request control-plane approval for an action |
144
144
  | `pnpm approval:review --id <approvalId> --decision <decision>` | Resolve an approval decision (`approved`/`rejected`/`expired`) |
145
145
  | `pnpm approval:list [--status <status>]` | List approvals with optional status/type filters |
146
- | `pnpm wu:block --id WU-XXX --reason "..."` | Block WU with reason |
147
- | `pnpm wu:unblock --id WU-XXX` | Unblock WU |
148
- | `pnpm wu:release --id WU-XXX` | Release orphaned WU (in_progress to ready) |
146
+ | `pnpm wu:block --id WU-XXX --reason "..."` | Block WU with reason (ownership-guarded, v3.19.0) |
147
+ | `pnpm wu:unblock --id WU-XXX` | Unblock WU (ownership-guarded, v3.19.0) |
148
+ | `pnpm wu:release --id WU-XXX --reason "..."` | Release orphaned WU (ownership-guarded, v3.19.0) |
149
149
  | `pnpm wu:status --id WU-XXX` | Show WU status, location, valid commands |
150
150
  | `pnpm wu:brief --id WU-XXX --client <client>` | **MANDATORY after wu:claim.** Generate handoff prompt + record evidence. wu:done blocks without this (WU-2379) |
151
151
  | `pnpm wu:brief --id WU-XXX --no-context` | Generate prompt without memory context injection |
@@ -154,50 +154,61 @@ you want to refresh docs without upgrading packages (e.g., after manually editin
154
154
 
155
155
  ### WU Maintenance
156
156
 
157
- | Command | Description |
158
- | -------------------------------- | ------------------------------------------------ |
159
- | `pnpm wu:validate --id WU-XXX` | Validate WU spec |
160
- | `pnpm wu:preflight --id WU-XXX` | Pre-flight checks before wu:done |
161
- | `pnpm wu:verify --id WU-XXX` | Verify WU completion (stamp, commit, clean tree) |
162
- | `pnpm wu:recover --id WU-XXX` | Analyze and fix WU state inconsistencies |
163
- | `pnpm wu:repair --id WU-XXX` | Repair WU state issues |
164
- | `pnpm wu:prune` | Clean stale worktrees |
165
- | `pnpm wu:cleanup --id WU-XXX` | Cleanup after PR merge (PR-only) |
166
- | `pnpm wu:deps --id WU-XXX` | Show WU dependencies |
167
- | `pnpm wu:infer-lane --id WU-XXX` | Infer lane from code paths/description |
168
- | `pnpm wu:delete --id WU-XXX` | Delete WU spec and cleanup |
169
- | `pnpm wu:unlock-lane --lane <L>` | Unlock stuck lane |
170
- | `pnpm wu:proto --lane <Lane>` | Create WU prototype (lightweight draft) |
157
+ | Command | Description |
158
+ | -------------------------------- | ----------------------------------------------------- |
159
+ | `pnpm wu:validate --id WU-XXX` | Validate WU spec |
160
+ | `pnpm wu:preflight --id WU-XXX` | Pre-flight checks before wu:done |
161
+ | `pnpm wu:verify --id WU-XXX` | Verify WU completion (stamp, commit, clean tree) |
162
+ | `pnpm wu:recover --id WU-XXX` | Analyze and fix WU state (ownership-guarded, v3.19.0) |
163
+ | `pnpm wu:repair --id WU-XXX` | Repair WU state issues |
164
+ | `pnpm wu:prune` | Clean stale worktrees |
165
+ | `pnpm wu:cleanup --id WU-XXX` | Cleanup after PR merge (PR-only) |
166
+ | `pnpm wu:deps --id WU-XXX` | Show WU dependencies |
167
+ | `pnpm wu:infer-lane --id WU-XXX` | Infer lane from code paths/description |
168
+ | `pnpm wu:delete --id WU-XXX` | Delete WU spec and cleanup |
169
+ | `pnpm wu:unlock-lane --lane <L>` | Unlock stuck lane |
170
+ | `pnpm wu:proto --lane <Lane>` | Create WU prototype (lightweight draft) |
171
+
172
+ **Ownership guards (v3.19.0, WU-2468):** `wu:block`, `wu:unblock`, `wu:release`, and `wu:recover`
173
+ validate session ownership before state mutations. If the WU belongs to another session, use
174
+ `--override-owner --reason "..."` to override (audited). **AGENTS: NEVER use --override-owner
175
+ without explicit human instruction.**
171
176
 
172
177
  ---
173
178
 
174
179
  ## Gates & Quality
175
180
 
176
- | Command | Description |
177
- | ------------------------------------------------------------------ | ----------------------------------------------- |
178
- | `pnpm gates` | Run all quality gates |
179
- | `pnpm gates --docs-only` | Run gates for docs changes |
180
- | `pnpm format` | Format all files (Prettier) |
181
- | `pnpm format:check` | Check formatting without changes |
182
- | `pnpm lint` | Run ESLint |
183
- | `pnpm typecheck` | Run TypeScript type checking |
184
- | `pnpm test` | Run all tests (Vitest) |
185
- | `pnpm spec:linter` | Validate WU specs (all) ¹ |
186
- | `pnpm lane:health` | Check lane config health |
187
- | `pnpm lane:suggest --output workspace.lanes.yaml` | Generate a workspace lane-definition snippet |
188
- | `pnpm lane:status` | Show lane lifecycle status |
189
- | `pnpm lane:setup` | Create/update draft lane config |
190
- | `pnpm lane:validate` | Validate lane draft artifacts |
191
- | `pnpm lane:lock` | Lock lane lifecycle for WU create |
192
- | `pnpm lane:edit --name <L>` | Edit lane definition (rename, wip-limit, paths) |
193
- | `pnpm gate:co-change --add --name <N> --trigger <G> --require <G>` | Add co-change gate rule |
194
- | `pnpm gate:co-change --remove --name <N>` | Remove co-change gate rule |
195
- | `pnpm gate:co-change --edit --name <N> --severity <S>` | Edit co-change gate rule |
196
- | `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) |
197
203
 
198
204
  ¹ **Script aliases:** `spec:linter` and `tasks:validate` are pnpm script aliases
199
205
  for `wu:validate --all`. They are not standalone CLI commands.
200
206
 
207
+ **Conditional gates (v3.19.0, WU-2448):** Define pattern-triggered commands in
208
+ `workspace.yaml > software_delivery.gates.conditional_commands`. Commands with `trigger_patterns`
209
+ only run when matching files change. Supports `error` (blocks), `warn` (logs), and `off` (skip)
210
+ severity levels. See workspace-spec.mdx for schema.
211
+
201
212
  **Formatting: always scope to changed files only.**
202
213
  Use `pnpm prettier --write <changed-files...>` — never unscoped `pnpm format`.
203
214
  Running `pnpm format` reformats every file in the repo, creating hundreds of
@@ -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,12 +197,13 @@ 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.
204
204
  6. **wu:edit requires a clean worktree.** Commit `wu-events.jsonl` and other changes before running `wu:edit`.
205
205
  7. **Don't edit on main then stash to a worktree.** If a hook blocks you on main, that means you need a WU. Create one and work in the worktree from the start.
206
+ 8. **Don't modify another agent's WU to free a lane.** `wu:block`, `wu:unblock`, `wu:release`, and `wu:recover` enforce ownership guards (v3.19.0). If you hit a `SESSION OWNERSHIP VIOLATION`, wait for the owning WU to complete or block itself — never use `--override-owner` without explicit human instruction.
206
207
 
207
208
  ---
208
209
 
@@ -458,11 +459,11 @@ cd <project-root> && pnpm wu:done --id WU-XXX --skip-gates \
458
459
 
459
460
  Do not use `git stash`, switch local main, or otherwise mutate main just to prove a pre-existing failure.
460
461
 
461
- ### Scenario 6: wu:done fails with non-fast-forward error
462
+ ### Scenario 6: wu:done reports branch drift or a non-fast-forward error
462
463
 
463
464
  **Cause:** Another agent or process pushed to main between your fetch and push (race condition).
464
465
 
465
- **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`.
466
467
 
467
468
  ```bash
468
469
  # WRONG - never manually rebase main
@@ -527,7 +528,7 @@ Default profiles:
527
528
 
528
529
  - Behavior/logic changes: follow project policy (`methodology.testing`: `tdd`, `test-after`, or `none`).
529
530
  - Structured-content-only changes (`.yaml/.yml/.json/.md/.mdx`): use parse/schema/lint/eval evidence; TDD checkpoint is omitted.
530
- - UI presentation hints: prefer smoke/manual/integration/E2E verification and use unit tests for pure logic or explicitly required checks.
531
+ - UI presentation hints: prefer smoke/manual/integration/E2E verification, never assert inline styles, CSS values, exact copy, or DOM shape, and use unit tests only for pure logic or explicitly required checks.
531
532
 
532
533
  Common override points include `visual-directive`, `structured-content-directive`,
533
534
  `verification-requirements`, and `design-context-ui`.
@@ -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