@giamme/forge 0.13.0 → 0.14.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 (60) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/SKILL.md +17 -11
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +1 -0
  5. package/docs/commands.md +121 -7
  6. package/docs/development.md +3 -0
  7. package/docs/forge-ui.md +7 -1
  8. package/docs/reviews.md +2 -0
  9. package/docs/troubleshooting.md +5 -1
  10. package/forge +28 -1
  11. package/package.json +1 -1
  12. package/references/dataset.md +3 -1
  13. package/references/decision-models.md +5 -1
  14. package/references/decompose.md +199 -61
  15. package/references/runtime.md +29 -0
  16. package/references/ui.md +10 -0
  17. package/scripts/forge-compare.py +491 -0
  18. package/scripts/forge-config.py +3 -3
  19. package/scripts/forge-contract.py +34 -8
  20. package/scripts/forge-control.py +105 -13
  21. package/scripts/forge-dispatch.sh +9 -5
  22. package/scripts/forge-jev-options.sh +17 -4
  23. package/scripts/forge-ledger.py +387 -0
  24. package/scripts/forge-lib-plans.sh +16 -2
  25. package/scripts/forge-lib-task.sh +390 -28
  26. package/scripts/forge-parallel-options.sh +20 -4
  27. package/scripts/forge-parallel.sh +118 -12
  28. package/scripts/forge-plan-check.py +68 -3
  29. package/scripts/forge-pr.py +276 -0
  30. package/scripts/forge-route.py +350 -34
  31. package/scripts/forge-runs.py +18 -1
  32. package/scripts/forge-runtime.py +23 -7
  33. package/scripts/forge-schedule.py +303 -46
  34. package/scripts/forge-solo.sh +1 -0
  35. package/scripts/forge-ui-options.sh +25 -0
  36. package/scripts/forge-verify-failed.py +111 -0
  37. package/scripts/forge-watch.py +372 -0
  38. package/scripts/forge_dataset/export.py +87 -41
  39. package/scripts/forge_dataset/harvest.py +3 -1
  40. package/scripts/forge_decide/budget.py +39 -8
  41. package/scripts/forge_decide/doctor.py +49 -0
  42. package/scripts/forge_fractal/cli.py +23 -6
  43. package/scripts/forge_infra.py +274 -0
  44. package/scripts/forge_jev/client.py +13 -9
  45. package/ui/docs/api.md +83 -15
  46. package/ui/forge_ui/control.py +11 -3
  47. package/ui/forge_ui/export.py +6 -2
  48. package/ui/forge_ui/models.py +16 -16
  49. package/ui/forge_ui/reader.py +217 -13
  50. package/ui/forge_ui/repos.py +428 -0
  51. package/ui/forge_ui/static/app.js +24 -5
  52. package/ui/forge_ui/static/checksview.js +20 -7
  53. package/ui/forge_ui/static/cloudmodel.js +8 -5
  54. package/ui/forge_ui/static/controls.js +6 -3
  55. package/ui/forge_ui/static/modelstats.js +12 -8
  56. package/ui/forge_ui/static/panel.js +69 -4
  57. package/ui/forge_ui/static/runmodel.js +55 -10
  58. package/ui/forge_ui/static/scene3d.js +3 -2
  59. package/ui/forge_ui/static/settings.js +147 -29
  60. package/ui/forge_ui/static/style.css +49 -7
@@ -262,11 +262,15 @@ So:
262
262
  parallel tasks. A task should still be reviewable and correct on its own.
263
263
  - End every `prompt.md` with an `## Acceptance criteria` section: observable checks the
264
264
  reviewer can verify (a behaviour, a command that passes, a file that exists), not
265
- restated goals.
265
+ restated goals. A command names the task's own tests, never the whole suite: the run's
266
+ verification runs the suite after each merge, and naming it here makes every attempt run it.
266
267
  - `plan` prints an advisory block under the table naming tasks at 7,000 characters or 9
267
- declared files and over, with the history for their size, and tasks with no acceptance
268
- criteria. A heading inside a code fence, or with nothing under it, does not count. The
269
- block never changes the table or the exit code.
268
+ declared files and over, with the history for their size, tasks with no acceptance
269
+ criteria, and tasks whose acceptance criteria ask for the whole suite (forge's
270
+ `tests/check.sh`, a bare `unittest discover`, `npm test`, `make check`, `cargo test` and the
271
+ like, or a command of the plan's `--verify` or the repository's `.forge/verify`). A heading
272
+ inside a code fence, or with nothing under it, does not count. The block never changes the
273
+ table or the exit code.
270
274
 
271
275
  ## Plan gates: sent back, and the block under the table
272
276
 
@@ -374,6 +378,10 @@ forge's rule that a dwarf → QA cycle does not loop on its own initiative.
374
378
  The prompt contract (preamble, findings format, severity definitions and the verdict lines)
375
379
  comes from one place, `scripts/forge-contract.py`, shared by solo, decomposed and the final
376
380
  review; the implementer rules appended to every dwarf prompt come from the same module.
381
+ When the run verifies the repository (`--verify`, verification lanes or `.forge/verify`), those
382
+ rules tell the implementer never to run the whole suite, even when the task's acceptance
383
+ criteria name it, and to report it as left to forge: the suite runs once, after the merge.
384
+ Without verification, the implementer runs the whole suite only when the task asks for it.
377
385
 
378
386
  ### Fail-first evidence (opt-in)
379
387
 
@@ -617,14 +625,16 @@ times on one model (`--escalate-after N` on `run` or `retry`, kept in the plan,
617
625
  turns it off):
618
626
 
619
627
  - **Counting:** the count is the task's failed attempts (FAIL, or an implementer TIMEOUT) on its current model,
620
- from the fifth column of `attempts.tsv`. Infrastructure stops, missing verdicts and
621
- forge's own errors judge nothing and are skipped; a pass or a change of model resets it.
628
+ from the fifth column of `attempts.tsv`, after the latest row of `tasks/<id>/decisions.tsv`.
629
+ Infrastructure stops, missing verdicts and forge's own errors judge nothing and are skipped; a pass
630
+ or a change of model resets it. A lateral move does not: the streak carries across `tasks/<id>/lateral.tsv`.
622
631
  - **Escalation:** at the threshold, the next attempt goes to a different model in the next tier
623
632
  up of the pools given to `plan` (same position in the pool, as with exploration),
624
633
  recorded in `escalations.tsv` and `tasks.tsv` like a `retry --dwarf`.
625
634
  - **Stop:** when nothing is above (the model is in the top tier, or in no tier pool at
626
- all), the task stops with `tasks/<id>/split.suggested`: split it into smaller tasks, or
627
- name a model. `run --retry-failed` does not retry it, and a plain `retry` refuses (exit 2).
635
+ all), the task stops as `NEEDS_DECISION` with reason `split` (see [When reviews don't converge](#when-reviews-dont-converge)).
636
+ `tasks/<id>/split.suggested` still says to split it or name a model. `run --retry-failed` does not retry it,
637
+ and a plain `retry` refuses (exit 2).
628
638
  - **Effort step** (`--escalate-effort` on `run` or `retry`, kept in the plan as `escalate_effort`;
629
639
  `--no-escalate-effort` removes it; off by default): when no higher tier has another model, the
630
640
  same alias and harness is tried once more at the next effort its pairing accepts
@@ -649,11 +659,82 @@ turns it off):
649
659
  History cannot yet say whether escalating rescues a task (31% of the 29 later attempts on a
650
660
  changed spec passed, mostly effort bumps); the attempts this policy makes are what will.
651
661
 
662
+ ## When reviews don't converge
663
+
664
+ A task can fail review after review, each round with new findings. forge keeps a findings ledger
665
+ at `tasks/<id>/ledger.tsv`, one row per review: epoch, attempt, review, verdict, gate, worst,
666
+ confirmed, new, carried, diff_bytes, delta_bytes. A CONFIRMED finding is carried when the previous
667
+ review named the same problem; the rest are new. The diff sizes are `changes.diff` and
668
+ `changes.since.diff` as they stand when the row is written.
669
+
670
+ The signal looks at the last reviews. The count is the plan file `converge_window` when that file
671
+ holds a number (`plan --converge-window N`, or `forge control set converge-window N` later), and
672
+ **4** otherwise. It fires when every review in that window failed (verdict
673
+ FAIL, or the gate turned a PASS into a fail) with at least one CONFIRMED finding, at least half of
674
+ the findings in the later reviews are new, and the worst severity is no better in the last review
675
+ than in the first. A window below 2 never fires. On past runs, a window of 4 stopped no task that
676
+ merged by attempt 4. Rows from before the latest `tasks/<id>/decisions.tsv` entry do not count: a
677
+ decision restarts the window, and the escalation streak with it.
678
+
679
+ Task and solo reviews are asked to list every CONFIRMED finding, and to say so plainly when the
680
+ diff is correct, so a round is the whole list and not only the worst few.
681
+
682
+ The task then stops with status **`NEEDS_DECISION`**. So does a task the retry policy cannot
683
+ escalate further (reason `split`; `split.suggested` still names the suggestion), and a task at its
684
+ attempt cap (reason `cap`). The cap is `plan --max-attempts N`, default **8** when `max_attempts`
685
+ is absent, counted across runs: an infrastructure stop spends nothing, and each `retry=N` a person
686
+ grants adds N to the cap. `0` is no cap, and a grant does not create one. `forge control set max-attempts N --confirm`
687
+ changes it; `--confirm` applies only to that key. A `NEEDS_INPUT` task at the cap keeps its question:
688
+ raise the plan's cap before the answer can start an attempt.
689
+
690
+ `tasks/<id>/decision.md` gives the reasons and the choices. Nothing else resumes the task: not a
691
+ re-run, not `--retry-failed`, not a retry budget and not a pin. A plain `retry` exits 2. The
692
+ choices:
693
+
694
+ - `forge-parallel.sh retry <plan> <id> --decide retry=N --reason "…" --approved` gives N more
695
+ attempts, N from 1 to 20. At the cap this raises the cap by N, and it is the only choice that
696
+ runs the task again while the attempts already spent sit on the cap.
697
+ - `forge-parallel.sh retry <plan> <id> --decide threshold=Pn --reason "…" --approved` sets this
698
+ task's blocking threshold (`P0`, `P1`, `P2` or `P3`) and then retries once.
699
+ - `forge-parallel.sh retry <plan> <id> --dwarf <spec> --reason "…" --approved` names a model. Not
700
+ together with `--decide`.
701
+ - `forge-parallel.sh accept <plan> <id> --reason "…" --approved` merges it; the findings become
702
+ known issues.
703
+ - Split it by hand: `tasks/<id>/decision.md` and the run summary say to replace its row in
704
+ `tasks.tsv` with smaller tasks, then `forge-parallel.sh run <plan>`, which reads that file
705
+ again and recomputes `waves.tsv`. `forge control drain` and `add` do not do it: they need a
706
+ scheduler that is still live (exit 3 once `scheduler.live` is gone, which it is by the time
707
+ the summary is printed), and `add` queues a new row without replacing the stopped one, which
708
+ stays `NEEDS_DECISION` for that invocation (its dependents keep the `deps` loaded at the
709
+ start, and the run exits 5 while the row is unmerged).
710
+
711
+ Take the stopped task's row out of `tasks.tsv`. Leave `tasks/<id>/` where it is; its diff
712
+ is not on the integration branch. A row left in place is not dispatched. Append one row
713
+ per smaller task, seven tab-separated columns: `id`, `deps`, `difficulty` (`low`, `medium`
714
+ or `high`), `files` (non-empty), `dwarf`, `qa`, `title`. Copy the stopped task's `dwarf`
715
+ and `qa` (explicit specs; `forge control add` refuses `-` and `UNASSIGNED`, and `run`
716
+ preflights every spec). `deps` is `-`, a task that is already `MERGED`, or another new
717
+ task. On every remaining row whose `deps` named the stopped task, put those new ids in
718
+ its place: a dependency that is no longer a row makes `run` die with `dependency cycle or
719
+ unsatisfiable deps`, and one that never merges leaves the dependent `BLOCKED`. Write a
720
+ non-empty `tasks/<id>/prompt.md` for each new id. The next `run` skips `MERGED` work and
721
+ dispatches the new rows from the integration branch as it stands, not from the stopped
722
+ task's worktree. While a scheduler is still live, `forge control add` can queue a row
723
+ written this way whose dependencies that run already knows; the row that replaces the
724
+ stopped task takes effect on the `run` after the scheduler has exited.
725
+ `forge-parallel.sh split` moves whole tasks into a new plan
726
+ ([below](#accepting-splitting-combining-and-the-whole-run-review)).
727
+
728
+ A live scheduler takes the same decision as `forge control retry <plan> <id> --decide …` (or
729
+ `--dwarf`), with `--reason` and `--approved`; that only queues the request. The answer is appended
730
+ to `tasks/<id>/decisions.tsv` (epoch, attempt, choice, reason). The run summary lists these tasks
731
+ under `waiting for your decision:`. A run that ends with such a task unmerged exits 5.
732
+
652
733
  **Live controls.** `forge control show|set|pin|unpin <plan>` changes a run while it works:
653
734
  `qa-threshold` (read once per attempt, so an attempt keeps the bar it started with; per task, `none`
654
735
  (P3) exempts it from a looser plan threshold and `inherit` drops the override; at plan level, `default` restores P2), `timeout`, `escalate-after`, `escalate-effort`
655
736
  (`on|off`), `verify-retries`, `infra-backoff` (a shape as for `--infra-backoff`; `none` drops it,
656
- read at the next infrastructure wait), and, only while a scheduler is live, `retry-budget` (plan
737
+ read at the next infrastructure wait), `infra-fallback` (`on|off`, at the next infrastructure stop), `max-attempts` (a non-negative integer, `0` = no cap, and only with `--confirm`), `converge-window` (a non-negative integer), and, only while a scheduler is live, `retry-budget` (plan
657
738
  or `--task`), `infra-retries` and `max-parallel` (1 to 64, at the next dispatch decision; a lower
658
739
  limit lets running tasks finish and never stops one). The budgets
659
740
  keep the **per invocation** rule: the flags of `run` are not remembered, and a live scheduler only
@@ -667,7 +748,8 @@ run. `pin <task> <spec>` sets the model the task's next full retry uses, once (c
667
748
  the pin stays and nothing is retried. A QA-only resume leaves it for the next full retry;
668
749
  Fractal plans never apply pins; a MERGED task refuses one.
669
750
  The last column of `escalations.tsv` says who decided: `policy`, `retry` (an explicit
670
- `--dwarf`), `pin` or `fallback` (`--infra-fallback`, below); four-column rows read as `policy`.
751
+ `--dwarf`) or `pin`; four-column rows read as `policy`. Older rows may say `fallback`.
752
+ A sideways move is recorded in `lateral.tsv`, not here (see [Infrastructure failures](#infrastructure-failures)).
671
753
  Every change goes to `control.log` (JSON lines: `at`, `actor` `cli|ui`, `action`, `task`, `key`,
672
754
  `value`, `previous`) and to the dataset as a `control` event. Exit 2 invalid input, 3 refused (not
673
755
  live, MERGED, Fractal, failing doctor, lock busy over 5 s). Report them; never set one yourself
@@ -690,16 +772,16 @@ Five more commands steer a live scheduler (exit 3 when none is live):
690
772
  an outcome line to `control.log` with the same `request` id (`actor` `scheduler`, `outcome`
691
773
  `applied|refused`, `reason`). `retry` takes a `FAIL`, `UNKNOWN`, `TIMEOUT`, `ERROR`,
692
774
  `BLOCKED` or `INTERRUPTED` task that is neither running nor waiting, prepares it exactly as
693
- `forge-parallel.sh retry` does (a policy stop refuses it unless `--dwarf` names a model), and
694
- spends no automatic retry budget; an `INFRA` task is the
695
- scheduler's own to resume. `add` takes a row the human appended to `tasks.tsv` (with its
775
+ `forge-parallel.sh retry` does. A `NEEDS_DECISION` task is resumed only by `--decide` or
776
+ `--dwarf`, each with `--reason` and `--approved`. It spends no automatic retry budget; an
777
+ `INFRA` task is the scheduler's own to resume. `add` takes a row the human appended to `tasks.tsv` (with its
696
778
  `tasks/<id>/prompt.md`) whose dependencies this run already knows, and refreshes `waves.tsv`.
697
779
  A request never outlives the scheduler that was live when it was queued; one left behind is
698
780
  refused, and every request is refused once the run is stopping.
699
781
 
700
782
  **Ordinary execution resume:** run `run` again. Tasks already `MERGED` are skipped. A saved PASS is fingerprint-checked and merged without
701
783
  redispatch. PENDING, `INFRA` (paused by an infrastructure failure) and newly unblocked tasks run
702
- when eligible. Failed or interrupted tasks
784
+ when eligible. A `NEEDS_DECISION` task is not among them: only a decision resumes it. Failed or interrupted tasks
703
785
  require an explicit `retry` (or `--retry-failed N`); `run` never silently pays for them again. Worktrees and pinned
704
786
  baselines are retained. A per-plan advisory lock excludes concurrent run/retry/integrate
705
787
  operations.
@@ -727,60 +809,107 @@ Pause, stop and inspection preserve both the work and diagnostics.
727
809
 
728
810
  ## Infrastructure failures
729
811
 
730
- Quota or usage limits, auth problems, rate limits, network errors and empty answers say nothing
731
- about the work. `forge-dispatch.sh` classifies them from the dispatch log (strong phrases and
732
- structured `is_error`/`turn.failed` results only; a reply that otherwise succeeded is never
733
- reclassified) and exits **8**, writing `<role>.infra` (`class=`, `retry_after=`, `detail=`,
734
- `harness=`, `model=`). `do_task` then ends the task as **`INFRA`**, copying that file to
735
- `tasks/<id>/infra.txt` with `stage=dwarf|qa`:
812
+ A usage window, a spent budget, an auth problem, a rate limit, a provider outage, a network error,
813
+ an empty answer or a cancelled dispatch says nothing about the work. The status stays **`INFRA`**.
814
+ `forge-dispatch.sh` classifies the stop from the dispatch log (strong phrases and structured
815
+ `is_error`/`turn.failed` results only; a reply that otherwise succeeded is never reclassified) and
816
+ exits **8**, writing `<role>.infra` (`class=`, `retry_after=`, `reset_at=` when the wait is known,
817
+ `detail=`, `rc=`, `role=`, `harness=`, `model=`). `do_task` copies that file to
818
+ `tasks/<id>/infra.txt` and adds `stage=dwarf|qa`. The class is a symptom. What happens next is the
819
+ cause, from `CAUSES` in `scripts/forge_infra.py`. A run recorded before the split may say `quota`;
820
+ that name is recovered as `usage_limit`, and the summary still prints the stored word.
736
821
 
737
822
  - a **dwarf-stage** stop refunds the attempt counter;
738
- - a **QA-stage** stop keeps the attempt (the dwarf's work is real and committed) and writes the
739
- `resume=qa` marker, so the next entry re-reviews without running the dwarf.
740
-
741
- The scheduler pauses only what the stop says something about. Its **scope** comes from the class:
742
-
743
- | Class | Scope paused | Other tasks |
744
- |---|---|---|
745
- | `rate_limit` | that model on that harness (`model:<harness>/<model>`) | keep running, on any other model |
746
- | `quota`, `auth` | that harness's account (`harness:<harness>`) | keep running on other harnesses |
747
- | anything else (network, empty output, ...) | everything (`all`): running tasks drain, nothing new starts | wait with it |
823
+ - a **QA-stage** stop keeps the attempt (the dwarf's work is committed) and writes the `resume=qa`
824
+ marker, so the next entry re-reviews without running the dwarf.
748
825
 
749
- A pending task whose next dispatch (its implementer and reviewer, or the reviewer alone before a
750
- QA-only resume) needs a paused pair waits; the rest of the run continues. Unstarted tasks stay
751
- `PENDING`, never `BLOCKED`. Without `--infra-retries`, `run` ends once nothing else can run, prints
752
- what to fix and exits `8`; verification is skipped and running the same command again resumes.
753
- `run --infra-retries M` waits out each scope instead, up to `M` waits **per scope** (a stop in a
754
- scope already paused joins its wait and is not counted again), then resumes its tasks in the same
755
- run with no attempt spent. A scope whose waits are used up stays paused while other tasks finish.
826
+ | Cause | Scope | Move | Without a peer | Hint |
827
+ |---|---|---|---|---|
828
+ | `capacity` | model | lateral | wait | — |
829
+ | `rate_limit` | model | wait | wait | — |
830
+ | `usage_limit` | harness | lateral | wait_if_reset | wait for the reset, or add another harness to this tier's pool |
831
+ | `budget` | harness | lateral | ask | add credits, or check the billing of {harness} |
832
+ | `auth` | harness | lateral | ask | log in to {harness} again |
833
+ | `network` | all | wait | wait | — |
834
+ | `provider_down` | harness | lateral | wait | — |
835
+ | `empty` | model | retry | wait | — |
836
+ | `cancelled` | model | retry | ask | check {harness}'s approval and permission settings |
837
+
838
+ **Scope** is what the pause holds back. `model` pauses that model on that harness
839
+ (`model:<harness>/<model>`); `harness` pauses that harness's account (`harness:<harness>`);
840
+ `all` pauses everything, so running tasks drain and nothing new starts. A model or harness cause
841
+ with no harness, or a model cause with no model, pauses everything. Other tasks keep running. A
842
+ pending task whose next dispatch needs a paused pair waits; unstarted tasks stay `PENDING`, never
843
+ `BLOCKED`.
844
+
845
+ **Move** is what happens first. **lateral** sends the work to another model of the same tier —
846
+ another harness or account when the scope is a harness, another model when the scope is one model —
847
+ and never a stronger tier. **wait** pauses the scope until the cause clears and spends one of that
848
+ scope's waits. **retry** dispatches the same model again at once and spends no wait; the next stop
849
+ of that same cause is treated as lateral.
850
+
851
+ **Without a peer** is the recovery when no model can take the work. **wait** is the pause above.
852
+ **wait_if_reset** waits when the reset is known and inside six hours, and asks otherwise; if this
853
+ task did move sideways, the scope waits rather than asking. **ask** pauses the scope, marks it
854
+ **needs you** with the hint (`{harness}` filled in), and spends no wait. Nothing on that scope is
855
+ retried until a person acts. Raising the infra-retry budget above the value it had when it asked
856
+ starts a wait after all. "Needs you" is that end of the recovery: no peer, and the cause will not
857
+ clear by itself.
858
+
859
+ **Lateral recovery** is on for a new plan. `plan` writes `infra_fallback` as `on`;
860
+ `plan --no-infra-fallback` writes `off`, and a re-plan keeps the file as it is. A plan with no file stays off. `run --infra-fallback` and
861
+ `run --no-infra-fallback` write the file, and `forge control set infra-fallback on|off` applies at
862
+ the next infrastructure stop. It runs at the dwarf stage and at the QA stage, and not on a Fractal
863
+ plan:
864
+
865
+ - a **dwarf-stage** stop takes the next healthy model of the tier the task is running in (the tier
866
+ recorded with its last escalation or exploration, otherwise its difficulty). A pinned implementer
867
+ is not moved. No attempt is spent.
868
+ - a **QA-stage** stop takes a reviewer of the same strength from `qa-routing.json`: the next member
869
+ of the task's difficulty pool, then of `any`, on a pair nobody paused. Never the stopped
870
+ reviewer's model, and never the implementer's. The attempt and the `resume` marker stay, so the
871
+ next entry is QA only. A reviewer no such pool lists, or a plan with no `qa-routing.json`, has
872
+ no peer. A pin waits for the next full retry.
873
+
874
+ Each move is a row of `tasks/<id>/lateral.tsv` (epoch, attempt, role `dwarf` or `qa`, from, to,
875
+ cause) and a `lateral` dataset event. It is not an escalation: it is not written to
876
+ `escalations.tsv`, and the escalation streak carries across the dwarf moves. A pool with no healthy
877
+ member keeps the ordinary pause.
878
+
879
+ Without `--infra-retries`, `run` ends once nothing else can run, prints what to fix and exits `8`;
880
+ verification is skipped, and running the same command again resumes. `run --infra-retries M` waits
881
+ out each scope instead, up to `M` waits **per scope** (a stop in a scope already paused joins its
882
+ wait and is not counted again). A scope whose waits are used up stays paused. An asking scope
883
+ spends none of those waits.
756
884
 
757
885
  Each wait is the provider's retry-after when the log carried one (capped at 6 h), otherwise the
758
- backoff shape for that wait number. `--infra-backoff <shape>` on `run` (kept in the plan as
759
- `infra_backoff`, read at every wait, so `forge control set infra-backoff` applies to the next one)
760
- takes `exp:<base>[,<cap>]` (base doubling, capped at `<cap>`, default the larger of the base and
761
- 30 min), `linear:<start>,<step>[,<cap>]`, or `list:<a>,<b>,...` (a bare `<a>,<b>,...` is a list;
762
- the last value repeats), all in positive seconds. The default is `exp:60`; `FORGE_INFRA_BACKOFF`
763
- changes that base. The wait message names the source, for example `waiting 120s before resuming
764
- (backoff exp:60, wait 2 of 3)`. While anything is paused, `infra.paused` (JSON `{"scopes": [...]}`
765
- with `scope`, `class`, `harness`, `model`, `tasks`, `cycle`, `until`, `exhausted`) says what waits
766
- and until when; `forge control show` reports it as `infra_paused`, and it is removed when nothing
767
- is paused.
768
-
769
- `--infra-fallback` on `run` (kept as `infra_fallback`; `--no-infra-fallback` turns it off, the
770
- default) moves a **dwarf-stage `rate_limit`** stop to the next member of the task's own tier pool,
771
- in pool order, that runs another model on a pair nobody paused. No attempt is spent; the move is
772
- recorded in `escalations.tsv` with source `fallback` and in `tasks.tsv`, and the task is
773
- dispatched again at once. A pinned task, a Fractal plan, a QA-stage stop and a pool with no
774
- healthy member keep the ordinary pause.
886
+ backoff shape for that wait number. `--infra-backoff <shape>` on `run` (kept as `infra_backoff`,
887
+ read at every wait, so `forge control set infra-backoff` applies to the next one) takes
888
+ `exp:<base>[,<cap>]` (base doubling, capped at `<cap>`, default the larger of the base and 30 min),
889
+ `linear:<start>,<step>[,<cap>]`, or `list:<a>,<b>,...` (a bare `<a>,<b>,...` is a list; the last
890
+ value repeats), all in positive seconds. The default is `exp:60`; `FORGE_INFRA_BACKOFF` changes
891
+ that base. The wait message names the source, for example `waiting 120s before resuming (backoff
892
+ exp:60, wait 2 of 3)`. While anything is paused, `infra.paused` (JSON `{"scopes": [...]}` with
893
+ `scope`, `class`, `harness`, `model`, `tasks`, `cycle`, `until`, `exhausted`, `needs_you`, `hint`,
894
+ `reset_at`) says what waits and until when. It is removed when nothing is paused, and again when
895
+ the scheduler exits, so a summary printed after the run reads `infra.txt` alone.
896
+
897
+ The run summary and `forge control show` name the cause, the reset when it is known
898
+ (`resets HH:MM`, with the date when it is not today), and **needs you** with the hint. The
899
+ summary's line is ` <task> <cause> on <harness>/<model> (<stage> stage)`, then the reset and
900
+ `— needs you: <hint>`, and a move is `moved sideways: <task> <role> <from> → <to> (<cause>)`.
901
+ `forge control show` prints the cause on the task's status (`INFRA (cause)`) and, while the
902
+ scheduler is live, on each pause line. forge-ui shows the same facts; the words it uses are in
903
+ [forge-ui](ui.md).
904
+
905
+ A dwarf that exits 0 with an empty final message *and* an empty diff is `class=empty`: it never
906
+ really ran. Under Fractal a dwarf-side stop still ends as Fractal's own `failed`; QA-side stops
907
+ behave as above, and `scripts/forge_fractal/pipeline.py` resets `INFRA` to `PENDING` on resume.
775
908
 
776
909
  A planned pause (a provider maintenance window, a quota reset) is `forge control drain`, not a
777
910
  signal: running tasks finish, nothing new starts, and `forge control resume` continues the same
778
911
  run.
779
912
 
780
- A dwarf that exits 0 with an empty final message *and* an empty diff is the same class
781
- (`class=empty`): it never really ran. Under Fractal a dwarf-side stop still ends as Fractal's own
782
- `failed`; QA-side stops behave as above, and `pipeline.py` resets `INFRA` to `PENDING` on resume.
783
-
784
913
  ## Implementer guards
785
914
 
786
915
  forge records what it observed about how each dwarf behaved, never what the dwarf claimed:
@@ -900,7 +1029,8 @@ The user's own branch and working tree are untouched for the whole run.
900
1029
  | task status `TIMEOUT` | that role exceeded the dispatch timeout and was killed. It has usually left a partial edit in the worktree; `retry` continues from it |
901
1030
  | task status `FAIL` with "produced no changes" | the dwarf ended without editing anything — usually an ambiguous prompt it could not resolve headlessly |
902
1031
  | task status `UNKNOWN` | QA never emitted a verdict line; read `tasks/<id>/qa.last`. `retry` re-runs QA only, on the unchanged work |
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`) |
1032
+ | task status `INFRA`, `run` exits `8` | an infrastructure stop; the cause is in the summary and `tasks/<id>/infra.txt`. No attempt spent. Fix a "needs you" line before re-running; otherwise re-run, or wait with `--infra-retries M`. See [Infrastructure failures](#infrastructure-failures) |
1033
+ | task status `NEEDS_DECISION` | reviews are not converging, the retry policy has no stronger model, or the attempt cap is spent. Read `tasks/<id>/decision.md`. Only a decision resumes it |
904
1034
  | 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 |
905
1035
  | 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 |
906
1036
  | 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` |
@@ -936,10 +1066,18 @@ Configure combined executable checks with `run <plan> --verify '<command>'` (als
936
1066
  `retry`), or a shell command file at `<repo>/.forge/verify`. Commands execute under Bash from
937
1067
  the integration checkout. Forge records `verification.command`, `.log`, `.exit`, `.fingerprint`
938
1068
  and `.status` in the plan directory. Failed checks or source changes fail the run. With no
939
- command, the result is explicitly UNVERIFIED.
1069
+ command, the result is explicitly UNVERIFIED. A `retry` that leaves tasks still to run
1070
+ (PENDING or BLOCKED) skips its verification and says so: the `run` that dispatches them verifies
1071
+ the integration branch at its end, and `integrate` verifies its candidate.
940
1072
 
941
1073
  A failed command whose source fingerprint is unchanged is rerun (`--verify-retries N`, default
942
- `1`, `0` = strict single run). A rerun that passes leaves status `PASS` but writes
1074
+ `1`, `0` = strict single run). When the repository has `.forge/verify-subset` (a test command
1075
+ with `{files}` or `{changed}`) and the log names failing tracked test files (unittest
1076
+ `FAIL:`/`ERROR:` lines, pytest `FAILED path::`, node's test runner `test at file:L:C` or TAP
1077
+ `location:`), those files run alone first (`verification.failing.log`, run kind `failing`): if
1078
+ they fail again the regression is confirmed and the whole command is not rerun. If they pass,
1079
+ or nothing can be named, the whole command reruns as before, so a pass always comes from the
1080
+ whole command. A rerun that passes leaves status `PASS` but writes
943
1081
  `verification.flaky` (both exit codes), keeps the first run in `verification.log` and the second
944
1082
  in `verification.retry.log`, and prints a loud `FLAKY` line in `run`/`retry`/`integrate` output;
945
1083
  a command that changes the tree is never retried.
@@ -31,6 +31,35 @@ Telemetry is independent of project memory. Dispatch and pipeline attempt record
31
31
  their total durations must not be added together. Unsupported usage remains unknown. See
32
32
  [the evaluation](../tests/benchmark-2026-09-07.md) for observed improvements and regressions.
33
33
 
34
+ ## Infrastructure stops
35
+
36
+ A dispatch that fails for a reason other than the work exits 8, and its task stops with
37
+ status `INFRA`. `forge-runtime.py classify` gives the stop a class, and `forge-dispatch.sh`
38
+ writes it to `<role>.infra` as `class=`. `forge_infra.py` holds the one table of what each
39
+ class means for a recovery (scope, first move, what to do without a peer).
40
+
41
+ - `capacity`: the model is at capacity for everyone (overloaded, at capacity, HTTP 529).
42
+ - `rate_limit`: this account is sending too fast (rate limit, too many requests, HTTP 429).
43
+ - `usage_limit`: a spent subscription window, which resets (usage limit, hit your session or weekly limit).
44
+ - `budget`: money that is gone (insufficient credits, credit balance too low, billing, quota exceeded, HTTP 402).
45
+ - `auth`: credentials refused (401, 403, unauthorized, login required).
46
+ - `provider_down`: one provider failing while the connection works (bad gateway, service unavailable, gateway time-out, HTTP 502/503/504).
47
+ - `network`: local connectivity (ECONNRESET and similar codes, getaddrinfo, connection refused or reset, fetch failed, name resolution, certificate).
48
+ - `empty`: exit 0 with no final answer. `cancelled`: the CLI stopped a working model to ask for approval.
49
+
50
+ The order is auth > usage_limit > budget > capacity > rate_limit > provider_down > network, and
51
+ the first class with a matching phrase wins. A usage-limit message that also mentions credits
52
+ is `usage_limit`: the window resets, the money does not.
53
+
54
+ When the message gives a wait, `<role>.infra` also has `retry_after=<seconds>` and
55
+ `reset_at=<epoch>` (now plus the wait). Without a wait there is no `reset_at` line. The
56
+ scheduler copies the file into `infra.txt`, so both lines go with it.
57
+
58
+ Runs recorded before the split say `quota`, which `forge_infra.LEGACY` reads as `usage_limit`.
59
+ The scheduler still acts on the classes it was written for: `infra_info` folds `capacity` into
60
+ `rate_limit`, `usage_limit` and `budget` into `quota`, and `provider_down` into `network`, until
61
+ it reads the table.
62
+
34
63
  ## Optional Fractal adapter decision
35
64
 
36
65
  Fractal adds a Python adapter around the existing shell pipeline instead of replacing
package/references/ui.md CHANGED
@@ -73,6 +73,16 @@ run goes on, with the same exit code.
73
73
  - It refreshes every two seconds while something runs (five otherwise) while the tab is
74
74
  visible, so a run can be watched as it goes. A run can also be replayed from its record.
75
75
 
76
+ An infrastructure stop shows as `INFRA · <label>`: `at capacity`, `rate limited`, `usage limit`,
77
+ `out of budget`, `login needed`, `network down`, `provider down`, `empty answer` or `cancelled`.
78
+ A cause the page does not know, such as an older run's `quota`, is shown as it was written.
79
+ Opening the task lists that label, the stage, the harness and model, and `resets …` when the
80
+ limit's reset is known. A pause that needs the user says "needs you" with the fix hint, and a
81
+ sideways move is a "moved sideways" line under Models. A task at `NEEDS_DECISION` is waiting, not
82
+ failed: its inspector gives the reasons, the attempts against the cap, the review ledger, and the
83
+ text of `tasks/<id>/decision.md`. forge-ui shows those commands and does not run them, and it does
84
+ not offer Retry now. A run whose unfinished tasks are all waiting is `WAITING`.
85
+
76
86
  The 3D view loads three.js from cdn.jsdelivr.net when first used; offline, the page shows the
77
87
  same run in 2D. The full page description is in [ui/README.md](../ui/README.md).
78
88