@giamme/forge 0.13.1 → 0.14.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 +29 -0
- package/SKILL.md +17 -11
- package/VERSION +1 -1
- package/docs/artifacts.md +1 -0
- package/docs/commands.md +121 -7
- package/docs/development.md +3 -0
- package/docs/reviews.md +2 -0
- package/docs/troubleshooting.md +5 -1
- package/forge +28 -1
- package/package.json +1 -1
- package/references/dataset.md +3 -1
- package/references/decompose.md +199 -61
- package/references/runtime.md +29 -0
- package/references/ui.md +10 -0
- package/scripts/forge-compare.py +491 -0
- package/scripts/forge-config.py +3 -3
- package/scripts/forge-contract.py +34 -8
- package/scripts/forge-control.py +105 -13
- package/scripts/forge-dispatch.sh +9 -5
- package/scripts/forge-jev-options.sh +17 -4
- package/scripts/forge-ledger.py +387 -0
- package/scripts/forge-lib-plans.sh +11 -2
- package/scripts/forge-lib-task.sh +390 -28
- package/scripts/forge-parallel-options.sh +20 -4
- package/scripts/forge-parallel.sh +116 -12
- package/scripts/forge-plan-check.py +68 -3
- package/scripts/forge-pr.py +276 -0
- package/scripts/forge-route.py +350 -34
- package/scripts/forge-runs.py +18 -1
- package/scripts/forge-runtime.py +23 -7
- package/scripts/forge-schedule.py +303 -46
- package/scripts/forge-verify-failed.py +111 -0
- package/scripts/forge-watch.py +372 -0
- package/scripts/forge_dataset/harvest.py +3 -1
- package/scripts/forge_fractal/cli.py +23 -6
- package/scripts/forge_infra.py +274 -0
- package/scripts/forge_jev/client.py +13 -9
- package/ui/docs/api.md +51 -8
- package/ui/forge_ui/export.py +6 -2
- package/ui/forge_ui/reader.py +172 -6
- package/ui/forge_ui/static/app.js +2 -2
- package/ui/forge_ui/static/checksview.js +20 -7
- package/ui/forge_ui/static/controls.js +6 -3
- package/ui/forge_ui/static/panel.js +69 -4
- package/ui/forge_ui/static/runmodel.js +30 -4
- package/ui/forge_ui/static/scene3d.js +3 -2
- package/ui/forge_ui/static/style.css +11 -4
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"""The one table of infrastructure causes, for every Python reader (the scheduler, forge-control.py,
|
|
2
|
+
the summary). Standard library only.
|
|
3
|
+
|
|
4
|
+
forge-runtime.py gives each infrastructure stop a class, the name written to <role>.infra and
|
|
5
|
+
infra.txt. A class names a symptom, not a recovery: `quota` once covered a window that resets and
|
|
6
|
+
money that is gone. CAUSES says what each cause means for a recovery. Each entry is a dict with:
|
|
7
|
+
|
|
8
|
+
scope model | harness | all: what a pause holds back (one model, one harness, everything)
|
|
9
|
+
move lateral | wait | retry: what to do first. lateral moves the work to a peer (another
|
|
10
|
+
model or harness); wait pauses until the cause clears; retry dispatches again
|
|
11
|
+
without_peer wait | ask | wait_if_reset: what to do when no peer can take the work. wait_if_reset
|
|
12
|
+
waits when the reset is known and inside WAIT_CAP_S, and asks otherwise
|
|
13
|
+
hint a sentence for a person, with {harness} filled in by hint(); None when there is
|
|
14
|
+
nothing to say
|
|
15
|
+
|
|
16
|
+
LEGACY maps the class names runs recorded before the split still carry.
|
|
17
|
+
|
|
18
|
+
The run summary and `forge control show` both say what a stop is (label, reset_text, stop_of, the
|
|
19
|
+
summary lines), so the wording lives here too. The summary (forge-lib-task.sh) calls this file as a
|
|
20
|
+
program: see main().
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import json
|
|
26
|
+
import math
|
|
27
|
+
import os
|
|
28
|
+
import sys
|
|
29
|
+
import time
|
|
30
|
+
|
|
31
|
+
# The longest wait worth holding a run for; the same value as INFRA_WAIT_CAP in forge-schedule.py
|
|
32
|
+
# (a test keeps the two equal).
|
|
33
|
+
WAIT_CAP_S = 6 * 3600
|
|
34
|
+
|
|
35
|
+
CAUSES = {
|
|
36
|
+
'capacity': {'scope': 'model', 'move': 'lateral', 'without_peer': 'wait', 'hint': None},
|
|
37
|
+
'rate_limit': {'scope': 'model', 'move': 'wait', 'without_peer': 'wait', 'hint': None},
|
|
38
|
+
'usage_limit': {'scope': 'harness', 'move': 'lateral', 'without_peer': 'wait_if_reset',
|
|
39
|
+
'hint': "wait for the reset, or add another harness to this tier's pool"},
|
|
40
|
+
'budget': {'scope': 'harness', 'move': 'lateral', 'without_peer': 'ask',
|
|
41
|
+
'hint': 'add credits, or check the billing of {harness}'},
|
|
42
|
+
'auth': {'scope': 'harness', 'move': 'lateral', 'without_peer': 'ask',
|
|
43
|
+
'hint': 'log in to {harness} again'},
|
|
44
|
+
'network': {'scope': 'all', 'move': 'wait', 'without_peer': 'wait', 'hint': None},
|
|
45
|
+
'provider_down': {'scope': 'harness', 'move': 'lateral', 'without_peer': 'wait', 'hint': None},
|
|
46
|
+
'empty': {'scope': 'model', 'move': 'retry', 'without_peer': 'wait', 'hint': None},
|
|
47
|
+
'cancelled': {'scope': 'model', 'move': 'retry', 'without_peer': 'ask',
|
|
48
|
+
'hint': "check {harness}'s approval and permission settings"},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
LEGACY = {'quota': 'usage_limit'}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def cause_of(cls) -> str:
|
|
55
|
+
"""The cause a stored class stands for: a legacy name is mapped, an unknown name is returned
|
|
56
|
+
as it is, and None or empty gives ''."""
|
|
57
|
+
if not cls:
|
|
58
|
+
return ''
|
|
59
|
+
return LEGACY.get(cls, cls)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def entry(cls) -> dict:
|
|
63
|
+
"""The table entry for a stored class. An unknown cause acts like network: pause everything, wait."""
|
|
64
|
+
found = CAUSES.get(cause_of(cls))
|
|
65
|
+
return dict(found if found is not None else CAUSES['network'])
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def needs_you(cls, has_peer, reset_known, reset_within_cap) -> bool:
|
|
69
|
+
"""True when the recovery ends in a person: no peer to move to, and the cause will not clear
|
|
70
|
+
by itself (it asks outright, or it waits for a reset that is unknown or past the cap)."""
|
|
71
|
+
if has_peer:
|
|
72
|
+
return False
|
|
73
|
+
without_peer = entry(cls)['without_peer']
|
|
74
|
+
if without_peer == 'ask':
|
|
75
|
+
return True
|
|
76
|
+
return without_peer == 'wait_if_reset' and not (reset_known and reset_within_cap)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def hint(cls, harness) -> str | None:
|
|
80
|
+
"""What to tell a person about this cause for this harness, or None when there is nothing to say."""
|
|
81
|
+
text = entry(cls)['hint']
|
|
82
|
+
return None if text is None else text.format(harness=harness or 'the harness')
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def label(cls) -> str:
|
|
86
|
+
"""The cause as a person reads it: the stored class as written (a legacy `quota` stays `quota`),
|
|
87
|
+
or `unknown` when there is none."""
|
|
88
|
+
return cls or 'unknown'
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def reset_text(epoch, now) -> str:
|
|
92
|
+
"""`resets HH:MM` for when a limit lifts, in local time; the date follows when it is not today
|
|
93
|
+
(as of `now`). '' when the reset is unknown."""
|
|
94
|
+
if epoch is None:
|
|
95
|
+
return ''
|
|
96
|
+
try:
|
|
97
|
+
at, today = time.localtime(epoch), time.localtime(now)
|
|
98
|
+
except (OverflowError, OSError, TypeError, ValueError):
|
|
99
|
+
return ''
|
|
100
|
+
if time.strftime('%Y-%m-%d', at) == time.strftime('%Y-%m-%d', today):
|
|
101
|
+
return 'resets ' + time.strftime('%H:%M', at)
|
|
102
|
+
return 'resets ' + time.strftime('%Y-%m-%d %H:%M', at)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _epoch(value) -> float | int | None:
|
|
106
|
+
"""A finite non-negative number from a stored value, else None."""
|
|
107
|
+
try:
|
|
108
|
+
number = float(value)
|
|
109
|
+
except (TypeError, ValueError):
|
|
110
|
+
return None
|
|
111
|
+
if not math.isfinite(number) or number < 0:
|
|
112
|
+
return None
|
|
113
|
+
return int(number) if number == int(number) else number
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def parse_stop(text) -> dict:
|
|
117
|
+
"""The key=value lines of a task's infra.txt, `stage=` included; a later line of a key wins."""
|
|
118
|
+
info = {}
|
|
119
|
+
for line in (text or '').splitlines():
|
|
120
|
+
key, sep, value = line.partition('=')
|
|
121
|
+
if sep and key.strip():
|
|
122
|
+
info[key.strip()] = value.strip()
|
|
123
|
+
return info
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def parse_pauses(text) -> list:
|
|
127
|
+
"""The scopes of an infra.paused file; [] when it is absent or unreadable."""
|
|
128
|
+
try:
|
|
129
|
+
scopes = json.loads(text or '')['scopes']
|
|
130
|
+
except (ValueError, KeyError, TypeError):
|
|
131
|
+
return []
|
|
132
|
+
if not isinstance(scopes, list):
|
|
133
|
+
return []
|
|
134
|
+
return [scope for scope in scopes if isinstance(scope, dict)]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def stop_of(task, info, scopes, now) -> dict:
|
|
138
|
+
"""What a person needs to know about an INFRA task: its cause, where it stopped, when its limit
|
|
139
|
+
resets and whether a person must act. The scope that names the task in its `tasks` decides
|
|
140
|
+
needs_you and the hint when one does; otherwise the cause decides as it would with no peer."""
|
|
141
|
+
cls = info.get('class', '')
|
|
142
|
+
harness, model = info.get('harness', ''), info.get('model', '')
|
|
143
|
+
reset = _epoch(info.get('reset_at'))
|
|
144
|
+
# A scope on another harness is not this stop's pause, whatever its list says (an earlier run's record).
|
|
145
|
+
scope = next((s for s in scopes if isinstance(s.get('tasks'), list) and task in s['tasks']
|
|
146
|
+
and (not s.get('harness') or not harness or s.get('harness') == harness)), None)
|
|
147
|
+
if scope is not None:
|
|
148
|
+
needs, text = bool(scope.get('needs_you')), scope.get('hint')
|
|
149
|
+
else:
|
|
150
|
+
within = reset is not None and reset - now <= WAIT_CAP_S
|
|
151
|
+
needs, text = needs_you(cls, False, reset is not None, within), hint(cls, harness)
|
|
152
|
+
return dict(cause=label(cls), harness=harness, model=model, stage=info.get('stage', ''),
|
|
153
|
+
reset_at=reset, needs_you=needs, hint=text)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def stop_line(task, record, now) -> str:
|
|
157
|
+
"""The run summary's line for an INFRA task, from its stop_of record."""
|
|
158
|
+
where = '/'.join(part for part in (record['harness'], record['model']) if part) or 'unknown'
|
|
159
|
+
line = ' %-14s %s on %s (%s stage)' % (task, record['cause'], where, record['stage'] or 'unknown')
|
|
160
|
+
reset = reset_text(record['reset_at'], now)
|
|
161
|
+
if reset:
|
|
162
|
+
line += ', ' + reset
|
|
163
|
+
if record['needs_you']:
|
|
164
|
+
line += ' — needs you' + (': ' + record['hint'] if isinstance(record['hint'], str) and record['hint'] else '')
|
|
165
|
+
return line
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def parse_laterals(task, text, since) -> list:
|
|
169
|
+
"""The lateral moves in one task's lateral.tsv made at or after `since`, an epoch in seconds. The rows
|
|
170
|
+
hold whole seconds, so `since` is taken down to one. Each move is a dict: task, role, frm, to, cause."""
|
|
171
|
+
moves, floor = [], math.floor(since)
|
|
172
|
+
for line in (text or '').splitlines():
|
|
173
|
+
cols = line.split('\t')
|
|
174
|
+
if len(cols) < 5 or not cols[0].isdigit() or int(cols[0]) < floor:
|
|
175
|
+
continue
|
|
176
|
+
cause = cols[5] if len(cols) > 5 and cols[5] != '-' else ''
|
|
177
|
+
moves.append(dict(task=task, role=cols[2], frm=cols[3], to=cols[4], cause=cause))
|
|
178
|
+
return moves
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def held_lines(scopes, still_held=lambda task: True) -> list:
|
|
182
|
+
"""The run summary's lines for the tasks a pause held back without a dispatch (infra.last's `held`):
|
|
183
|
+
they never stopped, so they have no stop record of their own, but the pause may need a person. A task
|
|
184
|
+
that has run since (`still_held` is false) is no longer held back."""
|
|
185
|
+
lines = []
|
|
186
|
+
for scope in scopes:
|
|
187
|
+
held = [task for task in scope.get('held') or [] if isinstance(task, str) and still_held(task)]
|
|
188
|
+
if not held:
|
|
189
|
+
continue
|
|
190
|
+
where = '/'.join(part for part in (scope.get('harness'), scope.get('model')) if part) or 'everything'
|
|
191
|
+
line = ' %-14s held back: %s on %s' % (', '.join(held), label(scope.get('class')), where)
|
|
192
|
+
if scope.get('needs_you') is True:
|
|
193
|
+
hint = scope.get('hint')
|
|
194
|
+
line += ' — needs you' + (': ' + hint if isinstance(hint, str) and hint else '')
|
|
195
|
+
lines.append(line)
|
|
196
|
+
return lines
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def moved_line(move) -> str:
|
|
200
|
+
"""The run summary's line for a lateral move."""
|
|
201
|
+
return 'moved sideways: %s %s %s → %s (%s)' % (move['task'], move['role'], move['frm'], move['to'],
|
|
202
|
+
label(move['cause']))
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# --- the summary's helper ------------------------------------------------------------------------
|
|
206
|
+
def _read(plan, name) -> str:
|
|
207
|
+
try:
|
|
208
|
+
with open(os.path.join(plan, name), errors='replace') as handle:
|
|
209
|
+
return handle.read()
|
|
210
|
+
except OSError:
|
|
211
|
+
return ''
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _task_ids(plan) -> list:
|
|
215
|
+
"""The task ids of tasks.tsv, in its order (the first field of each row that is not a comment)."""
|
|
216
|
+
return [line.split('\t')[0] for line in _read(plan, 'tasks.tsv').splitlines() if line and not line.startswith('#')]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _stop(plan, task, scopes, now) -> dict:
|
|
220
|
+
return stop_of(task, parse_stop(_read(plan, os.path.join('tasks', task, 'infra.txt'))), scopes, now)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _not_started(plan, task) -> bool:
|
|
224
|
+
"""True while a task has neither merged nor a status: what a held task was when its run ended."""
|
|
225
|
+
return (not os.path.exists(os.path.join(plan, 'tasks', task, 'merged'))
|
|
226
|
+
and _read(plan, os.path.join('tasks', task, 'status')).strip() in ('', 'PENDING'))
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def pauses_of(plan) -> list:
|
|
230
|
+
"""The pauses of a live scheduler (infra.paused), else those its end left (infra.last)."""
|
|
231
|
+
return parse_pauses(_read(plan, 'infra.paused')) or parse_pauses(_read(plan, 'infra.last'))
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def main(argv=None) -> int:
|
|
235
|
+
"""forge-lib-task.sh's run summary calls this for the infrastructure block. `stop` prints one
|
|
236
|
+
line for an INFRA task; `needs-you` exits 0 when one of the tasks needs a person and 1 when none
|
|
237
|
+
does; `held` prints a line for the tasks each pause held back undispatched; `moved` prints a line
|
|
238
|
+
for each lateral move made at or after the given epoch time."""
|
|
239
|
+
parser = argparse.ArgumentParser(prog='forge_infra.py', description=main.__doc__)
|
|
240
|
+
commands = parser.add_subparsers(dest='command', required=True)
|
|
241
|
+
stop = commands.add_parser('stop', help='the summary line for one INFRA task')
|
|
242
|
+
stop.add_argument('plan')
|
|
243
|
+
stop.add_argument('task')
|
|
244
|
+
needs = commands.add_parser('needs-you', help='exit 0 when one of these INFRA tasks needs a person')
|
|
245
|
+
needs.add_argument('plan')
|
|
246
|
+
needs.add_argument('tasks', nargs='+')
|
|
247
|
+
moved = commands.add_parser('moved', help='the lateral moves made at or after a time')
|
|
248
|
+
moved.add_argument('plan')
|
|
249
|
+
moved.add_argument('since', type=float)
|
|
250
|
+
held = commands.add_parser('held', help='the tasks a pause held back when the run ended; exit 0 when one '
|
|
251
|
+
'of those pauses needs a person')
|
|
252
|
+
held.add_argument('plan')
|
|
253
|
+
args = parser.parse_args(argv)
|
|
254
|
+
now = time.time()
|
|
255
|
+
scopes = pauses_of(args.plan)
|
|
256
|
+
if args.command == 'held':
|
|
257
|
+
still = lambda task: _not_started(args.plan, task) # noqa: E731
|
|
258
|
+
for line in held_lines(scopes, still):
|
|
259
|
+
print(line)
|
|
260
|
+
return 0 if any(s.get('needs_you') is True and any(still(t) for t in s.get('held') or [] if isinstance(t, str))
|
|
261
|
+
for s in scopes) else 1
|
|
262
|
+
if args.command == 'stop':
|
|
263
|
+
print(stop_line(args.task, _stop(args.plan, args.task, scopes, now), now))
|
|
264
|
+
return 0
|
|
265
|
+
if args.command == 'needs-you':
|
|
266
|
+
return 0 if any(_stop(args.plan, task, scopes, now)['needs_you'] for task in args.tasks) else 1
|
|
267
|
+
for task in _task_ids(args.plan):
|
|
268
|
+
for move in parse_laterals(task, _read(args.plan, os.path.join('tasks', task, 'lateral.tsv')), args.since):
|
|
269
|
+
print(moved_line(move))
|
|
270
|
+
return 0
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
if __name__ == '__main__':
|
|
274
|
+
sys.exit(main())
|
|
@@ -53,23 +53,25 @@ def _skip(run_dir: Path | str | None, site: str, reason: str) -> None:
|
|
|
53
53
|
pass
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def _gate_fields(site) -> dict:
|
|
56
|
+
def _gate_fields(site, resolved: dict | None = None) -> dict:
|
|
57
57
|
"""The gate a site answers to and its resolved mode. `shadow` is that mode, or --jev-shadow
|
|
58
58
|
on a gate the legacy level turned on (no user decide.json yet), which acts as it always
|
|
59
|
-
did and is marked shadow as it always was.
|
|
60
|
-
|
|
59
|
+
did and is marked shadow as it always was. `resolved` is the resolution the request was
|
|
60
|
+
sent under (ask() resolves for the repo it finds, which can be the working directory's);
|
|
61
|
+
without it, current_repo()'s."""
|
|
62
|
+
gate = _gate(site, resolved if resolved is not None else _resolved())
|
|
61
63
|
mode = gate['mode'] if gate else 'off'
|
|
62
64
|
legacy = mode == 'on' and gate.get('source') == 'legacy' and shadow()
|
|
63
65
|
return dict(gate=SITE_GATE.get(site), mode=mode, shadow=mode == 'shadow' or legacy)
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
def _log(run_dir, site, key, ok, reason, latency_s, model, usage, questions, answers, provider='typesafe',
|
|
67
|
-
cached=False) -> None:
|
|
69
|
+
cached=False, resolved=None) -> None:
|
|
68
70
|
if run_dir is None:
|
|
69
71
|
return
|
|
70
72
|
entry = dict(at=time.time(), site=site, key=key, ok=ok, reason=reason, latency_s=latency_s,
|
|
71
73
|
model=model, usage=usage, questions=questions, answers=answers,
|
|
72
|
-
acting=acting(), provider=provider, cached=cached, **_gate_fields(site))
|
|
74
|
+
acting=acting(), provider=provider, cached=cached, **_gate_fields(site, resolved))
|
|
73
75
|
try:
|
|
74
76
|
with (Path(run_dir) / 'jev.jsonl').open('a') as handle:
|
|
75
77
|
handle.write(json.dumps(entry) + '\n')
|
|
@@ -85,7 +87,8 @@ def _log(run_dir, site, key, ok, reason, latency_s, model, usage, questions, ans
|
|
|
85
87
|
_DATASET_SKIP_SITES = ('setup-probe',)
|
|
86
88
|
|
|
87
89
|
|
|
88
|
-
def _dataset(site, key, canonical, ok, reason, latency, model, usage, qids, answers, run_dir, extra=None
|
|
90
|
+
def _dataset(site, key, canonical, ok, reason, latency, model, usage, qids, answers, run_dir, extra=None,
|
|
91
|
+
resolved=None) -> None:
|
|
89
92
|
"""Keep the full request (state and questions) with its answers in the run dataset.
|
|
90
93
|
|
|
91
94
|
jev.jsonl keeps only the request's sha256, so a judgment could never be replayed
|
|
@@ -99,7 +102,7 @@ def _dataset(site, key, canonical, ok, reason, latency, model, usage, qids, answ
|
|
|
99
102
|
if scripts not in sys.path:
|
|
100
103
|
sys.path.insert(0, scripts)
|
|
101
104
|
from forge_dataset.capture import jev
|
|
102
|
-
fields = _gate_fields(site)
|
|
105
|
+
fields = _gate_fields(site, resolved)
|
|
103
106
|
jev(site=site, key=key, canonical=canonical, ok=ok, reason=reason, latency=latency, model=model,
|
|
104
107
|
usage=usage, questions=qids, answers=answers, run_dir=run_dir, acting=acting(),
|
|
105
108
|
shadow=fields.pop('shadow'), extra=dict(extra or {}, **fields))
|
|
@@ -373,11 +376,12 @@ def ask(state, questions: dict, *, site: str, run_dir=None, config: dict | None
|
|
|
373
376
|
def done(ok, reason, result, model=None, usage=None, latency=None, cached=False):
|
|
374
377
|
latency = latency if latency is not None else time.time() - started
|
|
375
378
|
answers = result['answers'] if result else None
|
|
376
|
-
_log(run_dir, site, fixture_key, ok, reason, latency, model, usage, qids, answers, provider, cached
|
|
379
|
+
_log(run_dir, site, fixture_key, ok, reason, latency, model, usage, qids, answers, provider, cached,
|
|
380
|
+
resolved)
|
|
377
381
|
# A cache hit is not a new judgment: the dataset keeps live ones, as it does for fixtures.
|
|
378
382
|
if canonical is not None and not cached:
|
|
379
383
|
_dataset(site, fixture_key, canonical, ok, reason, latency, model, usage, qids, answers, run_dir,
|
|
380
|
-
extra)
|
|
384
|
+
extra, resolved)
|
|
381
385
|
return result
|
|
382
386
|
|
|
383
387
|
fixture_key = canonical = None
|
package/ui/docs/api.md
CHANGED
|
@@ -59,13 +59,18 @@ written), and the reader must never raise because of one.
|
|
|
59
59
|
| `final-review` | a symlink to the newest *published* review dir; `final-review.verdict` a copy of its verdict |
|
|
60
60
|
| `integrate-<epoch>-<pid>/` | one `integrate`: `setup.log`, `merge.log`, `verification.*`, `attempts/verification-<uuid>/`, and `final-review/` (a review dir as above) when it ran one |
|
|
61
61
|
| `tasks/<id>/merged` | exists when the task was merged; its mtime is when |
|
|
62
|
-
| `tasks/<id>/status` | one word: `RUNNING PASS FAIL ERROR INFRA TIMEOUT UNKNOWN INVALIDATED BLOCKED INTERRUPTED NOCHANGES CONFLICT NEEDS_INPUT` |
|
|
62
|
+
| `tasks/<id>/status` | one word: `RUNNING PASS FAIL ERROR INFRA TIMEOUT UNKNOWN INVALIDATED BLOCKED INTERRUPTED NOCHANGES CONFLICT NEEDS_INPUT NEEDS_DECISION` |
|
|
63
63
|
| `tasks/<id>/attempt` | the current attempt number |
|
|
64
64
|
| `tasks/<id>/attempts.tsv` | `epoch<TAB>attempt<TAB>status<TAB>infra_class` per line, one per attempt entry; status may also be `MERGED`, `BOUNCED` or `INCOMPLETE` (a send-back that no reviewer judged: the task status stays `FAIL`), `infra_class` may be empty, `-` or missing |
|
|
65
65
|
| `tasks/<id>/escalations.tsv` | `epoch<TAB>attempt<TAB>from_spec<TAB>to_spec[<TAB>source]` per line; `source` (who decided: `policy`, a human's `retry --dwarf` as `retry`, or a `pin`) is missing on older rows, which read as `policy` |
|
|
66
66
|
| `tasks/<id>/qa.last` | the reviewer's final message; its last line matching `FORGE_VERDICT: PASS` or `FORGE_VERDICT: FAIL` is the verdict |
|
|
67
67
|
| `tasks/<id>/prompt.md`, `approach.md`, `retry_findings.md` | free text |
|
|
68
68
|
| `tasks/<id>/needs_input.md` | the question for the user, written when the task stopped `NEEDS_INPUT`: `The implementer asked:`, then the end of the dwarf's last message; free text, returned as `needs_input` |
|
|
69
|
+
| `tasks/<id>/infra.txt` | the stop record of an `INFRA` task: `key=value` lines `class` (the cause: `capacity`, `rate_limit`, `usage_limit`, `budget`, `auth`, `network`, `provider_down`, `empty` or `cancelled`; older runs say `quota`, `rate_limit` or `network`, shown as they are), `stage`, `harness`, `model`, `retry_after` (seconds), `reset_at` (an epoch, when known), `detail`, and `rc`, `role`; returned as `infra` |
|
|
70
|
+
| `tasks/<id>/lateral.tsv` | `epoch<TAB>attempt<TAB>role<TAB>from<TAB>to<TAB>cause` per line, one per move of a stopped dispatch to another model of the same tier (`role` `dwarf` or `qa`); returned as `lateral` |
|
|
71
|
+
| `tasks/<id>/ledger.tsv` | `epoch<TAB>attempt<TAB>review<TAB>verdict<TAB>gate<TAB>worst<TAB>confirmed<TAB>new<TAB>carried<TAB>diff_bytes<TAB>delta_bytes` per line, one per review (no header); `gate`, `worst` and `delta_bytes` may be `-`; returned as `ledger` |
|
|
72
|
+
| `tasks/<id>/decision.md` | written when the task stopped `NEEDS_DECISION`: its first line `reasons: converging, cap` (comma-separated, from `converging`, `split` and `cap`), then markdown for the user; returned as `decision` |
|
|
73
|
+
| `tasks/<id>/decisions.tsv` | `epoch<TAB>attempt<TAB>choice<TAB>reason` per line, one per human decision; a `retry=N` choice grants N more attempts; returned as `decisions` |
|
|
69
74
|
| `tasks/<id>/accepted.by` | who accepted a task over a reviewer's FAIL, and why (`key=value`: `task`, `status`, `reason`, `by`, `at`, `epoch`, `attempt`, `reviewed_commit`; older runs are free text; returned as text) |
|
|
70
75
|
| `tasks/<id>/qa.gate` | `threshold<TAB>decision<TAB>worst<TAB>n_confirmed<TAB>n_unlabelled<TAB>n_below` (`decision` is `accept` (the reviewer said FAIL, every CONFIRMED finding was below the threshold), `fail` (the reviewer said PASS, but listed a blocking CONFIRMED finding) or `keep`, `-` for none) |
|
|
71
76
|
| `tasks/<id>/known_issues.md` | the confirmed findings a threshold tolerated |
|
|
@@ -74,7 +79,8 @@ written), and the reader must never raise because of one.
|
|
|
74
79
|
| `tasks/<id>/<role>.log`, `<role>.clock` | the running dispatch's harness log and its clock: one `<epoch> <bytes>` line each time the log grew (forge-dispatch.sh samples it every second; `FORGE_LOG_CLOCK=off` writes none) |
|
|
75
80
|
| `tasks/<id>/escalation.stop`, `split.suggested` | the retry policy stopped the task: `<attempts><TAB><model>`, and the split it suggests (free text) |
|
|
76
81
|
| `scheduler.live` | `{"pid": n}`: the scheduler running the plan; it is live while that process is |
|
|
77
|
-
| `drain`, `stop`, `max_parallel`, `infra.paused` | a live scheduler's controls (Controls below): a drain, a stop (`graceful` or `now`), a capacity, and its infrastructure pauses as `{"scopes": [{scope, class, harness, model, tasks, cycle, until, exhausted}]}` |
|
|
82
|
+
| `drain`, `stop`, `max_parallel`, `infra.paused` | a live scheduler's controls (Controls below): a drain, a stop (`graceful` or `now`), a capacity, and its infrastructure pauses as `{"scopes": [{scope, class, harness, model, tasks, cycle, until, exhausted, needs_you, hint, reset_at}]}`; `needs_you` (a bool), `hint` (text or `null`) and `reset_at` (an epoch or `null`) are absent in older runs, which read as `false`, `null` and `null` |
|
|
83
|
+
| `max_attempts` | the base attempt cap of every task, an integer: `0` for no cap; without the file it is `8`. A task's `retry=N` decisions add to it (see `attempt_cap` below) |
|
|
78
84
|
| `tasks/<id>/attempts/<role>-<uuid>/` | one execution of the task: `task`, `dwarf` or `qa` |
|
|
79
85
|
| `tasks/<id>/changes.diff` | `git diff --binary` of the task's work since its base, cumulative, rewritten every attempt; `changes.prev.diff` the previous attempt's; `committed.diff` base..the reviewed commit |
|
|
80
86
|
| `tasks/<id>/drift.txt`, `conflict.files` | one path per line: files the diff changed without declaring them; files that conflicted on merge |
|
|
@@ -217,7 +223,7 @@ loaded. When it cannot be loaded, `findings_available` is `false` and every find
|
|
|
217
223
|
is `null`; verdicts and `gate` do not need it.
|
|
218
224
|
|
|
219
225
|
Text fields are capped so one huge file cannot blow up a response: `request`, `prompt`,
|
|
220
|
-
`approach`, `retry_findings`, `needs_input` keep their first 20,000 characters; `qa_tail`, `dwarf_tail`
|
|
226
|
+
`approach`, `retry_findings`, `needs_input` and the `decision` text keep their first 20,000 characters, and an `infra` `detail` its first 400; `qa_tail`, `dwarf_tail`
|
|
221
227
|
and `verification.log_tail` keep their last 4,000. A capped field ends (or, for tails,
|
|
222
228
|
starts) with `…` and the value of `truncated` lists the field names that were cut.
|
|
223
229
|
|
|
@@ -501,7 +507,9 @@ Every RunSummary field, plus:
|
|
|
501
507
|
- `scheduler`: `live` is whether the pid in `scheduler.live` is a running process. Only then are the
|
|
502
508
|
rest read: `drained` (a `drain` file), `stopping` (`stop` holds `graceful` or `now`, else `null`),
|
|
503
509
|
`max_parallel` (the `max_parallel` file when it holds 1 to 64, else `null`) and `pauses` (the scopes of
|
|
504
|
-
`infra.paused`, `[]` without it
|
|
510
|
+
`infra.paused`, `[]` without it; each with `needs_you` (`true` only for a bool `true`), `hint` (a string or
|
|
511
|
+
`null`) and `reset_at` (an epoch or `null`), which an older scope lacks, so they read as `false`, `null`, `null`);
|
|
512
|
+
while no scheduler runs they are `false`, `null`, `null` and `[]`.
|
|
505
513
|
A solo run's `scheduler` is `null`.
|
|
506
514
|
- `sweep`: the run's finding sweep (`run --sweep`), `null` without `sweep/plan.json` (and for a solo
|
|
507
515
|
run). `tasks` are its fix tasks (tasks with a `sweep.json`), `findings` how many findings they took
|
|
@@ -554,6 +562,15 @@ Every RunSummary field, plus:
|
|
|
554
562
|
"approach": null,
|
|
555
563
|
"retry_findings": "...",
|
|
556
564
|
"needs_input": "the question in tasks/<id>/needs_input.md, or null",
|
|
565
|
+
"infra": {"cause": "capacity", "stage": "dwarf", "harness": "claude", "model": "opus", "reset_at": 1760630000.0,
|
|
566
|
+
"retry_after": 600.0, "detail": "the model is overloaded", "needs_you": false, "hint": null},
|
|
567
|
+
"lateral": [{"at": 1760620500.0, "attempt": 1, "role": "dwarf", "from": "luna", "to": "sol", "cause": "capacity"}],
|
|
568
|
+
"ledger": [{"at": 1760620500.0, "attempt": 1, "review": "final-review-1760620500-4242", "verdict": "FAIL", "gate": "P2",
|
|
569
|
+
"worst": "P1", "confirmed": 2, "new": 1, "carried": 0, "diff_bytes": 4096, "delta_bytes": null}],
|
|
570
|
+
"decision": {"reasons": ["converging", "cap"], "text": "the markdown in tasks/<id>/decision.md, after its first line"},
|
|
571
|
+
"decisions": [{"at": 1760621000.0, "attempt": 2, "choice": "retry=3", "reason": "the fix is close"}],
|
|
572
|
+
"attempts_total": 2,
|
|
573
|
+
"attempt_cap": 9,
|
|
557
574
|
"qa_tail": "last 4000 chars of qa.last",
|
|
558
575
|
"dwarf_tail": "last 4000 chars of dwarf.last",
|
|
559
576
|
"executions": [Execution, ...],
|
|
@@ -611,6 +628,28 @@ Every RunSummary field, plus:
|
|
|
611
628
|
malformed (malformed is warned).
|
|
612
629
|
- `needs_input`: the text of `tasks/<id>/needs_input.md`, capped like `prompt`, or `null` when the file is
|
|
613
630
|
missing. The question a task stopped `NEEDS_INPUT` for; the export leaves it out unless texts are chosen.
|
|
631
|
+
- `infra`: for an `INFRA` task, the stop record in `tasks/<id>/infra.txt`: `cause` (its `class=`, as written),
|
|
632
|
+
`stage`, `harness`, `model`, `reset_at` (an epoch), `retry_after` (seconds) and `detail` (capped at 400
|
|
633
|
+
characters; the export leaves it out unless texts are chosen). A missing value is `null`, and a missing
|
|
634
|
+
file gives all of them `null`. `needs_you` (a boolean) and `hint` (or `null`) are forge's own answer
|
|
635
|
+
(`forge_infra.stop_of`): the scheduler's pause that names the task, live (`infra.paused`) or the one the run
|
|
636
|
+
ended with (`infra.last`), else what the cause asks for when no peer can take the work. `null` for every
|
|
637
|
+
other status.
|
|
638
|
+
- `lateral`: the rows of `tasks/<id>/lateral.tsv`, as `escalations` are read (a row with fewer than six columns
|
|
639
|
+
or a bad epoch or attempt is warned and skipped); `[]` without the file.
|
|
640
|
+
- `ledger`: the rows of `tasks/<id>/ledger.tsv`, the newest 50 (the list is in `truncated` when rows were cut).
|
|
641
|
+
`gate`, `worst` and `delta_bytes` read `-` as `null`; the counts and `diff_bytes` are integers; a row with a
|
|
642
|
+
bad number is warned and skipped. `[]` without the file.
|
|
643
|
+
- `decision`: for a `NEEDS_DECISION` task, `{reasons, text}`: `reasons` from the first line of
|
|
644
|
+
`tasks/<id>/decision.md` (`[]` when it has none, and that is warned), `text` the rest of the file, capped
|
|
645
|
+
like `needs_input` (`null` when the file is missing). `null` for every other status. Its `text` is blanked
|
|
646
|
+
by the export unless texts are chosen; `reasons` stay.
|
|
647
|
+
- `decisions`: the rows of `tasks/<id>/decisions.tsv` as `{at, attempt, choice, reason}`, `reason` `null` when
|
|
648
|
+
empty; `[]` without the file. A human's `retry=N` grants N more attempts (see `attempt_cap`).
|
|
649
|
+
- `attempts_total`: the number of `attempts.tsv` rows whose status is not `INFRA`: an infrastructure stop
|
|
650
|
+
spends no attempt. `attempt` is still the highest attempt number.
|
|
651
|
+
- `attempt_cap`: the attempt cap of the task: the plan's `max_attempts` (`8` without the file, `null` when it
|
|
652
|
+
is `0`, no cap) plus the N of each `retry=N` decision; `null` when there is no cap. Solo runs have `null`.
|
|
614
653
|
- `known_issues`: whether `known_issues.md` is a non-empty file.
|
|
615
654
|
- `now`: `null` unless the task is `RUNNING`. Then where it is: the newest running non-shadow `dwarf`
|
|
616
655
|
or `qa` execution (`role`, `execution`, `attempt`, `phase`, `phase_started`, `started`), else the
|
|
@@ -625,7 +664,8 @@ Every RunSummary field, plus:
|
|
|
625
664
|
not a scheduler runs); else, while `scheduler.live` is true, for a `PENDING` or `INFRA` task:
|
|
626
665
|
`infra` (a pause in `scheduler.pauses` holds it: scope `all`, or its id in `tasks`; the pause's
|
|
627
666
|
keys plus `kind`), then for a `PENDING` task `deps` (`on`: its deps not merged, `stopped`: those
|
|
628
|
-
in a stopped status such as `FAIL
|
|
667
|
+
in a stopped status such as `FAIL`; a dep at `NEEDS_INPUT` or `NEEDS_DECISION` is in `on` only, as the user
|
|
668
|
+
holds it and the retry policy did not stop it), `stopping` (`mode`), `drained`, `overlap` (`on`: running
|
|
629
669
|
tasks whose files overlap its own, as forge-schedule.py tells overlap), `slot` (`running`,
|
|
630
670
|
`max_parallel`: the run is at its capacity) or `next` (nothing holds it).
|
|
631
671
|
- `sweep`: `null` unless the task is a finding sweep's fix task (it has a `sweep.json`). Then `file`
|
|
@@ -644,7 +684,9 @@ from the run dir's `attempts.tsv`. `status` is the solo status; `attempt` is the
|
|
|
644
684
|
in `attempts.tsv`, or `null`. `escalations`, `route` and `shadow` are empty. `verdict` and
|
|
645
685
|
`qa_tail` come from `qa.last`, and `prompt` comes from `prompt.md`. `deps` and `files` are
|
|
646
686
|
`[]`; `difficulty`, `accepted_by`, `approach`, `retry_findings` and `needs_input` are `null`; `accepted` is
|
|
647
|
-
false; `accepted_attempt` and `accepted_over` are `null`; `explored` is false; `waiting` and `sweep` are `null`, `swept` is `[]`.
|
|
687
|
+
false; `accepted_attempt` and `accepted_over` are `null`; `explored` is false; `waiting` and `sweep` are `null`, `swept` is `[]`.
|
|
688
|
+
`infra` and `decision` are `null`, `lateral`, `ledger` and `decisions` are `[]`, `attempt_cap` is `null`, and `attempts_total`
|
|
689
|
+
counts the run dir's `attempts.tsv` rows that are not `INFRA`. `request` on
|
|
648
690
|
the detail is `request.md`.
|
|
649
691
|
|
|
650
692
|
## Execution
|
|
@@ -1204,7 +1246,7 @@ difficulty paths deps model` each), `decomposition_history` (its newest 20, each
|
|
|
1204
1246
|
(under their tail paths; line ranges are not stored, so the page shows the tail).
|
|
1205
1247
|
- `texts=0` (the default) nulls these keys wherever they hold a string, list or object: `prompt
|
|
1206
1248
|
last request log_tail dwarf_tail qa_tail qa_last qa_input tasks_summary known_issues texts text
|
|
1207
|
-
planning_last approach retry_findings needs_input dwarf_input error last_line message excerpt tail lines call split`,
|
|
1249
|
+
planning_last approach retry_findings needs_input dwarf_input error last_line message excerpt tail lines call split detail`,
|
|
1208
1250
|
and stores no diff, no transcript, no checks and no environment problems (a command is a text). A finding keeps its `summary`, a failing test its `name`.
|
|
1209
1251
|
- `paths=0` (the default) makes every string that is a whole absolute path (but `/api/…`, `url`s
|
|
1210
1252
|
and `command`s) its last component, and replaces the run dir, the repo and the home dir inside other
|
|
@@ -1452,7 +1494,8 @@ stage's own background and accent are `--stage-bg` and `--stage-accent` on `.sta
|
|
|
1452
1494
|
|
|
1453
1495
|
Suggested meaning: merged and pass green, running blue, pending grey, fail, error and conflict
|
|
1454
1496
|
red, infra and timeout orange, blocked, interrupted, invalidated, unknown and nochanges muted
|
|
1455
|
-
purple.
|
|
1497
|
+
purple. `NEEDS_DECISION` takes the same waiting colour as `NEEDS_INPUT` (`--lamp-wait`, the
|
|
1498
|
+
`st-needs_input` class in `style.css`): a task that waits for the user is neither done nor failed.
|
|
1456
1499
|
|
|
1457
1500
|
## The graph (`forge_ui/static/graph.js`)
|
|
1458
1501
|
|
package/ui/forge_ui/export.py
CHANGED
|
@@ -38,7 +38,10 @@ _EXEC = re.compile(r'(?:task|dwarf|qa|solo|verification|parallel)-[0-9a-f]{32}')
|
|
|
38
38
|
_TEXT_KEYS = frozenset(('prompt', 'last', 'request', 'log_tail', 'dwarf_tail', 'qa_tail', 'qa_last', 'qa_input',
|
|
39
39
|
'tasks_summary', 'known_issues', 'texts', 'text', 'planning_last', 'approach', 'retry_findings',
|
|
40
40
|
'dwarf_input', 'error', 'last_line', 'message', 'excerpt', 'tail', 'lines', 'call', 'split',
|
|
41
|
-
'needs_input'))
|
|
41
|
+
'needs_input', 'detail'))
|
|
42
|
+
# keys that are private text only under one parent: a person's --reason on each decision (`reason` elsewhere is
|
|
43
|
+
# a short machine word, such as a sweep's dropped-finding reason, and stays)
|
|
44
|
+
_TEXT_KEYS_UNDER = {'decisions': frozenset(('reason',))}
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
def _enc(value):
|
|
@@ -109,7 +112,8 @@ class _Snapshot:
|
|
|
109
112
|
|
|
110
113
|
def clean(self, value, key=None):
|
|
111
114
|
if isinstance(value, dict):
|
|
112
|
-
|
|
115
|
+
private = _TEXT_KEYS | _TEXT_KEYS_UNDER.get(key, frozenset())
|
|
116
|
+
return {k: (None if not self.texts and k in private and isinstance(v, (str, dict, list)) else self.clean(v, k))
|
|
113
117
|
for k, v in value.items()}
|
|
114
118
|
if isinstance(value, list):
|
|
115
119
|
return [self.clean(v, key) for v in value]
|