@giamme/forge 0.21.0 → 0.23.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 +81 -0
- package/README.md +25 -15
- package/SKILL.md +137 -216
- package/VERSION +1 -1
- package/bin/forge.js +104 -0
- package/docs/README.md +2 -3
- package/docs/add-ons.md +5 -3
- package/docs/artifacts.md +17 -2
- package/docs/commands.md +85 -63
- package/docs/decomposed-runs.md +195 -21
- package/docs/development.md +12 -10
- package/docs/forge-ui.md +33 -4
- package/docs/install.md +127 -6
- package/docs/memory.md +6 -1
- package/docs/models.md +36 -10
- package/docs/reviews.md +50 -29
- package/docs/safety.md +27 -2
- package/docs/troubleshooting.md +8 -11
- package/forge +29 -4
- package/forge.cmd +56 -0
- package/package.json +6 -3
- package/references/dataset.md +10 -9
- package/references/decompose-integration.md +337 -0
- package/references/decompose-opt-in.md +527 -0
- package/references/decompose-recovery.md +569 -0
- package/references/decompose-review.md +256 -0
- package/references/decompose.md +99 -1606
- package/references/findings.md +68 -0
- package/references/harnesses.md +7 -12
- package/references/memory.md +13 -2
- package/references/planning.md +48 -18
- package/references/ripwire.md +38 -13
- package/references/runtime.md +22 -33
- package/references/setup.md +90 -0
- package/references/solo.md +13 -42
- package/references/ui.md +12 -5
- package/registry.tsv +40 -22
- package/scripts/forge-artifact.sh +148 -13
- package/scripts/forge-compare.py +5 -15
- package/scripts/forge-config.py +14 -1
- package/scripts/forge-contract.py +216 -53
- package/scripts/forge-control.py +781 -51
- package/scripts/forge-dispatch.sh +202 -42
- package/scripts/forge-du.py +13 -3
- package/scripts/forge-guard.py +137 -6
- package/scripts/forge-handoff.py +221 -39
- package/scripts/forge-install-ripwire.sh +100 -24
- package/scripts/forge-install.sh +100 -41
- package/scripts/forge-issues.py +6 -4
- package/scripts/forge-jev-options.sh +3 -5
- package/scripts/forge-lib-adopt.sh +169 -5
- package/scripts/forge-lib-attribute.sh +10 -3
- package/scripts/forge-lib-decompose.sh +454 -0
- package/scripts/forge-lib-env.sh +179 -0
- package/scripts/forge-lib-group.sh +9 -6
- package/scripts/forge-lib-plans.sh +38 -21
- package/scripts/forge-lib-review.sh +28 -8
- package/scripts/forge-lib-task.sh +263 -69
- package/scripts/forge-lib-verify.sh +59 -10
- package/scripts/forge-memory.sh +83 -4
- package/scripts/forge-metrics.sh +10 -3
- package/scripts/forge-parallel-options.sh +23 -4
- package/scripts/forge-parallel.sh +602 -217
- package/scripts/forge-plan-check.py +71 -8
- package/scripts/forge-planner.py +303 -17
- package/scripts/forge-pr.py +9 -1
- package/scripts/forge-prompt.py +2 -2
- package/scripts/forge-review-links.py +248 -0
- package/scripts/forge-ripwire.py +234 -16
- package/scripts/forge-route.py +19 -27
- package/scripts/forge-runs-rm.py +92 -21
- package/scripts/forge-runs.py +46 -5
- package/scripts/forge-runtime.py +39 -14
- package/scripts/forge-schedule.py +141 -33
- package/scripts/forge-setup-stale.py +236 -0
- package/scripts/forge-setup.py +804 -0
- package/scripts/forge-shadow.py +2 -20
- package/scripts/forge-solo-lock.py +46 -0
- package/scripts/forge-solo.sh +39 -58
- package/scripts/forge-sweep.py +3 -2
- package/scripts/forge-ui.py +8 -1
- package/scripts/forge-update.sh +8 -3
- package/scripts/forge-verify.py +17 -1
- package/scripts/forge-version.py +13 -1
- package/scripts/forge-watch.py +7 -2
- package/scripts/forge-win.sh +156 -0
- package/scripts/forge_brief/__init__.py +6 -1
- package/scripts/forge_brief/proposals.py +6 -1
- package/scripts/forge_dataset/__init__.py +1 -1
- package/scripts/forge_dataset/capture.py +0 -34
- package/scripts/forge_dataset/checks.py +0 -1
- package/scripts/forge_dataset/cli.py +5 -1
- package/scripts/forge_dataset/export.py +28 -6
- package/scripts/forge_dataset/facts.py +1 -2
- package/scripts/forge_dataset/forecast.py +1 -1
- package/scripts/forge_dataset/harvest.py +107 -7
- package/scripts/forge_dataset/importer.py +3 -2
- package/scripts/forge_dataset/pairs.py +3 -3
- package/scripts/forge_dataset/reviewers.py +4 -3
- package/scripts/forge_dataset/routing.py +6 -3
- package/scripts/forge_dataset/tiers.py +1 -1
- package/scripts/forge_decide/__init__.py +1 -1
- package/scripts/forge_decide/budget.py +12 -7
- package/scripts/forge_decide/profiles.py +11 -14
- package/scripts/forge_decide/replay.py +9 -4
- package/scripts/forge_decompose.py +987 -0
- package/scripts/forge_flock.py +17 -2
- package/scripts/forge_groups/review.py +6 -1
- package/scripts/forge_jev/__init__.py +1 -1
- package/scripts/forge_jev/cli.py +10 -1
- package/scripts/forge_jev/gates.py +10 -1
- package/scripts/forge_jev/verify.py +10 -2
- package/scripts/forge_legacy.py +86 -0
- package/scripts/forge_memory_home.py +57 -0
- package/scripts/forge_models.py +151 -0
- package/scripts/forge_posix.py +17 -0
- package/scripts/forge_prefs.py +138 -0
- package/scripts/forge_proc.py +108 -0
- package/scripts/forge_registry.py +2 -2
- package/scripts/forge_side/__init__.py +23 -4
- package/scripts/forge_storage.py +28 -15
- package/ui/README.md +22 -10
- package/ui/docs/api.md +121 -99
- package/ui/forge_ui/control.py +53 -16
- package/ui/forge_ui/export.py +0 -10
- package/ui/forge_ui/models.py +15 -2
- package/ui/forge_ui/projects.py +4 -1
- package/ui/forge_ui/reader.py +462 -60
- package/ui/forge_ui/server.py +0 -10
- package/ui/forge_ui/static/app.js +28 -9
- package/ui/forge_ui/static/checksview.js +12 -3
- package/ui/forge_ui/static/controls.js +147 -11
- package/ui/forge_ui/static/convo.js +5 -2
- package/ui/forge_ui/static/diffview.js +4 -5
- package/ui/forge_ui/static/panel.js +180 -77
- package/ui/forge_ui/static/projectsview.js +16 -2
- package/ui/forge_ui/static/runmodel.js +18 -4
- package/ui/forge_ui/static/scene3d.js +52 -31
- package/ui/forge_ui/static/settings.js +1 -1
- package/ui/forge_ui/static/storageview.js +2 -2
- package/ui/forge_ui/static/style.css +23 -6
- package/ui/forge_ui/static/worktreesview.js +8 -4
- package/ui/forge_ui/transcripts.py +6 -0
- package/ui/forge_ui/worktrees.py +13 -1
- package/docs/fractal.md +0 -181
- package/references/fractal-dashboard.md +0 -21
- package/references/fractal.md +0 -307
- package/scripts/forge-fractal-dispatch.sh +0 -4
- package/scripts/forge-fractal-options.sh +0 -54
- package/scripts/forge-fractal.py +0 -6
- package/scripts/forge-install-fractal.sh +0 -4
- package/scripts/forge_fractal/__init__.py +0 -88
- package/scripts/forge_fractal/bridge.py +0 -46
- package/scripts/forge_fractal/cli.py +0 -224
- package/scripts/forge_fractal/dashboard.css +0 -138
- package/scripts/forge_fractal/dashboard.html +0 -41
- package/scripts/forge_fractal/dashboard.js +0 -687
- package/scripts/forge_fractal/decomposition.py +0 -262
- package/scripts/forge_fractal/execution.py +0 -659
- package/scripts/forge_fractal/inspection.py +0 -261
- package/scripts/forge_fractal/install.py +0 -158
- package/scripts/forge_fractal/invocation.py +0 -95
- package/scripts/forge_fractal/pipeline.py +0 -125
- package/scripts/forge_fractal/selection.py +0 -180
- package/ui/forge_ui/fractal.py +0 -582
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Subcommands, stdlib only, no network:
|
|
5
5
|
|
|
6
|
-
qa --part head|tail [--kind task|final|solo|sweep|adopt|group|script] [--threshold P0|P1|P2|P3|none]
|
|
6
|
+
qa --part head|tail [--kind task|final|solo|sweep|adopt|group|script] [--threshold P0|P1|P2|P3|none] [--test-minutes N]
|
|
7
7
|
Prints one piece of the QA prompt. The caller prints everything between and
|
|
8
8
|
after the pieces itself (scope notes, the diff fence, the memory note and the
|
|
9
9
|
"Place any learning notes before the final FORGE_VERDICT ..." sentence).
|
|
@@ -15,8 +15,8 @@ Subcommands, stdlib only, no network:
|
|
|
15
15
|
dwarf's text mentions writing .forge/retro-inbox.jsonl when a hard blocker hits.
|
|
16
16
|
gate --verdict PASS|FAIL|UNKNOWN --qa-last FILE [--threshold Pn|none] [--known-issues OUT]
|
|
17
17
|
Prints ONE tab-separated line
|
|
18
|
-
decision <TAB> worst_confirmed <TAB> n_confirmed <TAB> n_unlabelled <TAB> n_below
|
|
19
|
-
and, when findings were tolerated, writes them to OUT.
|
|
18
|
+
decision <TAB> worst_confirmed <TAB> n_confirmed <TAB> n_unlabelled <TAB> n_below <TAB> reason
|
|
19
|
+
(reason is findings, tests, or -) and, when findings were tolerated, writes them to OUT.
|
|
20
20
|
outside --qa-last FILE [--threshold Pn|none]
|
|
21
21
|
Prints a JSON list, one object per parsed finding: n (1-based), severity (P0-P3
|
|
22
22
|
or null), status, blocking (the gate's per-finding rule at the threshold) and
|
|
@@ -37,16 +37,27 @@ DEFAULT_THRESHOLD, P2, and `none` (any case) means P3, nothing tolerated.
|
|
|
37
37
|
|
|
38
38
|
The gate. A finding is BLOCKING when it is CONFIRMED with a severity at the threshold or
|
|
39
39
|
worse, CONFIRMED with no severity, or UNSTATED with a severity at the threshold or worse.
|
|
40
|
-
PLAUSIBLE findings never block.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
PLAUSIBLE findings never block. Reported failing tests (`FORGE_TESTS: RAN — FAILED: <names>`,
|
|
41
|
+
`FORGE_TESTS: FAILED — <names>`, or `FORGE_TESTS_FAILED: <names>`) also block, regardless of
|
|
42
|
+
finding severities. decision is one of:
|
|
43
|
+
- `fail` when the verdict is PASS and at least one finding is blocking or failing tests
|
|
44
|
+
are reported;
|
|
45
|
+
- `accept` when ALL of these hold: the verdict is FAIL; no failing tests are reported;
|
|
46
|
+
at least one CONFIRMED finding exists (a FAIL with none stays a FAIL); n_unlabelled == 0,
|
|
47
|
+
and every CONFIRMED finding carries a P0-P3 label strictly less severe than the threshold;
|
|
45
48
|
- `keep` otherwise, and always for UNKNOWN.
|
|
46
49
|
The decision is a statement about the findings only; wiring it into a verdict is the
|
|
47
50
|
caller's job. Fail-safe means blocking: anything the parser cannot read confidently
|
|
48
51
|
pushes toward `keep` for a FAIL and toward `fail` for a PASS, never toward `accept`.
|
|
49
52
|
|
|
53
|
+
Recaps (#254). A retry round's reviewer may recap the last round before its own review. A block
|
|
54
|
+
whose first line marks it `(fixed)`, `(resolved)` or `(addressed)`, and every block in the list
|
|
55
|
+
under a recap title (a heading, a bold line of its own or a short `Title:` line such as
|
|
56
|
+
"Previous findings", "Findings from the last round" or "Recap"), is not a finding of this round
|
|
57
|
+
and is skipped. A block that says the finding is not fixed, still present or regressed stays a
|
|
58
|
+
finding, and so does a CONFIRMED block under a recap title that never says it was fixed,
|
|
59
|
+
resolved, addressed, rejected or withdrawn. The recap's list ends at the next title or at a flush-left line that is not a bullet.
|
|
60
|
+
|
|
50
61
|
Fields: worst_confirmed is the most severe label among CONFIRMED labelled findings
|
|
51
62
|
(`-` if none); n_confirmed counts CONFIRMED findings; n_unlabelled counts CONFIRMED
|
|
52
63
|
findings with no recognisable severity, plus located findings carrying a severity but
|
|
@@ -73,8 +84,9 @@ them, and still when the facts brace is what closes the line. `{outside=…}` is
|
|
|
73
84
|
way, on its own or beside `{tasks=…}`, in either order.
|
|
74
85
|
|
|
75
86
|
Phantom findings. A reviewer may echo the contract it was given. Three layers keep that
|
|
76
|
-
from creating findings or blocking: (1) FORGE_VERDICT, FORGE_LEARNING, FORGE_TESTS,
|
|
77
|
-
FORGE_BLOCKED text is removed before parsing (the verdict
|
|
87
|
+
from creating findings or blocking: (1) FORGE_VERDICT, FORGE_LEARNING, FORGE_TESTS,
|
|
88
|
+
FORGE_TESTS_FAILED, FORGE_RETRO and FORGE_BLOCKED text is removed before parsing (the verdict
|
|
89
|
+
line itself says "CONFIRMED"); (2) any line that is a
|
|
78
90
|
contiguous fragment of this module's own contract text (all parts, kinds and thresholds,
|
|
79
91
|
whitespace-collapsed, at least 25 characters, list marker ignored) is removed, which
|
|
80
92
|
covers the example bullet, the severity definitions and the instructions even when
|
|
@@ -107,10 +119,10 @@ Finding.__doc__ = (
|
|
|
107
119
|
'tagged block with neither status word). severity: 0-3 or None. line: 1-based '
|
|
108
120
|
'line number of the block start in the original text. text: the block, verbatim.')
|
|
109
121
|
GateResult = collections.namedtuple(
|
|
110
|
-
'GateResult', 'decision worst n_confirmed n_unlabelled n_below tolerated')
|
|
122
|
+
'GateResult', 'decision worst n_confirmed n_unlabelled n_below tolerated reason')
|
|
111
123
|
GateResult.__doc__ = (
|
|
112
|
-
'decision accept|fail|keep, worst most severe confirmed label or "-", counters,
|
|
113
|
-
'
|
|
124
|
+
'decision accept|fail|keep, worst most severe confirmed label or "-", counters, tolerated '
|
|
125
|
+
'Findings tuple, and reason (findings|tests|-).')
|
|
114
126
|
|
|
115
127
|
|
|
116
128
|
# --- prompt text -----------------------------------------------------------------
|
|
@@ -197,20 +209,46 @@ _SOLO_EXTRA = ['If the diff is correct, say so plainly rather than inventing som
|
|
|
197
209
|
|
|
198
210
|
# The reviewer's own verification, bounded to the change (#89): one reviewer re-ran a whole
|
|
199
211
|
# repository suite to review a one-file patch. The evidence is what the caller prints between
|
|
200
|
-
# the head and the tail (fail-first, pre-review tests).
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
]
|
|
212
|
+
# the head and the tail (fail-first, pre-review tests). Checks in a brief's acceptance criteria
|
|
213
|
+
# take priority over the default test-minute guideline; stopped/skipped checks report PARTIAL (#223).
|
|
214
|
+
def _verify_lines(minutes: int = QA_TEST_MINUTES) -> list:
|
|
215
|
+
if minutes <= 0:
|
|
216
|
+
head = [
|
|
217
|
+
'Verify within the change: run only the tests that touch the changed code (the tests the',
|
|
218
|
+
'diff adds or edits, and the tests of the modules it changes), plus every check named in',
|
|
219
|
+
"the task's acceptance criteria, with no separate test-minute cap (only the review",
|
|
220
|
+
'timeout bounds it). Use any test evidence forge gives you above before running a test',
|
|
221
|
+
'yourself. When a check touches shared infrastructure (a test helper, a build file, a',
|
|
222
|
+
'lockfile) or cannot complete, report what stayed unchecked with PARTIAL instead of RAN.',
|
|
223
|
+
'If a test needs a dependency your checkout does not have, do not look for it elsewhere',
|
|
224
|
+
'and do not install anything: report that it could not run.',
|
|
225
|
+
]
|
|
226
|
+
else:
|
|
227
|
+
head = [
|
|
228
|
+
'Verify within the change: run only the tests that touch the changed code (the tests the',
|
|
229
|
+
'diff adds or edits, and the tests of the modules it changes), never the whole suite, and',
|
|
230
|
+
"spend at most about %d minutes running tests. Checks named in the task's acceptance" % minutes,
|
|
231
|
+
'criteria take priority over that %d-minute guideline: run them unless the review' % minutes,
|
|
232
|
+
'timeout stops them, and never report an unrun or stopped acceptance check as RAN. Use',
|
|
233
|
+
'any test evidence forge gives you above before running a test yourself. When a targeted',
|
|
234
|
+
'or required check is stopped at a time limit or skipped (such as shared infrastructure),',
|
|
235
|
+
'report what stayed unchecked with PARTIAL instead of RAN. If a test needs a dependency',
|
|
236
|
+
'your checkout does not have, do not look for it elsewhere and do not install anything:',
|
|
237
|
+
'report that it could not run.',
|
|
238
|
+
]
|
|
239
|
+
return head + [
|
|
240
|
+
'Say whether tests ran, on a line of its own before the verdict, in exactly one of these forms:',
|
|
241
|
+
' FORGE_TESTS: RAN',
|
|
242
|
+
' FORGE_TESTS: RAN — FAILED: <names>',
|
|
243
|
+
' FORGE_TESTS: PARTIAL — <what stopped or was skipped>',
|
|
244
|
+
' FORGE_TESTS: NOT NEEDED — why',
|
|
245
|
+
' FORGE_TESTS: COULD NOT RUN — why',
|
|
246
|
+
'Use FAILED only for tests failing because of this change; mention unrelated failures in',
|
|
247
|
+
'prose.',
|
|
248
|
+
]
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
_VERIFY = _verify_lines(QA_TEST_MINUTES)
|
|
214
252
|
|
|
215
253
|
_SEVERITY = [
|
|
216
254
|
'Label every finding with its severity at the start of its own bullet, in exactly this form:',
|
|
@@ -302,10 +340,12 @@ def _threshold_clause(rank: int, kind: str = 'task') -> list:
|
|
|
302
340
|
'finding is blocking.']
|
|
303
341
|
if kind == 'sweep': # the verdict lines below say when a sweep fails
|
|
304
342
|
lines[-2:] = ['not by itself justify FAIL.']
|
|
343
|
+
lines += ['File tests that fail with this change (new, or passed without it) as a CONFIRMED',
|
|
344
|
+
'finding at %s or worse (they block); mention unrelated failures in prose.' % name]
|
|
305
345
|
return lines + ['A CONFIRMED finding without a severity tag counts as blocking.']
|
|
306
346
|
|
|
307
347
|
|
|
308
|
-
def qa_text(part: str, kind: str = 'task', threshold=None) -> str:
|
|
348
|
+
def qa_text(part: str, kind: str = 'task', threshold=None, test_minutes=None) -> str:
|
|
309
349
|
"""One shared piece of the QA prompt, newline-terminated, no leading/trailing blank."""
|
|
310
350
|
if kind not in KINDS:
|
|
311
351
|
raise ValueError('kind must be one of ' + ', '.join(KINDS))
|
|
@@ -314,10 +354,13 @@ def qa_text(part: str, kind: str = 'task', threshold=None) -> str:
|
|
|
314
354
|
return '\n'.join(_HEAD[kind]) + '\n'
|
|
315
355
|
if part != 'tail':
|
|
316
356
|
raise ValueError('part must be head or tail')
|
|
357
|
+
minutes = QA_TEST_MINUTES if test_minutes is None else int(test_minutes)
|
|
358
|
+
if minutes < 0:
|
|
359
|
+
raise ValueError('test_minutes must be non-negative')
|
|
317
360
|
lines = list(_SWEEP_FINDINGS if kind == 'sweep' else _FINDINGS)
|
|
318
361
|
if kind in ('task', 'solo', 'adopt', 'group', 'script'):
|
|
319
362
|
lines += _ALL_CONFIRMED + _SOLO_EXTRA
|
|
320
|
-
lines += [''] +
|
|
363
|
+
lines += [''] + _verify_lines(minutes)
|
|
321
364
|
lines += [''] + _SEVERITY
|
|
322
365
|
if kind in ('task', 'solo', 'group', 'script'):
|
|
323
366
|
lines += [''] + _OUTSIDE
|
|
@@ -343,13 +386,13 @@ _VERIFY_SCOPE = (
|
|
|
343
386
|
' type checks unless the task asks for them.',
|
|
344
387
|
)
|
|
345
388
|
|
|
346
|
-
# When the run verifies the repository
|
|
347
|
-
#
|
|
389
|
+
# When the run verifies the repository, a task that names the whole suite in its acceptance criteria
|
|
390
|
+
# no longer buys a full run per attempt: forge runs it once at the end of the run.
|
|
348
391
|
_VERIFY_SCOPE_AFTER_MERGE = (
|
|
349
392
|
'- Verify within your change: run the tests the change affects (the task\'s own tests and the',
|
|
350
393
|
' tests of the modules you changed). Never run the whole suite or repo-wide lint, format or',
|
|
351
394
|
' type checks, even when the task or its acceptance criteria name them: forge runs the',
|
|
352
|
-
' repository\'s verification
|
|
395
|
+
' repository\'s verification once at the end of the run. Report that check as left to forge.',
|
|
353
396
|
)
|
|
354
397
|
|
|
355
398
|
_DWARF = [
|
|
@@ -419,7 +462,7 @@ def dwarf_text(pre_review: bool = False, verify_after_merge: bool = False) -> st
|
|
|
419
462
|
|
|
420
463
|
# --- parsing ---------------------------------------------------------------------
|
|
421
464
|
|
|
422
|
-
_PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING|TESTS
|
|
465
|
+
_PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING|TESTS(?:_FAILED)?|RETRO|BLOCKED):.*$')
|
|
423
466
|
_QUOTE = re.compile(r'^\s*(?:>[ \t]?)+')
|
|
424
467
|
_MARKER = re.compile(r'^(?:[-*+•–]|\d{1,3}[.)]|#{1,6})\s+')
|
|
425
468
|
_HEADING = re.compile(r'^ {0,3}#{1,6}[ \t]+\S')
|
|
@@ -476,10 +519,41 @@ def _starts_block(line: str) -> bool:
|
|
|
476
519
|
return bool(_LEAD.match(line) and _LOCATION.search(line))
|
|
477
520
|
|
|
478
521
|
|
|
522
|
+
# A retry round's reviewer often recaps the last round before its own review (#254). A recap is
|
|
523
|
+
# not a finding of this round: a block under a recap heading ("Previous findings", "Findings from
|
|
524
|
+
# the last round", ...) or one whose first line says `(fixed)` is skipped, unless it says the
|
|
525
|
+
# finding is still there. Fail-safe: anything that reads as still open stays a finding.
|
|
526
|
+
_RECAP_TITLE = re.compile(
|
|
527
|
+
r'^(?:recap\b|(?:previous|prior|earlier|last|past)\s+(?:round\'?s?\s+|review\'?s?\s+)?'
|
|
528
|
+
r'(?:findings?|issues?|round|review|feedback)\b'
|
|
529
|
+
r'|(?:findings?|issues?|feedback)\s+(?:from|of)\s+(?:the\s+)?(?:previous|prior|earlier|last)\b)',
|
|
530
|
+
re.IGNORECASE)
|
|
531
|
+
# A bold line of its own, `**Previous findings**` or `__Previous findings:__`, titles a section.
|
|
532
|
+
_BOLD_TITLE = re.compile(r'^\s*(\*\*|__)(?P<title>[^*_\n]+?)\1[ \t]*:?[ \t]*$')
|
|
533
|
+
_PLAIN_TITLE = re.compile(r'^(?P<title>[^\s*_#|>-][^:\n]{0,60}):[ \t]*$')
|
|
534
|
+
_FIXED = re.compile(r'[(\[][ \t]*(?:now[ \t]+|all[ \t]+)?(?:fixed|resolved|addressed)[ \t]*[.!]?[ \t]*[)\]]',
|
|
535
|
+
re.IGNORECASE)
|
|
536
|
+
_STILL_OPEN = re.compile(r'\b(?:not|un|partially|partly)[ \t-]*(?:fixed|resolved|addressed)\b|'
|
|
537
|
+
r'\bstill[ \t]+(?:present|open|there|broken|happens|fails|reproduces)\b|'
|
|
538
|
+
r'\bregress', re.IGNORECASE)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def _section_title(line: str):
|
|
542
|
+
"""The title a heading, a bold line of its own or a short `Title:` line gives, else None."""
|
|
543
|
+
if _HEADING.match(line):
|
|
544
|
+
return re.sub(r'^\s*#+\s*', '', line).strip(' \t*_:')
|
|
545
|
+
if _BULLET.match(line):
|
|
546
|
+
return None
|
|
547
|
+
match = _BOLD_TITLE.match(line) or _PLAIN_TITLE.match(line)
|
|
548
|
+
return match.group('title').strip(' \t*_:') if match else None
|
|
549
|
+
|
|
550
|
+
|
|
479
551
|
def _blocks(lines: list) -> list:
|
|
480
|
-
|
|
552
|
+
"""[start number, indent, [lines], recap] per block; recap: it opened inside a recap section."""
|
|
553
|
+
blocks = []
|
|
481
554
|
current = None
|
|
482
555
|
blank = False
|
|
556
|
+
recap = False
|
|
483
557
|
for number, line in lines:
|
|
484
558
|
if not line.strip():
|
|
485
559
|
blank = True
|
|
@@ -487,13 +561,23 @@ def _blocks(lines: list) -> list:
|
|
|
487
561
|
current[2].append('')
|
|
488
562
|
continue
|
|
489
563
|
indent = len(line) - len(line.lstrip(' '))
|
|
564
|
+
title = _section_title(line)
|
|
565
|
+
if title is not None:
|
|
566
|
+
recap = bool(_RECAP_TITLE.match(title))
|
|
567
|
+
if recap and not _HEADING.match(line):
|
|
568
|
+
current = None # the recap's title closes the block before it
|
|
569
|
+
blank = False
|
|
570
|
+
continue
|
|
571
|
+
elif recap and indent == 0 and not _BULLET.match(line) and (blank or current is None
|
|
572
|
+
or _starts_block(line)):
|
|
573
|
+
recap = False # a flush paragraph or finding ends the recap's list
|
|
490
574
|
if _starts_block(line):
|
|
491
575
|
nested = (current is not None and indent > current[1]
|
|
492
576
|
and not _HEADING.match(line))
|
|
493
577
|
if nested:
|
|
494
578
|
current[2].append(line)
|
|
495
579
|
else:
|
|
496
|
-
current = [number, indent, [line]]
|
|
580
|
+
current = [number, indent, [line], recap]
|
|
497
581
|
blocks.append(current)
|
|
498
582
|
elif current is not None:
|
|
499
583
|
if blank and indent <= current[1]:
|
|
@@ -504,6 +588,25 @@ def _blocks(lines: list) -> list:
|
|
|
504
588
|
return blocks
|
|
505
589
|
|
|
506
590
|
|
|
591
|
+
_SETTLED = re.compile(r'\b(?:fixed|resolved|addressed|rejected|withdrawn)\b', re.IGNORECASE)
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
def _recap(lines: list, in_recap: bool) -> bool:
|
|
595
|
+
"""Whether a block recaps an earlier round instead of reporting a finding of this one.
|
|
596
|
+
|
|
597
|
+
A CONFIRMED block under a recap title stays a finding unless it also says it was settled:
|
|
598
|
+
a new finding listed with the recap must not be lost."""
|
|
599
|
+
body = '\n'.join(lines)
|
|
600
|
+
if _STILL_OPEN.search(body):
|
|
601
|
+
return False
|
|
602
|
+
if _FIXED.search(lines[0]):
|
|
603
|
+
return True
|
|
604
|
+
if not in_recap:
|
|
605
|
+
return False
|
|
606
|
+
confirmed = _CONFIRMED.search(_NOT_CONFIRMED.sub('', body)) or _CONFIRMED_TAG.search(lines[0])
|
|
607
|
+
return not confirmed or bool(_SETTLED.search(body))
|
|
608
|
+
|
|
609
|
+
|
|
507
610
|
def _severity(first_line: str):
|
|
508
611
|
match = _SEVERITY_TOKEN.search(first_line)
|
|
509
612
|
return int(match.group(1)) if match else None
|
|
@@ -598,7 +701,8 @@ def outside_paths(finding_text: str) -> list:
|
|
|
598
701
|
|
|
599
702
|
def parse_findings(text: str) -> list:
|
|
600
703
|
"""Finding blocks of a QA reply, in order; see the module docstring for the rules."""
|
|
601
|
-
found = (_finding(start, lines) for start, _, lines in _blocks(_clean(text))
|
|
704
|
+
found = (_finding(start, lines) for start, _, lines, recap in _blocks(_clean(text))
|
|
705
|
+
if not _recap(lines, recap))
|
|
602
706
|
return [finding for finding in found if finding is not None]
|
|
603
707
|
|
|
604
708
|
|
|
@@ -616,7 +720,7 @@ def finding_blocks(finding, threshold=None) -> bool:
|
|
|
616
720
|
|
|
617
721
|
def gate(verdict: str, text: str, threshold=None) -> GateResult:
|
|
618
722
|
"""Check a QA verdict against its findings: a FAIL may be accepted as
|
|
619
|
-
PASS-with-known-issues, a PASS that lists a blocking finding fails."""
|
|
723
|
+
PASS-with-known-issues, a PASS that lists a blocking finding or failing tests fails."""
|
|
620
724
|
rank = _rank(threshold)
|
|
621
725
|
findings = parse_findings(text)
|
|
622
726
|
confirmed = [f for f in findings if f.status == 'CONFIRMED']
|
|
@@ -625,32 +729,46 @@ def gate(verdict: str, text: str, threshold=None) -> GateResult:
|
|
|
625
729
|
+ sum(1 for f in findings if f.status == 'UNSTATED'))
|
|
626
730
|
worst = 'P%d' % min(f.severity for f in labelled) if labelled else '-'
|
|
627
731
|
below = tuple(f for f in labelled if f.severity > rank)
|
|
732
|
+
failed_tests = bool(tests_failed(text))
|
|
628
733
|
blocking = any(finding_blocks(f, threshold) for f in findings)
|
|
629
|
-
if verdict == 'PASS' and blocking:
|
|
734
|
+
if verdict == 'PASS' and (blocking or failed_tests):
|
|
630
735
|
decision = 'fail'
|
|
631
|
-
elif (verdict == 'FAIL' and confirmed and unlabelled == 0
|
|
736
|
+
elif (verdict == 'FAIL' and not failed_tests and confirmed and unlabelled == 0
|
|
632
737
|
and len(below) == len(confirmed)):
|
|
633
738
|
decision = 'accept'
|
|
634
739
|
else:
|
|
635
740
|
decision = 'keep'
|
|
636
|
-
|
|
741
|
+
reason = 'findings' if blocking else ('tests' if failed_tests else '-')
|
|
742
|
+
return GateResult(decision, worst, len(confirmed), unlabelled, len(below), below, reason)
|
|
637
743
|
|
|
638
744
|
|
|
639
|
-
# A reviewer's own word on whether its tests ran (#117)
|
|
640
|
-
# when
|
|
641
|
-
#
|
|
642
|
-
#
|
|
745
|
+
# A reviewer's own word on whether its tests ran (#117) and whether any failed (#171). Only a
|
|
746
|
+
# line of its own counts, the last one when `tests_report` repeats: a quoted example in prose is
|
|
747
|
+
# not its report. Plain `RAN`, `NOT NEEDED` and `COULD NOT RUN` change no verdict, while any
|
|
748
|
+
# non-echo failing-tests report (`RAN — FAILED: <names>`, `FAILED — <names>`, or
|
|
749
|
+
# `FORGE_TESTS_FAILED: <names>`) blocks `accept` and turns `PASS` into `FAIL`.
|
|
643
750
|
_TESTS_LINE = re.compile(r'^[ \t>*_`+-]*FORGE_TESTS:[ \t*_`]*(.*?)[ \t*_`]*$', re.M)
|
|
644
|
-
|
|
645
|
-
|
|
751
|
+
_TESTS_FAILED_LINE = re.compile(r'^[ \t>*_`+-]*FORGE_TESTS_FAILED:[ \t*_`]*(.*?)[ \t*_`]*$', re.M)
|
|
752
|
+
_TESTS_VALUE = re.compile(r'(RAN|PARTIAL|NOT[ _]NEEDED|COULD[ _]NOT[ _]RUN)\b(.*)$', re.I)
|
|
753
|
+
_TESTS_STATUS = {'RAN': 'ran', 'PARTIAL': 'partial', 'NOT NEEDED': 'not_needed', 'COULD NOT RUN': 'could_not_run'}
|
|
646
754
|
_TESTS_TRIM = ' \t—–-:()'
|
|
647
755
|
_TESTS_REASON_MAX = 300
|
|
756
|
+
_TESTS_FAILED_HEAD = re.compile(r'^FAILED(?:\b[ \t—–-]*:?[ \t—–-]*(.*))?$', re.I)
|
|
757
|
+
_TESTS_NO_FAIL = re.compile(r'^(?:none|no|0|nothing|<names>|-)$', re.I)
|
|
648
758
|
|
|
649
759
|
|
|
650
760
|
def _tests_reason(text: str) -> str | None:
|
|
651
761
|
return ''.join(ch for ch in text.strip(_TESTS_TRIM) if ch.isprintable())[:_TESTS_REASON_MAX] or None
|
|
652
762
|
|
|
653
763
|
|
|
764
|
+
def _is_echoed_tests_reason(reason: str | None) -> bool:
|
|
765
|
+
low = (reason or '').strip().lower()
|
|
766
|
+
if low in ('why', '<what stopped or was skipped>', 'what stopped or was skipped'):
|
|
767
|
+
return True
|
|
768
|
+
match = _TESTS_FAILED_HEAD.match(low)
|
|
769
|
+
return bool(match and (match.group(1) or '').strip() == '<names>')
|
|
770
|
+
|
|
771
|
+
|
|
654
772
|
# An implementer's report that a fix lives outside the task's files (#149). Same leading
|
|
655
773
|
# markdown as a FORGE_TESTS line. The why may be empty; a repeated path keeps the first.
|
|
656
774
|
_BLOCKED_LINE = re.compile(r'^[ \t>*_`+-]*FORGE_BLOCKED:[ \t*_`]*(.*?)[ \t*_`]*$', re.M)
|
|
@@ -678,7 +796,7 @@ def blocked_lines(message: str) -> list:
|
|
|
678
796
|
|
|
679
797
|
|
|
680
798
|
def tests_report(text) -> dict | None:
|
|
681
|
-
"""{status: ran|not_needed|could_not_run|unclear, reason} from a QA reply, or None when it does not say."""
|
|
799
|
+
"""{status: ran|partial|not_needed|could_not_run|unclear, reason} from a QA reply, or None when it does not say."""
|
|
682
800
|
report = None
|
|
683
801
|
for value in _TESTS_LINE.findall((text or '').replace('\r\n', '\n')):
|
|
684
802
|
match = _TESTS_VALUE.match(value)
|
|
@@ -686,11 +804,37 @@ def tests_report(text) -> dict | None:
|
|
|
686
804
|
report = dict(status='unclear', reason=_tests_reason(value))
|
|
687
805
|
continue
|
|
688
806
|
reason = _tests_reason(match.group(2))
|
|
689
|
-
if (reason
|
|
807
|
+
if not _is_echoed_tests_reason(reason):
|
|
690
808
|
report = dict(status=_TESTS_STATUS[match.group(1).upper().replace('_', ' ')], reason=reason)
|
|
691
809
|
return report
|
|
692
810
|
|
|
693
811
|
|
|
812
|
+
def tests_failed(text) -> str | None:
|
|
813
|
+
"""Failing test names (or a short summary) when any non-echo line reports failing tests, else None."""
|
|
814
|
+
normalized = (text or '').replace('\r\n', '\n')
|
|
815
|
+
for value in _TESTS_LINE.findall(normalized):
|
|
816
|
+
match = _TESTS_VALUE.match(value)
|
|
817
|
+
if not match:
|
|
818
|
+
status = 'unclear'
|
|
819
|
+
reason = _tests_reason(value)
|
|
820
|
+
else:
|
|
821
|
+
status = _TESTS_STATUS[match.group(1).upper().replace('_', ' ')]
|
|
822
|
+
reason = _tests_reason(match.group(2))
|
|
823
|
+
if _is_echoed_tests_reason(reason):
|
|
824
|
+
continue
|
|
825
|
+
if status in ('ran', 'partial', 'unclear') and reason:
|
|
826
|
+
failed = _TESTS_FAILED_HEAD.match(reason)
|
|
827
|
+
if failed:
|
|
828
|
+
detail = _tests_reason(failed.group(1) or '')
|
|
829
|
+
if not (detail and _TESTS_NO_FAIL.match(detail)):
|
|
830
|
+
return detail or 'FAILED'
|
|
831
|
+
for raw in _TESTS_FAILED_LINE.findall(normalized):
|
|
832
|
+
detail = _tests_reason(raw)
|
|
833
|
+
if detail and not _TESTS_NO_FAIL.match(detail):
|
|
834
|
+
return detail
|
|
835
|
+
return None
|
|
836
|
+
|
|
837
|
+
|
|
694
838
|
def outside_report(text: str, threshold=None) -> list:
|
|
695
839
|
"""One object per parsed finding: n, severity, status, blocking, outside paths."""
|
|
696
840
|
rows = []
|
|
@@ -746,6 +890,16 @@ def _read_text(path: str):
|
|
|
746
890
|
return None
|
|
747
891
|
|
|
748
892
|
|
|
893
|
+
def _nonneg_int_arg(value: str) -> int:
|
|
894
|
+
try:
|
|
895
|
+
num = int(value)
|
|
896
|
+
except ValueError:
|
|
897
|
+
num = -1
|
|
898
|
+
if num < 0:
|
|
899
|
+
raise argparse.ArgumentTypeError('invalid non-negative integer %r' % value.strip())
|
|
900
|
+
return num
|
|
901
|
+
|
|
902
|
+
|
|
749
903
|
def _parser() -> argparse.ArgumentParser:
|
|
750
904
|
parser = argparse.ArgumentParser(
|
|
751
905
|
prog='forge-contract.py', formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
@@ -765,15 +919,18 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
765
919
|
'forge) or group (one review over several tasks; attribute each finding)')
|
|
766
920
|
qa.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
|
|
767
921
|
help='least severe level that still blocks; none = P3 (default: %s)' % DEFAULT_THRESHOLD)
|
|
922
|
+
qa.add_argument('--test-minutes', type=_nonneg_int_arg, default=None, metavar='N',
|
|
923
|
+
help='reviewer test-time guideline in minutes, 0 = no minute cap (default: %d)'
|
|
924
|
+
% QA_TEST_MINUTES)
|
|
768
925
|
dwarf = sub.add_parser('dwarf', help='print the implementer rules block')
|
|
769
926
|
dwarf.add_argument('--pre-review', action='store_true', help='forge runs the affected tests before the review')
|
|
770
927
|
dwarf.add_argument('--verify-after-merge', action='store_true',
|
|
771
|
-
help='the run verifies the repository
|
|
928
|
+
help='the run verifies the repository once at the end of the run, so the whole suite is left to it')
|
|
772
929
|
retro = sub.add_parser('retro', help='print the retro-note instruction for one role')
|
|
773
930
|
retro.add_argument('--role', required=True, choices=RETRO_ROLES,
|
|
774
931
|
help='dwarf also hears about .forge/retro-inbox.jsonl')
|
|
775
932
|
gate_parser = sub.add_parser(
|
|
776
|
-
'gate', help='print: decision (accept|fail|keep), worst_confirmed, n_confirmed, n_unlabelled, n_below')
|
|
933
|
+
'gate', help='print: decision (accept|fail|keep), worst_confirmed, n_confirmed, n_unlabelled, n_below, reason')
|
|
777
934
|
gate_parser.add_argument('--verdict', required=True, choices=('PASS', 'FAIL', 'UNKNOWN'))
|
|
778
935
|
gate_parser.add_argument('--qa-last', required=True, metavar='FILE', help="the QA reply")
|
|
779
936
|
gate_parser.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
|
|
@@ -783,6 +940,7 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
783
940
|
help='write tolerated findings here when there are any')
|
|
784
941
|
tests = sub.add_parser('tests', help='print what the reply says about its tests: status, a tab, the reason')
|
|
785
942
|
tests.add_argument('--qa-last', required=True, metavar='FILE', help='the QA reply')
|
|
943
|
+
tests.add_argument('--failed', action='store_true', help='print reported failing test names, if any')
|
|
786
944
|
outside = sub.add_parser('outside', help='print each finding\'s outside paths as JSON')
|
|
787
945
|
outside.add_argument('--qa-last', required=True, metavar='FILE', help='the QA reply')
|
|
788
946
|
outside.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
|
|
@@ -796,7 +954,7 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
796
954
|
def main(argv=None) -> int:
|
|
797
955
|
args = _parser().parse_args(argv)
|
|
798
956
|
if args.command == 'qa':
|
|
799
|
-
_emit(qa_text(args.part, args.kind, args.threshold))
|
|
957
|
+
_emit(qa_text(args.part, args.kind, args.threshold, args.test_minutes))
|
|
800
958
|
return 0
|
|
801
959
|
if args.command == 'dwarf':
|
|
802
960
|
_emit(dwarf_text(args.pre_review, args.verify_after_merge))
|
|
@@ -808,6 +966,11 @@ def main(argv=None) -> int:
|
|
|
808
966
|
if text is None:
|
|
809
967
|
return 3
|
|
810
968
|
if args.command == 'tests':
|
|
969
|
+
if args.failed:
|
|
970
|
+
failed = tests_failed(text)
|
|
971
|
+
if failed:
|
|
972
|
+
_emit(failed + '\n')
|
|
973
|
+
return 0
|
|
811
974
|
report = tests_report(text)
|
|
812
975
|
if report:
|
|
813
976
|
_emit('%s\t%s\n' % (report['status'], report['reason'] or ''))
|
|
@@ -832,8 +995,8 @@ def main(argv=None) -> int:
|
|
|
832
995
|
except OSError:
|
|
833
996
|
pass
|
|
834
997
|
return 3
|
|
835
|
-
_emit('%s\t%s\t%d\t%d\t%d\n' % (result.decision, result.worst, result.n_confirmed,
|
|
836
|
-
|
|
998
|
+
_emit('%s\t%s\t%d\t%d\t%d\t%s\n' % (result.decision, result.worst, result.n_confirmed,
|
|
999
|
+
result.n_unlabelled, result.n_below, result.reason))
|
|
837
1000
|
return 0
|
|
838
1001
|
|
|
839
1002
|
|