@giamme/forge 0.12.0 → 0.13.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 (117) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +1 -1
  3. package/SKILL.md +31 -12
  4. package/VERSION +1 -1
  5. package/docs/add-ons.md +11 -6
  6. package/docs/artifacts.md +18 -6
  7. package/docs/commands.md +189 -17
  8. package/docs/decomposed-runs.md +13 -5
  9. package/docs/forge-ui.md +34 -4
  10. package/docs/memory.md +2 -1
  11. package/docs/models.md +4 -2
  12. package/docs/reviews.md +81 -19
  13. package/docs/troubleshooting.md +3 -1
  14. package/forge +17 -1
  15. package/package.json +1 -1
  16. package/references/dataset.md +40 -14
  17. package/references/decision-models.md +759 -0
  18. package/references/decompose.md +197 -28
  19. package/references/harnesses.md +10 -3
  20. package/references/planning.md +8 -0
  21. package/references/solo.md +13 -3
  22. package/references/ui.md +11 -0
  23. package/scripts/forge-artifact.sh +30 -4
  24. package/scripts/forge-config.py +238 -29
  25. package/scripts/forge-contract.py +127 -58
  26. package/scripts/forge-control.py +40 -9
  27. package/scripts/forge-decide.py +6 -0
  28. package/scripts/forge-dispatch.sh +47 -15
  29. package/scripts/forge-fail-first.py +2 -2
  30. package/scripts/forge-gate-addressed.sh +40 -0
  31. package/scripts/forge-gate-message.sh +64 -0
  32. package/scripts/forge-issues.py +368 -36
  33. package/scripts/forge-jev-options.sh +269 -42
  34. package/scripts/forge-lib-attribute.sh +447 -0
  35. package/scripts/forge-lib-gates.sh +32 -0
  36. package/scripts/forge-lib-plans.sh +17 -6
  37. package/scripts/forge-lib-review.sh +24 -19
  38. package/scripts/forge-lib-task.sh +219 -39
  39. package/scripts/forge-lib-verify.sh +45 -8
  40. package/scripts/forge-memory.sh +3 -3
  41. package/scripts/forge-parallel-options.sh +44 -5
  42. package/scripts/forge-parallel.sh +503 -304
  43. package/scripts/forge-plan-check.py +35 -1
  44. package/scripts/forge-pre-review.py +437 -0
  45. package/scripts/forge-prompt.py +25 -5
  46. package/scripts/forge-route.py +2 -2
  47. package/scripts/forge-runtime.py +55 -1
  48. package/scripts/forge-schedule.py +70 -9
  49. package/scripts/forge-shadow.py +2 -2
  50. package/scripts/forge-solo.sh +41 -10
  51. package/scripts/forge-submodules.py +389 -0
  52. package/scripts/forge-sweep.py +542 -0
  53. package/scripts/forge_dataset/cli.py +12 -6
  54. package/scripts/forge_dataset/export.py +55 -45
  55. package/scripts/forge_dataset/forecast.py +4 -1
  56. package/scripts/forge_dataset/harvest.py +33 -5
  57. package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
  58. package/scripts/forge_decide/__init__.py +141 -0
  59. package/scripts/forge_decide/budget.py +149 -0
  60. package/scripts/forge_decide/cache.py +66 -0
  61. package/scripts/forge_decide/cli.py +953 -0
  62. package/scripts/forge_decide/doctor.py +221 -0
  63. package/scripts/forge_decide/label_addressed.py +75 -0
  64. package/scripts/forge_decide/label_attribution.py +62 -0
  65. package/scripts/forge_decide/label_coverage.py +81 -0
  66. package/scripts/forge_decide/label_message.py +38 -0
  67. package/scripts/forge_decide/label_prompt.py +139 -0
  68. package/scripts/forge_decide/labels.py +328 -0
  69. package/scripts/forge_decide/metrics.py +125 -0
  70. package/scripts/forge_decide/migrate.py +226 -0
  71. package/scripts/forge_decide/providers.py +292 -0
  72. package/scripts/forge_decide/replay.py +350 -0
  73. package/scripts/forge_decide/report.py +382 -0
  74. package/scripts/forge_decide/resolve.py +397 -0
  75. package/scripts/forge_decide/sites.py +377 -0
  76. package/scripts/forge_jev/__init__.py +202 -104
  77. package/scripts/forge_jev/addressed.py +171 -0
  78. package/scripts/forge_jev/attribution.py +198 -0
  79. package/scripts/forge_jev/cli.py +460 -382
  80. package/scripts/forge_jev/client.py +155 -77
  81. package/scripts/forge_jev/coupling.py +19 -87
  82. package/scripts/forge_jev/coverage.py +303 -0
  83. package/scripts/forge_jev/findings.py +219 -0
  84. package/scripts/forge_jev/gates.py +225 -27
  85. package/scripts/forge_jev/memory.py +65 -4
  86. package/scripts/forge_jev/message.py +134 -0
  87. package/scripts/forge_jev/plan_gates.py +294 -0
  88. package/scripts/forge_jev/questions.py +173 -313
  89. package/scripts/forge_jev/verify.py +130 -104
  90. package/ui/README.md +41 -10
  91. package/ui/docs/api.md +212 -44
  92. package/ui/forge_ui/checks.py +331 -0
  93. package/ui/forge_ui/control.py +60 -11
  94. package/ui/forge_ui/export.py +8 -3
  95. package/ui/forge_ui/models.py +1 -0
  96. package/ui/forge_ui/reader.py +436 -26
  97. package/ui/forge_ui/server.py +13 -0
  98. package/ui/forge_ui/static/app.js +15 -8
  99. package/ui/forge_ui/static/checksview.js +449 -0
  100. package/ui/forge_ui/static/controls.js +20 -13
  101. package/ui/forge_ui/static/convo.js +11 -2
  102. package/ui/forge_ui/static/findingsview.js +6 -4
  103. package/ui/forge_ui/static/index.html +1 -0
  104. package/ui/forge_ui/static/panel.js +105 -17
  105. package/ui/forge_ui/static/runmodel.js +40 -2
  106. package/ui/forge_ui/static/scene3d.js +2 -15
  107. package/ui/forge_ui/static/settings.js +336 -41
  108. package/ui/forge_ui/static/style.css +72 -7
  109. package/ui/forge_ui/transcripts.py +225 -54
  110. package/references/jev.md +0 -865
  111. package/scripts/forge_jev/backtest.py +0 -322
  112. package/scripts/forge_jev/corpus.py +0 -156
  113. package/scripts/forge_jev/features.py +0 -24
  114. package/scripts/forge_jev/predict.py +0 -204
  115. package/scripts/forge_jev/review.py +0 -73
  116. package/scripts/forge_jev/routing.py +0 -271
  117. package/scripts/forge_jev/subset.py +0 -123
@@ -14,6 +14,7 @@ run leaves branches behind.
14
14
  - [Fractal within decomposed tasks](#fractal-within-decomposed-tasks)
15
15
  - [Waves and disjointness](#waves-and-disjointness)
16
16
  - [Task size and acceptance criteria](#task-size-and-acceptance-criteria)
17
+ - [Plan gates: sent back, and the block under the table](#plan-gates-sent-back-and-the-block-under-the-table)
17
18
  - [The capsule](#the-capsule)
18
19
  - [Planning](#planning)
19
20
  - [QA verdicts](#qa-verdicts)
@@ -121,7 +122,11 @@ none of those exist, `UNASSIGNED`. An `UNASSIGNED` task makes `plan` exit 2 and
121
122
  outright. Forge does not invent a model when the user has not said which one should spend
122
123
  their quota.
123
124
 
124
- QA has no tier rules by default and falls back to `opus`, matching single-task forge.
125
+ QA has no tier rules by default and falls back to `opus` at `high`, matching single-task forge.
126
+ When the user names no reviewers, offer reviewers sized to the task's risk (never add them
127
+ unprompted): `--qa-low sonnet:medium --qa-medium sonnet:high --qa-high opus:high`. In the
128
+ SWE-bench Pro benchmark (#89) Sonnet reviewers gave no false PASS at about a seventh of an
129
+ `opus:xhigh` review's cost.
125
130
 
126
131
  ### Exploratory routing (on by default)
127
132
 
@@ -159,7 +164,7 @@ needs some randomized picks, so `plan` makes a few: `--explore E`, with E betwee
159
164
  keeps such a task in the arm it was assigned and reports it as not followed.
160
165
 
161
166
  `forge dataset routing` reads the draws back: per (tier, pool pick, neighbour) pair, each
162
- arm's first-pass rate (inverse-propensity weighted, every task in the arm it was assigned),
167
+ arm's first-try pass rate (inverse-propensity weighted, every task in the arm it was assigned),
163
168
  attrition, runtime and a run-clustered interval, judged at the first of 30, 60 or 120
164
169
  neighbour assignments it reaches. See [Dataset](dataset.md#routing). At the default rate
165
170
  that is weeks of normal use per pair; a pair that matters can be given more with
@@ -263,11 +268,42 @@ So:
263
268
  criteria. A heading inside a code fence, or with nothing under it, does not count. The
264
269
  block never changes the table or the exit code.
265
270
 
271
+ ## Plan gates: sent back, and the block under the table
272
+
273
+ With the prompt or coverage gate `on` (`forge decide gate <gate> on`; see
274
+ [decision models](decision-models.md)), `plan` can **exit 4**. That means: the gates sent work
275
+ back, nothing was validated and no `waves.tsv` was written by this call. Read
276
+ `<plan>/plan.sendback.md`, which `plan` also prints:
277
+
278
+ - **Task prompts a reviewer could not judge** (prompt gate): rewrite each listed
279
+ `tasks/<id>/prompt.md` so a reviewer can verify it, with checkable acceptance criteria.
280
+ - **Requirements no task covers** (coverage gate): extend a task's `## Acceptance criteria`
281
+ or add a task for each listed requirement of `request.md`.
282
+
283
+ Then run `plan` again, **once**. Forge sends each task and requirement back only once: what
284
+ is still flagged on the second call is listed under the table instead, and `plan` goes on.
285
+ With a dispatched planner (`--planner`), re-dispatch it with `plan.sendback.md` appended to
286
+ its prompt rather than editing the tasks yourself. In `shadow` a gate records and sends
287
+ nothing back, and with the gates `off` or decision models off `plan` never exits 4.
288
+
289
+ Under the table, `plan` prints a `decision-model gates:` block from `plan-gates.json` when a
290
+ gate recorded anything:
291
+
292
+ - `drift added to <task>: <files>`: drift `on` appended files to the task's `files` column
293
+ (`tasks.declared.tsv` keeps your table), so waves treat them as declared. Shadow lines say
294
+ *would add* and change nothing.
295
+ - `forward added a dependency: <a> now waits for <b>`: forward `on` made `a` depend on `b`
296
+ and recomputed the waves; a pair that would form a cycle is listed as skipped. Delete the
297
+ dep from `tasks.tsv` to undo it.
298
+ - `prompt still below … after its rewrite` and `requirements no task covers`: flagged items
299
+ that were already sent back once.
300
+
266
301
  ## The capsule
267
302
 
268
303
  Every dispatch is a clean slate — forge never passes `--continue`, `--resume`, or
269
304
  `codex exec resume`, except the opt-in `plan --reviewer-session` experiment (it continues
270
- a reviewer's session across rounds on claude, openclaude and codex). That keeps one task's
305
+ a reviewer's session across rounds on claude, openclaude and codex) and the opt-in
306
+ `plan --implementer-session` (a retry continues its implementer's session). That keeps one task's
271
307
  confused turn from poisoning another and keeps each task's context small, but it also
272
308
  leaves each dwarf blind to the wider run.
273
309
 
@@ -278,7 +314,7 @@ Complete requirements, approach, retry findings and distinct memory facts are as
278
314
  per role; implementation and review instructions are separate.
279
315
 
280
316
  It exists to prevent two specific failures that clean slates create, which the opt-in
281
- `--reviewer-session` experiment does not change:
317
+ `--reviewer-session` and `--implementer-session` do not change:
282
318
 
283
319
  - a dwarf reimplementing a helper an earlier task already merged, because nothing told it
284
320
  that task was done;
@@ -313,10 +349,17 @@ renders both — the last moment the plan can be changed for free.
313
349
  Decompose-mode QA prompts require a final line:
314
350
 
315
351
  ```
316
- FORGE_VERDICT: PASS no confirmed correctness bug (style nits are not failures)
317
- FORGE_VERDICT: FAIL at least one CONFIRMED correctness bug
352
+ FORGE_VERDICT: PASS — no CONFIRMED finding at the blocking threshold (P2 or worse)
353
+ FORGE_VERDICT: FAIL — at least one CONFIRMED finding at the blocking threshold (P2 or worse)
318
354
  ```
319
355
 
356
+ forge decides the verdict from the findings, at a blocking threshold: `P2` unless
357
+ `--qa-threshold` sets another. A CONFIRMED finding at the threshold or worse, or one with no
358
+ severity, blocks: a PASS that lists one becomes FAIL. A CONFIRMED finding below the threshold
359
+ never blocks: a FAIL made only of those is accepted, and either way they are recorded in
360
+ `known_issues.md`, which `forge issues` and the sweep pick up. PLAUSIBLE findings never block.
361
+ `--qa-threshold P3` (or `none`) makes every CONFIRMED finding block.
362
+
320
363
  The runner accepts only a standalone verdict on the final nonempty line (the shared parser
321
364
  also tolerates the dash gloss the prompt prints after each verdict, trailing whitespace and
322
365
  CRLF). A missing verdict is `UNKNOWN` and is treated exactly
@@ -337,8 +380,10 @@ review; the implementer rules appended to every dwarf prompt come from the same
337
380
  `plan --fail-first` (and `forge-solo.sh --fail-first`) checks that the tests a change adds
338
381
  or edits can fail. Before each review, forge exports the reviewed commit and, separately,
339
382
  the task's base plus only the change's test-path files (tests, their fixtures and helpers),
340
- then runs `.forge/verify-subset` (the per-file test command with `{files}`, see
341
- [Jev](jev.md)) once per new or edited test file in each. Every file gets one result in
383
+ then runs `.forge/verify-subset` (a per-file test command that contains `{files}`, such as
384
+ `pytest -q {files}` or `npm test -- {files}`; it is a separate file from `.forge/verify` because
385
+ there is no general way to restrict an arbitrary command to a file list) once per new or
386
+ edited test file in each. Every file gets one result in
342
387
  `tasks/<id>/failfirst.json` (solo: `<run>/failfirst.json`):
343
388
 
344
389
  - `proven`: passes with the change, fails without it;
@@ -349,13 +394,87 @@ then runs `.forge/verify-subset` (the per-file test command with `{files}`, see
349
394
  The reviewer's prompt lists the results and asks for a `[P2][CONFIRMED]` finding for each
350
395
  test that passes without the change, unless the reviewer explains why it need not fail
351
396
  (a refactor kept green). It is advice: forge never changes a status or verdict from it, and
352
- a P2 only blocks through the reviewer and the usual `--qa-threshold` gate. The exports are
397
+ a P2 only blocks through the reviewer and the usual threshold gate (`P2` by default, see [QA verdicts](#qa-verdicts)). The exports are
353
398
  throwaway directories outside the review snapshot, so no fingerprint changes. forge-ui
354
399
  shows the evidence under the task's review findings, and each check is recorded in the
355
400
  run dataset as a `fail_first` event with the JSON attached. Without
356
401
  `.forge/verify-subset` the check records `skipped` and the prompt says nothing.
357
402
  `plan --no-fail-first` turns it off again.
358
403
 
404
+ ### Pre-review tests (opt-in)
405
+
406
+ `plan --pre-review-tests` runs **only the tests an attempt affects** before paying for its
407
+ review, never the whole suite (that stays the run's end-of-run verification). After an attempt is
408
+ committed, forge exports the reviewed commit and runs `.forge/verify-subset` on a selection:
409
+
410
+ 1. the test files the change adds or edits;
411
+ 2. for each changed source file, the tests from the first source that answers: `.forge/test-map`,
412
+ then the naming convention (`foo.py` → `test_foo.py`, `foo_test.py`, `foo.test.js`, ...), then
413
+ a reverse lookup (test files that name the changed module);
414
+ 3. with `{changed}` in the command instead of `{files}`, the changed paths themselves, for a runner
415
+ that finds the related tests on its own (`npx jest --findRelatedTests {changed}`).
416
+
417
+ `.forge/test-map` is the reliable source; one rule per line, `#` comments, globs where `*` also
418
+ matches `/`, and `-` for "no tests":
419
+
420
+ ```
421
+ scripts/forge-issues.py tests/test_issues.py tests/test_sweep.py
422
+ ui/forge_ui/*.py ui/tests/test_*.py
423
+ docs/* -
424
+ ```
425
+
426
+ A change to shared test infrastructure (a conftest, a test helper, a lockfile, a build file),
427
+ more than 20 selected files (`FORGE_PRE_REVIEW_MAX_FILES`) or a run past 120 s
428
+ (`FORGE_PRE_REVIEW_TIMEOUT`) makes the check `skipped` as too broad. A failing run is rerun file
429
+ by file (a file that passes alone is `flaky`), and each file that still fails is run on the task
430
+ base: one that fails there too is `pre-existing` and does not count against the attempt.
431
+
432
+ - **Red** (`failed`): the attempt is `FAIL` without a review. Its retry findings are the failing
433
+ tests and the end of their output, labelled as forge's (`tasks/<id>/prereview.md`). It counts
434
+ toward `--retry-failed` and `--escalate-after` like a rejected attempt.
435
+ - **Green**, `flaky` or `pre-existing`: the review runs, and the reviewer's prompt says what forge
436
+ ran and found.
437
+ - **Skipped or broken** (no `.forge/verify-subset`, nothing selected, too broad, a command error):
438
+ the review runs exactly as without the option. The check never blocks on its own failure.
439
+
440
+ The implementer is told forge will run them, so it need not repeat them exhaustively. Checks run
441
+ in throwaway exports, so neither the task worktree nor any fingerprint changes; at most 2 run at
442
+ once across the plan's tasks (`plan --pre-review-parallel N`, 1-64). A QA-only resume reuses the
443
+ check of the commit it re-reviews. `tasks/<id>/prereview.json` records the selection, every run
444
+ and the outcome; forge-ui shows it under the task's review findings, and the dataset records a
445
+ `pre_review` event. `forge control set <plan> pre-review-tests on|off` and `pre-review-parallel N`
446
+ change both while a run works; `plan --no-pre-review-tests` turns it off.
447
+
448
+ ### Implementer session (opt-in)
449
+
450
+ `plan --implementer-session` makes a retry **continue the implementer's own session** instead of
451
+ starting one that re-reads the same files: the dwarf keeps what it learned, and the retry's prompt
452
+ (the task, the findings, the rules) arrives as the next turn, after a short note that its work is
453
+ as it left it. It applies to claude and openclaude. codex's `exec resume` takes no sandbox flag, so
454
+ a codex implementer could be resumed only by a config override nobody verifies, and it stays fresh.
455
+
456
+ A retry continues only when all of these hold; anything else is a fresh session, as without the
457
+ option:
458
+
459
+ - it carries findings from a review, or from pre-review tests, of a commit this session made;
460
+ - the worktree is still exactly that commit: no edits since (a timed-out or interrupted attempt
461
+ leaves some), nothing committed on top;
462
+ - the dwarf resolves to the same harness, model and effort, so an escalation (`--escalate-after`,
463
+ a pin, `retry --dwarf`) starts fresh;
464
+ - the plan is not Fractal.
465
+
466
+ A continue the harness refuses or that fails at once (dispatch exit **9**, nothing changed in the
467
+ worktree) is followed by a fresh dispatch of the same prompt, which decides the attempt. One that
468
+ fails after it already changed files is a failed implementer (`ERROR`), as a fresh one would be:
469
+ running another on top would pay for the attempt twice. One row per attempt goes to
470
+ `tasks/<id>/implementer_sessions.tsv`: row, attempt, `continued`, `fresh` or `failed`, the reason
471
+ (`same-spec`, `first-attempt`, `no-findings`, `work-changed`, `no-session`, `invalid-session`,
472
+ `spec-changed`, `harness-unsupported`, `fractal`, `continue-unsupported`, `continue-failed`) and
473
+ the session id it considered. The dataset tags a continued dwarf dispatch `session_continue`, and
474
+ `forge dataset status` counts implementer continues apart from reviewer ones.
475
+ `plan --no-implementer-session` turns it off; `split` and `combine` carry it (combine only when
476
+ every source has it).
477
+
359
478
  ### Shadow reviews (opt-in)
360
479
 
361
480
  `plan --shadow-qa <spec>[,<spec>...] [--shadow-rate R]` sends a sampled share of
@@ -392,17 +511,52 @@ P0 data loss, security hole, crash or wrong result on the main path; P1 wrong be
392
511
  realistic input or a broken existing contract; P2 edge-case bug, unusual-timing race, missing
393
512
  hardening; P3 minor. Severity is impact; CONFIRMED/PLAUSIBLE is confidence.
394
513
 
395
- `run`/`retry --qa-threshold Pn` (remembered in `<plan>/qa_threshold`; `none` clears it) sets
396
- the **least severe level that still blocks**. `tasks/<id>/qa_threshold` overrides it per task (the value `none` exempts the task from a plan threshold; `forge control set ... qa-threshold` writes both and takes effect at the next attempt) —
514
+ `--qa-threshold Pn` on `plan`, `run`, `retry` or `review` (remembered in `<plan>/qa_threshold`; `none`
515
+ means P3, `default` removes the setting) changes the default `P2`, the **least severe level that
516
+ still blocks** (see [QA verdicts](#qa-verdicts)). `tasks/<id>/qa_threshold` overrides it per task (a
517
+ per-task `none` means P3, so it exempts the task from a looser plan threshold; `forge control set ... qa-threshold`
518
+ writes both and takes effect at the next attempt) —
397
519
  the way to give a dev-tooling or investigation task a looser bar than production code,
398
520
  which otherwise gets a new finding in a new corner of a non-default option every round and
399
521
  only a human decision ends it. The orchestrator decides *deterministically* (`forge-contract.py gate`),
400
- it does not take the reviewer's word: with a threshold set, a `FAIL` becomes `PASS` with known
522
+ and does not take the reviewer's word in either direction: a `FAIL` becomes `PASS` with known
401
523
  issues only when there is at least one CONFIRMED finding, every CONFIRMED finding carries a
402
- `P0..P3` label, and all of them are strictly milder than the threshold. Anything unlabelled,
403
- any blocking finding, or a `FAIL` with no CONFIRMED finding stays a failure. The task's status is
404
- then the literal `PASS`; `known_issues.md`, `qa.gate` and the summary say what was tolerated.
405
- Without a threshold none of this applies.
524
+ `P0..P3` label, and all of them are strictly milder than the threshold; a `PASS` that lists a
525
+ blocking finding becomes `FAIL`. Anything unlabelled, any blocking finding, or a `FAIL` with no
526
+ CONFIRMED finding stays a failure. The task's status is then the literal `PASS`; `known_issues.md`,
527
+ `qa.gate` and the summary say what was tolerated.
528
+
529
+ ### The finding sweep (opt-in)
530
+
531
+ Tolerated findings are recorded, not fixed. `run --sweep Pn` fixes them inside the run instead: once
532
+ every task has merged, and before the combined verification, the scheduler runs `forge-sweep.py plan`
533
+ once. It collects the open findings at `Pn` or worse (the ones the threshold tolerated, plus
534
+ PLAUSIBLE ones with `--sweep-plausible`), with `forge issues`' own collector, and leaves out:
535
+
536
+ - findings a person accepted with `accept`, and findings of fix tasks (one round: what a sweep review
537
+ finds goes to `forge issues`, never into another sweep);
538
+ - dismissed ones (`forge issues --dismiss`), ones with no file, and ones whose file is gone;
539
+ - ones whose line, as the reviewer saw it, a later merge changed (`changed`, naming those merges).
540
+
541
+ Every finding left out is listed in the plan with its reason. The rest become fix tasks, one per file,
542
+ worst first, at most 8 findings each and `--sweep-max N` (default 5) tasks. Each fix task is a row
543
+ `sweep-<n>` in `tasks.tsv` with `prompt.md` and `sweep.json`. Its implementer is the plan's low tier
544
+ (the first spec of `--dwarf-low`, else of `--dwarf`; checked at `run` start), else the implementer of
545
+ the task the worst finding came from. Its reviewer is that task's reviewer. The plan (groups, findings,
546
+ dispatches) is printed and kept in `<plan>/sweep/plan.md` and `plan.json`. A plan is swept at most once.
547
+
548
+ Fix tasks share the run's scheduling, controls and `--retry-failed` budget. Their review is narrow
549
+ (`forge-contract.py qa --kind sweep`): one `S<n>: FIXED` or `S<n>: NOT FIXED` line per finding, plus
550
+ regressions as findings. It passes when at least one finding is fixed and there is no blocking
551
+ regression. When a fix task merges, its review's lines go to `tasks/<id>/sweep.outcome.json`, and
552
+ `forge issues` leaves out what it fixed (`swept` in `--json`). A fix task that fails leaves its
553
+ findings for `forge issues` and does not fail the run. The run's summary says what the sweep fixed,
554
+ and the whole-run review that follows reads the sweep's changes like any other task's.
555
+
556
+ `run --sweep-ahead` (kept in `<plan>/sweep_ahead`; `--no-sweep-ahead` turns it off) is the cheaper
557
+ first step. A task dispatched after others merged is told the open findings in files it owns (at
558
+ most 3, picked once in `tasks/<id>/sweep.ahead.json`), to fix only on its way, and its reviewer is
559
+ told the same. It adds no dispatch. A later sweep counts the ones whose line changed as `changed`.
406
560
 
407
561
  ## Retrying, and resuming an interrupted run
408
562
 
@@ -450,10 +604,10 @@ lines, because every labelled line is counted. That is the retry's review, not t
450
604
  QA-only re-run above.
451
605
 
452
606
  **In-run retries.** `run <plan> --retry-failed N` re-queues a task whose reviewer said
453
- `FAIL`/`UNKNOWN` as soon as it ends, up to `N` more times in that run, preparing the retry exactly
607
+ `FAIL`/`UNKNOWN`, or whose review was `INVALIDATED` by a change to the review copy, as soon as it ends, up to `N` more times in that run, preparing the retry exactly
454
608
  as `retry` does (same findings carry-forward, same pinned base, same cumulative review). Other
455
609
  tasks keep running; dependents wait for the task to merge. It applies per invocation (not
456
- remembered), never to `TIMEOUT`/`ERROR`/`INVALIDATED`/`CONFLICT`, and never after a retry that
610
+ remembered), never to `TIMEOUT`/`ERROR`/`CONFLICT` or an `INVALIDATED` merge, and never after a retry that
457
611
  changed nothing (`tasks/<id>/noretry`). Every entry is logged in `tasks/<id>/attempts.tsv`.
458
612
 
459
613
  **Escalation after repeated failures.** In forge's history the first three attempts at a task
@@ -497,7 +651,7 @@ changed spec passed, mostly effort bumps); the attempts this policy makes are wh
497
651
 
498
652
  **Live controls.** `forge control show|set|pin|unpin <plan>` changes a run while it works:
499
653
  `qa-threshold` (read once per attempt, so an attempt keeps the bar it started with; per task, `none`
500
- exempts it and `inherit` drops the override), `timeout`, `escalate-after`, `escalate-effort`
654
+ (P3) exempts it from a looser plan threshold and `inherit` drops the override; at plan level, `default` restores P2), `timeout`, `escalate-after`, `escalate-effort`
501
655
  (`on|off`), `verify-retries`, `infra-backoff` (a shape as for `--infra-backoff`; `none` drops it,
502
656
  read at the next infrastructure wait), and, only while a scheduler is live, `retry-budget` (plan
503
657
  or `--task`), `infra-retries` and `max-parallel` (1 to 64, at the next dispatch decision; a lower
@@ -651,7 +805,7 @@ Four subcommands act on plans after tasks have run. Full usage and refusal condi
651
805
  over the combined result (`integration.base..tip`, or `parent..candidate`) in a disposable
652
806
  checkout with the goal, every task's requirements, known issues, drift, guard notes and the
653
807
  verification result in front of the reviewer. Same verdict/severity contract and
654
- `--qa-threshold` gate as per-task QA; a mutation during the review is `INVALIDATED`; a `FAIL`
808
+ threshold gate as per-task QA; a mutation during the review is `INVALIDATED`; a `FAIL`
655
809
  or missing verdict blocks `integrate` with exit `5`, an infrastructure stop with `8`, and the
656
810
  user's branch is never touched. Nothing runs unless one of them is invoked.
657
811
  - **`split <plan> <new-plan> --tasks a,b`** copies the selected tasks' saved state to a new plan,
@@ -672,7 +826,7 @@ removes what it created.
672
826
  <repo>/../.forge-worktrees/<run-id>/<task-id> task worktree
673
827
  <repo>/../.forge-worktrees/<run-id>/_integration integration worktree
674
828
  forge/<run-id>/<task-id> task branch
675
- forge/<run-id> integration branch
829
+ forge/<run-id>-integration integration branch
676
830
  ```
677
831
 
678
832
  Fractal also keeps control repositories, isolated product candidates and per-step logs
@@ -702,6 +856,21 @@ one checkout holding every task's merged work is the one checkout that cannot bu
702
856
  Failure is reported and non-fatal: the dwarf gets a worktree it can still install into itself,
703
857
  which is the status quo this replaces. Output lands in `tasks/<id>/setup.out`.
704
858
 
859
+ **Submodules.** `git worktree add` leaves every submodule directory empty. Before the setup step,
860
+ forge fills them offline from the source checkout (no fetch, no `git submodule`), so `.forge/setup`
861
+ sees a complete tree. Each submodule gets one state in `tasks/<id>/submodules.txt`:
862
+
863
+ - `exported` — the recorded commit was extracted from the source's submodule repository;
864
+ - `copied` — that commit was not available, so the source checkout's files were copied;
865
+ - `kept` — the directory already held files (a resume), left as they are;
866
+ - `missing` — nothing was available; the directory stays empty and the runner prints a note.
867
+
868
+ The files carry no `.git`, so git ignores them: they never appear in `changes.diff`, a commit, a
869
+ review snapshot or a fingerprint, and the worktree still moves and is removed normally. The capsule
870
+ tells the dwarf which submodules are present. Integration worktrees (`run`, `integrate`, `combine`,
871
+ `split`) get the same treatment. Out of scope: a task that moves a gitlink's recorded commit (its
872
+ worktree keeps the old content) and nested submodules (left empty).
873
+
705
874
  Forge does not guess this step, and the obvious guess is worth naming because it looks right and
706
875
  is not: symlinking the source repo's `node_modules` into the worktree. In a workspace monorepo the
707
876
  workspace links inside it point back at the source checkout, so the worktree builds against the
@@ -734,7 +903,8 @@ The user's own branch and working tree are untouched for the whole run.
734
903
  | task status `INFRA`, `run` exits `8` | quota/auth/rate limit/network/empty output stopped a dispatch; no attempt spent. See `tasks/<id>/infra.txt`, fix the cause, run again (or `--infra-retries M`, `--infra-fallback`) |
735
904
  | task status `INTERRUPTED`, `run` exits `130` | the run was signalled or stopped with `forge control stop --now`; verification was skipped. The summary prints `forge-parallel.sh retry <plan> <id>` for each one; a plain `run` does not dispatch them |
736
905
  | a run that sits idle with tasks `PENDING` | `forge control drain` is in effect (`forge control show` says `drained`; `forge control resume` continues), every scope a task needs is paused on infrastructure (`infra.paused`), or `max-parallel` is lower than you think |
737
- | a `FAIL` task merged anyway | an explicit `--qa-threshold` tolerated its findings; see `known_issues.md` and `qa.gate` |
906
+ | a `FAIL` task merged anyway | the threshold (`P2` by default) tolerated its findings, or a person ran `accept`; see `known_issues.md` and `qa.gate` |
907
+ | a task `FAIL`ed although its reviewer said `PASS` | forge's gate: a CONFIRMED finding at or above the threshold was listed (`qa.gate` decision `fail`); the retry starts with a note saying so |
738
908
  | task status `CONFLICT` | QA passed but the merge onto the integration branch conflicted — `files` was understated somewhere |
739
909
  | every wave has one task | `files` sets overlap across most tasks; the decomposition is not actually parallel |
740
910
  | dwarves ignore existing work | `goal.txt` or `files` missing, so the capsule carries no useful status |
@@ -758,8 +928,9 @@ retried after its prerequisites merge. A fresh task then branches from current i
758
928
 
759
929
  QA receives complete implementation input, approach, capsule and cumulative binary diff.
760
930
  It runs in a disposable repository. Both source and review fingerprints must remain unchanged,
761
- and the task branch must still point at the reviewed commit when merged. INVALIDATED results
762
- never merge. Disposable snapshots detect mutation; they do not confine unrestricted shell access.
931
+ and the task branch must still point at the reviewed commit when merged; the review copy is a
932
+ commit, so only its tracked content counts (a test run's untracked `__pycache__/` there changes
933
+ nothing). INVALIDATED results never merge; `retry` re-runs only QA while the work is unchanged. Disposable snapshots detect mutation; they do not confine unrestricted shell access.
763
934
 
764
935
  Configure combined executable checks with `run <plan> --verify '<command>'` (also accepted by
765
936
  `retry`), or a shell command file at `<repo>/.forge/verify`. Commands execute under Bash from
@@ -771,8 +942,7 @@ A failed command whose source fingerprint is unchanged is rerun (`--verify-retri
771
942
  `1`, `0` = strict single run). A rerun that passes leaves status `PASS` but writes
772
943
  `verification.flaky` (both exit codes), keeps the first run in `verification.log` and the second
773
944
  in `verification.retry.log`, and prints a loud `FLAKY` line in `run`/`retry`/`integrate` output;
774
- a command that changes the tree is never retried. This runs before Jev's optional model-assisted
775
- triage, which then does not.
945
+ a command that changes the tree is never retried.
776
946
 
777
947
  **Verification lanes.** Instead of one command, verification can be several named **lanes**
778
948
  that run side by side, each rerun on its own. A lane is a file whose name is the lane's name
@@ -803,8 +973,7 @@ in the run output (`FLAKY: lane <name> failed once and passed on rerun`), in
803
973
  checkout's fingerprint is compared after every round, and a change fails the verification
804
974
  (`mutated`; with lanes in parallel it cannot be pinned to one of them). A lane's states are
805
975
  `waiting`, `running`, `pass`, `fail`, `flaky`, `known`, `skipped` and `interrupted`. Lanes mode
806
- replaces the whole-command rerun above and Jev's flake triage (a note says so when Jev's tests
807
- site is on); the single-command mode is unchanged.
976
+ replaces the whole-command rerun above; the single-command mode is unchanged.
808
977
 
809
978
  A lane may print `::forge step name=<step> state=start` and `::forge step name=<step>
810
979
  state=end [exit=<n>]`, each on a line of its own, to say which step it is in; forge-ui shows the
@@ -22,7 +22,7 @@ provider test. See [Fractal execution](fractal.md).
22
22
  - [opencode](#opencode)
23
23
  - [antigravity (agy)](#antigravity-agy)
24
24
  - [grok](#grok)
25
- - [Continuing a reviewer session](#continuing-a-reviewer-session)
25
+ - [Continuing a reviewer session](#continuing-a-reviewer-session) (and an implementer's)
26
26
  - [Adding a harness](#adding-a-harness)
27
27
 
28
28
  ## At a glance
@@ -329,8 +329,15 @@ A grok reviewer has not been proven live yet.
329
329
  `forge-dispatch.sh qa <spec> ... --continue-session <id>` continues an earlier reviewer session instead of
330
330
  starting a fresh one. `<id>` is the session or thread id a dispatch left in `<run-dir>/<role>.session`
331
331
  (8 to 128 characters of `[A-Za-z0-9-]`, not starting with `-`). It is accepted for the `qa` role on claude,
332
- openclaude and codex in custom-prompt mode only; any other role, harness, `--native-review` or a malformed id
333
- is a usage error (exit 2). Nothing in forge asks for it by default.
332
+ openclaude and codex in custom-prompt mode only, and for the `dwarf` role on claude and openclaude
333
+ (`plan --implementer-session`); any other role or harness, `--native-review` or a malformed id is a usage
334
+ error (exit 2). Nothing in forge asks for it by default.
335
+
336
+ An implementer continues with the fresh dwarf argv plus `--resume <id>`, so it keeps `acceptEdits` and its
337
+ Bash allowance. codex is reviewer-only: `exec resume` has no `-s` and no `--approve-for-me` (checked against
338
+ codex-cli 0.164.0), so its write access would rest on a config override that nothing verifies, and a
339
+ sandbox it silently lacked would end in an empty diff. Its preamble says the work has been reviewed since,
340
+ is in `<repo>` as the implementer left it and need not be re-read, and that this attempt's instructions win.
334
341
 
335
342
  Probed 2026-10-22 (claude 2.1.307, codex 0.162.0):
336
343
 
@@ -38,5 +38,13 @@ pass on a first attempt, each ending its prompt with an `## Acceptance criteria`
38
38
  checks the reviewer can verify; see [task size](decompose.md#task-size-and-acceptance-criteria). Write each task's approach to
39
39
  `tasks/<id>/approach.md`, where the runner picks it up for both the dwarf and qa.
40
40
 
41
+ If `plan` exits 4 (the prompt or coverage gate is `on` and sent work back), read
42
+ `<plan>/plan.sendback.md` and re-dispatch the planner with that file appended to its prompt: it
43
+ rewrites the listed `prompt.md` files and extends or adds tasks for each uncovered requirement.
44
+ Then run `plan` again, once; forge never sends the same task or requirement back twice. Under
45
+ the table, the `decision-model gates:` block lists what drift and forward added to
46
+ `tasks.tsv` (files and deps, `on` only) and what is still flagged; see
47
+ [decomposition](decompose.md#plan-gates-sent-back-and-the-block-under-the-table).
48
+
41
49
  Show the approach before dispatching and let the user change it. That gate is the last
42
50
  moment the plan is free; after it, changing the plan costs a whole run.
@@ -46,7 +46,7 @@ Statuses: PASS, FAIL, UNKNOWN, NOCHANGES, INVALIDATED. Exit codes: 0 completed r
46
46
  review, 7 timeout, 8 infrastructure failure (quota, auth, rate limit, network, empty output:
47
47
  nothing was judged — fix the cause and run again; a dwarf that returns nothing *and* changes
48
48
  nothing is reported as 8, not 5). The default dispatch timeout is 2700 seconds, scaled up for
49
- `xhigh`/`max` effort (so the default QA/planner effort gets 3600), overridable per model in the
49
+ `xhigh`/`max` effort (so the default planner effort gets 3600; QA defaults to `high`), overridable per model in the
50
50
  registry; 0 disables that dispatch timeout, but an enabled Fractal task still has its own attempt
51
51
  deadline. See [dispatch timeouts](../docs/commands.md#scriptsforge-dispatchsh).
52
52
 
@@ -54,8 +54,18 @@ The dwarf prompt carries implementer rules (no commits, no background processes,
54
54
  measurement before the last message). forge records what it observes: if the dwarf committed
55
55
  anyway the run still reviews its changes, says so, and prints `git reset --soft <old HEAD>` —
56
56
  it never resets anything itself; leftover processes (stopped) and promises of later work appear
57
- under "implementer guard notes". The QA prompt asks for `P0..P3`-labelled findings; solo has no
58
- threshold gate, so any CONFIRMED finding still fails.
57
+ under "implementer guard notes". The QA prompt asks for `P0..P3`-labelled findings.
58
+
59
+ forge decides the verdict from the findings, at a blocking threshold: `P2` unless
60
+ `--qa-threshold` sets another. A CONFIRMED finding at the threshold or worse, or one with no
61
+ severity, blocks: a PASS that lists one becomes FAIL. A CONFIRMED finding below the threshold
62
+ never blocks: a FAIL made only of those is accepted, and either way they are recorded in
63
+ `known_issues.md`, which `forge issues` and the sweep pick up. PLAUSIBLE findings never block.
64
+ `--qa-threshold P3` (or `none`) makes every CONFIRMED finding block.
65
+
66
+ `--qa-threshold P0|P1|P2|P3|none` sets this run's threshold and is written to `<run>/qa_threshold`
67
+ only when given. The gate, the same as in a decomposed run, writes `qa.gate` and `known_issues.md`
68
+ in the run directory. See [the verdict rule](decompose.md#qa-verdicts).
59
69
 
60
70
  `--native-review` is an explicit Codex-only alternative: native review cannot accept the
61
71
  custom requirements prompt or verdict instruction. Its result is informational and UNKNOWN;
package/references/ui.md CHANGED
@@ -55,6 +55,17 @@ run goes on, with the same exit code.
55
55
  output; after a failure, the failing tests first, by lane, new or known (from JUnit/TAP
56
56
  reports), each opening the lane's log at its line, or a reportless lane's log tail; then every
57
57
  lane's state, time, runs and tests; a lane's name opens its output.
58
+ - **Where each task is:** the task table's *Now* column and a task's *Now* section: the command a
59
+ running dwarf or reviewer runs and for how long, flagged *quiet* after five minutes with no
60
+ output, or why a task waits (dependencies, shared files, no free slot, a drain or stop, an
61
+ infrastructure pause with its countdown, the retry policy's stop and its split). The run
62
+ inspector says what the scheduler is doing.
63
+ - **Checks:** each attempt's tests, type checks, lints and builds, read from its dwarf's and
64
+ reviewer's logs, with exits, times and counts, a failed one's last lines, and which of the
65
+ commands its `## Acceptance criteria` name never ran. codex and grok logs carry no times, so
66
+ `forge-dispatch.sh` keeps `<role>.clock` (when the log grew, each second) beside each log for
67
+ them; `FORGE_LOG_CLOCK=off` turns it off. An environment problem (Docker, a sandbox's EPERM, a
68
+ port in use, …) that several tasks' failed commands met gets one banner in the run header.
58
69
  - **Opening a node** shows its attempts, dwarves and reviews, and an inspector with the prompt
59
70
  that launched each one, the model, timings by phase, tokens, verdicts and the P0–P3 findings
60
71
  of every review (the final review's included).
@@ -1,14 +1,18 @@
1
1
  #!/usr/bin/env bash
2
2
  # Shared artifact operations. A private index never stages or unstages user work.
3
+ # forge_tree <dir> [--tracked]: the tree of everything in <dir> that is not ignored. --tracked
4
+ # leaves untracked files out, for a copy whose artifact is a commit: there an untracked file
5
+ # (a test run's __pycache__/ in a repository with no .gitignore) cannot reach what merges.
3
6
  forge_tree() (
4
7
  cd "$1" || exit 1
5
- local idx tree actual_index f
8
+ local idx tree actual_index f add=-A
9
+ [ "${2:-}" = --tracked ] && add=-u
6
10
  idx="$(mktemp "${TMPDIR:-/tmp}/forge-index.XXXXXX")" || exit 1
7
11
  rm -f "$idx"
8
12
  trap 'rm -f "$idx"' EXIT
9
13
  actual_index="$(git rev-parse --git-path index)" || exit 1
10
14
  export GIT_INDEX_FILE="$idx"
11
- git read-tree HEAD && git add -A -- . ':(exclude).forge' || exit 1
15
+ git read-tree HEAD && git add "$add" -- . ':(exclude).forge' || exit 1
12
16
  # Force-added ignored files are tracked in the real index, but not in HEAD yet.
13
17
  GIT_INDEX_FILE="$actual_index" git diff --cached --name-only --diff-filter=A -z HEAD |
14
18
  while IFS= read -r -d '' f; do
@@ -55,14 +59,36 @@ forge_review_snapshot() ( # source, baseline tree, final tree, destination
55
59
 
56
60
  )
57
61
 
58
- forge_fingerprint() {
62
+ forge_fingerprint() { # forge_fingerprint <dir> [--tracked], as forge_tree
59
63
  local tree head index
60
- tree="$(forge_tree "$1")" || return 1
64
+ tree="$(forge_tree "$1" "${2:-}")" || return 1
61
65
  head="$(git -C "$1" rev-parse HEAD)" || return 1
62
66
  index="$(git -C "$1" diff --cached --binary HEAD | git -C "$1" hash-object --stdin)" || return 1
63
67
  printf '%s %s %s\n' "$head" "$tree" "$index"
64
68
  }
65
69
 
70
+ forge_pre_review() { # review snapshot, task dir, repo, plan dir: 1 when the affected tests fail (#85)
71
+ # Runs only the tests the attempt affects, in throwaway exports of the review snapshot, so no
72
+ # fingerprint changes. Writes <dir>/prereview.json, the reviewer's evidence to prereview.txt
73
+ # and, when they fail, the implementer's findings to prereview.md. Anything but a red check
74
+ # (nothing selected, too broad, a broken check) returns 0: the review runs as usual.
75
+ local cmd="" map="" reviewed rc
76
+ rm -f "$2/prereview.json" "$2/prereview.txt" "$2/prereview.md"
77
+ [ -s "$3/.forge/verify-subset" ] && cmd="$(cat "$3/.forge/verify-subset")"
78
+ [ -s "$3/.forge/test-map" ] && map="$3/.forge/test-map"
79
+ reviewed="$(git -C "$1" rev-parse HEAD)" || return 0
80
+ python3 "$SKILL_DIR/scripts/forge-pre-review.py" run --repo "$1" --base "$(cat "$2/review.base")" \
81
+ --reviewed "$reviewed" --command "$cmd" ${map:+--map "$map"} --out "$2/prereview.json" \
82
+ --report "$2/prereview.md" --deps-from "$3" --slots-dir "$4/.prereview-slots" \
83
+ --slots "$(cat "$4/pre_review_parallel" 2>/dev/null || echo 2)" --log "$2/prereview.log" \
84
+ > "$2/prereview.txt" 2>/dev/null
85
+ rc=$?
86
+ forge_dataset_event pre_review --dir "$2" --file prereview="$2/prereview.json"
87
+ [ "$rc" = 1 ] && [ -s "$2/prereview.md" ] && return 1
88
+ [ "$rc" = 0 ] || : > "$2/prereview.txt"
89
+ return 0
90
+ }
91
+
66
92
  forge_fail_first() { # review snapshot, run or task dir, repo: advisory fail-first evidence for QA
67
93
  # Writes <dir>/failfirst.json and the reviewer's section to <dir>/failfirst.txt; never fails
68
94
  # the run and never touches the snapshot (forge-fail-first.py exports through its own index).