@giamme/forge 0.22.0 → 0.23.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 (153) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +19 -12
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/docs/README.md +2 -3
  6. package/docs/add-ons.md +5 -3
  7. package/docs/artifacts.md +17 -2
  8. package/docs/commands.md +85 -63
  9. package/docs/decomposed-runs.md +195 -21
  10. package/docs/development.md +11 -9
  11. package/docs/forge-ui.md +33 -4
  12. package/docs/install.md +37 -5
  13. package/docs/memory.md +6 -1
  14. package/docs/models.md +36 -10
  15. package/docs/reviews.md +44 -25
  16. package/docs/safety.md +27 -2
  17. package/docs/troubleshooting.md +7 -10
  18. package/forge +25 -4
  19. package/package.json +2 -1
  20. package/references/dataset.md +10 -9
  21. package/references/decompose-integration.md +337 -0
  22. package/references/decompose-opt-in.md +527 -0
  23. package/references/decompose-recovery.md +569 -0
  24. package/references/decompose-review.md +256 -0
  25. package/references/decompose.md +99 -1606
  26. package/references/findings.md +68 -0
  27. package/references/harnesses.md +7 -12
  28. package/references/memory.md +13 -2
  29. package/references/planning.md +48 -18
  30. package/references/ripwire.md +38 -13
  31. package/references/runtime.md +22 -33
  32. package/references/setup.md +90 -0
  33. package/references/solo.md +13 -42
  34. package/references/ui.md +12 -5
  35. package/registry.tsv +40 -22
  36. package/scripts/forge-artifact.sh +143 -12
  37. package/scripts/forge-compare.py +5 -15
  38. package/scripts/forge-config.py +14 -1
  39. package/scripts/forge-contract.py +216 -53
  40. package/scripts/forge-control.py +777 -54
  41. package/scripts/forge-dispatch.sh +95 -12
  42. package/scripts/forge-du.py +13 -3
  43. package/scripts/forge-handoff.py +221 -39
  44. package/scripts/forge-install-ripwire.sh +100 -24
  45. package/scripts/forge-install.sh +18 -32
  46. package/scripts/forge-issues.py +6 -4
  47. package/scripts/forge-jev-options.sh +3 -5
  48. package/scripts/forge-lib-adopt.sh +169 -5
  49. package/scripts/forge-lib-attribute.sh +10 -3
  50. package/scripts/forge-lib-decompose.sh +454 -0
  51. package/scripts/forge-lib-env.sh +21 -0
  52. package/scripts/forge-lib-group.sh +4 -1
  53. package/scripts/forge-lib-plans.sh +30 -18
  54. package/scripts/forge-lib-review.sh +28 -8
  55. package/scripts/forge-lib-task.sh +225 -56
  56. package/scripts/forge-lib-verify.sh +59 -10
  57. package/scripts/forge-memory.sh +81 -4
  58. package/scripts/forge-metrics.sh +4 -2
  59. package/scripts/forge-parallel-options.sh +23 -4
  60. package/scripts/forge-parallel.sh +447 -175
  61. package/scripts/forge-plan-check.py +71 -8
  62. package/scripts/forge-planner.py +303 -17
  63. package/scripts/forge-pr.py +9 -1
  64. package/scripts/forge-prompt.py +2 -2
  65. package/scripts/forge-review-links.py +248 -0
  66. package/scripts/forge-ripwire.py +234 -16
  67. package/scripts/forge-route.py +19 -27
  68. package/scripts/forge-runs-rm.py +92 -21
  69. package/scripts/forge-runs.py +46 -5
  70. package/scripts/forge-runtime.py +37 -12
  71. package/scripts/forge-schedule.py +124 -33
  72. package/scripts/forge-setup-stale.py +236 -0
  73. package/scripts/forge-setup.py +804 -0
  74. package/scripts/forge-shadow.py +2 -20
  75. package/scripts/forge-solo-lock.py +46 -0
  76. package/scripts/forge-solo.sh +33 -56
  77. package/scripts/forge-sweep.py +2 -1
  78. package/scripts/forge-ui.py +8 -1
  79. package/scripts/forge-update.sh +2 -2
  80. package/scripts/forge-verify.py +16 -1
  81. package/scripts/forge-version.py +13 -1
  82. package/scripts/forge-watch.py +7 -2
  83. package/scripts/forge_dataset/__init__.py +1 -1
  84. package/scripts/forge_dataset/capture.py +0 -34
  85. package/scripts/forge_dataset/checks.py +0 -1
  86. package/scripts/forge_dataset/cli.py +5 -1
  87. package/scripts/forge_dataset/export.py +28 -6
  88. package/scripts/forge_dataset/facts.py +1 -2
  89. package/scripts/forge_dataset/forecast.py +1 -1
  90. package/scripts/forge_dataset/harvest.py +107 -7
  91. package/scripts/forge_dataset/importer.py +3 -2
  92. package/scripts/forge_dataset/pairs.py +3 -3
  93. package/scripts/forge_dataset/reviewers.py +4 -3
  94. package/scripts/forge_dataset/routing.py +6 -3
  95. package/scripts/forge_dataset/tiers.py +1 -1
  96. package/scripts/forge_decide/__init__.py +1 -1
  97. package/scripts/forge_decide/profiles.py +11 -14
  98. package/scripts/forge_decompose.py +987 -0
  99. package/scripts/forge_groups/review.py +6 -1
  100. package/scripts/forge_jev/__init__.py +1 -1
  101. package/scripts/forge_jev/cli.py +10 -1
  102. package/scripts/forge_jev/gates.py +10 -1
  103. package/scripts/forge_jev/verify.py +10 -2
  104. package/scripts/forge_legacy.py +86 -0
  105. package/scripts/forge_memory_home.py +57 -0
  106. package/scripts/forge_models.py +151 -0
  107. package/scripts/forge_prefs.py +138 -0
  108. package/scripts/forge_side/__init__.py +10 -0
  109. package/scripts/forge_storage.py +28 -15
  110. package/ui/README.md +22 -10
  111. package/ui/docs/api.md +121 -99
  112. package/ui/forge_ui/control.py +46 -14
  113. package/ui/forge_ui/export.py +0 -10
  114. package/ui/forge_ui/models.py +15 -2
  115. package/ui/forge_ui/projects.py +4 -1
  116. package/ui/forge_ui/reader.py +456 -59
  117. package/ui/forge_ui/server.py +0 -10
  118. package/ui/forge_ui/static/app.js +28 -9
  119. package/ui/forge_ui/static/checksview.js +12 -3
  120. package/ui/forge_ui/static/controls.js +147 -11
  121. package/ui/forge_ui/static/convo.js +5 -2
  122. package/ui/forge_ui/static/diffview.js +4 -5
  123. package/ui/forge_ui/static/panel.js +180 -77
  124. package/ui/forge_ui/static/projectsview.js +16 -2
  125. package/ui/forge_ui/static/runmodel.js +18 -4
  126. package/ui/forge_ui/static/scene3d.js +29 -29
  127. package/ui/forge_ui/static/settings.js +1 -1
  128. package/ui/forge_ui/static/storageview.js +2 -2
  129. package/ui/forge_ui/static/style.css +23 -6
  130. package/ui/forge_ui/static/worktreesview.js +8 -4
  131. package/ui/forge_ui/transcripts.py +6 -0
  132. package/ui/forge_ui/worktrees.py +13 -1
  133. package/docs/fractal.md +0 -181
  134. package/references/fractal-dashboard.md +0 -21
  135. package/references/fractal.md +0 -307
  136. package/scripts/forge-fractal-dispatch.sh +0 -4
  137. package/scripts/forge-fractal-options.sh +0 -54
  138. package/scripts/forge-fractal.py +0 -6
  139. package/scripts/forge-install-fractal.sh +0 -4
  140. package/scripts/forge_fractal/__init__.py +0 -88
  141. package/scripts/forge_fractal/bridge.py +0 -46
  142. package/scripts/forge_fractal/cli.py +0 -224
  143. package/scripts/forge_fractal/dashboard.css +0 -138
  144. package/scripts/forge_fractal/dashboard.html +0 -41
  145. package/scripts/forge_fractal/dashboard.js +0 -687
  146. package/scripts/forge_fractal/decomposition.py +0 -262
  147. package/scripts/forge_fractal/execution.py +0 -659
  148. package/scripts/forge_fractal/inspection.py +0 -261
  149. package/scripts/forge_fractal/install.py +0 -158
  150. package/scripts/forge_fractal/invocation.py +0 -95
  151. package/scripts/forge_fractal/pipeline.py +0 -125
  152. package/scripts/forge_fractal/selection.py +0 -180
  153. package/ui/forge_ui/fractal.py +0 -582
@@ -0,0 +1,527 @@
1
+ # Decomposed runs: opt-in modes
2
+
3
+ Opt-in modes of a decomposed run: offer them, never add them unprompted. Part of the
4
+ decomposition reference; planning is in [decompose.md](decompose.md).
5
+
6
+ What the orchestrator does in each mode:
7
+
8
+ - **Groups**: offer `plan --groups` and `plan --group-review` for several small, related, low-risk tasks;
9
+ keep a high-risk task on per-task review.
10
+ - **Brief and summaries** need a model the user names (`--brief-model`, `--summaries-model` or `forge
11
+ config set`); forge never picks one. With brief on, relay the questions from `forge brief show <plan>`,
12
+ pass the user's answers with `forge brief answer`, and never answer for the user. A strict brief run
13
+ exits `3` before any task starts while questions are open.
14
+ - **Retro**: record each obstacle with `forge retro note <plan> --type T --fixable-by F --summary S`
15
+ (`T`: `environment`, `sandbox`, `tooling`, `prompt`, `forge-bug` or `other`; `F`: `user`, `forge` or
16
+ `unsure`), and at the end of the run relay the groups in `<plan>/retro.md`. `forge retro issues` posts
17
+ only on the user's approval of the exact text it prints (`--apply --approve <hash>`).
18
+
19
+ ## Contents
20
+
21
+ - [Groups and group review (opt-in)](#groups-and-group-review-opt-in)
22
+ - [Retro notes (opt-in)](#retro-notes-opt-in)
23
+ - [Brief mode (opt-in)](#brief-mode-opt-in)
24
+ - [Task summaries (opt-in)](#task-summaries-opt-in)
25
+
26
+ ## Groups and group review (opt-in)
27
+
28
+ Two opt-ins share `groups.tsv`. A planner may name groups, and those are identity only
29
+ (`review=task`): they do not change dispatch or the estimate.
30
+ `plan --groups` with `--group-review` is the other opt-in: one QA review covers several tasks.
31
+ Offer either; never add them unprompted. The user-facing tradeoff is in
32
+ [group review](../docs/reviews.md#group-review-opt-in). The data layer is `scripts/forge_groups`
33
+ and `scripts/forge-groups.py` (`validate`, `derive`, `resolve`, `freeze`, `check`, `of`, `show`).
34
+
35
+ ### `groups.tsv`
36
+
37
+ Six tab-separated columns. `#` lines and blank lines are ignored.
38
+
39
+ ```
40
+ # id review qa members title goal
41
+ ```
42
+
43
+ - `id` matches `[a-z0-9][a-z0-9-]{0,39}`, is unique, and is not also a task id.
44
+ - `review` is `task` or `group`.
45
+ - `qa` is a spec, or `-`.
46
+ - `members` is a comma list of task ids, in order. A task is in at most one group.
47
+ - `title` and `goal` are one line each, or `-` when absent. A planner's title and goal are
48
+ at most 200 characters.
49
+
50
+ Where a row comes from:
51
+
52
+ - A planner reply that includes `groups` writes `groups.tsv` with `review` always `task` and
53
+ `qa` always `-`. A planner group may have one member. The planner never sets `review=group`.
54
+ - `plan --groups waves` makes one group per computed wave that has at least two tasks, named
55
+ `w1`, `w2`, and so on. A wave larger than the max splits in `tasks.tsv` order into `w3a`,
56
+ `w3b`, and so on. A leftover single task is dropped. Each gets the title `Wave 3` (`Wave 3a`)
57
+ and no goal: nothing in a computed wave says what it is for.
58
+ - `--group-review` is only valid with `--groups waves`. Without it, `plan` exits 2:
59
+ `--group-review goes with --groups waves (it sets the review of the groups waves derives)`.
60
+ The derived groups then have `review=group`. High-difficulty tasks stay out and keep their
61
+ own review. A leftover single is dropped.
62
+ - `plan --groups FILE` copies that file. An existing `groups.tsv` and no `--groups` is used
63
+ as it is.
64
+
65
+ `plan` computes waves, then validates, resolves each review group's `qa`, and freezes.
66
+ The approval table shows each group's title and goal, `(no goal)` when it has none, and one line
67
+ naming the groups without a goal. `forge group set PLAN GID --goal "…"` (or `--title`) writes it
68
+ and freezes the groups again, under the control lock and logged in `control.log` (actor `cli`).
69
+ It refuses (exit 3) when `groups.tsv` or a member's deps or files already differ from what `plan`
70
+ froze, since freezing again would accept those edits too. It works on a live run: a title or a
71
+ goal changes no membership, and the next group review or brief prompt uses the new text.
72
+
73
+ ### Rules for `review=group`
74
+
75
+ These apply only when `review` is `group`. A `review=task` group is not checked this way.
76
+
77
+ - At least two members, and at most `--group-max-tasks` (default 6, plan file
78
+ `group_max_tasks`). The flag accepts a positive integer. Deriving waves requires at
79
+ least 2 (`max tasks must be at least 2`). Validating an existing file uses the same max,
80
+ so 1 rejects every review group.
81
+ - No member depends on another member, directly or through a task outside the group.
82
+ - Declared `files` do not overlap. A directory covers the paths under it, `.` covers
83
+ everything, and `-` declares nothing. Same rule as the scheduler.
84
+ - No sweep member (an id `sweep-N`, or `tasks/<id>/sweep.json`).
85
+ - `qa` of `-` becomes the QA spec of the highest-difficulty member (`high` over `medium`
86
+ over `low`; a tie takes the first listed), as `tasks.tsv` has it after `plan`.
87
+
88
+ ### The freeze, and what makes `run` refuse
89
+
90
+ `groups.frozen` is the sha256 of the freeze text: one line per group, all six columns, then
91
+ one line per member, `member<TAB>deps<TAB>files`. The dwarf column is not in it. No groups
92
+ removes `groups.frozen`. A `groups.frozen` with no `groups.tsv` fails the check.
93
+
94
+ `run` calls `forge-groups.py check` when `groups.tsv` or `groups.frozen` exists, a dry run
95
+ included, before any dispatch. A mismatch, a missing file, or groups that cannot be read
96
+ refuses with `groups.tsv or a member's deps/files changed since plan; run plan again`.
97
+
98
+ ### The member lifecycle and `IMPLEMENTED`
99
+
100
+ A `review=group` member implements, writes `reviewed.commit` and `source.fingerprint`, and
101
+ stops at `IMPLEMENTED`. There is no per-task QA snapshot, no shadow review, no fail-first
102
+ check, and no QA-only resume (the `resume` marker is removed). `--pre-review-tests` still
103
+ runs, on a snapshot that exists only for that check. Red is `FAIL`, unreviewed, not
104
+ `IMPLEMENTED`.
105
+
106
+ `record_attempt` writes no `attempts.tsv` row while the status is `IMPLEMENTED`, and
107
+ `post_attempt` does nothing. The attempt cap counts `attempts.tsv` rows (an `INFRA` row
108
+ does not count), so that stop spends nothing. The `attempt` counter may already have moved.
109
+
110
+ `retry` and `accept` of an `IMPLEMENTED` task exit 3: `<id> is implemented and waits for
111
+ group <gid>'s review`. The scheduler does not dispatch that member again. A dependent waits
112
+ for `MERGED`, so it does not start.
113
+
114
+ ### When a group is reviewed
115
+
116
+ The scheduler treats each `review=group` group as one unit, keyed `group:<gid>` in `active`.
117
+ It is ready when every member is `IMPLEMENTED`, nothing is running it, it has not merged, and
118
+ its status is empty or `WAITING`, or `FAIL` with `settled.round` equal to the current
119
+ `round`, or this run has marked it to review again. It starts as soon as the last member is
120
+ `IMPLEMENTED`. There is no wave barrier. It takes one slot, and it does not start while the
121
+ run is stopping, draining, or paused for infrastructure. The command is
122
+ `forge-parallel.sh _group`.
123
+
124
+ ### The candidate, and the size bound
125
+
126
+ The candidate worktree is `<wt_root>/_group-<gid>`. It starts at the integration HEAD, then
127
+ merges each member's `reviewed.commit` with `--no-ff`, in member order.
128
+
129
+ - A member that is not `IMPLEMENTED`: the group is `WAITING`. Members stay as they are.
130
+ - A member whose branch tip is not `reviewed.commit`, or whose worktree fingerprint is not
131
+ `source.fingerprint`: that member becomes `INVALIDATED` with `invalidated.reason`
132
+ `group-candidate`, and the group is `WAITING`.
133
+ - A conflict between members: the group is `CONFLICT`, `conflict.files` lists the files, the
134
+ merge is aborted, the members stay `IMPLEMENTED`, and nothing is dispatched.
135
+ - Any other merge failure, or no integration HEAD: `ERROR`.
136
+
137
+ The fingerprint is the sha256 of the sorted `task=commit` lines plus a final
138
+ `tree=<candidate tree>` line.
139
+
140
+ `combined.diff` is `git diff --binary --irreversible-delete` of the candidate against that
141
+ base, excluding `.forge`. Over `group_max_diff_kb` times 1024 bytes (default 256 when the
142
+ plan file is absent), the group is `NEEDS_DECISION` with reason `oversized`. Nothing is
143
+ dispatched, truncated, or sent to another reviewer. `decision.md` starts `reasons: oversized`
144
+ and offers two edits, then `plan` again: smaller groups in `groups.tsv`, or this group's
145
+ `review` set to `task`. `forge group retry` refuses an oversized group.
146
+ `--group-max-diff-kb N` is a positive integer, written only when given, so a re-plan keeps it.
147
+ The same is true of `--group-max-tasks`.
148
+
149
+ This is not a [whole-run review](../docs/reviews.md#whole-run-review-opt-in). That one reads
150
+ the combined result after the run and truncates. A group review that is over the bound never
151
+ builds a prompt.
152
+
153
+ ### The prompt and `{tasks=…}`
154
+
155
+ One fresh QA dispatch. The prompt is the contract head for kind `group` (the task preamble,
156
+ plus that this review covers several tasks and must judge each against its own criteria and
157
+ judge the combined change), the group's title and goal, `Members, in merge order`, then any
158
+ findings from the previous round that named no task. Each member follows: title, `prompt.md`,
159
+ the declared files and the reviewed commit. When the task has them, it also has the intended
160
+ approach, that member's diff `--stat` against its base, pre-review text, guard notes and
161
+ drift. Findings the previous round attributed to the task are quoted, and the implementer's
162
+ reply is included when this attempt is not the one those findings judged. The tail is the task contract plus
163
+ the `{tasks=…}` instructions below, then the whole combined diff in a fence. The diff is not
164
+ truncated. An oversized group never gets here. The threshold is the plan's QA threshold.
165
+
166
+ `{tasks=…}` is its own brace. It is not the facts brace
167
+ `{reach=… origin=… evidence=…}`. The prompt says to write it immediately before the facts
168
+ brace, so the facts brace still ends the line. The last `{tasks=…}` on a finding wins. Ids
169
+ are separated by commas or spaces.
170
+
171
+ Attribution (`scripts/forge_groups/attribute.py`, written to `attribution.json` with the
172
+ round):
173
+
174
+ - A tag names those ids. An empty tag (`{tasks=}` or `{tasks= , }`) names nobody and does
175
+ not fall back to the file.
176
+ - With no tag, the tasks are the members whose changed paths contain the finding's file, in
177
+ member order. A leading `./` is stripped and nothing else is normalised: `src/./a.py` does
178
+ not match `src/a.py`.
179
+ - Ambiguous when the tag names an id that is not a member, when the tag names nobody, when
180
+ there is no tag and no file, or when no member changed that file.
181
+ - `blocking` is the gate's per-finding decision at the threshold (`none` is P3; unset is
182
+ P2). `PLAUSIBLE` never blocks.
183
+ - `implicated` is the union, in member order, of the tasks on blocking findings that are not
184
+ ambiguous. The top-level `ambiguous` list is the `n` of findings that are both blocking
185
+ and ambiguous.
186
+
187
+ The facts line is `implicated<TAB>ambiguous<TAB>findings<TAB>blocking`. The two lists are
188
+ comma separated, or `-`. `findings` is the count. `blocking` is `1` or `0`.
189
+
190
+ ### Each outcome, and what happens next
191
+
192
+ The round ends in `groups/<gid>/status`, and one `rounds.tsv` row: round, epoch, status,
193
+ implicated tasks or `-`, QA spec. Status writes are atomic.
194
+
195
+ - **`PASS`.** The scheduler runs `_merge_group`: one `--no-ff` merge of `candidate.commit`
196
+ onto integration (`forge: merge group <gid> (ids)`). Every member is judged `PASS` (one
197
+ `attempts.tsv` row), its status becomes `PASS`, `merged` is touched, and the group's
198
+ `merged` is touched. A conflict sets the group and every member to `CONFLICT`, keeps
199
+ `conflict.files`, and merges nothing. Integration moved (`accepted.integration` does not
200
+ match) or dirty: the group is `INVALIDATED` with `integration-moved` or
201
+ `integration-dirty`, and nothing merges. A member whose branch tip is not its reviewed
202
+ commit, or whose worktree fingerprint is not `source.fingerprint`: those members are
203
+ `INVALIDATED` with `group-candidate`, and the group is `INVALIDATED` with
204
+ `candidate-moved`. A member that is no longer `IMPLEMENTED`, or a recomputed fingerprint
205
+ that does not match, invalidates the group with `candidate-moved` and merges nothing;
206
+ members are not marked `INVALIDATED` unless they moved. A member dependency that is not
207
+ `MERGED` blocks the merge and leaves the status unchanged. `forge group retry` on `PASS`
208
+ refuses; the next `run` merges it.
209
+ - **`FAIL`.** `_group_settle` writes each implicated member's `qa.last` (a header, the
210
+ blocks attributed to it, `Also involves:` when a finding names other members too, then
211
+ `FORGE_VERDICT: FAIL`), runs the QA gate, sets the status to `FAIL`, writes one judged
212
+ attempt row, runs `post_attempt`, and writes `settled.group` (`gid round`). A member that
213
+ is not implicated stays `IMPLEMENTED`: no `qa.last`, no attempt row, no gate. The group
214
+ writes `settled.round`. The scheduler requeues the `FAIL` members when `--retry-failed`
215
+ budget remains. Without it they stay `FAIL` and the others stay `IMPLEMENTED`. The next
216
+ round starts when the implicated members are `IMPLEMENTED` again. Settling the same round
217
+ twice does nothing. A `FAIL` that implicates no member settles nothing.
218
+ - **`NEEDS_DECISION`, ambiguous.** A blocking finding names no member. Members stay
219
+ `IMPLEMENTED`. `decision.md` starts `reasons: ambiguous`. The user names the members with
220
+ `forge group retry PLAN GID --tasks a,b`. That runs `_group_settle --tasks`, which fails
221
+ those members, each with the ambiguous findings (marked as assigned by a decision), and
222
+ also any member the review implicated by its own blocking finding, with only that. It moves
223
+ `decision.md` to `decision.<round>.md`, and sets the group to `FAIL`. The next `run
224
+ --retry-failed` retries those tasks. A live scheduler picks them up on its sweep when
225
+ they have budget left. Do this only when the user says so.
226
+ - **`NEEDS_DECISION`, oversized.** Refused by `forge group retry`. Split `groups.tsv` and
227
+ run `plan` again, or set that group's `review` to `task` and run `plan` again. The reason
228
+ word is the first token after `reasons:`. Only `oversized` and `ambiguous` are handled.
229
+ Any other reason is refused; read `decision.md`.
230
+ - **`UNKNOWN`.** No verdict. Members stay `IMPLEMENTED`. The scheduler reviews the group
231
+ again within `--retry-failed`, counted in `groups/<gid>/retries.used`. No member attempt
232
+ is spent. With the budget spent, the group stays `UNKNOWN`.
233
+ - **`INFRA`, `TIMEOUT`, `ERROR`, `INTERRUPTED`.** `INFRA` is dispatch exit 8: `infra.txt`
234
+ has `stage=qa` and the class, and no attempt is spent. `TIMEOUT` is exit 7. Any other
235
+ dispatch failure is `ERROR`. `forge group retry` on `UNKNOWN`, `INFRA`, `TIMEOUT`,
236
+ `INTERRUPTED` or `ERROR` sets the group status to `INTERRUPTED` and touches no member
237
+ file, so the next `run` reviews it again. `--tasks` is refused in those states. A review
238
+ that dies while `REVIEWING` is marked `ERROR`. A scheduler killed mid-review leaves
239
+ `REVIEWING`; the next `run` turns that into `INTERRUPTED` and reviews again, without
240
+ re-implementing the members.
241
+ - **`INVALIDATED`.** A tracked change to the candidate or to the review snapshot during the
242
+ review. An untracked file in the snapshot is not a change. Also the merge-time reasons
243
+ above. The next `run` reviews it again, unless `invalidated.reason` is
244
+ `integration-moved` or `integration-dirty`. `forge group retry` says the same and does
245
+ not rearm it.
246
+ - **`CONFLICT`.** `forge group retry` refuses. Two paths differ. A conflict while building
247
+ the candidate leaves the members `IMPLEMENTED`, and `retry` of an `IMPLEMENTED` task
248
+ exits 3, so the printed `forge-parallel.sh retry` line does not apply until a member is
249
+ no longer `IMPLEMENTED`. A conflict merging onto integration sets every member to
250
+ `CONFLICT`, and a `CONFLICT` task can be retried.
251
+ - **`WAITING`.** A member is not `IMPLEMENTED`. **`REVIEWING`.** A review is running.
252
+ Neither is retried with `forge group retry`.
253
+
254
+ ### Attempt accounting
255
+
256
+ Only a judged attempt writes an `attempts.tsv` row, and the cap counts those rows. An
257
+ `IMPLEMENTED` member spends nothing. A member a `FAIL` does not implicate spends nothing.
258
+ A re-review after `UNKNOWN`, `INFRA`, `TIMEOUT`, `INTERRUPTED` or `ERROR` spends no member
259
+ attempt. On `PASS`, every member gets one judged `PASS` row, including members the findings
260
+ did not name. A later `FAIL` of only some members records one `FAIL` row for each of those,
261
+ at the attempt number they are on. Separately, a task attempt left `STALE` (`prompt.md` or
262
+ `approach.md` changed while it ran) is not judged. `attempts.tsv` records `STALE`, and the cap
263
+ skips that row, as it skips `INFRA`.
264
+
265
+ ### Resume
266
+
267
+ `run` again does not re-implement a member left `IMPLEMENTED`. A `PASS` group is merged,
268
+ with no new QA dispatch; a stale member branch is not merged. An unsettled `FAIL` is
269
+ settled, then those members are requeued. `INTERRUPTED`, `INFRA` and `TIMEOUT` are reviewed
270
+ again. `INVALIDATED` is reviewed again unless the reason is `integration-moved` or
271
+ `integration-dirty`. `UNKNOWN` is reviewed again while the group's `--retry-failed` budget
272
+ remains; otherwise the status line is printed. `NEEDS_DECISION`, `CONFLICT` and `ERROR` wait
273
+ for a person. The summary says `forge: <id> is implemented, waiting for group <gid>
274
+ (<status>)` for a member still `IMPLEMENTED`. An empty group status is printed as
275
+ `not reviewed`. A dependent of an unmerged group stays `BLOCKED`.
276
+
277
+ ### Files in `groups/<gid>/`
278
+
279
+ `status` (then `PASS`, `FAIL`, `NEEDS_DECISION`, `UNKNOWN`, `CONFLICT`, `INFRA`, `TIMEOUT`,
280
+ `ERROR`, `INVALIDATED`, `WAITING`, or `REVIEWING`; `INTERRUPTED` is written by the scheduler
281
+ or by `forge group retry`), `round`, `rounds.tsv`, `candidate.base`, `candidate.commit`,
282
+ `members.tsv` (round, task, reviewed commit, attempt; one row per member of a round that
283
+ built a candidate), `fingerprint`, `combined.diff`, `members.paths` (`task<TAB>path`),
284
+ `attribution.json`, `qa.input`, `qa.last`, `qa.out`, `qa.gate`, `qa.round-<n>.last`,
285
+ `known_issues.md`, `infra.txt`, `decision.md`, `conflict.files`, `review.base`, `merge.out`,
286
+ `group.out` (the scheduler's log). Settle writes `settled.round`, `settle.tasks` (until the
287
+ round is settled) and `decision.<round>.md`. Merge writes `merged` and, when it refuses,
288
+ `invalidated.reason` (`integration-moved`, `integration-dirty`, `candidate-moved`).
289
+ `retries.used` counts `UNKNOWN` re-reviews. The candidate worktree stays at
290
+ `<wt_root>/_group-<gid>`.
291
+
292
+ On the member: `reviewed.commit`, `source.fingerprint`, `settled.group`, and
293
+ `invalidated.reason` of `group-candidate` when the member moved. Plan files: `groups.tsv`,
294
+ `groups.frozen`, `group_max_tasks`, `group_max_diff_kb`.
295
+
296
+ The dataset records `group_review` and `group_merge`. The QA dispatch has `scope` `group`
297
+ and an empty task, and it is left out of the per-task reviewer statistics. A judged member
298
+ attempt is linked with `review_scope=group`, `group` and `round`, and does not keep a copy
299
+ of that review's `qa.last` or `qa.gate`. See
300
+ [the dataset](dataset.md#raw-events-not-training-examples).
301
+
302
+ `forge group show PLAN [--group GID] [--json]` reads this. `forge group retry` is the
303
+ decision and the rearm above. Exit codes and flags are in
304
+ [commands](../docs/commands.md#the-forge-command).
305
+
306
+ ### Out of scope
307
+
308
+ - Shadow reviews of groups. A member skips shadow, and the group dispatch is one fresh QA.
309
+ - A reviewer session across rounds. The group dispatch does not continue a session.
310
+ - Fail-first on a member. Pre-review tests still run, as above.
311
+
312
+ ## Retro notes (opt-in)
313
+
314
+ `plan --retro` makes each agent record what got in its way: a sandbox that blocked a command, a
315
+ tool that is not installed, an instruction it could not follow, a forge fault. A note says what
316
+ happened and who can fix it. Without a flag a plan keeps its earlier choice, and a first plan
317
+ takes the user setting (`forge config set retro on`). `plan --no-retro` turns it off.
318
+
319
+ - **What an agent writes.** Most tasks have nothing to report, and a hard task is not a note.
320
+ A note is one `FORGE_RETRO: {json}` line in the final message. The planner, QA and the
321
+ whole-run review write it the same way. A dwarf blocked before it finishes also appends the
322
+ same JSON to `.forge/retro-inbox.jsonl` in its worktree, which forge reads when the dispatch
323
+ ends. The fields are `type` (`environment`, `sandbox`, `tooling`, `prompt`, `forge-bug` or
324
+ `other`), `fixable_by` (`user`, `forge` or `unsure`), `summary`, `evidence` (the command, its
325
+ exit code and the error, up to 2 KB), `blocking` and `tried`.
326
+ - **Checked against the log.** forge looks for the note's command and the first line of its
327
+ error in that dispatch's log. When both are there the note is `verified`; otherwise `claimed`.
328
+ - **Orchestrator notes.** `forge retro note PLAN --type T --fixable-by F --summary S` records
329
+ one note of the run's own, with `--command`, `--exit`, `--error`, `--blocking` and `--tried`
330
+ as needed. It is always `claimed`, and it does not check the retro setting.
331
+ - **Where it goes.** `<plan>/retro/notes.jsonl`, `tasks/<id>/retro.json` for a task, and one
332
+ `retro_note` dataset event per note. `forge retro report PLAN` writes `<plan>/retro.md`.
333
+ Notes with the same type and the same normalised command form one pattern; a note with no
334
+ command is matched on its normalised summary instead. Each pattern
335
+ goes to the group its majority `fixable_by` names: **You can fix this on this machine**
336
+ (`user`), **forge should fix this** (`forge`), or **Not sure who should fix this** (`unsure`,
337
+ also on a tie). A run prints one line with the pattern count and the path when there are any
338
+ patterns. The first plan with retro on says what is recorded, once per user.
339
+ - **Filing.** `forge retro issues PLAN` drafts one redacted issue per `forge` pattern, for
340
+ forge's own repository, and posts nothing. The dry run prints the texts and their hash.
341
+ `forge retro issues PLAN --apply --approve HASH` posts only when the hash matches those texts
342
+ and the `--choice rN=new|comment:N|skip` choices. It needs an authenticated `gh`, and it
343
+ refuses a never-send repository. Both refusals exit `3`.
344
+ - **Never memory.** Notes never go into `.forge/memory.md` or the ledger, and no prompt reads
345
+ them back. A retro plan does add a short instruction block to each prompt, at its end.
346
+ - **Off.** With retro off (`--no-retro`, no setting, or `FORGE_RETRO=off`) no instruction is
347
+ added to any prompt, the inbox is not read, and forge stores no note from a dispatch. Its
348
+ prompts stay as they were without the feature. `forge retro note` still records a note when
349
+ it is called, because it does not check the setting.
350
+
351
+ Files it adds: `retro_mode` (plan file), `retro/notes.jsonl`, `retro/.lock`, `retro.md`,
352
+ `tasks/<id>/retro.json`, and `.forge/retro-inbox.jsonl` in a worktree (removed once its notes
353
+ are stored). It costs no model call of its own.
354
+
355
+ ## Brief mode (opt-in)
356
+
357
+ With `plan --brief advisory|gated|strict --brief-model SPEC`, a read-only side dispatch writes
358
+ the questions each task needs answered before it starts. Each question has a default. A task
359
+ with no answer follows the default. The user answers with `forge brief answer`.
360
+ A task-scoped answer goes into that task's prompt. A `wave` or `plan` answer stays parked
361
+ until an approved proposal applies its diff. forge never answers for the user.
362
+
363
+ - **Cost.** One dispatch per task that has no `brief.json`, at effort `low`, four at a time.
364
+ A reply that is not valid JSON, or has the wrong shape, is retried once; a second failure
365
+ stores no questions and the reason in `brief.json`'s `error`. Answers, stale flags and
366
+ `reject` call no model. A proposal is one more side dispatch, kind `brief-change`. Each
367
+ unstarted task whose questions are regenerated is one more, kind `brief`. Both are read-only,
368
+ at effort `low`, on the brief model.
369
+ - **When.** `run` writes the missing briefs when it starts. `strict` waits for them; `advisory`
370
+ and `gated` write them alongside the scheduler. `forge brief write PLAN [--task ID] [--jobs N]
371
+ [--force]` does the same by hand, and `--force` redoes a task that already has a brief.
372
+ - **Levels.**
373
+ - `advisory`: the run does not wait. Open questions reach the prompt under "Open questions:
374
+ follow the stated default", with each default.
375
+ - `gated`: a task with an unanswered must-answer question is held. The run prints
376
+ `forge: <task> waits for your answer to <qid>` with the `forge brief answer` line. A task
377
+ whose brief is still being written waits too.
378
+ - `strict`: `run` exits `3` before any task starts while a question of an unstarted task is
379
+ open. It prints each question, its default and the answer command. Answer them and run again.
380
+ - **Answers.** `forge brief answer PLAN TASK QID TEXT` (or `--file F`; `-` reads stdin). For a
381
+ task-scoped question, an answer given before the task starts goes to `brief.answers.json` and
382
+ into the prompt under "Decisions the user made", which overrides what the requirements say.
383
+ After the task starts, that answer goes to `brief.late.json` and changes nothing in the run.
384
+ The command then prints the `tasks.tsv` row, the `prompt.md` a follow-up needs, and the
385
+ `forge control add` line that queues it.
386
+ - **Scope.** `--brief-scope` is `task` (the default), `wave` or `plan`. The question's own
387
+ scope decides what an answer may change. `task` writes the answer into that task. `wave` and
388
+ `plan` questions are parked in `brief.parked.json` whatever `--brief-scope` says, and they
389
+ change the plan only through a proposal you approve. Both scopes use the plan's
390
+ [groups](#groups-and-group-review-opt-in). A wave proposal needs the question's group in
391
+ `groups.tsv`. When the task belongs to a group, the question
392
+ writer is told that group's title, goal and the other tasks in it. It asks `wave` when the
393
+ answer would change how several tasks of the group are done, and `plan` when the answer
394
+ would add, remove or split tasks, or change their order. A wave question from a grouped
395
+ task records `"group": "<gid>"`. A plan question from a grouped task records `"group": null`.
396
+ A task in no group keeps the prompt it had before groups, and its parked questions have no
397
+ `group` key. With `--brief-scope wave` or `plan` and no `groups.tsv`, forge prints one note
398
+ and goes on. `brief.groups.noted` keeps that note to once per plan. The note says to run
399
+ `plan --groups waves`, or to let the planner write groups, because a wave question with no
400
+ group stays parked. `gated` and `strict` still read only the task questions in `brief.json`.
401
+ A parked question does not hold a task.
402
+ - **Parked answers.** A parked question can be answered when the brief scope is at least as
403
+ wide as the question. `wave` answers wave questions. `plan` answers wave and plan questions.
404
+ `task` answers neither: the question id is unknown, and `answer` exits `2`. The answer goes
405
+ to `tasks/<id>/brief.parked.answers.json` as `{qid: {text, actor, t}}`, including after the
406
+ task has started. It is never a late answer, and it does not change a prompt. The command
407
+ prints `forge brief propose PLAN TASK QID`. Nothing in the plan changes until that proposal
408
+ is approved. `forge brief show` lists parked questions by group: `Group <gid> (<title>):`
409
+ and the question, or `Group <gid>:` when the title is `-` or the group is gone, then
410
+ `Plan:` for a plan question. A question with no `group` key stays under
411
+ `Parked (wider scope):`.
412
+ - **Proposals.** `forge brief propose PLAN TASK QID` asks the brief model what that parked
413
+ answer changes, in one read-only side dispatch of kind `brief-change`, and stores the result
414
+ under `proposals/<pid>/` (`p1`, `p2`, and so on). Each directory holds `proposal.json`,
415
+ `diff.patch` (a unified diff of the plan files it would change) and `hash`. `state` is
416
+ `proposed`, `refused`, `approved` or `rejected`. A reply that breaks the rules below, or
417
+ that changes nothing, is stored as `refused` with its reason and its diff, and `propose`
418
+ exits `3`. `apply` leaves a refused proposal where it is. A failed dispatch stores nothing.
419
+ The question's scope is the proposal's scope: under `--brief-scope plan`, a wave question
420
+ is still a wave proposal. A plan question needs `--brief-scope plan`, or `propose` refuses
421
+ it. `forge brief proposals PLAN` lists every proposal, oldest first, with its state, scope,
422
+ group, summary and diff. `--json` prints the same records. A `proposed` one also prints the
423
+ exact `forge brief apply` line. `forge brief reject PLAN PID [--reason TEXT]` sets
424
+ `rejected`. It touches no plan file. Only a `proposed` or `refused` proposal can be rejected.
425
+ - **What each scope may change.**
426
+ - `task`: the answer, as under Answers. There is no proposal.
427
+ - `wave`: `prompt.md`, `approach.md` and the `files` column, and only for unstarted members
428
+ of the question's group. The question must name a group that is in `groups.tsv`. A change
429
+ that names another task, a started member, or any other field refuses the whole proposal.
430
+ A wave question with no group cannot be proposed.
431
+ - `plan`: the same three fields on any unstarted task, new tasks, removal of unstarted
432
+ tasks, and new dependency lists for unstarted tasks. A split is a removal plus the added
433
+ tasks, and every task that still depended on a removed one needs its deps rewritten in
434
+ the same reply. An added task's group is null or an existing group id. Anything that
435
+ would not be a plan `plan` could have written refuses the whole proposal. Between runs,
436
+ an added row gets dwarf and qa `-`.
437
+ - **Approve by hash.** `hash` is the sha256 of `diff.patch` and the current contents of every
438
+ target. For a wave `files` change the target is that task's `tasks.tsv` row. For a plan
439
+ change the hash also covers `tasks.tsv`, `groups.tsv` and every edited prompt or approach.
440
+ `forge brief apply PLAN PID --approve HASH` must quote the hash `proposals` shows. A
441
+ different hash, a state other than `proposed`, a target that has started, or a target that
442
+ changed since the proposal, refuses the apply and writes nothing. After a target changes,
443
+ propose again.
444
+ - **Live and between runs.** While a scheduler is live, a wave proposal that changes only
445
+ prompt and approach is written. The next attempt of an unstarted task reads those files.
446
+ A wave proposal that changes `files` is refused while the run is live, and nothing is
447
+ written: the scheduler keeps the files column it read at start. With no live run, a wave
448
+ `files` change is written, `groups.frozen` is re-frozen (a stale marker left by a plan
449
+ proposal stays stale), and `waves.tsv` is recomputed when that file already exists. A
450
+ plan apply with no live run writes `tasks.tsv` and the task directories, and `groups.tsv`
451
+ when membership changed. A removed task's directory moves to `tasks/.removed/<id>-<pid>/`.
452
+ `groups.frozen` becomes the marker `stale: plan changed by proposal <pid>`, so `run`
453
+ refuses until `forge-parallel.sh plan` validates, routes and freezes again. With a live
454
+ run, a plan proposal that includes an edit, a removal or a dep change is refused, and
455
+ nothing is written. A proposal that only adds tasks queues each one with
456
+ `forge control add`, in dependency order. A task added that way joins no group. It needs
457
+ dwarf and qa specs copied from a task that already has them. If a later add is refused,
458
+ the tasks already queued stay, and the proposal is `approved` so it is not applied again.
459
+ - **Affected tasks.** After a successful apply, every task the proposal changed or added, and
460
+ every task that depends on a changed, added or removed task, directly or further down, gets
461
+ `tasks/<id>/brief.affected`. The marker is `{pid, reason, t}`. `reason` is `changed`,
462
+ `added` or `dependent`. An unstarted task's questions are regenerated, one brief dispatch
463
+ each (`write --force`). An answer whose question text is still in the new brief is kept.
464
+ Any other answer moves to `brief.answers.prev.json`. A task that has already started gets
465
+ the same marker with `flag_only`, and its questions stay. `forge brief show` lists a marked
466
+ task as `affected by <pid>`, and adds `flagged (already started)` when `flag_only` is set.
467
+ `apply --no-regenerate` writes the same markers and does not dispatch. Regenerating one
468
+ task later is `forge brief write PLAN --task ID --force`. The next approved proposal that
469
+ touches a task replaces that task's marker. Earlier proposals stay in `proposals/`.
470
+ - **Stale.** After a task merges, a merge that changed files outside that task's declared files
471
+ flags the open questions of its dependents that have not started (`possibly_stale`). `forge
472
+ brief stale PLAN TASK` does this by hand.
473
+ - **Model.** `--brief-model SPEC` is required with brief on, and it must resolve; otherwise
474
+ `plan` exits `2`. forge never picks the model.
475
+ - **Privacy.** A never-send repository gets no brief dispatch (`never-send`), so its tasks have
476
+ no questions and nothing holds them.
477
+ - **Off.** With `--brief off`, no setting, or `FORGE_BRIEF=off`, there is no writer, no hold and
478
+ no prompt addition. `forge-prompt.py` adds nothing without a `brief` file. `forge brief write`,
479
+ `forge brief show` and `forge brief propose` exit `3` for such a plan.
480
+
481
+ Files it adds: the plan files `brief`, `brief_scope` and `brief_model`; `brief.out` (the
482
+ writer's output), `brief.pid` (while the writer runs) and `brief.groups.noted` (once, when
483
+ wave or plan scope has no groups); `proposals/<pid>/proposal.json`, `diff.patch` and `hash`;
484
+ and per task `tasks/<id>/brief.json`, `brief.parked.json`, `brief.answers.json`,
485
+ `brief.late.json`, `brief.parked.answers.json`, `brief.affected` and `brief.answers.prev.json`.
486
+ A removed task's directory is moved to `tasks/.removed/<id>-<pid>/`. Its events are
487
+ `brief_question`, `brief_answer`, `brief_diff` and `side_dispatch` (kind `brief` or
488
+ `brief-change`). A `brief_diff` event is `{pid, scope, group, state, tasks}` and is written
489
+ when a proposal is proposed, refused, approved or rejected. The approved event from a
490
+ successful apply also carries `affected` and `flagged`, the task ids it marked.
491
+
492
+ ## Task summaries (opt-in)
493
+
494
+ `plan --summaries on --summaries-model SPEC` writes a short summary of each task to
495
+ `tasks/<id>/summary.json`. The model sees only the task's facts: its status, its attempt trail
496
+ (attempt, dwarf spec, verdict, findings count, worst severity, retry reason), the latest review's
497
+ finding titles and severities, its known issues, and its dependencies and dependents. The facts
498
+ are capped at 8 KB. The model never sees the repository, the diff or the task prompt.
499
+
500
+ - **Cost.** One read-only dispatch per task, at effort `low`, when its facts change. Unchanged
501
+ facts are not dispatched again, because `inputs_hash` matches the stored summary. Each kind
502
+ of side dispatch is capped per run at `max(10, 3 × tasks)`.
503
+ - **When.** During `run`, the scheduler starts a detached `forge summarize PLAN --task ID` for
504
+ each task whose status, dwarf reply, attempt trail, verdict or retry count changed since its
505
+ last look. The first look at a task only remembers it. The scheduler never waits for a
506
+ summary, and a failed one changes nothing in the run. On a finished run, `forge control set
507
+ PLAN summaries on` starts `forge summarize` itself, with its output in `summaries.out`.
508
+ - **Output.** `summary.json` holds `text`, `sentence`, `model`, `generated_at`, `inputs_hash`
509
+ and `sources` (the attempts and findings the facts came from). The prompt asks for 3 to 5
510
+ short lines. A reply that is not a JSON object with `text` and `sentence`, or whose text runs
511
+ past 8 lines, is rejected: the previous `summary.json` stays and `summary.error` says why.
512
+ - **Commands.** `forge summarize PLAN [--task ID] [--force] [--json]`. `--force` dispatches even
513
+ when the facts did not change. `--json` prints one object per task: `task`, `status`, `reason`.
514
+ `forge control set PLAN summaries on|off` sets the plan. `--task ID on|off|inherit` sets one
515
+ task; its own `on` or `off` overrides the plan, and `inherit` drops that override.
516
+ - **Model.** `--summaries-model SPEC` is required with summaries on, and it must resolve;
517
+ otherwise `plan` exits `2`. Set a user default with `forge config set summaries.model SPEC`.
518
+ A planned plan does not read that default again: `forge control set PLAN summaries-model SPEC`
519
+ sets its own, and `forge control set PLAN summaries on` is refused, with that command, while the
520
+ plan has no model, so summaries are never switched on only to be skipped with `no-model`.
521
+ - **Off.** With `--summaries off`, no setting, or `FORGE_SUMMARIES=off`, there is no dispatch and
522
+ no `summary.json`.
523
+
524
+ Files it adds: the plan files `summaries` and `summaries_model`; `summaries.out`; and per task
525
+ `tasks/<id>/summary.json`, `summary.error` (after a failed reply) and `tasks/<id>/summaries`
526
+ (`on` or `off`, the task's override). Its events are `side_dispatch` (kind `summary`) and the
527
+ `side_summary` role in the dataset.