@giamme/forge 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +1 -1
  3. package/SKILL.md +31 -12
  4. package/VERSION +1 -1
  5. package/docs/add-ons.md +11 -6
  6. package/docs/artifacts.md +18 -6
  7. package/docs/commands.md +189 -17
  8. package/docs/decomposed-runs.md +13 -5
  9. package/docs/forge-ui.md +34 -4
  10. package/docs/memory.md +2 -1
  11. package/docs/models.md +4 -2
  12. package/docs/reviews.md +81 -19
  13. package/docs/troubleshooting.md +3 -1
  14. package/forge +17 -1
  15. package/package.json +1 -1
  16. package/references/dataset.md +40 -14
  17. package/references/decision-models.md +759 -0
  18. package/references/decompose.md +197 -28
  19. package/references/harnesses.md +10 -3
  20. package/references/planning.md +8 -0
  21. package/references/solo.md +13 -3
  22. package/references/ui.md +11 -0
  23. package/scripts/forge-artifact.sh +30 -4
  24. package/scripts/forge-config.py +238 -29
  25. package/scripts/forge-contract.py +127 -58
  26. package/scripts/forge-control.py +40 -9
  27. package/scripts/forge-decide.py +6 -0
  28. package/scripts/forge-dispatch.sh +47 -15
  29. package/scripts/forge-fail-first.py +2 -2
  30. package/scripts/forge-gate-addressed.sh +40 -0
  31. package/scripts/forge-gate-message.sh +64 -0
  32. package/scripts/forge-issues.py +368 -36
  33. package/scripts/forge-jev-options.sh +269 -42
  34. package/scripts/forge-lib-attribute.sh +447 -0
  35. package/scripts/forge-lib-gates.sh +32 -0
  36. package/scripts/forge-lib-plans.sh +17 -6
  37. package/scripts/forge-lib-review.sh +24 -19
  38. package/scripts/forge-lib-task.sh +219 -39
  39. package/scripts/forge-lib-verify.sh +45 -8
  40. package/scripts/forge-memory.sh +3 -3
  41. package/scripts/forge-parallel-options.sh +44 -5
  42. package/scripts/forge-parallel.sh +503 -304
  43. package/scripts/forge-plan-check.py +35 -1
  44. package/scripts/forge-pre-review.py +437 -0
  45. package/scripts/forge-prompt.py +25 -5
  46. package/scripts/forge-route.py +2 -2
  47. package/scripts/forge-runtime.py +55 -1
  48. package/scripts/forge-schedule.py +70 -9
  49. package/scripts/forge-shadow.py +2 -2
  50. package/scripts/forge-solo.sh +41 -10
  51. package/scripts/forge-submodules.py +389 -0
  52. package/scripts/forge-sweep.py +542 -0
  53. package/scripts/forge_dataset/cli.py +12 -6
  54. package/scripts/forge_dataset/export.py +55 -45
  55. package/scripts/forge_dataset/forecast.py +4 -1
  56. package/scripts/forge_dataset/harvest.py +33 -5
  57. package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
  58. package/scripts/forge_decide/__init__.py +141 -0
  59. package/scripts/forge_decide/budget.py +149 -0
  60. package/scripts/forge_decide/cache.py +66 -0
  61. package/scripts/forge_decide/cli.py +953 -0
  62. package/scripts/forge_decide/doctor.py +221 -0
  63. package/scripts/forge_decide/label_addressed.py +75 -0
  64. package/scripts/forge_decide/label_attribution.py +62 -0
  65. package/scripts/forge_decide/label_coverage.py +81 -0
  66. package/scripts/forge_decide/label_message.py +38 -0
  67. package/scripts/forge_decide/label_prompt.py +139 -0
  68. package/scripts/forge_decide/labels.py +328 -0
  69. package/scripts/forge_decide/metrics.py +125 -0
  70. package/scripts/forge_decide/migrate.py +226 -0
  71. package/scripts/forge_decide/providers.py +292 -0
  72. package/scripts/forge_decide/replay.py +350 -0
  73. package/scripts/forge_decide/report.py +382 -0
  74. package/scripts/forge_decide/resolve.py +397 -0
  75. package/scripts/forge_decide/sites.py +377 -0
  76. package/scripts/forge_jev/__init__.py +202 -104
  77. package/scripts/forge_jev/addressed.py +171 -0
  78. package/scripts/forge_jev/attribution.py +198 -0
  79. package/scripts/forge_jev/cli.py +460 -382
  80. package/scripts/forge_jev/client.py +155 -77
  81. package/scripts/forge_jev/coupling.py +19 -87
  82. package/scripts/forge_jev/coverage.py +303 -0
  83. package/scripts/forge_jev/findings.py +219 -0
  84. package/scripts/forge_jev/gates.py +225 -27
  85. package/scripts/forge_jev/memory.py +65 -4
  86. package/scripts/forge_jev/message.py +134 -0
  87. package/scripts/forge_jev/plan_gates.py +294 -0
  88. package/scripts/forge_jev/questions.py +173 -313
  89. package/scripts/forge_jev/verify.py +130 -104
  90. package/ui/README.md +41 -10
  91. package/ui/docs/api.md +212 -44
  92. package/ui/forge_ui/checks.py +331 -0
  93. package/ui/forge_ui/control.py +60 -11
  94. package/ui/forge_ui/export.py +8 -3
  95. package/ui/forge_ui/models.py +1 -0
  96. package/ui/forge_ui/reader.py +436 -26
  97. package/ui/forge_ui/server.py +13 -0
  98. package/ui/forge_ui/static/app.js +15 -8
  99. package/ui/forge_ui/static/checksview.js +449 -0
  100. package/ui/forge_ui/static/controls.js +20 -13
  101. package/ui/forge_ui/static/convo.js +11 -2
  102. package/ui/forge_ui/static/findingsview.js +6 -4
  103. package/ui/forge_ui/static/index.html +1 -0
  104. package/ui/forge_ui/static/panel.js +105 -17
  105. package/ui/forge_ui/static/runmodel.js +40 -2
  106. package/ui/forge_ui/static/scene3d.js +2 -15
  107. package/ui/forge_ui/static/settings.js +336 -41
  108. package/ui/forge_ui/static/style.css +72 -7
  109. package/ui/forge_ui/transcripts.py +225 -54
  110. package/references/jev.md +0 -865
  111. package/scripts/forge_jev/backtest.py +0 -322
  112. package/scripts/forge_jev/corpus.py +0 -156
  113. package/scripts/forge_jev/features.py +0 -24
  114. package/scripts/forge_jev/predict.py +0 -204
  115. package/scripts/forge_jev/review.py +0 -73
  116. package/scripts/forge_jev/routing.py +0 -271
  117. package/scripts/forge_jev/subset.py +0 -123
@@ -0,0 +1,759 @@
1
+ # Decision models
2
+
3
+ A decision model is a small hosted model that answers narrow, typed questions (a yes/no
4
+ probability, a single choice) over state forge supplies, in about a second. forge uses two:
5
+ TypeSafe's **Jev** and Cloudflare's **Clef**, which takes Jev's request shape. Both are
6
+ optional. Read this when turning one on, when changing a site, or before proposing a new one.
7
+
8
+ - **Off by default.** Nothing is sent until a gate is `shadow` or `on` and its provider can be
9
+ asked. See [Setup](#setup).
10
+ - **Always fail-open.** A timeout, an error, a refusal or a missing key is logged as a skip
11
+ reason, and the run proceeds exactly as it would with the model off. A decision-model call
12
+ can never fail a run.
13
+ - **The rule: a gate never changes a verdict, never blocks a dispatch, and never makes work
14
+ pass.** It never changes a review verdict, a severity, `accept` or a PASS. A decision model
15
+ never changes a task's tier or the model a task runs on, and never marks anything verified
16
+ itself. With the gate `on`, a gate acts in one of these ways and no other: it sends a task's
17
+ prompt or an uncovered requirement back to the planner, once; it adds a predicted file to a
18
+ task's `files`, or a dependency that forms no cycle; it bounces a retry, skips the review of an
19
+ attempt that says it did not finish, or stops a task for the user's answer; it puts the likeliest
20
+ culprit's boundary first in the attribution search; it turns duplicate findings into comments and
21
+ pre-selects concrete ones for filing; or it acts on memory and on the verify command. Verify
22
+ discover picks the command that runs when none is configured; that command's own result decides
23
+ verification. `shadow` asks and records, and changes nothing. See [Gates and modes](#gates-and-modes)
24
+ and [Setup](#setup).
25
+ - **`FORGE_JEV=off` sends nothing.** It turns every gate off. A repo privacy floor does the
26
+ same and is applied after it. See [Setup](#setup).
27
+
28
+ Which models do which work is measured instead of asked: exploratory routing and
29
+ `forge dataset routing` compare models per tier from randomized assignments (see
30
+ [Decomposition](decompose.md#exploratory-routing-on-by-default)).
31
+
32
+ ## Criteria a site must meet to exist
33
+
34
+ #35 audited every site against four rules. A site that fails one is removed, not tuned.
35
+
36
+ 1. **It changes something.** A warning a person sees, a command forge runs, a fact it keeps
37
+ or drops. A score nobody reads is not a site.
38
+ 2. **It was measured.** Against a label from outside the model (git history, the task's own
39
+ outcome, the repo's documented command), on state production really sends.
40
+ 3. **It beats a trivial baseline.** Doing nothing, an exact-match key, or a cheap feature.
41
+ 4. **It is cheap enough per run.** One bounded request, never one per file, per dispatch or
42
+ per entry on a hot path.
43
+
44
+ How each kept site meets them:
45
+
46
+ | site | changes | measured | baseline it beats | cost |
47
+ |---|---|---|---|---|
48
+ | drift | in `on`, adds the predicted undeclared file to the task's `files` before the waves are computed (in `shadow`, only recorded) | precision at `gate_warn` 0.60 over 50 commits × 2 repos: **1.000** and **0.934**; non-edited files scored ≤0.23 where the true file scored 0.65 | the post-wave `drift.txt`, which reports the broken promise only after the wave ran | one request per task |
49
+ | forward | in `on`, makes the earlier-wave task wait for the later one it may be written against, unless that forms a cycle (in `shadow`, only recorded) | 7 cross-wave pairs, 5 runs each: `readme`→`cli` **0.88–0.90**, every other pair 0.05–0.15 (gap 0.73, noise 0.07) | wave order, which cannot see the case; the review cannot either | one request per plan |
50
+ | prompt adequacy | in `on`, sends a task back to the planner, once, when a reviewer could not judge its prompt (in `shadow`, only recorded) | 3 runs over 8 probe prompts and 8 real ones: unjudgeable **0.06–0.27**, checkable behaviour **0.85–0.96** | silence; the old 0.30 sat 0.03 above the worst true positive | one request per task |
51
+ | memory curate, slice, stale | refiles, merges, hides or drops a fact in `memory.md` | merge: wrong 0.56–0.72, right 0.91–1.00. Refile: wrong 0.56–0.72, right 0.92–1.00. Stale: gone false 0.03–0.10, still true 0.47–0.96 | exact-match keys (two wordings of one fact never reach two distinct runs) | curate at `record`, slice at `inject`, stale only on `prune` |
52
+ | verify discover | picks a verify command when none is configured | 18 repos: 10 fire at 0.70, every pick correct, lowest correct 0.73, highest wrong 0.55 | `UNVERIFIED` | one request, only when nothing is configured |
53
+
54
+ The five gates added in C3–C5 (coverage, retry-addressed, dwarf-message, attribution, findings)
55
+ are not in this table. None has a replay or a measured threshold yet, so their thresholds are
56
+ starting points, and `forge decide gate G on` needs `--force` for each until a replay passes.
57
+
58
+ Two caveats travel with these numbers:
59
+
60
+ - Forward rests on a single positive example. A second plan could move the positive class, but
61
+ unlikely by 0.38.
62
+ - `tests_act` 0.70 is **stale**. The 18-repo table was measured before a make target's recipe
63
+ reached the model, and the one confirmed wrong pick (`spankai` → `cargo test`) has since risen
64
+ from 0.55 to 0.77–0.81, past the gate. The gate reads 1 − P(none), the probability that the
65
+ repo is verifiable at all, because Choice confidence drops when two commands both run the suite.
66
+ Re-measure across the 18 repos before moving the number; fitting a new one to one data point
67
+ is the mistake this file records.
68
+
69
+ Every number here is from this project's repos and does not transfer. Re-measure before trusting
70
+ a threshold elsewhere. Each rubric has its own threshold because the rubrics are not on one
71
+ scale: the single shared `gate_warn` warned on 5 of 9 and 5 of 11 perfectly good tasks.
72
+
73
+ ## The kept sites
74
+
75
+ `SITE_CAPABILITY` in `scripts/forge_jev/__init__.py` is the source of truth for the first two
76
+ columns; thresholds are `DEFAULT_THRESHOLDS` in the same file. A capability of `—` means the
77
+ gate has no legacy capability, so its own mode alone decides.
78
+
79
+ | site | capability | runs | can change | threshold | recorded |
80
+ |---|---|---|---|---|---|
81
+ | `jev-prompt` | `gates` | `plan`, per task | sends a task whose prompt is below the threshold back to the planner, once (`plan` exits 4) | `prompt_warn` 0.55 (flags a probability below it) | `<plan>/jev.jsonl`; judgment in `tasks/<id>/jev.json`; `plan-gates.json` (`prompt`) |
82
+ | `jev-drift` | `gates` | `plan`, per task | adds each predicted file at or above the threshold to the task's `files`, before the waves are computed | `drift_warn`, falls back to `gate_warn` 0.60 | `<plan>/jev.jsonl`; judgment in `tasks/<id>/jev.json`; `plan-gates.json` (`drift`) |
83
+ | `jev-forward` | `gates` | `plan`, once | makes the earlier task of a warned pair depend on the later one, unless that would form a cycle (then recorded as refused); at most three pairs a plan (`MAX_WARNINGS`, the highest-scoring) | `forward_warn` 0.50 | `<plan>/jev.jsonl`; `jev-coupling.json`; `plan-gates.json` (`forward`) |
84
+ | `jev-coverage` | `—` | `plan`, once, one question per requirement of `request.md`: the first 30 that have at least four words and are not repeated (`MAX_REQUIREMENTS`), so a later requirement is never asked. Skipped above 40 tasks, with fewer than two requirements, or without `request.md` | sends each uncovered requirement back to the planner, once (`plan` exits 4) | `coverage_warn` 0.50 (the probability that no task covers it) | `<plan>/jev.jsonl`; `plan-gates.json` (`coverage`, `sent_back`, `pending`) |
85
+ | `jev-retry-addressed` | `—` | a retry (attempt above 1) whose retry findings came from a review, after its diff is taken and before QA | bounces the retry back to its implementer without a review when its diff leaves a blocking finding untouched | `untouched_warn` 0.70 | `tasks/<id>/jev.jsonl`; `bounced` and `bounce.md`; attempts.tsv `BOUNCED`; dataset attempt `sent_back: bounce` |
86
+ | `jev-dwarf-message` | `—` | each implementer reply, before its diff is taken and before any review | stops the task as `NEEDS_INPUT` when the message asks a question only the user can answer; sends the attempt back as FAIL without a review when it says it did not finish or was blocked | `message_ask` 0.70 (question); `message_warn` 0.70 (unfinished, blocked) | `tasks/<id>/jev.jsonl`; `needs_input.md` or `message.md` with `message.failed`; attempts.tsv `INCOMPLETE`; dataset attempt `sent_back: message` (not for a question) |
87
+ | `jev-attribution` | `—` | `attribute` and `run --attribute`, once per search, after a failed combined verification | ranks the merged tasks, and in `on` verifies the top suspect's boundary first; nothing is merged, reverted or accepted | none (it orders a search) | `<plan>/jev.jsonl`; `attribution.json` (`gate`); the `attribution` event |
88
+ | `jev-findings` | `—` | `forge-issues.py`, once per plan, through `forge-jev.py findings --run-dir <plan>` | turns a finding that duplicates an open issue into a comment on that issue (posted by `--apply`), and pre-selects the PLAUSIBLE findings that read as concrete defects | `findings_dup` 0.85 (duplicate); `findings_concrete` 0.50 (concrete) | `<plan>/jev.jsonl`; the `gate` field of each finding and draft; comment receipts in `${XDG_STATE_HOME:-~/.local/state}/forge/findings/<repo key>.comments.json` |
89
+ | `jev-memory-curate` | `memory` | `forge-memory.sh record` | not injected, refiled, or merged onto an existing key | `memory_merge` 0.85, `memory_recategorize` 0.80, durability `gate_warn` 0.60 | ledger flag; nothing is ever lost |
90
+ | `jev-memory-slice` | `memory` | `forge-memory.sh inject` | removes lines from the role slice, never adds or reorders | none | `jev.jsonl` |
91
+ | `jev-memory-stale` | `memory` | `forge-memory.sh prune`, deep prune only | drops an entry whose fact went false | `stale_drop` 0.25 | `memory_prune` event |
92
+ | `jev-verify-discover` | `tests` | `verify_result`, when neither `--verify` nor `.forge/verify` exists | chooses the verify command | `tests_act` 0.70 | `verification.jev.json` |
93
+
94
+ Every request, from every site, is also recorded:
95
+
96
+ - `<run-dir>/jev.jsonl`: one row per request with site, question ids, answers, confidences,
97
+ latency, tokens and whether the judgment was applied. `jev.skip` holds the reason for a
98
+ skipped one.
99
+ - The run dataset keeps the **full request** whole (state and questions), so a judgment can be
100
+ replayed later. See [Dataset](dataset.md).
101
+
102
+ Thresholds are deliberately conservative where an action is irreversible: `stale_drop` sits far
103
+ below `gate_warn` because dropping a fact is silent and permanent, while a stale fact costs a
104
+ line. `memory.md` is injected into every future dispatch, so a wrong fact is paid for forever;
105
+ `ledger.tsv` is append-only, so a rejected line is still kept in full.
106
+
107
+ Verify discover enumerates commands that demonstrably exist (`package.json` scripts, Makefile
108
+ targets with their recipes, tox/nox, runner scripts, workflow `run:` steps, `## Verify` facts in
109
+ `.forge/memory.md`) and Jev selects one or `none`. It selects, never generates. `UNVERIFIED`
110
+ remains the outcome whenever nothing is chosen: a model may find a command, never declare
111
+ something verified.
112
+
113
+ ## Setup
114
+
115
+ `forge decide` is the setup command. `forge jev` is an alias for this release and then goes
116
+ away. For `setup`, `sites`, `enable`, `disable`, `status` and `doctor` the launcher names the
117
+ `forge decide` command and then runs the old one. Command lines are also in
118
+ [the command reference](../docs/commands.md#forge-decide).
119
+
120
+ ### Quick start
121
+
122
+ ```sh
123
+ # hosted TypeSafe. The key is one line on stdin, stored mode 0600.
124
+ printf '%s\n' "$TYPESAFE_API_KEY" | forge decide provider add jev --name typesafe --key-stdin
125
+
126
+ # or a local server: --local needs --url, sends no key and costs nothing
127
+ forge decide provider add jev --name local --url http://127.0.0.1:8080 --local
128
+
129
+ forge decide gate memory-curate shadow --provider typesafe
130
+ forge decide status
131
+ ```
132
+
133
+ Name a provider to choose where a gate's requests go. The local server above is
134
+ `forge decide gate memory-curate shadow --provider local`. `on` waits for a passing replay
135
+ (see [Measuring a gate](#measuring-a-gate)). A gate with no `--provider` does not
136
+ read the key file `provider add` wrote: it uses the legacy transport, `jev.json`'s endpoint
137
+ with `TYPESAFE_API_KEY` or `jev.json`'s key (or Cloudflare, for a site `jev.json` maps
138
+ there). Migration leaves `jev.json` in place, so with either key present such a gate still
139
+ sends requests, wherever `jev.json` points.
140
+
141
+ `status` prints each gate's effective mode and which level set it, the providers (key
142
+ `present` or `missing`), today's spend, and whether a privacy floor is on. It never writes.
143
+ forge-ui's Settings page has the same fields under Decision models; a change there writes the
144
+ user file.
145
+
146
+ ### Gates and modes
147
+
148
+ Twelve gates, each `off` (the default), `shadow` or `on`:
149
+
150
+ `drift`, `forward`, `prompt`, `coverage`, `retry-addressed`, `dwarf-message`, `attribution`,
151
+ `findings`, `memory-curate`, `memory-slice`, `memory-stale`, `verify-discover`.
152
+
153
+ `off` asks nothing. `shadow`, on every gate, asks and records the answer, then leaves the run
154
+ as it would have been with the gate off: no note, no work sent back, no retry bounced, no review
155
+ skipped, no task stopped, no search reordered, no memory edit, no comment, no verify command.
156
+
157
+ What `on` does:
158
+
159
+ | gate | what `on` does |
160
+ |---|---|
161
+ | `drift` | adds each file it predicts at or above `drift_warn` to the task's `files`, before the waves are computed, so the wave plan treats it as declared |
162
+ | `forward` | makes the earlier task of a warned pair depend on the later one, never one that would form a cycle; the waves are computed again |
163
+ | `prompt` | sends a task whose prompt is below `prompt_warn` back to the planner, once |
164
+ | `coverage` | sends each uncovered requirement back to the planner, once (among the first 30 requirements of `request.md`) |
165
+ | `retry-addressed` | bounces a retry back to its implementer without a review when its diff leaves a blocking finding untouched |
166
+ | `dwarf-message` | skips the review of an attempt whose final message says it did not finish or was blocked (the attempt ends FAIL, unreviewed), or stops the task as `NEEDS_INPUT` when the message asks a question only the user can answer |
167
+ | `attribution` | after a failed combined verification, verifies the likeliest culprit's boundary first |
168
+ | `findings` | turns a finding that duplicates an open issue into a comment on that issue (posted by `forge issues --apply`), and pre-selects the concrete findings for filing |
169
+ | `memory-curate` | refiles, merges or withholds the fact |
170
+ | `memory-slice` | removes lines from the injected slice |
171
+ | `memory-stale` | drops a fact that went false |
172
+ | `verify-discover` | runs the chosen command when none is configured |
173
+
174
+ `prompt` and `coverage` send work back **once** per item: a task for `prompt`, a requirement for
175
+ `coverage`. `plan` writes `plan.sendback.md` listing what was flagged and exits 4 before it prints
176
+ the table. Rewrite what the file lists, then run `plan` again. What is still flagged from that list
177
+ is printed under the table and is not sent back again. An item the first list did not name is a new
178
+ flag, such as a task the rewrite added with an unjudgeable prompt, or a requirement the rewrite left
179
+ uncovered. That item is sent back in its own round, so the second `plan` can exit 4 again. No item
180
+ is sent back twice; `plan-gates.json` keeps that history across re-plans.
181
+
182
+ `dwarf-message` and `retry-addressed` send an attempt back without spending a review on it. The
183
+ attempt ends FAIL, and the next attempt is handed the implementer's own words (`dwarf-message`) or
184
+ the untouched blocking findings (`retry-addressed`). `retry-addressed` does not check the attempt
185
+ after its bounce again.
186
+
187
+ The memory gates and verify discover act as they did before C3–C5. Verify discover still does
188
+ not mark anything verified: the command it picked does, or `UNVERIFIED` stands.
189
+
190
+ `on` for any gate needs a passing replay for the provider and model it uses, or `--force`.
191
+ See [Measuring a gate](#measuring-a-gate). None of the five gates added in C3–C5 has a recorded
192
+ replay yet, so each needs `--force` for now.
193
+
194
+ Set one with `forge decide gate <gate> off|shadow|on [--provider P] [--model M]`. `--repo DIR`
195
+ writes `<repo>/.forge/decide.json`; `--profile NAME` writes that profile in the user file.
196
+ The two flags are exclusive. `--provider` must already be configured, and the gate uses only
197
+ that provider.
198
+
199
+ ### Where settings live, and which wins
200
+
201
+ Two files. The user file is `${XDG_CONFIG_HOME:-~/.config}/forge/decide.json`, mode `0600`.
202
+ An empty or relative `XDG_CONFIG_HOME` counts as unset. The repo file is
203
+ `<repo>/.forge/decide.json`, mode `0644`, and is the one a checkout shares.
204
+ `--repo` defaults to `FORGE_DECIDE_REPO`, else the git top level of the working directory.
205
+
206
+ Six levels, lowest first. A level sets only the fields it names. The user file wins over the
207
+ repo on any field both set; `status` lists those as shadowed.
208
+
209
+ 1. **default.** Every gate `off`, no budget.
210
+ 2. **repo.** `<repo>/.forge/decide.json`: `gates`, and the per-run budget (`run_tokens`,
211
+ `run_usd`).
212
+ 3. **user.** `decide.json`: `gates`, providers, and the whole budget, including the daily caps.
213
+ While that file does not exist, the legacy level stands here (source `legacy`): `jev.json`
214
+ plus `FORGE_JEV*` turn a gate `on` when its old capability is enabled. A fresh install, with
215
+ neither file and no `FORGE_JEV*`, stays at `default`.
216
+ 4. **profile.** `FORGE_DECIDE_PROFILE`, looked up in the user file's `profiles` first, then the
217
+ repo file's. A profile in the user file may set the daily budget; one in the repo file may
218
+ set only the per-run budget.
219
+ 5. **env.** `FORGE_DECIDE_GATE_<NAME>=off|shadow|on`, with `NAME` upper-cased and `-` written
220
+ `_` (`FORGE_DECIDE_GATE_MEMORY_CURATE`, `FORGE_DECIDE_GATE_VERIFY_DISCOVER`). Once the user
221
+ `decide.json` exists, `FORGE_JEV_<CAP>` can only turn gates off, and any `=on` is an
222
+ allowlist of the capabilities left on. `FORGE_JEV_SHADOW=on` (`--jev-shadow`) turns every
223
+ `on` into `shadow`, except, before the user `decide.json` exists, a gate the legacy level
224
+ turned on: that site acts as it did before #36, its records are marked shadow, and `plan`
225
+ prints a count in shadow mode instead of its warnings. Drift, forward and prompt are the
226
+ exception to the exception: they only advised before #36, so under `--jev-shadow` they
227
+ record what they would do (`would_add`, `shadow: true`) and change nothing in the plan.
228
+ 6. **flags.** `--gate`, `--no-gates` and `--decide-budget` on `plan` or a solo run, frozen in
229
+ `<plan-or-run>/jev-selection.json`. `--no-gates` turns every gate off after `--gate` is
230
+ applied. A re-plan replaces the file. Solo again on the same run dir keeps it. `run` and
231
+ `retry` keep it too, and say so when flags are passed again. A plan with no selection file
232
+ takes the flags on `run` or `retry` and freezes them then.
233
+
234
+ After those six, `FORGE_JEV=off` turns every gate off (skip `kill`). A repo privacy floor then
235
+ turns every gate off (skip `privacy`) and wins over the kill switch. Both send nothing.
236
+
237
+ `providers` and `budget.daily_*` count only in the user file. `privacy` counts only in the repo
238
+ file. Anywhere else they are ignored, and `doctor` reports them as misplaced.
239
+
240
+ ### Providers
241
+
242
+ Two types, each hosted or local. `jev` is TypeSafe's request shape; hosted, the URL defaults
243
+ to `https://api.typesafe.ai/v1/systemone` and the model to `jev-latest`. `clef` is Cloudflare's
244
+ envelope; hosted, pass `--url`, or `--account-id` (else `CLOUDFLARE_ACCOUNT_ID`) to build the
245
+ Workers AI URL. The default model is `clef`.
246
+
247
+ ```sh
248
+ forge decide provider add jev --name typesafe --key-stdin
249
+ forge decide provider add clef --name cloudflare --account-id <id> --key-env CLOUDFLARE_API_TOKEN
250
+ forge decide provider add jev --name local --url http://127.0.0.1:8080 --local
251
+ forge decide provider list
252
+ forge decide provider rm local
253
+ ```
254
+
255
+ `--context N` is the context limit in tokens. A request over 90% of it is skipped `too-large`
256
+ and the state is not cut to fit. `--price X` is USD per million tokens, which the budget uses.
257
+ `--deadline S` is seconds per request; the default is 5. `--local` requires `--url`, sends no
258
+ key and adds no cost.
259
+
260
+ A key is never an argument. `provider add` reads one line from `--key-stdin` and writes
261
+ `${XDG_CONFIG_HOME:-~/.config}/forge/keys/<name>.key` (mode `0600`, the `keys/` directory
262
+ `0700`), stores a variable name with `--key-env VAR` and reads it when a request is made, or
263
+ prompts on a terminal. Adding the same name again without a key keeps the key it has. `status`
264
+ and `provider list` show `present` or `missing`. `provider rm` refuses while a gate names that
265
+ provider, and deletes the `keys/<name>.key` it wrote.
266
+
267
+ ### Budgets
268
+
269
+ Two caps, each in tokens and estimated USD. Unset means no cap.
270
+
271
+ ```sh
272
+ forge decide budget # caps, and what today has spent
273
+ forge decide budget --run tokens=20000,usd=0.50 # this run
274
+ forge decide budget --daily tokens=200000,usd=5 # user level; a repo file cannot set it
275
+ forge decide budget --run none # clear the per-run cap
276
+ forge decide budget --repo DIR --run tokens=5000 # per-run cap for one repo
277
+ ```
278
+
279
+ `--daily` is refused together with `--repo`. `none`, or `tokens=none` / `usd=none`, clears
280
+ that cap. A number is zero or more.
281
+
282
+ Today's spend is `${XDG_STATE_HOME:-~/.local/state}/forge/decide/spend/<YYYY-MM-DD>.json`
283
+ (local date; a new day is a new file). The run's own counter is `<run-dir>/decide.budget.json`
284
+ and shows up in `status` when `FORGE_DECIDE_RUN_DIR` is set. `forge decide budget` and
285
+ `forge decide status` both print today's tokens and USD.
286
+
287
+ Once any set cap is reached, every later decision-model call is skipped with reason `budget`
288
+ and the run continues. A local provider, or one with no `--price`, adds tokens and zero USD.
289
+ A replay (`forge decide replay --send`) is charged to neither cap, and a request-cache hit
290
+ costs nothing. See [Measuring a gate](#measuring-a-gate).
291
+ `--decide-budget tokens=N[,usd=X]` on a run sets that run's cap at the flags level and does
292
+ not change the daily cap.
293
+
294
+ ### Privacy floor
295
+
296
+ ```sh
297
+ forge decide privacy never-send --repo DIR
298
+ forge decide privacy allow --repo DIR
299
+ ```
300
+
301
+ `never-send` writes `"privacy": "never-send"` into `<DIR>/.forge/decide.json`. Every gate is
302
+ then off (skip `privacy`): no decision-model request leaves that repo, and `doctor --live`
303
+ does not probe. The floor beats every level, including run flags and `FORGE_JEV=off`. A
304
+ replay skips that repo's stored requests too.
305
+
306
+ Removing it is a per-repo edit: `privacy allow --repo DIR` deletes the key from that repo's
307
+ file. The user `decide.json` cannot set or clear it.
308
+
309
+ With no floor, a gate that is `shadow` or `on` sends that site's state to its provider.
310
+ `.forge/memory.md` is part of it: prompt adequacy includes its first 4000 characters, the
311
+ memory gates send the entries they are judging, and verify discover sends the bullets under
312
+ `## Verify`. Drift's candidate file list leaves out `.forge/` and `.git`; that filter applies
313
+ to the candidate list only. Keep private text out of `.forge/memory.md`, or set the floor.
314
+
315
+ ### Migration
316
+
317
+ ```sh
318
+ forge decide migrate # once
319
+ forge decide migrate --force # replace the user decide.json from jev.json again
320
+ ```
321
+
322
+ `migrate` reads `${XDG_CONFIG_HOME:-~/.config}/forge/jev.json` and a Cloudflare token
323
+ (`cloudflare.env` beside it, or `CLOUDFLARE_API_TOKEN`) and writes the user `decide.json`:
324
+
325
+ - A TypeSafe key becomes the provider `typesafe` (`type` `jev`, URL and model from
326
+ `jev.json`). The key moves to `keys/typesafe.key`.
327
+ - Cloudflare becomes the provider `cloudflare` (`type` `clef`). A token already in
328
+ `cloudflare.env` stays in that file; one stored in `jev.json` moves to
329
+ `keys/cloudflare.key`; one that lives only in the environment is referenced as
330
+ `key_env` `CLOUDFLARE_API_TOKEN`.
331
+ - When `jev.json` is `enabled`, the `memory` gates and `verify-discover` are set `on`, and
332
+ `drift`, `forward` and `prompt` are set `shadow`. A capability switched off is left unset,
333
+ so its gates stay `off`. The five gates added in C3–C5 have no legacy capability, so migration
334
+ leaves them unset. The `on` gates are written with `"force": true`, so they show as
335
+ forced until a replay passes for them.
336
+ - A site mapped to `cloudflare` points at that provider; every other site points at
337
+ `typesafe`, when that provider was created. `forge jev setup --provider cloudflare` mapped
338
+ `jev-drift` by default, and migrate copies that map.
339
+ - Each stored threshold is copied onto the gates that read it (`drift_warn` onto `drift`,
340
+ `forward_warn` onto `forward`, `prompt_warn` onto `prompt`, `memory_merge`,
341
+ `memory_recategorize` and `gate_warn` onto `memory-curate`, `gate_warn` also onto `drift`,
342
+ `stale_drop` onto `memory-stale`, `tests_act` onto `verify-discover`). Per-model values for
343
+ the provider's model override those and set `thresholds_model`. Retired thresholds are not
344
+ copied.
345
+
346
+ While the user `decide.json` does not exist, runs still follow `jev.json` and `FORGE_JEV*`.
347
+ On that path `FORGE_CLEF=off` sends every site to TypeSafe, `FORGE_JEV_PROVIDER` forces
348
+ `typesafe` or `cloudflare`, and `TYPESAFE_API_KEY` overrides the stored key.
349
+ `status`, `doctor`, `provider list` and a bare `budget` never write, so they do not migrate.
350
+ The migration runs before a write to the user file: `gate` without `--repo`, `provider add`,
351
+ `provider rm`, `budget` with `--run` or `--daily` and without `--repo`, and `migrate`.
352
+ A repo-only write (`privacy`, `gate --repo`, `budget --repo`) leaves `jev.json` in place.
353
+ After `decide.json` exists, which gates are on comes from it.
354
+
355
+ `forge jev` remains an alias for this release. Next release it is gone.
356
+
357
+ ### Doctor
358
+
359
+ ```sh
360
+ forge decide doctor [--repo DIR] [--json]
361
+ forge decide doctor --live
362
+ ```
363
+
364
+ Offline, it reports settings that went stale. Nothing it prints contains a key. Exit 0 when
365
+ the only findings are advice, exit 1 when a problem is found or a live probe fails.
366
+
367
+ Advice, which does not fail the command: `threshold-override` (a stored threshold differs from
368
+ the measured default), `shadowed` (the user file wins over the repo), `privacy-floor`.
369
+
370
+ Problems: `retired-threshold`, `unknown-provider` (a gate names a provider that is not
371
+ configured), `unused-provider`, `misplaced` (providers or a daily budget in a repo file, or
372
+ `privacy` in the user file), `key-file` (missing, or not mode `0600`), `not-migrated`
373
+ (`jev.json` exists and `decide.json` does not), `config-error`.
374
+
375
+ `--live` sends one fixed synthetic request, with no repo data, to each configured provider.
376
+ It is the only `forge decide` subcommand that uses the network, and it is skipped when the
377
+ repo has a privacy floor.
378
+
379
+ ### Cloudflare Clef
380
+
381
+ Point a gate at that provider with `forge decide gate drift on --provider <name>`, once a
382
+ replay has passed for it (see [Measuring a gate](#measuring-a-gate)). A paired replay on
383
+ 2026-10-16 found hosted Clef non-inferior on drift: AUC 0.985 against
384
+ Jev's 0.972, paired difference [0.000, +0.028], on 4560 decisions from 17 runs. A site moves
385
+ on the rule in [Promotion](#promotion). `jev-memory-slice` tied (AUC 0.951 against 0.953) on
386
+ 5 runs and stays on a `jev` provider. No per-model threshold is set, so Clef reads the shared ones.
387
+
388
+ The client sends at most 64 questions per request (drift asks up to 120, so that request is
389
+ two concurrent chunks) and refuses `too-large` past the context, 64K tokens for `clef` and
390
+ 24K for `clef-flash`, or whatever `--context` set. The service would otherwise cut the state.
391
+ Rate limits are retried inside the deadline; quota and plan errors are final. A response
392
+ missing an answer, or with one out of range, is `malformed`.
393
+
394
+ ## Measuring a gate
395
+
396
+ A gate becomes `on` by the same path for every site:
397
+
398
+ 1. **Shadow records.** With the gate `shadow`, the site asks. The answers go to `jev.jsonl`,
399
+ and the full request and its answers go to the run dataset. The run goes on as it would
400
+ with the gate off.
401
+ 2. **Labels arrive for free.** After the run, the dataset shows what happened next: which
402
+ undeclared file the task edited, which command the repo documents. Nobody labels anything.
403
+ See [Labels](#labels).
404
+ 3. **Replay compares.** `forge decide replay` re-asks the stored requests on one provider and
405
+ model, and scores the answers against those labels and against the site's baseline, a cheap
406
+ heuristic that uses no model.
407
+ 4. **Promotion.** The gate may be `on` for a provider and model only when the replay for them
408
+ passes. Otherwise `forge decide gate G on` is refused, unless it is forced. See
409
+ [Promotion](#promotion).
410
+
411
+ A replay measures one provider and model. A passing replay on `typesafe` does not cover `local`.
412
+
413
+ ### Labels
414
+
415
+ Each site's label is one sentence in its record in `forge_decide/sites.py`. Labels mean
416
+ **should act**: a label is true when the gate should have acted (sent the work back, added the
417
+ file or the dependency, bounced the attempt, named the culprit), and false when it should not
418
+ have. A label never comes from the gate's own action: whatever followed a send-back that the gate
419
+ made is left unlabelled, or labelled by evidence the gate did not produce.
420
+
421
+ A site whose threshold reads the other way round from its score sets `invert` in its record.
422
+ Two do:
423
+ - **Prompt adequacy.** Its model answers "is the prompt adequate", so the probability of acting
424
+ is `1 − p`, and its score is that. `replay` compares the score with `1 − prompt_warn`, the
425
+ same line as `p < prompt_warn`.
426
+ - **Findings.** Its score is the Noul of "does it read as a preference", the probability of
427
+ deselecting, and its baseline is 1.0 for a finding with no concrete cue. Its threshold
428
+ `findings_concrete` is on the concreteness scale (`1 − p`), so `replay` compares the score with
429
+ `1 − findings_concrete`.
430
+
431
+ `report` counts each site's fired decisions with the site's own rule, which already reads the
432
+ threshold the right way, so it needs no inversion of its own.
433
+
434
+ `forge_decide/labels.py` computes the labels from the run dataset with the joins of `forge
435
+ dataset export`, so a run the dataset did not capture has no labels. The gate modules' labellers
436
+ (`label_prompt`, `label_coverage`, `label_addressed`, `label_message`, `label_attribution`) are
437
+ loaded lazily, so a site whose labeller is missing has no rows.
438
+
439
+ | site | label: true means should act | precision floor |
440
+ |---|---|---|
441
+ | `jev-drift` | the undeclared file was edited by the task's final passing attempt (true), or was not (false). A file the gate added to `files` is labelled by the same edit | 0.5 |
442
+ | `jev-forward` | a later plan revision of the run has the dependency and the gate did not add it (true); both tasks merged and no revision has it (false). A dependency the gate added is false only once a later revision removes it, the user's correction, and is otherwise unlabelled | 0.5 |
443
+ | `jev-prompt` | the prompt was inadequate (true): a later plan revision changed it before its first attempt started, or the first attempt's review calls it ambiguous or unclear. False when the first attempt was reviewed and neither held. No label for a task the gate sent back, a task that never ran, or one whose first review is missing or unparseable | none |
444
+ | `jev-memory-slice` | the fact's anchor was edited by the task (true), or lies in an area the task never touched (false); a request needs both classes | none |
445
+ | `jev-verify-discover` | the candidate is the command the repo documents: its `.forge/verify`, or the command a later run of the same repo verified with, from `--verify` or `repo.verify` (command source not `jev`) | 0.7 |
446
+ | `jev-coverage` | the requirement is uncovered (true): a later plan revision has a task whose acceptance criteria hold at least 60% of the requirement's content words, and the tasks the request was asked about did not. Covered (false): every task of the run merged and no revision changed any acceptance criteria. No label for a requirement the gate sent back | none |
447
+ | `jev-retry-addressed` | the review of the same attempt raised the finding again (true); that review parsed in full and did not (false). No label without a review (a bounced attempt has none), or when its findings cannot be read in full | none |
448
+ | `jev-dwarf-message` | `unfinished` and `blocked`: the QA verdict of the same attempt was FAIL (true) or PASS (false). `question` has no label. No label for an attempt with no review, which is what a send-back leaves | none |
449
+ | `jev-attribution` | `culprit:<id>`: the merge breaks verification (true) when the search verified prefix k−1 PASS and prefix k FAIL; false when both were verified and do not form that pair. No label when either prefix was not verified, the base fails, or the search was inconclusive | none |
450
+
451
+ Verify discover has a label only for a repo that documents a command. Memory slice labels a
452
+ request only when it has both classes.
453
+
454
+ Three sites have no label, so `forge decide replay` refuses them, and their `on` needs
455
+ `--force`. Each is listed with the reason its label is not yet defined:
456
+
457
+ | site | why it has no label |
458
+ |---|---|
459
+ | `jev-memory-curate`, `jev-memory-stale` | `#41: recurrence is influenced by the gate itself; needs independent contradiction evidence`. An injected fact gets re-recorded, so the gate's own action would decide the label |
460
+ | `jev-findings` | `#46: needs issue-closure records`. Auto mode would supply its own ground truth, and an operational non-filing (a cap, a same-titled issue) is not a judgment |
461
+
462
+ ### forge decide report
463
+
464
+ `forge decide report` reads the `jev.jsonl` files of past runs and the dataset's labels. It
465
+ asks no model.
466
+
467
+ It reads these runs:
468
+
469
+ - by default, the newest 10 runs in this repo's run registry, by the run directory's
470
+ modification time. `--runs N` changes the count;
471
+ - with `--all`, every repo's registered runs, cut the same way: the newest 10 across all repos,
472
+ or the newest N with `--runs N`;
473
+ - with `--run DIR` (repeatable), just those directories. It cannot be combined with `--all` or
474
+ `--runs`.
475
+
476
+ In each run directory it reads every `jev.jsonl`: the run's own, and those under `tasks/*/`
477
+ and `integrate-*/`. Anything under `jev-backtests/` is ignored. `--site S` keeps one site.
478
+
479
+ It prints one row per site, sorted by input tokens, then a `total` row:
480
+
481
+ | column | meaning |
482
+ |---|---|
483
+ | `mode` | the gate's mode for this repo, with `(forced)` when it is `on` without a passing replay. `-` for a site with no gate |
484
+ | `calls` | every logged request, including cache hits and skips |
485
+ | `cached` | requests answered from the request cache, at no cost |
486
+ | `errors` | failed requests with no skip reason |
487
+ | `skipped` | failed requests with a reason. The line under the table counts each reason |
488
+ | `in tokens`, `out tokens` | from each request's usage. A cache hit has none |
489
+ | `cost $` | tokens times the provider's price per million tokens, from the user `decide.json` (`provider add --price`). `-` when a provider in use has no price |
490
+ | `fired` | requests the site acted on at its threshold for the model used. `(+N?)` counts requests it could not judge, since verify discover needs the stored request body |
491
+ | `right` | decisions the site fired on whose label is true |
492
+ | `wrong` | decisions the site fired on whose label is false |
493
+ | `missed` | decisions the site did not fire on whose label is true |
494
+
495
+ `right`, `wrong` and `missed` count decisions, one per question, not requests. They read `-`
496
+ for a site with no label, and `0` when the runs carry no dataset or no labelled decision yet.
497
+ `--json` also gives `labelled.decisions`, which the table does not show.
498
+
499
+ An example, from a small test run directory with no dataset. Drift's label columns read `0`
500
+ because there is no dataset; prompt has no label, so its columns read `-`:
501
+
502
+ ```text
503
+ site mode calls cached errors skipped in tokens out tokens cost $ fired right wrong missed
504
+ jev-drift on (forced) 3 1 0 1 1,200 80 0.0019 2 0 0 0
505
+ jev-prompt off 1 0 0 0 300 20 0.0005 1 - - -
506
+ total 4 1 0 1 1,500 100 0.0024 3 0 0 0
507
+ skipped: budget 1
508
+ runs read: 1: …/run
509
+ ```
510
+
511
+ ### forge decide replay
512
+
513
+ ```sh
514
+ forge decide replay --site jev-drift --provider typesafe --model jev-latest # dry run
515
+ forge decide replay --site jev-drift --provider typesafe --model jev-latest --send # ask, judge, record
516
+ ```
517
+
518
+ Run the dry run first. It counts the labelled requests the replay would ask, and prints how
519
+ many are already answered, how many would be sent, how many the privacy floor skips, the input
520
+ tokens and the cost at the provider's price. It sends nothing and writes nothing.
521
+
522
+ `--send` asks each unanswered request, `--workers` at a time (default 3), then judges the
523
+ answers. A request already answered is never sent again, so an interrupted replay resumes. A
524
+ failed request is asked again by the next `--send`.
525
+
526
+ It takes the site's labelled live requests from the dataset, the first per request key.
527
+ `--runs N` keeps the newest N dataset runs. A request from a repo with the privacy floor is
528
+ never sent. The floor is read from that repo's `.forge/decide.json` at replay time, and the
529
+ request is counted under `privacy floor`.
530
+
531
+ The answers and the result are stored under `${XDG_STATE_HOME:-~/.local/state}/forge/decide/`:
532
+
533
+ - `replay/<site>/<provider>/<model>.jsonl`: one line per request, with its answers or its
534
+ failure reason. Each component is percent-encoded, so `--model @cf/meta/llama` is stored as
535
+ `replay/<site>/<provider>/%40cf%2Fmeta%2Fllama.jsonl`;
536
+ - `replays/<gate>.json`: the result, under `"<provider>/<model>"`. `forge decide gate G on`
537
+ reads this file. A result is recorded only when at least one labelled decision was judged.
538
+
539
+ On the judged half of the runs (the newer half, see [Promotion](#promotion)), `--send` reports:
540
+
541
+ - requests answered, and requests skipped by the privacy floor;
542
+ - decisions, positives and runs;
543
+ - the AUC of the replay, of the baseline, and of the live answers, one per live model;
544
+ - replay minus baseline, with its 95% interval and the margin;
545
+ - precision, recall and the number flagged at the site's threshold, against its floor;
546
+ - `PASSES: passes`, or `does not pass:` with the first rule that failed.
547
+
548
+ A replay is not charged to the run or daily budget, and its requests are not written to
549
+ `jev.jsonl` or the dataset. Each `--send` is a deliberate call to the provider.
550
+
551
+ Exit codes: 2 for an unknown site, a site with no label, an unknown provider or a bad flag; 1
552
+ when the provider has no key and is not local.
553
+
554
+ ### Promotion
555
+
556
+ `forge decide gate G on`, for the provider and model the gate resolves to, writes `on` only when
557
+ the replay of G on that provider and model passes, or when it is forced (see
558
+ [Forced gates](#forced-gates)). It passes when, on the judged half:
559
+
560
+ 1. there are at least 30 labelled decisions;
561
+ 2. they come from at least 8 judged runs. Runs are ordered by their first labelled request,
562
+ and the older half calibrates while the newer half is judged. So a site needs 15 runs before
563
+ it has 8 to judge;
564
+ 3. the lower bound of the 95% paired interval of AUC(replay) − AUC(baseline) is above −0.02.
565
+ The interval resamples whole runs 2,000 times. `--seed` (default 7) sets the resamples and
566
+ `--margin` (default 0.02) the bound. The verdict uses the interval that is reported;
567
+ 4. for `drift`, `forward` and `verify-discover`, the replay's precision at the site's
568
+ threshold is at least the floor: 0.5, 0.5 and 0.7. The threshold is `drift_warn`,
569
+ `forward_warn` or `tests_act`, for the model replayed. `memory-slice` has no floor, so it
570
+ passes on rules 1 to 3.
571
+
572
+ A passing replay shows as `replayed <date>` in `status`.
573
+
574
+ ### Forced gates
575
+
576
+ `--force` turns a gate on without a passing replay:
577
+
578
+ ```sh
579
+ forge decide gate drift on --provider typesafe --force
580
+ ```
581
+
582
+ It writes `"force": true` into the gate's entry. That lets the write through, and lets
583
+ `forge config set decide.gate.<gate>.provider` or `.model` change an `on` gate without a
584
+ replay.
585
+
586
+ "Forced" describes the state, not the flag. A gate is forced when it is `on` and no passing
587
+ replay exists for its provider and model, whichever level turned it on: the user file, the
588
+ repo, a profile, an environment variable, a flag, the legacy `jev.json`, or `migrate`. It stays
589
+ forced until a replay passes. Setting it to `off` or `shadow`, or to `on` with a passing
590
+ replay, drops the flag too.
591
+
592
+ Forced shows in:
593
+
594
+ - `forge decide status`: `forced` after the gate's provider, as in
595
+ `drift on (user) provider typesafe, forced`. `status --json` has `"forced": true` for the gate;
596
+ - `forge decide report`: the mode column reads `on (forced)`;
597
+ - `forge config show --json`: the same `forced` field. The text view does not print it;
598
+ - the plan's decide line, as in `forge: decide: on: drift (forced); shadow: none`;
599
+ - forge-ui: a `forced` tag on the gate, in Settings under Decision models. A recorded replay
600
+ shows as `replayed <date>`, or as `replay failed` when it did not pass.
601
+
602
+ `forge decide migrate` writes each gate it turns on with `"force": true`. Those gates keep
603
+ acting, and show as forced until a replay passes.
604
+
605
+ ### The request cache
606
+
607
+ Each decision-model request is keyed by its body: the state, the model and the questions.
608
+ Answers from live calls are kept in `<run dir>/decide.cache/`, one file per request and
609
+ provider (name and URL). Each file holds the request's hash and the answers, not the request.
610
+ The run dir is the plan dir or the solo run dir (`FORGE_DECIDE_RUN_DIR`), so every task of a
611
+ plan shares one cache.
612
+
613
+ The cache answers a repeated request in the same run dir:
614
+
615
+ - a `run` that resumes a plan, and a `retry`;
616
+ - a re-`plan` of the same plan dir;
617
+ - a QA-only resume, where the dwarf's work is kept and only QA runs again.
618
+
619
+ A changed state, model or question is a miss, and so is a different provider or URL.
620
+
621
+ A hit costs nothing and is not charged to a budget, even when a cap is reached. It is logged in
622
+ `jev.jsonl` with `"cached": true`, counts under `cached` in `forge decide report`, and is not
623
+ written to the dataset a second time. Only live answers are cached: failures, fixtures and
624
+ replays are not. The privacy floor is checked before the cache, so a hit cannot get past it.
625
+
626
+ To turn the cache off, set `FORGE_DECIDE_CACHE=off` (`0`, `no` and `false` work too) in the
627
+ run's environment. Every request is then sent, and nothing is written to the cache.
628
+
629
+ ## Adding a site
630
+
631
+ A new site takes this path, in this order. Skipping a step is how the sites in
632
+ [Tried and removed](#tried-and-removed) shipped.
633
+
634
+ 1. **A rubric in `questions.py`.** A typed question with its own wording and its own threshold
635
+ name. Never reuse another rubric's threshold: `coupling_warn` borrowed `gate_warn` and never
636
+ fired once on any plan.
637
+ 2. **Asked through `client.ask` with a site name** (`jev-<name>`). `client.ask` is the only
638
+ place that talks to a provider; it handles the key, the deadline, the provider mapping and
639
+ the fail-open skip, and it records the request.
640
+ 3. **Gated in every copy of the gate list.** The gate's name goes into `GATES`, its site into
641
+ `GATE_SITE`, and its legacy capability into `GATE_CAPABILITY`, all in
642
+ `scripts/forge_decide/__init__.py`. The capability is `None` when the gate has none: the legacy
643
+ level then never turns it on. The same names are also hard-coded
644
+ in these places, and each one needs the new name:
645
+ - `scripts/forge_jev/__init__.py`: `SITE_CAPABILITY`, for every site, and `DEFAULT_THRESHOLDS`
646
+ for each threshold the rubric reads;
647
+ - `scripts/forge_decide/migrate.py`: `THRESHOLD_GATES`, the gates each stored threshold is
648
+ copied onto;
649
+ - `scripts/forge-jev-options.sh`: `FORGE_DECIDE_GATE_NAMES` and the gate names in its help
650
+ text (`tests/test_decide_flags.py` keeps it in step with `forge_decide.GATES`);
651
+ - `ui/forge_ui/control.py`: `DECIDE_GATES`;
652
+ - `ui/forge_ui/static/settings.js`: `GATES`;
653
+ - `ui/tests/test_browser_settings.py`: `_GATES`;
654
+ - `ui/tests/js/settings.test.js`: the list its assertions compare the page with.
655
+
656
+ Three tests spell the list out by hand and need the name too: `tests/test_config.py`,
657
+ `tests/test_decide_cli.py` and `tests/test_gate_registry.py`.
658
+
659
+ The shell asks `forge_decide_active <gate>` and the Python side asks `site_ready(site)`; both
660
+ must be false when the gate is off, `FORGE_JEV=off` is set, the privacy floor is on, or the
661
+ provider cannot be asked.
662
+ 4. **Recorded in the run dataset.** The request must land in `jev.jsonl` and the run dataset
663
+ whole, state included. The labeller reads it back from the dataset and labels it from what
664
+ happened afterwards.
665
+ 5. **A record in `forge_decide/sites.py`, with its functions taken lazily.** One `Site` per site:
666
+ its `fired`, `decisions`, `score` and `baseline`, the label sentence or a `label_issue`, the
667
+ floor if it has one, and `invert=True` when the raw probability points away from acting. A
668
+ site whose functions live in its gate module takes them through `_lazy(module, attr, default)`,
669
+ so `sites.py` never imports a module another task is still writing. While the module is
670
+ missing the site acts on nothing: `fired` and `decisions` give `[]`, `score` gives None and
671
+ `baseline` gives 0.0.
672
+ 6. **A labeller, read lazily.** `forge_decide/labels.py` finds a site's labeller in `LABELLERS`.
673
+ A labeller has the shape `label(index, record, event, body) -> {qid: bool}`. One in its own
674
+ module, `forge_decide/label_<name>.py`, is registered as `sites._lazy('forge_decide.label_<name>',
675
+ 'label', {})`, so the site has no rows until the module exists.
676
+ 7. **The measurement functions and the CLI verb.** `forge_jev/<module>.py` exports `decisions`,
677
+ `score`, `fired` and `baseline` over the stored body, and `main(args)` for its verb. In
678
+ `forge_jev/cli.py`, `cmd_<verb>` checks its paths (exit 2) and calls
679
+ `_delegate(verb, module, args, repo)`, which imports the module and returns its `main`. A
680
+ missing module is exit 3. Exit 3 always means no opinion: skipped, shadow, or nothing to say.
681
+ Each `main` checks `site_ready(site)` first. The verb goes into `parser()` and into the dispatch
682
+ table in `main()`.
683
+ 8. **A run-time gate puts its attempt into the request state.** A gate that runs once per attempt
684
+ puts `run` (the plan's `run_id`), `task` and `attempt` into the request's **state**, as
685
+ `dwarf-message` and `retry-addressed` do, and not only into `client.ask(context=...)`. The
686
+ request key, and with it the cache, then differs per attempt and per run. `labels.requests`
687
+ keeps only the first request per key, so without this a message repeated on a later attempt,
688
+ or in another run, would be neither asked nor labelled again. A per-run gate (`attribution`)
689
+ puts `run` alone.
690
+ 9. **Replayed against labelled outcomes before it may act.** The label must come from outside the
691
+ model. Then measure the site on the state production sends, and report the class separation,
692
+ the noise floor from repeated identical requests, and the baseline from the criteria above.
693
+ `forge decide replay` judges it by the rule in [Measuring a gate](#measuring-a-gate). A number
694
+ measured on state the model is not sent describes nothing: it has bitten this file seven times.
695
+ 10. **Ships in `shadow` first.** `shadow` asks and records, and changes nothing. A new site moves
696
+ to `on` only after step 9 holds on live runs. What `on` may then do is one of the actions in
697
+ [Gates and modes](#gates-and-modes): it never changes a verdict, never blocks a dispatch, and
698
+ never makes work pass.
699
+
700
+ ## Tried and removed
701
+
702
+ All of these were removed on 2026-10-27 (#35) unless noted, each on a measurement. None should
703
+ be retried without new data that answers the measurement below.
704
+
705
+ **Routing rubrics and the tier composite.** Five `Score` rubrics per task (design judgment,
706
+ concurrency subtlety, blast radius, spec clarity, test coverage) were weighted into a tier, with
707
+ a "suggests <tier>" note and a `--jev-act` mode that could write it into the `difficulty`
708
+ column. No repo ever reached the calibration floor, so it never acted (removed 2026-10-17).
709
+ Over the run dataset its score predicted a first pass about as well as cheap features (AUC 0.69
710
+ against 0.64–0.67 on older runs), and on the newest runs every method sat near chance. A model
711
+ swap on Clef explained 2% of the variance in its predictions: a decision model judges how hard
712
+ a task is, not which model does it better. Models and efforts are measured by randomized
713
+ routing instead. `--jev-act` stays as a no-op, and `--jev-routing` still parses.
714
+
715
+ **`independently_verifiable`.** A gate for tasks whose confirmation needs another task's work.
716
+ Its first form asked about a sibling task the model was never shown. With the whole plan in
717
+ state it still could not separate a task documenting later work (`readme`, 0.60–0.65) from a
718
+ real one (`cli`, 0.65–0.75). At the old 0.38 it caught nothing on a real plan, and at 0.55 it
719
+ was a precision gate whose silence meant "no evidence", not "verifiable".
720
+
721
+ **Same-wave coupling.** Asked whether two tasks in one wave share an interface. It never fired
722
+ on any plan until measured, because it borrowed `gate_warn` (0.60) while coupling scores sat at
723
+ 0.09–0.38. With its own `coupling_warn` 0.20 and a cap of three pairs, it rested on a single
724
+ plan with a margin of about 0.02. Cross-wave forward dependency, with a gap of 0.73, is the half that stayed.
725
+
726
+ **Review triage.** After a FAIL it read the review against the diff and flagged an unsound one
727
+ (correctness and citation). It could never change the verdict, and on real runs it flagged 2 of 5
728
+ FAILs, both artifacts of the 24K diff cut rather than unsound reviews. The reviewer's
729
+ verdict was never its to change, so there was nothing left for it to do.
730
+
731
+ **`clef-first-pass` and `clef-retry-pass`.** Silent Clef predictions of whether a first attempt
732
+ or a retry would pass, recorded and never acted on. They ranked at AUC 0.73 and 0.75 but were
733
+ poorly calibrated (retry ECE 0.28), cost 8% of tokens and hit two 10-second timeouts, and never
734
+ learned: the newest, largest tasks were too few to test, so the skill never showed up on new
735
+ runs.
736
+
737
+ **Verify flake triage (`flake_act`).** Classified a failing verify command as
738
+ `real_regression`, `known_flake`, `environment` or `generated_drift` and reran once on a
739
+ corroborated flake. It was unreachable by default: the deterministic rerun (`--verify-retries`,
740
+ default 1) comes first and needs no model, so the triage only ran with retries set to 0, plus a
741
+ recorded trap sharing a distinctive token with the failure. Its memory readers were also empty
742
+ for every repo for a time. The deterministic rerun and the `FLAKY` line stay.
743
+
744
+ **The test subset.** Asked which tests a diff makes relevant, to run them early. The safe
745
+ threshold at recall ≥ 0.95 was 0.20 in one repo and 0.45 in another, a 2.25× spread, so no
746
+ global default could serve, and it only ever added a run: the full suite still ran at
747
+ integration. `.forge/verify-subset` stays, for `--fail-first`.
748
+
749
+ **`forge jev backtest` and the corpus.** Replayed git history to score the test rubric, and the
750
+ tracked `jev-backtests/` directory held its results. Its tally carried a 140M-token artifact, so
751
+ its numbers could not be trusted. Captured requests in the run dataset are what a site is
752
+ replayed against now, as in step 5 above.
753
+
754
+ **Earlier removals (2026-10-17).** Effort sizing (AUC 0.64 overall but 0.50–0.54 within a tier,
755
+ 81% of suggestions `xhigh` or higher), `forge jev parse-spec` (no shorter than typing the
756
+ `--dwarf-<tier>` flags) and Fractal child re-rating (gated on a calibration no repo had).
757
+
758
+ Old plan dirs and dataset stores that hold routing, coupling or triage rows stay readable; they
759
+ are no longer written.