@giamme/forge 0.11.1 → 0.12.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/SKILL.md +7 -3
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +50 -11
  5. package/docs/commands.md +56 -8
  6. package/docs/decomposed-runs.md +43 -2
  7. package/docs/forge-ui.md +55 -8
  8. package/docs/reviews.md +64 -6
  9. package/package.json +1 -1
  10. package/references/dataset.md +4 -2
  11. package/references/decompose.md +191 -17
  12. package/references/harnesses.md +13 -1
  13. package/references/ui.md +25 -4
  14. package/scripts/forge-contract.py +37 -7
  15. package/scripts/forge-control.py +268 -25
  16. package/scripts/forge-dispatch.sh +90 -3
  17. package/scripts/forge-guard.py +156 -15
  18. package/scripts/forge-issues.py +47 -3
  19. package/scripts/forge-lib-plans.sh +9 -3
  20. package/scripts/forge-lib-review.sh +24 -5
  21. package/scripts/forge-lib-task.sh +53 -5
  22. package/scripts/forge-lib-verify.sh +137 -6
  23. package/scripts/forge-parallel-options.sh +85 -0
  24. package/scripts/forge-parallel.sh +262 -31
  25. package/scripts/forge-ripwire.py +1 -1
  26. package/scripts/forge-route.py +157 -5
  27. package/scripts/forge-runtime.py +49 -1
  28. package/scripts/forge-schedule.py +735 -53
  29. package/scripts/forge-solo.sh +3 -1
  30. package/scripts/forge-sweep.py +542 -0
  31. package/scripts/forge-verify.py +878 -0
  32. package/scripts/forge_dataset/forecast.py +33 -5
  33. package/scripts/forge_dataset/harvest.py +10 -4
  34. package/scripts/forge_verify_reports.py +225 -0
  35. package/ui/README.md +58 -12
  36. package/ui/docs/api.md +277 -28
  37. package/ui/forge_ui/checks.py +331 -0
  38. package/ui/forge_ui/control.py +12 -2
  39. package/ui/forge_ui/export.py +25 -8
  40. package/ui/forge_ui/reader.py +657 -24
  41. package/ui/forge_ui/server.py +29 -0
  42. package/ui/forge_ui/static/app.js +15 -7
  43. package/ui/forge_ui/static/checksview.js +449 -0
  44. package/ui/forge_ui/static/controls.js +217 -33
  45. package/ui/forge_ui/static/convo.js +11 -2
  46. package/ui/forge_ui/static/findingsview.js +6 -4
  47. package/ui/forge_ui/static/gantt.js +14 -9
  48. package/ui/forge_ui/static/index.html +2 -0
  49. package/ui/forge_ui/static/panel.js +44 -1
  50. package/ui/forge_ui/static/runmodel.js +109 -12
  51. package/ui/forge_ui/static/scene3d.js +9 -5
  52. package/ui/forge_ui/static/style.css +113 -0
  53. package/ui/forge_ui/static/verifyview.js +324 -0
  54. package/ui/forge_ui/transcripts.py +225 -54
@@ -0,0 +1,331 @@
1
+ """The checks an agent ran, read from its transcript (transcripts.py): each test, type check, lint or build command
2
+ with its exit, how long it took and the counts it printed; the call it is running now; the commands its brief's
3
+ acceptance criteria name that it never ran; and the environment problems its failed commands met (Docker, a
4
+ sandbox's EPERM, a port in use, …), which forge-ui groups across a run's tasks.
5
+
6
+ Nothing here opens a file: it reads the events transcripts.transcript() answers and the brief's text.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import re
11
+
12
+ KINDS = ('test', 'typecheck', 'lint', 'build')
13
+ COMMAND_CAP = 1000 # characters of a command kept in a check
14
+ LINE_CAP = 240 # of an environment problem's line
15
+ TAIL_LINES = 6 # of a failed check's output, its last non-empty lines
16
+ _ANSI = re.compile(r'\x1b\[[0-9;?]*[ -/]*[@-~]')
17
+
18
+ # ---------- what a command is ----------
19
+
20
+ _SPLIT = re.compile(r'\s*(?:&&|\|\||;|\||\n)\s*')
21
+ _WRAPPED = re.compile(r'''^(?:/\S+/)?(?:ba|z)?sh\s+-l?c\s+(['"])(.*)\1$''', re.S)
22
+ _PREFIX = re.compile(r'''^(?:[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|\S*)\s+|env\s+|command\s+|exec\s+|time\s+|nice\s+(?:-n\s*-?\d+\s+)?
23
+ |timeout\s+(?:-\S+\s+)*\d+(?:\.\d+)?[smhd]?\s+|gtimeout\s+(?:-\S+\s+)*\d+[smhd]?\s+|xvfb-run\s+(?:-\S+\s+)*
24
+ |uv\s+run\s+(?:--?[A-Za-z-]+(?:[= ](?!-)\S+)?\s+)*|poetry\s+run\s+|pipenv\s+run\s+|hatch\s+run\s+|pdm\s+run\s+|rye\s+run\s+
25
+ |npx\s+(?:--yes\s+|-y\s+)?|pnpm\s+(?:exec|dlx)\s+|yarn\s+dlx\s+|bunx\s+|bundle\s+exec\s+|dotenv\s+(?:-\S+\s+)*--\s+)''', re.X)
26
+ _PY = r'(?:python(?:\d+(?:\.\d+)?)?|py)'
27
+ _PKG = r'(?:npm|pnpm|yarn|bun)'
28
+ # (kind, pattern), tried in this order on each part of a command
29
+ _PATTERNS = tuple((kind, re.compile(pattern)) for kind, pattern in (
30
+ ('test', _PY + r'\s+-m\s+(?:pytest|unittest|nose2?|tox|nox|green)\b'),
31
+ ('test', r'(?:pytest|py\.test|tox|nox|nose2?|ward)\b'),
32
+ ('test', _PY + r'\s+(?:-\S+\s+)*(?:\S*/)?(?:test_\S*|\S*_tests?|run_?tests|runtests|tests)\.py\b'),
33
+ ('test', _PKG + r'\s+(?:run(?:-script)?\s+)?(?:test|tests|t)(?:[:\-]\S*)?(?:\s|$)'),
34
+ ('test', r'node\s+(?:--\S+\s+)*--test\b'),
35
+ ('test', r'(?:jest|vitest|mocha|ava|tap|jasmine|karma|cypress\s+run|playwright\s+test|deno\s+test|bun\s+test)\b'),
36
+ ('test', r'go\s+test\b|cargo\s+(?:test|nextest)\b|(?:make|just|task)\s+(?:-\S+\s+)*(?:test|tests|check|test-\S+|check-\S+)\b'),
37
+ ('test', r'(?:\./)?(?:\S*/)?(?:test|tests|check|run-tests|run_tests)\.sh\b|(?:ba|z)?sh\s+(?:\S*/)?\S*(?:test|check)\S*\.sh\b'),
38
+ ('test', r'(?:rspec|rake\s+test|phpunit|vendor/bin/phpunit|dotnet\s+test|mvn\s+(?:-\S+\s+)*(?:test|verify)\b|'
39
+ r'(?:\./)?gradlew?\s+(?:-\S+\s+)*(?:test|check)\b|swift\s+test|ctest|mix\s+test|stack\s+test|cabal\s+test)'),
40
+ ('typecheck', r'(?:tsc|vue-tsc|mypy|dmypy|pyright|basedpyright|pyre|pytype|flow)\b|' + _PY + r'\s+-m\s+(?:mypy|pyright|py_compile|compileall)\b'),
41
+ ('typecheck', _PKG + r'\s+(?:run\s+)?(?:typecheck|type-check|types|tsc|check-types|check:types)\b'),
42
+ ('typecheck', r'cargo\s+check\b|go\s+vet\b|node\s+--check\b|(?:ba|z)?sh\s+-n\b'),
43
+ ('lint', r'(?:eslint|ruff|flake8|pylint|pycodestyle|pyflakes|golangci-lint|shellcheck|stylelint|biome|rubocop|hadolint|'
44
+ r'markdownlint|yamllint|actionlint|oxlint|swiftlint|ktlint|tflint|deno\s+lint|cargo\s+clippy)\b'),
45
+ ('lint', _PY + r'\s+-m\s+(?:ruff|flake8|pylint|pycodestyle)\b|' + _PKG + r'\s+(?:run\s+)?lint\S*'),
46
+ ('lint', r'(?:prettier|black|isort|gofmt|rustfmt|cargo\s+fmt|ruff\s+format)\b.*(?:--check|--diff|\s-l\b|\s-d\b)'),
47
+ ('build', _PKG + r'\s+(?:run\s+)?build\S*|(?:cargo|go|swift|dotnet|zig)\s+build\b|(?:\./)?gradlew?\s+(?:-\S+\s+)*build\b|'
48
+ r'mvn\s+(?:-\S+\s+)*(?:package|install|compile)\b|(?:vite|webpack|next|tsup|esbuild|rollup|parcel)\s+build\b|'
49
+ r'make(?:\s+-j\s*\d*)?(?:\s+(?:all|build))?$|docker\s+(?:compose\s+)?build\b'),
50
+ ))
51
+ # programs that only read: a failed one says nothing about the environment
52
+ _READERS = frozenset(('rg', 'grep', 'egrep', 'fgrep', 'cat', 'sed', 'awk', 'head', 'tail', 'less', 'more', 'ls', 'find', 'fd',
53
+ 'wc', 'nl', 'file', 'stat', 'tree', 'jq', 'diff', 'cmp', 'echo', 'printf', 'test', '[', 'which', 'type',
54
+ 'git', 'pwd', 'cd', 'true', 'false', 'basename', 'dirname', 'realpath', 'readlink', 'sort', 'uniq', 'cut'))
55
+
56
+
57
+ def parts(command):
58
+ """The commands a shell line runs, each without its env assignments and wrappers (`timeout 600`, `uv run`,
59
+ `npx`, …); `cd` steps are left out."""
60
+ out = []
61
+ for part in _SPLIT.split(command or ''):
62
+ part = part.strip().strip('()').strip()
63
+ inner = _WRAPPED.match(part)
64
+ if inner:
65
+ out.extend(parts(inner.group(2)))
66
+ continue
67
+ while True:
68
+ m = _PREFIX.match(part)
69
+ if not m or not m.group(0):
70
+ break
71
+ part = part[m.end():]
72
+ if part and not re.match(r'(?:cd|pushd|popd|export|set|source|\.)\b', part):
73
+ out.append(part)
74
+ return out
75
+
76
+
77
+ def classify(command):
78
+ """test, typecheck, lint or build when some part of the command is one (the first of those, in that order),
79
+ else None."""
80
+ found = set()
81
+ for part in parts(command):
82
+ for kind, pattern in _PATTERNS:
83
+ if pattern.match(part):
84
+ found.add(kind)
85
+ break
86
+ return next((kind for kind in KINDS if kind in found), None)
87
+
88
+
89
+ def _readonly(command):
90
+ programs = [part.split()[0].rsplit('/', 1)[-1] for part in parts(command) if part.split()]
91
+ return bool(programs) and all(program in _READERS for program in programs)
92
+
93
+
94
+ # ---------- what it printed ----------
95
+
96
+ _WORDS = {'passed': 'passed', 'passing': 'passed', 'pass': 'passed', 'xpassed': 'passed', 'ok': None,
97
+ 'failed': 'failed', 'failing': 'failed', 'fail': 'failed', 'error': 'failed', 'errors': 'failed',
98
+ 'skipped': 'skipped', 'pending': 'skipped', 'todo': 'skipped', 'xfailed': 'skipped', 'skip': 'skipped'}
99
+ _COUNTED = re.compile(r'(\d+)\s+(passed|failed|skipped|errors?|xfailed|xpassed|pending|todo)\b')
100
+ _SUMMARY = re.compile(r'^.*\b\d+\s+(?:passed|failed)\b.*$', re.M)
101
+
102
+
103
+ def _ints(**values):
104
+ return {key: int(value) for key, value in values.items() if value is not None}
105
+
106
+
107
+ def counts(output, kind=None):
108
+ """What a check's output says it found: {passed, failed, skipped} for tests, {errors, warnings} for type
109
+ checks and linters, or None. Read from the end of the output, where the summaries are."""
110
+ text = _ANSI.sub('', output or '')[-8000:]
111
+ if not text.strip():
112
+ return None
113
+ if kind in ('lint', 'typecheck'):
114
+ return _problems(text) or _tests(text)
115
+ return _tests(text) or _problems(text)
116
+
117
+
118
+ def _tests(text):
119
+ # cargo test: one line per test binary, summed
120
+ rows = re.findall(r'test result: \w+\. (\d+) passed; (\d+) failed; (\d+) ignored', text)
121
+ if rows:
122
+ return {key: sum(int(row[i]) for row in rows) for i, key in enumerate(('passed', 'failed', 'skipped'))}
123
+ # forge's tests/run_tests.py: "1639 tests in 312 classes: …; 75 skipped", then "OK" or "FAILED: 2 failures, 1 errors in …"
124
+ m = None
125
+ for m in re.finditer(r'^(\d+) tests in \d+ classes: .*; (\d+) skipped\s*\n(?:FAILED: (\d+) failures, (\d+) errors|OK)', text, re.M):
126
+ pass
127
+ if m:
128
+ total, skipped = int(m.group(1)), int(m.group(2))
129
+ failed = int(m.group(3) or 0) + int(m.group(4) or 0)
130
+ return {'passed': max(0, total - failed - skipped), 'failed': failed, 'skipped': skipped}
131
+ # unittest: "Ran 12 tests in 0.3s" then "OK (skipped=2)" or "FAILED (failures=1, errors=2)"
132
+ ran = list(re.finditer(r'^Ran (\d+) tests? in [\d.]+s\s*\n+\s*(OK|FAILED)\b(?: \(([^)]*)\))?', text, re.M))
133
+ if ran:
134
+ m = ran[-1]
135
+ detail = {key: int(value) for key, value in re.findall(r'(\w+)=(\d+)', m.group(3) or '')}
136
+ failed = detail.get('failures', 0) + detail.get('errors', 0) + detail.get('unexpected_successes', 0)
137
+ skipped = detail.get('skipped', 0) + detail.get('expected_failures', 0)
138
+ return {'passed': max(0, int(m.group(1)) - failed - skipped), 'failed': failed, 'skipped': skipped}
139
+ # node --test: "# pass 5", "# fail 1" (tap) or "ℹ pass 5" (spec)
140
+ node = dict(re.findall(r'^[#ℹ]\s+(pass|fail|skipped|todo|cancelled)\s+(\d+)\s*$', text, re.M))
141
+ if 'pass' in node:
142
+ n = lambda key: int(node.get(key, 0))
143
+ return {'passed': n('pass'), 'failed': n('fail') + n('cancelled'), 'skipped': n('skipped') + n('todo')}
144
+ # mocha: "5 passing (20ms)", "1 failing", "2 pending", each on its own line
145
+ mocha = dict((word, int(n)) for n, word in re.findall(r'^\s*(\d+) (passing|failing|pending)\b', text, re.M))
146
+ if 'passing' in mocha or 'failing' in mocha:
147
+ return {'passed': mocha.get('passing', 0), 'failed': mocha.get('failing', 0), 'skipped': mocha.get('pending', 0)}
148
+ # playwright: one line per outcome, the count first (" 1 failed", " 5 passed (10.2s)")
149
+ found = {}
150
+ for n, word in re.findall(r'^\s*(\d+) (passed|failed|flaky|skipped|did not run|interrupted)\b', '\n'.join(text.splitlines()[-40:]), re.M):
151
+ key = {'flaky': 'passed', 'did not run': 'skipped', 'interrupted': 'failed'}.get(word, word)
152
+ found[key] = found.get(key, 0) + int(n)
153
+ if found:
154
+ return {key: found.get(key, 0) for key in ('passed', 'failed', 'skipped')}
155
+ # pytest, jest ("Tests: 1 failed, 5 passed, 6 total"), vitest ("Tests 1 failed | 5 passed (6)"): the last line that
156
+ # counts passes or failures
157
+ lines = _SUMMARY.findall(text)
158
+ if lines:
159
+ found = {}
160
+ for n, word in _COUNTED.findall(lines[-1]):
161
+ key = _WORDS.get(word)
162
+ if key:
163
+ found[key] = found.get(key, 0) + int(n)
164
+ if found:
165
+ return {key: found.get(key, 0) for key in ('passed', 'failed', 'skipped')}
166
+ # go test: one line per test with -v, else one per package
167
+ go = re.findall(r'^\s*--- (PASS|FAIL|SKIP):', text, re.M)
168
+ if go:
169
+ return {'passed': go.count('PASS'), 'failed': go.count('FAIL'), 'skipped': go.count('SKIP')}
170
+ return None
171
+
172
+
173
+ def _problems(text):
174
+ m = None
175
+ for m in re.finditer(r'✖ (\d+) problems? \((\d+) errors?, (\d+) warnings?\)', text): # eslint
176
+ pass
177
+ if m:
178
+ return _ints(errors=m.group(2), warnings=m.group(3))
179
+ m = re.search(r'(\d+) errors?, (\d+) warnings?, \d+ (?:informations|notes)\s*$', text, re.M) # pyright
180
+ if m:
181
+ return _ints(errors=m.group(1), warnings=m.group(2))
182
+ found = re.findall(r'^Found (\d+) errors?\b', text, re.M) # tsc, mypy, ruff
183
+ if found:
184
+ return {'errors': int(found[-1])}
185
+ if re.search(r'^(?:Success: no issues found|All checks passed!|0 errors, 0 warnings)', text, re.M):
186
+ return {'errors': 0}
187
+ return None
188
+
189
+
190
+ def _tail(output):
191
+ lines = [line.rstrip() for line in _ANSI.sub('', output or '').splitlines() if line.strip()]
192
+ return '\n'.join(lines[-TAIL_LINES:]) or None
193
+
194
+
195
+ # ---------- environment problems ----------
196
+
197
+ # (id, label, pattern), in the order a banner lists them
198
+ ENVIRONMENT = tuple((key, label, re.compile(pattern, re.I | re.M)) for key, label, pattern in (
199
+ ('docker-daemon', 'Docker is not running', r'Cannot connect to the Docker daemon|Is the docker daemon running|'
200
+ r'docker daemon is not running|error during connect:.*docker'),
201
+ ('docker-pools', 'Docker ran out of network address pools', r'all predefined address pools have been fully subnetted|'
202
+ r'could not find an available, non-overlapping IPv4 address pool'),
203
+ ('container', 'A container is missing or its name is taken', r'No such container|container name "[^"]*" is already in use|'
204
+ r'Conflict\. The container name'),
205
+ ('port', 'A port is already in use', r'EADDRINUSE|address already in use|port is already allocated'),
206
+ ('sandbox', 'The sandbox refused an operation (EPERM)', r'\bEPERM\b|Operation not permitted|PermissionError: \[Errno 1\]'),
207
+ ('refused', 'A local service refused the connection', r'ECONNREFUSED|Connection refused|could not connect to server'),
208
+ ('network', 'No network or DNS', r'Could not resolve host|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)|Temporary failure in name '
209
+ r'resolution|Network is unreachable|ENETUNREACH|nodename nor servname provided'),
210
+ ('disk', 'The disk is full', r'ENOSPC|No space left on device'),
211
+ ('missing-tool', 'A command is not installed', r'command not found|^\S+: not found$|is not recognized as an internal or external command'),
212
+ ))
213
+ LABELS = {key: label for key, label, _ in ENVIRONMENT}
214
+
215
+
216
+ def environment(output):
217
+ """[(id, the first line that shows it)] for each environment problem in a failed command's output."""
218
+ text = _ANSI.sub('', output or '')
219
+ found = []
220
+ for key, _, pattern in ENVIRONMENT:
221
+ m = pattern.search(text)
222
+ if m:
223
+ start = text.rfind('\n', 0, m.start()) + 1
224
+ end = text.find('\n', m.end())
225
+ line = text[start:end if end >= 0 else len(text)].strip()
226
+ found.append((key, line[:LINE_CAP]))
227
+ return found
228
+
229
+
230
+ # ---------- one transcript ----------
231
+
232
+ def _failed(ev):
233
+ return bool(ev.get('error')) or ev.get('exit') not in (None, 0)
234
+
235
+
236
+ def _command(text):
237
+ text = text or ''
238
+ return text if len(text) <= COMMAND_CAP else text[:COMMAND_CAP] + '…'
239
+
240
+
241
+ def analyze(events):
242
+ """{checks, call, environment} of one transcript's events.
243
+
244
+ checks: [{index, command, kind, exit, failed, running, started, ended, duration_s, counts, tail}], in order; index
245
+ is the event's place in the transcript (the conversation view's `ev-<index>`).
246
+ call: the call not answered yet ({index, kind: command|tool, command, tool, check, started}), the newest when
247
+ several run at once, or None.
248
+ environment: [{index, command, problem, label, line}] for each problem a failed command met.
249
+ """
250
+ checks, problems, call = [], [], None
251
+ for index, ev in enumerate(events):
252
+ kind = ev.get('kind')
253
+ if kind not in ('command', 'tool', 'edit'):
254
+ continue
255
+ if ev.get('running'):
256
+ call = dict(index=index, kind=kind, command=_command(ev.get('command')) if kind == 'command' else None,
257
+ tool=ev.get('tool') or None, started=ev.get('t'),
258
+ check=classify(ev.get('command')) if kind == 'command' else None)
259
+ if kind != 'command':
260
+ continue
261
+ command, check = ev.get('command') or '', classify(ev.get('command'))
262
+ failed = not ev.get('running') and _failed(ev)
263
+ if check:
264
+ started, ended = ev.get('t'), ev.get('ended')
265
+ checks.append(dict(index=index, command=_command(command), kind=check, exit=ev.get('exit'), failed=failed,
266
+ running=bool(ev.get('running')), started=started, ended=ended,
267
+ duration_s=round(ended - started, 3) if started is not None and ended is not None else None,
268
+ counts=counts(ev.get('output'), check), tail=_tail(ev.get('output')) if failed else None))
269
+ if failed and not _readonly(command):
270
+ for key, line in environment(ev.get('output')):
271
+ problems.append(dict(index=index, command=_command(command), problem=key, label=LABELS[key], line=line))
272
+ return dict(checks=checks, call=call, environment=problems)
273
+
274
+
275
+ # ---------- the brief's acceptance criteria ----------
276
+
277
+ _HEADING = re.compile(r'^(#{1,6})\s+acceptance criteria\s*:?\s*$', re.I)
278
+ _ANY_HEADING = re.compile(r'^(#{1,6})\s')
279
+ _FENCE = re.compile(r'^\s*(```|~~~)')
280
+ _CODE = re.compile(r'(`+)(.+?)\1')
281
+
282
+
283
+ def criteria(brief):
284
+ """The check commands an `## Acceptance criteria` section of a brief names: in `code` spans or in its fenced
285
+ blocks, each once, in order: [{command, kind}]."""
286
+ found, seen, level, fenced = [], set(), None, False
287
+ for line in (brief or '').splitlines():
288
+ if _FENCE.match(line):
289
+ fenced = not fenced
290
+ continue
291
+ heading = None if fenced else _ANY_HEADING.match(line)
292
+ if heading and level is not None and len(heading.group(1)) <= level:
293
+ level = None
294
+ if not fenced and _HEADING.match(line):
295
+ level = len(_HEADING.match(line).group(1))
296
+ continue
297
+ if level is None:
298
+ continue
299
+ candidates = [line.strip().lstrip('$ ').strip()] if fenced else [m.group(2).strip() for m in _CODE.finditer(line)]
300
+ for text in candidates:
301
+ kind = classify(text)
302
+ if kind and text not in seen:
303
+ seen.add(text)
304
+ found.append(dict(command=text, kind=kind))
305
+ return found
306
+
307
+
308
+ def _tokens(command):
309
+ out = []
310
+ for part in parts(command):
311
+ out.extend(re.sub(r'^python(?:\d+(?:\.\d+)?)?$', 'python', word.strip('\'"')) for word in part.split())
312
+ return out
313
+
314
+
315
+ def coverage(wanted, ran):
316
+ """Each wanted check against the commands that ran: `ran` when one has every word of it, `similar` when one is
317
+ the same kind of check by the same program (the whole suite where one module was asked, say), else `missing`.
318
+ ran = [(command, info)]; the matching run's info rides along as `by`."""
319
+ out = []
320
+ runs = [(set(_tokens(command)), (_tokens(command) or [None])[0], classify(command), info) for command, info in ran]
321
+ for item in wanted:
322
+ words = _tokens(item['command'])
323
+ status, by = 'missing', None
324
+ for tokens, program, kind, info in runs:
325
+ if words and set(words) <= tokens:
326
+ status, by = 'ran', info
327
+ break
328
+ if status == 'missing' and words and program == words[0] and kind == item['kind']:
329
+ status, by = 'similar', info
330
+ out.append(dict(item, status=status, by=by))
331
+ return out
@@ -199,9 +199,13 @@ def validate_body(body):
199
199
  action = body.get('action')
200
200
  shapes = {'set': ({'action', 'key', 'value', 'task'}, ('key', 'value')),
201
201
  'pin': ({'action', 'task', 'spec'}, ('task', 'spec')),
202
- 'unpin': ({'action', 'task'}, ('task',))}
202
+ 'unpin': ({'action', 'task'}, ('task',)),
203
+ 'retry': ({'action', 'task', 'dwarf'}, ('task',)),
204
+ 'drain': ({'action'}, ()),
205
+ 'resume': ({'action'}, ()),
206
+ 'stop': ({'action', 'now'}, ())}
203
207
  if not isinstance(action, str) or action not in shapes:
204
- raise BadBody('action must be one of set, pin, unpin')
208
+ raise BadBody('action must be one of ' + ', '.join(shapes))
205
209
  allowed, required = shapes[action]
206
210
  extra = sorted(set(body) - allowed)
207
211
  if extra:
@@ -209,6 +213,12 @@ def validate_body(body):
209
213
  tail = [_text(body, name) for name in required]
210
214
  if action == 'set' and 'task' in body:
211
215
  tail += ['--task', _text(body, 'task')]
216
+ if action == 'retry' and 'dwarf' in body:
217
+ tail += ['--dwarf', _text(body, 'dwarf')]
218
+ if action == 'stop' and 'now' in body:
219
+ if not isinstance(body['now'], bool):
220
+ raise BadBody('now must be true or false')
221
+ tail += ['--now'] if body['now'] else []
212
222
  return action, tail
213
223
 
214
224
 
@@ -22,11 +22,11 @@ import re
22
22
  import time
23
23
  import urllib.parse
24
24
 
25
- from forge_ui import __version__, server
25
+ from forge_ui import __version__, reader, server
26
26
 
27
27
  STATIC = server.STATIC_DIR
28
28
  # what the exported page runs, in index.html's order; the cloud, the leaderboard and notifications need a server
29
- SCRIPTS = ('theme.js', 'icons.js', 'datatable.js', 'shell.js', 'runmodel.js', 'cloudmodel.js', 'graph.js', 'gantt.js', 'panel.js', 'diffview.js', 'convo.js', 'files.js', 'map3d.js',
29
+ SCRIPTS = ('theme.js', 'icons.js', 'datatable.js', 'shell.js', 'runmodel.js', 'cloudmodel.js', 'graph.js', 'gantt.js', 'verifyview.js', 'checksview.js', 'panel.js', 'diffview.js', 'convo.js', 'files.js', 'map3d.js',
30
30
  'search.js', 'app.js')
31
31
  MODULES = ('iso.js', 'cloud3d.js', 'findings3d.js', 'stagectl.js', 'scene3d.js') # bundled in dependency order
32
32
  DIFF_CAP = 1 << 20 # one diff's JSON
@@ -37,7 +37,7 @@ _EXEC = re.compile(r'(?:task|dwarf|qa|solo|verification|parallel)-[0-9a-f]{32}')
37
37
  # texts that can hold code, prompts or private notes: nulled unless texts=True
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
- 'dwarf_input', 'error'))
40
+ 'dwarf_input', 'error', 'last_line', 'message', 'excerpt', 'tail', 'lines', 'call', 'split'))
41
41
 
42
42
 
43
43
  def _enc(value):
@@ -113,12 +113,13 @@ class _Snapshot:
113
113
  if isinstance(value, list):
114
114
  return [self.clean(v, key) for v in value]
115
115
  if isinstance(value, str) and not self.paths and key != 'url':
116
- return self.hide(value)
116
+ return self.hide(value, key)
117
117
  return value
118
118
 
119
- def hide(self, text):
120
- # a whole absolute path becomes its last component; known roots inside longer texts are replaced too
121
- if re.fullmatch(r'(/|[A-Za-z]:[\\/])[^\n]*', text) and not text.startswith('/api/'):
119
+ def hide(self, text, key=None):
120
+ # a whole absolute path becomes its last component; known roots inside longer texts are replaced too.
121
+ # A command that starts with a path is not one path: only its known roots go.
122
+ if key != 'command' and re.fullmatch(r'(/|[A-Za-z]:[\\/])[^\n]*', text) and not text.startswith('/api/'):
122
123
  return os.path.basename(text.rstrip('/\\')) or text
123
124
  for root, name in self.roots:
124
125
  if root in text:
@@ -187,10 +188,26 @@ def build(catalog, key, texts=False, paths=False, now=None):
187
188
  snap.add(url, cap=DIFF_CAP)
188
189
  for name in reviews:
189
190
  snap.add(f'{base}/final-reviews/{_enc(name)}/diff', cap=DIFF_CAP)
190
- # what each dwarf and reviewer said and ran: its conversation is all text
191
+ # what each dwarf and reviewer said and ran: its conversation is all text, and so are the commands it ran
191
192
  for name in names:
192
193
  if name.startswith(('dwarf-', 'qa-')):
193
194
  snap.add(f'{base}/executions/{name}/transcript', cap=TRANSCRIPT_CAP)
195
+ snap.add(f'{base}/executions/{name}/checks')
196
+ for task in tasks:
197
+ snap.add(f"{base}/tasks/{_enc(task['id'])}/checks")
198
+ snap.add(f'{base}/environment')
199
+ # the verification's log tails: its own, each lane's and each lane run's (line ranges stay out)
200
+ verification = run.get('verification') or {}
201
+ if verification:
202
+ snap.add(f'{base}/verification/log')
203
+ for lane in verification.get('lanes') or []:
204
+ name = lane.get('name') if isinstance(lane, dict) else None
205
+ if isinstance(name, str) and reader.LANE_NAME.fullmatch(name):
206
+ snap.add(f'{base}/verification/lanes/{name}/log')
207
+ for item in lane.get('runs') or []:
208
+ k = item.get('k') if isinstance(item, dict) else None
209
+ if isinstance(k, int) and not isinstance(k, bool) and k > 0:
210
+ snap.add(f'{base}/verification/lanes/{name}/runs/{k}/log')
194
211
  meta = {'format': 'forge-ui-export', 'version': 1, 'app': __version__, 'key': key,
195
212
  'generated': now if now is not None else time.time(), 'texts': bool(texts), 'paths': bool(paths),
196
213
  'omitted': snap.omitted}