devrites 5.7.1 → 5.8.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 (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +4 -4
  3. package/docs/command-map.md +1 -1
  4. package/docs/engine/commands.md +1 -0
  5. package/docs/orchestration.md +2 -2
  6. package/engine/internal/parallel/cli.go +69 -0
  7. package/engine/internal/parallel/select.go +76 -0
  8. package/engine/internal/parallel/select_test.go +95 -0
  9. package/pack/.claude/settings.json +1 -0
  10. package/pack/.claude/skills/devrites-lib/reference/standards/afk-hitl.md +9 -10
  11. package/pack/.claude/skills/devrites-lib/reference/standards/loop-operations.md +3 -3
  12. package/pack/.claude/skills/rite-autocomplete/SKILL.md +5 -4
  13. package/pack/.claude/skills/rite-autocomplete/reference/loop.md +9 -10
  14. package/pack/.claude/skills/rite-autocomplete/reference/stop-conditions.md +2 -3
  15. package/pack/.claude/skills/rite-build/SKILL.md +2 -1
  16. package/pack/.claude/skills/rite-build/reference/afk-discipline.md +3 -1
  17. package/pack/.claude/skills/rite-build/reference/one-slice-cycle.md +1 -1
  18. package/pack/.claude/skills/rite-build/reference/parallel-batch.md +17 -13
  19. package/pack/generated/claude/settings.json +1 -0
  20. package/pack/generated/claude/skills/devrites-lib/reference/standards/afk-hitl.md +9 -10
  21. package/pack/generated/claude/skills/devrites-lib/reference/standards/loop-operations.md +3 -3
  22. package/pack/generated/claude/skills/rite-autocomplete/SKILL.md +5 -4
  23. package/pack/generated/claude/skills/rite-autocomplete/reference/loop.md +9 -10
  24. package/pack/generated/claude/skills/rite-autocomplete/reference/stop-conditions.md +2 -3
  25. package/pack/generated/claude/skills/rite-build/SKILL.md +2 -1
  26. package/pack/generated/claude/skills/rite-build/reference/afk-discipline.md +3 -1
  27. package/pack/generated/claude/skills/rite-build/reference/one-slice-cycle.md +1 -1
  28. package/pack/generated/claude/skills/rite-build/reference/parallel-batch.md +17 -13
  29. package/pack/generated/codex/skills/devrites-lib/reference/standards/afk-hitl.md +9 -10
  30. package/pack/generated/codex/skills/devrites-lib/reference/standards/loop-operations.md +3 -3
  31. package/pack/generated/codex/skills/rite-autocomplete/SKILL.md +5 -4
  32. package/pack/generated/codex/skills/rite-autocomplete/reference/loop.md +9 -10
  33. package/pack/generated/codex/skills/rite-autocomplete/reference/stop-conditions.md +2 -3
  34. package/pack/generated/codex/skills/rite-build/SKILL.md +2 -1
  35. package/pack/generated/codex/skills/rite-build/reference/afk-discipline.md +3 -1
  36. package/pack/generated/codex/skills/rite-build/reference/one-slice-cycle.md +1 -1
  37. package/pack/generated/codex/skills/rite-build/reference/parallel-batch.md +17 -13
  38. package/pack/generated/omp/skills/devrites-lib/reference/standards/afk-hitl.md +9 -10
  39. package/pack/generated/omp/skills/devrites-lib/reference/standards/loop-operations.md +3 -3
  40. package/pack/generated/omp/skills/rite-autocomplete/SKILL.md +5 -4
  41. package/pack/generated/omp/skills/rite-autocomplete/reference/loop.md +9 -10
  42. package/pack/generated/omp/skills/rite-autocomplete/reference/stop-conditions.md +2 -3
  43. package/pack/generated/omp/skills/rite-build/SKILL.md +2 -1
  44. package/pack/generated/omp/skills/rite-build/reference/afk-discipline.md +3 -1
  45. package/pack/generated/omp/skills/rite-build/reference/one-slice-cycle.md +1 -1
  46. package/pack/generated/omp/skills/rite-build/reference/parallel-batch.md +17 -13
  47. package/pack/generated/pi/agents/devrites-code-reviewer.md +1 -1
  48. package/pack/generated/pi/agents/devrites-devex-reviewer.md +1 -1
  49. package/pack/generated/pi/agents/devrites-doubt-reviewer.md +1 -1
  50. package/pack/generated/pi/agents/devrites-evidence-scout.md +1 -1
  51. package/pack/generated/pi/agents/devrites-frontend-reviewer.md +1 -1
  52. package/pack/generated/pi/agents/devrites-performance-reviewer.md +1 -1
  53. package/pack/generated/pi/agents/devrites-plan-drafter.md +1 -1
  54. package/pack/generated/pi/agents/devrites-plan-reviewer.md +1 -1
  55. package/pack/generated/pi/agents/devrites-proof-runner.md +1 -1
  56. package/pack/generated/pi/agents/devrites-retrospector.md +1 -1
  57. package/pack/generated/pi/agents/devrites-security-auditor.md +1 -1
  58. package/pack/generated/pi/agents/devrites-simplifier-reviewer.md +1 -1
  59. package/pack/generated/pi/agents/devrites-slice-wright.md +1 -1
  60. package/pack/generated/pi/agents/devrites-spec-reviewer.md +1 -1
  61. package/pack/generated/pi/agents/devrites-strategy-reviewer.md +1 -1
  62. package/pack/generated/pi/agents/devrites-test-analyst.md +1 -1
  63. package/pack/generated/pi/agents/devrites-upgrade-planner.md +1 -1
  64. package/pack/generated/pi/skills/devrites-lib/reference/standards/afk-hitl.md +9 -10
  65. package/pack/generated/pi/skills/devrites-lib/reference/standards/loop-operations.md +3 -3
  66. package/pack/generated/pi/skills/rite-autocomplete/SKILL.md +5 -4
  67. package/pack/generated/pi/skills/rite-autocomplete/reference/loop.md +9 -10
  68. package/pack/generated/pi/skills/rite-autocomplete/reference/stop-conditions.md +2 -3
  69. package/pack/generated/pi/skills/rite-build/SKILL.md +2 -1
  70. package/pack/generated/pi/skills/rite-build/reference/afk-discipline.md +3 -1
  71. package/pack/generated/pi/skills/rite-build/reference/one-slice-cycle.md +1 -1
  72. package/pack/generated/pi/skills/rite-build/reference/parallel-batch.md +17 -13
  73. package/package.json +1 -1
  74. package/scripts/pi-generate.sh +52 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to DevRites are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and DevRites adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Releases are generated automatically by [semantic-release](https://semantic-release.gitbook.io/) from Conventional Commits on `main`.
4
4
 
5
+ ## [5.8.0](https://github.com/ViktorsBaikers/DevRites/compare/v5.7.2...v5.8.0) (2026-09-14)
6
+
7
+ ### Added
8
+
9
+ * **agents:** allowlist lean-ctx and lens tools on pi agents ([#74](https://github.com/ViktorsBaikers/DevRites/issues/74)) ([08390d3](https://github.com/ViktorsBaikers/DevRites/commit/08390d3bf3ccffec0353803e910ee7a7227ff6ba))
10
+
11
+ ### Fixed
12
+
13
+ * **rite:** re-select parallel width after a serial round ([#73](https://github.com/ViktorsBaikers/DevRites/issues/73)) ([ac8f073](https://github.com/ViktorsBaikers/DevRites/commit/ac8f073c0640ab0350b92a87a86193de39dedd57))
14
+
15
+ ## [5.7.2](https://github.com/ViktorsBaikers/DevRites/compare/v5.7.1...v5.7.2) (2026-09-14)
16
+
17
+ ### Fixed
18
+
19
+ * **skills:** drop absolute AFK sentinel expiry so unattended runs finish ([#72](https://github.com/ViktorsBaikers/DevRites/issues/72)) ([3f880cb](https://github.com/ViktorsBaikers/DevRites/commit/3f880cb0c0e3072a1512c87229c9c1c38ef12417))
20
+
5
21
  ## [5.7.1](https://github.com/ViktorsBaikers/DevRites/compare/v5.7.0...v5.7.1) (2026-09-13)
6
22
 
7
23
  ### Fixed
package/README.md CHANGED
@@ -33,7 +33,7 @@ project-conventional push, tag, or PR action, and archive the workspace.
33
33
  Unattended runs may create local WIP checkpoint commits along the way, but they
34
34
  remain local unless Ship's disclosed plan includes an approved remote action.
35
35
 
36
- **Status:** [`v5.7.1`](https://github.com/ViktorsBaikers/DevRites/releases/tag/v5.7.1): see [`CHANGELOG.md`](CHANGELOG.md) for release notes.
36
+ **Status:** [`v5.8.0`](https://github.com/ViktorsBaikers/DevRites/releases/tag/v5.8.0): see [`CHANGELOG.md`](CHANGELOG.md) for release notes.
37
37
 
38
38
  This is the latest published release; `main` may contain unreleased work.
39
39
 
@@ -239,7 +239,6 @@ max_slices: 10
239
239
  max_agents: 32
240
240
  max_minutes: 120
241
241
  max_review_queue: 8
242
- expires_at: "<ISO-8601 UTC timestamp>"
243
242
  allow_gates: [advisory]
244
243
  ```
245
244
 
@@ -247,8 +246,9 @@ The workflow treats this file as configuration and never rewrites it.
247
246
  `max_slices` seeds the remaining budget in the active feature's `state.md`; the
248
247
  root charges that state exactly once after each green built slice and stops
249
248
  before another dispatch at zero. Unattended slice work additionally requires a
250
- valid `max_agents`, `max_minutes`, `max_review_queue`, and `expires_at`;
251
- sentinels that miss or malform these fail closed. Delete `.devrites/AFK` to
249
+ valid `max_agents`, `max_minutes`, and `max_review_queue`;
250
+ sentinels that miss or malform these fail closed. Leftover `expires_at` is
251
+ ignored and never rewritten. Delete `.devrites/AFK` to
252
252
  return to HITL.
253
253
 
254
254
  AFK still pauses for product, scope, or policy choices, irreversible risk,
@@ -40,7 +40,7 @@ The Go surface is intentionally closed and deterministic:
40
40
 
41
41
  | Lane | Commands | Owner |
42
42
  |---|---|---|
43
- | Candidate and deterministic checks | `check candidate`, `check readiness [--emit-binding]`, `check seal`, `check task-graph`, `check path-disjoint`, `check skill-trust`, `check indexes` | Candidate validates/hashes the strict project manifest; readiness checks phase files, the required `tasks.md` slice graph, or emits the vetted Build-input binding; seal checks final files/open gates, that graph and binding, then exact candidate bindings. `check indexes` reports install manifest and optional code-index directory presence as JSON. |
43
+ | Candidate and deterministic checks | `check candidate`, `check readiness [--emit-binding]`, `check seal`, `check task-graph`, `check path-disjoint`, `parallel select`, `check skill-trust`, `check indexes` | Candidate validates/hashes the strict project manifest; readiness checks phase files, the required `tasks.md` slice graph, or emits the vetted Build-input binding; seal checks final files/open gates, that graph and binding, then exact candidate bindings. `check indexes` reports install manifest and optional code-index directory presence as JSON. `parallel select` returns the greedy path-disjoint subset ≤ cap from the supplied ready slices. |
44
44
  | Workspace observation | `observe summary`, `orient`, `observe slice <slug> <SLICE-ID>` | JSON workspace snapshot for agents (cursor, task graph, `artifact_budgets`, `bulk_files`); `orient` is an alias for `observe summary`. `observe slice` prints one `SLICE-###` section of `tasks.md` so Build reads a slice, not the file. |
45
45
  | Atomic workspace state | `state resolve`, `state merge-manifest`, `state close`, `migrate [--dry-run] [--answer id=choice]` | Go owns answer/drop/batch resolution, the recorded predecessor-chain manifest union for a release milestone, transactional close, and fail-closed v5 schema normalization. |
46
46
  | Security | `secret-scan` | `/rite-ship`, safe hooks, or an operator scans staged blobs, stdin, or touched files. |
@@ -16,6 +16,7 @@ workflow strategy.
16
16
  | `check readiness --emit-binding <slug>` | Render the exact stable Build-input binding for Vet to record after review. |
17
17
  | `check seal <slug>` | Check files required by target Phase `seal`, open human gates, the `tasks.md` slice graph, canonical `AC-###` presence when `tasks.md`/`test-plan.md` are required, the stable Build-input binding, and exact candidate bindings. |
18
18
  | `check path-disjoint [--root <dir>] [<json-file> | -]` | Verify slice path sets are pairwise disjoint. |
19
+ | `parallel select --cap <1-10> [--root <dir>] [<json-file> | -]` | Choose the greedy path-disjoint subset ≤ cap from supplied ready slices. |
19
20
  | `check task-graph <slug>` | Validate `tasks.md` slice dependency graph for cycles, unknown deps, malformed tokens, duplicate IDs, missing `Dependencies`, and `depends_on` mismatch. |
20
21
  | `check skill-trust <path>` | Scan one skill/agent Markdown file for structural trust violations. |
21
22
  | `observe summary <slug>` | Emit sanitized JSON workspace summary from one retained observation. `task_graph.ok` is true iff `task_graph.problems` is empty; `problems` lists cycle, unknown-dep, malformed-token, duplicate-id, and missing-`Dependencies` blockers. |
@@ -130,8 +130,8 @@ Isolation does not authorize same-worktree throughput. Parallel writers are allo
130
130
  **only** under the `/rite-build` batch path when path-disjoint eligibility, abort-batch,
131
131
  and a control `parallel-lease.md` apply. `--parallel N` (or the AFK sentinel
132
132
  `max_parallel`, default cap 10 under `/rite-autocomplete`) is a **cap**: each round runs
133
- the largest eligible set, recomputes after every integrate, and repeats until no pending
134
- slice remains; fewer than two eligible slices fall back to the serial cycle (see
133
+ the largest eligible set, recomputes after every completed round, and repeats until no
134
+ pending slice remains; a one-slice round is serial for that round only (see
135
135
  [`parallel-batch.md`](../pack/.claude/skills/rite-build/reference/parallel-batch.md)).
136
136
  Same-worktree multi-writer and root-emulated worktrees remain forbidden; default
137
137
  `/rite-build` stays one writer across linked worktrees.
@@ -5,6 +5,7 @@ import (
5
5
  "fmt"
6
6
  "io"
7
7
  "os"
8
+ "strconv"
8
9
  "strings"
9
10
  )
10
11
 
@@ -71,6 +72,71 @@ func runPathDisjoint(args []string, stdin io.Reader, stdout, stderr io.Writer) i
71
72
  return ExitOK
72
73
  }
73
74
 
75
+ func cmdSelect(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
76
+ const usage = "usage: parallel select --cap <1-10> [--root <dir>] [<json-file>|-]"
77
+ root := ""
78
+ jsonPath := "-"
79
+ capN := 0
80
+ sawCap := false
81
+ for i := 0; i < len(args); i++ {
82
+ switch args[i] {
83
+ case "--root":
84
+ if i+1 >= len(args) {
85
+ fmt.Fprintln(stderr, usage)
86
+ return ExitUsage
87
+ }
88
+ i++
89
+ root = args[i]
90
+ case "--cap":
91
+ if i+1 >= len(args) {
92
+ fmt.Fprintln(stderr, usage)
93
+ return ExitUsage
94
+ }
95
+ i++
96
+ n, err := strconv.Atoi(args[i])
97
+ if err != nil {
98
+ fmt.Fprintf(stderr, "parallel select: --cap must be an integer\n")
99
+ return ExitUsage
100
+ }
101
+ capN = n
102
+ sawCap = true
103
+ case "-h", "--help":
104
+ fmt.Fprintln(stdout, usage)
105
+ return ExitOK
106
+ default:
107
+ if args[i] != "-" && strings.HasPrefix(args[i], "-") {
108
+ fmt.Fprintf(stderr, "parallel select: unknown flag %s\n", args[i])
109
+ return ExitUsage
110
+ }
111
+ jsonPath = args[i]
112
+ }
113
+ }
114
+ if !sawCap {
115
+ fmt.Fprintln(stderr, usage)
116
+ return ExitUsage
117
+ }
118
+ data, err := readJSONInput(jsonPath, stdin)
119
+ if err != nil {
120
+ fmt.Fprintf(stderr, "parallel select: %v\n", err)
121
+ return ExitBlocked
122
+ }
123
+ slices, err := ParseSlicesJSON(data)
124
+ if err != nil {
125
+ fmt.Fprintf(stderr, "parallel select: %v\n", err)
126
+ return ExitBlocked
127
+ }
128
+ selected, err := SelectGreedy(capN, slices, root)
129
+ if err != nil {
130
+ fmt.Fprintf(stderr, "parallel select: %v\n", err)
131
+ if strings.Contains(err.Error(), "cap must be") {
132
+ return ExitUsage
133
+ }
134
+ return ExitBlocked
135
+ }
136
+ fmt.Fprintln(stdout, formatSelect(selected))
137
+ return ExitOK
138
+ }
139
+
74
140
  func runParallel(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
75
141
  if len(args) == 0 {
76
142
  fmt.Fprintln(stderr, parallelUsage())
@@ -98,6 +164,8 @@ func runParallel(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
98
164
  return cmdLeaseClear(rest, stdout, stderr)
99
165
  case "check-disjoint", "path-disjoint":
100
166
  return runPathDisjoint(rest, stdin, stdout, stderr)
167
+ case "select":
168
+ return cmdSelect(rest, stdin, stdout, stderr)
101
169
  case "-h", "--help", "help":
102
170
  fmt.Fprintln(stdout, parallelUsage())
103
171
  return ExitOK
@@ -121,6 +189,7 @@ Subcommands:
121
189
  lease-read --root --slug [--field name]
122
190
  lease-clear --root --slug
123
191
  check-disjoint [--root] [<json-file>|-]
192
+ select --cap <1-10> [--root] [<json-file>|-]
124
193
 
125
194
  Exit codes: 0 ok, 2 usage, 3 blocked`)
126
195
  }
@@ -0,0 +1,76 @@
1
+ package parallel
2
+
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+ )
7
+
8
+ // SelectGreedy returns the largest plan-order pairwise-disjoint subset of ready
9
+ // whose size is ≤ cap. ready must already be dependency-satisfied and in plan
10
+ // order. cap is 1–MaxParallelSlices; 1 is a legal one-slice round, not a latch.
11
+ func SelectGreedy(cap int, ready []SlicePaths, root string) ([]SlicePaths, error) {
12
+ if cap < 1 || cap > MaxParallelSlices {
13
+ return nil, fmt.Errorf("cap must be 1-%d (got %d)", MaxParallelSlices, cap)
14
+ }
15
+ normalized := make([]SlicePaths, 0, len(ready))
16
+ seen := make(map[string]struct{}, len(ready))
17
+ for i, item := range ready {
18
+ label := fmt.Sprintf("slice %d", i)
19
+ if item.ID != "" {
20
+ if err := validateSliceID(item.ID); err != nil {
21
+ return nil, fmt.Errorf("%s: %w", label, err)
22
+ }
23
+ label = fmt.Sprintf("slice %q", item.ID)
24
+ } else {
25
+ return nil, fmt.Errorf("%s: missing id", label)
26
+ }
27
+ if _, ok := seen[item.ID]; ok {
28
+ return nil, fmt.Errorf("duplicate slice id %q", item.ID)
29
+ }
30
+ seen[item.ID] = struct{}{}
31
+ paths, err := validateSlicePaths(item.Paths, label, root)
32
+ if err != nil {
33
+ return nil, err
34
+ }
35
+ normalized = append(normalized, SlicePaths{ID: item.ID, Paths: paths})
36
+ }
37
+
38
+ selected := make([]SlicePaths, 0, min(cap, len(normalized)))
39
+ for _, cand := range normalized {
40
+ if len(selected) >= cap {
41
+ break
42
+ }
43
+ if len(selected) == 0 {
44
+ selected = append(selected, cand)
45
+ continue
46
+ }
47
+ trial := append(append([]SlicePaths{}, selected...), cand)
48
+ if _, err := CheckPathDisjoint(trial, root); err != nil {
49
+ if strings.Contains(err.Error(), "overlap") {
50
+ continue
51
+ }
52
+ return nil, err
53
+ }
54
+ selected = trial
55
+ }
56
+ return selected, nil
57
+ }
58
+
59
+ func selectMode(n int) string {
60
+ switch {
61
+ case n <= 0:
62
+ return "none"
63
+ case n == 1:
64
+ return "serial"
65
+ default:
66
+ return "parallel"
67
+ }
68
+ }
69
+
70
+ func formatSelect(selected []SlicePaths) string {
71
+ ids := make([]string, len(selected))
72
+ for i, item := range selected {
73
+ ids[i] = item.ID
74
+ }
75
+ return fmt.Sprintf("select: n_eff=%d mode=%s slices=%s", len(selected), selectMode(len(selected)), strings.Join(ids, ","))
76
+ }
@@ -0,0 +1,95 @@
1
+ package parallel
2
+
3
+ import (
4
+ "bytes"
5
+ "strings"
6
+ "testing"
7
+ )
8
+
9
+ func TestSelectGreedyOneThenMany(t *testing.T) {
10
+ t.Parallel()
11
+ round1, err := SelectGreedy(5, []SlicePaths{
12
+ {ID: "SLICE-001", Paths: []string{"src/a.go"}},
13
+ }, "")
14
+ if err != nil {
15
+ t.Fatal(err)
16
+ }
17
+ if len(round1) != 1 || round1[0].ID != "SLICE-001" {
18
+ t.Fatalf("round1=%#v", round1)
19
+ }
20
+
21
+ round2, err := SelectGreedy(5, []SlicePaths{
22
+ {ID: "SLICE-002", Paths: []string{"src/b.go"}},
23
+ {ID: "SLICE-003", Paths: []string{"src/c.go"}},
24
+ {ID: "SLICE-004", Paths: []string{"src/d.go"}},
25
+ {ID: "SLICE-005", Paths: []string{"src/e.go"}},
26
+ }, "")
27
+ if err != nil {
28
+ t.Fatal(err)
29
+ }
30
+ if len(round2) != 4 {
31
+ t.Fatalf("after a one-slice round, cap 5 with 4 ready must select 4, got %d (%#v)", len(round2), round2)
32
+ }
33
+ }
34
+
35
+ func TestSelectGreedySkipsOverlapKeepsCap(t *testing.T) {
36
+ t.Parallel()
37
+ got, err := SelectGreedy(5, []SlicePaths{
38
+ {ID: "SLICE-001", Paths: []string{"src/shared.go"}},
39
+ {ID: "SLICE-002", Paths: []string{"src/shared.go", "src/b.go"}},
40
+ {ID: "SLICE-003", Paths: []string{"src/c.go"}},
41
+ }, "")
42
+ if err != nil {
43
+ t.Fatal(err)
44
+ }
45
+ if len(got) != 2 || got[0].ID != "SLICE-001" || got[1].ID != "SLICE-003" {
46
+ t.Fatalf("got %#v", got)
47
+ }
48
+ }
49
+
50
+ func TestSelectGreedyRejectsBadCap(t *testing.T) {
51
+ t.Parallel()
52
+ if _, err := SelectGreedy(0, nil, ""); err == nil {
53
+ t.Fatal("cap 0 should fail")
54
+ }
55
+ if _, err := SelectGreedy(11, nil, ""); err == nil {
56
+ t.Fatal("cap 11 should fail")
57
+ }
58
+ }
59
+
60
+ func TestSelectCLIOneThenMany(t *testing.T) {
61
+ t.Parallel()
62
+ var stdout, stderr bytes.Buffer
63
+ in := strings.NewReader(`{"slices":[{"id":"SLICE-001","paths":["src/a.go"]}]}`)
64
+ code := Run("parallel", []string{"select", "--cap", "5", "-"}, in, &stdout, &stderr)
65
+ if code != ExitOK {
66
+ t.Fatalf("code=%d stderr=%s", code, stderr.String())
67
+ }
68
+ if got := stdout.String(); got != "select: n_eff=1 mode=serial slices=SLICE-001\n" {
69
+ t.Fatalf("round1 got %q", got)
70
+ }
71
+
72
+ stdout.Reset()
73
+ stderr.Reset()
74
+ in = strings.NewReader(`{"slices":[
75
+ {"id":"SLICE-002","paths":["src/b.go"]},
76
+ {"id":"SLICE-003","paths":["src/c.go"]},
77
+ {"id":"SLICE-004","paths":["src/d.go"]}
78
+ ]}`)
79
+ code = Run("parallel", []string{"select", "--cap", "5", "-"}, in, &stdout, &stderr)
80
+ if code != ExitOK {
81
+ t.Fatalf("code=%d stderr=%s", code, stderr.String())
82
+ }
83
+ if got := stdout.String(); got != "select: n_eff=3 mode=parallel slices=SLICE-002,SLICE-003,SLICE-004\n" {
84
+ t.Fatalf("round2 got %q; must not stay n_eff=1", got)
85
+ }
86
+ }
87
+
88
+ func TestSelectCLIRequiresCap(t *testing.T) {
89
+ t.Parallel()
90
+ var stdout, stderr bytes.Buffer
91
+ code := Run("parallel", []string{"select", "-"}, strings.NewReader(`{"slices":[]}`), &stdout, &stderr)
92
+ if code != ExitUsage {
93
+ t.Fatalf("code=%d want %d stderr=%s", code, ExitUsage, stderr.String())
94
+ }
95
+ }
@@ -13,6 +13,7 @@
13
13
  "Bash(devrites-engine orient *)",
14
14
  "Bash(devrites-engine observe *)",
15
15
  "Bash(devrites-engine parallel status *)",
16
+ "Bash(devrites-engine parallel select *)",
16
17
  "Bash(devrites-engine parallel create *)",
17
18
  "Bash(devrites-engine parallel record-green *)",
18
19
  "Bash(devrites-engine parallel integrate *)",
@@ -54,7 +54,6 @@ max_slices: 10 # whole-workspace writer budget; seeds stat
54
54
  max_agents: 32 # native agent dispatches in one host activation
55
55
  max_minutes: 120 # wall-clock minutes in one host activation
56
56
  max_review_queue: 8 # unresolved review/gate items admitted before fan-out stops
57
- expires_at: "<ISO-8601 UTC timestamp>" # absolute unattended-authority expiry
58
57
  # max_tokens: 200000 # optional stricter host-observed token cap
59
58
  # max_cost_usd: 10 # optional stricter host-observed cost cap
60
59
  notify: "ntfy.sh/my-topic" # shell command; examples: rite-build/reference/afk-discipline.md
@@ -108,7 +107,7 @@ candidate manifest to cover the whole recorded chain — run
108
107
 
109
108
  - Only continuations recorded in the parent's `decisions.md` sequence
110
109
  ([slicing.md § Continuation workspaces](../../../rite-plan/reference/slicing.md#continuation-workspaces))
111
- qualify; no recorded next entry, or the cap/expiry/review-queue bound reached, stops
110
+ qualify; no recorded next entry, or the cap/review-queue bound reached, stops
112
111
  with the winning reason.
113
112
  - Milestones are **not** shipped: they stay sealed and unarchived in `.devrites/work/`
114
113
  with `Next step: /rite-ship` preserved. Per-slice `WIP(<slug>)` checkpoints still
@@ -121,34 +120,34 @@ candidate manifest to cover the whole recorded chain — run
121
120
  run exactly as without this field.
122
121
 
123
122
  `max_parallel` caps a Build batch for unattended runs; `1` forces the serial cycle.
124
- Unattended runs take the largest eligible set ≤ cap and recompute after every integrate
123
+ Unattended runs take the largest eligible set ≤ cap and recompute after every completed
124
+ round (serial slice or parallel integrate)
125
125
  ([parallel-batch.md § Dynamic selection and re-batching](../../../rite-build/reference/parallel-batch.md#dynamic-selection-and-re-batching));
126
126
  an explicit `/rite-build --parallel N` cap wins for that invocation.
127
127
 
128
128
  ## Unattended resource envelope
129
129
 
130
130
  AFK writer admission needs a bounded input queue, effective slice cap, and valid
131
- `max_agents`, `max_minutes`, `max_review_queue`, and `expires_at`. Existing sentinels
131
+ `max_agents`, `max_minutes`, and `max_review_queue`. Existing sentinels
132
132
  that declare writer admission but miss/malform these fail closed; cold resume keeps the
133
- state-owned slice counter.
133
+ state-owned slice counter. A leftover `expires_at` is ignored and never rewritten.
134
134
  Read-only watchers use equivalent native caps from [`loop-operations.md`](loop-operations.md).
135
135
 
136
136
  `max_agents` counts every leaf in the native activation, including failures and
137
137
  parallel branches; do not add dispatch telemetry to `.devrites/`. `max_review_queue`
138
138
  counts open validating questions plus unresolved admitted Critical/Important findings.
139
- Above it stop; at it run only reconciliation that reduces the queue. `expires_at` is
140
- absolute ISO-8601 authority. Optional `max_tokens`/`max_cost_usd` lower enforceable
141
- native caps; if declared but unobservable, stop.
139
+ Above it stop; at it run only reconciliation that reduces the queue. Optional
140
+ `max_tokens`/`max_cost_usd` lower enforceable native caps; if declared but unobservable, stop.
142
141
 
143
142
  Numeric limits are nonnegative decimals. Before costly checks, fan-out, or writing,
144
143
  run cheap readiness, reject overlap, count queue, and confirm agent/time/token/cost
145
144
  headroom; re-check after every result. Never start one call that can exceed remaining
146
145
  headroom. Agent/time/token/cost counters are per native activation and start fresh only
147
- for a genuinely new activation. Slices, recovery attempts, absolute expiry, and current
146
+ for a genuinely new activation. Slices, recovery attempts, and current
148
147
  review queue remain durable/recomputed across wakes. Persist each activation stop and
149
148
  checkpoint before notification.
150
149
 
151
- New sentinels default `expires_at` to arming + 4h with no notification/token/cost cap.
150
+ New sentinels write no `expires_at` and no notification/token/cost cap.
152
151
  Post-Vet pending count may lower slices. Existing files
153
152
  never receive missing defaults implicitly.
154
153
 
@@ -38,13 +38,13 @@ Every unattended loop must name:
38
38
  4. **Evaluator:** the skill's existing readiness, proof, review, or watcher verdict.
39
39
  5. **Budget:** every applicable `.devrites/AFK` resource cap.
40
40
  6. **Checkpoint:** durable workspace/evidence update before the turn ends.
41
- 7. **Stop:** success, human/safety/access gate, expiry, budget exhaustion, unchanged
41
+ 7. **Stop:** success, human/safety/access gate, budget exhaustion, unchanged
42
42
  no-progress fingerprint, host failure, or terminal external state.
43
43
  8. **Notification:** optional native-host notification after state is durable; never a
44
44
  substitute for recording the stop.
45
45
 
46
46
  A read-only scheduled/event loop that has no active AFK workspace must still configure
47
- native maximum activations/iterations, wall time, and absolute expiry. Add token/cost
47
+ native maximum activations/iterations and wall time. Add token/cost
48
48
  caps when the host exposes them. One observation cycle per wake is the work unit; the
49
49
  skill never starts its own timer or background poller.
50
50
 
@@ -76,7 +76,7 @@ armed AFK workspace whose exact scope, gates, and budgets permit it.
76
76
  is `gap`/`cannot_verify`, never success.
77
77
  - Do not retry unchanged work merely because a timer fired. Apply the exact
78
78
  causal-fingerprint recovery cap ([`afk-hitl.md`](afk-hitl.md)).
79
- - A cold resume continues durable slice/recovery state and absolute expiry. Fresh
79
+ - A cold resume continues durable slice/recovery state. Fresh
80
80
  native activation counters follow `afk-hitl.md`; no durable bound is reinitialized.
81
81
  - Native notifications fire only after evidence and stop state are written.
82
82
 
@@ -48,7 +48,7 @@ executable controller/harness/bundle bytes or a missing writer, read
48
48
  - Every exact causal fingerprint gets at most three no-progress corrections.
49
49
  Closing one is progress; a distinct Critical/Important invariant has its own
50
50
  budget. Lower severity cannot prolong recovery.
51
- - Enforce `--max-slices`, the AFK sentinel, expiry, review queue, and native
51
+ - Enforce `--max-slices`, the AFK sentinel, review queue, and native
52
52
  agent/token/cost/time limits before every phase or dispatch. Count failed,
53
53
  malformed, and unavailable leaf calls. At the review cap, permit only work
54
54
  that reduces the queue.
@@ -94,9 +94,10 @@ executable controller/harness/bundle bytes or a missing writer, read
94
94
  `/rite-review` → `/rite-seal`. Read and execute each skill; durable files, not
95
95
  chat, carry state. Apply the mutable post-vet budget before first Build.
96
96
  Build runs the largest eligible path-disjoint batch (cap: `--parallel N`, else
97
- sentinel `max_parallel`, else 10) and recomputes after every integrate until no
98
- pending slice remains; serial only when fewer than two slices are eligible or the
99
- host cannot isolate concurrent worktree writers.
97
+ sentinel `max_parallel`, else 10) and recomputes after every completed round until no
98
+ pending slice remains; a one-slice round is serial for that round only, then
99
+ selection runs again (host isolation still forces serial when concurrent writers
100
+ cannot be separated).
100
101
  **Completion:** loop reaches Seal GO or persists a valid stop before any later phase.
101
102
  5. **Apply stops.** At every gate use
102
103
  [stop-conditions.md](reference/stop-conditions.md). A `blocked` label alone is not a stop condition:
@@ -18,7 +18,6 @@ max_slices: 10
18
18
  max_agents: 32
19
19
  max_minutes: 120
20
20
  max_review_queue: 8
21
- expires_at: "<now + 4 hours>"
22
21
  # continue_sequence: true # opt-in: chain recorded continuations after Seal GO
23
22
  # max_workspaces: 5 # sequence budget when chaining
24
23
  # max_parallel: 10 # Build batch cap; 1 = serial (default: eligible, cap 10)
@@ -28,11 +27,11 @@ expires_at: "<now + 4 hours>"
28
27
  ```
29
28
 
30
29
  Read an existing sentinel first. Preserve it byte-for-byte when valid; stop if
31
- its gate ceiling exceeds advisory, required envelope is malformed/expired, or
30
+ its gate ceiling exceeds advisory, required envelope is malformed, or
32
31
  `max_slices` conflicts with the invocation. If absent, write it once after
33
- clarity, replacing the safe slice default only for explicit `--max-slices N`
34
- and resolving one absolute UTC expiry. It is read-only: never rewrite it after
35
- Vet or reset it on resume.
32
+ clarity, replacing the safe slice default only for explicit `--max-slices N`.
33
+ It is read-only: never rewrite it after Vet or reset it on resume. Leftover
34
+ `expires_at` is ignored and never rewritten.
36
35
 
37
36
  ### Derive the mutable post-vet budget
38
37
 
@@ -45,12 +44,12 @@ or reinitialize it. AFK configuration itself stays unchanged.
45
44
 
46
45
  Before every phase, review fan-out, recovery, or writer dispatch, apply
47
46
  [`afk-hitl.md`](../../devrites-lib/reference/standards/afk-hitl.md#unattended-resource-envelope): cheapest current-state/readiness
48
- check first; reject overlap; count unresolved review; check expiry and native
47
+ check first; reject overlap; count unresolved review; check native
49
48
  agent/token/cost/time headroom. Count every leaf result. At the review cap, only
50
49
  reconciliation that reduces the queue may run. Any reached or unobservable
51
50
  bound stops before more work and persists the winning reason. A new activation
52
- gets fresh activation-local counters but retains durable slice/recovery state,
53
- expiry, and recomputed queue.
51
+ gets fresh activation-local counters but retains durable slice/recovery state
52
+ and recomputed queue.
54
53
 
55
54
  `allow_gates: [advisory]` means validating gates pause now rather than becoming
56
55
  Seal NO-GO. Only explicit human configuration outside Autocomplete may widen it.
@@ -66,7 +65,7 @@ Workspace files carry state; chat does not. Read and execute each phase skill:
66
65
  | 3 | `/rite-temper` | harden or reduce; expansion and irreversible risk pause |
67
66
  | 4 | `/rite-define` | approved plan/tasks/traceability |
68
67
  | 5 | `/rite-vet` | every plan; derive mutable budget after READY |
69
- | 6 | `/rite-build` batch loop | largest eligible path-disjoint set (cap 10; serial when <2 eligible); recompute after each integrate; charge once per green built slice |
68
+ | 6 | `/rite-build` batch loop | largest eligible path-disjoint set (cap 10; one-slice round when <2 eligible); recompute after each round; charge once per green built slice |
70
69
  | 7 | `/rite-prove` | all slices built; approved proof; recovery on red |
71
70
  | 8 | `/rite-polish` | re-prove after code edits |
72
71
  | 9 | `/rite-review` | in-scope correction then fresh proof |
@@ -100,7 +99,7 @@ fields are missing is re-seeded from its `brief.md` parent/position and the
100
99
  parent's counter (same values, never a second charge); a child with no recorded
101
100
  parent/position is not a sequence member and the chain stops.
102
101
 
103
- Stop instead when: no recorded next entry; the cap, expiry, or review-queue bound is
102
+ Stop instead when: no recorded next entry; the cap or review-queue bound is
104
103
  reached; a human-owned, safety, access, or exhaustion condition fires; or Seal returns
105
104
  `NO-GO`. On stop, report the sequence position, the sealed-but-unshipped workspaces, and
106
105
  the single release command (`/rite-autocomplete <release milestone> --ship`, or
@@ -71,11 +71,10 @@ exhausted.
71
71
  when slices remain; malformed state also stops. Report whether the winning
72
72
  bound was the pre-existing remaining value, explicit flag, sentinel cap, or post-vet pending count.
73
73
  Zero with no pending slices is normal completion and proceeds to Prove.
74
- - **Resource envelope:** missing/malformed/expired AFK, overlapping run,
74
+ - **Resource envelope:** missing/malformed AFK, overlapping run,
75
75
  exhausted/unobservable declared agent/token/cost/time headroom, or review queue
76
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.
77
+ bound and observed usage; a new activation does not reset durable budgets.
79
78
  - **Confidence:** intent still cannot become testable acceptance after interview.
80
79
  - **Repeated failure:** the exact fingerprint's bounded recovery is exhausted.
81
80
 
@@ -60,7 +60,8 @@ Wright applies anti-slop; root verifies returns and never patches source.
60
60
 
61
61
  Omitted/`1` ≡ serial; `2`–`10` is a **cap** — the root runs the largest eligible
62
62
  path-disjoint set it can start now (`N_eff`), takes fewer when the cap cannot be
63
- filled, and recomputes after every integrate until no pending slice remains
63
+ filled, and recomputes after every completed round (serial slice or parallel
64
+ integrate) until no pending slice remains
64
65
  ([`parallel-batch.md` § Dynamic selection](reference/parallel-batch.md#dynamic-selection-and-re-batching)).
65
66
  Unattended runs (`/rite-autocomplete`, `.devrites/AFK` `max_parallel`) repeat batches
66
67
  inside the same run; HITL stops after each batch. Non-integer/`N≤0`/`N>10` hard refuse.
@@ -16,7 +16,9 @@ control; irreversible work (destructive/auth/public API) always pauses.
16
16
  The controlling root owns the cap:
17
17
 
18
18
  1. **Before every dispatch**, re-read `.devrites/AFK`, `state.md`, and the
19
- selected slice. A configured `max_slices` and any existing
19
+ selected slice. When `--parallel N` or sentinel `max_parallel` is greater than
20
+ 1, recompute `N_eff` via `parallel select` before the next dispatch — a prior
21
+ one-slice round does not keep the run serial. A configured `max_slices` and any existing
20
22
  `afk_slices_remaining` value, including its released bullet form, must each
21
23
  be a decimal nonnegative integer. A missing
22
24
  `state.md` or malformed configured value fails closed; an omitted cap is the
@@ -26,7 +26,7 @@ RECORD → orchestrator: after green verification, update state.md/evidence.m
26
26
  upsert the authoritative candidate manifest from the actual scoped diff
27
27
  (CHECKPOINT) → orchestrator: commit the proven slice local-only as WIP(<slug>)
28
28
  with a [devrites-context] body → clean tree, survives a crash (checkpoint.md)
29
- NEXT → HITL root reports and stops; AFK root may repeat only under afk-discipline.md
29
+ NEXT → HITL root reports and stops. AFK with parallel cap>1: return to parallel-batch selection and run the new N_eff; otherwise repeat under afk-discipline.md
30
30
  ```
31
31
 
32
32
  ## Why the boundary matters
@@ -28,18 +28,20 @@ N_eff = min(
28
28
  )
29
29
  ```
30
30
 
31
- Select **greedily in plan order**: walk pending slices whose `depends_on` are built and
32
- add each one while it stays pairwise disjoint with the selected set and the cap is not
33
- reached. Then `N_eff 2` parallel batch; `N_eff = 1` → the serial one-slice cycle;
34
- nothing pending → Prove. A cap that cannot be filled is normal: take fewer.
35
-
36
- **Re-batch automatically.** After integrate + cleanup are green, re-read `state.md`,
37
- the pending slices (`observe slice`), and the updated tree, then recompute: integrated
38
- siblings leave the pending set and free their paths, and satisfied dependencies unlock
39
- new slices. Repeat until no pending slice remains. Under `.devrites/AFK` and
40
- `/rite-autocomplete` the repeat is part of the same run — a new batch is another
41
- `/rite-build --parallel` round inside it, not a new user invocation; HITL stops after
42
- each batch. A batch of three followed by one of four and then two is the expected shape.
31
+ Select **greedily in plan order**: pass every currently dependency-ready pending slice
32
+ (plan order, `Files likely touched`) to
33
+ `devrites-engine parallel select --cap N [--root <dir>]`. `N_eff 2` → parallel batch;
34
+ `N_eff = 1` → one serial round; nothing pending → Prove. A cap that cannot be filled
35
+ is normal: take fewer. Serial is this round's size, not the rest of the run.
36
+
37
+ **Re-batch automatically after every completed round** (parallel integrate+cleanup or
38
+ a serial slice). Re-read `state.md`, pending slices, and the tree, then run
39
+ `parallel select` again: finished work leaves the pending set, and satisfied
40
+ dependencies unlock new slices. Under `.devrites/AFK` and `/rite-autocomplete` the
41
+ repeat is the same run HITL stops after each batch. `--parallel 5` with one eligible
42
+ slice runs that one; when two to five then become eligible, the next round takes that
43
+ many. **Failing case:** the run stays one-by-one after a serial round even though more
44
+ slices are now eligible under the same cap.
43
45
 
44
46
  ## Path-disjoint
45
47
 
@@ -71,7 +73,8 @@ Lease: `batch_id`, `created_at`, `base_sha`, `n`,
71
73
  1. Orient/gate; parse the cap; compute `N_eff` and select the eligible set
72
74
  ([Dynamic selection and re-batching](#dynamic-selection-and-re-batching)) —
73
75
  candidates from `orient` `task_graph.slices` + built list, each candidate's
74
- `Files likely touched` via `observe slice`, disjointness via `check path-disjoint`.
76
+ `Files likely touched` via `observe slice`, then
77
+ `parallel select --cap N` (pairwise disjointness is inside that verb).
75
78
  2. Write lease; freeze `B=HEAD`; `parallel create` worktrees.
76
79
  3. Dispatch ≤10 wrights in parallel (cwd=worktree; allowlist; prove `HEAD==B`).
77
80
  4. Inspect each returned path list, cumulative diff from `B`, transfer identity,
@@ -163,6 +166,7 @@ Repair rejected work in place; never discard/rebuild while budget remains.
163
166
  ## Engine verbs
164
167
 
165
168
  ```text
169
+ devrites-engine parallel select --cap <1-10> [--root <dir>] [<json-file>|-]
166
170
  devrites-engine parallel create --root <repo> --slug <slug> --batch <id> --base <B> --json <file>|-
167
171
  devrites-engine parallel record-green --root <repo> --slug <slug> --slice <id> --commit <sha>
168
172
  devrites-engine parallel integrate --root <repo> --slug <slug> --apply-to-control
@@ -13,6 +13,7 @@
13
13
  "Bash(devrites-engine orient *)",
14
14
  "Bash(devrites-engine observe *)",
15
15
  "Bash(devrites-engine parallel status *)",
16
+ "Bash(devrites-engine parallel select *)",
16
17
  "Bash(devrites-engine parallel create *)",
17
18
  "Bash(devrites-engine parallel record-green *)",
18
19
  "Bash(devrites-engine parallel integrate *)",