@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
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
Three subcommands, stdlib only, no network:
|
|
5
5
|
|
|
6
|
-
qa --part head|tail [--kind task|final|solo] [--threshold P0|P1|P2|P3]
|
|
6
|
+
qa --part head|tail [--kind task|final|solo|sweep] [--threshold P0|P1|P2|P3|none]
|
|
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).
|
|
10
|
-
dwarf
|
|
11
|
-
Prints the implementer rules block that callers append to the dwarf prompt
|
|
12
|
-
|
|
10
|
+
dwarf [--pre-review]
|
|
11
|
+
Prints the implementer rules block that callers append to the dwarf prompt;
|
|
12
|
+
--pre-review adds that forge runs the affected tests before the review (#85).
|
|
13
|
+
gate --verdict PASS|FAIL|UNKNOWN --qa-last FILE [--threshold Pn|none] [--known-issues OUT]
|
|
13
14
|
Prints ONE tab-separated line
|
|
14
15
|
decision <TAB> worst_confirmed <TAB> n_confirmed <TAB> n_unlabelled <TAB> n_below
|
|
15
16
|
and, when findings were tolerated, writes them to OUT.
|
|
@@ -19,25 +20,29 @@ result on the main path), P1 (wrong behaviour on realistic input, breaks an exis
|
|
|
19
20
|
contract), P2 (edge-case bug, unusual-timing race, missing hardening) or P3 (minor).
|
|
20
21
|
Severity is impact; confidence stays CONFIRMED vs PLAUSIBLE.
|
|
21
22
|
|
|
22
|
-
Threshold.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
The gate.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
Threshold. The threshold is the LEAST severe level that still blocks: `P2` means P0, P1
|
|
24
|
+
and P2 block and only P3 is tolerated; `P0` means only P0 blocks; `P3` means everything
|
|
25
|
+
blocks (nothing is ever tolerated). There is always one: unset (None or "") means
|
|
26
|
+
DEFAULT_THRESHOLD, P2, and `none` (any case) means P3, nothing tolerated.
|
|
27
|
+
|
|
28
|
+
The gate. A finding is BLOCKING when it is CONFIRMED with a severity at the threshold or
|
|
29
|
+
worse, CONFIRMED with no severity, or UNSTATED with a severity at the threshold or worse.
|
|
30
|
+
PLAUSIBLE findings never block. decision is one of:
|
|
31
|
+
- `fail` when the verdict is PASS and at least one finding is blocking;
|
|
32
|
+
- `accept` when ALL of these hold: the verdict is FAIL; at least one CONFIRMED finding
|
|
33
|
+
exists (a FAIL with none stays a FAIL); n_unlabelled == 0, and every CONFIRMED
|
|
34
|
+
finding carries a P0-P3 label strictly less severe than the threshold;
|
|
35
|
+
- `keep` otherwise, and always for UNKNOWN.
|
|
36
|
+
The decision is a statement about the findings only; wiring it into a verdict is the
|
|
33
37
|
caller's job. Fail-safe means blocking: anything the parser cannot read confidently
|
|
34
|
-
pushes toward `keep
|
|
38
|
+
pushes toward `keep` for a FAIL and toward `fail` for a PASS, never toward `accept`.
|
|
35
39
|
|
|
36
40
|
Fields: worst_confirmed is the most severe label among CONFIRMED labelled findings
|
|
37
41
|
(`-` if none); n_confirmed counts CONFIRMED findings; n_unlabelled counts CONFIRMED
|
|
38
42
|
findings with no recognisable severity, plus located findings carrying a severity but
|
|
39
43
|
no CONFIRMED/PLAUSIBLE tag at all (neither can ever be tolerated); n_below counts
|
|
40
|
-
CONFIRMED labelled findings below the threshold
|
|
44
|
+
CONFIRMED labelled findings strictly below the threshold. They are the tolerated ones,
|
|
45
|
+
listed in OUT whenever n_below >= 1, whatever the decision.
|
|
41
46
|
|
|
42
47
|
Parsing. The reply is cut into finding blocks. A block starts at a bullet (`-`, `*`,
|
|
43
48
|
`+`, `1.`, `1)`), a markdown heading, a table row, or a flush line that leads with a
|
|
@@ -73,7 +78,9 @@ import sys
|
|
|
73
78
|
|
|
74
79
|
SEVERITIES = ('P0', 'P1', 'P2', 'P3')
|
|
75
80
|
PLACEHOLDER = 'path/file.py:123'
|
|
76
|
-
KINDS = ('task', 'final', 'solo')
|
|
81
|
+
KINDS = ('task', 'final', 'solo', 'sweep')
|
|
82
|
+
DEFAULT_THRESHOLD = 'P2'
|
|
83
|
+
QA_TEST_MINUTES = 5 # the reviewer's own test time, beyond which it says the check is too broad (#89)
|
|
77
84
|
|
|
78
85
|
Finding = collections.namedtuple('Finding', 'status severity located line text')
|
|
79
86
|
Finding.__doc__ = (
|
|
@@ -83,18 +90,19 @@ Finding.__doc__ = (
|
|
|
83
90
|
GateResult = collections.namedtuple(
|
|
84
91
|
'GateResult', 'decision worst n_confirmed n_unlabelled n_below tolerated')
|
|
85
92
|
GateResult.__doc__ = (
|
|
86
|
-
'decision accept|keep, worst most severe confirmed label or "-", counters, and the '
|
|
93
|
+
'decision accept|fail|keep, worst most severe confirmed label or "-", counters, and the '
|
|
87
94
|
'tuple of tolerated Findings (CONFIRMED, labelled, below the threshold).')
|
|
88
95
|
|
|
89
96
|
|
|
90
97
|
# --- prompt text -----------------------------------------------------------------
|
|
91
98
|
|
|
92
|
-
def _rank(threshold) ->
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
value
|
|
99
|
+
def _rank(threshold) -> int:
|
|
100
|
+
"""The threshold's index (P0 = 0): None or "" is the default, `none` is P3."""
|
|
101
|
+
value = str(threshold if threshold is not None else '').strip().upper() or DEFAULT_THRESHOLD
|
|
102
|
+
if value == 'NONE':
|
|
103
|
+
value = SEVERITIES[-1]
|
|
96
104
|
if value not in SEVERITIES:
|
|
97
|
-
raise ValueError('threshold must be one of ' + ', '.join(SEVERITIES))
|
|
105
|
+
raise ValueError('threshold must be one of ' + ', '.join(SEVERITIES) + ' or none')
|
|
98
106
|
return int(value[1])
|
|
99
107
|
|
|
100
108
|
|
|
@@ -114,6 +122,14 @@ _HEAD = {
|
|
|
114
122
|
'behaviour versus what was asked. Also say if it solved a different problem than the',
|
|
115
123
|
"one stated, or changed files outside the goal's scope.",
|
|
116
124
|
] + _NO_TRUST,
|
|
125
|
+
'sweep': [
|
|
126
|
+
'This is a finding sweep. The implementer was asked to fix only the review findings listed in',
|
|
127
|
+
'the task above (S1, S2, ...), which reviews of earlier tasks in this run left open. Your review',
|
|
128
|
+
'is narrow: for each listed finding, decide from the diff below whether it is fixed, or no longer',
|
|
129
|
+
'applies to the code; and check that the change breaks nothing it touches. Do not review code the',
|
|
130
|
+
'diff did not change, and do not report other problems you notice there: they are not this',
|
|
131
|
+
"task's work.",
|
|
132
|
+
] + _NO_TRUST,
|
|
117
133
|
'final': [
|
|
118
134
|
'This is the final, whole-run review. The diff below is the COMBINED result of several',
|
|
119
135
|
'tasks that were implemented independently and each reviewed on its own slice only.',
|
|
@@ -135,6 +151,18 @@ _FINDINGS = [
|
|
|
135
151
|
]
|
|
136
152
|
_SOLO_EXTRA = ['If the diff is correct, say so plainly rather than inventing something to report.']
|
|
137
153
|
|
|
154
|
+
# The reviewer's own verification, bounded to the change (#89): one reviewer re-ran a whole
|
|
155
|
+
# repository suite to review a one-file patch. The evidence is what the caller prints between
|
|
156
|
+
# the head and the tail (fail-first, pre-review tests).
|
|
157
|
+
_VERIFY = [
|
|
158
|
+
'Verify within the change: run only the tests that touch the changed code (the tests the',
|
|
159
|
+
'diff adds or edits, and the tests of the modules it changes), never the whole suite, and',
|
|
160
|
+
'spend at most about %d minutes running tests. Use any test evidence forge gives you above' % QA_TEST_MINUTES,
|
|
161
|
+
'before running a test yourself. When the targeted tests would take longer, or the change',
|
|
162
|
+
'touches shared infrastructure (a test helper, a build file, a lockfile), say so instead of',
|
|
163
|
+
'running everything.',
|
|
164
|
+
]
|
|
165
|
+
|
|
138
166
|
_SEVERITY = [
|
|
139
167
|
'Label every finding with its severity at the start of its own bullet, in exactly this form:',
|
|
140
168
|
' - [P1][CONFIRMED] path/file.py:123 — what breaks (trigger input)',
|
|
@@ -146,13 +174,28 @@ _SEVERITY = [
|
|
|
146
174
|
' P3 minor: cosmetic, naming, nit-level correctness',
|
|
147
175
|
]
|
|
148
176
|
|
|
149
|
-
|
|
177
|
+
_SWEEP_FINDINGS = [
|
|
178
|
+
'Report findings only — do not edit any file. A finding here is a regression the change',
|
|
179
|
+
'introduced: give its file and line, what breaks, and a concrete input that triggers it. Mark it',
|
|
180
|
+
'CONFIRMED if you traced it in the code, or PLAUSIBLE if you could not fully verify it.',
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
_SWEEP_STATUS = [
|
|
184
|
+
'Then give one line for every listed finding, in exactly this form (its own S number):',
|
|
185
|
+
' - S<n>: FIXED',
|
|
186
|
+
' - S<n>: NOT FIXED — what is still wrong',
|
|
187
|
+
'FIXED means the diff removes the problem, or the code it pointed at no longer has it. Do not',
|
|
188
|
+
'repeat a NOT FIXED finding as a finding bullet; its line is enough.',
|
|
189
|
+
]
|
|
150
190
|
|
|
151
|
-
|
|
152
|
-
|
|
191
|
+
_CHECKED = [
|
|
192
|
+
'forge checks the verdict against your findings: a PASS that lists a blocking CONFIRMED',
|
|
193
|
+
'finding is turned into FAIL. List only problems still present in the code under review;',
|
|
194
|
+
'never list a fixed problem as a finding.',
|
|
195
|
+
]
|
|
153
196
|
|
|
154
197
|
|
|
155
|
-
def _threshold_clause(rank: int) -> list:
|
|
198
|
+
def _threshold_clause(rank: int, kind: str = 'task') -> list:
|
|
156
199
|
name = SEVERITIES[rank]
|
|
157
200
|
blocking = ', '.join(SEVERITIES[:rank + 1])
|
|
158
201
|
if rank == len(SEVERITIES) - 1:
|
|
@@ -164,6 +207,8 @@ def _threshold_clause(rank: int) -> list:
|
|
|
164
207
|
'CONFIRMED finding at a lower severity (%s) is recorded as a known issue and does' % tolerated,
|
|
165
208
|
'not by itself justify FAIL. Give FAIL if and only if at least one CONFIRMED',
|
|
166
209
|
'finding is blocking.']
|
|
210
|
+
if kind == 'sweep': # the verdict lines below say when a sweep fails
|
|
211
|
+
lines[-2:] = ['not by itself justify FAIL.']
|
|
167
212
|
return lines + ['A CONFIRMED finding without a severity tag counts as blocking.']
|
|
168
213
|
|
|
169
214
|
|
|
@@ -176,11 +221,15 @@ def qa_text(part: str, kind: str = 'task', threshold=None) -> str:
|
|
|
176
221
|
return '\n'.join(_HEAD[kind]) + '\n'
|
|
177
222
|
if part != 'tail':
|
|
178
223
|
raise ValueError('part must be head or tail')
|
|
179
|
-
lines = list(_FINDINGS) + (_SOLO_EXTRA if kind == 'solo' else [])
|
|
224
|
+
lines = list(_SWEEP_FINDINGS if kind == 'sweep' else _FINDINGS) + (_SOLO_EXTRA if kind == 'solo' else [])
|
|
225
|
+
lines += [''] + _VERIFY
|
|
180
226
|
lines += [''] + _SEVERITY
|
|
181
|
-
lines += [''] + (
|
|
182
|
-
if
|
|
183
|
-
|
|
227
|
+
lines += [''] + _threshold_clause(rank, kind) + _CHECKED
|
|
228
|
+
if kind == 'sweep':
|
|
229
|
+
lines += [''] + _SWEEP_STATUS
|
|
230
|
+
where = ' at the blocking threshold (%s or worse)' % SEVERITIES[rank]
|
|
231
|
+
verdicts = [' FORGE_VERDICT: PASS — at least one listed finding is FIXED, and no CONFIRMED regression%s' % where,
|
|
232
|
+
' FORGE_VERDICT: FAIL — no listed finding is FIXED, or a CONFIRMED regression%s' % where]
|
|
184
233
|
else:
|
|
185
234
|
where = '%s or worse' % SEVERITIES[rank]
|
|
186
235
|
verdicts = [' FORGE_VERDICT: PASS — no CONFIRMED finding at the blocking threshold (%s)' % where,
|
|
@@ -194,15 +243,24 @@ _DWARF = [
|
|
|
194
243
|
'- Do not run git commit, checkout, switch, reset, stash or rebase. The harness captures',
|
|
195
244
|
' the working tree itself; a self-commit makes the change set ambiguous.',
|
|
196
245
|
'- Do not start background processes, and leave nothing running when you finish.',
|
|
246
|
+
'- Verify within your change: run the tests the change affects (the task\'s own tests and the',
|
|
247
|
+
' tests of the modules you changed). Do not run the whole suite or repo-wide lint, format or',
|
|
248
|
+
' type checks unless the task asks for them.',
|
|
197
249
|
'- Finish every measurement and test run BEFORE your last message and report its actual',
|
|
198
250
|
' result. If you could not run something, say so explicitly instead of claiming it passed.',
|
|
199
251
|
'- State precisely which verification commands you ran and what each one returned.',
|
|
200
252
|
]
|
|
201
253
|
|
|
202
254
|
|
|
203
|
-
|
|
255
|
+
_DWARF_PRE_REVIEW = [
|
|
256
|
+
'- forge runs the tests this change affects before the review, and a failure comes back to',
|
|
257
|
+
' you instead of a review: you need not repeat them exhaustively, but report what you ran.',
|
|
258
|
+
]
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def dwarf_text(pre_review: bool = False) -> str:
|
|
204
262
|
"""The implementer rules block, newline-terminated."""
|
|
205
|
-
return '\n'.join(_DWARF) + '\n'
|
|
263
|
+
return '\n'.join(_DWARF + (_DWARF_PRE_REVIEW if pre_review else [])) + '\n'
|
|
206
264
|
|
|
207
265
|
|
|
208
266
|
# --- parsing ---------------------------------------------------------------------
|
|
@@ -233,7 +291,7 @@ def _contract_flat() -> str:
|
|
|
233
291
|
parts = [dwarf_text()]
|
|
234
292
|
for kind in KINDS:
|
|
235
293
|
for part in ('head', 'tail'):
|
|
236
|
-
for threshold in
|
|
294
|
+
for threshold in SEVERITIES: # None and `none` render one of these
|
|
237
295
|
parts.append(qa_text(part, kind, threshold))
|
|
238
296
|
return _collapse(' '.join(parts))
|
|
239
297
|
|
|
@@ -323,7 +381,8 @@ def parse_findings(text: str) -> list:
|
|
|
323
381
|
# --- the gate --------------------------------------------------------------------
|
|
324
382
|
|
|
325
383
|
def gate(verdict: str, text: str, threshold=None) -> GateResult:
|
|
326
|
-
"""
|
|
384
|
+
"""Check a QA verdict against its findings: a FAIL may be accepted as
|
|
385
|
+
PASS-with-known-issues, a PASS that lists a blocking finding fails."""
|
|
327
386
|
rank = _rank(threshold)
|
|
328
387
|
findings = parse_findings(text)
|
|
329
388
|
confirmed = [f for f in findings if f.status == 'CONFIRMED']
|
|
@@ -331,11 +390,17 @@ def gate(verdict: str, text: str, threshold=None) -> GateResult:
|
|
|
331
390
|
unlabelled = (len(confirmed) - len(labelled)
|
|
332
391
|
+ sum(1 for f in findings if f.status == 'UNSTATED'))
|
|
333
392
|
worst = 'P%d' % min(f.severity for f in labelled) if labelled else '-'
|
|
334
|
-
below = tuple(f for f in labelled if
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
393
|
+
below = tuple(f for f in labelled if f.severity > rank)
|
|
394
|
+
blocking = any(f.status in ('CONFIRMED', 'UNSTATED')
|
|
395
|
+
and (f.severity is None or f.severity <= rank) for f in findings)
|
|
396
|
+
if verdict == 'PASS' and blocking:
|
|
397
|
+
decision = 'fail'
|
|
398
|
+
elif (verdict == 'FAIL' and confirmed and unlabelled == 0
|
|
399
|
+
and len(below) == len(confirmed)):
|
|
400
|
+
decision = 'accept'
|
|
401
|
+
else:
|
|
402
|
+
decision = 'keep'
|
|
403
|
+
return GateResult(decision, worst, len(confirmed), unlabelled, len(below), below)
|
|
339
404
|
|
|
340
405
|
|
|
341
406
|
def known_issues_text(threshold, tolerated) -> str:
|
|
@@ -351,13 +416,12 @@ def known_issues_text(threshold, tolerated) -> str:
|
|
|
351
416
|
|
|
352
417
|
# --- command line ----------------------------------------------------------------
|
|
353
418
|
|
|
354
|
-
def _threshold_arg(value: str):
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return value
|
|
419
|
+
def _threshold_arg(value: str) -> str:
|
|
420
|
+
try:
|
|
421
|
+
return SEVERITIES[_rank(value)]
|
|
422
|
+
except ValueError:
|
|
423
|
+
raise argparse.ArgumentTypeError(
|
|
424
|
+
'invalid threshold %r (choose P0, P1, P2, P3 or none)' % value.strip()) from None
|
|
361
425
|
|
|
362
426
|
|
|
363
427
|
def _emit(text: str) -> None:
|
|
@@ -371,23 +435,28 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
371
435
|
prog='forge-contract.py', formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
372
436
|
description='Shared QA contract, implementer rules and severity gate for forge.',
|
|
373
437
|
epilog='threshold: the LEAST severe level that still blocks. P2 = P0, P1 and P2 '
|
|
374
|
-
'block, only P3 is tolerated; P0 = only P0 blocks; P3 = everything blocks
|
|
375
|
-
'Unset (or empty) =
|
|
438
|
+
'block, only P3 is tolerated; P0 = only P0 blocks; P3 = everything blocks; '
|
|
439
|
+
'none = P3. Unset (or empty) = the default, %s. The gate turns a FAIL whose '
|
|
440
|
+
'findings are all tolerated into accept, and a PASS that lists a blocking '
|
|
441
|
+
'finding into fail.' % DEFAULT_THRESHOLD)
|
|
376
442
|
sub = parser.add_subparsers(dest='command', required=True)
|
|
377
443
|
qa = sub.add_parser('qa', help='print one piece of the QA prompt')
|
|
378
444
|
qa.add_argument('--part', required=True, choices=('head', 'tail'),
|
|
379
445
|
help='head = review preamble, tail = findings format + verdict contract')
|
|
380
446
|
qa.add_argument('--kind', choices=KINDS, default='task',
|
|
381
|
-
help='task (default), final (whole-run review)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
447
|
+
help='task (default), final (whole-run review), solo (solo wording) or sweep (a finding '
|
|
448
|
+
'sweep task: per-finding FIXED lines, regressions only)')
|
|
449
|
+
qa.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
|
|
450
|
+
help='least severe level that still blocks; none = P3 (default: %s)' % DEFAULT_THRESHOLD)
|
|
451
|
+
dwarf = sub.add_parser('dwarf', help='print the implementer rules block')
|
|
452
|
+
dwarf.add_argument('--pre-review', action='store_true', help='forge runs the affected tests before the review')
|
|
385
453
|
gate_parser = sub.add_parser(
|
|
386
|
-
'gate', help='print: decision, worst_confirmed, n_confirmed, n_unlabelled, n_below')
|
|
454
|
+
'gate', help='print: decision (accept|fail|keep), worst_confirmed, n_confirmed, n_unlabelled, n_below')
|
|
387
455
|
gate_parser.add_argument('--verdict', required=True, choices=('PASS', 'FAIL', 'UNKNOWN'))
|
|
388
456
|
gate_parser.add_argument('--qa-last', required=True, metavar='FILE', help="the QA reply")
|
|
389
|
-
gate_parser.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3',
|
|
390
|
-
help='least severe level that still blocks (default:
|
|
457
|
+
gate_parser.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
|
|
458
|
+
help='least severe level that still blocks; none = P3 (default: %s)'
|
|
459
|
+
% DEFAULT_THRESHOLD)
|
|
391
460
|
gate_parser.add_argument('--known-issues', metavar='OUT', default=None,
|
|
392
461
|
help='write tolerated findings here when there are any')
|
|
393
462
|
return parser
|
|
@@ -399,7 +468,7 @@ def main(argv=None) -> int:
|
|
|
399
468
|
_emit(qa_text(args.part, args.kind, args.threshold))
|
|
400
469
|
return 0
|
|
401
470
|
if args.command == 'dwarf':
|
|
402
|
-
_emit(dwarf_text())
|
|
471
|
+
_emit(dwarf_text(args.pre_review))
|
|
403
472
|
return 0
|
|
404
473
|
try:
|
|
405
474
|
with open(args.qa_last, 'rb') as handle:
|
package/scripts/forge-control.py
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
show <plan> [--json] every control, per-task overrides, pins and the change log
|
|
5
5
|
set <plan> <key> <value> [--task ID] qa-threshold, timeout, escalate-after, escalate-effort,
|
|
6
6
|
verify-retries, retry-budget, infra-retries, infra-backoff
|
|
7
|
-
(none drops it), max-parallel (1-64)
|
|
7
|
+
(none drops it), max-parallel (1-64), pre-review-tests
|
|
8
|
+
(on/off), pre-review-parallel (1-64)
|
|
8
9
|
pin <plan> <task> <spec> the model the task's next FULL implementer retry uses
|
|
9
10
|
unpin <plan> <task>
|
|
10
11
|
retry <plan> <task> [--dwarf SPEC] queue a retry of a stopped or failed task into the live run
|
|
@@ -18,8 +19,8 @@
|
|
|
18
19
|
them like SIGTERM
|
|
19
20
|
|
|
20
21
|
`show` reports escalate-after and verify-retries at their defaults (3 and 1) when unset,
|
|
21
|
-
escalate-effort as on or off (off when the file is absent),
|
|
22
|
-
scheduler is live.
|
|
22
|
+
escalate-effort and pre-review-tests as on or off (off when the file is absent), pre-review-parallel
|
|
23
|
+
at its default (2) when unset, and the two budgets only while a scheduler is live.
|
|
23
24
|
|
|
24
25
|
Every change is validated, written atomically under the plan's control lock (`control.lock`),
|
|
25
26
|
appended to `control.log` and recorded as a dataset `control` event. This is the only writer of
|
|
@@ -63,6 +64,7 @@ LOG_TAIL = 256 * 1024
|
|
|
63
64
|
READ_MAX = 8 * 1024 * 1024
|
|
64
65
|
DEFAULT_ESCALATE_AFTER = 3 # forge-route.py
|
|
65
66
|
DEFAULT_VERIFY_RETRIES = 1 # forge-parallel.sh
|
|
67
|
+
DEFAULT_PRE_REVIEW_PARALLEL = 2 # forge-artifact.sh forge_pre_review
|
|
66
68
|
LEVELS = ('P0', 'P1', 'P2', 'P3')
|
|
67
69
|
STOP_MARKERS = ('escalation.stop', 'split.suggested', 'escalation.next')
|
|
68
70
|
DIR_FLAGS = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW | os.O_CLOEXEC
|
|
@@ -372,6 +374,25 @@ def level(text, task_level=False):
|
|
|
372
374
|
return text if text in LEVELS or (task_level and text == 'none') else None
|
|
373
375
|
|
|
374
376
|
|
|
377
|
+
_CONTRACT = None
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def run_threshold(text):
|
|
381
|
+
"""(effective level, 'set' | 'default') of the plan file's text; `none` means P3."""
|
|
382
|
+
global _CONTRACT
|
|
383
|
+
if _CONTRACT is None:
|
|
384
|
+
import importlib.util
|
|
385
|
+
spec = importlib.util.spec_from_file_location('forge_contract', os.path.join(SKILL, 'scripts', 'forge-contract.py'))
|
|
386
|
+
_CONTRACT = importlib.util.module_from_spec(spec)
|
|
387
|
+
spec.loader.exec_module(_CONTRACT)
|
|
388
|
+
value = (text.splitlines()[0].replace(' ', '').upper() if text else '')
|
|
389
|
+
if value == 'NONE':
|
|
390
|
+
return LEVELS[-1], 'set'
|
|
391
|
+
if value in LEVELS:
|
|
392
|
+
return value, 'set'
|
|
393
|
+
return _CONTRACT.DEFAULT_THRESHOLD, 'default'
|
|
394
|
+
|
|
395
|
+
|
|
375
396
|
def nullable(value):
|
|
376
397
|
return None if value in (None, '', '-', 'UNASSIGNED') else value
|
|
377
398
|
|
|
@@ -399,7 +420,8 @@ def show(plan, rows):
|
|
|
399
420
|
def budget(rel):
|
|
400
421
|
return number(get(rel)) if live else None
|
|
401
422
|
|
|
402
|
-
|
|
423
|
+
threshold, source = run_threshold(get('qa_threshold'))
|
|
424
|
+
run = dict(qa_threshold=threshold, qa_threshold_source=source, timeout=number(get('timeout')),
|
|
403
425
|
escalate_after=number(get('escalate_after')),
|
|
404
426
|
escalate_effort='on' if get('escalate_effort') == 'on' else 'off',
|
|
405
427
|
verify_retries=number(get('verify_retries')),
|
|
@@ -415,6 +437,10 @@ def show(plan, rows):
|
|
|
415
437
|
run['escalate_after'] = DEFAULT_ESCALATE_AFTER
|
|
416
438
|
if run['verify_retries'] is None:
|
|
417
439
|
run['verify_retries'] = DEFAULT_VERIFY_RETRIES
|
|
440
|
+
# Pre-review tests (#85): the plan file's presence turns them on (`plan --pre-review-tests`).
|
|
441
|
+
run['pre_review_tests'] = 'on' if has(plan, 'pre_review_tests') else 'off'
|
|
442
|
+
slots = number(get('pre_review_parallel'))
|
|
443
|
+
run['pre_review_parallel'] = slots if slots and slots <= 64 else DEFAULT_PRE_REVIEW_PARALLEL
|
|
418
444
|
tasks = {}
|
|
419
445
|
for row in rows:
|
|
420
446
|
task = row[0]
|
|
@@ -445,9 +471,10 @@ def show(plan, rows):
|
|
|
445
471
|
# ------------------------------------------------------------------------------------ changes
|
|
446
472
|
|
|
447
473
|
def _qa(value, task):
|
|
448
|
-
if value in LEVELS or value == 'none' or (task and value == 'inherit'):
|
|
474
|
+
if value in LEVELS or value == 'none' or (task and value == 'inherit') or (not task and value == 'default'):
|
|
449
475
|
return value
|
|
450
|
-
raise Invalid('qa-threshold needs P0, P1, P2, P3 or none
|
|
476
|
+
raise Invalid('qa-threshold needs P0, P1, P2, P3 or none (none means P3)'
|
|
477
|
+
+ (' (or inherit to drop the override)' if task else ', or default to drop the file'))
|
|
451
478
|
|
|
452
479
|
|
|
453
480
|
def _int(value, task):
|
|
@@ -511,6 +538,8 @@ KEYS = {
|
|
|
511
538
|
'infra-retries': ('plan', _int, 'infra_budget', True, NEXT_DECISION),
|
|
512
539
|
'infra-backoff': ('plan', _backoff, 'infra_backoff', False, NEXT_INFRA_WAIT),
|
|
513
540
|
'max-parallel': ('plan', _parallel, 'max_parallel', True, NEXT_DISPATCH),
|
|
541
|
+
'pre-review-tests': ('plan', _onoff, 'pre_review_tests', False, NEXT_ATTEMPT),
|
|
542
|
+
'pre-review-parallel': ('plan', _parallel, 'pre_review_parallel', False, NEXT_ATTEMPT),
|
|
514
543
|
}
|
|
515
544
|
|
|
516
545
|
|
|
@@ -573,7 +602,8 @@ def cmd_set(args):
|
|
|
573
602
|
except Invalid as error:
|
|
574
603
|
raise Invalid(f'{args.key}: {error}')
|
|
575
604
|
rel = f'tasks/{task}/{name}' if task else name
|
|
576
|
-
drop = value
|
|
605
|
+
drop = (value in ('inherit', 'default') or (args.key in ('escalate-effort', 'pre-review-tests') and value == 'off')
|
|
606
|
+
or (args.key == 'infra-backoff' and value == 'none'))
|
|
577
607
|
# Plan-wide stop markers go when the policy that wrote them changes: the policy turned off
|
|
578
608
|
# (escalate-after 0), or the effort step turned on, which may yet have a move for them.
|
|
579
609
|
wide = (args.key == 'escalate-after' and value == '0') or (args.key == 'escalate-effort' and value == 'on')
|
|
@@ -789,7 +819,8 @@ def cmd_show(args):
|
|
|
789
819
|
run = controls['run']
|
|
790
820
|
print(f"{plan} run {cell(controls['run_id'])} live {'yes' if controls['live'] else 'no'}"
|
|
791
821
|
f" fractal {'yes' if controls['fractal'] else 'no'}")
|
|
792
|
-
print(' ' + ' '.join(f"{k.replace('_', '-')} {cell(v)}"
|
|
822
|
+
print(' ' + ' '.join(f"{k.replace('_', '-')} {cell(v)}" + (' (default)' if k == 'qa_threshold' and run['qa_threshold_source'] == 'default' else '')
|
|
823
|
+
for k, v in run.items() if k not in ('infra_paused', 'qa_threshold_source')))
|
|
793
824
|
for p in run['infra_paused'] or []:
|
|
794
825
|
tasks = ','.join(t for t in (p['tasks'] or []) if isinstance(t, str)) or '-'
|
|
795
826
|
if p['exhausted']:
|
|
@@ -836,7 +867,7 @@ def parser():
|
|
|
836
867
|
p.set_defaults(func=cmd_show)
|
|
837
868
|
p = sub.add_parser('set', help='change a control', description='Keys: ' + ', '.join(KEYS) + '. '
|
|
838
869
|
'retry-budget, infra-retries and max-parallel change only while a run is live. '
|
|
839
|
-
'qa-threshold and retry-budget also take --task (value inherit drops the override).')
|
|
870
|
+
'qa-threshold and retry-budget also take --task (value inherit drops the override; at run level, default drops the file and none means P3).')
|
|
840
871
|
common(p)
|
|
841
872
|
p.add_argument('key', choices=list(KEYS))
|
|
842
873
|
p.add_argument('value')
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
# [--native-review [--review-base <ref>]]
|
|
12
12
|
# forge-dispatch.sh qa <spec> ... --continue-session <id> continue that reviewer session
|
|
13
13
|
# (claude, openclaude, codex; custom prompt only)
|
|
14
|
+
# forge-dispatch.sh dwarf <spec> ... --continue-session <id> continue that implementer session
|
|
15
|
+
# (claude, openclaude)
|
|
14
16
|
# any role: [--no-ripwire] [--ripwire-query-file <requirements>]
|
|
15
17
|
# any role: [--timeout <seconds>] 0 disables the watchdog
|
|
16
18
|
# forge-dispatch.sh efforts --spec <spec>
|
|
@@ -278,8 +280,10 @@ if [ "$NATIVE_REVIEW" = 1 ] && { [ "$ROLE" != qa ] || [ "$HARNESS" != codex ]; }
|
|
|
278
280
|
die "--native-review requires QA on codex"
|
|
279
281
|
fi
|
|
280
282
|
if [ "$CONTINUE_GIVEN" = 1 ]; then
|
|
281
|
-
|
|
282
|
-
|
|
283
|
+
# codex's `exec resume` takes no sandbox flag, so only a read-only reviewer continues there:
|
|
284
|
+
# an implementer's write access would rest on a config override nothing verifies.
|
|
285
|
+
[ "$NATIVE_REVIEW" != 1 ] && case "$ROLE:$HARNESS" in qa:codex|qa:claude|qa:openclaude|dwarf:claude|dwarf:openclaude) true ;; *) false ;; esac \
|
|
286
|
+
|| die "--continue-session needs the qa role on codex, claude or openclaude, or the dwarf role on claude or openclaude, without --native-review"
|
|
283
287
|
case "$CONTINUE_ID" in ''|*[!A-Za-z0-9-]*) die "--continue-session id must be letters, digits and '-' only" ;; esac
|
|
284
288
|
[ "${#CONTINUE_ID}" -ge 8 ] && [ "${#CONTINUE_ID}" -le 128 ] || die "--continue-session id must be 8 to 128 characters"
|
|
285
289
|
fi
|
|
@@ -307,11 +311,13 @@ if [ "$NO_EFFORT" = 1 ]; then
|
|
|
307
311
|
EFFORT=""
|
|
308
312
|
else
|
|
309
313
|
if [ -z "$EFFORT" ]; then
|
|
310
|
-
# Build at medium, review high: a reviewer that thinks less than the
|
|
311
|
-
# implementer tends to rubber-stamp, which defeats the point of a second model
|
|
312
|
-
#
|
|
313
|
-
#
|
|
314
|
-
|
|
314
|
+
# Build at medium, review at high: a reviewer that thinks less than the
|
|
315
|
+
# implementer tends to rubber-stamp, which defeats the point of a second model;
|
|
316
|
+
# xhigh reviews cost about twice as much for the same verdicts (#89). Planning is
|
|
317
|
+
# the stage where thinking pays for itself most cheaply — a bad plan is executed
|
|
318
|
+
# at full cost by every dwarf downstream of it. forge-parallel.sh's approval
|
|
319
|
+
# table names the QA default (render_table).
|
|
320
|
+
case "$ROLE" in dwarf) EFFORT="medium" ;; qa) EFFORT="high" ;; planner) EFFORT="xhigh" ;; esac
|
|
315
321
|
DEFAULTED=1
|
|
316
322
|
[ -n "$LADDER" ] || EFFORT="" # opencode: no ladder, let the provider choose
|
|
317
323
|
else
|
|
@@ -381,7 +387,7 @@ write_continue() { :; } # redefined below once there is an attempt to archive
|
|
|
381
387
|
ATTEMPT=""
|
|
382
388
|
if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
|
|
383
389
|
ATTEMPT="$(python3 "$RUNTIME" begin "$RUN_DIR" "$ROLE")" || exit 3
|
|
384
|
-
rm -f "$RUN_DIR/$ROLE.last" "$RUN_DIR/$ROLE.log" "$RUN_DIR/$ROLE.resolved" "$RUN_DIR/$ROLE.cmd" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.session" "$RUN_DIR/$ROLE.continue" "$RUN_DIR/$ROLE.harness"
|
|
390
|
+
rm -f "$RUN_DIR/$ROLE.last" "$RUN_DIR/$ROLE.log" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.resolved" "$RUN_DIR/$ROLE.cmd" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.session" "$RUN_DIR/$ROLE.continue" "$RUN_DIR/$ROLE.harness"
|
|
385
391
|
trap 'exit 143' TERM
|
|
386
392
|
trap 'exit 130' INT
|
|
387
393
|
# GUARD_ON is 1 only when the harness was started in its own process group (see the
|
|
@@ -398,6 +404,7 @@ if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
|
|
|
398
404
|
python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" >/dev/null 2>&1
|
|
399
405
|
fi
|
|
400
406
|
if [ -n "${wpid:-}" ]; then pkill -P "$wpid" 2>/dev/null; kill "$wpid" 2>/dev/null; fi
|
|
407
|
+
[ -z "${cpid:-}" ] || kill "$cpid" 2>/dev/null
|
|
401
408
|
rm -f "$RUN_DIR/$ROLE.harness"
|
|
402
409
|
}
|
|
403
410
|
# What the EXIT trap's `finish` archives. Pessimistic until an outcome is known, so every
|
|
@@ -458,15 +465,25 @@ if [ -n "$ATTEMPT" ]; then
|
|
|
458
465
|
--prompt "$PROMPT_FILE" --query "$RIPWIRE_QUERY" --baseline "$REVIEW_BASE" \
|
|
459
466
|
--artifacts "$ATTEMPT" --native "$NATIVE_REVIEW" || note "Ripwire preparation failed; continuing"
|
|
460
467
|
fi
|
|
461
|
-
# A continued
|
|
462
|
-
# records what was sent, so the preamble goes into the file itself.
|
|
468
|
+
# A continued session remembers the earlier round, including its instructions. $ROLE.prompt
|
|
469
|
+
# records what was sent, so the preamble goes into the file itself. A continued implementer's
|
|
470
|
+
# work is exactly as it left it (forge-parallel.sh continues only then), so it need not re-read
|
|
471
|
+
# it; a continued reviewer is looking at changed work.
|
|
463
472
|
if [ -n "$CONTINUE_ID" ]; then
|
|
464
473
|
continued_prompt="$(mktemp "$RUN_DIR/.prompt.XXXXXX")" || die "cannot create continued prompt"
|
|
465
474
|
{
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
475
|
+
if [ "$ROLE" = dwarf ]; then
|
|
476
|
+
printf 'This continues your earlier work on this task, which has been reviewed since. Your\n'
|
|
477
|
+
printf 'working directory is %s; your changes are there as you left them,\n' "$REPO"
|
|
478
|
+
printf 'committed on the task branch, so you need not read them again. Work this attempt\n'
|
|
479
|
+
printf "exactly as instructed below; where it differs from earlier instructions, this attempt's\n"
|
|
480
|
+
printf 'instructions win.\n\n'
|
|
481
|
+
else
|
|
482
|
+
printf 'This continues your earlier review of this work. The work has changed since you last\n'
|
|
483
|
+
printf 'looked. Your working directory is now %s. Re-read files rather than relying on what\n' "$REPO"
|
|
484
|
+
printf 'you read before. Review this round exactly as instructed below; where it differs from\n'
|
|
485
|
+
printf "earlier instructions (a threshold, for example), this round's instructions win.\n\n"
|
|
486
|
+
fi
|
|
470
487
|
cat "$PROMPT_FILE"
|
|
471
488
|
} > "$continued_prompt" && mv "$continued_prompt" "$RUN_DIR/$ROLE.prompt" || { rm -f "$continued_prompt"; die "cannot install continued prompt"; }
|
|
472
489
|
fi
|
|
@@ -726,7 +743,7 @@ fi
|
|
|
726
743
|
# when a stale $LAST is already there. That is harmless when each run gets a fresh
|
|
727
744
|
# run-dir, and silently wrong for `forge-parallel.sh retry`, which reuses the task
|
|
728
745
|
# directory — it would read the first attempt's result and never notice.
|
|
729
|
-
rm -f "$LAST" "$LOG" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.harness"
|
|
746
|
+
rm -f "$LAST" "$LOG" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.clock.stop" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.harness"
|
|
730
747
|
python3 "$RUNTIME" phase "$ATTEMPT" model
|
|
731
748
|
t0="$(date +%s)"
|
|
732
749
|
# Process-group guard. A dwarf that starts `npm test &` and ends its turn leaves that
|
|
@@ -748,6 +765,13 @@ else
|
|
|
748
765
|
( cd "$REPO" && exec "${RUNCMD[@]}" </dev/null ) > "$LOG" 2>&1 &
|
|
749
766
|
fi
|
|
750
767
|
hpid=$!
|
|
768
|
+
# Log clock: when the log grew, so forge-ui can time the commands of a harness whose events
|
|
769
|
+
# carry no time (codex, grok). Advisory and off with FORGE_LOG_CLOCK=off; it ends on its own
|
|
770
|
+
# if this dispatch dies first.
|
|
771
|
+
cpid=""
|
|
772
|
+
case "${FORGE_LOG_CLOCK:-on}" in off|OFF|Off|0|no|false) ;; *)
|
|
773
|
+
[ -z "$ATTEMPT" ] || { python3 "$RUNTIME" clock "$LOG" "$RUN_DIR/$ROLE.clock" </dev/null >/dev/null 2>&1 & cpid=$!; } ;;
|
|
774
|
+
esac
|
|
751
775
|
# The harness leads its own session, so a scheduler's signal to this dispatch's group never
|
|
752
776
|
# reaches it; only the EXIT trap below does. Record it for the scheduler's backstop
|
|
753
777
|
# (forge-guard.py stop) in case this dispatch dies before the trap finishes. The start time
|
|
@@ -786,6 +810,14 @@ if [ "${LIMIT:-0}" != "0" ]; then
|
|
|
786
810
|
fi
|
|
787
811
|
|
|
788
812
|
wait "$hpid"; rc=$?
|
|
813
|
+
# Its last sample is in before `finish` copies the clock into the attempt. A stop file, not a TERM:
|
|
814
|
+
# a signal could reach a sampler still starting up and kill it before its first sample (#84). When
|
|
815
|
+
# the file cannot be written (the run dir is gone, the disk is full), a TERM it is: the sampler
|
|
816
|
+
# waits for that file or for its parent, and its parent is this `wait` (#100).
|
|
817
|
+
if [ -n "$cpid" ]; then
|
|
818
|
+
{ : > "$RUN_DIR/$ROLE.clock.stop"; } 2>/dev/null || kill -TERM "$cpid" 2>/dev/null
|
|
819
|
+
wait "$cpid" 2>/dev/null; cpid=""; rm -f "$RUN_DIR/$ROLE.clock.stop"
|
|
820
|
+
fi
|
|
789
821
|
if [ -n "$wpid" ]; then
|
|
790
822
|
# The watchdog is asleep in a child of its own; kill that too or it outlives the
|
|
791
823
|
# run as an orphan holding the timer.
|
|
@@ -38,8 +38,8 @@ import sys
|
|
|
38
38
|
import tempfile
|
|
39
39
|
import time
|
|
40
40
|
|
|
41
|
-
#
|
|
42
|
-
#
|
|
41
|
+
# Two conditions: a test path, and for the files that are run, a source suffix
|
|
42
|
+
# (README.md and JSON fixtures under tests/ are carried over, never run).
|
|
43
43
|
TEST_PATH = re.compile(r'(^|/)(tests?|spec|specs|__tests__)/'
|
|
44
44
|
r'|(^|/)test_[^/]*$|_test\.[^/]+$|\.(test|spec)\.[^/]+$')
|
|
45
45
|
CODE_SUFFIXES = ('.py', '.go', '.js', '.jsx', '.ts', '.tsx', '.rb', '.rs', '.java',
|