@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
|
@@ -29,21 +29,24 @@ def _human(n: int) -> str:
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def _continued_sessions(db) -> dict:
|
|
32
|
-
"""How many dispatches asked to continue a
|
|
32
|
+
"""How many dispatches asked to continue a session: reviewers' and implementers' apart.
|
|
33
33
|
|
|
34
34
|
Counted from the dispatch events themselves. A shadow review is not required, and a
|
|
35
35
|
continue that failed still counts: the file was written because continuing was requested.
|
|
36
36
|
"""
|
|
37
|
-
|
|
37
|
+
counts = dict(continued_reviews=0, failed_continues=0,
|
|
38
|
+
continued_implementers=0, failed_implementer_continues=0)
|
|
38
39
|
for (raw,) in db.execute(
|
|
39
40
|
"SELECT data FROM events WHERE kind = 'dispatch' AND data LIKE ?",
|
|
40
41
|
('%"session_continue": "%',)):
|
|
41
|
-
|
|
42
|
+
data = json.loads(raw)
|
|
43
|
+
value = data.get('session_continue')
|
|
44
|
+
dwarf = data.get('role') == 'dwarf'
|
|
42
45
|
if value == 'continued':
|
|
43
|
-
|
|
46
|
+
counts['continued_implementers' if dwarf else 'continued_reviews'] += 1
|
|
44
47
|
elif value == 'failed':
|
|
45
|
-
|
|
46
|
-
return
|
|
48
|
+
counts['failed_implementer_continues' if dwarf else 'failed_continues'] += 1
|
|
49
|
+
return counts
|
|
47
50
|
|
|
48
51
|
|
|
49
52
|
def status(args) -> int:
|
|
@@ -99,6 +102,9 @@ def status(args) -> int:
|
|
|
99
102
|
if summary.get('continued_reviews') or summary.get('failed_continues'):
|
|
100
103
|
print(' continued reviews: %d' % summary['continued_reviews'])
|
|
101
104
|
print(' failed continues: %d' % summary['failed_continues'])
|
|
105
|
+
if summary.get('continued_implementers') or summary.get('failed_implementer_continues'):
|
|
106
|
+
print(' continued implementers: %d' % summary['continued_implementers'])
|
|
107
|
+
print(' failed implementer continues: %d' % summary['failed_implementer_continues'])
|
|
102
108
|
if summary['legacy_archives']:
|
|
103
109
|
print(' legacy: %d archived run dir(s) kept in %s (`forge dataset import %s` re-reads them;'
|
|
104
110
|
' events already stored are skipped)' % (summary['legacy_archives'], legacy, legacy))
|
|
@@ -32,12 +32,9 @@ import time
|
|
|
32
32
|
from collections import Counter, defaultdict
|
|
33
33
|
from pathlib import Path
|
|
34
34
|
|
|
35
|
-
from forge_jev import outcome
|
|
36
|
-
from forge_jev.features import task_size
|
|
37
|
-
from forge_jev.questions import first_pass, retry_pass # noqa: F401 shared with live forge
|
|
38
|
-
|
|
39
35
|
from . import SKILL, connect, data_home, read_blob
|
|
40
36
|
from .harvest import review_completeness
|
|
37
|
+
from .states import assemble, retry, siblings, task_size
|
|
41
38
|
|
|
42
39
|
SLICES = ('routing', 'retry', 'review', 'drift', 'citation', 'memory')
|
|
43
40
|
|
|
@@ -150,6 +147,37 @@ def declared_tier() -> dict:
|
|
|
150
147
|
'or state/concurrency, or the right approach is not obvious from the goal.'})
|
|
151
148
|
|
|
152
149
|
|
|
150
|
+
# Frozen: these strings are part of every exported routing and retry case.
|
|
151
|
+
|
|
152
|
+
def first_pass() -> dict:
|
|
153
|
+
return dict(type='noul', instructions=(
|
|
154
|
+
'This Forge task is dispatched to the model in state.dwarf, at the effort shown, in its '
|
|
155
|
+
'own worktree. An independent model (state.reviewer) then reviews the resulting diff '
|
|
156
|
+
'against the task. Will that FIRST attempt pass review, with no retry needed?'),
|
|
157
|
+
criteria={
|
|
158
|
+
'true': 'The task is within reach of this model at this effort on the first try: the '
|
|
159
|
+
'requirements are clear, the change is contained, and nothing in it is likely '
|
|
160
|
+
'to be missed or subtly wrong.',
|
|
161
|
+
'false': 'The first attempt is likely to fail review: the task has edge cases, '
|
|
162
|
+
'cross-cutting effects, unclear requirements or subtle state that a first '
|
|
163
|
+
'attempt by this model at this effort typically gets wrong, so a retry would '
|
|
164
|
+
'be needed.'})
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def retry_pass() -> dict:
|
|
168
|
+
return dict(type='noul', instructions=(
|
|
169
|
+
'An earlier attempt at this Forge task failed review. The task is now dispatched again, to '
|
|
170
|
+
'the model in state.dwarf at the effort shown, with that review\'s findings '
|
|
171
|
+
'(state.previous_review) to fix; state.attempt is which try this is, and the model in '
|
|
172
|
+
'state.reviewer reviews the result. Will this attempt pass review?'),
|
|
173
|
+
criteria={
|
|
174
|
+
'true': 'The findings are specific and fixable, and this model at this effort can address '
|
|
175
|
+
'them without breaking something else: the retry is likely to pass.',
|
|
176
|
+
'false': 'The findings point at a design problem, an unclear requirement or a recurring '
|
|
177
|
+
'mistake that another attempt by this model at this effort is likely to repeat: '
|
|
178
|
+
'the retry is likely to fail again and should be escalated or rethought.'})
|
|
179
|
+
|
|
180
|
+
|
|
153
181
|
def review_passes() -> dict:
|
|
154
182
|
return dict(type='noul', instructions=(
|
|
155
183
|
'A diff is about to be reviewed for correctness by an independent model that did not '
|
|
@@ -233,20 +261,6 @@ class Runs:
|
|
|
233
261
|
held = self.survival.get(d['reviewed'])
|
|
234
262
|
if held is None or d['horizon_days'] > held['horizon_days']:
|
|
235
263
|
self.survival[d['reviewed']] = d
|
|
236
|
-
# Live Clef predictions (forge_jev/predict.py), recorded before the attempt they are
|
|
237
|
-
# about: {(run, task, attempt): [(ts, p, model, assignment)]}, oldest first.
|
|
238
|
-
self.clef = defaultdict(list)
|
|
239
|
-
for e in sorted(store.of('jev'), key=lambda e: e['ts']):
|
|
240
|
-
d = e['d']
|
|
241
|
-
site = d.get('site')
|
|
242
|
-
if site not in ('clef-first-pass', 'clef-retry-pass') or not d.get('ok'):
|
|
243
|
-
continue
|
|
244
|
-
qid = 'first_pass' if site == 'clef-first-pass' else 'retry_pass'
|
|
245
|
-
p = ((d.get('answers') or {}).get(qid) or {}).get('noul')
|
|
246
|
-
n = d.get('intended_attempt') if site == 'clef-first-pass' else d.get('attempt')
|
|
247
|
-
if isinstance(p, (int, float)) and n:
|
|
248
|
-
self.clef[(e['run'], e['task'] or d.get('task'), int(n))].append(
|
|
249
|
-
(e['ts'], float(p), d.get('model'), d.get('assignment') or {}))
|
|
250
264
|
self.integrate_verification = {}
|
|
251
265
|
for e in sorted(store.of('verification'), key=lambda e: e['ts']):
|
|
252
266
|
if e['d'].get('scope') == 'integrate' and e['d'].get('status'):
|
|
@@ -308,7 +322,7 @@ def _file_excerpts(store: Store, plan, files) -> dict:
|
|
|
308
322
|
|
|
309
323
|
|
|
310
324
|
def _siblings(plan, task_id) -> list:
|
|
311
|
-
return
|
|
325
|
+
return siblings([dict(row, id=tid) for tid, row in (plan['d'].get('tasks') or {}).items()], task_id)
|
|
312
326
|
|
|
313
327
|
|
|
314
328
|
def _attempts(runs: Runs, run, task, rows) -> list:
|
|
@@ -358,6 +372,12 @@ def _verdicts(runs: Runs, run, task) -> dict:
|
|
|
358
372
|
return out
|
|
359
373
|
|
|
360
374
|
|
|
375
|
+
def _gate_decision(line) -> str | None:
|
|
376
|
+
"""The decision cell of a `qa.gate` line (`thr<TAB>decision<TAB>...`), None when absent or unknown."""
|
|
377
|
+
cells = (line or '').split('\t')
|
|
378
|
+
return cells[1] if len(cells) > 1 and cells[1] in ('accept', 'fail', 'keep') else None
|
|
379
|
+
|
|
380
|
+
|
|
361
381
|
def _course(runs: Runs, run, task, attempts) -> dict:
|
|
362
382
|
"""How the task went, for meta: what a single first-pass bit leaves out."""
|
|
363
383
|
raw = _verdicts(runs, run, task)
|
|
@@ -374,7 +394,9 @@ def _course(runs: Runs, run, task, attempts) -> dict:
|
|
|
374
394
|
stop = 'interrupted'
|
|
375
395
|
else:
|
|
376
396
|
stop = 'no_pass_observed'
|
|
397
|
+
gate = _gate_decision(attempts[0]['events'][-1]['d'].get('gate')) if attempts else None
|
|
377
398
|
return dict(attempts_observed=len(attempts), raw_verdict=raw.get(first),
|
|
399
|
+
gate_fail=gate == 'fail',
|
|
378
400
|
gate_pass=bool(attempts) and attempts[0]['events'][-1]['d'].get('status') == 'PASS'
|
|
379
401
|
and raw.get(first) == 'FAIL',
|
|
380
402
|
first_raw_pass_attempt=min((n for n, v in raw.items() if v == 'PASS'), default=None),
|
|
@@ -398,7 +420,7 @@ def _task_state(runs: Runs, run, task, attempt):
|
|
|
398
420
|
return None, None, None
|
|
399
421
|
dwarf = runs.resolved(run, task, 'dwarf', attempt['attempt']) or _spec(attempt['d'].get('dwarf'))
|
|
400
422
|
reviewer = runs.resolved(run, task, 'qa', attempt['attempt']) or _spec(attempt['d'].get('qa'))
|
|
401
|
-
state =
|
|
423
|
+
state = assemble(
|
|
402
424
|
goal=store.text((plan['d'].get('blobs') or {}).get('goal')) or plan['d'].get('goal') or '',
|
|
403
425
|
task_id=task, title=row.get('title', ''), files=row.get('files', ''), deps=row.get('deps', ''),
|
|
404
426
|
prompt=prompt, approach=store.text(row.get('approach')), plan_tasks=_siblings(plan, task),
|
|
@@ -452,12 +474,6 @@ def routing_cases(runs: Runs):
|
|
|
452
474
|
if declared in ('low', 'medium', 'high'):
|
|
453
475
|
baseline.setdefault('first_pass_declared', dict(source='declared difficulty', risk=
|
|
454
476
|
dict(low=0.0, medium=0.5, high=1.0)[declared]))
|
|
455
|
-
live = _clef_before(runs, run, task, 1, first['d'].get('wall_started') or first['ts'])
|
|
456
|
-
if live:
|
|
457
|
-
# Followed: attempt 1 ran the dwarf the prediction was about. A gate edit or a
|
|
458
|
-
# `retry --dwarf` in between makes it a prediction about a model that never ran.
|
|
459
|
-
baseline['first_pass_clef'] = dict(source='live clef first-pass', p=live[1], model=live[2],
|
|
460
|
-
followed=live[3].get('dwarf') == first['d'].get('dwarf'))
|
|
461
477
|
yield dict(slice='routing', key=(run, task), run=run, repo=first['repo'], task=task,
|
|
462
478
|
state=state, questions=questions, expected=expected, baseline=baseline,
|
|
463
479
|
label_source=dict(first_pass='final status of the first real attempt',
|
|
@@ -531,30 +547,14 @@ def retry_cases(runs: Runs):
|
|
|
531
547
|
state, _row, plan = _task_state(runs, run, task, start)
|
|
532
548
|
if state is None:
|
|
533
549
|
continue
|
|
534
|
-
state =
|
|
550
|
+
state = retry(state, attempt=a['n'], previous_review=findings)
|
|
535
551
|
yield dict(slice='retry', key=(run, task, a['n']), run=run, repo=start['repo'], task=task,
|
|
536
552
|
state=state, questions=dict(retry_pass=retry_pass()),
|
|
537
|
-
expected=dict(retry_pass=a['outcome']), baseline=
|
|
553
|
+
expected=dict(retry_pass=a['outcome']), baseline={},
|
|
538
554
|
label_source=dict(retry_pass='final status of this retry attempt'),
|
|
539
555
|
dwarf=state['dwarf'].get('model'), meta=_meta(runs, run, plan, a['events'][-1]))
|
|
540
556
|
|
|
541
557
|
|
|
542
|
-
def _clef_before(runs: Runs, run, task, attempt, started):
|
|
543
|
-
"""The last plan-time Clef prediction about attempt 1 made before it started, or None."""
|
|
544
|
-
found = None
|
|
545
|
-
for item in runs.clef.get((run, task, attempt), []):
|
|
546
|
-
if item[0] <= (started or 0):
|
|
547
|
-
found = item
|
|
548
|
-
return found
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
def _retry_baseline(runs: Runs, run, task, n) -> dict:
|
|
552
|
-
"""The Clef prediction about retry attempt n. It is made once, as the attempt begins
|
|
553
|
-
(after its receipt opened, so not timed against it): the attempt number is the join."""
|
|
554
|
-
live = (runs.clef.get((run, task, n)) or [None])[0]
|
|
555
|
-
return dict(retry_pass_clef=dict(source='live clef retry-pass', p=live[1], model=live[2])) if live else {}
|
|
556
|
-
|
|
557
|
-
|
|
558
558
|
def _float(value):
|
|
559
559
|
try:
|
|
560
560
|
return float(value)
|
|
@@ -571,6 +571,21 @@ def session_continued(event) -> bool:
|
|
|
571
571
|
return (event.get('d') or {}).get('session_continue') is not None
|
|
572
572
|
|
|
573
573
|
|
|
574
|
+
def _ending_qa(rows) -> dict:
|
|
575
|
+
"""Index, per attempt, of the last primary dispatch with a PASS or FAIL verdict.
|
|
576
|
+
|
|
577
|
+
`rows` is the chronological list `runs.dispatches[(run, task, 'qa')]`. The choice is
|
|
578
|
+
made before continued sessions are removed: the dispatch the attempt ended on may have
|
|
579
|
+
continued a reviewer session, and an earlier fresh verdict must not stand in for it.
|
|
580
|
+
Same choice as `shadow_pairs`.
|
|
581
|
+
"""
|
|
582
|
+
ending = {}
|
|
583
|
+
for index, event in enumerate(rows):
|
|
584
|
+
if (event.get('d') or {}).get('verdict') in ('PASS', 'FAIL'):
|
|
585
|
+
ending[event['attempt']] = index
|
|
586
|
+
return ending
|
|
587
|
+
|
|
588
|
+
|
|
574
589
|
def _qa_rows(runs: Runs):
|
|
575
590
|
"""Every independent QA dispatch with a verdict, with the diff it was shown and its task text.
|
|
576
591
|
|
|
@@ -578,11 +593,18 @@ def _qa_rows(runs: Runs):
|
|
|
578
593
|
one whose continue failed after it had already printed a verdict. A fresh fallback in
|
|
579
594
|
the same round has no `session_continue` and stays. There is no switch to put the
|
|
580
595
|
continued ones back, so a slice never mixes the two.
|
|
596
|
+
|
|
597
|
+
The attempt event's gate belongs to the QA execution the attempt ended on (see
|
|
598
|
+
`_ending_qa`). Every earlier dispatch of that attempt gets `gate=None`. When the one
|
|
599
|
+
the attempt ended on continued a session, it is skipped below, so no row of the
|
|
600
|
+
attempt carries the gate.
|
|
581
601
|
"""
|
|
582
602
|
store = runs.store
|
|
583
603
|
effort = {}
|
|
604
|
+
gates = {}
|
|
584
605
|
for (run, task), rows in runs.attempts.items():
|
|
585
606
|
for e in rows:
|
|
607
|
+
gates[(run, task, e['attempt'])] = _gate_decision(e['d'].get('gate'))
|
|
586
608
|
text = store.text((e['d'].get('blobs') or {}).get('qa_effort_jev'))
|
|
587
609
|
if text.strip():
|
|
588
610
|
word, _, conf = text.strip().partition('\t')
|
|
@@ -590,7 +612,8 @@ def _qa_rows(runs: Runs):
|
|
|
590
612
|
for (run, task, role), rows in runs.dispatches.items():
|
|
591
613
|
if role != 'qa':
|
|
592
614
|
continue
|
|
593
|
-
|
|
615
|
+
ending = _ending_qa(rows)
|
|
616
|
+
for index, e in enumerate(rows):
|
|
594
617
|
if session_continued(e):
|
|
595
618
|
continue
|
|
596
619
|
d = e['d']
|
|
@@ -601,14 +624,24 @@ def _qa_rows(runs: Runs):
|
|
|
601
624
|
if not blocks or not blocks[-1].strip():
|
|
602
625
|
continue
|
|
603
626
|
found = d.get('findings') or []
|
|
627
|
+
# Only the dispatch the attempt ended on was gated. An earlier one in the same
|
|
628
|
+
# attempt (a QA-only re-run keeps the number) was never the gate's input.
|
|
629
|
+
gate = gates.get((run, task, e['attempt'])) if ending.get(e['attempt']) == index else None
|
|
604
630
|
yield dict(run=run, task=task, attempt=e['attempt'], repo=e['repo'], verdict=d['verdict'],
|
|
631
|
+
gate=gate,
|
|
605
632
|
diff=blocks[-1], review=store.text((d.get('blobs') or {}).get('message')),
|
|
606
633
|
effort=effort.get((run, task, e['attempt'])), model=d.get('model'),
|
|
607
634
|
reviewer=dict(model=d.get('model'), effort=d.get('effort'), harness=d.get('harness')),
|
|
608
635
|
# Receipts from before findings_parse existed: an empty list then cannot
|
|
609
636
|
# tell a clean review from a parser failure, which was rare; read it as clean.
|
|
610
637
|
completeness=d.get('findings_parse') or review_completeness(d['verdict'], found),
|
|
611
|
-
worst=_worst(found)
|
|
638
|
+
worst=_worst(found),
|
|
639
|
+
# The dispatch this row was built from. A shadow pair names that event,
|
|
640
|
+
# so an earlier execution of the same attempt cannot claim it.
|
|
641
|
+
dispatch=e,
|
|
642
|
+
# Its place in the task's chronological QA dispatches: a split review
|
|
643
|
+
# case is keyed by it, never by the order rows come out of the store.
|
|
644
|
+
execution=index)
|
|
612
645
|
|
|
613
646
|
|
|
614
647
|
def _worst(found) -> str:
|
|
@@ -691,44 +724,60 @@ def review_cases(runs: Runs):
|
|
|
691
724
|
if len(verdicts) != 1:
|
|
692
725
|
# Two reviews of the same diff disagreed: the label is noise, not an outcome.
|
|
693
726
|
continue
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
#
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
727
|
+
# Same verdict on one diff stays one case, separate runs that met the same diff
|
|
728
|
+
# included. Only the executions of one attempt split, when forge gated them
|
|
729
|
+
# differently: the first row's gate must not hide the one the attempt ended on.
|
|
730
|
+
gates = defaultdict(set)
|
|
731
|
+
for item, _ in items:
|
|
732
|
+
gates[(item['run'], item['task'], item['attempt'])].add(item['gate'])
|
|
733
|
+
split = any(len(g) > 1 for g in gates.values())
|
|
734
|
+
exported = items if split else [items[0]]
|
|
735
|
+
for r, task in exported:
|
|
736
|
+
cohort = [(r, task)] if split else items
|
|
737
|
+
diff = r['diff']
|
|
738
|
+
# Who reviews decides the outcome as much as the diff: the same diff meets a 0.93 pass rate
|
|
739
|
+
# from one reviewer and 0.39 from another, so the reviewer is part of the state.
|
|
740
|
+
state = dict(diff=diff[:DIFF_CHARS], task=task, truncated=len(diff) > DIFF_CHARS, reviewer=r['reviewer'])
|
|
741
|
+
baseline = {}
|
|
742
|
+
if r['effort'] and r['effort'][0] in EFFORT_RANK:
|
|
743
|
+
baseline['passes'] = dict(source='hosted-jev qa effort', risk=EFFORT_RANK[r['effort'][0]] / 4.0)
|
|
744
|
+
questions, expected = dict(passes=review_passes()), dict(passes=r['verdict'] == 'PASS')
|
|
745
|
+
label_source = dict(passes='QA verdict')
|
|
746
|
+
# A graded label only where every review of this diff agrees. The gate split
|
|
747
|
+
# exports each execution, but severity stays a property of the whole group:
|
|
748
|
+
# a clean PASS beside a PASS that lists a confirmed P2 disagree, so neither
|
|
749
|
+
# case is graded. Skipping an unreadable review keeps "none" honest.
|
|
750
|
+
if all(item['completeness'] in ('clean', 'graded') for item, _ in items) and \
|
|
751
|
+
len({item['worst'] for item, _ in items}) == 1:
|
|
752
|
+
questions['severity'], expected['severity'] = review_severity(), r['worst']
|
|
753
|
+
label_source['severity'] = 'worst CONFIRMED finding (%s)' % r['completeness']
|
|
754
|
+
meta = dict(completeness=r['completeness'], gate=r['gate'])
|
|
755
|
+
# A second reviewer of the same diff, never consulted by the run: agreement is how
|
|
756
|
+
# much of this label is the diff and how much is who happened to review it.
|
|
757
|
+
# shadow_pairs binds that comparison to the dispatch the attempt ended on. A gate
|
|
758
|
+
# split exports every execution; only the cohort that contains that dispatch may
|
|
759
|
+
# carry it, or an earlier review of the same attempt would count the pair too.
|
|
760
|
+
paired = next((shadows[k] for k in dict.fromkeys((i['run'], i['task'], i['attempt']) for i, _ in cohort)
|
|
761
|
+
if k in shadows and any(item.get('dispatch') is shadows[k][0] for item, _ in cohort)), None)
|
|
762
|
+
if paired:
|
|
763
|
+
primary, shadow = paired
|
|
764
|
+
meta['shadow'] = dict(verdict=shadow['d']['verdict'], reviewer=shadow['d'].get('model'),
|
|
765
|
+
worst=_worst(shadow['d'].get('findings') or []))
|
|
766
|
+
meta['consensus'] = shadow['d']['verdict'] == primary['d']['verdict']
|
|
767
|
+
# The one label here no reviewer decides: whether the merged diff's lines stayed.
|
|
768
|
+
landed = next((runs.survival[c] for c in (runs.reviewed.get((i['run'], i['task'], i['attempt']))
|
|
769
|
+
for i, _ in cohort) if c in runs.survival), None)
|
|
770
|
+
if landed:
|
|
771
|
+
kept = landed['surviving'] / landed['added']
|
|
772
|
+
questions['survives'] = review_survives()
|
|
773
|
+
expected['survives'] = kept >= SURVIVES_AT and not landed.get('reverted_by')
|
|
774
|
+
label_source['survives'] = 'git blame %d days after integrate' % landed['horizon_days']
|
|
775
|
+
meta['survival'] = dict(added=landed['added'], surviving=landed['surviving'],
|
|
776
|
+
reverted_by=landed.get('reverted_by') or [], horizon_days=landed['horizon_days'])
|
|
777
|
+
yield dict(slice='review', key=key if not split else _sha(key, r['run'], r['task'], r['attempt'], r['execution']),
|
|
778
|
+
run=r['run'], repo=r['repo'], task=r['task'], state=state,
|
|
779
|
+
questions=questions, expected=expected, baseline=baseline, label_source=label_source,
|
|
780
|
+
reviewer=r['model'], meta=meta)
|
|
732
781
|
|
|
733
782
|
|
|
734
783
|
_SKIP_PREFIXES = ('.git/', '.forge/', 'node_modules/', 'vendor/', 'target/', 'dist/',
|
|
@@ -939,6 +988,13 @@ def memory_cases(runs: Runs, rng_seed: int):
|
|
|
939
988
|
'or in an area it never touched (false)'))
|
|
940
989
|
|
|
941
990
|
|
|
991
|
+
# The joins forge_decide.labels reuses to label live requests the same way.
|
|
992
|
+
final_pass = _final_pass
|
|
993
|
+
area = _area
|
|
994
|
+
words = _words
|
|
995
|
+
ANCHOR = _ANCHOR
|
|
996
|
+
|
|
997
|
+
|
|
942
998
|
# --- sampling and output ---------------------------------------------------------------
|
|
943
999
|
|
|
944
1000
|
def _sample(cases: list, limit: int | None, seed: int) -> list:
|
|
@@ -30,7 +30,8 @@ PIPELINE_ROLES = ('task', 'solo', 'verification', 'parallel')
|
|
|
30
30
|
TASKS_COLS = ('id', 'deps', 'difficulty', 'files', 'dwarf', 'qa', 'title')
|
|
31
31
|
STRUCTURED = ('codex', 'claude', 'openclaude', 'grok', 'opencode') # as forge-runtime.py's: .last is the message, not the log
|
|
32
32
|
# Plan files that change what a plan decides, added to its rid only when present (see plan_event).
|
|
33
|
-
PLAN_RID_LATER = ('decompose_level', 'shadow_qa', 'shadow_rate', 'explore', 'reviewer_session'
|
|
33
|
+
PLAN_RID_LATER = ('decompose_level', 'shadow_qa', 'shadow_rate', 'explore', 'reviewer_session',
|
|
34
|
+
'implementer_session', 'pre_review_tests')
|
|
34
35
|
|
|
35
36
|
# Files a task or solo execution may write. begin() snapshots their signatures so
|
|
36
37
|
# finish() can tell this execution's outputs from what an earlier one left behind.
|
|
@@ -44,8 +45,12 @@ WATCHED = (
|
|
|
44
45
|
'verification.retry.log', 'verification.flaky', 'verification.coverage.txt',
|
|
45
46
|
'verification.jev.json', 'verification.runs.tsv', 'verification.commit', 'verification.fingerprint',
|
|
46
47
|
'verification.lanes.json', 'results.tsv',
|
|
48
|
+
'prereview.failed', 'bounced', 'message.failed', 'needs_input.md',
|
|
47
49
|
)
|
|
48
50
|
|
|
51
|
+
# The markers of an attempt forge sent back without a review, and the kind each one records.
|
|
52
|
+
SENT_BACK = (('prereview.failed', 'prereview'), ('bounced', 'bounce'), ('message.failed', 'message'))
|
|
53
|
+
|
|
49
54
|
_VERDICT = re.compile(r'^FORGE_VERDICT: (PASS|FAIL)([ \t]+(—|–|-)( .*)?)?[ \t]*$')
|
|
50
55
|
_LEARNING = re.compile(r'^\s*FORGE_LEARNING:\s*(.+)$')
|
|
51
56
|
|
|
@@ -481,6 +486,8 @@ def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') ->
|
|
|
481
486
|
drift=(text(tdir / 'drift.txt') or '').split() if made('drift.txt') else [],
|
|
482
487
|
guard=(text(tdir / 'guard.txt') or '').splitlines() if made('guard.txt') else [],
|
|
483
488
|
noretry=made('noretry'), gate=gate, infra=infra or None,
|
|
489
|
+
sent_back=next((kind for marker, kind in SENT_BACK if made(marker)), None),
|
|
490
|
+
retry_source=first_line(tdir / 'retry_findings.source'),
|
|
484
491
|
identical_retry=bool(diff) and made('changes.prev.diff') and diff == text(tdir / 'changes.prev.diff'),
|
|
485
492
|
produced=sorted(n for n in WATCHED if made(n)),
|
|
486
493
|
carried=sorted(n for n in WATCHED if (tdir / n).exists() and not made(n)),
|
|
@@ -508,6 +515,16 @@ def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') ->
|
|
|
508
515
|
attempt=number, parent=prov.get('parent'), inv=prov.get('inv'), data=data)
|
|
509
516
|
|
|
510
517
|
|
|
518
|
+
def effective_threshold(plan: Path):
|
|
519
|
+
"""The blocking threshold a plan ran with and whether the plan set it: file, else the default."""
|
|
520
|
+
value = (first_line(plan / 'qa_threshold') or '').strip().upper() if (plan / 'qa_threshold').exists() else ''
|
|
521
|
+
if value == 'NONE':
|
|
522
|
+
value = 'P3'
|
|
523
|
+
if value in ('P0', 'P1', 'P2', 'P3'):
|
|
524
|
+
return value, 'set'
|
|
525
|
+
return contract().DEFAULT_THRESHOLD, 'default'
|
|
526
|
+
|
|
527
|
+
|
|
511
528
|
def solo_event(attempt: Path, run: Path, rc, prov: dict, src: str = 'live') -> dict:
|
|
512
529
|
before = prov.get('files')
|
|
513
530
|
made = lambda name: produced(run, before, name)
|
|
@@ -521,6 +538,7 @@ def solo_event(attempt: Path, run: Path, rc, prov: dict, src: str = 'live') -> d
|
|
|
521
538
|
guard=(text(run / 'guard.txt') or '').splitlines() if made('guard.txt') else [],
|
|
522
539
|
start_tree=first_line(run / 'start.tree') if made('start.tree') else None,
|
|
523
540
|
reviewed_tree=first_line(run / 'reviewed.tree') if made('reviewed.tree') else None,
|
|
541
|
+
gate=first_line(run / 'qa.gate') if made('qa.gate') else None,
|
|
524
542
|
produced=sorted(n for n in WATCHED if made(n)), children=children(run, attempt.name),
|
|
525
543
|
**(diff_summary(diff) if diff is not None else dict(changed_files=[], numstat={}, binary=[], patch_key=None)),
|
|
526
544
|
)
|
|
@@ -531,6 +549,7 @@ def solo_event(attempt: Path, run: Path, rc, prov: dict, src: str = 'live') -> d
|
|
|
531
549
|
request=put_file(run / 'request.md', 'prompt'),
|
|
532
550
|
dwarf_memory=put_file(run / 'dwarf.memory') if made('dwarf.memory') else None,
|
|
533
551
|
qa_memory=put_file(run / 'qa.memory') if made('qa.memory') else None,
|
|
552
|
+
known_issues=put_file(run / 'known_issues.md') if made('known_issues.md') else None,
|
|
534
553
|
)
|
|
535
554
|
return dict(rid=attempt.name, kind='attempt', ts=prov.get('wall_ended') or time.time(), src=src,
|
|
536
555
|
run=prov.get('run'), run_id=prov.get('run_id'), mode='solo', task=None, attempt=number,
|
|
@@ -685,9 +704,14 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
685
704
|
routes = {tid: [d.get('decision') for d in r['route']] for tid, r in per_task.items() if r.get('route')}
|
|
686
705
|
if routes:
|
|
687
706
|
later['route'] = routes
|
|
707
|
+
# PLAN_RID_LATER hashes a file's first line, which is `{` for any JSON record: hash the content.
|
|
708
|
+
plan_gates = read_json(plan / 'plan-gates.json')
|
|
709
|
+
if plan_gates is not None:
|
|
710
|
+
later['plan_gates'] = plan_gates
|
|
688
711
|
inputs = json.dumps([text(plan / 'goal.txt'), text(plan / 'tasks.tsv'), text(declared_path),
|
|
689
712
|
{t: [r['prompt'], r['approach']] for t, r in per_task.items()}] + ([later] if later else []),
|
|
690
713
|
sort_keys=True, default=str)
|
|
714
|
+
threshold, threshold_source = effective_threshold(plan)
|
|
691
715
|
snapshot_excerpts = decision_snapshot(repo, rows, head) if repo else None
|
|
692
716
|
listing = _git(repo, 'ls-tree', '-r', '--name-only', head) if inventory and repo and head else None
|
|
693
717
|
data = dict(
|
|
@@ -698,10 +722,12 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
698
722
|
pools=read_json(plan / 'fractal-routing.json'), jev_selection=read_json(plan / 'jev-selection.json'),
|
|
699
723
|
fractal_selection=read_json(plan / 'fractal-selection.json'),
|
|
700
724
|
jev_coupling=read_json(plan / 'jev-coupling.json'),
|
|
701
|
-
options={name: first_line(plan / name) for name in ('
|
|
702
|
-
'shadow_qa', 'shadow_rate', 'explore', 'reviewer_session'
|
|
703
|
-
|
|
704
|
-
|
|
725
|
+
options=dict({name: first_line(plan / name) for name in ('verify_retries', 'timeout', 'final_qa',
|
|
726
|
+
'shadow_qa', 'shadow_rate', 'explore', 'reviewer_session',
|
|
727
|
+
'implementer_session')
|
|
728
|
+
if (plan / name).exists()}, qa_threshold=threshold, qa_threshold_source=threshold_source),
|
|
729
|
+
flags=sorted(name for name in ('no_memory', 'no_ripwire', 'yolo_dwarf', 'yolo_qa', 'pre_review_tests')
|
|
730
|
+
if (plan / name).exists()),
|
|
705
731
|
blobs=blobs(goal=put_file(plan / 'goal.txt'), request=put_file(plan / 'request.md', 'prompt'),
|
|
706
732
|
tasks=put_file(plan / 'tasks.tsv'), tasks_declared=put_file(declared_path),
|
|
707
733
|
jev_routing=put_file(plan / 'jev-routing.tsv'),
|
|
@@ -709,6 +735,8 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
709
735
|
inventory=put_blob(listing, 'request') if listing else None,
|
|
710
736
|
memory=put_file(Path(repo) / '.forge' / 'memory.md') if repo else None),
|
|
711
737
|
)
|
|
738
|
+
if plan_gates is not None:
|
|
739
|
+
data['plan_gates'] = plan_gates
|
|
712
740
|
return dict(rid='plan:%s:%s' % (prov.get('run'), sha256(inputs.encode())[:16]), kind='plan',
|
|
713
741
|
ts=time.time(), src=src, run=prov.get('run'), run_id=prov.get('run_id'), mode='parallel',
|
|
714
742
|
inv=prov.get('inv'), data=data)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""State assemblers for the dataset export's routing and retry slices.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
the state it answers in production cannot drift apart in shape. Pure: no file reads.
|
|
3
|
+
`siblings`, `assemble` and `retry` build the state of those slices from events the
|
|
4
|
+
export has already read. `task_size` is the size block on that state. This only caps
|
|
5
|
+
and arranges what callers pass in. Pure: no file reads.
|
|
7
6
|
|
|
8
|
-
The caps are the export's (`forge dataset export`)
|
|
9
|
-
|
|
7
|
+
The caps are the export's (`forge dataset export`): goal and prompt are not cut.
|
|
8
|
+
|
|
9
|
+
A task's size is the strongest regime signal in forge's run history: the median prompt of
|
|
10
|
+
the newest runs is twice the older ones' and their first-pass rate is half. A model reading
|
|
11
|
+
prose and a 40-entry sibling list can only estimate that, so the state spells it out.
|
|
10
12
|
"""
|
|
11
13
|
from __future__ import annotations
|
|
12
14
|
|
|
@@ -47,3 +49,15 @@ def retry(state: dict, *, attempt: int, previous_review: str) -> dict:
|
|
|
47
49
|
review = previous_review or ''
|
|
48
50
|
return dict(state, attempt=attempt, previous_review=review[:REVIEW_CHARS],
|
|
49
51
|
previous_review_truncated=len(review) > REVIEW_CHARS)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _count(value) -> int:
|
|
55
|
+
if isinstance(value, (list, tuple)):
|
|
56
|
+
return len([v for v in value if v])
|
|
57
|
+
return len([w for w in str(value or '').replace(',', ' ').split() if w and w != '-'])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def task_size(*, prompt: str, declared_files, plan_tasks: int, deps, decompose_level: str | None) -> dict:
|
|
61
|
+
return dict(prompt_chars=len(prompt or ''), declared_files=_count(declared_files),
|
|
62
|
+
plan_tasks=int(plan_tasks), deps=_count(deps),
|
|
63
|
+
decompose_level=decompose_level if decompose_level in ('low', 'medium', 'high') else None)
|