devrites 4.1.0 → 4.3.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 (133) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/docs/engine/commands.md +69 -6
  4. package/docs/orchestration.md +6 -3
  5. package/engine/go.mod +1 -1
  6. package/engine/internal/gate/gate.go +154 -46
  7. package/engine/internal/gate/gate_test.go +290 -2
  8. package/engine/internal/gate/readiness_binding.go +66 -100
  9. package/engine/internal/gate/readiness_binding_test.go +126 -3
  10. package/engine/internal/lib/cli_observe.go +66 -0
  11. package/engine/internal/lib/observe_summary.go +79 -0
  12. package/engine/internal/lib/resolve.go +6 -6
  13. package/engine/internal/lib/skilltrust.go +196 -0
  14. package/engine/internal/lib/taskgraph.go +162 -0
  15. package/engine/internal/lib/taskgraph_test.go +150 -0
  16. package/engine/internal/lib/workspace_read.go +29 -0
  17. package/engine/internal/parallel/cli.go +467 -0
  18. package/engine/internal/parallel/git.go +181 -0
  19. package/engine/internal/parallel/lease.go +244 -0
  20. package/engine/internal/parallel/ops.go +416 -0
  21. package/engine/internal/parallel/parallel_test.go +242 -0
  22. package/engine/internal/parallel/pathdisjoint.go +129 -0
  23. package/engine/internal/parallel/pathdisjoint_test.go +97 -0
  24. package/engine/internal/state/cmd/workflowmanifest/main.go +32 -3
  25. package/engine/internal/state/feature.go +1 -100
  26. package/engine/internal/state/observation.go +584 -0
  27. package/engine/internal/state/observation_open_other.go +9 -0
  28. package/engine/internal/state/observation_open_unix.go +12 -0
  29. package/engine/internal/state/observation_test.go +960 -0
  30. package/engine/internal/state/observation_unix_test.go +68 -0
  31. package/engine/internal/state/schema.go +60 -160
  32. package/engine/internal/state/state_test.go +489 -101
  33. package/engine/internal/state/status.go +97 -53
  34. package/engine/main.go +72 -3
  35. package/engine/root_routing_test.go +1 -1
  36. package/engine/tests/adr_0004_required_by_phase_test.go +16 -13
  37. package/engine/tests/adr_0011_define_plan_test.go +14 -12
  38. package/engine/tests/gate_test.go +403 -28
  39. package/engine/tests/workspace_observation_migration_test.go +1065 -0
  40. package/pack/.claude/skills/devrites-debug-recovery/SKILL.md +1 -10
  41. package/pack/.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  42. package/pack/.claude/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  43. package/pack/.claude/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  44. package/pack/.claude/skills/devrites-lib/reference/standards/skill-authoring.md +22 -0
  45. package/pack/.claude/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  46. package/pack/.claude/skills/rite-autocomplete/SKILL.md +98 -146
  47. package/pack/.claude/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  48. package/pack/.claude/skills/rite-autocomplete/reference/loop.md +96 -134
  49. package/pack/.claude/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  50. package/pack/.claude/skills/rite-build/SKILL.md +46 -81
  51. package/pack/.claude/skills/rite-build/reference/afk-discipline.md +19 -25
  52. package/pack/.claude/skills/rite-build/reference/checkpoint-protocol.md +29 -59
  53. package/pack/.claude/skills/rite-build/reference/one-slice-cycle.md +8 -3
  54. package/pack/.claude/skills/rite-build/reference/output.md +2 -0
  55. package/pack/.claude/skills/rite-build/reference/parallel-batch.md +64 -0
  56. package/pack/.claude/skills/rite-build/reference/phase-contract.md +9 -22
  57. package/pack/.claude/skills/rite-build/reference/wright-dispatch.md +7 -3
  58. package/pack/.claude/skills/rite-clarify/reference/anti-patterns.md +24 -0
  59. package/pack/.claude/skills/rite-customize/SKILL.md +3 -2
  60. package/pack/.claude/skills/rite-doctor/SKILL.md +5 -1
  61. package/pack/.claude/skills/rite-plan/SKILL.md +17 -17
  62. package/pack/.claude/skills/rite-plan/reference/anti-patterns.md +11 -1
  63. package/pack/.claude/skills/rite-plan/reference/dependency-graph.md +3 -0
  64. package/pack/.claude/skills/rite-plan/reference/replan-and-repair.md +10 -3
  65. package/pack/.claude/skills/rite-prove/SKILL.md +95 -153
  66. package/pack/.claude/skills/rite-vet/SKILL.md +121 -174
  67. package/pack/.claude/skills/rite-vet/reference/anti-patterns.md +14 -2
  68. package/pack/.claude/skills/rite-vet/reference/artifacts.md +10 -6
  69. package/pack/.claude/skills/rite-vet/reference/depth.md +10 -3
  70. package/pack/.claude/skills/rite-vet/reference/review-axes.md +12 -4
  71. package/pack/generated/claude/skills/devrites-debug-recovery/SKILL.md +1 -10
  72. package/pack/generated/claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  73. package/pack/generated/claude/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  74. package/pack/generated/claude/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  75. package/pack/generated/claude/skills/devrites-lib/reference/standards/skill-authoring.md +22 -0
  76. package/pack/generated/claude/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  77. package/pack/generated/claude/skills/rite-autocomplete/SKILL.md +98 -146
  78. package/pack/generated/claude/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  79. package/pack/generated/claude/skills/rite-autocomplete/reference/loop.md +96 -134
  80. package/pack/generated/claude/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  81. package/pack/generated/claude/skills/rite-build/SKILL.md +46 -81
  82. package/pack/generated/claude/skills/rite-build/reference/afk-discipline.md +19 -25
  83. package/pack/generated/claude/skills/rite-build/reference/checkpoint-protocol.md +29 -59
  84. package/pack/generated/claude/skills/rite-build/reference/one-slice-cycle.md +8 -3
  85. package/pack/generated/claude/skills/rite-build/reference/output.md +2 -0
  86. package/pack/generated/claude/skills/rite-build/reference/parallel-batch.md +64 -0
  87. package/pack/generated/claude/skills/rite-build/reference/phase-contract.md +9 -22
  88. package/pack/generated/claude/skills/rite-build/reference/wright-dispatch.md +7 -3
  89. package/pack/generated/claude/skills/rite-clarify/reference/anti-patterns.md +24 -0
  90. package/pack/generated/claude/skills/rite-customize/SKILL.md +3 -2
  91. package/pack/generated/claude/skills/rite-doctor/SKILL.md +5 -1
  92. package/pack/generated/claude/skills/rite-plan/SKILL.md +17 -17
  93. package/pack/generated/claude/skills/rite-plan/reference/anti-patterns.md +11 -1
  94. package/pack/generated/claude/skills/rite-plan/reference/dependency-graph.md +3 -0
  95. package/pack/generated/claude/skills/rite-plan/reference/replan-and-repair.md +10 -3
  96. package/pack/generated/claude/skills/rite-prove/SKILL.md +95 -153
  97. package/pack/generated/claude/skills/rite-vet/SKILL.md +121 -174
  98. package/pack/generated/claude/skills/rite-vet/reference/anti-patterns.md +14 -2
  99. package/pack/generated/claude/skills/rite-vet/reference/artifacts.md +10 -6
  100. package/pack/generated/claude/skills/rite-vet/reference/depth.md +10 -3
  101. package/pack/generated/claude/skills/rite-vet/reference/review-axes.md +12 -4
  102. package/pack/generated/codex/skills/devrites-debug-recovery/SKILL.md +1 -10
  103. package/pack/generated/codex/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md +30 -0
  104. package/pack/generated/codex/skills/devrites-lib/reference/standards/afk-hitl.md +2 -9
  105. package/pack/generated/codex/skills/devrites-lib/reference/standards/one-shot-actions.md +1 -6
  106. package/pack/generated/codex/skills/devrites-lib/reference/standards/skill-authoring.md +22 -0
  107. package/pack/generated/codex/skills/devrites-lib/reference/standards/workflow-artifacts.md +411 -102
  108. package/pack/generated/codex/skills/rite-autocomplete/SKILL.md +98 -146
  109. package/pack/generated/codex/skills/rite-autocomplete/reference/decision-policy.md +11 -5
  110. package/pack/generated/codex/skills/rite-autocomplete/reference/loop.md +96 -134
  111. package/pack/generated/codex/skills/rite-autocomplete/reference/stop-conditions.md +92 -131
  112. package/pack/generated/codex/skills/rite-build/SKILL.md +46 -81
  113. package/pack/generated/codex/skills/rite-build/reference/afk-discipline.md +19 -25
  114. package/pack/generated/codex/skills/rite-build/reference/checkpoint-protocol.md +29 -59
  115. package/pack/generated/codex/skills/rite-build/reference/one-slice-cycle.md +8 -3
  116. package/pack/generated/codex/skills/rite-build/reference/output.md +2 -0
  117. package/pack/generated/codex/skills/rite-build/reference/parallel-batch.md +64 -0
  118. package/pack/generated/codex/skills/rite-build/reference/phase-contract.md +9 -22
  119. package/pack/generated/codex/skills/rite-build/reference/wright-dispatch.md +7 -3
  120. package/pack/generated/codex/skills/rite-clarify/reference/anti-patterns.md +24 -0
  121. package/pack/generated/codex/skills/rite-customize/SKILL.md +3 -2
  122. package/pack/generated/codex/skills/rite-doctor/SKILL.md +5 -1
  123. package/pack/generated/codex/skills/rite-plan/SKILL.md +17 -17
  124. package/pack/generated/codex/skills/rite-plan/reference/anti-patterns.md +11 -1
  125. package/pack/generated/codex/skills/rite-plan/reference/dependency-graph.md +3 -0
  126. package/pack/generated/codex/skills/rite-plan/reference/replan-and-repair.md +10 -3
  127. package/pack/generated/codex/skills/rite-prove/SKILL.md +95 -153
  128. package/pack/generated/codex/skills/rite-vet/SKILL.md +121 -174
  129. package/pack/generated/codex/skills/rite-vet/reference/anti-patterns.md +14 -2
  130. package/pack/generated/codex/skills/rite-vet/reference/artifacts.md +10 -6
  131. package/pack/generated/codex/skills/rite-vet/reference/depth.md +10 -3
  132. package/pack/generated/codex/skills/rite-vet/reference/review-axes.md +12 -4
  133. package/package.json +1 -1
@@ -1,131 +1,92 @@
1
- # Stop conditions: when autocomplete must pause for a human
2
-
3
- On these conditions, write `state.md` (`awaiting_human` or `blocked`), report
4
- the reason and one resume command when an actual human/safety/access action can
5
- change the state, notify if configured, and stop. Exhausted agent-owned
6
- technical recovery is terminal for its unchanged causal fingerprint: record
7
- `Next step: none` and no runnable recovery command. `--ship` cannot bypass them.
8
- Closure of a prior fingerprint is progress, not exhaustion. A separately evidenced
9
- Critical/Important failed invariant starts its own bounded fingerprint; it never
10
- resets or extends the budget of the one just closed.
11
-
12
- An exhausted consumptive-action authorization is not technical-recovery
13
- exhaustion. It blocks another real action, but retained evidence of a new
14
- Critical/Important fingerprint must enter offline caller-owned recovery while its
15
- own no-progress budget remains. After affected Vet is READY, pause for fresh action
16
- authorization; never execute from the old GO.
17
-
18
- ## Always stop (irreversible-risk list: from `afk-hitl.md`)
19
-
20
- Regardless of `allow_gates` or `--ship`:
21
- - Destructive data migration (drop column/table, irreversible backfill).
22
- - Auth / authz boundary change.
23
- - Public-API break (response shape, removed endpoint, changed status semantics).
24
- - External-service contract change.
25
- - Filesystem destruction outside the workspace.
26
-
27
- Red checks are hard non-advance gates. Run bounded `devrites-debug-recovery`;
28
- on exhaustion, stop as a technical blocker unless human-owned.
29
-
30
- ## Not a stop: agent-owned backtracking
31
-
32
- `NEEDS_REPLAN` is not a stop condition under an active Autocomplete caller. It
33
- blocks forward advancement, persists the return cursor, and immediately routes
34
- Plan repair plus Recovery Vet. The same applies to any intermediate nested
35
- `STOP`/`Next step` whose underlying decision is agent-owned.
36
-
37
- Agent-owned backtracking is not a stop condition while its causal-fingerprint
38
- budget remains. The active caller invokes the earlier phase inline, follows Vet
39
- and any bounded remediation, then resumes the originating phase. Persist
40
- `Next step` for crash recovery, but do not surface it as a command the human must
41
- submit. Use the repaired finding's narrow Vet recheck to distinguish resolution,
42
- the same decisive failure, and a genuinely new Critical/Important invariant.
43
- Stop only after three no-progress attempts on the exact same fingerprint or when
44
- the remaining choice is a real human/safety/access gate.
45
-
46
- On technical exhaustion, preserve the fingerprint, reproduction, attempts, and
47
- dead ends, then stop without `/rite-plan unblock` or another phase command.
48
- Reinvocation with unchanged evidence remains blocked and does not reset the cap.
49
- Here `unchanged` means the same fingerprint already has three recorded
50
- no-progress corrections. A retained fingerprint with remaining offline budget is
51
- not terminal merely because `state.md` was written by the failed action or a prior
52
- session ended.
53
-
54
- A pre-ownership workflow-artifact writer stop is not unchanged evidence when the
55
- current contract supplies controlling-root materialization. Prior drafter/wright refusals do not count
56
- as root materialization attempts. Reopen only when exact paths and executable
57
- behavior passed Vet and there is **no controlling-root materialization attempt**;
58
- record the routing migration so it cannot reset again. Missing product slices,
59
- unresolved protocol choices, or a recorded root attempt remain under their normal
60
- gate/fingerprint rules. The first controlling-root failure is not exhaustion: it
61
- is the first no-progress result for the materializer fingerprint. If all targets
62
- still equal their recorded preimages, no real action ran, and only admitted bound
63
- temporaries remain, reopen an incorrectly persisted one-shot `1/1` terminal,
64
- preserve its evidence as attempt one, clean/repair/preflight offline, and continue
65
- within the shared three-attempt cap.
66
-
67
- Past evidence being irretrievable is not by itself terminal. When an in-scope
68
- trusted diagnostic seam can make the next retained fingerprint uniquely
69
- actionable, Autocomplete must run diagnostic-amplification Plan repair and narrow
70
- Vet inline, then pause for a fresh GO before the single evidence-acquisition
71
- attempt. Use `Next: none` only after proving no safe in-scope amplification seam
72
- exists, a real human/risk/scope gate owns it, or bounded recovery is exhausted.
73
-
74
- ## Stop on gate severity
75
-
76
- - `blocking` gate fires synchronous pause.
77
- - `escalating` gate fires pause, route to the specialist tag.
78
- - Any `questions.md` entry with `gate: validating` and `status: open` → pause (it is a
79
- seal NO-GO by definition; stop before reaching seal).
80
-
81
- ## Stop on strategic-review scope expansion (`/rite-temper`)
82
-
83
- - Any `expand` or added acceptance criterion pauses regardless of
84
- `allow_gates`/`--ship`. Only `hold-rigor` and `reduce-to-MVP` auto-apply;
85
- skipped low-stakes specs and those two modes do not pause.
86
-
87
- ## Stop on incomplete decision coverage (`/rite-clarify`)
88
-
89
- - Stop on any material Partial/Missing/unowned row or low-confidence, high-consequence
90
- assumption. Continue the up-front window with the next genuine decision packet; never arm
91
- AFK or carry it into build. Resolve facts and reversible choices automatically.
92
-
93
- ## Stop on workflow state
94
-
95
- - **NO-GO at seal** → stop; surface every blocker with `file:line` and the fix
96
- direction. Do not round NO-GO up to GO.
97
- - **Spec Drift Guard fires** (`/rite-build` finds the plan is wrong and the change
98
- alters product behaviour) → stop; route through `/rite-plan repair`.
99
- - **Budget exhausted with slices still pending:** any validated root-owned remaining
100
- value of zero stops before the next dispatch. Report which bound won (pre-existing
101
- remaining value, explicit flag, sentinel cap, or post-vet pending count) and the
102
- unbuilt slices. A malformed value also fails closed. Zero with no pending slices is
103
- normal completion → continue to `/rite-prove` without pausing.
104
- - **Resource envelope unavailable or exhausted:** stop before more work when the AFK
105
- envelope is missing/malformed/expired; another run overlaps; native agent, token,
106
- cost, or wall-time headroom is exhausted/unobservable despite a declared cap; or
107
- unresolved review/gate backlog is above its cap. At the review cap, permit only
108
- reconciliation that reduces the queue. Record the exact winning limit and observed
109
- usage/count. A new activation gets fresh activation-local counters; it does not reset
110
- durable slice/recovery budgets, expiry, or the recomputed queue.
111
- - **Still low-confidence after the interview:** the idea can't be pinned to testable
112
- acceptance criteria → stop and ask, rather than guessing the product.
113
- - **Repeated failure:** bounded recovery exhausts → stop with reproduction.
114
-
115
- ## The final type-GO
116
-
117
- - `--ship` / `--yolo` never authorizes Git. Continue through ship preflight,
118
- disclose the exact plan, then stop for literal `GO` and native approval.
119
- - Without either flag, stop at seal GO with `/rite-ship` as the resume command.
120
- Seal GO, AFK, prior approval, and flags never satisfy ship approval.
121
-
122
- ## How to stop well
123
-
124
- State must be enough for a fresh agent to resume cold:
125
- - `state.md`: `Status`, the blocking reason, and either a single actionable
126
- `Next step` command or the terminal `none — technical recovery exhausted`
127
- marker.
128
- - The relevant `questions.md` / `drift.md` / `seal.md` entry that explains the pause.
129
- - A one-line user-facing message: *what* stopped it and, only when one exists,
130
- *what human-owned action* resumes. A terminal technical blocker names no
131
- routine Plan/Vet/retry command.
1
+ # Stop conditions: when autocomplete pauses
2
+
3
+ On a real stop, write `state.md` as `awaiting_human` or `blocked`, persist the
4
+ reason, and include one resume command only when an actual human/safety/access
5
+ action can change it. Exhausted agent-owned recovery records terminal
6
+ `Next step: none` and no runnable recovery command. `--ship` never bypasses a
7
+ stop.
8
+
9
+ Authority: `.claude/skills/devrites-lib/reference/standards/acceptance-preserving-reslice.md`.
10
+
11
+ <!-- BEGIN RESLICE ROUTE-TO-ACTION -->
12
+ - `FOLD` keep Plan repair/affected Vet internal; no stop solely for topology/count.
13
+ - `GUARD_AND_REPAIR` enter Spec Drift Guard/Clarify; pause only at an existing human-owned gate; resume Plan/Vet internally.
14
+ - `BLOCKED_INPUT` no planning writes; stop internal branch; exact diagnostic; recover authority; reclassify.
15
+ <!-- END RESLICE ROUTE-TO-ACTION -->
16
+
17
+ ## Always stop
18
+
19
+ Regardless of flags or AFK ceiling:
20
+
21
+ - destructive data migration;
22
+ - auth/authz boundary change;
23
+ - public API break;
24
+ - external-service contract change; or
25
+ - filesystem destruction outside the workspace.
26
+
27
+ Red proof cannot advance. Run bounded Debug Recovery; stop after proven
28
+ exhaustion unless the remaining owner is human.
29
+
30
+ ## Not stops: internal technical routing
31
+
32
+ `NEEDS_REPLAN` is not a stop condition under active Autocomplete. It blocks
33
+ forward work, persists the return cursor, and invokes Plan repair plus Recovery
34
+ Vet inline. The same applies to nested `STOP`/`Next step` when its decision is
35
+ agent-owned.
36
+
37
+ Agent-owned backtracking is not a stop condition while the exact causal
38
+ fingerprint has budget. Invoke the earlier phase, affected Vet, remediation, and
39
+ proof; then resume the origin. Stop only after three no-progress corrections of
40
+ that exact fingerprint or a real human/safety/access gate. Preserve reproduction,
41
+ attempts, and dead ends; never offer `/rite-plan unblock` or another routine
42
+ phase command. Reinvocation with unchanged evidence does not reset the cap.
43
+ `unchanged` means the same fingerprint already has three recorded no-progress
44
+ corrections. Closure is progress; a separately evidenced Critical/Important
45
+ invariant starts its own cap and cannot extend the closed one.
46
+
47
+ Spent consumptive-action authorization is not technical-recovery exhaustion.
48
+ It blocks another execution; retained new Critical/Important evidence still
49
+ enters offline recovery. After affected Vet is READY, pause for fresh action
50
+ authorization and never reuse old GO.
51
+
52
+ Past evidence being irretrievable is not by itself terminal. If an in-scope
53
+ trusted seam can uniquely discriminate the next failure, run diagnostic-
54
+ amplification Plan repair and narrow Vet inline, then pause for fresh GO before
55
+ one evidence-acquisition attempt. Use terminal none only when no safe in-scope
56
+ seam exists, a real human/risk/scope gate owns it, or bounded recovery is
57
+ exhausted.
58
+
59
+ <!-- workflow-artifact-adapter: {"module":"devrites-lib/reference/standards/workflow-artifacts.md","entry":"classifier returns owner-busy, exhausted, or existing hard gate","action":"stop on exact WAIT_ACTIVE_OWNER, BLOCKED_EXHAUSTED, or BLOCKED_GATE result","return":"unchanged cursor plus fixed route-owned output"} -->
60
+ ## Other stop classes
61
+
62
+ - **Gate severity:** blocking or escalating gate; any open validating question.
63
+ - **Temper:** any `expand` or added acceptance criterion. `hold-rigor`,
64
+ `reduce-to-MVP`, and a justified skip do not pause.
65
+ - **Clarify:** material Partial/Missing/unowned decision coverage or a
66
+ low-confidence high-consequence assumption. Continue the initial interview;
67
+ never arm AFK early.
68
+ - **Seal:** NO-GO, with every blocker and fix direction. Never round up to GO.
69
+ - **Reslice:** execute its marked action before deciding continue/stop.
70
+ - **Slice budget:** any validated root-owned remaining value of zero stops before the next dispatch
71
+ when slices remain; malformed state also stops. Report whether the winning
72
+ bound was the pre-existing remaining value, explicit flag, sentinel cap, or post-vet pending count.
73
+ Zero with no pending slices is normal completion and proceeds to Prove.
74
+ - **Resource envelope:** missing/malformed/expired AFK, overlapping run,
75
+ exhausted/unobservable declared agent/token/cost/time headroom, or review queue
76
+ above cap. At cap, only queue-reducing reconciliation may run. Persist winning
77
+ bound and observed usage; a new activation does not reset durable budgets or
78
+ expiry.
79
+ - **Confidence:** intent still cannot become testable acceptance after interview.
80
+ - **Repeated failure:** the exact fingerprint's bounded recovery is exhausted.
81
+
82
+ ## Final GO and durable stop
83
+
84
+ `--ship`/`--yolo` never authorizes Git. With a flag, complete Ship preflight,
85
+ disclose the exact plan, and stop for literal `GO` plus native approval. Without
86
+ one, stop at Seal GO with `/rite-ship`. Seal GO, AFK, prior approval, and flags
87
+ never satisfy Ship approval.
88
+
89
+ A cold-resumable stop records `state.md` status, exact reason, and either one
90
+ human-owned resume action or `none technical recovery exhausted`; the owning
91
+ question/drift/seal entry explains it. The user-facing line says what stopped
92
+ and, only when applicable, what human action resumes it.
@@ -1,99 +1,64 @@
1
1
  ---
2
2
  name: rite-build
3
- description: Build the next approved vertical slice with evidence. HITL stops after one; explicit AFK may chain bounded green slices.
4
- argument-hint: "[slice number or name]"
3
+ description: Build the next approved vertical slice with evidence. HITL one-slice default; AFK may chain serially; opt-in `--parallel N` (2≤N≤3) for path-disjoint worktrees.
4
+ argument-hint: "[--parallel N] [slice number or name]"
5
5
  user-invocable: true
6
6
  ---
7
7
 
8
8
  # /rite-build: one verified slice
9
9
 
10
10
  Build and prove one slice. HITL stops; a later user invocation starts the next.
11
- Explicit `.devrites/AFK` alone lets the controlling root chain pending slices,
12
- only under existing green-proof, cap, and pause rules. **Read the active workspace
13
- first**; if none, tell the user to run `/rite-spec <feature>`.
11
+ Explicit `.devrites/AFK` alone lets the controlling root chain pending slices
12
+ serially under green proof, caps, and pause rules. Every wright returns after it.
13
+ **Opt-in:** `/rite-build --parallel N` (2≤N≤3; N=1≡serial) follows
14
+ [`reference/parallel-batch.md`](reference/parallel-batch.md).
14
15
 
15
- The root owns gates/workspace; a
16
- fresh-context [`devrites-slice-wright`](../../agents/devrites-slice-wright.md)
17
- writes product source and tests. Exact Vet-ready executable workflow artifacts use
16
+ Root owns gates/bookkeeping. Fresh
17
+ [`devrites-slice-wright`](../../agents/devrites-slice-wright.md) writes product
18
+ source/tests. Workflow Artifact paths use
18
19
  [`workflow-artifacts.md`](../devrites-lib/reference/standards/workflow-artifacts.md).
19
- Apply the readiness, selection, host, HITL/AFK,
20
- dispatch, doubt, fail-on-red, record, and stop checks. See
20
+ Execute [`reference/phase-contract.md`](reference/phase-contract.md); dispatch uses
21
21
  [`reference/wright-dispatch.md`](reference/wright-dispatch.md).
22
22
 
23
- ## Rules consulted (read on demand from `.claude/skills/devrites-lib/reference/standards/`)
24
- Read `.claude/skills/devrites-lib/reference/standards/core.md` first. The wright
25
- reads named on-demand rules while writing; root reads them for doubt/record gates:
26
- - `coding-style.md`: naming, function shape, guard clauses, comments, reuse-first.
27
- - `error-handling.md`: fail fast, no silent catches, fail closed.
28
- - `testing.md`: pyramid, behaviour over implementation, see-it-fail-first.
29
- - [`reference/tdd.md`](reference/tdd.md): the slice-level Red → Green → Refactor
30
- and Prove-It contract.
31
- - `patterns.md`: composition over inheritance, avoid premature abstraction.
32
- - `principles.md`: the project invariants (`.devrites/principles.md`) the slice must honor; the wright reads them as **binding**, not priors.
33
- - `security.md`: when the slice touches user input, auth, data, or external integrations.
34
- - `repository-topology.md`: when targets span roots/languages/services or touch generated/vendor surfaces.
35
- - `data-integrity.md`: when the slice writes durable state or changes migration/concurrency/tenant/retention behavior.
36
- - `integration-reliability.md`: when the slice changes an API/webhook/queue/job/cache/cross-service boundary.
37
- - `definition-of-done.md`: standing Done bar: acceptance mapped, fresh proof, no open hard gates, scoped edits, rollback/docs where needed.
23
+ ## Required rules
38
24
 
25
+ Read `.claude/skills/devrites-lib/reference/standards/core.md` first. Load only triggered rules:
26
+ coding/error/testing/[`tdd.md`](reference/tdd.md)/patterns/DoD; binding
27
+ `.devrites/principles.md`; security; topology; data integrity; integration reliability.
28
+ Wright applies anti-slop; root verifies returns and never patches source.
39
29
 
40
- ## Operating rules
41
- - **One slice per wright dispatch.** Every wright returns after it. The controlling
42
- root applies the mode rule above before another dispatch. Prefer the guarded serial
43
- native-worktree pilot in `wright-dispatch.md` only when its committed-clean
44
- preflight and explicit reconciliation path both hold; otherwise use the existing
45
- serial same-worktree writer. Never run writers in parallel.
46
- - Evidence over confidence. Prefer existing conventions. Feature scope only: no
47
- drive-by refactors.
48
- - **Record adjacent issues; do not edit them.** An issue outside the exact paths
49
- stated in the dispatch task becomes an FYI follow-up in `decisions.md`. The slice summary states
50
- what it deliberately left alone ([`git-workflow.md`](../devrites-lib/reference/standards/git-workflow.md)
51
- "Things I didn't touch"). The root rejects a returned diff outside this boundary.
52
- - **Don't re-run an unchanged check.** The same build or test on unchanged code provides
53
- no new evidence. Re-verify after an edit.
54
- - Surface material assumptions. Do not introduce an unplanned dependency or second design
55
- system: route the objective plan gap to `/rite-vet` (or bounded recovery), not to a human.
56
- Ask only if the newly exposed choice changes licensing/cost/security, product behavior,
57
- or an explicit architecture policy. The
58
- [Spec Drift Guard](reference/spec-drift-guard.md) is active throughout.
59
- - **Avoid AI slop while writing.** `devrites-slice-wright` applies the anti-slop charter
60
- while writing. The canonical list is `rite-polish/reference/anti-ai-slop.md`; do not
61
- duplicate it here. The wright follows project idioms and reuses existing code first.
62
- **Verify the charter on return.** Do not correct source from the orchestrator.
63
- The **prose you write yourself** (`evidence.md`, `decisions.md`, the slice report) follows
64
- the human-voice charter (`.claude/skills/devrites-lib/reference/standards/prose-style.md`; depth in `devrites-prose-craft`): no
65
- filler openers or marketing adjectives; preserve exact commands and identifiers.
66
- - **Honor declared project principles.** The wright reads `.devrites/principles.md` and treats
67
- each invariant as **binding** (not a prior to weigh like a convention): a slice it cannot build
68
- without breaking one is an **Escalation**, not a silent violation. On return **you verify no
69
- principle was broken**; a fresh violation is handled like any irreversible-risk item: a
70
- human-approved, scoped exception in the register or a stop, never folded into the slice. No
71
- `.devrites/principles.md` → none declared → nothing to honor.
72
- - **You never edit product source/tests.** You write `.devrites/` bookkeeping and,
73
- only through `workflow-artifacts.md`, an exact Vet-ready executable workflow-artifact set.
74
- Follow the
75
- host gate in `wright-dispatch.md` before every build or recovery dispatch. On a
76
- supported host, the wright is the only writer of code and tests. Codex gives
77
- the root workspace permission only so that native writer dispatch can execute;
78
- never patch code from the root. Put the exact project-relative source/test path
79
- list directly in the task, dispatch the exact `devrites-slice-wright`, then
80
- compare `git diff --name-only` with those task paths. Any extra source file is
81
- a hard STOP.
82
- - **Executable workflow-artifact branch.** If every implementation target is an
83
- exact admitted path under the active `.devrites/work/<slug>/`, the controlling
84
- root materializes and proves that atomic set itself. It does not dispatch the wright,
85
- decrement/count a product slice, update the candidate manifest, or execute the
86
- consumptive action. After narrow Vet, restore the caller cursor.
30
+ ## Invariants
87
31
 
88
- ## Workflow
32
+ - Default: one slice; writers serial on control. Parallel only via `--parallel N`
33
+ under [`reference/parallel-batch.md`](reference/parallel-batch.md). Same-worktree
34
+ multi-writer / root-emulated concurrency forbidden. Native-worktree pilot =
35
+ single-slice isolation when `wright-dispatch.md` preflight + reconcile hold.
36
+ - Exact feature scope only; reject out-of-allowlist diffs; record adjacent issues.
37
+ - Never rerun an unchanged check; re-prove after edits.
38
+ - Unplanned dependency/design-system/gap/repair → Vet/Spec Drift Guard. Ask only
39
+ for licensing/cost/security/product or explicit architecture-policy decisions.
40
+ - Root never edits product source/tests (`.devrites/` + Workflow Artifact only).
41
+ Wright is sole product writer; extras in returned paths/`git diff --name-only` hard-stop.
42
+ - Principles bind; irreversible conflict needs human exception or stop.
43
+ - Evidence beats confidence. Never weaken tests, skip TDD, widen writers, or
44
+ self-approve. Drift → [`spec-drift-guard.md`](reference/spec-drift-guard.md);
45
+ checkpoint → [`checkpoint.md`](reference/checkpoint.md).
89
46
 
90
- Run the full execution contract in
91
- [`reference/phase-contract.md`](reference/phase-contract.md). It is not optional:
92
- it contains the gated one-slice workflow, including readiness, HITL/AFK handling,
93
- wright dispatch, doubt, fail-on-red, record gates, and stop behavior.
47
+ ## Workflow Artifact branch
94
48
 
95
- ## Output
49
+ <!-- workflow-artifact-adapter: {"module":"devrites-lib/reference/standards/workflow-artifacts.md","entry":"Vet-ready admitted bytes require root authorship outside product wright","action":"ROOT_TRANSACTION; root writes only admitted .devrites/** targets","return":"saved Build slice cursor; wright product allowlist unchanged"} -->
50
+ ## `--parallel N` (opt-in)
96
51
 
97
- Use [`reference/output.md`](reference/output.md) and the shared
98
- [`reply contract`](../devrites-lib/reference/reply-contract.md). They keep the
99
- HITL stop, bounded AFK chaining, and no-automatic-`/rite-prove` boundary explicit.
52
+ Omitted/`1` ≡ serial; `2`/`3` path-disjoint fan-out when eligible; else hard refuse.
53
+ All-green serial integrate; one red/gap aborts. AFK charges after integrate only.
54
+ Running lease blocks another `/rite-build`. Details: `parallel-batch.md`.
55
+
56
+ ## Execute and reply
57
+
58
+ Run every step in `reference/phase-contract.md`: readiness, one target, dispatch
59
+ or canonical transaction, return inspection, independent doubt/test analysis,
60
+ approved fail-on-red proof, record, AFK accounting, and stop. Use
61
+ [`reference/output.md`](reference/output.md) plus the shared
62
+ [`reply contract`](../devrites-lib/reference/reply-contract.md). HITL never starts
63
+ the next slice automatically; AFK chains only within its durable remaining
64
+ budget; Prove starts only after all slices are built.
@@ -8,16 +8,8 @@ Load the shared
8
8
  contract for the sentinel schema, defaults, gate ceiling, and mutable-counter
9
9
  ownership. This file owns only Build's dispatch, charging, and red-path behavior.
10
10
 
11
- These rules follow established autonomous-coding loops, including Ralph Wiggum and
12
- Claude Code auto mode:
13
-
14
- 1. **Require green feedback.** Tests, types, and lint must pass before a slice is
15
- marked `built`.
16
- 2. **Cap iterations.** `max_slices` is the hard limit.
17
- 3. **Run gates before the action they control.** A post-action gate is only a review
18
- queue.
19
- 4. **Keep irreversible work manual.** Destructive work, auth boundaries, and public
20
- API breaks always pause regardless of the sentinel.
11
+ Rules: green before `built`; hard `max_slices` cap; gates before the action they
12
+ control; irreversible work (destructive/auth/public API) always pauses.
21
13
 
22
14
  ## Iteration cap
23
15
 
@@ -41,32 +33,33 @@ The controlling root owns the cap:
41
33
  A controlling orchestrator may pre-seed the remaining field from a validated
42
34
  post-plan budget before the first dispatch; never increase or reinitialize an
43
35
  existing value.
44
- 3. **Charge exactly once after each green built slice.** A slice already marked
45
- built is not charged again after retry, resume, or compaction. Re-read the
46
- saved cursor; if it is zero, report the cap and stop before the next
47
- dispatch.
36
+ 3. **Charge exactly once after each green built slice.** On the control tree, a slice
37
+ already marked built is not charged again after retry, resume, or
38
+ compaction. Re-read the saved cursor; if it is zero, report the cap and stop
39
+ before the next dispatch.
40
+ - **Serial:** charge when fail-on-red is green and the built record is written
41
+ (same rewrite as step 2).
42
+ - **Parallel `--parallel`:** charge only after **successful serial integrate**
43
+ — once per integrated green sibling. Abort / integrate-failed → charge **0**.
44
+ Do not charge on worktree-green before integrate. See
45
+ [`parallel-batch.md`](parallel-batch.md).
48
46
 
49
47
  Use this stop message:
50
48
 
51
- ```
49
+ ```text
52
50
  AFK cap reached. Raise `state.md` `AFK slices remaining` or remove the sentinel to continue.
53
51
  ```
54
52
 
55
53
  `max_slices` itself is read-only and never rewritten. No exit-code command
56
54
  enforces this policy.
57
55
 
58
- Choose a missing or large cap deliberately. Ralph's rule is 5-10 iterations for small
59
- tasks and 30-50 for larger ones. Do not use `unlimited` for work that has not completed
60
- successfully in HITL.
56
+ Choose caps deliberately (≈5–10 small, ≈30–50 larger). Avoid `unlimited` until HITL
57
+ has succeeded for the work.
61
58
 
62
59
  ## Fail-on-red
63
60
 
64
- The **fail-on-red step** (workflow step 5) refuses to mark a slice `built` if targeted
65
- tests, types, or lint are red:
66
-
67
- - A red signal means either the slice's contract is wrong or the implementation/proof path is.
68
- The slice cannot advance, but an objective root cause is agent-owned recovery work.
69
- - Marking it `built` would let the next slice build on broken state.
61
+ The **fail-on-red step** refuses `built` when targeted tests/types/lint are red. Red means
62
+ wrong contract or proof path — agent-owned recovery; never advance on broken state.
70
63
 
71
64
  The fail-on-red path:
72
65
 
@@ -105,7 +98,7 @@ The hook is a single shell command run on the `awaiting_human` transition. Envir
105
98
  the hook receives:
106
99
 
107
100
  | Var | Value |
108
- |---|---|
101
+ | --- | --- |
109
102
  | `DEVRITES_QID` | the new qid (e.g. `q-2026-05-28-001`) |
110
103
  | `DEVRITES_GATE` | `advisory` / `validating` / `blocking` / `escalating` |
111
104
  | `DEVRITES_SLICE` | `<N — name>` |
@@ -117,6 +110,7 @@ The hook is best effort: a non-zero exit does **not** roll back the pause. Failu
117
110
  logged to `evidence.md` so the user sees them on return.
118
111
 
119
112
  Example targets:
113
+
120
114
  - `curl -d "$DEVRITES_QID: $DEVRITES_QUESTION" ntfy.sh/my-topic`
121
115
  - `osascript -e "display notification \"$DEVRITES_QUESTION\" with title \"DevRites: $DEVRITES_GATE\""`
122
116
  - `pb push "$DEVRITES_SLUG: $DEVRITES_QUESTION"` (via pushbullet CLI)
@@ -1,29 +1,22 @@
1
1
  # Checkpoint protocol: what `/rite-build` does when a slice is HITL
2
2
 
3
- When `/rite-build` reaches a slice with `Mode: HITL`, it does **not** start writing code. It
4
- surfaces the checkpoint as a ranked **option set** and resolves it **before** any code lands:
3
+ HITL slices pause **pre-action** as a ranked **option set** before any code:
5
4
 
6
- - **Human present (interactive):** ask inline via `AskUserQuestion` (the option set below).
7
- The human picks; record the pick to `questions.md` (`answered`) + `decisions.md`, clear the
8
- gate, and **continue building in place**: no STOP, no `/rite-resolve` round-trip.
9
- - **Human absent / AFK-pausing / notify-only:** persist the checkpoint (`questions.md` open +
10
- `state.md` `Awaiting human`), fire the `notify:` hook, and **stop**. Resume later via
11
- `/rite-resolve` (or `--batch`).
12
-
13
- Either way the pause is **pre-action**, not post-action: code never lands before the gate.
5
+ - **Interactive:** `AskUserQuestion`; record to `questions.md`/`decisions.md`; clear gate;
6
+ continue in place (no `/rite-resolve` round-trip).
7
+ - **Absent / AFK / notify-only:** persist open question + `Awaiting human`, notify, **stop**.
8
+ Resume via `/rite-resolve` (or `--batch`).
14
9
 
15
10
  ## Render contract
16
11
 
17
- The checkpoint must be rendered in user-facing output **and** persisted to the workspace.
18
- Both are required: the output is for the human in the room (or the notification target),
19
- the persisted form is for the next session or the AFK observer.
12
+ Render the checkpoint in user-facing output **and** persist it for the next session / AFK
13
+ observer.
20
14
 
21
15
  ### User-facing render: the option set
22
16
 
23
- Present the checkpoint as an `AskUserQuestion` with a ranked **option set**
24
- (`afk-hitl.md` "Option set"): 2-4 options, **recommended first** + labelled `(Recommended)`,
25
- each option's description carrying the dimension-tagged rationale + the trade-off it accepts,
26
- plus the escape hatch. The header names the slice + gate:
17
+ Present as `AskUserQuestion` ranked **option set** (`afk-hitl.md`): 2–4 options,
18
+ recommended first + `(Recommended)`, dimension-tagged trade-offs, plus escape hatch.
19
+ Header names slice + gate:
27
20
 
28
21
  ```
29
22
  Slice <N — name> — HITL (<gate>, SLA <SLA>). <Checkpoint text from tasks.md>
@@ -35,12 +28,9 @@ Slice <N — name> — HITL (<gate>, SLA <SLA>). <Checkpoint text from tasks.md>
35
28
  4. Something else — I'll describe it
36
29
  ```
37
30
 
38
- The recommended option (#1) is **required**: a checkpoint without a recommendation is a worse
39
- interrupt than one with shape; the human reacts to a ranked draft faster than to a blank prompt
40
- (the "give the human something to approve" rule). The recommendation reflects *this* project
41
- (its conventions, stack, scale), not a generic default. On an interactive pick, resolve in
42
- place; when persisting a pause instead, the same set is written to `questions.md` `options:`
43
- and the resume line is `/rite-resolve <qid> "<answer>"` (or `--drop <qid> "<reason>"`).
31
+ Option #1 (recommended) is **required** and must reflect *this* project. Interactive pick
32
+ resolve in place; pause persist the same set to `questions.md` `options:` with resume
33
+ `/rite-resolve <qid> "<answer>"` (or `--drop <qid> "<reason>"`).
44
34
 
45
35
  ### Workspace mutations
46
36
 
@@ -93,9 +83,7 @@ rewrite; do not claim cross-file atomicity):
93
83
  sh -c "$notify_cmd"
94
84
  ```
95
85
 
96
- The hook fires after the workspace write so the notification target sees a workspace
97
- that already records the pause. Failures in the hook **do not** roll back the pause:
98
- the gate is authoritative; the notification is best-effort.
86
+ Fire after workspace write. Hook failure does **not** roll back the pause (best-effort).
99
87
 
100
88
  ## qid generation
101
89
 
@@ -109,42 +97,24 @@ reservation or engine command for qids.
109
97
 
110
98
  ## When AFK is active
111
99
 
112
- If `.devrites/AFK` exists and the slice's `Gate` is in `allow_gates`, `/rite-build` does
113
- **not** invoke the checkpoint protocol. Instead:
114
-
115
- - For `advisory`: log a `gate: advisory` entry to `questions.md`, record the trade-off in
116
- `decisions.md`, and **dispatch the wright** to build the slice (workflow step 3).
117
- - For `validating` (only when `allow_gates` includes it): **dispatch the wright** (step 3); on
118
- return, write a `gate: validating` entry to `questions.md`, mark the slice
119
- `built (pending review)` in `state.md`, and continue. A slice's only states are `pending` and `built`:
120
- acceptance is proven at the **feature** level by `/rite-prove` (recorded in
121
- `evidence.md`), not per slice. The `built (pending review)` slice is not done until the
122
- open `validating` gate resolves via `/rite-resolve`; an open `validating` gate is a
123
- NO-GO at seal.
124
-
125
- For gates in `allow_gates`, AFK **auto-picks the recommended option** (option 1 of the set)
126
- instead of pausing, recording it as above. For `blocking` and `escalating` (and every
127
- irreversible-risk item), AFK **always** invokes the checkpoint protocol: the sentinel does
128
- not unlock these gates and no AFK key can override them. See `afk-discipline.md`
129
- for the irreversible-risk list.
100
+ If `.devrites/AFK` exists and the slice `Gate` is in `allow_gates`, skip this protocol and
101
+ auto-pick recommended option 1:
102
+
103
+ - `advisory`: log `gate: advisory` + `decisions.md`, then dispatch wright.
104
+ - `validating` (only if allowed): dispatch wright; on return log `gate: validating`, mark
105
+ `built (pending review)`, continue. Slice states remain `pending|built`; feature
106
+ acceptance is `/rite-prove`. Open `validating` is NO-GO at seal until `/rite-resolve`.
107
+
108
+ `blocking` / `escalating` / irreversible-risk always use this protocol (`afk-discipline.md`).
130
109
 
131
110
  ## Multi-question pauses
132
111
 
133
- The current protocol is **one question per pause**. If a slice has multiple HITL
134
- checkpoints, split it into sub-slices via `/rite-plan reslice` so each pause is
135
- single-question. Multi-question pauses are reserved future shape; `Awaiting human` is
136
- written as a single block.
112
+ **One question per pause.** Multiple HITL checkpoints `/rite-plan reslice`.
137
113
 
138
114
  ## What NOT to do
139
115
 
140
- - **Don't write code first and pause after.** The pre-action rule is the whole point.
141
- - **Don't render the checkpoint without persisting.** Output without `state.md` + `questions.md`
142
- updates means the workspace lies on `/clear`.
143
- - **Don't self-answer a question that *paused* for a human.** When a gate stopped the session
144
- (an AFK queue, or a HITL pause the human walked away from), `/rite-resolve` requires an
145
- explicit answer: the agent doesn't confirm its own `proposed:` on resume. This is distinct
146
- from the two legitimate auto-resolutions: an interactive `AskUserQuestion` pick the human
147
- just made, and an AFK auto-pick of the recommended option on a gate `allow_gates` permits.
148
- - **Don't bundle the `notify:` hook output into chat.** Fire-and-forget; the chat already
149
- has the user-facing render.
150
- - **Don't fire `notify:` on `advisory`-downgraded entries.** It's reserved for true pauses.
116
+ - Don't write code then pause pre-action only.
117
+ - Don't render without persisting `state.md` + `questions.md`.
118
+ - Don't self-answer a human pause via `proposed:` — `/rite-resolve` needs an explicit
119
+ answer (distinct from interactive pick / AFK auto-pick on `allow_gates`).
120
+ - Don't put `notify:` output in chat; don't fire `notify:` on advisory-only entries.