@giamme/forge 0.12.1 → 0.13.1
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.
- package/CHANGELOG.md +66 -0
- package/README.md +1 -1
- package/SKILL.md +29 -12
- package/VERSION +1 -1
- package/docs/add-ons.md +11 -6
- package/docs/artifacts.md +12 -6
- package/docs/commands.md +179 -17
- package/docs/decomposed-runs.md +13 -5
- package/docs/forge-ui.md +14 -4
- package/docs/memory.md +2 -1
- package/docs/models.md +4 -2
- package/docs/reviews.md +49 -20
- package/docs/troubleshooting.md +3 -1
- package/forge +17 -1
- package/package.json +1 -1
- package/references/dataset.md +39 -13
- package/references/decision-models.md +763 -0
- package/references/decompose.md +166 -29
- package/references/harnesses.md +10 -3
- package/references/planning.md +8 -0
- package/references/solo.md +13 -3
- package/scripts/forge-artifact.sh +30 -4
- package/scripts/forge-config.py +238 -29
- package/scripts/forge-contract.py +95 -56
- package/scripts/forge-control.py +40 -9
- package/scripts/forge-decide.py +6 -0
- package/scripts/forge-dispatch.sh +38 -16
- package/scripts/forge-fail-first.py +2 -2
- package/scripts/forge-gate-addressed.sh +40 -0
- package/scripts/forge-gate-message.sh +64 -0
- package/scripts/forge-issues.py +321 -33
- package/scripts/forge-jev-options.sh +269 -42
- package/scripts/forge-lib-attribute.sh +447 -0
- package/scripts/forge-lib-gates.sh +32 -0
- package/scripts/forge-lib-plans.sh +22 -6
- package/scripts/forge-lib-review.sh +22 -17
- package/scripts/forge-lib-task.sh +217 -38
- package/scripts/forge-lib-verify.sh +45 -8
- package/scripts/forge-memory.sh +3 -3
- package/scripts/forge-parallel-options.sh +18 -5
- package/scripts/forge-parallel.sh +457 -303
- package/scripts/forge-plan-check.py +35 -1
- package/scripts/forge-pre-review.py +437 -0
- package/scripts/forge-prompt.py +25 -5
- package/scripts/forge-route.py +2 -2
- package/scripts/forge-runtime.py +10 -4
- package/scripts/forge-schedule.py +21 -5
- package/scripts/forge-shadow.py +2 -2
- package/scripts/forge-solo.sh +39 -9
- package/scripts/forge-submodules.py +389 -0
- package/scripts/forge-ui-options.sh +25 -0
- package/scripts/forge_dataset/cli.py +12 -6
- package/scripts/forge_dataset/export.py +140 -84
- package/scripts/forge_dataset/harvest.py +33 -5
- package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
- package/scripts/forge_decide/__init__.py +141 -0
- package/scripts/forge_decide/budget.py +180 -0
- package/scripts/forge_decide/cache.py +66 -0
- package/scripts/forge_decide/cli.py +953 -0
- package/scripts/forge_decide/doctor.py +270 -0
- package/scripts/forge_decide/label_addressed.py +75 -0
- package/scripts/forge_decide/label_attribution.py +62 -0
- package/scripts/forge_decide/label_coverage.py +81 -0
- package/scripts/forge_decide/label_message.py +38 -0
- package/scripts/forge_decide/label_prompt.py +139 -0
- package/scripts/forge_decide/labels.py +328 -0
- package/scripts/forge_decide/metrics.py +125 -0
- package/scripts/forge_decide/migrate.py +226 -0
- package/scripts/forge_decide/providers.py +292 -0
- package/scripts/forge_decide/replay.py +350 -0
- package/scripts/forge_decide/report.py +382 -0
- package/scripts/forge_decide/resolve.py +397 -0
- package/scripts/forge_decide/sites.py +377 -0
- package/scripts/forge_jev/__init__.py +202 -104
- package/scripts/forge_jev/addressed.py +171 -0
- package/scripts/forge_jev/attribution.py +198 -0
- package/scripts/forge_jev/cli.py +460 -382
- package/scripts/forge_jev/client.py +155 -77
- package/scripts/forge_jev/coupling.py +19 -87
- package/scripts/forge_jev/coverage.py +303 -0
- package/scripts/forge_jev/findings.py +219 -0
- package/scripts/forge_jev/gates.py +225 -27
- package/scripts/forge_jev/memory.py +65 -4
- package/scripts/forge_jev/message.py +134 -0
- package/scripts/forge_jev/plan_gates.py +294 -0
- package/scripts/forge_jev/questions.py +173 -313
- package/scripts/forge_jev/verify.py +130 -104
- package/ui/README.md +2 -2
- package/ui/docs/api.md +92 -39
- package/ui/forge_ui/control.py +71 -14
- package/ui/forge_ui/export.py +2 -1
- package/ui/forge_ui/models.py +17 -16
- package/ui/forge_ui/reader.py +132 -21
- package/ui/forge_ui/repos.py +428 -0
- package/ui/forge_ui/static/app.js +24 -5
- package/ui/forge_ui/static/cloudmodel.js +8 -5
- package/ui/forge_ui/static/controls.js +20 -13
- package/ui/forge_ui/static/modelstats.js +12 -8
- package/ui/forge_ui/static/panel.js +63 -17
- package/ui/forge_ui/static/runmodel.js +48 -7
- package/ui/forge_ui/static/scene3d.js +2 -15
- package/ui/forge_ui/static/settings.js +481 -68
- package/ui/forge_ui/static/style.css +56 -9
- package/references/jev.md +0 -865
- package/scripts/forge_jev/backtest.py +0 -322
- package/scripts/forge_jev/corpus.py +0 -156
- package/scripts/forge_jev/features.py +0 -24
- package/scripts/forge_jev/predict.py +0 -204
- package/scripts/forge_jev/review.py +0 -73
- package/scripts/forge_jev/routing.py +0 -271
- package/scripts/forge_jev/subset.py +0 -123
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"""The live decision-model sites: what each acts on, what judges it, what it must beat.
|
|
2
|
+
|
|
3
|
+
`forge decide report` and `replay` read this registry. A record holds, per site:
|
|
4
|
+
|
|
5
|
+
- `fired(answers, threshold_value, request)`: the question ids the site acted on, mirroring
|
|
6
|
+
the site's own code (forge_jev/gates.py, coupling.py, memory.py, verify.py). `answers` is a
|
|
7
|
+
request's answers, {question id: answer}, as jev.jsonl and the dataset keep them.
|
|
8
|
+
`request` is the stored request body {state, model, questions}, or the list of question ids
|
|
9
|
+
jev.jsonl logs: the answers alone cannot say which lines were asked or which `runs_<i>` is
|
|
10
|
+
which command. A site that cannot be read without the body (verify-discover) returns None
|
|
11
|
+
for "unknown" when it lacks it.
|
|
12
|
+
- `decisions(body)`: the question ids of a stored request body that are scored decisions
|
|
13
|
+
(a label can exist for them).
|
|
14
|
+
- `score(answers, qid, request)`: the decision's probability.
|
|
15
|
+
- `label`: one sentence naming the label, or None with the issue that will define it.
|
|
16
|
+
- `baseline(body, qid)`: the cheap heuristic the site must not lose to; higher = more
|
|
17
|
+
likely positive.
|
|
18
|
+
- `floor`: the precision a promoted gate must reach at its threshold.
|
|
19
|
+
- `invert`: the raw probability points away from acting, so `score` is 1 - p and replay and
|
|
20
|
+
report compare it against 1 - threshold.
|
|
21
|
+
|
|
22
|
+
The sites of the five new gates take their `fired`, `decisions`, `score` and `baseline` from
|
|
23
|
+
their gate module (forge_jev.coverage and so on) through `_lazy`, so this file never imports
|
|
24
|
+
a module that another task writes: until one exists its site acts on nothing.
|
|
25
|
+
|
|
26
|
+
Pure functions over answers and bodies: no I/O, and nothing here asks a model.
|
|
27
|
+
"""
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
from dataclasses import dataclass
|
|
31
|
+
import importlib
|
|
32
|
+
import re
|
|
33
|
+
from typing import Callable
|
|
34
|
+
|
|
35
|
+
from forge_decide import SITE_GATE
|
|
36
|
+
from forge_jev.client import probabilities
|
|
37
|
+
from forge_jev.coupling import MAX_WARNINGS
|
|
38
|
+
from forge_jev.memory import SLICE_KEEP
|
|
39
|
+
|
|
40
|
+
# Verify-discover is decided per candidate; its decision for candidate i is the question
|
|
41
|
+
# the request already asks about it, `runs_<i>`.
|
|
42
|
+
_INDEXED = re.compile(r'^(?:f|l|runs_)(\d+)$')
|
|
43
|
+
_FILE = re.compile(r'''the file (?P<q>['"])(?P<path>.+?)(?P=q)(?:\s|\?|,|$)''')
|
|
44
|
+
_EARLIER = re.compile(r'''Task EARLIER: ['"](?P<id>\S+) \(''')
|
|
45
|
+
_LATER = re.compile(r'''task LATER: ['"](?P<id>\S+) \(''')
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _noul(answers, qid) -> float | None:
|
|
49
|
+
answer = (answers or {}).get(qid)
|
|
50
|
+
if isinstance(answer, dict) and answer.get('type', 'noul') == 'noul':
|
|
51
|
+
value = answer.get('noul')
|
|
52
|
+
if isinstance(value, (int, float)) and not isinstance(value, bool):
|
|
53
|
+
return float(value)
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _index(qid: str) -> int:
|
|
58
|
+
found = _INDEXED.match(qid)
|
|
59
|
+
return int(found.group(1)) if found else -1
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _ids(answers, prefix: str) -> list[str]:
|
|
63
|
+
"""The answered question ids that are `<prefix><n>`, in index order."""
|
|
64
|
+
found = [qid for qid in (answers or {}) if re.fullmatch(prefix + r'\d+', str(qid))]
|
|
65
|
+
return sorted(found, key=_index)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _questions(body) -> dict:
|
|
69
|
+
"""The body's questions by id. Anything but a stored body, which has them as a dict, has
|
|
70
|
+
none: a jev.jsonl entry's id list is read by _asked."""
|
|
71
|
+
questions = body.get('questions') if isinstance(body, dict) else None
|
|
72
|
+
return questions if isinstance(questions, dict) else {}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _asked(request) -> list[str]:
|
|
76
|
+
"""The question ids a request asked: a stored body's questions, or the id list jev.jsonl
|
|
77
|
+
logs. Empty when the caller has neither."""
|
|
78
|
+
if isinstance(request, dict):
|
|
79
|
+
questions = request.get('questions')
|
|
80
|
+
request = list(questions) if isinstance(questions, (dict, list)) else []
|
|
81
|
+
return [str(qid) for qid in request] if isinstance(request, (list, tuple)) else []
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _state(body) -> dict:
|
|
85
|
+
state = (body or {}).get('state')
|
|
86
|
+
return state if isinstance(state, dict) else {}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _question_ids(request, prefix: str) -> list[str]:
|
|
90
|
+
return sorted((qid for qid in _asked(request) if re.fullmatch(prefix + r'\d+', qid)), key=_index)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _instructions(body, qid) -> str:
|
|
94
|
+
question = _questions(body).get(qid)
|
|
95
|
+
return str(question.get('instructions') or '') if isinstance(question, dict) else ''
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _files(text) -> list[str]:
|
|
99
|
+
return [name for name in str(text or '').replace(',', ' ').split() if name]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _lazy(module: str, attr: str, default):
|
|
103
|
+
"""A function calling `module.attr` with its arguments, importing `module` on each call.
|
|
104
|
+
`default` is returned instead while the module or the attribute is missing; any other
|
|
105
|
+
import error propagates, so a broken gate module is not read as an absent one."""
|
|
106
|
+
def call(*args, **kwargs):
|
|
107
|
+
try:
|
|
108
|
+
target = importlib.import_module(module)
|
|
109
|
+
except ModuleNotFoundError as exc:
|
|
110
|
+
if exc.name is None or not (module == exc.name or module.startswith(exc.name + '.')):
|
|
111
|
+
raise
|
|
112
|
+
return default
|
|
113
|
+
function = getattr(target, attr, None)
|
|
114
|
+
return default if function is None else function(*args, **kwargs)
|
|
115
|
+
return call
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# --- fired ------------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
def _fired_at_least(prefix: str, keep: int | None = None):
|
|
121
|
+
def fired(answers, threshold_value, request=None):
|
|
122
|
+
found = []
|
|
123
|
+
for qid in _ids(answers, prefix):
|
|
124
|
+
probability = _noul(answers, qid)
|
|
125
|
+
if probability is not None and probability >= threshold_value:
|
|
126
|
+
found.append((probability, qid))
|
|
127
|
+
# The site lists its warnings highest first; ties stay in question order.
|
|
128
|
+
found.sort(key=lambda item: (-item[0], _index(item[1])))
|
|
129
|
+
return [qid for _p, qid in found[:keep]]
|
|
130
|
+
return fired
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _fired_prompt(answers, threshold_value, request=None):
|
|
134
|
+
# `forge jev score-plan` warns BELOW prompt_warn: the probability is that a reviewer
|
|
135
|
+
# could judge the task from its text, and the site acts when it is too low.
|
|
136
|
+
probability = _noul(answers, 'prompt_adequacy')
|
|
137
|
+
return ['prompt_adequacy'] if probability is not None and probability < threshold_value else []
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _fired_slice(answers, threshold_value=None, request=None):
|
|
141
|
+
"""The lines relevant_lines keeps: the top SLICE_KEEP by p, an unscored line as 1.0,
|
|
142
|
+
ties by index; every line when it was asked about no more than SLICE_KEEP. The asked
|
|
143
|
+
lines are the `l<i>` ids of the request. None without it."""
|
|
144
|
+
if request is None:
|
|
145
|
+
return None
|
|
146
|
+
ids = _question_ids(request, 'l')
|
|
147
|
+
if len(ids) <= SLICE_KEEP:
|
|
148
|
+
return ids
|
|
149
|
+
scored = []
|
|
150
|
+
for qid in ids:
|
|
151
|
+
probability = _noul(answers, qid)
|
|
152
|
+
scored.append((1.0 if probability is None else probability, _index(qid), qid))
|
|
153
|
+
scored.sort(key=lambda item: (-item[0], item[1]))
|
|
154
|
+
return sorted((qid for _p, _i, qid in scored[:SLICE_KEEP]), key=_index)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _commands(request) -> list | None:
|
|
158
|
+
"""The candidates' commands in the order `runs_<i>` follows: the request's
|
|
159
|
+
state.candidates. The choice question's criteria are sorted when sent and the answer's
|
|
160
|
+
probability map follows them, so neither says which command `runs_<i>` is. None when
|
|
161
|
+
the caller has no stored body."""
|
|
162
|
+
if not isinstance(request, dict):
|
|
163
|
+
return None
|
|
164
|
+
candidates = _state(request).get('candidates')
|
|
165
|
+
if not isinstance(candidates, list):
|
|
166
|
+
return None
|
|
167
|
+
return [candidate.get('command') if isinstance(candidate, dict) else None for candidate in candidates]
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _fired_verify(answers, threshold_value, request=None):
|
|
171
|
+
"""The chosen candidate's runs_<i>, when 1 - P(none) >= tests_act and its runs_<i> Noul
|
|
172
|
+
is >= 0.5, as verify.discover gates it. Without a distribution it falls back to the
|
|
173
|
+
choice's own confidence, as discover does. None without the body: `runs_<i>` names a
|
|
174
|
+
candidate by its place in the request, which the answers do not record."""
|
|
175
|
+
commands = _commands(request)
|
|
176
|
+
if commands is None:
|
|
177
|
+
return None
|
|
178
|
+
answers = answers or {}
|
|
179
|
+
answer = answers.get('choice')
|
|
180
|
+
if not isinstance(answer, dict) or answer.get('type') != 'choice':
|
|
181
|
+
return []
|
|
182
|
+
picked = answer.get('choice')
|
|
183
|
+
if picked is None or picked == 'none':
|
|
184
|
+
return []
|
|
185
|
+
distribution = probabilities({'answers': answers}, 'choice')
|
|
186
|
+
if distribution:
|
|
187
|
+
if (1.0 - distribution.get('none', 0.0)) < threshold_value:
|
|
188
|
+
return []
|
|
189
|
+
elif (answer.get('confidence') or 0.0) < threshold_value:
|
|
190
|
+
return []
|
|
191
|
+
if picked not in commands:
|
|
192
|
+
return []
|
|
193
|
+
qid = f'runs_{commands.index(picked)}'
|
|
194
|
+
runs = _noul(answers, qid)
|
|
195
|
+
return [qid] if runs is not None and runs >= 0.5 else []
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
# --- decisions and scores ----------------------------------------------------------------
|
|
199
|
+
|
|
200
|
+
def _decisions_prefix(prefix: str):
|
|
201
|
+
return lambda body: _question_ids(body, prefix)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _decisions_prompt(body):
|
|
205
|
+
return ['prompt_adequacy'] if 'prompt_adequacy' in _asked(body) else []
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _score_noul(answers, qid, request=None):
|
|
209
|
+
return _noul(answers, qid)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def _score_inverted(answers, qid, request=None):
|
|
213
|
+
"""The probability of acting for a site whose model answers the other way round (prompt
|
|
214
|
+
adequacy): 1 - p. None while the answer is missing."""
|
|
215
|
+
probability = _noul(answers, qid)
|
|
216
|
+
return None if probability is None else 1.0 - probability
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _score_verify(answers, qid, request=None):
|
|
220
|
+
"""The choice distribution's probability of the candidate's command. None without the
|
|
221
|
+
body (see _fired_verify)."""
|
|
222
|
+
commands = _commands(request)
|
|
223
|
+
index = _index(qid)
|
|
224
|
+
if commands is None or not 0 <= index < len(commands) or commands[index] is None:
|
|
225
|
+
return None
|
|
226
|
+
return probabilities({'answers': answers or {}}, 'choice').get(commands[index])
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _decisions_verify(body):
|
|
230
|
+
"""One `runs_<i>` per candidate of the body."""
|
|
231
|
+
commands = _commands(body)
|
|
232
|
+
return [f'runs_{i}' for i in range(len(commands))] if commands is not None else _question_ids(body, 'runs_')
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# --- baselines ---------------------------------------------------------------------------
|
|
236
|
+
|
|
237
|
+
def _drift_file(body, qid) -> str:
|
|
238
|
+
found = _FILE.search(_instructions(body, qid))
|
|
239
|
+
return found.group('path') if found else ''
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def _baseline_drift(body, qid) -> float:
|
|
243
|
+
"""near(): same directory as a declared file +1, file stem in prompt+approach +2, full
|
|
244
|
+
path in that text +4."""
|
|
245
|
+
path = _drift_file(body, qid)
|
|
246
|
+
if not path:
|
|
247
|
+
return 0.0
|
|
248
|
+
state = _state(body)
|
|
249
|
+
task = state.get('task') if isinstance(state.get('task'), dict) else {}
|
|
250
|
+
declared = _files(task.get('declared_files'))
|
|
251
|
+
directories = {name.rsplit('/', 1)[0] for name in declared if '/' in name}
|
|
252
|
+
text = (str(state.get('prompt') or '') + str(state.get('approach') or '')).lower()
|
|
253
|
+
stem = path.split('/')[-1].split('.')[0].lower()
|
|
254
|
+
return float((path.rsplit('/', 1)[0] in directories) + 2 * (stem in text) + 4 * (path.lower() in text))
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def _baseline_slice(body, qid) -> float:
|
|
258
|
+
"""named(): 2 if the fact's [anchor] is in the task text, +1 if the anchor's directory is."""
|
|
259
|
+
state = _state(body)
|
|
260
|
+
facts = state.get('facts')
|
|
261
|
+
index = _index(qid)
|
|
262
|
+
if not isinstance(facts, list) or not 0 <= index < len(facts):
|
|
263
|
+
return 0.0
|
|
264
|
+
line = str(facts[index])
|
|
265
|
+
if '[' not in line:
|
|
266
|
+
return 0.0
|
|
267
|
+
anchor = line.rsplit('[', 1)[-1].split(']')[0]
|
|
268
|
+
if not anchor:
|
|
269
|
+
return 0.0
|
|
270
|
+
task = str(state.get('task') or '')
|
|
271
|
+
return float(2 * (anchor in task) + (anchor.rsplit('/', 1)[0] in task))
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def _baseline_verify(body, qid) -> float:
|
|
275
|
+
"""Candidate order: the first candidate scores highest."""
|
|
276
|
+
index = _index(qid)
|
|
277
|
+
count = len(_decisions_verify(body))
|
|
278
|
+
return float(count - index) if 0 <= index < count else 0.0
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def _baseline_forward(body, qid) -> float:
|
|
282
|
+
"""1 when a path in the earlier task's files appears in the later task's requirements."""
|
|
283
|
+
text = _instructions(body, qid)
|
|
284
|
+
earlier, later = _EARLIER.search(text), _LATER.search(text)
|
|
285
|
+
if not earlier or not later:
|
|
286
|
+
return 0.0
|
|
287
|
+
tasks = {str(task.get('id')): task for task in (_state(body).get('tasks') or []) if isinstance(task, dict)}
|
|
288
|
+
first, second = tasks.get(earlier.group('id')), tasks.get(later.group('id'))
|
|
289
|
+
if not first or not second:
|
|
290
|
+
return 0.0
|
|
291
|
+
requirements = str(second.get('requirements') or '')
|
|
292
|
+
return 1.0 if any(path in requirements for path in _files(first.get('files'))) else 0.0
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def _baseline_none(body, qid) -> float:
|
|
296
|
+
return 0.0
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@dataclass(frozen=True)
|
|
300
|
+
class Site:
|
|
301
|
+
name: str
|
|
302
|
+
gate: str
|
|
303
|
+
threshold: str | None
|
|
304
|
+
fired: Callable
|
|
305
|
+
decisions: Callable
|
|
306
|
+
score: Callable
|
|
307
|
+
label: str | None
|
|
308
|
+
baseline: Callable
|
|
309
|
+
floor: float | None = None
|
|
310
|
+
# The issue that will define the label, for a site that has none.
|
|
311
|
+
label_issue: str | None = None
|
|
312
|
+
# The raw probability points away from acting: score is 1 - p.
|
|
313
|
+
invert: bool = False
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def _site(name, threshold, fired, decisions, score, label, baseline, floor=None, label_issue=None,
|
|
317
|
+
invert=False):
|
|
318
|
+
return Site(name, SITE_GATE[name], threshold, fired, decisions, score, label, baseline, floor,
|
|
319
|
+
label_issue, invert)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _gate_module_site(name, module, threshold, label, label_issue=None, invert=False):
|
|
323
|
+
"""A site whose fired, decisions, score and baseline are its gate module's, lazily (see
|
|
324
|
+
_lazy). No floor: the new sites have none until their replay measures one."""
|
|
325
|
+
return _site(name, threshold, _lazy(module, 'fired', []), _lazy(module, 'decisions', []),
|
|
326
|
+
_lazy(module, 'score', None), label, _lazy(module, 'baseline', 0.0), label_issue=label_issue,
|
|
327
|
+
invert=invert)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# Both memory sites: the labels need a contradiction record, which does not exist yet.
|
|
331
|
+
_MEMORY_ISSUE = '#41: recurrence is influenced by the gate itself; needs independent contradiction evidence'
|
|
332
|
+
|
|
333
|
+
SITES: dict[str, Site] = {record.name: record for record in (
|
|
334
|
+
_site('jev-drift', 'drift_warn', _fired_at_least('f'), _decisions_prefix('f'), _score_noul,
|
|
335
|
+
"the file was edited by the task's final passing attempt (and was not declared)",
|
|
336
|
+
_baseline_drift, floor=0.5),
|
|
337
|
+
_site('jev-forward', 'forward_warn', _fired_at_least('f', MAX_WARNINGS), _decisions_prefix('f'),
|
|
338
|
+
_score_noul,
|
|
339
|
+
'a later plan revision of the same run added the dependency (true); both tasks merged '
|
|
340
|
+
'with no such dependency (false)',
|
|
341
|
+
_baseline_forward, floor=0.5),
|
|
342
|
+
_site('jev-prompt', 'prompt_warn', _fired_prompt, _decisions_prompt, _score_inverted,
|
|
343
|
+
'true when the prompt was inadequate: a later plan revision changed it before its first '
|
|
344
|
+
'attempt, or the first review called it ambiguous; false otherwise',
|
|
345
|
+
_baseline_none, invert=True),
|
|
346
|
+
_site('jev-memory-curate', None, _lazy('forge_jev.memory', 'fired_curate', []), lambda body: [],
|
|
347
|
+
_score_noul, None, _baseline_none, label_issue=_MEMORY_ISSUE),
|
|
348
|
+
_site('jev-memory-slice', None, _fired_slice, _decisions_prefix('l'), _score_noul,
|
|
349
|
+
"the fact's anchor was edited by the task (true), or lies in an area the task never "
|
|
350
|
+
'touched (false)',
|
|
351
|
+
_baseline_slice),
|
|
352
|
+
_site('jev-memory-stale', 'stale_drop', _lazy('forge_jev.memory', 'fired_stale', []),
|
|
353
|
+
lambda body: [], _score_noul, None, _baseline_none, label_issue=_MEMORY_ISSUE),
|
|
354
|
+
_site('jev-verify-discover', 'tests_act', _fired_verify, _decisions_verify, _score_verify,
|
|
355
|
+
'the candidate is the command the repo documents: `.forge/verify`, or the command a later '
|
|
356
|
+
'run of the same repo verified with, from `--verify` or `repo.verify` (command_source not '
|
|
357
|
+
'`jev`)',
|
|
358
|
+
_baseline_verify, floor=0.7),
|
|
359
|
+
_gate_module_site('jev-coverage', 'forge_jev.coverage', 'coverage_warn',
|
|
360
|
+
'true when a later plan revision added a task covering the requirement; false when '
|
|
361
|
+
'every task merged with no change to the acceptance criteria'),
|
|
362
|
+
_gate_module_site('jev-retry-addressed', 'forge_jev.addressed', 'untouched_warn',
|
|
363
|
+
'true when the review of the same attempt raised the finding again; false when that '
|
|
364
|
+
'review parsed without it'),
|
|
365
|
+
_gate_module_site('jev-dwarf-message', 'forge_jev.message', None,
|
|
366
|
+
"true when the same attempt's review failed; false when it passed"),
|
|
367
|
+
_gate_module_site('jev-attribution', 'forge_jev.attribution', None,
|
|
368
|
+
'true when verified prefixes show the merge breaks verification (prefix k−1 passes, '
|
|
369
|
+
'k fails); false when both were verified and do not'),
|
|
370
|
+
_gate_module_site('jev-findings', 'forge_jev.findings', 'findings_concrete', None,
|
|
371
|
+
label_issue='#46: needs issue-closure records', invert=True),
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def site(name: str) -> Site | None:
|
|
376
|
+
"""The record for a live site; None for an unknown or retired one (jev-score-plan)."""
|
|
377
|
+
return SITES.get(name)
|