@giamme/forge 0.16.0 → 0.17.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.
- package/CHANGELOG.md +19 -0
- package/VERSION +1 -1
- package/docs/dataset.md +8 -0
- package/docs/reviews.md +15 -1
- package/package.json +1 -1
- package/references/dataset.md +124 -5
- package/references/decision-models.md +15 -2
- package/references/decompose.md +46 -10
- package/references/planning.md +3 -2
- package/scripts/forge-contract.py +52 -1
- package/scripts/forge-issues.py +4 -3
- package/scripts/forge-ledger.py +3 -1
- package/scripts/forge-lib-adopt.sh +7 -1
- package/scripts/forge-metrics.sh +22 -0
- package/scripts/forge-parallel.sh +3 -1
- package/scripts/forge-plan-check.py +25 -2
- package/scripts/forge-planner.py +20 -6
- package/scripts/forge-shadow.py +28 -9
- package/scripts/forge-sweep.py +25 -10
- package/scripts/forge_dataset/cli.py +83 -0
- package/scripts/forge_dataset/facts.py +278 -0
- package/scripts/forge_dataset/harvest.py +16 -3
- package/scripts/forge_dataset/outcomes.py +206 -58
- package/scripts/forge_dataset/pairs.py +174 -0
- package/scripts/forge_dataset/risk.py +108 -0
- package/scripts/forge_dataset/tiers.py +427 -0
- package/scripts/forge_decide/cli.py +23 -2
- package/scripts/forge_decide/labels.py +30 -6
- package/scripts/forge_decide/replay.py +10 -4
- package/ui/docs/api.md +12 -3
- package/ui/forge_ui/export.py +9 -2
- package/ui/forge_ui/findings.py +4 -2
- package/ui/forge_ui/reader.py +71 -4
- package/ui/forge_ui/server.py +8 -0
- package/ui/forge_ui/static/app.js +6 -1
- package/ui/forge_ui/static/diffview.js +7 -3
- package/ui/forge_ui/static/panel.js +43 -2
- package/ui/forge_ui/static/style.css +1 -0
|
@@ -655,7 +655,27 @@ def _rollback(plan: Path, original: bytes, moved: list, made_pre: bool, replaced
|
|
|
655
655
|
pre.rmdir()
|
|
656
656
|
|
|
657
657
|
|
|
658
|
-
|
|
658
|
+
RISK_RANK = {'low': 0, 'medium': 1, 'high': 2}
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def read_risk(path: Path):
|
|
662
|
+
"""A task's recorded risk (#122): the first word of tasks/<id>/risk when it is low, medium or high, else None."""
|
|
663
|
+
try:
|
|
664
|
+
words = (_read_task_file(path) or '').split()
|
|
665
|
+
except PlanShapeError: # a label nothing routes on never stops a collapse
|
|
666
|
+
return None
|
|
667
|
+
return words[0] if words and words[0] in RISK_RANK else None
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
def combined_risk(risks: list):
|
|
671
|
+
"""The highest risk of the parts when every part was rated, else None: an unrated part could be the riskiest."""
|
|
672
|
+
if not risks or any(risk is None for risk in risks):
|
|
673
|
+
return None
|
|
674
|
+
return max(risks, key=RISK_RANK.get)
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
def commit_collapse(plan: Path, original: bytes, rows: list, row: dict, prompt: str, approach, info: dict,
|
|
678
|
+
risk=None) -> None:
|
|
659
679
|
"""Move the chain aside and write the combined task. A failure restores the plan."""
|
|
660
680
|
moved, made_pre, replaced, made_combined = [], False, False, False
|
|
661
681
|
try:
|
|
@@ -676,6 +696,8 @@ def commit_collapse(plan: Path, original: bytes, rows: list, row: dict, prompt:
|
|
|
676
696
|
_atomic_write(combined / 'prompt.md', prompt)
|
|
677
697
|
if approach is not None:
|
|
678
698
|
_atomic_write(combined / 'approach.md', approach)
|
|
699
|
+
if risk is not None:
|
|
700
|
+
_atomic_write(combined / 'risk', risk + '\n')
|
|
679
701
|
ids = [task['id'] for task in _parts_in_wave_order(rows)]
|
|
680
702
|
_atomic_write(plan / COLLAPSED_JSON, _collapsed_text(ids, info))
|
|
681
703
|
except Exception as err:
|
|
@@ -728,7 +750,8 @@ def command_collapse(plan: Path) -> int:
|
|
|
728
750
|
if approach is not None:
|
|
729
751
|
approaches[row['id']] = approach
|
|
730
752
|
combined, prompt, approach = collapse_rows(rows, prompts, approaches)
|
|
731
|
-
|
|
753
|
+
risk = combined_risk([read_risk(plan / 'tasks' / row['id'] / 'risk') for row in rows])
|
|
754
|
+
commit_collapse(plan, original, rows, combined, prompt, approach, info, risk)
|
|
732
755
|
except PlanShapeError as err:
|
|
733
756
|
print('forge-plan-check: %s' % err, file=sys.stderr)
|
|
734
757
|
return 2
|
package/scripts/forge-planner.py
CHANGED
|
@@ -8,7 +8,8 @@ gate and the one-task plan. Standard library only; no shell wiring.
|
|
|
8
8
|
|
|
9
9
|
forge-planner.py parse --plan P --reply FILE
|
|
10
10
|
Turns the planner's reply into P/tasks.tsv, P/tasks/<id>/prompt.md and, when it is not
|
|
11
|
-
empty, P/tasks/<id>/approach.md
|
|
11
|
+
empty, P/tasks/<id>/approach.md; a task's `risk` (#122) goes to P/tasks/<id>/risk, and a
|
|
12
|
+
missing or unknown one writes nothing. It never guesses or repairs: a reply that breaks one
|
|
12
13
|
rule writes nothing but P/planner.refused (the first reason and the reply's path), prints
|
|
13
14
|
both and exits 4. P/request.md must hold the user's request (exit 2 when it is missing);
|
|
14
15
|
it is attached to every task prompt so no requirement is lost.
|
|
@@ -43,7 +44,11 @@ MAX_REQUIREMENTS = 6
|
|
|
43
44
|
|
|
44
45
|
MAX_TASKS = 20
|
|
45
46
|
TASK_KEYS = ('id', 'deps', 'difficulty', 'files', 'title', 'approach', 'prompt')
|
|
47
|
+
# #122: a task's risk, recorded in shadow beside its difficulty. Optional, and the one key that never refuses a
|
|
48
|
+
# reply: a missing or unknown value records nothing, because a label nothing routes on must not cost a plan.
|
|
49
|
+
OPTIONAL_KEYS = ('risk',)
|
|
46
50
|
DIFFICULTIES = ('low', 'medium', 'high')
|
|
51
|
+
RISKS = ('low', 'medium', 'high')
|
|
47
52
|
LEVELS = DIFFICULTIES
|
|
48
53
|
ID_RE = re.compile(r'[a-z0-9][a-z0-9-]{0,39}')
|
|
49
54
|
ACCEPTANCE_RE = re.compile(r'## Acceptance criteria[ \t]*:?[ \t]*')
|
|
@@ -75,7 +80,7 @@ worktree of its own, and a reviewer judges each task against its prompt."""
|
|
|
75
80
|
EXAMPLE = """\
|
|
76
81
|
```forge-plan
|
|
77
82
|
{"tasks": [
|
|
78
|
-
{"id": "parse-config", "deps": [], "difficulty": "medium",
|
|
83
|
+
{"id": "parse-config", "deps": [], "difficulty": "medium", "risk": "low",
|
|
79
84
|
"files": ["src/config.py", "tests/test_config.py"],
|
|
80
85
|
"title": "Parse the new config section",
|
|
81
86
|
"approach": "Add parse_section() beside load(); keep load()'s signature.",
|
|
@@ -153,6 +158,12 @@ def build_prompt(request: str, level: str | None) -> str:
|
|
|
153
158
|
'judgment, touches cross-cutting behaviour, has subtle edge cases or state or concurrency, or '
|
|
154
159
|
'the right approach is not obvious from the request. A five-hundred-line mechanical rename is '
|
|
155
160
|
'`low`; a ten-line concurrency fix is `high`.',
|
|
161
|
+
'Rate `risk` apart from difficulty, by what a mistake that gets through would cost: what breaks, for '
|
|
162
|
+
'whom, and how hard it is to undo. `low`: local and easy to see and revert (docs, a test, an internal '
|
|
163
|
+
'helper). `medium`: wrong behaviour users would notice, undone by a revert. `high`: hard to undo or '
|
|
164
|
+
'reaching everyone: release and CI files, migrations and persisted data, auth and permissions, public '
|
|
165
|
+
'APIs. A one-line change to a release script is low difficulty and high risk. The rating is recorded '
|
|
166
|
+
'only; it changes no model or reviewer.',
|
|
156
167
|
'**Each task\'s `prompt`** carries the whole requirement it owns, written so that someone who '
|
|
157
168
|
'sees only that prompt can do it, and ends with a `## Acceptance criteria` section of checks '
|
|
158
169
|
'a reviewer can verify (a behaviour, a command that passes, a file that exists), not restated '
|
|
@@ -190,6 +201,7 @@ these keys and no others:
|
|
|
190
201
|
- `id`: lowercase slug matching `^[a-z0-9][a-z0-9-]{{0,39}}$`, unique in the plan;
|
|
191
202
|
- `deps`: list of ids of tasks that must land first (`[]` for none), no cycles;
|
|
192
203
|
- `difficulty`: `low`, `medium` or `high`;
|
|
204
|
+
- `risk`: `low`, `medium` or `high`, as the rules above define it;
|
|
193
205
|
- `files`: non-empty list of repo-relative paths the task creates or edits (no absolute path, no
|
|
194
206
|
`..`, no tab, comma or newline in a path);
|
|
195
207
|
- `title`: one line without a tab;
|
|
@@ -237,11 +249,11 @@ def no_duplicate_keys(pairs):
|
|
|
237
249
|
return dict(pairs)
|
|
238
250
|
|
|
239
251
|
|
|
240
|
-
def check_keys(obj, expected, where: str):
|
|
252
|
+
def check_keys(obj, expected, where: str, optional=()):
|
|
241
253
|
if not isinstance(obj, dict):
|
|
242
254
|
raise Refusal(f'{where} is not a JSON object')
|
|
243
255
|
missing = [k for k in expected if k not in obj]
|
|
244
|
-
extra = [k for k in obj if k not in expected]
|
|
256
|
+
extra = [k for k in obj if k not in expected and k not in optional]
|
|
245
257
|
if missing or extra:
|
|
246
258
|
parts = []
|
|
247
259
|
if missing:
|
|
@@ -290,7 +302,7 @@ def check_path(path, where: str):
|
|
|
290
302
|
|
|
291
303
|
def check_task(task, index: int, seen: set) -> dict:
|
|
292
304
|
where = f'task {index + 1}'
|
|
293
|
-
check_keys(task, TASK_KEYS, where)
|
|
305
|
+
check_keys(task, TASK_KEYS, where, OPTIONAL_KEYS)
|
|
294
306
|
tid = task['id']
|
|
295
307
|
if not isinstance(tid, str) or not ID_RE.fullmatch(tid):
|
|
296
308
|
raise Refusal(f'{where}: id {tid!r} does not match ^[a-z0-9][a-z0-9-]{{0,39}}$')
|
|
@@ -323,7 +335,8 @@ def check_task(task, index: int, seen: set) -> dict:
|
|
|
323
335
|
check_text(prompt, where)
|
|
324
336
|
if not has_acceptance_heading(prompt):
|
|
325
337
|
raise Refusal(f'{where}: prompt has no "## Acceptance criteria" heading')
|
|
326
|
-
|
|
338
|
+
risk = task.get('risk')
|
|
339
|
+
return dict(task, risk=risk if isinstance(risk, str) and risk in RISKS else None)
|
|
327
340
|
|
|
328
341
|
|
|
329
342
|
def check_graph(tasks: list):
|
|
@@ -397,6 +410,7 @@ def cmd_parse(args) -> int:
|
|
|
397
410
|
text = t['prompt'].rstrip('\n') + f'\n\n{WHOLE_REQUEST}\n\n' + request
|
|
398
411
|
outputs.append((folder / 'prompt.md', text.encode('utf-8')))
|
|
399
412
|
outputs.append((folder / 'approach.md', t['approach'].encode('utf-8') if t['approach'].strip() else None))
|
|
413
|
+
outputs.append((folder / 'risk', (t['risk'] + '\n').encode('utf-8') if t['risk'] else None))
|
|
400
414
|
outputs.append((plan / 'tasks.tsv', ('\n'.join(rows) + '\n').encode('utf-8')))
|
|
401
415
|
for path, data in outputs:
|
|
402
416
|
if data is None:
|
package/scripts/forge-shadow.py
CHANGED
|
@@ -27,11 +27,14 @@ Guarantees, because the task waits for this process before it writes any status:
|
|
|
27
27
|
timeout, error, invalid (the reviewer changed its snapshot), overtime, stopped, orphaned.
|
|
28
28
|
Only a `done` review counts as a second opinion.
|
|
29
29
|
Forge never picks a model: the reviewer is one the user listed, preferring a different
|
|
30
|
-
model family from the primary reviewer's, so two reviewers do not share one blind spot.
|
|
30
|
+
model family from the primary reviewer's, so two reviewers do not share one blind spot. A listed
|
|
31
|
+
spec that resolves to the primary's own harness, model and effort is picked last, as a `control`:
|
|
32
|
+
it measures a reviewer's noise, not what another effort or model buys (#121).
|
|
31
33
|
"""
|
|
32
34
|
from __future__ import annotations
|
|
33
35
|
|
|
34
36
|
import argparse
|
|
37
|
+
import functools
|
|
35
38
|
import hashlib
|
|
36
39
|
import json
|
|
37
40
|
import os
|
|
@@ -115,8 +118,9 @@ def family(model: str) -> str:
|
|
|
115
118
|
return m
|
|
116
119
|
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
@functools.lru_cache(maxsize=None)
|
|
122
|
+
def resolution(spec: str) -> tuple | None:
|
|
123
|
+
"""(harness, model, effort) a qa dispatch of `spec` would use, by dispatch's own dry run; None when it fails."""
|
|
120
124
|
with tempfile.TemporaryDirectory(prefix='forge-shadow-resolve-') as tmp:
|
|
121
125
|
prompt = Path(tmp) / 'input'
|
|
122
126
|
prompt.write_text('Offline resolution')
|
|
@@ -127,7 +131,9 @@ def resolved_model(spec: str) -> str | None:
|
|
|
127
131
|
except (OSError, subprocess.SubprocessError):
|
|
128
132
|
return None
|
|
129
133
|
fields = dict(line.split('=', 1) for line in out.stdout.splitlines() if '=' in line)
|
|
130
|
-
|
|
134
|
+
if not fields.get('model'):
|
|
135
|
+
return None
|
|
136
|
+
return fields.get('harness') or None, fields['model'], fields.get('effort') or None
|
|
131
137
|
|
|
132
138
|
|
|
133
139
|
def candidates(plan: Path) -> list:
|
|
@@ -140,14 +146,27 @@ def candidates(plan: Path) -> list:
|
|
|
140
146
|
|
|
141
147
|
|
|
142
148
|
def pick(listed: list, primary: str) -> tuple[str | None, str | None]:
|
|
143
|
-
"""(spec, why): the first listed spec of another family than the primary's
|
|
149
|
+
"""(spec, why): the first listed spec of another family than the primary's (`other_family`); else the
|
|
150
|
+
first one of its family that does not resolve to the primary's own harness, model and effort
|
|
151
|
+
(`same_model` when only the effort or harness differs, `same_family` for another model); else the
|
|
152
|
+
first listed, labelled `control` (#121). A control reviews the diff with the primary's own settings,
|
|
153
|
+
so it measures noise and never counts as an effort comparison. A spec that does not resolve is
|
|
154
|
+
compared by its text."""
|
|
144
155
|
if not listed:
|
|
145
156
|
return None, None
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
me = resolution(primary)
|
|
158
|
+
mine = family(me[1] if me else primary)
|
|
159
|
+
resolved = [(spec, resolution(spec)) for spec in listed]
|
|
160
|
+
for spec, found in resolved:
|
|
161
|
+
if family(found[1] if found else spec) != mine:
|
|
149
162
|
return spec, 'other_family'
|
|
150
|
-
|
|
163
|
+
for spec, found in resolved:
|
|
164
|
+
if me and found:
|
|
165
|
+
if found != me:
|
|
166
|
+
return spec, 'same_model' if found[1] == me[1] else 'same_family'
|
|
167
|
+
elif spec.strip().lower() != primary.strip().lower():
|
|
168
|
+
return spec, 'same_family'
|
|
169
|
+
return listed[0], 'control'
|
|
151
170
|
|
|
152
171
|
|
|
153
172
|
def fresh_dir(base: Path, attempt: str) -> Path:
|
package/scripts/forge-sweep.py
CHANGED
|
@@ -25,8 +25,12 @@ least as severe as --severity, from a task that is not itself a sweep task (one
|
|
|
25
25
|
review finds goes to `forge issues`), not dismissed (`forge issues --dismiss`), located in a file the
|
|
26
26
|
integration branch still has, and still there: when a later merge changed the file and the line the
|
|
27
27
|
reviewer saw is gone from it, the finding is left for `forge issues` rather than "fixed" twice. A
|
|
28
|
-
person's acceptance of a reviewer's FAIL (`accept`) is theirs to triage, so accepted
|
|
29
|
-
swept. Every finding left out is listed in the plan with its reason.
|
|
28
|
+
person's acceptance of a reviewer's FAIL (`accept`, or `adopt --approved`) is theirs to triage, so accepted
|
|
29
|
+
findings are never swept. Every finding left out is listed in the plan with its reason.
|
|
30
|
+
|
|
31
|
+
A range `adopt` brought in has no task row, and what its review tolerated is swept like a task's (#131):
|
|
32
|
+
its fix task's reviewer is the adoption's reviewer, and its implementer the plan's low tier, else the
|
|
33
|
+
implementer of the run's first task.
|
|
30
34
|
|
|
31
35
|
Each fix task gets at most GROUP_CAP findings; --max (default DEFAULT_MAX) caps the tasks, worst
|
|
32
36
|
severity first. Its implementer is the plan's low tier (the first spec of --dwarf-low, else of
|
|
@@ -67,6 +71,7 @@ REASONS = {
|
|
|
67
71
|
'group-cap': 'over the %d findings one fix task takes' % GROUP_CAP,
|
|
68
72
|
'over-max': 'over --sweep-max fix tasks',
|
|
69
73
|
'no-model': 'no implementer or reviewer to give its fix task',
|
|
74
|
+
'accepted': 'a person kept it over the review (accept, or adopt --approved): theirs to triage',
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
_ISSUES = None
|
|
@@ -218,13 +223,19 @@ def triage(ctx: Context, found: list, severity: str, plausible: bool) -> tuple:
|
|
|
218
223
|
kept, dropped, seen = [], [], {}
|
|
219
224
|
tip_text = {}
|
|
220
225
|
for f in sorted(found, key=lambda f: SEVERITIES.index(f['severity'])):
|
|
221
|
-
if
|
|
226
|
+
if not f.get('task') or is_sweep_task(ctx.plan, f['task']):
|
|
227
|
+
continue
|
|
228
|
+
if f['origin'] not in origins and f['origin'] != 'accepted':
|
|
222
229
|
continue
|
|
223
230
|
f = dict(f, key=mod.finding_key(f))
|
|
224
231
|
|
|
225
232
|
def drop(reason, **detail):
|
|
226
233
|
dropped.append(dict(f, reason=reason, detail=detail))
|
|
227
234
|
|
|
235
|
+
if f['origin'] == 'accepted':
|
|
236
|
+
drop('accepted')
|
|
237
|
+
continue
|
|
238
|
+
|
|
228
239
|
if SEVERITIES.index(f['severity']) > cut:
|
|
229
240
|
drop('below-severity')
|
|
230
241
|
continue
|
|
@@ -279,18 +290,22 @@ def pools(plan: Path) -> dict:
|
|
|
279
290
|
return data if isinstance(data, dict) else {}
|
|
280
291
|
|
|
281
292
|
|
|
282
|
-
def models(plan: Path, source: 'list | None') -> tuple:
|
|
283
|
-
"""(dwarf, qa) for a fix task whose worst finding came from the task with row `source
|
|
284
|
-
|
|
293
|
+
def models(plan: Path, source: 'list | None', finding: 'dict | None' = None, table: list = ()) -> tuple:
|
|
294
|
+
"""(dwarf, qa) for a fix task whose worst finding came from the task with row `source`; an empty string
|
|
295
|
+
where there is no spec to use. Without a row (an adopted range, #131) the reviewer is the finding's own
|
|
296
|
+
(the adoption's spec) and the implementer, below the low tier, the run's first task's."""
|
|
285
297
|
def usable(spec):
|
|
286
298
|
return spec if isinstance(spec, str) and spec not in ('', '-', 'UNASSIGNED') else ''
|
|
287
|
-
qa = usable(source[5]) if source else ''
|
|
299
|
+
qa = usable(source[5]) if source else usable((finding or {}).get('reviewer'))
|
|
288
300
|
routing = pools(plan)
|
|
289
301
|
for tier in ('low', 'any'):
|
|
290
302
|
specs = routing.get(tier)
|
|
291
303
|
if isinstance(specs, list) and specs and usable(specs[0]):
|
|
292
304
|
return specs[0], qa
|
|
293
|
-
|
|
305
|
+
if source:
|
|
306
|
+
return usable(source[4]), qa
|
|
307
|
+
first = next((row for row in table if len(row) > 4 and not is_sweep_task(plan, row[0])), None)
|
|
308
|
+
return (usable(first[4]) if first else ''), qa
|
|
294
309
|
|
|
295
310
|
|
|
296
311
|
def free_ids(taken: set, count: int) -> list:
|
|
@@ -368,7 +383,7 @@ def cmd_plan(args) -> int:
|
|
|
368
383
|
run_id = read(plan / 'run_id') or plan.name
|
|
369
384
|
tasks, new_rows = [], []
|
|
370
385
|
for path, items in list(chosen):
|
|
371
|
-
if not all(models(plan, by_id.get(items[0]['task']))):
|
|
386
|
+
if not all(models(plan, by_id.get(items[0]['task']), items[0], table)):
|
|
372
387
|
chosen.remove((path, items))
|
|
373
388
|
dropped += [dict(f, reason='no-model', detail={}) for f in items]
|
|
374
389
|
for ident, (path, items) in zip(ids, chosen):
|
|
@@ -376,7 +391,7 @@ def cmd_plan(args) -> int:
|
|
|
376
391
|
origin=f['origin'], task=f['task'], file=f['file'], line=f.get('line'), path=path,
|
|
377
392
|
location=location(f, path), text=f['text'], raw=f['raw'])
|
|
378
393
|
for n, f in enumerate(items, 1)]
|
|
379
|
-
dwarf, qa = models(plan, by_id.get(items[0]['task']))
|
|
394
|
+
dwarf, qa = models(plan, by_id.get(items[0]['task']), items[0], table)
|
|
380
395
|
title = 'Fix %d review finding%s in %s' % (len(entries), '' if len(entries) == 1 else 's', path)
|
|
381
396
|
root = plan / 'tasks' / ident
|
|
382
397
|
root.mkdir(parents=True, exist_ok=True)
|
|
@@ -6,6 +6,8 @@ silent): event, invocation, plan.
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import argparse
|
|
9
|
+
import os
|
|
10
|
+
from collections import Counter
|
|
9
11
|
import json
|
|
10
12
|
import sys
|
|
11
13
|
import time
|
|
@@ -49,6 +51,35 @@ def _continued_sessions(db) -> dict:
|
|
|
49
51
|
return counts
|
|
50
52
|
|
|
51
53
|
|
|
54
|
+
def _outcomes(db) -> dict:
|
|
55
|
+
"""Recorded survival outcomes by status, and what the last harvest that wrote did (#120)."""
|
|
56
|
+
from . import outcomes
|
|
57
|
+
recorded = Counter()
|
|
58
|
+
for (raw,) in db.execute("SELECT data FROM events WHERE kind = 'outcome'"):
|
|
59
|
+
data = json.loads(raw)
|
|
60
|
+
if data.get('name') == 'survival':
|
|
61
|
+
recorded[data.get('status') or 'unknown'] += 1
|
|
62
|
+
return dict(recorded=dict(recorded), last=outcomes.last_harvest())
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _outcomes_line(found) -> str | None:
|
|
66
|
+
recorded, last = found.get('recorded') or {}, found.get('last')
|
|
67
|
+
total = sum(recorded.values())
|
|
68
|
+
line = 'outcomes: %d recorded' % total
|
|
69
|
+
if total:
|
|
70
|
+
line += ' (%s)' % ', '.join('%d %s' % (recorded[k], k.replace('_', ' ')) for k in sorted(recorded))
|
|
71
|
+
if last and isinstance(last.get('at'), (int, float)):
|
|
72
|
+
counts = last.get('counts') or {}
|
|
73
|
+
where = os.path.basename(last['repo']) if last.get('repo') else 'every repo'
|
|
74
|
+
extra = ', '.join('%d %s' % (counts[k], k.replace('_', ' ')) for k in ('not_landed', 'pending', 'deferred', 'git_error')
|
|
75
|
+
if counts.get(k))
|
|
76
|
+
line += '; last harvested %s for %s: %d recorded%s' % (time.strftime('%Y-%m-%d %H:%M', time.localtime(last['at'])),
|
|
77
|
+
where, last.get('recorded') or 0, ', ' + extra if extra else '')
|
|
78
|
+
else:
|
|
79
|
+
line += '; never harvested (`forge dataset outcomes`, or the end of a run)'
|
|
80
|
+
return line
|
|
81
|
+
|
|
82
|
+
|
|
52
83
|
def status(args) -> int:
|
|
53
84
|
from . import checks
|
|
54
85
|
directory = dataset_dir()
|
|
@@ -65,6 +96,7 @@ def status(args) -> int:
|
|
|
65
96
|
summary['last_event'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(last)) if last else None
|
|
66
97
|
summary['checks'] = checks.run(db, verbose=args.verbose)
|
|
67
98
|
summary.update(_continued_sessions(db))
|
|
99
|
+
summary['outcomes'] = _outcomes(db)
|
|
68
100
|
if summary['events'].get('dispatch'):
|
|
69
101
|
from . import export
|
|
70
102
|
if db.execute("SELECT 1 FROM events WHERE kind = 'dispatch' AND data LIKE '%qa_shadow%' LIMIT 1").fetchone():
|
|
@@ -99,6 +131,10 @@ def status(args) -> int:
|
|
|
99
131
|
% (shadow['shadow_reviews'], shadow['pairs'], shadow['agree'], rate))
|
|
100
132
|
for pair, n in shadow['by_pair'].items():
|
|
101
133
|
print(' %s: %d of %d agree' % (pair, n['agree'], n['pairs']))
|
|
134
|
+
print(' by effort, model and family: forge dataset pairs')
|
|
135
|
+
line = _outcomes_line(summary.get('outcomes') or {})
|
|
136
|
+
if line:
|
|
137
|
+
print(' ' + line)
|
|
102
138
|
if summary.get('continued_reviews') or summary.get('failed_continues'):
|
|
103
139
|
print(' continued reviews: %d' % summary['continued_reviews'])
|
|
104
140
|
print(' failed continues: %d' % summary['failed_continues'])
|
|
@@ -196,6 +232,26 @@ def run_reviewers(args) -> int:
|
|
|
196
232
|
return reviewers.main(args)
|
|
197
233
|
|
|
198
234
|
|
|
235
|
+
def run_facts(args) -> int:
|
|
236
|
+
from . import facts
|
|
237
|
+
return facts.main(args)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def run_pairs(args) -> int:
|
|
241
|
+
from . import pairs
|
|
242
|
+
return pairs.main(args)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def run_risk(args) -> int:
|
|
246
|
+
from . import risk
|
|
247
|
+
return risk.main(args)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def run_tiers(args) -> int:
|
|
251
|
+
from . import tiers
|
|
252
|
+
return tiers.main(args)
|
|
253
|
+
|
|
254
|
+
|
|
199
255
|
def run_history(args) -> int:
|
|
200
256
|
from . import history
|
|
201
257
|
return history.main(args)
|
|
@@ -253,6 +309,9 @@ def parser() -> argparse.ArgumentParser:
|
|
|
253
309
|
p.add_argument('--repo', help='only this repo')
|
|
254
310
|
p.add_argument('--include-temp', action='store_true', help='also repos under temp dirs (test runs)')
|
|
255
311
|
p.add_argument('--dry-run', action='store_true', help='report what would be recorded, write nothing')
|
|
312
|
+
p.add_argument('--deadline', type=float, metavar='SECONDS',
|
|
313
|
+
help='start no new integration after this long; the rest waits for the next harvest')
|
|
314
|
+
p.add_argument('--quiet', action='store_true', help='print nothing (the automatic harvest at the end of a run)')
|
|
256
315
|
p.set_defaults(func=run_outcomes)
|
|
257
316
|
p = sub.add_parser('routing', help='pass rate and runtime per tier and model, and what the --explore draws say')
|
|
258
317
|
p.add_argument('--repo', help='only this repo')
|
|
@@ -264,6 +323,30 @@ def parser() -> argparse.ArgumentParser:
|
|
|
264
323
|
p.add_argument('--repo', help='only this repo')
|
|
265
324
|
p.add_argument('--json', action='store_true')
|
|
266
325
|
p.set_defaults(func=run_reviewers)
|
|
326
|
+
p = sub.add_parser('facts', help="the reach, origin and evidence reviewers give findings: agreement, and what "
|
|
327
|
+
"a gate on them would have changed (advisory)")
|
|
328
|
+
p.add_argument('--repo', help='only this repo')
|
|
329
|
+
p.add_argument('--json', action='store_true')
|
|
330
|
+
p.set_defaults(func=run_facts)
|
|
331
|
+
p = sub.add_parser('pairs', help='two reviewers of one attempt, per pair of settings: effort within one model apart '
|
|
332
|
+
'from model and family comparisons and controls (advisory)')
|
|
333
|
+
p.add_argument('--repo', help='only this repo')
|
|
334
|
+
p.add_argument('--json', action='store_true')
|
|
335
|
+
p.set_defaults(func=run_pairs)
|
|
336
|
+
p = sub.add_parser('risk', help="tasks by difficulty and risk together: how often they differ, and how each "
|
|
337
|
+
"pair fared (advisory)")
|
|
338
|
+
p.add_argument('--repo', help='only this repo')
|
|
339
|
+
p.add_argument('--json', action='store_true')
|
|
340
|
+
p.set_defaults(func=run_risk)
|
|
341
|
+
p = sub.add_parser('tiers', help="what explains results inside each difficulty tier: plan-time facts held out by "
|
|
342
|
+
"run and adjusted for the implementer, and blind-rating agreement (advisory)")
|
|
343
|
+
p.add_argument('--repo', help='only this repo')
|
|
344
|
+
p.add_argument('--tier', choices=('low', 'medium', 'high'), help='only this tier')
|
|
345
|
+
p.add_argument('--sample', type=int, metavar='N', help='write N past prompts for blind rating into --out')
|
|
346
|
+
p.add_argument('--out', help='an empty directory for --sample')
|
|
347
|
+
p.add_argument('--blind', metavar='DIR', help='agreement of DIR/ratings.tsv with the recorded tiers')
|
|
348
|
+
p.add_argument('--json', action='store_true')
|
|
349
|
+
p.set_defaults(func=run_tiers)
|
|
267
350
|
p = sub.add_parser('history', help="every review's findings and every learning, for forge-ui's Projects screen")
|
|
268
351
|
p.add_argument('--json', action='store_true')
|
|
269
352
|
p.set_defaults(func=run_history)
|