@giamme/forge 0.12.1 → 0.13.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.
- package/CHANGELOG.md +66 -0
- package/README.md +1 -1
- package/SKILL.md +29 -12
- package/VERSION +1 -1
- package/docs/add-ons.md +11 -6
- package/docs/artifacts.md +12 -6
- package/docs/commands.md +179 -17
- package/docs/decomposed-runs.md +13 -5
- package/docs/forge-ui.md +14 -4
- package/docs/memory.md +2 -1
- package/docs/models.md +4 -2
- package/docs/reviews.md +49 -20
- package/docs/troubleshooting.md +3 -1
- package/forge +17 -1
- package/package.json +1 -1
- package/references/dataset.md +39 -13
- package/references/decision-models.md +763 -0
- package/references/decompose.md +166 -29
- package/references/harnesses.md +10 -3
- package/references/planning.md +8 -0
- package/references/solo.md +13 -3
- package/scripts/forge-artifact.sh +30 -4
- package/scripts/forge-config.py +238 -29
- package/scripts/forge-contract.py +95 -56
- package/scripts/forge-control.py +40 -9
- package/scripts/forge-decide.py +6 -0
- package/scripts/forge-dispatch.sh +38 -16
- 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 +321 -33
- 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 +22 -6
- package/scripts/forge-lib-review.sh +22 -17
- package/scripts/forge-lib-task.sh +217 -38
- package/scripts/forge-lib-verify.sh +45 -8
- package/scripts/forge-memory.sh +3 -3
- package/scripts/forge-parallel-options.sh +18 -5
- package/scripts/forge-parallel.sh +457 -303
- 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 +10 -4
- package/scripts/forge-schedule.py +21 -5
- package/scripts/forge-shadow.py +2 -2
- package/scripts/forge-solo.sh +39 -9
- package/scripts/forge-submodules.py +389 -0
- package/scripts/forge-ui-options.sh +25 -0
- package/scripts/forge_dataset/cli.py +12 -6
- package/scripts/forge_dataset/export.py +140 -84
- 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 +180 -0
- package/scripts/forge_decide/cache.py +66 -0
- package/scripts/forge_decide/cli.py +953 -0
- package/scripts/forge_decide/doctor.py +270 -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 +2 -2
- package/ui/docs/api.md +92 -39
- package/ui/forge_ui/control.py +71 -14
- package/ui/forge_ui/export.py +2 -1
- package/ui/forge_ui/models.py +17 -16
- package/ui/forge_ui/reader.py +132 -21
- package/ui/forge_ui/repos.py +428 -0
- package/ui/forge_ui/static/app.js +24 -5
- package/ui/forge_ui/static/cloudmodel.js +8 -5
- package/ui/forge_ui/static/controls.js +20 -13
- package/ui/forge_ui/static/modelstats.js +12 -8
- package/ui/forge_ui/static/panel.js +63 -17
- package/ui/forge_ui/static/runmodel.js +48 -7
- package/ui/forge_ui/static/scene3d.js +2 -15
- package/ui/forge_ui/static/settings.js +481 -68
- package/ui/forge_ui/static/style.css +56 -9
- 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
|
@@ -34,7 +34,7 @@ blocks on a plate, with cables between them and lamps that light up as things ha
|
|
|
34
34
|
otherwise); running nodes pulse and show their current phase.
|
|
35
35
|
- **Extras:** replay a run from its recorded times, light its critical path, set block height
|
|
36
36
|
and colour by duration, tokens, attempts or model, and mark shadow reviews that disagreed
|
|
37
|
-
with the primary
|
|
37
|
+
with the primary.
|
|
38
38
|
- **Beyond one run:** a full-screen **run cloud** of every run, grouped by project, in five
|
|
39
39
|
layouts with filters and runs you can drag anywhere; **diffs** with each finding under the
|
|
40
40
|
line it names; each dwarf's and reviewer's **conversation**, read from its CLI's log; a
|
|
@@ -189,7 +189,7 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
189
189
|
timings (busy, model time, overhead, queue wait after its dependencies merged), attempts and
|
|
190
190
|
their executions with the checks each ran, review findings with the gate decision, what the
|
|
191
191
|
finding sweep did with its findings (or, for a fix task, each finding it took and whether its
|
|
192
|
-
review found it fixed),
|
|
192
|
+
review found it fixed), and its prompts; for one execution, its model, phases, tokens,
|
|
193
193
|
checks, exact prompt and final message; for the final review, its verdict, findings, report,
|
|
194
194
|
prompt and history.
|
|
195
195
|
- **Now and checks:** a running task's *Now* names the agent at work and its attempt, the phase
|