@giamme/forge 0.15.0 → 0.16.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 (63) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/VERSION +1 -1
  3. package/docs/artifacts.md +1 -1
  4. package/docs/commands.md +14 -3
  5. package/docs/forge-ui.md +14 -0
  6. package/docs/memory.md +22 -0
  7. package/docs/reviews.md +7 -0
  8. package/forge +11 -0
  9. package/package.json +1 -1
  10. package/references/dataset.md +5 -2
  11. package/references/decompose.md +51 -5
  12. package/references/harnesses.md +4 -1
  13. package/references/solo.md +5 -1
  14. package/references/ui.md +10 -1
  15. package/scripts/forge-artifact.sh +53 -0
  16. package/scripts/forge-contract.py +55 -8
  17. package/scripts/forge-control.py +0 -2
  18. package/scripts/forge-dispatch.sh +28 -12
  19. package/scripts/forge-fail-first.py +3 -1
  20. package/scripts/forge-guard.py +247 -8
  21. package/scripts/forge-issues.py +12 -0
  22. package/scripts/forge-lib-adopt.sh +260 -0
  23. package/scripts/forge-lib-attribute.sh +10 -2
  24. package/scripts/forge-lib-plans.sh +16 -4
  25. package/scripts/forge-lib-review.sh +8 -2
  26. package/scripts/forge-lib-task.sh +19 -5
  27. package/scripts/forge-memory.sh +41 -4
  28. package/scripts/forge-metrics.sh +7 -0
  29. package/scripts/forge-parallel.sh +96 -13
  30. package/scripts/forge-route.py +16 -2
  31. package/scripts/forge-runs-rm.py +23 -7
  32. package/scripts/forge-runtime.py +25 -2
  33. package/scripts/forge-schedule.py +5 -2
  34. package/scripts/forge-shadow.py +2 -0
  35. package/scripts/forge-solo.sh +6 -0
  36. package/scripts/forge_dataset/cli.py +16 -0
  37. package/scripts/forge_dataset/export.py +1 -0
  38. package/scripts/forge_dataset/harvest.py +11 -0
  39. package/scripts/forge_dataset/history.py +126 -0
  40. package/scripts/forge_dataset/worktrees.py +95 -0
  41. package/scripts/forge_memory_list.py +153 -0
  42. package/scripts/forge_worktrees.py +88 -0
  43. package/ui/README.md +31 -0
  44. package/ui/docs/api.md +81 -4
  45. package/ui/forge_ui/__init__.py +14 -1
  46. package/ui/forge_ui/__main__.py +1 -1
  47. package/ui/forge_ui/control.py +77 -0
  48. package/ui/forge_ui/findings.py +7 -0
  49. package/ui/forge_ui/projects.py +571 -0
  50. package/ui/forge_ui/reader.py +27 -7
  51. package/ui/forge_ui/static/app.js +99 -21
  52. package/ui/forge_ui/static/cloudui.js +6 -2
  53. package/ui/forge_ui/static/convo.js +1 -1
  54. package/ui/forge_ui/static/diffview.js +2 -2
  55. package/ui/forge_ui/static/files.js +1 -1
  56. package/ui/forge_ui/static/index.html +5 -1
  57. package/ui/forge_ui/static/panel.js +28 -2
  58. package/ui/forge_ui/static/projectsview.js +372 -0
  59. package/ui/forge_ui/static/settings.js +136 -4
  60. package/ui/forge_ui/static/style.css +93 -3
  61. package/ui/forge_ui/static/uikit.js +94 -1
  62. package/ui/forge_ui/static/worktreesview.js +250 -0
  63. package/ui/forge_ui/worktrees.py +570 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and versions follow the format `{major}.{minor}[.{patch}]` ([...] parts appear only when non-zero).
7
7
 
8
+ ## [0.16] - 2026-11-06
9
+
10
+ forge-ui gets a Worktrees screen and a Projects screen with each repository's runs, findings and memories, and a live refresh no longer cancels what you were doing. A stopped run can be steered by hand: adopt brings in a commit made outside forge, and retry --no-dispatch resumes several tasks side by side. Reviewers get the attempt's dependencies and say whether their tests ran, and a timeout now stops the test servers a harness started.
11
+
12
+ ### Added
13
+
14
+ - Each reviewer now says whether its tests ran, with a `FORGE_TESTS: RAN`, `NOT NEEDED` or `COULD NOT RUN` line before its verdict. It never changes the verdict. The run summary lists reviews whose tests could not run, and forge-ui and the dataset record the answer (#117).
15
+ - forge-ui's Settings page now explains each decision gate: what it does, when it asks, what it sends and what `on` changes. **How to set this up** opens a dialog with the steps from adding a provider to turning a gate on, and how to stop sending.
16
+ - `forge-parallel.sh adopt` brings a commit made outside forge into a run, where `review` used to refuse. It cherry-picks a commit or range, or with `--head` takes what is already on the integration branch, and the run's QA reviews just that range against your reason, with no implementer. A failed review puts the branch back unless `--approved` keeps it, whose findings then reach `forge issues` and the run's report. A review that concludes nothing (a crash, a timeout, a stop) always puts it back. Every adoption is recorded and shown in forge-ui, and `attribute` can name one as the step that broke verification (#79).
17
+ - `forge-parallel.sh retry --no-dispatch` resumes several stopped tasks side by side: it records the decision, carries the findings forward and starts nothing, and one `run` then dispatches them all under `--max-parallel`. `--decide` and `--dwarf` now combine, so "this model, two more attempts" is one decision, on `retry` and on `forge control retry`. The run summary shows how (#118).
18
+ - forge-ui shows forge's version next to the logo, with the build id in its tooltip, and `/api/health` now reports that version (#113).
19
+ - forge-ui has a Worktrees screen (`#/worktrees`, linked from the header and from each run's page). It lists every worktree forge created, in any repository it knows, with its run, task, branch, last commit, size and status: in use, uncommitted changes, locked, needed by the run, failed task, finished, missing on disk, not forge's, unknown to git, or removed. It gives the command that removes each one safely, to copy, never with `--force`. The page runs nothing, so it works with `--read-only`. forge now records each worktree it adds or removes in the dataset (`worktree_created`, `worktree_removed`, read with `forge dataset worktrees`), so removed ones stay listed with their dates. Worktrees from older runs are derived from run dirs and the dataset (#125).
20
+ - forge-ui has a Projects screen (`#/projects`), linked from the header, a run's repository name and each map district. It has one page per repository with three tabs. Runs lists its runs, with the checkout and branch as a column. Findings lists every finding of every review of every run, with its run, task, attempt, reviewer and status, and opens the diff at it. A finding a later review got past is `superseded`, never `fixed`, and repeats across rounds are one row with a count. Memories shows what `memory.md` gives each role and every learning in the ledger with its state, from each checkout. The dataset fills in runs and checkouts that are gone, and those rows say so (#126).
21
+ - `forge memory learnings <repo> --json` lists every learning in a repository's ledger with what forge does with it: in memory, waiting for a second run, stale, trimmed by the cap, or curated out. The states come from forge's own memory rebuild, run without changing the repository. `forge memory` also takes `show`, `prune`, `spend` and `inject` (#126).
22
+
23
+ ### Changed
24
+
25
+ - `forge runs rm --worktrees` also removes a clean scratch worktree forge left in the run's folder: an `integrate` candidate (`_candidate-<n>`) or a culprit search's `_attribute`. It used to count them as foreign and keep them. It uses the same ownership rule as forge-ui's Worktrees screen (#125).
26
+ - Review snapshots now also get `bower_components`, `.bundle`, `Pods`, Mix's `deps` and `_build`, `.dart_tool`, `elm-stuff` and SwiftPM's `.build` linked from the checkout under review, beside `node_modules`, `.venv`, `venv` and `vendor`, so reviewers can run dependency-backed tests in more ecosystems. The fail-first check links the same directories (#127).
27
+
28
+ ### Fixed
29
+
30
+ - A codex that never reaches the network ("workspace routing discovery failed", or a reconnect loop that runs out) is now an infrastructure stop. A task pauses as `INFRA` and `--infra-retries` waits it out, where it used to end as `ERROR`, and a whole-run review exits 8 instead of reporting a failed review (#114).
31
+ - Reviewers can run tests with the attempt's own dependencies: forge links `node_modules`, `.venv`, `venv` and `vendor` from the checkout under review into its review snapshot, at the root and in workspace packages, and the prompt says what is there and tells the reviewer to report rather than search or install (#117).
32
+ - A `retry` with no decision behind it no longer prints a "No such file" error about `decided.left`.
33
+ - forge-ui: a live refresh no longer cancels a click, clears a text selection, replaces a focused `<select>` or closes a disclosure you opened. A redraw waits until you finish and then shows the latest data, and a long wait tells you newer data is there (#115).
34
+ - A retry no longer prints a missing-file error when the optional qa.gate file is absent.
35
+ - A dispatch that times out or exits now also stops the processes its harness started in sessions or process groups of their own, such as a test runner and the web servers it launched, before verification or a retry can overlap with them in the same worktree. forge samples the harness's descendants every 2 seconds and lists what it stopped in `<role>.orphans`. A standalone `retry` that gets a TERM or Ctrl-C now stops what it dispatched before it exits with 143, instead of leaving the implementer running (#129).
36
+
8
37
  ## [0.15] - 2026-11-04
9
38
 
10
39
  Profiles keep your model routing and run policies under a name, and forge-parallel.sh auto takes a goal to the approval table in one blocking command, planning only when it pays and collapsing plans that would run sequentially. Fast service tiers can be asked per role.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15
1
+ 0.16
package/docs/artifacts.md CHANGED
@@ -17,7 +17,7 @@ as if the dwarf had written it.
17
17
  <role>.clock when the log grew: one `<epoch> <bytes>` line per second it grew (forge-ui times codex and grok events by it; FORGE_LOG_CLOCK=off)
18
18
  <role>.last the final message — read this first
19
19
  <role>.infra only after an infrastructure failure: class, retry_after, detail, harness, model
20
- <role>.orphans only when processes were left running after the harness exited
20
+ <role>.orphans only when processes were left running after the harness exited or timed out
21
21
  <role>.settled only when claude/openclaude stayed up on a background task after its final result and forge ended it: ended_by=grace|timeout, backend_exit=; the result stands (not a timeout)
22
22
  <role>.session session id reported by claude, openclaude or codex; absent when the dispatch published none
23
23
  <role>.continue only when the dispatch was asked to continue a session (a reviewer's, or an implementer's): requested=, mode=continued|failed, reason=
package/docs/commands.md CHANGED
@@ -23,6 +23,7 @@ harness (`/forge`); this command installs forge and drives its optional tools.
23
23
  | `forge runs rm RUN_DIR [--dry-run] [--yes] [--no-archive] [--worktrees] [--branches] [--json]` | delete a run directory but keep what it taught the dataset; see [below](#forge-runs-rm) |
24
24
  | `forge runs rerun RUN_DIR --dwarf SPEC [--qa SPEC] [--to DIR] [--max-parallel N] [--dry-run] [--run --yes]` | set up the same plan again with another implementer, from the same starting commit; spends nothing unless `--run --yes`; never merges. See [below](#forge-runs-rerun-and-compare) |
25
25
  | `forge runs compare RUN_A RUN_B [--json] [--no-record]` | two runs of one plan, side by side, per task; records the pair in the dataset |
26
+ | `forge memory show\|learnings\|prune\|spend REPO …` | a repository's project memory; `learnings REPO --json` lists every learning in its ledger with what forge does with it (`in_memory`, `waiting` for a second run, `stale`, `capped`, `muted`), from forge-memory.sh's own rebuild, without changing the repository. See [project memory](memory.md) |
26
27
  | `forge issues RUN [--apply] …` | file the review findings a run left open as GitHub issues; see [below](#forge-issues) |
27
28
  | `forge pr [RUN_DIR \| --repo DIR] [--texts] [--paths] [--out FILE] [--create [--base B] [--head B]]` | a draft pull-request description for a finished run, on stdout; `--create` opens it as a draft PR with `gh`; see [below](#forge-pr) |
28
29
  | `forge ui open\|status\|stop` | forge-ui, the run viewer; see [the command group](forge-ui.md#forge-ui-command-group) |
@@ -80,7 +81,9 @@ solo run), so a run started meanwhile fails to start instead of racing the delet
80
81
 
81
82
  What counts as the run's is decided from the run id, not read from the run directory: a worktree
82
83
  under `<repo>/../.forge-worktrees/<run id>/` on `forge/<run id>/<task>` or
83
- `forge/<run id>-integration`. Any other worktree there is `foreign`, one with uncommitted changes
84
+ `forge/<run id>-integration`, or a detached scratch worktree forge left there (`_candidate-<n>` from
85
+ `integrate`, `_attribute[-<n>]` from `attribute`). forge-ui's Worktrees screen uses the same rule
86
+ (`scripts/forge_worktrees.py`). Any other worktree there is `foreign`, one with uncommitted changes
84
87
  is `dirty`; neither is touched, and a dirty one keeps the run directory only when `--worktrees`
85
88
  was asked. Branches are reported
86
89
  `merged` or `UNMERGED`, so you see what deleting them would lose. `--dry-run` changes nothing and
@@ -488,7 +491,12 @@ quietly swapping backends hides the fact that the one you picked is broken.
488
491
  **Process hygiene.** Unless `FORGE_ORPHAN_GUARD=off` (or the run is a Fractal one), the harness
489
492
  is started in its own session, and after it exits any process still alive in that session is
490
493
  listed in `<role>.orphans` and stopped, so a backgrounded measurement cannot outlive the
491
- dispatch. The timeout watchdog and the exit trap signal the whole session too.
494
+ dispatch. The timeout watchdog and the exit trap signal the whole session too. A tool that leaves
495
+ that session (a test runner's web server started in a session of its own) is still the harness's
496
+ descendant: forge samples the harness's descendants every 2 s while it runs, and stops those
497
+ still alive, with their children, after a timeout or exit as well. A process that double-forks
498
+ away within those 2 s is not seen. A standalone `retry` that gets a TERM or Ctrl-C stops
499
+ everything it dispatched the same way before it exits (`143`).
492
500
 
493
501
  **Log clock.** Beside the log, `<role>.clock` records when it grew (one `<epoch> <bytes>` line for
494
502
  each second it did), so forge-ui can time the commands of a harness that logs no times (codex,
@@ -621,6 +629,7 @@ forge-parallel.sh retry <plan-dir> <task-id> [--dwarf <spec>] [--answer <tex
621
629
  [--verify <cmd> | --verify-lane 'name[opts]=cmd' ...] [--verify-parallel N]
622
630
  [--escalate-after N] [--escalate-effort | --no-escalate-effort]
623
631
  forge-parallel.sh accept <plan-dir> <task-id> --reason "<why>" --approved
632
+ forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason "<why>" [--qa <spec>] [--yolo-qa] [--approved]
624
633
  forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold P0|P1|P2|P3|none|default]
625
634
  forge-parallel.sh attribute <plan-dir> [--force]
626
635
  forge-parallel.sh integrate <plan-dir> --approved [--final-review <qa-spec>] [--verify-retries N]
@@ -925,7 +934,9 @@ model, or the task has spent its attempt cap (`plan --max-attempts N`, default 8
925
934
  the `retry` and `accept` commands are in `tasks/<id>/decision.md`. The run summary lists them under
926
935
  `waiting for your decision:`. Neither a later `run`, `--retry-failed`, a retry budget nor a pin
927
936
  resumes that same task. Only `retry <plan> <id> --decide retry=N` or `--decide threshold=Pn`, or
928
- `--dwarf <spec>`, each with `--reason "…" --approved`, or `accept`, does. Replacing it is a hand
937
+ `--dwarf <spec>`, or `--decide` and `--dwarf` together, each with `--reason "…" --approved`, or
938
+ `accept`, does. To resume several at once, add `--no-dispatch` to each `retry`, which records the
939
+ decision and starts nothing, then `run` the plan. Replacing it is a hand
929
940
  edit of `tasks.tsv` before the next `run`, as the summary says (`forge control add` queues a new
930
941
  row but does not replace the stopped one). A live scheduler takes the same flags as `forge control retry`. A run that ends with such a
931
942
  task still in `tasks.tsv` and unmerged exits `5`. See
package/docs/forge-ui.md CHANGED
@@ -123,6 +123,20 @@ indistinguishable from the same command typed in a terminal, except that `contro
123
123
  Each is `forge control`; see [decomposed runs](decomposed-runs.md#changing-a-run-while-it-works).
124
124
  A control that cannot apply (a budget with no live scheduler, a merged task) is disabled and
125
125
  says why.
126
+ - **Projects (`#/projects`):** one page per repository with its runs, every finding forge's reviews
127
+ wrote about it (each attempt, final reviews, shadow reviews behind a toggle), and every memory forge
128
+ keeps for it, whichever run or checkout they came from. A finding a later review got past is
129
+ `superseded`, never `fixed`; repeats across rounds are one row with a count. The Memories tab shows
130
+ what `memory.md` gives each role and each learning's state, as `forge memory learnings` reports it.
131
+ Runs and checkouts that are gone are read from the dataset, and those rows say so. Reachable from the
132
+ header, a run's repository name and each map district.
133
+ - **Worktrees (`#/worktrees`):** every worktree forge created, in any repository it knows: its
134
+ run, task, branch, last commit, size and status (in use, uncommitted changes, locked, needed by
135
+ the run, failed task, finished, missing on disk, not forge's, unknown to git, removed), and the
136
+ command that removes it safely, to copy. The commands never use `--force` and the page runs
137
+ none of them. Removed worktrees are listed from the dataset (`worktree_created` and
138
+ `worktree_removed` events); worktrees from before forge recorded them are derived from run dirs,
139
+ without dates. With `FORGE_DATASET=off` the screen lists only what git and the run dirs say.
126
140
  - **Open findings:** the review findings a run left open (tolerated by `--qa-threshold`,
127
141
  PLAUSIBLE, or left by the whole-run review), for this run or every run of its repository.
128
142
  Findings of an outdated review carry an "outdated review" marker, findings a person
package/docs/memory.md CHANGED
@@ -113,6 +113,7 @@ forge-memory.sh record <repo> --last <file> --role <r> [--run-id X] [--task T]
113
113
  forge-memory.sh show <repo>
114
114
  forge-memory.sh prune <repo> # re-apply staleness and the cap now
115
115
  forge-memory.sh spend <repo> [--run <run-id>] # what forge has cost this repo
116
+ forge-memory.sh learnings <repo> [--json] # every ledger learning and its state, as JSON (forge memory learnings)
116
117
  ```
117
118
 
118
119
  `record` appends to the ledger and then rebuilds `memory.md` from the whole ledger — the
@@ -128,6 +129,27 @@ bash scripts/forge-memory.sh inject ~/dev/api dwarf
128
129
  rm -rf ~/dev/api/.forge
129
130
  ```
130
131
 
132
+ ## Every learning and its state
133
+
134
+ `forge memory learnings <repo> --json` lists each learning in the ledger once (grouped as the rebuild groups
135
+ them: by category and normalised text) with the number of distinct runs that emitted it, its latest wording,
136
+ its rows, and what forge does with it now:
137
+
138
+ | State | Why |
139
+ |---|---|
140
+ | `in_memory` | the rebuilt `memory.md` has it |
141
+ | `waiting` | a finding seen in one run only: it needs a second run to be promoted |
142
+ | `stale` | its `[anchor]` path no longer exists |
143
+ | `capped` | trimmed by the memory cap (`FORGE_MEMORY_MAX_LINES`, `FORGE_MEMORY_MAX_BYTES`) |
144
+ | `muted` | every row of it was marked not injectable (Jev's curation) |
145
+
146
+ The states come from forge-memory.sh's own rebuild, run into a scratch directory, so they cannot differ
147
+ from what `record` writes; the repository is only read. The answer also has the current `memory.md` by
148
+ section, with the roles each section reaches, and `rebuilt_differs` when that file is not what a rebuild
149
+ makes now (an older forge wrote it, or a `prune` asked Jev to drop facts). forge-ui's Projects screen
150
+ shows it on each repository's *Memories* tab, merged across the checkouts its runs started in and, from
151
+ the dataset, the learnings of checkouts that are gone.
152
+
131
153
  ## Spend
132
154
 
133
155
  The ledger already holds a row per dispatch and is never injected into a prompt, so
package/docs/reviews.md CHANGED
@@ -28,6 +28,13 @@ in the reply is never a verdict. A missing verdict is `UNKNOWN` and is treated e
28
28
  failure — excluded from integration and flagged. Merging a diff whose reviewer never reached
29
29
  a conclusion would defeat the point of reviewing it, so the ambiguous case fails safe.
30
30
 
31
+ Before the verdict, a reviewer says whether its tests ran: `FORGE_TESTS: RAN`,
32
+ `FORGE_TESTS: NOT NEEDED — why` or `FORGE_TESTS: COULD NOT RUN — why`. This never changes the
33
+ verdict. `COULD NOT RUN` prints a note, and forge-ui and the dataset record all three, so a review
34
+ that judged the diff by reading alone can be told apart. Markup and any separator are accepted,
35
+ because nothing gates on this line, and a line that says something else is recorded as `unclear`.
36
+ An older reply has no such line.
37
+
31
38
  A failing task is excluded and **its branch and worktree are preserved**; the rest of the run
32
39
  proceeds. forge never loops a dwarf against its reviewer on its own: a retry happens when you
33
40
  type `retry`, or when you opt in for a run with `--retry-failed N` ([below](#retrying-inside-a-run---retry-failed-n)).
package/forge CHANGED
@@ -23,6 +23,7 @@ usage() {
23
23
  ' jev the old decision-model commands, replaced by decide (kept for one release)' \
24
24
  ' dataset every run'"'"'s inputs and outcomes: status, dump, import, export, outcomes, ...' \
25
25
  ' issues file the review findings a run left open as GitHub issues (plain gh)' \
26
+ ' memory a repository'"'"'s project memory: show, learnings --json (each learning and its state), prune' \
26
27
  ' pr a draft pull-request description for a finished run (--create opens it with gh)' \
27
28
  ' ui forge-ui, the run viewer: open [DIR], status, stop' \
28
29
  ' runs this repo'"'"'s recent runs in the terminal: state, verdicts and run dirs; rerun a plan with another model, compare' \
@@ -98,6 +99,16 @@ case "${1:-}" in
98
99
  shift
99
100
  exec python3 "$ROOT/scripts/forge-issues.py" "$@"
100
101
  ;;
102
+ memory)
103
+ shift
104
+ # only the commands its help lists: note and record are what a run writes into the ledger, not a person
105
+ case "${1:-}" in
106
+ show|learnings|prune|spend|inject|-h|--help|help) ;;
107
+ '') /bin/bash "$ROOT/scripts/forge-memory.sh" --help >&2; exit 2 ;;
108
+ *) printf 'forge memory: unknown command: %s (show, learnings, prune, spend or inject)\n' "$1" >&2; exit 2 ;;
109
+ esac
110
+ exec /bin/bash "$ROOT/scripts/forge-memory.sh" "$@"
111
+ ;;
101
112
  pr)
102
113
  shift
103
114
  exec python3 "$ROOT/scripts/forge-pr.py" "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giamme/forge",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Multi-model coding with a reviewer that reads the code: plan, build in parallel worktrees, review every real diff, merge only what passes.",
5
5
  "keywords": ["claude-code", "codex", "opencode", "agent-skill", "code-review", "multi-model"],
6
6
  "license": "MIT",
@@ -30,16 +30,17 @@ time order: an attempt that PASSed, then a merge that CONFLICTed, then a human `
30
30
  | kind | one per | what it holds |
31
31
  |---|---|---|
32
32
  | `start` | execution | a receipt written by `begin()`. A start with no matching end is an execution that was killed or is still running |
33
- | `dispatch` | model call | role, alias, harness, **resolved** model, effort after clamping, timeout and its source, delivery (custom or native review), phase timings, exit, timeout, infra class, tokens, parsed verdict and findings, `FORGE_LEARNING` lines, `session_id`, `session_continue`, `service_tier`, `speed`, `speed_reason`. Blobs: the delivered prompt and the final message |
33
+ | `dispatch` | model call | role, alias, harness, **resolved** model, effort after clamping, timeout and its source, delivery (custom or native review), phase timings, exit, timeout, infra class, tokens, parsed verdict and findings, `tests` (a reviewer's `FORGE_TESTS` line: `status`, `reason`; null when it has none), `FORGE_LEARNING` lines, `session_id`, `session_continue`, `service_tier`, `speed`, `speed_reason`. Blobs: the delivered prompt and the final message |
34
34
  | `attempt` | task attempt or solo run | status, attempt number (with refund and resume flags), trigger (`initial`, `auto`, `human`), dwarf and qa spec, declared vs changed files, numstat, drift, guard notes, gate line (`thr<TAB>decision<TAB>worst<TAB>n_confirmed<TAB>n_unlabelled<TAB>n_below`; a solo attempt has it too, with the `known_issues` blob; null when the run wrote none), patch key, the files this execution wrote and the ones it only carried, `sent_back` (`prereview`, `bounce` or `message`: the send-back this attempt ended with, which leaves its status `FAIL`; null otherwise) and `retry_source` (where the retry findings it was given came from: `review`, `prereview`, `bounce`, `message` or `answer`; null on a first attempt). Blobs: the diff, retry findings, memory slices, capsule, Jev task files |
35
35
  | `verification` / `verify_run` | verify, and each command execution | command and its source (flag, `.forge/verify`, Jev), status, flaky. One `verify_run` per execution, each with its own log |
36
36
  | `plan` | `plan` | goal, original request, decompose level, exploratory routing decisions (`tasks[id].route`, with their odds), author (`planner` when a planner was dispatched into the plan dir, else `orchestrator`), `orchestrator` (the first line of the plan's `orchestrator` file: `auto` for a plan started by `forge-parallel.sh auto`; absent for a plan built by hand), per-task declared vs executed difficulty and who set it, pools, waves, Jev's plan-time judgments (stores from before 2026-10-27 also hold routing and coupling), options (`qa_threshold`, the effective blocking threshold, and `qa_threshold_source`, `set` when the plan's file held a valid value and `default` otherwise; plus `reviewer_session` when that file is present), `plan_gates` (the parsed `plan-gates.json`: what the plan-time gates did, with the `sent_back` history and `pending`; absent when the plan has no such file), `shape`, `widest` and `wave_count` from `plan-shape.json` (`shape` is `one`, `chain` or `branches`; `wave_count` is how many waves; `widest` is the largest wave). `waves` stays the task-to-wave map from `waves.tsv` on every plan. `collapsed` (true when `collapsed.json` exists) and `collapsed_from` (the task ids it merged), `plan_gate` (the parsed `plan-gate.json`: the planner's one-task-or-plan decision). `shape`, `widest`, `wave_count`, `collapsed`, `collapsed_from` and `plan_gate` are absent when their file is missing. Blobs: both task tables, prompts, approaches, excerpts of the declared files at plan time, the file inventory, `memory.md` |
37
37
  | `run_end` | `run` | results per task, the accepted integration commit, `memory.md` |
38
38
  | `invocation` | user-facing `forge-parallel.sh` subcommand | argv, exit, duration, plus final review, accept, integrate and split/combine payloads |
39
- | `event` | point event | `merge` (MERGED, CONFLICT with the files, INVALIDATED and why), `integrate_advanced`, `integrate_conflict`, `combine_conflict`, `sched_terminal`, `memory_record`, `memory_prune`, `attribution` (below) |
39
+ | `event` | point event | `merge` (MERGED, CONFLICT with the files, INVALIDATED and why), `adopt` (a range made outside forge: base, tip, verdict, approved, adopted, spec, reason, authors; adopted 0 when the review refused it), `integrate_advanced`, `integrate_conflict`, `combine_conflict`, `sched_terminal`, `memory_record`, `memory_prune`, `attribution` (below) |
40
40
  | `event` `escalation` | retry that changes the model | the model a retry escalated from and to, `after_attempt`, and `source` (`policy`, `retry` for an explicit `--dwarf`, or `pin`), recorded at the rewrite, before the retried attempt begins. Runs from before lateral moves had their own record may also hold `source` `fallback`: those rows are lateral moves |
41
41
  | `event` `lateral` | dwarf-stage infrastructure stop moved the task to another model of its tier | `role` (`dwarf`), the model it moved `from` and `to`, `cause` (the stop's class, `-` when none was given) and `attempt` (the attempts spent when it moved). Recorded in `tasks/<id>/lateral.tsv`, not as an `escalation`; a streak of failures carries across it |
42
42
  | `event` `control` | `forge control` change | a human's live change: `at`, `actor` (`cli`/`ui`), `action` (`set`, `pin`, `unpin`), `key`, `value`, `previous`; task events carry the task id. Also read back from `control.log` by `import` |
43
+ | `event` `worktree_created` / `worktree_removed` | forge adds or removes a worktree | `path`, `branch` (`-` when detached), `kind` (`task`, `integration`, `candidate` for integrate's scratch worktree, `attribute` for the culprit search's), `repo_path`, and the task for a task worktree; `forge runs rm` adds `by`. Written at task and `_integration` creation, the merged-task cleanup at the end of `run`, integrate's candidate, every prefix of `attribute`, `combine` and `split` (a moved worktree is removed from the old run and created in the new one), and `forge runs rm --worktrees`. A worktree removed outside forge has no `worktree_removed`. forge-ui's Worktrees screen reads them through `forge dataset worktrees` |
43
44
  | `event` `run_delete_started` / `run_deleted` | `forge runs rm` | written strictly around a run's deletion: `path`, `run_id`, `archive`, and for `run_deleted` the bytes freed |
44
45
  | `event` `shadow_review` | shadow review | how an opt-in second review ended (`done`, `invalid`, `overtime`, `orphaned`, ...), with the reviewed commit and both specs. Its dispatch is recorded with role `qa_shadow` |
45
46
  | `jev` | Jev request | site, answers, usage, latency, mode. Blob: the **full request** (state and questions). Its original sha is `jev.jsonl`'s `key`. A per-attempt gate's request state carries `run`, `task` and `attempt` (`dwarf-message`, `retry-addressed`), so its key differs per attempt and per run; `attribution` carries `run` only |
@@ -163,6 +164,8 @@ forge still running keeps writing.
163
164
  ./forge dataset routing [--repo PATH] [--since DAYS] [--json] # pass rate and runtime per tier and model
164
165
  ./forge dataset reviewers [--horizon-days 14] [--repo PATH] [--json] # how each reviewer's PASSed work held up
165
166
  ./forge dataset forecast <plan> [--repo PATH] [--json] # likely cost and first-try PASS rate per task
167
+ ./forge dataset worktrees [--json] # the worktrees forge created and removed (forge-ui's Worktrees screen)
168
+ ./forge dataset history [--json] # every review's findings and every learning, by run (forge-ui's Projects screen)
166
169
  ```
167
170
 
168
171
  `status` runs a different completeness check for each mode, because each mode
@@ -787,16 +787,27 @@ changes it; `--confirm` applies only to that key. A `NEEDS_INPUT` task at the ca
787
787
  raise the plan's cap before the answer can start an attempt.
788
788
 
789
789
  `tasks/<id>/decision.md` gives the reasons and the choices. Nothing else resumes the task: not a
790
- re-run, not `--retry-failed`, not a retry budget and not a pin. A plain `retry` exits 2. The
791
- choices:
790
+ re-run, not `--retry-failed`, not a retry budget and not a pin. A plain `retry` exits 2.
791
+
792
+ `retry` holds the plan lock until its attempts end, so to resume several tasks side by side add
793
+ `--no-dispatch` to each. It records the decision, carries the findings forward and starts nothing;
794
+ the task is then `PENDING`, and one `forge-parallel.sh run <plan>` dispatches them all under
795
+ `--max-parallel`, with dependents starting as their dependencies merge. It works on any `retry`,
796
+ not only a decision, but takes no `--retry-failed` or `--infra-retries`: give those to the `run`. A
797
+ second `--decide` on a prepared task is refused; a `--dwarf` changes its model and keeps its count.
798
+
799
+ The choices:
792
800
 
793
801
  - `forge-parallel.sh retry <plan> <id> --decide retry=N --reason "…" --approved` gives N more
794
802
  attempts, N from 1 to 20. At the cap this raises the cap by N, and it is the only choice that
795
803
  runs the task again while the attempts already spent sit on the cap.
796
804
  - `forge-parallel.sh retry <plan> <id> --decide threshold=Pn --reason "…" --approved` sets this
797
805
  task's blocking threshold (`P0`, `P1`, `P2` or `P3`) and then retries once.
798
- - `forge-parallel.sh retry <plan> <id> --dwarf <spec> --reason "…" --approved` names a model. Not
799
- together with `--decide`.
806
+ - `forge-parallel.sh retry <plan> <id> --dwarf <spec> --reason "…" --approved` names a model for
807
+ one attempt. Add `--decide retry=N` for up to N attempts: the retry policy keeps the task on that
808
+ model until they are used, and they end early the way any retry does, on a pass or when the reviews
809
+ stop converging. Or add `--decide threshold=Pn` to set the threshold too. `decisions.tsv` records it
810
+ as one row, such as `retry=2 dwarf=sol:high`.
800
811
  - `forge-parallel.sh accept <plan> <id> --reason "…" --approved` merges it; the findings become
801
812
  known issues.
802
813
  - Split it by hand: `tasks/<id>/decision.md` and the run summary say to replace its row in
@@ -1015,7 +1026,7 @@ run.
1015
1026
 
1016
1027
  forge records what it observed about how each dwarf behaved, never what the dwarf claimed:
1017
1028
  HEAD or the checked-out ref moved (**self-commit / branch switch**), processes left alive in the
1018
- harness's session after it exited (**orphans**, listed in `dwarf.orphans` and stopped; disabled by
1029
+ harness's session after it exited, or started by it in a session of their own (**orphans**, listed in `dwarf.orphans` and stopped; disabled by
1019
1030
  `FORGE_ORPHAN_GUARD=off` or under Fractal), and a final message that **promises later work**.
1020
1031
  They are written to `tasks/<id>/guard.txt`, added to the QA prompt as "Implementer guard notes" and
1021
1032
  shown in the run summary. They never change a status. The dwarf prompt itself tells the
@@ -1027,6 +1038,24 @@ its last message, and to say plainly what it could not run.
1027
1038
  Four subcommands act on plans after tasks have run. Full usage and refusal conditions are in the
1028
1039
  [README](../docs/reviews.md#accepting-a-task-despite-its-reviewer); the mechanics:
1029
1040
 
1041
+ - **`adopt <plan> <commit|a..b> --reason …`**, or **`adopt <plan> --head --reason …`** (each with
1042
+ `--qa <spec>`, `--yolo-qa`, `--approved`), brings a commit
1043
+ made outside forge into the run instead of leaving `review` refusing. The first cherry-picks onto the
1044
+ integration branch. `--head` takes what is already on it past `accepted.integration`, and it is what
1045
+ `review`'s refusal names. The run's QA (`--qa`, then `final_qa`, then the first task's) reviews that
1046
+ range alone against the reason, and no implementer runs. PASS, or a verdict the threshold accepts, moves
1047
+ `accepted.integration`, adds a row to `adoptions.tsv` (epoch, base, tip, verdict, approved, spec, review,
1048
+ reason) and to `control.log`, writes an `adopt` dataset event, and verifies as a retry does. A FAIL or
1049
+ UNKNOWN puts the branch back and exits 5, unless `--approved` keeps it, which writes the findings to the
1050
+ adoption's `known_issues.md` as `accept` does; `forge issues` and the run's report read that file (as
1051
+ accepted findings, the reason with them), and the sweep does not. A review that concluded nothing always puts it back: a crash or timeout exits 5, an
1052
+ infrastructure stop exits 8, a signal exits 130 or 143. If the worktree changed during the review it is
1053
+ left as it is, with the commands to go on. A range that lived only on the branch stays at
1054
+ `refs/forge/adopt-refused/<dir>`. A merge commit is refused, and a range that does not apply exits 6. A
1055
+ diff over 400 KB is read in the snapshot rather than inlined, as in a final review.
1056
+ There is no task row, because no model implemented it; the final review reads the whole range and is told
1057
+ about it, `attribute` treats it as a step of its own, and forge-ui lists it above the final review.
1058
+ `adopt-<epoch>-<pid>/` keeps the review.
1030
1059
  - **`accept <plan> <task> --reason … --approved`** overrides a `FAIL`/`UNKNOWN` reviewer only
1031
1060
  when the reviewed commit is still the branch tip and the worktree still matches
1032
1061
  `source.fingerprint`. It records `known_issues.md` and `accepted.by`, merges through `merge_task`,
@@ -1101,6 +1130,23 @@ tells the dwarf which submodules are present. Integration worktrees (`run`, `int
1101
1130
  `split`) get the same treatment. Out of scope: a task that moves a gitlink's recorded commit (its
1102
1131
  worktree keeps the old content) and nested submodules (left empty).
1103
1132
 
1133
+ **Reviewers get the same dependencies.** A review snapshot holds committed files only, so forge
1134
+ links the directories package managers install into (`node_modules`, `bower_components`, `.venv`,
1135
+ `venv`, `vendor`, `.bundle`, `Pods`, Mix's `deps` and `_build`, `.dart_tool`, `elm-stuff` and
1136
+ SwiftPM's `.build`) from the checkout under review (the task's
1137
+ worktree, or the integration worktree for a final review) into the snapshot, at the root and in
1138
+ workspace packages down to five levels, unless the snapshot already holds that path or lacks its
1139
+ parent. These are the directories this step filled, so they match the attempt. The links count for
1140
+ no fingerprint and stay out of the reviewer's `git status`. The prompt names what was linked and what
1141
+ is committed, or says there is none, says when forge ran no tests of its own, and tells the reviewer
1142
+ to report rather than search or install. A directory that is only partly committed (`vendor/.gitkeep`)
1143
+ keeps its committed files and gets no link. Nothing guards a write
1144
+ through a link: forge commits whatever git does not ignore, so a linked directory is an ignored one
1145
+ (a directory the attempt committed is already in the snapshot and gets no link), and a write there
1146
+ changes nothing that merges. A link dangles once its worktree is removed, which harms nothing. Each
1147
+ reviewer ends with `FORGE_TESTS: RAN`, `NOT NEEDED — why` or `COULD NOT RUN — why`; the last prints a note, and
1148
+ forge-ui and the dataset show it.
1149
+
1104
1150
  Forge does not guess this step, and the obvious guess is worth naming because it looks right and
1105
1151
  is not: symlinking the source repo's `node_modules` into the worktree. In a workspace monorepo the
1106
1152
  workspace links inside it point back at the source checkout, so the worktree builds against the
@@ -70,7 +70,10 @@ through `forge-guard.py session` (python's `os.setsid()` then `exec`, same pid,
70
70
  unless `FORGE_ORPHAN_GUARD=off` or the run is Fractal. That gives a process group to signal as a
71
71
  unit: the watchdog (TERM, then KILL for a CLI that traps TERM) and the exit trap signal the whole
72
72
  group in addition to `pkill -P`, and after a normal exit `forge-guard.py reap` lists and stops
73
- anything still alive in it (`<role>.orphans`). This is proven offline only; verify a new harness
73
+ anything still alive in it (`<role>.orphans`). Tools can leave the group (codex runs commands in
74
+ groups of their own, and a test runner's web server starts a session of its own), so
75
+ `forge-guard.py track` samples the harness's descendants every 2 s into `<role>.tracked` (pid and
76
+ start time), and `reap --tracked` stops those still alive and their children as well (#129). This is proven offline only; verify a new harness
74
77
  with one live dispatch before relying on it, and use the kill switch if a harness deliberately
75
78
  leaves a helper running.
76
79
 
@@ -82,7 +82,11 @@ Solo defaults to `--output summary`; `--output full` includes raw CLI output. Re
82
82
  `.last` files once, then inspect logs only as needed. `forge-dispatch.sh report <run-dir>`
83
83
  reports immutable attempt metrics and native usage independently of project memory. Shared
84
84
  context is assembled from original requirements and approach; QA does not embed dwarf
85
- execution instructions. Review snapshots use self-contained object packs and one checkout.
85
+ execution instructions. Review snapshots use self-contained object packs and one checkout, with
86
+ the repo's dependency directories (`node_modules`, `.venv`, `vendor`, Mix's `deps` and the others
87
+ listed under [worktree setup](decompose.md#worktree-setup)) linked in, at the root and in workspace
88
+ packages, when it has them; the prompt says what is there, and the reviewer reports `FORGE_TESTS` as in
89
+ [worktree setup](decompose.md#worktree-setup).
86
90
 
87
91
  Optional [Ripwire context](ripwire.md) is enabled by default. Use `--no-ripwire`
88
92
  or `FORGE_RIPWIRE=off` to disable preparation and installation offers.
package/references/ui.md CHANGED
@@ -35,7 +35,7 @@ run goes on, with the same exit code.
35
35
  filed as GitHub issues or dismissed through `forge issues`.
36
36
  - **Delete a run:** a dry run, then `forge runs rm`: the dataset keeps the traces, an archive is
37
37
  written unless declined, and clean worktrees and unchecked-out branches can go with it.
38
- - **Settings:** `forge config show` in one view: the registry, decision-model gates, profiles,
38
+ - **Settings:** `forge config show` in one view: the registry, decision-model gates (each says what it does, when, what it sends and what `on` changes, and **How to set this up** opens a setup guide), profiles,
39
39
  the per-repo files, the dataset and `FORGE_*` variables, with edits where the server can write.
40
40
  - **Export a run:** one HTML file to share that opens without forge-ui; prompts, diffs, reports
41
41
  and local paths stay out unless chosen.
@@ -204,3 +204,12 @@ server that is already running, do not unregister runs, and do not block `forge
204
204
  close the exposure, run `forge ui stop`. Do not forward the server's port.
205
205
 
206
206
  The API contract is [ui/docs/api.md](../ui/docs/api.md).
207
+
208
+ ## Live refresh
209
+
210
+ A live refresh never cancels what the user is doing. Every view that redraws on new data goes through
211
+ `ForgeUI.guard(region, draw)` (`preserve` in `app.js` does): while a pointer is down in the region, a
212
+ selection touches it or a `<select>` in it has focus, the latest draw waits and runs when that ends. What the
213
+ user just did draws at once, and a hold that lasts five seconds shows **Newer data is waiting**, with a
214
+ button that runs it. Anything collapsible in such a view gets a `data-keep` key, which `preserve` and
215
+ `ForgeUI.keepOpen` restore. A new view that rebuilds on a poll goes through the same two.
@@ -59,6 +59,59 @@ forge_review_snapshot() ( # source, baseline tree, final tree, destination
59
59
 
60
60
  )
61
61
 
62
+ # Where package managers install into a checkout: npm and bower, Python virtualenvs, Go, PHP and Ruby
63
+ # vendor dirs, Bundler's config, CocoaPods, Mix (deps, _build), Dart, Elm and SwiftPM (#127). The same
64
+ # names as forge-fail-first.py's DEP_DIRS. Only a directory the snapshot does not hold is linked, so a
65
+ # committed one of these names is never replaced.
66
+ FORGE_DEP_DIRS='node_modules bower_components .venv venv vendor .bundle Pods deps _build .dart_tool elm-stuff .build'
67
+
68
+ _forge_dep_dirs() { # checkout: its dependency directories, relative, never one inside another
69
+ # Five levels reach apps/group/name/node_modules.
70
+ local name names=()
71
+ for name in $FORGE_DEP_DIRS; do names+=(${names[0]+-o} -name "$name"); done
72
+ (cd "$1" && find . -maxdepth 5 \( -name .git -o -name .forge \) -prune -o \
73
+ \( "${names[@]}" \) \( -type d -o -type l \) -print -prune 2>/dev/null) |
74
+ sed 's#^\./##'
75
+ }
76
+
77
+ forge_review_deps() { # source checkout, review snapshot, note file (#117)
78
+ # Links the dependency directories of the checkout under review (what .forge/setup filled, so
79
+ # they match the attempt, unlike the source repo's) into its snapshot, at the root and in
80
+ # workspace packages, and writes what the reviewer has to the note. An untracked link counts for
81
+ # no fingerprint, and the exclude keeps it out of the reviewer's `git status`: a `node_modules/`
82
+ # ignore pattern does not match a link. A directory the snapshot already holds is committed: it
83
+ # stays as it is. `ln` fails where the snapshot lacks the parent (an old run's dir in a solo
84
+ # repo): that is no part of the change, so nothing is linked there.
85
+ local src rel linked="" committed
86
+ src="$(cd "$1" && pwd)" || src=""
87
+ committed="$(_forge_dep_dirs "$2" | sort | awk 'NR > 1 { printf ", " } { printf "%s", $0 }')"
88
+ if [ -n "$src" ]; then
89
+ while IFS= read -r rel; do
90
+ [ -n "$rel" ] && [ -d "$src/$rel" ] && [ ! -e "$2/$rel" ] && [ ! -L "$2/$rel" ] || continue
91
+ ln -s "$src/$rel" "$2/$rel" 2>/dev/null || continue
92
+ mkdir -p "$2/.git/info" && echo "/$rel" >> "$2/.git/info/exclude"
93
+ linked="$linked${linked:+, }$rel"
94
+ done <<< "$(_forge_dep_dirs "$src" | sort)"
95
+ fi
96
+ {
97
+ if [ -n "$linked" ]; then
98
+ echo "Dependencies linked into your checkout from the attempt's own copy: $linked. Use them to run tests, and do not write to them. forge does not check that they are complete, or look more than five levels down."
99
+ fi
100
+ if [ -n "$committed" ]; then
101
+ echo "Dependency directories committed in your checkout, holding only what was committed: $committed."
102
+ fi
103
+ if [ -z "$linked$committed" ]; then
104
+ echo "Dependencies in your checkout: none. It holds committed files only, with no installed packages."
105
+ fi
106
+ } > "$3"
107
+ }
108
+
109
+ forge_tests_note() { # QA reply: the reason, when the reviewer says its tests could not run (#117)
110
+ grep -qs 'FORGE_TESTS:' "$1" || return 0
111
+ python3 "$SKILL_DIR/scripts/forge-contract.py" tests --qa-last "$1" 2>/dev/null |
112
+ awk -F'\t' '$1 == "could_not_run" { print ($2 == "" ? "no reason given" : $2) }'
113
+ }
114
+
62
115
  forge_fingerprint() { # forge_fingerprint <dir> [--tracked], as forge_tree
63
116
  local tree head index
64
117
  tree="$(forge_tree "$1" "${2:-}")" || return 1
@@ -55,7 +55,7 @@ lowercase prose do not count. The severity is the first P0-P3 token of the block
55
55
  line (`[P2]`, `(P2)`, `**P2**`, `P2:`, `P2 -` or a standalone `P2`; uppercase only).
56
56
 
57
57
  Phantom findings. A reviewer may echo the contract it was given. Three layers keep that
58
- from creating findings or blocking: (1) FORGE_VERDICT and FORGE_LEARNING text is removed
58
+ from creating findings or blocking: (1) FORGE_VERDICT, FORGE_LEARNING and FORGE_TESTS text is removed
59
59
  before parsing (the verdict line itself says "CONFIRMED"); (2) any line that is a
60
60
  contiguous fragment of this module's own contract text (all parts, kinds and thresholds,
61
61
  whitespace-collapsed, at least 25 characters, list marker ignored) is removed, which
@@ -78,7 +78,7 @@ import sys
78
78
 
79
79
  SEVERITIES = ('P0', 'P1', 'P2', 'P3')
80
80
  PLACEHOLDER = 'path/file.py:123'
81
- KINDS = ('task', 'final', 'solo', 'sweep')
81
+ KINDS = ('task', 'final', 'solo', 'sweep', 'adopt')
82
82
  DEFAULT_THRESHOLD = 'P2'
83
83
  QA_TEST_MINUTES = 5 # the reviewer's own test time, beyond which it says the check is too broad (#89)
84
84
 
@@ -130,6 +130,12 @@ _HEAD = {
130
130
  'diff did not change, and do not report other problems you notice there: they are not this',
131
131
  "task's work.",
132
132
  ] + _NO_TRUST,
133
+ 'adopt': [
134
+ "This range was made outside forge, by a person or another agent, and is about to enter this run's",
135
+ 'integration branch. Review the diff below for correctness bugs, and for whether it does what the',
136
+ 'reason above says. Also say if it changes anything that reason does not cover.',
137
+ "Do not trust the reason's claims about which checks ran or passed; judge the diff itself.",
138
+ ],
133
139
  'final': [
134
140
  'This is the final, whole-run review. The diff below is the COMBINED result of several',
135
141
  'tasks that were implemented independently and each reviewed on its own slice only.',
@@ -163,7 +169,12 @@ _VERIFY = [
163
169
  'spend at most about %d minutes running tests. Use any test evidence forge gives you above' % QA_TEST_MINUTES,
164
170
  'before running a test yourself. When the targeted tests would take longer, or the change',
165
171
  'touches shared infrastructure (a test helper, a build file, a lockfile), say so instead of',
166
- 'running everything.',
172
+ 'running everything. If a test needs a dependency your checkout does not have, do not look for',
173
+ 'it elsewhere and do not install anything: report that it could not run.',
174
+ 'Say whether tests ran, on a line of its own before the verdict, in exactly one of these forms:',
175
+ ' FORGE_TESTS: RAN',
176
+ ' FORGE_TESTS: NOT NEEDED — why',
177
+ ' FORGE_TESTS: COULD NOT RUN — why',
167
178
  ]
168
179
 
169
180
  _SEVERITY = [
@@ -225,7 +236,7 @@ def qa_text(part: str, kind: str = 'task', threshold=None) -> str:
225
236
  if part != 'tail':
226
237
  raise ValueError('part must be head or tail')
227
238
  lines = list(_SWEEP_FINDINGS if kind == 'sweep' else _FINDINGS)
228
- if kind in ('task', 'solo'):
239
+ if kind in ('task', 'solo', 'adopt'):
229
240
  lines += _ALL_CONFIRMED + _SOLO_EXTRA
230
241
  lines += [''] + _VERIFY
231
242
  lines += [''] + _SEVERITY
@@ -289,7 +300,7 @@ def dwarf_text(pre_review: bool = False, verify_after_merge: bool = False) -> st
289
300
 
290
301
  # --- parsing ---------------------------------------------------------------------
291
302
 
292
- _PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING):.*$')
303
+ _PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING|TESTS):.*$')
293
304
  _QUOTE = re.compile(r'^\s*(?:>[ \t]?)+')
294
305
  _MARKER = re.compile(r'^(?:[-*+•–]|\d{1,3}[.)]|#{1,6})\s+')
295
306
  _HEADING = re.compile(r'^ {0,3}#{1,6}[ \t]+\S')
@@ -327,7 +338,7 @@ def _clean(text: str) -> list:
327
338
  for number, raw in enumerate(text.replace('\r\n', '\n').replace('\r', '\n').split('\n'), 1):
328
339
  raw = raw.expandtabs(4)
329
340
  line = _PROTOCOL.sub('', raw)
330
- if line != raw and not line.strip():
341
+ if line != raw and not line.strip(' \t*_`>+-'):
331
342
  continue
332
343
  line = _QUOTE.sub('', line).rstrip()
333
344
  core = _collapse(_MARKER.sub('', line.strip()))
@@ -427,6 +438,35 @@ def gate(verdict: str, text: str, threshold=None) -> GateResult:
427
438
  return GateResult(decision, worst, len(confirmed), unlabelled, len(below), below)
428
439
 
429
440
 
441
+ # A reviewer's own word on whether its tests ran (#117). Only a line of its own counts, the last one
442
+ # when it repeats: a quoted example in prose is not its report. Unlike the verdict, nothing gates on
443
+ # this line and it exists to be seen, so markup and any separator are forgiven, and a line that says
444
+ # something else is `unclear` rather than silence. The forms' own "why" is the prompt echoed.
445
+ _TESTS_LINE = re.compile(r'^[ \t>*_`+-]*FORGE_TESTS:[ \t*_`]*(.*?)[ \t*_`]*$', re.M)
446
+ _TESTS_VALUE = re.compile(r'(RAN|NOT[ _]NEEDED|COULD[ _]NOT[ _]RUN)\b(.*)$', re.I)
447
+ _TESTS_STATUS = {'RAN': 'ran', 'NOT NEEDED': 'not_needed', 'COULD NOT RUN': 'could_not_run'}
448
+ _TESTS_TRIM = ' \t—–-:()'
449
+ _TESTS_REASON_MAX = 300
450
+
451
+
452
+ def _tests_reason(text: str) -> str | None:
453
+ return ''.join(ch for ch in text.strip(_TESTS_TRIM) if ch.isprintable())[:_TESTS_REASON_MAX] or None
454
+
455
+
456
+ def tests_report(text) -> dict | None:
457
+ """{status: ran|not_needed|could_not_run|unclear, reason} from a QA reply, or None when it does not say."""
458
+ report = None
459
+ for value in _TESTS_LINE.findall((text or '').replace('\r\n', '\n')):
460
+ match = _TESTS_VALUE.match(value)
461
+ if not match:
462
+ report = dict(status='unclear', reason=_tests_reason(value))
463
+ continue
464
+ reason = _tests_reason(match.group(2))
465
+ if (reason or '').lower() != 'why':
466
+ report = dict(status=_TESTS_STATUS[match.group(1).upper().replace('_', ' ')], reason=reason)
467
+ return report
468
+
469
+
430
470
  def known_issues_text(threshold, tolerated) -> str:
431
471
  name = SEVERITIES[_rank(threshold)]
432
472
  lines = ['## Known issues (QA findings below blocking threshold %s)' % name, '',
@@ -468,8 +508,8 @@ def _parser() -> argparse.ArgumentParser:
468
508
  qa.add_argument('--part', required=True, choices=('head', 'tail'),
469
509
  help='head = review preamble, tail = findings format + verdict contract')
470
510
  qa.add_argument('--kind', choices=KINDS, default='task',
471
- help='task (default), final (whole-run review), solo (solo wording) or sweep (a finding '
472
- 'sweep task: per-finding FIXED lines, regressions only)')
511
+ help='task (default), final (whole-run review), solo (solo wording), sweep (a finding '
512
+ 'sweep task: per-finding FIXED lines, regressions only) or adopt (a range made outside forge)')
473
513
  qa.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
474
514
  help='least severe level that still blocks; none = P3 (default: %s)' % DEFAULT_THRESHOLD)
475
515
  dwarf = sub.add_parser('dwarf', help='print the implementer rules block')
@@ -485,6 +525,8 @@ def _parser() -> argparse.ArgumentParser:
485
525
  % DEFAULT_THRESHOLD)
486
526
  gate_parser.add_argument('--known-issues', metavar='OUT', default=None,
487
527
  help='write tolerated findings here when there are any')
528
+ tests = sub.add_parser('tests', help='print what the reply says about its tests: status, a tab, the reason')
529
+ tests.add_argument('--qa-last', required=True, metavar='FILE', help='the QA reply')
488
530
  return parser
489
531
 
490
532
 
@@ -502,6 +544,11 @@ def main(argv=None) -> int:
502
544
  except OSError as error:
503
545
  sys.stderr.write('forge-contract: cannot read %s: %s\n' % (args.qa_last, error))
504
546
  return 3
547
+ if args.command == 'tests':
548
+ report = tests_report(text)
549
+ if report:
550
+ _emit('%s\t%s\n' % (report['status'], report['reason'] or ''))
551
+ return 0
505
552
  result = gate(args.verdict, text, args.threshold)
506
553
  if args.known_issues and result.n_below >= 1:
507
554
  temporary = args.known_issues + '.%d.tmp' % os.getpid()
@@ -845,8 +845,6 @@ def decision_of(plan, args, dwarf):
845
845
  if line.strip())
846
846
  raise Refused(f'task {args.task} is waiting for your decision, and only a decision resumes it: {head or "see decision.md"} '
847
847
  '(retry --decide retry=N | threshold=Pn, or --dwarf SPEC, each with --reason TEXT --approved)')
848
- if args.decide is not None and dwarf is not None:
849
- raise Invalid('give --decide or --dwarf, not both: a decision is one choice')
850
848
  if args.decide is not None and not DECISION.fullmatch(args.decide):
851
849
  raise Invalid('--decide takes retry=N (1 to 20) or threshold=P0|P1|P2|P3')
852
850
  reason = re.sub(r'\s+', ' ', args.reason or '').strip()