@giamme/forge 0.18.0 → 0.19.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 +33 -0
- package/README.md +1 -0
- package/SKILL.md +16 -2
- package/VERSION +1 -1
- package/docs/artifacts.md +25 -1
- package/docs/commands.md +81 -14
- package/docs/decomposed-runs.md +114 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +84 -15
- package/docs/memory.md +25 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/forge +20 -3
- package/package.json +2 -1
- package/references/dataset.md +20 -1
- package/references/decompose.md +621 -33
- package/references/harnesses.md +18 -3
- package/references/planning.md +43 -14
- package/references/ui.md +53 -6
- package/registry.tsv +8 -3
- package/scripts/forge-brief.py +88 -3
- package/scripts/forge-compare.py +4 -3
- package/scripts/forge-contract.py +202 -27
- package/scripts/forge-control.py +117 -5
- package/scripts/forge-dispatch.sh +34 -5
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-lib-group.sh +641 -0
- package/scripts/forge-lib-plans.sh +339 -3
- package/scripts/forge-lib-task.sh +197 -4
- package/scripts/forge-memory.sh +245 -3
- package/scripts/forge-parallel.sh +715 -34
- package/scripts/forge-planner.py +104 -8
- package/scripts/forge-route.py +190 -12
- package/scripts/forge-runs.py +9 -5
- package/scripts/forge-schedule.py +354 -45
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-worktrees.py +243 -0
- package/scripts/forge_brief/__init__.py +294 -50
- package/scripts/forge_brief/answers.py +58 -11
- package/scripts/forge_brief/proposals.py +1630 -0
- package/scripts/forge_dataset/efforts.py +4 -3
- package/scripts/forge_dataset/export.py +24 -12
- package/scripts/forge_dataset/facts.py +5 -3
- package/scripts/forge_dataset/forecast.py +8 -18
- package/scripts/forge_dataset/harvest.py +204 -9
- package/scripts/forge_dataset/history.py +11 -6
- package/scripts/forge_dataset/importer.py +65 -1
- package/scripts/forge_dataset/names.py +66 -0
- package/scripts/forge_dataset/reviewers.py +5 -2
- package/scripts/forge_dataset/risk.py +6 -3
- package/scripts/forge_dataset/routing.py +6 -1
- package/scripts/forge_groups/__init__.py +308 -0
- package/scripts/forge_groups/attribute.py +289 -0
- package/scripts/forge_groups/review.py +286 -0
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_side/__init__.py +12 -7
- package/ui/docs/api.md +173 -17
- package/ui/forge_ui/control.py +361 -2
- package/ui/forge_ui/executions.py +8 -1
- package/ui/forge_ui/export.py +31 -4
- package/ui/forge_ui/groups.py +264 -0
- package/ui/forge_ui/models.py +70 -8
- package/ui/forge_ui/reader.py +262 -19
- package/ui/forge_ui/server.py +4 -0
- package/ui/forge_ui/static/app.js +93 -13
- package/ui/forge_ui/static/briefview.js +350 -47
- package/ui/forge_ui/static/diffview.js +86 -1
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +1 -0
- package/ui/forge_ui/static/panel.js +127 -7
- package/ui/forge_ui/static/projectsview.js +189 -10
- package/ui/forge_ui/static/runmodel.js +14 -3
- package/ui/forge_ui/static/storageview.js +91 -10
- package/ui/forge_ui/static/style.css +79 -5
- package/ui/forge_ui/static/worktreesview.js +233 -12
- package/ui/forge_ui/storage.py +14 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"""Groups of a plan: `<plan>/groups.tsv` and, for a group that is reviewed as one, `<plan>/groups/<gid>/`.
|
|
2
|
+
|
|
3
|
+
Read through the run reader (`text`, `rows`, `object`, `exists`). A missing file is an empty result.
|
|
4
|
+
A malformed one is a warning on `reader.warnings` and whatever rows could still be read: nothing here raises.
|
|
5
|
+
|
|
6
|
+
`groups.tsv` is `id review qa members title goal`, tab-separated, `#` comments and blank lines ignored.
|
|
7
|
+
`-` in a cell is `None`. `members` is a list of task ids. A `review=task` group is that identity only.
|
|
8
|
+
A `review=group` group also has the review state in its directory: `status`, `round`, `merged`,
|
|
9
|
+
`rounds.tsv` (`round epoch status implicated reviewer`), and the first line of `decision.md`.
|
|
10
|
+
`group()` adds the review itself: `attribution.json`, `members.tsv`, `qa.last`, `known_issues.md`,
|
|
11
|
+
`candidate.base` and `candidate.commit`, and the QA dispatch `executions.scan` reads from
|
|
12
|
+
`groups/<gid>/attempts/` — the same builder a task's QA dispatch uses.
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import math
|
|
17
|
+
import re
|
|
18
|
+
|
|
19
|
+
from forge_ui import executions
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# The same shape forge_groups accepts, and the shape the group route matches.
|
|
23
|
+
GID = re.compile(r'[a-z0-9][a-z0-9-]{0,39}')
|
|
24
|
+
# Head and tail kept of a review text, as TaskDetail's texts and a final review's qa.last do
|
|
25
|
+
# (reader.excerpt: two bounded reads, the cut marked in reader.truncated).
|
|
26
|
+
_TEXT_HEAD = 20000
|
|
27
|
+
_TEXT_TAIL = 8000
|
|
28
|
+
_REVIEWS = ('task', 'group')
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _blank(value):
|
|
32
|
+
"""A stripped cell, or None for an empty one and for `-`."""
|
|
33
|
+
if value is None:
|
|
34
|
+
return None
|
|
35
|
+
text = str(value).strip()
|
|
36
|
+
return None if text in ('', '-') else text
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _id_list(value):
|
|
40
|
+
"""A comma list of ids, or None for an empty cell and for `-`."""
|
|
41
|
+
text = _blank(value)
|
|
42
|
+
if text is None:
|
|
43
|
+
return None
|
|
44
|
+
items = [part.strip() for part in text.split(',') if part.strip()]
|
|
45
|
+
return items or None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _int(reader, label, value, what):
|
|
49
|
+
text = (value or '').strip()
|
|
50
|
+
if text in ('', '-'):
|
|
51
|
+
return None
|
|
52
|
+
try:
|
|
53
|
+
return int(text)
|
|
54
|
+
except (ValueError, OverflowError):
|
|
55
|
+
reader.warn(label, f'{what} is not an integer')
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _rounds(reader, name):
|
|
60
|
+
"""rounds.tsv rows that parse. A bad row is warned and skipped."""
|
|
61
|
+
result = []
|
|
62
|
+
for label, row in reader.rows(name, 5):
|
|
63
|
+
if len(row) != 5:
|
|
64
|
+
reader.warn(label, 'expected 5 columns')
|
|
65
|
+
try:
|
|
66
|
+
number, epoch = int(row[0].strip()), float(row[1].strip())
|
|
67
|
+
if not math.isfinite(epoch):
|
|
68
|
+
raise ValueError()
|
|
69
|
+
except (ValueError, OverflowError):
|
|
70
|
+
reader.warn(label, 'invalid round or epoch')
|
|
71
|
+
continue
|
|
72
|
+
result.append(dict(round=number, epoch=epoch, status=_blank(row[2]),
|
|
73
|
+
implicated=_id_list(row[3]), reviewer=_blank(row[4])))
|
|
74
|
+
return result
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _state(reader, gid):
|
|
78
|
+
"""The review state a review=group group carries. Missing files are null, not an error."""
|
|
79
|
+
prefix = f'groups/{gid}'
|
|
80
|
+
rounds = _rounds(reader, prefix + '/rounds.tsv')
|
|
81
|
+
last = rounds[-1] if rounds else None
|
|
82
|
+
return dict(status=reader.word(prefix + '/status'), round=reader.number(prefix + '/round', int),
|
|
83
|
+
merged=reader.exists(prefix + '/merged'),
|
|
84
|
+
implicated=None if last is None else last['implicated'],
|
|
85
|
+
decision=reader.line(prefix + '/decision.md'), rounds=rounds)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def groups(reader) -> list:
|
|
89
|
+
"""One dict per groups.tsv row, in file order. `[]` when the plan has no groups.tsv."""
|
|
90
|
+
if not reader.exists('groups.tsv'):
|
|
91
|
+
return []
|
|
92
|
+
found, seen = [], set()
|
|
93
|
+
for label, row in reader.rows('groups.tsv', 6):
|
|
94
|
+
if len(row) != 6:
|
|
95
|
+
reader.warn(label, 'expected 6 columns')
|
|
96
|
+
gid = row[0].strip()
|
|
97
|
+
if not GID.fullmatch(gid):
|
|
98
|
+
reader.warn(label, 'invalid group id')
|
|
99
|
+
continue
|
|
100
|
+
if gid in seen:
|
|
101
|
+
reader.warn(label, 'duplicate group id')
|
|
102
|
+
continue
|
|
103
|
+
seen.add(gid)
|
|
104
|
+
# `-` is None in every cell, review included. Anything but task or group is still returned,
|
|
105
|
+
# without review state, and warned.
|
|
106
|
+
review = _blank(row[1])
|
|
107
|
+
if review not in _REVIEWS:
|
|
108
|
+
reader.warn(label, 'review must be task or group')
|
|
109
|
+
item = dict(id=gid, review=review, qa=_blank(row[2]), members=_id_list(row[3]),
|
|
110
|
+
title=_blank(row[4]), goal=_blank('\t'.join(row[5:])))
|
|
111
|
+
if review == 'group':
|
|
112
|
+
item.update(_state(reader, gid))
|
|
113
|
+
found.append(item)
|
|
114
|
+
return found
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _members_by_round(reader, name):
|
|
118
|
+
"""members.tsv grouped by round, in file order: [{round, members: [{task, commit, attempt}]}]."""
|
|
119
|
+
rows = []
|
|
120
|
+
for label, row in reader.rows(name, 4):
|
|
121
|
+
raw = (row[0] or '').strip()
|
|
122
|
+
number = _int(reader, label, row[0], 'round')
|
|
123
|
+
if number is None:
|
|
124
|
+
# `_int` already warned a cell that is not an integer. A blank one has not.
|
|
125
|
+
if raw in ('', '-'):
|
|
126
|
+
reader.warn(label, 'invalid round')
|
|
127
|
+
continue
|
|
128
|
+
task = row[1].strip()
|
|
129
|
+
if not task or task == '-':
|
|
130
|
+
reader.warn(label, 'missing task')
|
|
131
|
+
continue
|
|
132
|
+
rows.append(dict(round=number, task=task, commit=_blank(row[2]),
|
|
133
|
+
attempt=_int(reader, label, row[3], 'attempt')))
|
|
134
|
+
grouped, index = [], {}
|
|
135
|
+
for row in rows:
|
|
136
|
+
bucket = index.get(row['round'])
|
|
137
|
+
if bucket is None:
|
|
138
|
+
bucket = index[row['round']] = dict(round=row['round'], members=[])
|
|
139
|
+
grouped.append(bucket)
|
|
140
|
+
bucket['members'].append(dict(task=row['task'], commit=row['commit'], attempt=row['attempt']))
|
|
141
|
+
return grouped
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _flag(reader, name, index, item, key):
|
|
145
|
+
value = item.get(key)
|
|
146
|
+
if type(value) is bool:
|
|
147
|
+
return value
|
|
148
|
+
if value is not None:
|
|
149
|
+
reader.warn(name, f'finding {index} {key} is not a boolean')
|
|
150
|
+
return False
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _finding(reader, name, index, item):
|
|
154
|
+
number = item.get('n')
|
|
155
|
+
if type(number) is not int:
|
|
156
|
+
reader.warn(name, f'finding {index} has no n')
|
|
157
|
+
number = index
|
|
158
|
+
line = item.get('line')
|
|
159
|
+
if type(line) is not int:
|
|
160
|
+
if line is not None:
|
|
161
|
+
reader.warn(name, f'finding {index} line is not an integer')
|
|
162
|
+
line = None
|
|
163
|
+
tasks = item.get('tasks')
|
|
164
|
+
if not (isinstance(tasks, list) and all(isinstance(part, str) for part in tasks)):
|
|
165
|
+
reader.warn(name, f'finding {index} tasks is not a list of ids')
|
|
166
|
+
tasks = []
|
|
167
|
+
|
|
168
|
+
def text(key):
|
|
169
|
+
value = item.get(key)
|
|
170
|
+
return value if isinstance(value, str) and value else None
|
|
171
|
+
|
|
172
|
+
return dict(n=number, severity=text('severity'), status=text('status'), file=text('file'), line=line,
|
|
173
|
+
tasks=tasks, blocking=_flag(reader, name, index, item, 'blocking'),
|
|
174
|
+
ambiguous=_flag(reader, name, index, item, 'ambiguous'))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _strings(reader, name, obj, key):
|
|
178
|
+
value = obj.get(key)
|
|
179
|
+
if value is None:
|
|
180
|
+
return []
|
|
181
|
+
if isinstance(value, list) and all(isinstance(part, str) for part in value):
|
|
182
|
+
return value
|
|
183
|
+
reader.warn(name, f'{key} is not a list of ids')
|
|
184
|
+
return []
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _numbers(reader, name, obj, key):
|
|
188
|
+
value = obj.get(key)
|
|
189
|
+
if value is None:
|
|
190
|
+
return []
|
|
191
|
+
if isinstance(value, list) and all(type(part) is int for part in value):
|
|
192
|
+
return value
|
|
193
|
+
reader.warn(name, f'{key} is not a list of numbers')
|
|
194
|
+
return []
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _attribution(reader, name):
|
|
198
|
+
"""attribution.json, or None when it is missing or not an attribution (warned)."""
|
|
199
|
+
obj = reader.object(name)
|
|
200
|
+
if obj is None:
|
|
201
|
+
return None
|
|
202
|
+
findings = obj.get('findings')
|
|
203
|
+
if not isinstance(findings, list):
|
|
204
|
+
reader.warn(name, 'not an attribution')
|
|
205
|
+
return None
|
|
206
|
+
parsed = []
|
|
207
|
+
for index, item in enumerate(findings, 1):
|
|
208
|
+
if not isinstance(item, dict):
|
|
209
|
+
reader.warn(name, f'finding {index} is not an object')
|
|
210
|
+
continue
|
|
211
|
+
parsed.append(_finding(reader, name, index, item))
|
|
212
|
+
number = obj.get('round')
|
|
213
|
+
if type(number) is not int:
|
|
214
|
+
if number is not None:
|
|
215
|
+
reader.warn(name, 'round is not an integer')
|
|
216
|
+
number = None
|
|
217
|
+
result = dict(round=number, findings=parsed, implicated=_strings(reader, name, obj, 'implicated'),
|
|
218
|
+
ambiguous=_numbers(reader, name, obj, 'ambiguous'))
|
|
219
|
+
blocking = obj.get('blocking')
|
|
220
|
+
if type(blocking) is bool:
|
|
221
|
+
result['blocking'] = blocking
|
|
222
|
+
elif blocking is not None:
|
|
223
|
+
reader.warn(name, 'blocking is not a boolean')
|
|
224
|
+
return result
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _review_execution(reader, gid):
|
|
228
|
+
"""The group's QA dispatch, built the same way as a task's: the newest qa execution in its attempts/."""
|
|
229
|
+
prefix = f'groups/{gid}'
|
|
230
|
+
# REVIEWING is the only status on which the dispatch is still in flight. Any other, including a
|
|
231
|
+
# missing status file, leaves an execution with no exit code orphaned rather than running.
|
|
232
|
+
execs = executions.scan(reader, prefix + '/attempts', reader.word(prefix + '/status') == 'REVIEWING', ('qa',))
|
|
233
|
+
return execs[-1] if execs else None
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def group(reader, gid) -> dict | None:
|
|
237
|
+
"""One group, with its review, or None when `gid` is not a group of this plan.
|
|
238
|
+
|
|
239
|
+
A gid that cannot name a group dir (`GID`) is None without a read. The dict is the `groups()`
|
|
240
|
+
row plus `attribution`, `members_by_round`, `qa_last`, `known_issues`, `candidate` and
|
|
241
|
+
`execution`. `qa_last` and `known_issues` go through `reader.excerpt`, the bounded reader the
|
|
242
|
+
task and review inspectors use. `warnings` are this group's files under `groups/<gid>/`:
|
|
243
|
+
a bad `groups.tsv` row, and another group's files, belong to the list read, not this one.
|
|
244
|
+
`truncated` names the texts this read cut.
|
|
245
|
+
"""
|
|
246
|
+
if not isinstance(gid, str) or not GID.fullmatch(gid):
|
|
247
|
+
return None
|
|
248
|
+
noted = len(reader.warnings)
|
|
249
|
+
cut = len(reader.truncated)
|
|
250
|
+
found = next((dict(item) for item in groups(reader) if item['id'] == gid), None)
|
|
251
|
+
if found is None:
|
|
252
|
+
return None
|
|
253
|
+
prefix = f'groups/{gid}/'
|
|
254
|
+
found['attribution'] = _attribution(reader, prefix + 'attribution.json')
|
|
255
|
+
found['members_by_round'] = _members_by_round(reader, prefix + 'members.tsv')
|
|
256
|
+
found['qa_last'] = reader.excerpt(prefix + 'qa.last', _TEXT_HEAD, _TEXT_TAIL, 'qa_last')
|
|
257
|
+
found['known_issues'] = reader.excerpt(prefix + 'known_issues.md', _TEXT_HEAD, _TEXT_TAIL, 'known_issues')
|
|
258
|
+
found['candidate'] = dict(base=_blank(reader.line(prefix + 'candidate.base')),
|
|
259
|
+
commit=_blank(reader.line(prefix + 'candidate.commit')))
|
|
260
|
+
found['execution'] = _review_execution(reader, gid)
|
|
261
|
+
# groups() walked every row. Keep warnings for this group's files only: not groups.tsv, not another group.
|
|
262
|
+
found['warnings'] = [item for item in reader.warnings[noted:] if item.startswith(prefix)]
|
|
263
|
+
found['truncated'] = reader.truncated[cut:]
|
|
264
|
+
return found
|
package/ui/forge_ui/models.py
CHANGED
|
@@ -69,6 +69,44 @@ def _is_side_role():
|
|
|
69
69
|
return fn
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
_NAMES = _DATASET.parent / 'names.py'
|
|
73
|
+
_NAME_FN = {}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _dispatch_name():
|
|
77
|
+
"""forge_dataset.names.dispatch_name, loaded read-only. None when it cannot be."""
|
|
78
|
+
with _SIDE_LOCK:
|
|
79
|
+
if 'fn' in _NAME_FN:
|
|
80
|
+
return _NAME_FN['fn']
|
|
81
|
+
fn = None
|
|
82
|
+
try:
|
|
83
|
+
spec = importlib.util.spec_from_file_location(
|
|
84
|
+
'forge_dataset_names_for_ui', _NAMES,
|
|
85
|
+
loader=findings._ReadOnlyLoader('forge_dataset_names_for_ui', str(_NAMES)))
|
|
86
|
+
module = importlib.util.module_from_spec(spec)
|
|
87
|
+
spec.loader.exec_module(module)
|
|
88
|
+
candidate = getattr(module, 'dispatch_name', None)
|
|
89
|
+
fn = candidate if callable(candidate) else None
|
|
90
|
+
except Exception:
|
|
91
|
+
fn = None
|
|
92
|
+
_NAME_FN['fn'] = fn
|
|
93
|
+
return fn
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _named(model):
|
|
97
|
+
"""The alias a model row is counted under: an alias that has since moved to a newer model
|
|
98
|
+
names its old dispatches by the alias that resolves to their model today (`terra-5.6`)."""
|
|
99
|
+
if not model:
|
|
100
|
+
return None
|
|
101
|
+
fn = _dispatch_name()
|
|
102
|
+
if fn is None:
|
|
103
|
+
return model.get('alias')
|
|
104
|
+
try:
|
|
105
|
+
return fn(dict(alias=model.get('alias'), model=model.get('model'), harness=model.get('harness'))) or model.get('alias')
|
|
106
|
+
except Exception:
|
|
107
|
+
return model.get('alias')
|
|
108
|
+
|
|
109
|
+
|
|
72
110
|
def side_role(role) -> bool:
|
|
73
111
|
"""A side dispatch: harvested `side_*`, or the on-disk role `side` (`is_side_role` rejects the bare name).
|
|
74
112
|
|
|
@@ -82,10 +120,30 @@ def side_role(role) -> bool:
|
|
|
82
120
|
return isinstance(role, str) and role.startswith('side_')
|
|
83
121
|
|
|
84
122
|
|
|
123
|
+
def _group_scope(item) -> bool:
|
|
124
|
+
"""A group review: one QA dispatch for several tasks, not one task's review of record.
|
|
125
|
+
|
|
126
|
+
The execution may say so (`scope`, or dataset.json's `scope`). A path under
|
|
127
|
+
`groups/<gid>/` says so too, which is how a scan of that dir is recognized before
|
|
128
|
+
the execution dict carries the field. A task whose id is `groups` lives under `tasks/`.
|
|
129
|
+
"""
|
|
130
|
+
if item.get('scope') == 'group':
|
|
131
|
+
return True
|
|
132
|
+
dataset = getattr(item, 'dataset', None)
|
|
133
|
+
if isinstance(dataset, dict) and dataset.get('scope') == 'group':
|
|
134
|
+
return True
|
|
135
|
+
rel = getattr(item, 'rel', None)
|
|
136
|
+
if not isinstance(rel, str) or not rel:
|
|
137
|
+
return False
|
|
138
|
+
head, _, _ = rel.partition('/')
|
|
139
|
+
return head == 'groups'
|
|
140
|
+
|
|
141
|
+
|
|
85
142
|
def _primary_qa(item) -> bool:
|
|
86
|
-
"""The review of record for an attempt. A shadow review
|
|
143
|
+
"""The review of record for an attempt. A shadow review, a side dispatch and a group review are not one."""
|
|
87
144
|
role = item['role']
|
|
88
|
-
return role == 'qa' and not item['shadow'] and role != 'qa_shadow' and not side_role(role)
|
|
145
|
+
return (role == 'qa' and not item['shadow'] and role != 'qa_shadow' and not side_role(role)
|
|
146
|
+
and not _group_scope(item))
|
|
89
147
|
|
|
90
148
|
|
|
91
149
|
def _builtin_profiles_path():
|
|
@@ -193,7 +251,7 @@ def _attempts(rows, execs, plan_spec):
|
|
|
193
251
|
else:
|
|
194
252
|
spec = source = None
|
|
195
253
|
verdict = reviews[-1]['verdict'] if reviews else None
|
|
196
|
-
result.append(dict(n=n, alias=model
|
|
254
|
+
result.append(dict(n=n, alias=_named(model) if model else _alias(spec), spec=spec, source=source,
|
|
197
255
|
outcome=outcome, reason=reason, gate=outcome == 'pass' and verdict == 'FAIL',
|
|
198
256
|
gate_fail=outcome == 'fail' and verdict == 'PASS',
|
|
199
257
|
model_s=last['phases'].get('model') if last is not None else None,
|
|
@@ -221,7 +279,7 @@ def _reviews(key, ident, execs, shadows):
|
|
|
221
279
|
for item in execs:
|
|
222
280
|
if _primary_qa(item) and item['state'] == 'done':
|
|
223
281
|
model = item['model'] or {}
|
|
224
|
-
rows.append(dict(run=key, task=ident, n=item['attempt'], kind='primary', alias=model
|
|
282
|
+
rows.append(dict(run=key, task=ident, n=item['attempt'], kind='primary', alias=_named(model),
|
|
225
283
|
spec=model.get('spec'), verdict=item['verdict'], findings=item['findings'],
|
|
226
284
|
duration_s=item['duration_s'], tokens=item['tokens'], agreement=None, primary_alias=None))
|
|
227
285
|
for entry, items, _ in shadows:
|
|
@@ -231,11 +289,11 @@ def _reviews(key, ident, execs, shadows):
|
|
|
231
289
|
spec = entry['spec'] if isinstance(entry['spec'], str) else model.get('spec')
|
|
232
290
|
primaries = [item for item in execs if _primary_qa(item)
|
|
233
291
|
and item['attempt'] == entry['attempt'] and item['model']]
|
|
234
|
-
rows.append(dict(run=key, task=ident, n=entry['attempt'], kind='shadow', alias=model
|
|
292
|
+
rows.append(dict(run=key, task=ident, n=entry['attempt'], kind='shadow', alias=_named(model) or _alias(spec),
|
|
235
293
|
spec=spec, verdict=entry['verdict'], findings=entry['findings'],
|
|
236
294
|
duration_s=entry['duration_s'], tokens=items[-1]['tokens'] if items else None,
|
|
237
295
|
agreement=entry['agreement'],
|
|
238
|
-
primary_alias=primaries[-1]['model']
|
|
296
|
+
primary_alias=_named(primaries[-1]['model']) if primaries else _alias(entry['primary'])))
|
|
239
297
|
return rows
|
|
240
298
|
|
|
241
299
|
|
|
@@ -258,10 +316,14 @@ def _facts(path, summary, root):
|
|
|
258
316
|
execs = reader._task_execs(rd, task)
|
|
259
317
|
shadows = reader._shadows(rd, task['id'], execs)
|
|
260
318
|
explored, propensity = _route(rd, base)
|
|
319
|
+
# A scripted task (#142) ran a command, not a model: its attempts are no implementer's result.
|
|
320
|
+
# Its reviews still count for the reviewer.
|
|
321
|
+
scripted = task['dwarf'] == 'script'
|
|
261
322
|
tasks.append(dict(base_row, task=task['id'], kind='plan', difficulty=task['difficulty'] or None,
|
|
262
323
|
explored=explored, propensity=propensity, final_status=task['status'],
|
|
263
324
|
accepted=reader._nonempty(rd, base + '/accepted.by'),
|
|
264
|
-
attempts=_attempts(_attempt_rows(rd, base + '/attempts.tsv'), execs,
|
|
325
|
+
attempts=[] if scripted else _attempts(_attempt_rows(rd, base + '/attempts.tsv'), execs,
|
|
326
|
+
task['dwarf']),
|
|
265
327
|
escalations=[{'n': item['attempt'], 'from': item['from'], 'to': item['to']}
|
|
266
328
|
for item in reader._history(rd, base + '/escalations.tsv', True)]))
|
|
267
329
|
reviews += _reviews(key, task['id'], execs, shadows)
|
|
@@ -274,7 +336,7 @@ def _facts(path, summary, root):
|
|
|
274
336
|
run = execs[-1] if execs else None
|
|
275
337
|
model = (run['model'] if run else None) or {}
|
|
276
338
|
spec = review['spec'] or model.get('spec')
|
|
277
|
-
reviews.append(dict(run=key, task=None, n=None, kind='final', alias=model
|
|
339
|
+
reviews.append(dict(run=key, task=None, n=None, kind='final', alias=_named(model) or _alias(spec),
|
|
278
340
|
spec=spec, verdict=review['verdict'] if review['verdict'] in ('PASS', 'FAIL') else None,
|
|
279
341
|
findings=review['findings'], duration_s=review['duration_s'],
|
|
280
342
|
tokens=run['tokens'] if run else None, agreement=None, primary_alias=None))
|