@giamme/forge 0.12.0 → 0.13.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 +77 -0
- package/README.md +1 -1
- package/SKILL.md +31 -12
- package/VERSION +1 -1
- package/docs/add-ons.md +11 -6
- package/docs/artifacts.md +18 -6
- package/docs/commands.md +189 -17
- package/docs/decomposed-runs.md +13 -5
- package/docs/forge-ui.md +34 -4
- package/docs/memory.md +2 -1
- package/docs/models.md +4 -2
- package/docs/reviews.md +81 -19
- package/docs/troubleshooting.md +3 -1
- package/forge +17 -1
- package/package.json +1 -1
- package/references/dataset.md +40 -14
- package/references/decision-models.md +759 -0
- package/references/decompose.md +197 -28
- package/references/harnesses.md +10 -3
- package/references/planning.md +8 -0
- package/references/solo.md +13 -3
- package/references/ui.md +11 -0
- package/scripts/forge-artifact.sh +30 -4
- package/scripts/forge-config.py +238 -29
- package/scripts/forge-contract.py +127 -58
- package/scripts/forge-control.py +40 -9
- package/scripts/forge-decide.py +6 -0
- package/scripts/forge-dispatch.sh +47 -15
- package/scripts/forge-fail-first.py +2 -2
- package/scripts/forge-gate-addressed.sh +40 -0
- package/scripts/forge-gate-message.sh +64 -0
- package/scripts/forge-issues.py +368 -36
- package/scripts/forge-jev-options.sh +269 -42
- package/scripts/forge-lib-attribute.sh +447 -0
- package/scripts/forge-lib-gates.sh +32 -0
- package/scripts/forge-lib-plans.sh +17 -6
- package/scripts/forge-lib-review.sh +24 -19
- package/scripts/forge-lib-task.sh +219 -39
- package/scripts/forge-lib-verify.sh +45 -8
- package/scripts/forge-memory.sh +3 -3
- package/scripts/forge-parallel-options.sh +44 -5
- package/scripts/forge-parallel.sh +503 -304
- package/scripts/forge-plan-check.py +35 -1
- package/scripts/forge-pre-review.py +437 -0
- package/scripts/forge-prompt.py +25 -5
- package/scripts/forge-route.py +2 -2
- package/scripts/forge-runtime.py +55 -1
- package/scripts/forge-schedule.py +70 -9
- package/scripts/forge-shadow.py +2 -2
- package/scripts/forge-solo.sh +41 -10
- package/scripts/forge-submodules.py +389 -0
- package/scripts/forge-sweep.py +542 -0
- package/scripts/forge_dataset/cli.py +12 -6
- package/scripts/forge_dataset/export.py +55 -45
- package/scripts/forge_dataset/forecast.py +4 -1
- package/scripts/forge_dataset/harvest.py +33 -5
- package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
- package/scripts/forge_decide/__init__.py +141 -0
- package/scripts/forge_decide/budget.py +149 -0
- package/scripts/forge_decide/cache.py +66 -0
- package/scripts/forge_decide/cli.py +953 -0
- package/scripts/forge_decide/doctor.py +221 -0
- package/scripts/forge_decide/label_addressed.py +75 -0
- package/scripts/forge_decide/label_attribution.py +62 -0
- package/scripts/forge_decide/label_coverage.py +81 -0
- package/scripts/forge_decide/label_message.py +38 -0
- package/scripts/forge_decide/label_prompt.py +139 -0
- package/scripts/forge_decide/labels.py +328 -0
- package/scripts/forge_decide/metrics.py +125 -0
- package/scripts/forge_decide/migrate.py +226 -0
- package/scripts/forge_decide/providers.py +292 -0
- package/scripts/forge_decide/replay.py +350 -0
- package/scripts/forge_decide/report.py +382 -0
- package/scripts/forge_decide/resolve.py +397 -0
- package/scripts/forge_decide/sites.py +377 -0
- package/scripts/forge_jev/__init__.py +202 -104
- package/scripts/forge_jev/addressed.py +171 -0
- package/scripts/forge_jev/attribution.py +198 -0
- package/scripts/forge_jev/cli.py +460 -382
- package/scripts/forge_jev/client.py +155 -77
- package/scripts/forge_jev/coupling.py +19 -87
- package/scripts/forge_jev/coverage.py +303 -0
- package/scripts/forge_jev/findings.py +219 -0
- package/scripts/forge_jev/gates.py +225 -27
- package/scripts/forge_jev/memory.py +65 -4
- package/scripts/forge_jev/message.py +134 -0
- package/scripts/forge_jev/plan_gates.py +294 -0
- package/scripts/forge_jev/questions.py +173 -313
- package/scripts/forge_jev/verify.py +130 -104
- package/ui/README.md +41 -10
- package/ui/docs/api.md +212 -44
- package/ui/forge_ui/checks.py +331 -0
- package/ui/forge_ui/control.py +60 -11
- package/ui/forge_ui/export.py +8 -3
- package/ui/forge_ui/models.py +1 -0
- package/ui/forge_ui/reader.py +436 -26
- package/ui/forge_ui/server.py +13 -0
- package/ui/forge_ui/static/app.js +15 -8
- package/ui/forge_ui/static/checksview.js +449 -0
- package/ui/forge_ui/static/controls.js +20 -13
- package/ui/forge_ui/static/convo.js +11 -2
- package/ui/forge_ui/static/findingsview.js +6 -4
- package/ui/forge_ui/static/index.html +1 -0
- package/ui/forge_ui/static/panel.js +105 -17
- package/ui/forge_ui/static/runmodel.js +40 -2
- package/ui/forge_ui/static/scene3d.js +2 -15
- package/ui/forge_ui/static/settings.js +336 -41
- package/ui/forge_ui/static/style.css +72 -7
- package/ui/forge_ui/transcripts.py +225 -54
- package/references/jev.md +0 -865
- package/scripts/forge_jev/backtest.py +0 -322
- package/scripts/forge_jev/corpus.py +0 -156
- package/scripts/forge_jev/features.py +0 -24
- package/scripts/forge_jev/predict.py +0 -204
- package/scripts/forge_jev/review.py +0 -73
- package/scripts/forge_jev/routing.py +0 -271
- package/scripts/forge_jev/subset.py +0 -123
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
"""Verify-command discovery
|
|
1
|
+
"""Verify-command discovery: select, never generate."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
import re
|
|
7
|
+
import subprocess
|
|
7
8
|
|
|
8
9
|
from . import enabled, load_config, threshold
|
|
9
10
|
from .client import ask, choice, noul, probabilities, score
|
|
10
|
-
from .questions import
|
|
11
|
+
from .questions import runs_tests, verify_runtime, verify_selection
|
|
11
12
|
|
|
12
13
|
CANDIDATE_CAP = 25 # keeps one discover() request small; deterministic order means the
|
|
13
14
|
# cap always drops the same (least-likely) tail, never a random one.
|
|
14
|
-
LOG_TAIL_CHARS = 4000 # the failure signature (assertion, traceback) is at the end of a
|
|
15
|
-
# log; the setup/build noise at the start is not needed to triage it.
|
|
16
15
|
|
|
17
16
|
_PKG_SCRIPT_RE = re.compile(r'^(test|check|ci|verify)(?:[:\-]|$)', re.I)
|
|
18
17
|
_MAKE_TARGETS = ('test', 'tests', 'check', 'verify', 'ci')
|
|
@@ -22,25 +21,80 @@ _WORKFLOW_TEST_HINT_RE = re.compile(
|
|
|
22
21
|
r'\b(pytest|npm (?:test|run\s+test\S*)|yarn (?:test|run\s+test\S*)|go test|cargo test|'
|
|
23
22
|
r'make test|tox\b|jest|vitest|mvn test|gradle test|rspec|phpunit|ctest|go\s+vet\s+&&\s+go\s+test)\b',
|
|
24
23
|
re.I)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
# A remembered command is read off a rendered fact two ways (#42). A code span is the command as
|
|
25
|
+
# its author wrote it, so its content is taken whole, quotes and option values included. Prose is
|
|
26
|
+
# scanned for a runner and the arguments after it, and an argument is a flag, a path or a quoted
|
|
27
|
+
# string: a plain word ends the command, so "cargo test --workspace runs all tests" names
|
|
28
|
+
# `cargo test --workspace`. A bare flag followed by a plain word may take that word as its value
|
|
29
|
+
# ("--features integration"), and half an option is a command cargo rejects, so the command ends
|
|
30
|
+
# before such a flag unless the word is plain prose ("runs", "also"). A number after a flag is
|
|
31
|
+
# always its value ("--jobs 2"), so it stays with the flag. The rendered source tag
|
|
32
|
+
# ("[tests/]") matches none of these forms.
|
|
33
|
+
_CODE_SPAN_RE = re.compile(r'`([^`\n]+)`')
|
|
34
|
+
_PROSE_WORD = r'[A-Za-z][\w-]*(?![\w/-]|\.\w)'
|
|
35
|
+
_PROSE_STOP = (r'(?:runs?|running|also|and|or|then|which|that|for|to|in|on|with|before|after|if|'
|
|
36
|
+
r'when|but|is|are|will|should|must|can|takes?|checks?|covers?|lints?|builds?|'
|
|
37
|
+
r'executes?|needs?|requires?)(?![\w/-]|\.\w)')
|
|
38
|
+
_PROSE_FLAG = (r'-{1,2}[^\s`\'"\[\]=]+(?![^\s`\'"\[\]=])(?:=[^\s`\'"\[\]]*|\s+\d[\w.]*(?![\w/-])|'
|
|
39
|
+
r'(?!\s+(?!' + _PROSE_STOP + r')' + _PROSE_WORD + r'))')
|
|
40
|
+
_PROSE_ARG = r'''(?:''' + _PROSE_FLAG + r'''|[\w.-]*/[\w./-]*|"[^"\n]*"|'[^'\n]*')'''
|
|
41
|
+
# A runner is a whole word: "pytest.ini" and "tests/pytest/" are files, not the pytest command.
|
|
42
|
+
_HEAD_START = r'(?<![\w./-])'
|
|
43
|
+
_HEAD_END = r'(?![\w/-]|\.\w)'
|
|
44
|
+
_MEMORY_HEADS = (
|
|
45
|
+
r'pytest',
|
|
46
|
+
r'make\s+\w[\w-]*',
|
|
47
|
+
r'npm run\s+[\w:_-]+',
|
|
48
|
+
r'npm test',
|
|
49
|
+
r'yarn(?:\s+run)?\s+[\w:_-]+',
|
|
50
|
+
r'go test',
|
|
51
|
+
r'cargo test',
|
|
52
|
+
r'tox',
|
|
53
|
+
r'nox',
|
|
54
|
+
r'bash\s+[\w./-]+\.sh',
|
|
55
|
+
r'python3?\s+[\w./-]+\.py',
|
|
56
|
+
)
|
|
57
|
+
_MEMORY_HEAD_RES = tuple(re.compile(_HEAD_START + head + _HEAD_END) for head in _MEMORY_HEADS)
|
|
58
|
+
_MEMORY_PROSE_RES = tuple(re.compile(_HEAD_START + head + _HEAD_END + r'(?:\s+' + _PROSE_ARG + r')*')
|
|
59
|
+
for head in _MEMORY_HEADS)
|
|
60
|
+
# Punctuation that ends the sentence a command sits in: "pytest -q." names `pytest -q`, but
|
|
61
|
+
# "go test ./..." keeps its dots.
|
|
62
|
+
_SENTENCE_END_RE = re.compile(r'(?:[,;:!?)]|(?<=[^.])\.)+$')
|
|
63
|
+
|
|
64
|
+
# Extension -> language, for languages_present (#42). Anything else is not code here.
|
|
65
|
+
_LANGUAGE_BY_EXTENSION = {
|
|
66
|
+
'py': 'python', 'rs': 'rust', 'go': 'go', 'rb': 'ruby', 'swift': 'swift',
|
|
67
|
+
'js': 'javascript', 'jsx': 'javascript', 'ts': 'javascript', 'tsx': 'javascript',
|
|
68
|
+
'mjs': 'javascript', 'cjs': 'javascript',
|
|
69
|
+
'java': 'jvm', 'kt': 'jvm',
|
|
70
|
+
'c': 'c', 'cc': 'c', 'cpp': 'c', 'h': 'c', 'hpp': 'c',
|
|
71
|
+
}
|
|
72
|
+
# A language is present when it has this many code files and this share of them.
|
|
73
|
+
LANGUAGE_MIN_FILES = 5
|
|
74
|
+
LANGUAGE_MIN_SHARE = 0.10
|
|
75
|
+
# Words that name the language a command runs the tests of (#42). Whole words only.
|
|
76
|
+
_COVERAGE_RES = (
|
|
77
|
+
(re.compile(r'\bcargo\b', re.I), 'rust'),
|
|
78
|
+
(re.compile(r'\b(?:pytest|python3?|tox|nox)\b', re.I), 'python'),
|
|
79
|
+
(re.compile(r'\b(?:npm|pnpm|yarn|npx|node|jest|vitest)\b', re.I), 'javascript'),
|
|
80
|
+
(re.compile(r'\bgo[ \t]+(?:test|vet)\b', re.I), 'go'),
|
|
81
|
+
(re.compile(r'\b(?:bundle|rake|rspec)\b', re.I), 'ruby'),
|
|
82
|
+
(re.compile(r'\b(?:gradle|mvn)\b', re.I), 'jvm'),
|
|
83
|
+
(re.compile(r'\bswift\b', re.I), 'swift'),
|
|
84
|
+
(re.compile(r'\b(?:ctest|cmake)\b', re.I), 'c'),
|
|
35
85
|
)
|
|
36
86
|
|
|
37
87
|
|
|
38
|
-
def _add(found: list[dict], seen: set[str], command: str, source: str, evidence: str
|
|
88
|
+
def _add(found: list[dict], seen: set[str], command: str, source: str, evidence: str,
|
|
89
|
+
excerpt: str = '') -> None:
|
|
39
90
|
command = command.strip()
|
|
40
91
|
if not command or command in seen or len(found) >= CANDIDATE_CAP:
|
|
41
92
|
return
|
|
42
93
|
seen.add(command)
|
|
43
|
-
|
|
94
|
+
entry = dict(command=command, source=source, evidence=evidence)
|
|
95
|
+
if excerpt:
|
|
96
|
+
entry['excerpt'] = excerpt
|
|
97
|
+
found.append(entry)
|
|
44
98
|
|
|
45
99
|
|
|
46
100
|
def _forge_verify(repo: Path, found, seen) -> None:
|
|
@@ -173,24 +227,33 @@ def _workflows(repo: Path, found, seen) -> None:
|
|
|
173
227
|
_add(found, seen, command, 'workflow', str(path))
|
|
174
228
|
|
|
175
229
|
|
|
230
|
+
def _remembered_commands(fact: str) -> list[str]:
|
|
231
|
+
"""The runner invocations one memory fact names (#42): code spans first, then the prose."""
|
|
232
|
+
commands = []
|
|
233
|
+
for span in _CODE_SPAN_RE.findall(fact):
|
|
234
|
+
if any(pattern.search(span) for pattern in _MEMORY_HEAD_RES):
|
|
235
|
+
commands.append(span.strip())
|
|
236
|
+
# The prose with each span blanked out, so a span's text is not read a second time.
|
|
237
|
+
prose = _CODE_SPAN_RE.sub(lambda match: ' ' * len(match.group(0)), fact)
|
|
238
|
+
for pattern in _MEMORY_PROSE_RES:
|
|
239
|
+
for match in pattern.finditer(prose):
|
|
240
|
+
commands.append(_SENTENCE_END_RE.sub('', match.group(0)))
|
|
241
|
+
return commands
|
|
242
|
+
|
|
243
|
+
|
|
176
244
|
def _memory_verify(repo: Path, found, seen) -> None:
|
|
177
245
|
path = repo / '.forge' / 'memory.md'
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
for line in path.read_text(errors='replace').splitlines():
|
|
181
|
-
if 'verify |' not in line:
|
|
182
|
-
continue
|
|
183
|
-
text = line.split('verify |', 1)[1]
|
|
184
|
-
# A memory entry is prose ("pytest -q runs the suite; make test also lints and
|
|
246
|
+
for fact in _memory_facts(repo, 'verify'):
|
|
247
|
+
# A memory fact is prose ("pytest -q runs the suite; make test also lints and
|
|
185
248
|
# is 4x slower"), not a bare command -- pull out anything that looks like a
|
|
186
249
|
# known runner invocation rather than treating the whole sentence as a command.
|
|
187
|
-
for
|
|
188
|
-
|
|
189
|
-
_add(found, seen, match.group(0), 'memory:verify', str(path))
|
|
250
|
+
for command in _remembered_commands(fact):
|
|
251
|
+
_add(found, seen, command, 'memory', str(path), excerpt=fact)
|
|
190
252
|
|
|
191
253
|
|
|
192
254
|
def candidates(repo) -> list[dict]:
|
|
193
|
-
"""Real, existing verify commands. Each: {'command': str, 'source': str, 'evidence': str}
|
|
255
|
+
"""Real, existing verify commands. Each: {'command': str, 'source': str, 'evidence': str},
|
|
256
|
+
and 'excerpt' for a memory candidate (the memory fact that named it).
|
|
194
257
|
|
|
195
258
|
Deterministic order, deduplicated, capped at CANDIDATE_CAP. Never executes anything --
|
|
196
259
|
this only enumerates what plausibly exists so Jev can select among real options.
|
|
@@ -214,13 +277,11 @@ def _repo_files(repo: Path, limit: int = 200) -> list[str]:
|
|
|
214
277
|
return entries[:limit]
|
|
215
278
|
|
|
216
279
|
|
|
217
|
-
# The headings forge-memory.sh:93 renders.
|
|
280
|
+
# The headings forge-memory.sh:93 renders. The reader below looked for the LEDGER row
|
|
218
281
|
# format instead -- `verify |` and `trap |` -- which is what ledger.tsv holds, not what
|
|
219
282
|
# `rebuild` writes into memory.md. No line in a rendered memory.md has ever contained
|
|
220
|
-
# either, so
|
|
221
|
-
#
|
|
222
|
-
# known_traps never corroborated anything -- which made the flake re-run unreachable,
|
|
223
|
-
# since its third condition is a trap sharing a distinctive token with the failure.
|
|
283
|
+
# either, so the list was empty for every repo, always, while jev.md documented it as
|
|
284
|
+
# working. Verification discovery never saw a recorded verify command.
|
|
224
285
|
_MEMORY_SECTIONS = {'verify': '## Verify', 'trap': '## Known traps',
|
|
225
286
|
'finding': '## Recurring QA findings'}
|
|
226
287
|
|
|
@@ -256,19 +317,6 @@ def _memory_verify_lines(repo: Path) -> list[str]:
|
|
|
256
317
|
return _memory_facts(repo, 'verify')
|
|
257
318
|
|
|
258
319
|
|
|
259
|
-
def known_traps(repo) -> list[str]:
|
|
260
|
-
"""Recorded 'trap' facts from .forge/memory.md (flaky tests, generated files, sharp
|
|
261
|
-
edges), for the CLI to hand to triage() -- see references/memory.md."""
|
|
262
|
-
path = Path(repo) / '.forge' / 'memory.md'
|
|
263
|
-
if not path.is_file():
|
|
264
|
-
return []
|
|
265
|
-
try:
|
|
266
|
-
lines = path.read_text(errors='replace').splitlines()
|
|
267
|
-
except OSError:
|
|
268
|
-
return []
|
|
269
|
-
return _memory_facts(path.parent.parent, 'trap')
|
|
270
|
-
|
|
271
|
-
|
|
272
320
|
# Enough of an evidence file to tell a test command from a build one, and no more: the
|
|
273
321
|
# request already carries one Choice and two Nouls per candidate.
|
|
274
322
|
EVIDENCE_CHARS = 400
|
|
@@ -283,6 +331,10 @@ def _evidence_excerpt(candidate: dict) -> str:
|
|
|
283
331
|
`make test` at 0.58 while leaving 0.40 on `none`, for a Choice confidence of 0.37
|
|
284
332
|
against a 0.70 gate -- so it declined, and a verifiable repo reported UNVERIFIED.
|
|
285
333
|
"""
|
|
334
|
+
# A memory candidate's evidence is memory.md, whose head describes every fact, not
|
|
335
|
+
# just the one that named the command. The fact itself is what it runs.
|
|
336
|
+
if candidate.get('excerpt'):
|
|
337
|
+
return candidate['excerpt'][:EVIDENCE_CHARS]
|
|
286
338
|
path = candidate.get('evidence') or ''
|
|
287
339
|
try:
|
|
288
340
|
text = Path(path).read_text(errors='replace')
|
|
@@ -308,11 +360,37 @@ def _evidence_excerpt(candidate: dict) -> str:
|
|
|
308
360
|
return text[:EVIDENCE_CHARS]
|
|
309
361
|
|
|
310
362
|
|
|
363
|
+
def languages_present(repo) -> list[str]:
|
|
364
|
+
"""The languages a repo has, from its tracked files (#42), sorted. A language counts at
|
|
365
|
+
LANGUAGE_MIN_FILES files and LANGUAGE_MIN_SHARE of the code files. Empty when the repo
|
|
366
|
+
is not a git repository."""
|
|
367
|
+
try:
|
|
368
|
+
listed = subprocess.run(['git', '-C', str(repo), 'ls-files', '-z'],
|
|
369
|
+
capture_output=True, check=True).stdout
|
|
370
|
+
except (OSError, subprocess.CalledProcessError):
|
|
371
|
+
return []
|
|
372
|
+
counts: dict[str, int] = {}
|
|
373
|
+
for name in listed.decode(errors='replace').split('\0'):
|
|
374
|
+
language = _LANGUAGE_BY_EXTENSION.get(Path(name).suffix[1:].lower())
|
|
375
|
+
if language:
|
|
376
|
+
counts[language] = counts.get(language, 0) + 1
|
|
377
|
+
total = sum(counts.values())
|
|
378
|
+
return sorted(language for language, n in counts.items()
|
|
379
|
+
if n >= LANGUAGE_MIN_FILES and n / total >= LANGUAGE_MIN_SHARE)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def languages_covered(command, evidence) -> list[str]:
|
|
383
|
+
"""The languages whose tests a command runs, judged from the command and the excerpt of
|
|
384
|
+
what it runs (#42), sorted. Empty when nothing is recognised."""
|
|
385
|
+
text = f'{command}\n{evidence}'
|
|
386
|
+
return sorted({language for pattern, language in _COVERAGE_RES if pattern.search(text)})
|
|
387
|
+
|
|
388
|
+
|
|
311
389
|
def discover(repo, *, config=None, run_dir=None) -> dict | None:
|
|
312
390
|
"""Ask Jev which candidate actually verifies this repo. None when Jev is
|
|
313
391
|
unavailable, no candidates exist, or it picks `none`.
|
|
314
392
|
-> {'command', 'confidence', 'verifiable', 'runs_tests', 'runtime_level', 'source',
|
|
315
|
-
'evidence'}
|
|
393
|
+
'evidence', 'coverage': {'present', 'covered'}}
|
|
316
394
|
"""
|
|
317
395
|
config = config or load_config()
|
|
318
396
|
if not enabled('tests', config=config):
|
|
@@ -359,7 +437,7 @@ def discover(repo, *, config=None, run_dir=None) -> dict | None:
|
|
|
359
437
|
# correct commands leaves it high; genuine doubt piles onto `none` and drops it.
|
|
360
438
|
# Ties are then broken by the winner, which is what Choice is for.
|
|
361
439
|
distribution = probabilities(result, 'choice')
|
|
362
|
-
act_at = threshold('tests_act', config=config)
|
|
440
|
+
act_at = threshold('tests_act', config=config, site='jev-verify-discover')
|
|
363
441
|
if distribution:
|
|
364
442
|
if (1.0 - distribution.get('none', 0.0)) < act_at:
|
|
365
443
|
return None
|
|
@@ -390,64 +468,12 @@ def discover(repo, *, config=None, run_dir=None) -> dict | None:
|
|
|
390
468
|
# `verifiable` is the quantity the gate actually used; `confidence` is kept beside it
|
|
391
469
|
# because they answer different questions and a future re-measurement needs both.
|
|
392
470
|
verifiable = (1.0 - distribution.get('none', 0.0)) if distribution else None
|
|
471
|
+
# Coverage (#42) only informs the announcement: the pick stands, and the command's own
|
|
472
|
+
# run still decides verification. `described` already holds the pick's excerpt.
|
|
473
|
+
coverage = dict(present=languages_present(repo_path),
|
|
474
|
+
covered=languages_covered(picked, described[idx]['runs']))
|
|
393
475
|
return dict(command=picked, confidence=confidence, verifiable=verifiable,
|
|
394
476
|
runs_tests=runs_probability,
|
|
395
477
|
runtime_level=runtime_level, source=picked_candidate['source'],
|
|
396
|
-
evidence=picked_candidate['evidence'])
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
# A token is distinctive enough to corroborate only if it looks like an identifier or a
|
|
400
|
-
# path -- `test_timeout`, `tests/test_api.py`, `CamelCase` -- rather than an English word
|
|
401
|
-
# that any failure log would contain.
|
|
402
|
-
_TOKEN_RE = re.compile(r'[A-Za-z_][A-Za-z0-9_./:-]{3,}')
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
def _distinctive(text: str) -> set[str]:
|
|
406
|
-
tokens = set()
|
|
407
|
-
for match in _TOKEN_RE.findall(text or ''):
|
|
408
|
-
# Split on path and node-id separators: a trap says `test_api.py::test_timeout`
|
|
409
|
-
# while the log says `tests/test_api.py::test_timeout`, which never compare equal
|
|
410
|
-
# as whole tokens. Atoms do.
|
|
411
|
-
for token in re.split(r'[/:]+', match):
|
|
412
|
-
token = token.strip('.-_')
|
|
413
|
-
if len(token) < 4:
|
|
414
|
-
continue
|
|
415
|
-
# A bare short word like `tests` matches every repo; require either an
|
|
416
|
-
# identifier/path shape or enough length to be specific.
|
|
417
|
-
if '_' in token or '.' in token or len(token) >= 8:
|
|
418
|
-
tokens.add(token)
|
|
419
|
-
return tokens
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
def corroborating_traps(log_tail: str, traps) -> list[str]:
|
|
423
|
-
"""Traps that share a distinctive token with the failure output.
|
|
478
|
+
evidence=picked_candidate['evidence'], coverage=coverage)
|
|
424
479
|
|
|
425
|
-
The re-run gate needs evidence that THIS failure matches a recorded trap, not merely
|
|
426
|
-
that the repo has recorded some trap at some point. Without that, one flaky test
|
|
427
|
-
noted months ago would excuse every future failure in the repo -- which is precisely
|
|
428
|
-
how a real regression gets waved through.
|
|
429
|
-
"""
|
|
430
|
-
haystack = _distinctive(log_tail)
|
|
431
|
-
return [trap for trap in (traps or []) if _distinctive(trap) & haystack]
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
def triage(repo, *, command, log_tail, traps, config=None, run_dir=None) -> dict | None:
|
|
435
|
-
"""Classify a verification failure. -> {'verdict', 'confidence'} or None."""
|
|
436
|
-
config = config or load_config()
|
|
437
|
-
if not enabled('tests', config=config):
|
|
438
|
-
return None
|
|
439
|
-
tail = (log_tail or '')[-LOG_TAIL_CHARS:]
|
|
440
|
-
# The diff is never sent: recognising a flake needs the failure signature (timeout,
|
|
441
|
-
# ordering, port-in-use, a named trap), not the change itself, and the diff is a
|
|
442
|
-
# larger payload for no benefit here.
|
|
443
|
-
state = dict(command=command, log_tail=tail, known_traps=list(traps or []))
|
|
444
|
-
result = ask(state, {'triage': failure_triage(list(traps or []))}, site='jev-verify-triage',
|
|
445
|
-
run_dir=run_dir, config=config)
|
|
446
|
-
if result is None:
|
|
447
|
-
return None
|
|
448
|
-
verdict, confidence = choice(result, 'triage')
|
|
449
|
-
if verdict is None:
|
|
450
|
-
return None
|
|
451
|
-
matched = corroborating_traps(tail, traps)
|
|
452
|
-
return dict(verdict=verdict, confidence=confidence,
|
|
453
|
-
corroborated=bool(matched), corroborating_traps=matched)
|
package/ui/README.md
CHANGED
|
@@ -18,6 +18,13 @@ blocks on a plate, with cables between them and lamps that light up as things ha
|
|
|
18
18
|
- **Verification as it happens:** the step each lane is in, its last line, the failing tests
|
|
19
19
|
first (new or known, from the lanes' test reports) with a link into the log at each one, and
|
|
20
20
|
every lane's output a click away.
|
|
21
|
+
- **Where each task is, and what it checked:** the command a running dwarf or reviewer is
|
|
22
|
+
running and for how long, flagged when its log has been quiet for five minutes; why a task
|
|
23
|
+
that is not running waits (its dependencies, shared files, a full run, a drain, an
|
|
24
|
+
infrastructure pause with its countdown, the retry policy); each attempt's tests, type checks,
|
|
25
|
+
lints and builds with their exits, times and counts, against the commands its acceptance
|
|
26
|
+
criteria name; and one banner for an environment problem (Docker, a sandbox's EPERM, a port in
|
|
27
|
+
use) that several tasks met.
|
|
21
28
|
- **Click to open.** A task opens to show its attempts, each with its dwarf, its reviewer and
|
|
22
29
|
any shadow reviews, linked; an escalation is a labelled cable between attempts. The
|
|
23
30
|
inspector beside the stage shows what launched each step and what came of it: the exact
|
|
@@ -27,7 +34,7 @@ blocks on a plate, with cables between them and lamps that light up as things ha
|
|
|
27
34
|
otherwise); running nodes pulse and show their current phase.
|
|
28
35
|
- **Extras:** replay a run from its recorded times, light its critical path, set block height
|
|
29
36
|
and colour by duration, tokens, attempts or model, and mark shadow reviews that disagreed
|
|
30
|
-
with the primary
|
|
37
|
+
with the primary.
|
|
31
38
|
- **Beyond one run:** a full-screen **run cloud** of every run, grouped by project, in five
|
|
32
39
|
layouts with filters and runs you can drag anywhere; **diffs** with each finding under the
|
|
33
40
|
line it names; each dwarf's and reviewer's **conversation**, read from its CLI's log; a
|
|
@@ -172,15 +179,35 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
172
179
|
a lamp: their severity is a shape (P0 spike, P1 diamond, P2 cone, P3 pin).
|
|
173
180
|
- **Tables:** the task table and the leaderboard's tables sort by any column (click its header:
|
|
174
181
|
ascending, descending, off), reorder by dragging a header (or Alt+← → on it), and show or hide
|
|
175
|
-
columns from *Columns*, which also resets them. Each table remembers its columns.
|
|
182
|
+
columns from *Columns*, which also resets them. Each table remembers its columns. The task
|
|
183
|
+
table's *Now* column says what each running task runs (and for how long), or why one waits.
|
|
176
184
|
|
|
177
185
|
<img src="docs/media/run.png" width="49%" alt="Planned waves: a run's tasks on a 3D plate with dependency cables, finding marks and the finish nodes, between the runs list and the run's inspector."> <img src="docs/media/execution.png" width="49%" alt="Execution: one block per attempt on wall-clock time, failed attempts in red, with the timeline and critical path in the inspector.">
|
|
178
|
-
- **Inspector:** for the run, its timeline, critical path, peak concurrency
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
- **Inspector:** for the run, its timeline, critical path, peak concurrency, what its scheduler
|
|
187
|
+
is doing (dispatching, drained or stopping, how many tasks wait and on what, each pause with its
|
|
188
|
+
countdown) and finish line, with what the finding sweep fixed and left; for a task, *Now* (below), its models and routing, escalations,
|
|
189
|
+
timings (busy, model time, overhead, queue wait after its dependencies merged), attempts and
|
|
190
|
+
their executions with the checks each ran, review findings with the gate decision, what the
|
|
191
|
+
finding sweep did with its findings (or, for a fix task, each finding it took and whether its
|
|
192
|
+
review found it fixed), and its prompts; for one execution, its model, phases, tokens,
|
|
193
|
+
checks, exact prompt and final message; for the final review, its verdict, findings, report,
|
|
194
|
+
prompt and history.
|
|
195
|
+
- **Now and checks:** a running task's *Now* names the agent at work and its attempt, the phase
|
|
196
|
+
and for how long, the command it is running (its first line, and whether it is a test, type
|
|
197
|
+
check, lint or build) and for how long, when its log last moved, and *quiet N min* once that is
|
|
198
|
+
over five minutes; it links to the conversation. A task that is not running says why: the
|
|
199
|
+
tasks it waits on (a stopped one marked), the running task it shares files with, no free slot,
|
|
200
|
+
a drain or stop, an infrastructure pause with its countdown, or the retry policy's stop with
|
|
201
|
+
the split it suggests. Under each attempt's dwarf and reviewer are the checks they ran, from
|
|
202
|
+
their logs: a lamp, the kind, the command (opening the conversation at it), its exit, time and
|
|
203
|
+
counts (passed, failed, skipped; or errors and warnings), and a failed one's last lines; then
|
|
204
|
+
the environment problems its failed commands met, and which of the commands the brief's
|
|
205
|
+
`## Acceptance criteria` names ran, ran another way, or never ran. A codex or grok log carries
|
|
206
|
+
no times, so the times come from the clock forge keeps beside each log (runs from before it
|
|
207
|
+
show none). The run header's *Environment* banner lists a problem (Docker down or out of
|
|
208
|
+
address pools, a missing container, a port in use, the sandbox's EPERM, a refused local
|
|
209
|
+
service, no network, a full disk, a missing command) that the failed commands of more than one
|
|
210
|
+
task met, with those tasks and, folded, each command and the line that showed it.
|
|
184
211
|
- **Verification (its finish node):** while it runs, how long it has run, the step a lane
|
|
185
212
|
announced (`::forge step name=… state=start`) and for how long, the last line it printed, a
|
|
186
213
|
warning after five minutes with no output, and the live output of the lane that printed last
|
|
@@ -223,7 +250,7 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
223
250
|
from a finding's mark on the stage (`/finding/<id>` scrolls to that finding and focuses it).
|
|
224
251
|
|
|
225
252
|
<img src="docs/media/diff.png" width="760" alt="The diff a reviewer read, with a P1 finding under the line that compares token digests and a P2 finding under the revoke function.">
|
|
226
|
-
- **Conversations (`…/tasks/<id>/executions/<dwarf-or-qa>/conversation`, `…/executions/<id>/conversation`):**
|
|
253
|
+
- **Conversations (`…/tasks/<id>/executions/<dwarf-or-qa>/conversation[/event/<n>]`, `…/executions/<id>/conversation`):**
|
|
227
254
|
what one dwarf or reviewer said and did, read from its agent CLI's `<role>.log`, in the diff's
|
|
228
255
|
place: its messages, its thinking folded, each command with its exit and output, each edit with
|
|
229
256
|
its patch and a link to the file in the diff its review read, other tool calls, and the final
|
|
@@ -232,7 +259,8 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
232
259
|
*Follow* keeps the newest event in view. codex, grok, claude, openclaude and opencode logs are
|
|
233
260
|
read event by event; when a claude run logged only its final answer, the conversation comes from
|
|
234
261
|
Claude's own session file for that run, if it is still on this machine; any other log is shown
|
|
235
|
-
as it is. Open it from an attempt's dwarf or reviewer in the inspector
|
|
262
|
+
as it is. Open it from an attempt's dwarf or reviewer in the inspector, or at one command from a
|
|
263
|
+
check or an environment problem (`/event/<n>` opens it there and stops following the end).
|
|
236
264
|
|
|
237
265
|
<img src="docs/media/conversation.png" width="760" alt="A dwarf's conversation: its thinking, the files it wrote, a test run that failed with exit 1 and the run that passed after the fix.">
|
|
238
266
|
- **Fractal child tasks:** when a run used Fractal, a task's inspector shows the tree it was split
|
|
@@ -322,6 +350,9 @@ turns all of it off: no token is issued, every change is a 405, and the controls
|
|
|
322
350
|
- `forge_ui/static/diffview.js`: the diff viewer, with findings pinned to their lines.
|
|
323
351
|
- `forge_ui/static/convo.js`, `forge_ui/transcripts.py`: an execution's conversation, and the
|
|
324
352
|
reader of each agent CLI's log format behind it.
|
|
353
|
+
- `forge_ui/static/checksview.js`, `forge_ui/checks.py`: where each task stands and the checks its
|
|
354
|
+
agents ran (the Now column and section, each attempt's checks, the environment banner), and
|
|
355
|
+
the reading of checks, counts, acceptance criteria and environment problems from a transcript.
|
|
325
356
|
- `forge_ui/static/files.js`: the files heatmap (`matrix()` is pure and node-tested).
|
|
326
357
|
- `forge_ui/export.py`: a run as one HTML file (the page's scripts and styles inlined, the API
|
|
327
358
|
responses it reads, the 3D stage's modules as one module text, a hash-based policy).
|