@giamme/forge 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/SKILL.md +7 -3
- package/VERSION +1 -1
- package/docs/artifacts.md +50 -11
- package/docs/commands.md +56 -8
- package/docs/decomposed-runs.md +43 -2
- package/docs/forge-ui.md +55 -8
- package/docs/reviews.md +64 -6
- package/package.json +1 -1
- package/references/dataset.md +4 -2
- package/references/decompose.md +191 -17
- package/references/harnesses.md +13 -1
- package/references/ui.md +25 -4
- package/scripts/forge-contract.py +37 -7
- package/scripts/forge-control.py +268 -25
- package/scripts/forge-dispatch.sh +90 -3
- package/scripts/forge-guard.py +156 -15
- package/scripts/forge-issues.py +47 -3
- package/scripts/forge-lib-plans.sh +9 -3
- package/scripts/forge-lib-review.sh +24 -5
- package/scripts/forge-lib-task.sh +53 -5
- package/scripts/forge-lib-verify.sh +137 -6
- package/scripts/forge-parallel-options.sh +85 -0
- package/scripts/forge-parallel.sh +262 -31
- package/scripts/forge-ripwire.py +1 -1
- package/scripts/forge-route.py +157 -5
- package/scripts/forge-runtime.py +49 -1
- package/scripts/forge-schedule.py +735 -53
- package/scripts/forge-solo.sh +3 -1
- package/scripts/forge-sweep.py +542 -0
- package/scripts/forge-verify.py +878 -0
- package/scripts/forge_dataset/forecast.py +33 -5
- package/scripts/forge_dataset/harvest.py +10 -4
- package/scripts/forge_verify_reports.py +225 -0
- package/ui/README.md +58 -12
- package/ui/docs/api.md +277 -28
- package/ui/forge_ui/checks.py +331 -0
- package/ui/forge_ui/control.py +12 -2
- package/ui/forge_ui/export.py +25 -8
- package/ui/forge_ui/reader.py +657 -24
- package/ui/forge_ui/server.py +29 -0
- package/ui/forge_ui/static/app.js +15 -7
- package/ui/forge_ui/static/checksview.js +449 -0
- package/ui/forge_ui/static/controls.js +217 -33
- package/ui/forge_ui/static/convo.js +11 -2
- package/ui/forge_ui/static/findingsview.js +6 -4
- package/ui/forge_ui/static/gantt.js +14 -9
- package/ui/forge_ui/static/index.html +2 -0
- package/ui/forge_ui/static/panel.js +44 -1
- package/ui/forge_ui/static/runmodel.js +109 -12
- package/ui/forge_ui/static/scene3d.js +9 -5
- package/ui/forge_ui/static/style.css +113 -0
- package/ui/forge_ui/static/verifyview.js +324 -0
- package/ui/forge_ui/transcripts.py +225 -54
package/scripts/forge-guard.py
CHANGED
|
@@ -17,6 +17,19 @@
|
|
|
17
17
|
bounded ~2s, KILL, print how many were found. Never exits nonzero for an ordinary
|
|
18
18
|
outcome, and never touches its own or its caller's group.
|
|
19
19
|
|
|
20
|
+
forge-guard.py identity <pid>
|
|
21
|
+
Print the process's start time, which survives exec. Dispatch records it with the
|
|
22
|
+
harness pid right after `$!`, when that pid may still be the subshell or this helper
|
|
23
|
+
before the exec into the harness, so the command name cannot identify it.
|
|
24
|
+
|
|
25
|
+
forge-guard.py stop <record-file>
|
|
26
|
+
The backstop for a harness its dispatch could not stop. The record is
|
|
27
|
+
`<pid><TAB><identity>`. A live pid with the recorded start time gets its group
|
|
28
|
+
signalled (or itself alone, before setsid made it a leader): TERM, ~2s, KILL. A live
|
|
29
|
+
pid with another start time was reused and is left alone. A dead pid's group may
|
|
30
|
+
still hold the harness's background jobs, and cannot have been reused while they
|
|
31
|
+
live, so it is reaped. The record is removed; prints how many processes were signalled.
|
|
32
|
+
|
|
20
33
|
forge-guard.py promises <file> [--tail-bytes N]
|
|
21
34
|
Scan the tail of an implementer's final message for promises of later work ("it is
|
|
22
35
|
still running in the background", "I'll check back"). One `pattern<TAB>excerpt`
|
|
@@ -115,39 +128,153 @@ def wait_gone(pgid: int, seconds: float) -> bool:
|
|
|
115
128
|
return (not members) if members is not None else not group_exists(pgid)
|
|
116
129
|
|
|
117
130
|
|
|
118
|
-
def
|
|
119
|
-
# Never signal ourselves, the
|
|
131
|
+
def _forbidden() -> set:
|
|
132
|
+
# Never signal ourselves, the process that called us, or init.
|
|
120
133
|
forbidden = {0, 1, os.getpgrp()}
|
|
121
134
|
try:
|
|
122
135
|
forbidden.add(os.getpgid(os.getppid()))
|
|
123
136
|
except OSError:
|
|
124
137
|
pass
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
return forbidden
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _reap_group(pgid: int, orphans_file: str | None) -> int:
|
|
142
|
+
"""TERM, then KILL, whatever is alive in the group; how many were found."""
|
|
143
|
+
if pgid in _forbidden() or pgid < 0:
|
|
127
144
|
return 0
|
|
128
145
|
if not group_exists(pgid):
|
|
129
|
-
print(0)
|
|
130
146
|
return 0
|
|
131
147
|
members = list_group(pgid)
|
|
132
148
|
if members is not None and not members:
|
|
133
149
|
# Only zombies (or nothing visible) left; nothing worth reporting or killing.
|
|
134
|
-
print(0)
|
|
135
150
|
return 0
|
|
136
151
|
found = members if members is not None else [(0, '(unknown: ps unavailable; process group %d still has live members)' % pgid)]
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
if orphans_file:
|
|
153
|
+
try:
|
|
154
|
+
with open(orphans_file, 'w') as handle:
|
|
155
|
+
for pid, command in found:
|
|
156
|
+
handle.write('%s\t%s\n' % (pid or '?', ' '.join(command.split()) or '?'))
|
|
157
|
+
except OSError:
|
|
158
|
+
pass
|
|
143
159
|
for sig, wait in ((signal.SIGTERM, TERM_WAIT_S), (signal.SIGKILL, KILL_WAIT_S)):
|
|
144
160
|
try:
|
|
145
161
|
os.killpg(pgid, sig)
|
|
146
|
-
except
|
|
162
|
+
except OSError:
|
|
147
163
|
break
|
|
148
164
|
if wait_gone(pgid, wait):
|
|
149
165
|
break
|
|
150
|
-
|
|
166
|
+
return len(found)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def reap(pgid: int, orphans_file: str) -> int:
|
|
170
|
+
print(_reap_group(pgid, orphans_file))
|
|
171
|
+
return 0
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# --- identity / stop ----------------------------------------------------------
|
|
175
|
+
def _ps_field(pid: int, field: str) -> str | None:
|
|
176
|
+
"""One ps column for one pid, whitespace-normalised; None when the pid is gone or ps
|
|
177
|
+
is unavailable. LC_ALL=C keeps lstart's format the same for every caller."""
|
|
178
|
+
if pid <= 0:
|
|
179
|
+
return None
|
|
180
|
+
for ps in PS_CANDIDATES:
|
|
181
|
+
if not os.access(ps, os.X_OK):
|
|
182
|
+
continue
|
|
183
|
+
try:
|
|
184
|
+
out = subprocess.run([ps, '-p', str(pid), '-o', field + '='], stdout=subprocess.PIPE,
|
|
185
|
+
stderr=subprocess.DEVNULL, timeout=5,
|
|
186
|
+
env=dict(os.environ, LC_ALL='C')).stdout.decode(errors='replace')
|
|
187
|
+
except (OSError, subprocess.SubprocessError):
|
|
188
|
+
continue
|
|
189
|
+
return ' '.join(out.split()) or None
|
|
190
|
+
return None
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def identity(pid: int) -> str | None:
|
|
194
|
+
return _ps_field(pid, 'lstart')
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _pid_alive(pid: int) -> bool:
|
|
198
|
+
try:
|
|
199
|
+
os.kill(pid, 0)
|
|
200
|
+
except ProcessLookupError:
|
|
201
|
+
return False
|
|
202
|
+
except PermissionError:
|
|
203
|
+
return True
|
|
204
|
+
except OSError:
|
|
205
|
+
return False
|
|
206
|
+
# A zombie still answers kill(0) until its parent waits for it.
|
|
207
|
+
return not (_ps_field(pid, 'stat') or 'Z').startswith('Z')
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _wait_pid_gone(pid: int, seconds: float) -> bool:
|
|
211
|
+
deadline = time.monotonic() + seconds
|
|
212
|
+
while time.monotonic() < deadline:
|
|
213
|
+
if not _pid_alive(pid):
|
|
214
|
+
return True
|
|
215
|
+
time.sleep(0.05)
|
|
216
|
+
return not _pid_alive(pid)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _stop_live(pid: int) -> int:
|
|
220
|
+
try:
|
|
221
|
+
leader = os.getpgid(pid) == pid
|
|
222
|
+
except OSError:
|
|
223
|
+
leader = False
|
|
224
|
+
if leader:
|
|
225
|
+
if pid in _forbidden():
|
|
226
|
+
return 0
|
|
227
|
+
members = list_group(pid)
|
|
228
|
+
count = len(members) if members else 1
|
|
229
|
+
for sig, wait in ((signal.SIGTERM, TERM_WAIT_S), (signal.SIGKILL, KILL_WAIT_S)):
|
|
230
|
+
try:
|
|
231
|
+
os.killpg(pid, sig)
|
|
232
|
+
except OSError:
|
|
233
|
+
break
|
|
234
|
+
if wait_gone(pid, wait):
|
|
235
|
+
break
|
|
236
|
+
return count
|
|
237
|
+
# Recorded before setsid: the pid is still in its dispatcher's group, so only it is ours.
|
|
238
|
+
for sig, wait in ((signal.SIGTERM, TERM_WAIT_S), (signal.SIGKILL, KILL_WAIT_S)):
|
|
239
|
+
try:
|
|
240
|
+
os.kill(pid, sig)
|
|
241
|
+
except OSError:
|
|
242
|
+
break
|
|
243
|
+
if _wait_pid_gone(pid, wait):
|
|
244
|
+
break
|
|
245
|
+
return 1
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def stop(record: str) -> int:
|
|
249
|
+
try:
|
|
250
|
+
with open(record) as handle:
|
|
251
|
+
line = handle.readline()
|
|
252
|
+
except FileNotFoundError:
|
|
253
|
+
print(0)
|
|
254
|
+
return 0
|
|
255
|
+
except OSError as error:
|
|
256
|
+
print('forge-guard: cannot read %s: %s' % (record, error), file=sys.stderr)
|
|
257
|
+
print(0)
|
|
258
|
+
return 0
|
|
259
|
+
pid_text, _, recorded = line.rstrip('\n').partition('\t')
|
|
260
|
+
try:
|
|
261
|
+
pid = int(pid_text)
|
|
262
|
+
except ValueError:
|
|
263
|
+
pid = 0
|
|
264
|
+
recorded = ' '.join(recorded.split())
|
|
265
|
+
count = 0
|
|
266
|
+
if pid > 1:
|
|
267
|
+
if _pid_alive(pid):
|
|
268
|
+
# A mismatch, or no way to tell, means the pid now belongs to someone else.
|
|
269
|
+
if recorded and identity(pid) == recorded:
|
|
270
|
+
count = _stop_live(pid)
|
|
271
|
+
else:
|
|
272
|
+
count = _reap_group(pid, None)
|
|
273
|
+
try:
|
|
274
|
+
os.unlink(record)
|
|
275
|
+
except OSError:
|
|
276
|
+
pass
|
|
277
|
+
print(count)
|
|
151
278
|
return 0
|
|
152
279
|
|
|
153
280
|
|
|
@@ -229,7 +356,7 @@ def promises(path: str, tail_bytes: int = 3000) -> int:
|
|
|
229
356
|
def main(argv: list[str]) -> int:
|
|
230
357
|
if not argv:
|
|
231
358
|
print('usage: forge-guard.py ping | session -- CMD... | reap <pgid> <orphans-file> | '
|
|
232
|
-
'promises <file> [--tail-bytes N]', file=sys.stderr)
|
|
359
|
+
'identity <pid> | stop <record-file> | promises <file> [--tail-bytes N]', file=sys.stderr)
|
|
233
360
|
return 2
|
|
234
361
|
command, rest = argv[0], argv[1:]
|
|
235
362
|
try:
|
|
@@ -245,6 +372,20 @@ def main(argv: list[str]) -> int:
|
|
|
245
372
|
print('usage: forge-guard.py reap <pgid> <orphans-file>', file=sys.stderr)
|
|
246
373
|
return 2
|
|
247
374
|
return reap(int(rest[0]), rest[1])
|
|
375
|
+
if command == 'identity':
|
|
376
|
+
if len(rest) != 1:
|
|
377
|
+
print('usage: forge-guard.py identity <pid>', file=sys.stderr)
|
|
378
|
+
return 2
|
|
379
|
+
found = identity(int(rest[0]))
|
|
380
|
+
if found is None:
|
|
381
|
+
return 1
|
|
382
|
+
print(found)
|
|
383
|
+
return 0
|
|
384
|
+
if command == 'stop':
|
|
385
|
+
if len(rest) != 1:
|
|
386
|
+
print('usage: forge-guard.py stop <record-file>', file=sys.stderr)
|
|
387
|
+
return 2
|
|
388
|
+
return stop(rest[0])
|
|
248
389
|
if command == 'promises':
|
|
249
390
|
tail = 3000
|
|
250
391
|
if '--tail-bytes' in rest:
|
package/scripts/forge-issues.py
CHANGED
|
@@ -21,7 +21,11 @@ gh-proman computes, and both tools skip a finding either of them already filed,
|
|
|
21
21
|
When the gh-proman skill is configured for the repository, prefer `gh-proman findings`: it also
|
|
22
22
|
adds the issues to the team's project board with a priority. This command is the fallback.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
A finding a run's finding sweep (`run --sweep`) fixed stays listed, with `swept` = {task, finding} (null
|
|
25
|
+
otherwise), and is never drafted: the sweep task that merged and whose reviewer marked it FIXED is its record.
|
|
26
|
+
One the sweep did not fix is drafted as before.
|
|
27
|
+
|
|
28
|
+
--json lists every finding in `findings` (fp, severity, origin, plan, task, text, `filed`, `review`, `swept`, ...). --offline never
|
|
25
29
|
runs `gh` (no filed state, publication of commits judged from local refs only). --only FP[,FP] keeps those
|
|
26
30
|
fingerprints. --all-runs reads <run> as a repository (or a plan dir naming one) and collects every run in its
|
|
27
31
|
registry, the newest plan winning for a finding present in several. A caller filing an explicit selection
|
|
@@ -611,6 +615,41 @@ def fingerprint(slug, f):
|
|
|
611
615
|
return hashlib.sha1(f"{slug.lower()}|{f['file']}|{norm}".encode("utf-8")).hexdigest()[:12]
|
|
612
616
|
|
|
613
617
|
|
|
618
|
+
def finding_key(f):
|
|
619
|
+
"""A finding's fingerprint without the repository, for what is recorded before any slug is known: the
|
|
620
|
+
finding sweep (forge-sweep.py) keys its findings by it."""
|
|
621
|
+
return fingerprint("", f)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
def swept(plan_dir):
|
|
625
|
+
"""{finding_key: {task, finding}} for the findings a merged sweep task's reviewer marked FIXED."""
|
|
626
|
+
fixed = {}
|
|
627
|
+
tasks = Path(plan_dir) / "tasks"
|
|
628
|
+
if not tasks.is_dir():
|
|
629
|
+
return fixed
|
|
630
|
+
for task_dir in sorted(tasks.iterdir()):
|
|
631
|
+
if not (task_dir / "merged").exists() or not (task_dir / "sweep.outcome.json").is_file():
|
|
632
|
+
continue
|
|
633
|
+
try:
|
|
634
|
+
items = json.loads(read(task_dir / "sweep.outcome.json"))["findings"]
|
|
635
|
+
except (ValueError, KeyError, TypeError):
|
|
636
|
+
continue
|
|
637
|
+
for item in items if isinstance(items, list) else []:
|
|
638
|
+
if isinstance(item, dict) and item.get("status") == "fixed" and isinstance(item.get("key"), str):
|
|
639
|
+
fixed.setdefault(item["key"], {"task": task_dir.name, "finding": item.get("id")})
|
|
640
|
+
return fixed
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
def mark_swept(found):
|
|
644
|
+
"""Set `swept` on each finding a sweep of its own plan fixed (None otherwise)."""
|
|
645
|
+
plans = {}
|
|
646
|
+
for f in found:
|
|
647
|
+
plan_dir = f.get("plan_dir")
|
|
648
|
+
if plan_dir not in plans:
|
|
649
|
+
plans[plan_dir] = swept(plan_dir) if plan_dir else {}
|
|
650
|
+
f["swept"] = plans[plan_dir].get(finding_key(f)) if f.get("task") else None
|
|
651
|
+
|
|
652
|
+
|
|
614
653
|
def github_slug(repo_path):
|
|
615
654
|
res = run(["git", "-C", repo_path, "remote", "get-url", "origin"], check=False)
|
|
616
655
|
m = re.search(r"github\.com[:/]([^/\s]+)/([^/\s]+?)(?:\.git)?/?$", res.stdout.strip())
|
|
@@ -989,13 +1028,14 @@ def finding_entry(f, filed=None, dismissed=None):
|
|
|
989
1028
|
"plan": f["plan"], "plan_dir": f["plan_dir"], "task": f["task"], "file": f["file"],
|
|
990
1029
|
"summary": (f["text"].splitlines() or [""])[0][:160], "text": f["text"],
|
|
991
1030
|
"reviewer": f["reviewer"], "commit": f.get("commit") or "",
|
|
992
|
-
"review": f.get("review"),
|
|
1031
|
+
"review": f.get("review"), "swept": f.get("swept"),
|
|
993
1032
|
"filed": {"url": filed["url"], "state": filed["state"]} if filed else None,
|
|
994
1033
|
"dismissed": dismissed}
|
|
995
1034
|
|
|
996
1035
|
|
|
997
1036
|
def file_findings(args):
|
|
998
1037
|
meta, found, notes = collect(Path(args.run), args.include_plausible, args.all_runs)
|
|
1038
|
+
mark_swept(found)
|
|
999
1039
|
repo_path, warnings = run_repository(meta)
|
|
1000
1040
|
slug = args.repo or github_slug(repo_path)
|
|
1001
1041
|
if not slug:
|
|
@@ -1028,6 +1068,8 @@ def list_and_file(args, meta, found, notes, repo_path, slug, warnings):
|
|
|
1028
1068
|
entries.append(finding_entry(f, issue, mark))
|
|
1029
1069
|
if issue:
|
|
1030
1070
|
already.append({"finding": f["raw"], "issue": issue["url"], "state": issue["state"]})
|
|
1071
|
+
elif f.get("swept"):
|
|
1072
|
+
continue # fixed in the run by its finding sweep
|
|
1031
1073
|
elif not mark or args.include_dismissed:
|
|
1032
1074
|
todo.append(f)
|
|
1033
1075
|
notes = notes + [f"--only {fp}: no such open finding" for fp in args.only if fp not in known]
|
|
@@ -1058,7 +1100,8 @@ def list_and_file(args, meta, found, notes, repo_path, slug, warnings):
|
|
|
1058
1100
|
drafts.sort(key=lambda d: SEVERITIES.index(d["severity"]))
|
|
1059
1101
|
out = {"repo": slug, "plan": meta["plan"], "notes": notes, "warnings": warnings,
|
|
1060
1102
|
"summary": {"findings": len(seen), "already_filed": len(already),
|
|
1061
|
-
"dismissed": sum(1 for e in entries if e["dismissed"]),
|
|
1103
|
+
"dismissed": sum(1 for e in entries if e["dismissed"]),
|
|
1104
|
+
"swept": sum(1 for e in entries if e["swept"]), "drafts": len(drafts),
|
|
1062
1105
|
**{o: sum(1 for f in todo if f["origin"] == o)
|
|
1063
1106
|
for o in ("tolerated", "accepted", "review", "plausible")}},
|
|
1064
1107
|
"findings": entries, "already_filed": already, "drafts": drafts}
|
|
@@ -1103,6 +1146,7 @@ def create(slug, drafts, args):
|
|
|
1103
1146
|
def print_human(out, applied):
|
|
1104
1147
|
s = out["summary"]
|
|
1105
1148
|
dismissed = f", {s['dismissed']} dismissed" if s["dismissed"] else ""
|
|
1149
|
+
dismissed += f", {s['swept']} fixed by the run's finding sweep" if s.get("swept") else ""
|
|
1106
1150
|
print(f"{out['repo']} · run {out['plan']}: {s['findings']} finding(s), {s['already_filed']} already filed{dismissed}, "
|
|
1107
1151
|
f"{s['drafts']} draft(s) ({s['tolerated']} tolerated, {s['accepted']} accepted, "
|
|
1108
1152
|
f"{s['review']} review, {s['plausible']} plausible)")
|
|
@@ -130,7 +130,7 @@ plans_make_integration() { # plans_make_integration <repo> <branch> <commit> <wt
|
|
|
130
130
|
|
|
131
131
|
# Per-plan option files carried to a derived plan. The cost-bearing choices a user made
|
|
132
132
|
# for this plan apply to the plan made from it; `planner` does not (nothing plans again).
|
|
133
|
-
PLANS_OPTION_FILES="no_ripwire no_memory yolo_dwarf yolo_qa reviewer_session qa_threshold timeout verify_retries verify_cmd setup_cmd final_qa shadow_qa shadow_rate explore escalate_after fractal-routing.json fractal-selection.json jev-selection.json"
|
|
133
|
+
PLANS_OPTION_FILES="no_ripwire no_memory yolo_dwarf yolo_qa reviewer_session qa_threshold timeout verify_retries verify_cmd verify_parallel setup_cmd final_qa shadow_qa shadow_rate explore escalate_after fractal-routing.json fractal-selection.json jev-selection.json"
|
|
134
134
|
|
|
135
135
|
# --- accept ---------------------------------------------------------------------
|
|
136
136
|
# A reviewer's FAIL is the QA gate; overriding it is the user's call and never forge's or
|
|
@@ -524,7 +524,7 @@ Retry or accept them (or split them off into their own plan) first." 3
|
|
|
524
524
|
# and what the dataset records; readers only test that the file exists.
|
|
525
525
|
all=1; for p in "${SRC[@]}"; do [ -f "$p/reviewer_session" ] || all=0; done
|
|
526
526
|
[ "$all" = 1 ] && printf '%s\n' on > "$NEW/reviewer_session"
|
|
527
|
-
for f in qa_threshold timeout verify_retries; do
|
|
527
|
+
for f in qa_threshold timeout verify_retries verify_parallel; do
|
|
528
528
|
same=1
|
|
529
529
|
for p in "${SRC[@]}"; do
|
|
530
530
|
if [ ! -f "$p/$f" ] || ! cmp -s "$p/$f" "${SRC[0]}/$f"; then same=0; fi
|
|
@@ -541,7 +541,11 @@ Retry or accept them (or split them off into their own plan) first." 3
|
|
|
541
541
|
for p in "${SRC[@]}"; do [ -s "$p/setup_cmd" ] && { cp -p "$p/setup_cmd" "$NEW/setup_cmd"; break; }; done
|
|
542
542
|
if [ -n "$VERIFY" ]; then printf '%s' "$VERIFY" > "$NEW/verify_cmd"
|
|
543
543
|
else
|
|
544
|
-
|
|
544
|
+
# The first source that declares verification gives it: its lanes, else its command.
|
|
545
|
+
for p in "${SRC[@]}"; do
|
|
546
|
+
if verify_lanes_present "$p/verify.d"; then cp -Rp "$p/verify.d" "$NEW/verify.d"; break; fi
|
|
547
|
+
[ -s "$p/verify_cmd" ] && { cp -p "$p/verify_cmd" "$NEW/verify_cmd"; break; }
|
|
548
|
+
done
|
|
545
549
|
fi
|
|
546
550
|
for f in fractal-routing.json jev-selection.json; do
|
|
547
551
|
for p in "${SRC[@]}"; do [ -f "$p/$f" ] && { cp -p "$p/$f" "$NEW/$f"; break; }; done
|
|
@@ -743,6 +747,8 @@ except Exception:
|
|
|
743
747
|
for f in $PLANS_OPTION_FILES; do
|
|
744
748
|
[ ! -e "$PLAN/$f" ] || cp -p "$PLAN/$f" "$NEW/$f" || ok=0
|
|
745
749
|
done
|
|
750
|
+
# The plan's verification lanes travel with it, like its --verify.
|
|
751
|
+
[ ! -d "$PLAN/verify.d" ] || cp -Rp "$PLAN/verify.d" "$NEW/verify.d" || ok=0
|
|
746
752
|
for id in $(all_ids "$T"); do
|
|
747
753
|
case "$SEL" in *" $id "*) ;; *) continue ;; esac
|
|
748
754
|
plans_copy_taskdir "$PLAN/tasks/$id" "$NEW/tasks/$id" || ok=0
|
|
@@ -94,7 +94,7 @@ review_warn_unmerged() { # review_warn_unmerged <plan>
|
|
|
94
94
|
# notes what forge observed that no per-task reviewer was shown
|
|
95
95
|
review_context() { # review_context <pre|notes> <plan> <tasks.summary> <verification-dir>
|
|
96
96
|
python3 - "$1" "$2" "$3" "$4" "$REVIEW_REQ_BUDGET" <<'PY'
|
|
97
|
-
import os, re, sys
|
|
97
|
+
import json, os, re, sys
|
|
98
98
|
|
|
99
99
|
mode, plan, summary, vdir, budget = sys.argv[1:6]
|
|
100
100
|
BUDGET = int(budget)
|
|
@@ -195,13 +195,32 @@ else:
|
|
|
195
195
|
'A promise of later work means a check may never have run.')
|
|
196
196
|
ver = []
|
|
197
197
|
status = read(os.path.join(vdir, 'verification.status'))
|
|
198
|
+
lanes = None
|
|
199
|
+
try:
|
|
200
|
+
doc = json.loads(read(os.path.join(vdir, 'verification.lanes.json')) or b'null')
|
|
201
|
+
lanes = [l for l in doc.get('lanes') or [] if isinstance(l, dict) and l.get('name')]
|
|
202
|
+
except (ValueError, AttributeError):
|
|
203
|
+
pass
|
|
198
204
|
if status and status.strip():
|
|
199
205
|
ver.append('status: %s' % text(status))
|
|
200
206
|
cmd = read(os.path.join(vdir, 'verification.command'))
|
|
201
|
-
if
|
|
207
|
+
if lanes is not None:
|
|
208
|
+
# Lanes: each one's state; a flaky lane passed only on its rerun, a known lane failed
|
|
209
|
+
# only tests the project's baseline lists.
|
|
210
|
+
ver.append('lanes (each ran on its own; a failed lane was rerun alone):')
|
|
211
|
+
for l in lanes:
|
|
212
|
+
ver.append(' %s: %s' % (l['name'], l.get('state') or 'unknown'))
|
|
213
|
+
by = lambda state: [l['name'] for l in lanes if l.get('state') == state]
|
|
214
|
+
if by('fail'):
|
|
215
|
+
ver.append('failed: ' + ', '.join('lane ' + n for n in by('fail')))
|
|
216
|
+
for n in by('flaky'):
|
|
217
|
+
ver.append('FLAKY: lane %s failed once and passed on rerun, so its pass is not clean' % n)
|
|
218
|
+
for n in by('known'):
|
|
219
|
+
ver.append('known failures only: lane %s (every failing test is in its baseline)' % n)
|
|
220
|
+
elif cmd and cmd.strip():
|
|
202
221
|
ver.append('command: %s' % text(cmd))
|
|
203
222
|
flaky = read(os.path.join(vdir, 'verification.flaky'))
|
|
204
|
-
if flaky and flaky.strip():
|
|
223
|
+
if flaky and flaky.strip() and lanes is None:
|
|
205
224
|
ver.append('FLAKY: the command failed once and passed on rerun, so the pass is not clean:')
|
|
206
225
|
ver += [' ' + l for l in text(flaky).splitlines() if not l.startswith(('first_log=', 'retry_log='))]
|
|
207
226
|
cover = read(os.path.join(vdir, 'verification.coverage.txt'))
|
|
@@ -405,7 +424,7 @@ final_review() {
|
|
|
405
424
|
{ note "final review: cannot assemble the review context"; return 3; }
|
|
406
425
|
|
|
407
426
|
# At most the limit plus one byte is ever read, so an enormous change cannot fill the disk.
|
|
408
|
-
git -C "$src" diff --binary "$base" "$tip" -- . ':(exclude).forge' 2>/dev/null |
|
|
427
|
+
git -C "$src" diff --binary --irreversible-delete "$base" "$tip" -- . ':(exclude).forge' 2>/dev/null |
|
|
409
428
|
head -c $((REVIEW_DIFF_LIMIT + 1)) > "$out/combined.diff"
|
|
410
429
|
diff_n="$(wc -c < "$out/combined.diff" | tr -d ' ')"
|
|
411
430
|
if [ "$diff_n" -gt "$REVIEW_DIFF_LIMIT" ]; then inline=0; rm -f "$out/combined.diff"; fi
|
|
@@ -424,7 +443,7 @@ final_review() {
|
|
|
424
443
|
echo "There are no changes since that review: it judged this same commit."
|
|
425
444
|
else
|
|
426
445
|
echo "### Changes since that review ($(printf '%.7s' "$since")..$(printf '%.7s' "$tip"))"
|
|
427
|
-
git -C "$src" diff --binary "$since" "$tip" -- . ':(exclude).forge' 2>/dev/null |
|
|
446
|
+
git -C "$src" diff --binary --irreversible-delete "$since" "$tip" -- . ':(exclude).forge' 2>/dev/null |
|
|
428
447
|
head -c $((REVIEW_SINCE_LIMIT + 1)) > "$out/since.diff"
|
|
429
448
|
if [ "$inline" = 1 ] && [ "$(wc -c < "$out/since.diff" | tr -d ' ')" -le "$REVIEW_SINCE_LIMIT" ] &&
|
|
430
449
|
! grep -q '```diff' "$out/since.diff"; then
|
|
@@ -237,7 +237,7 @@ attempt_delta() { # attempt_delta <tdir> <worktree> <reviewed-commit>
|
|
|
237
237
|
&& from="$(git -C "$wt" rev-parse --verify -q "$(cat "$tdir/retry_findings.commit")^{commit}")" \
|
|
238
238
|
&& to="$(git -C "$wt" rev-parse --verify -q "$reviewed^{commit}")" \
|
|
239
239
|
&& git -C "$wt" merge-base --is-ancestor "$from" "$to" \
|
|
240
|
-
&& git -C "$wt" diff --binary "$from" "$to" -- . ':(exclude).forge' > "$tdir/.changes.since.diff" 2>/dev/null \
|
|
240
|
+
&& git -C "$wt" diff --binary --irreversible-delete "$from" "$to" -- . ':(exclude).forge' > "$tdir/.changes.since.diff" 2>/dev/null \
|
|
241
241
|
&& [ -s "$tdir/.changes.since.diff" ] \
|
|
242
242
|
&& git -C "$wt" diff --stat "$from" "$to" -- . ':(exclude).forge' > "$tdir/.changes.since.stat" 2>/dev/null; then
|
|
243
243
|
printf '%s %s\n' "$from" "$to" > "$tdir/changes.since.range"
|
|
@@ -406,15 +406,43 @@ prepare_resume() { # prepare_resume <plan> <id>
|
|
|
406
406
|
return 0
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
# --infra-fallback: a dwarf-stage capacity stop moves the task to the next healthy member of
|
|
410
|
+
# its own tier pool (forge-route.py fallback), recorded like an escalation with source
|
|
411
|
+
# `fallback`. No attempt is spent: the stop already refunded it. Returns 1, changing nothing,
|
|
412
|
+
# when there is no candidate, a pin is waiting (a human's choice wins) or the plan is Fractal.
|
|
413
|
+
prepare_fallback() { # prepare_fallback <plan> <id> <excluded harness/model,...>
|
|
414
|
+
local PLAN="$1" id="$2" tdir="$1/tasks/$2" cur pick
|
|
415
|
+
[ -e "$tdir/escalation.pin" ] && return 1
|
|
416
|
+
forge_plan_is_fractal "$PLAN" && return 1
|
|
417
|
+
cur="$(field "$PLAN/tasks.tsv" "$id" dwarf)"
|
|
418
|
+
pick="$(python3 "$SKILL_DIR/scripts/forge-route.py" fallback --plan "$PLAN" --task "$id" --exclude "$3")" || return 1
|
|
419
|
+
[ -n "$pick" ] || return 1
|
|
420
|
+
write_escalation "$PLAN" "$id" "$cur" "$pick" fallback || return 1
|
|
421
|
+
rm -f "$tdir/status" "$tdir/infra.txt"
|
|
422
|
+
note "$id: $cur is at capacity; falling back to $pick (same tier)"
|
|
423
|
+
}
|
|
424
|
+
|
|
409
425
|
# The scheduler's `_prepare_retry` target: prepare, then clear the status so the task
|
|
410
426
|
# reads as PENDING again. `retry` clears it itself, after its own preflight. With --resume it
|
|
411
|
-
# prepares an infrastructure stop's resume instead (prepare_resume), and the status stays
|
|
412
|
-
|
|
427
|
+
# prepares an infrastructure stop's resume instead (prepare_resume), and the status stays;
|
|
428
|
+
# with --dwarf <spec> the spec is the explicit new implementer; --fallback <pairs> is
|
|
429
|
+
# prepare_fallback.
|
|
430
|
+
retry_for_scheduler() { # retry_for_scheduler <plan> <id> [--resume | --dwarf <spec> | --fallback <pairs>]
|
|
413
431
|
if [ "${3:-}" = --resume ]; then
|
|
414
432
|
prepare_resume "$1" "$2"
|
|
415
433
|
return $?
|
|
416
434
|
fi
|
|
417
|
-
|
|
435
|
+
if [ "${3:-}" = --fallback ]; then
|
|
436
|
+
prepare_fallback "$1" "$2" "${4:-}"
|
|
437
|
+
return $?
|
|
438
|
+
fi
|
|
439
|
+
# --dwarf: `forge control retry --dwarf`, the same explicit escalation as `retry --dwarf`.
|
|
440
|
+
if [ "${3:-}" = --dwarf ]; then
|
|
441
|
+
[ -n "${4:-}" ] || die "_prepare_retry: --dwarf needs a spec"
|
|
442
|
+
prepare_retry "$1" "$2" "$4" || return $?
|
|
443
|
+
else
|
|
444
|
+
prepare_retry "$1" "$2" || return $?
|
|
445
|
+
fi
|
|
418
446
|
rm -f "$1/tasks/$2/status"
|
|
419
447
|
}
|
|
420
448
|
|
|
@@ -540,7 +568,26 @@ report_guard_notes() { # report_guard_notes <plan>
|
|
|
540
568
|
|
|
541
569
|
report_verify_notes() { # report_verify_notes <dir holding verification.*>
|
|
542
570
|
local d="$1"
|
|
543
|
-
if [ -s "$d/verification.
|
|
571
|
+
if [ -s "$d/verification.lanes.json" ]; then
|
|
572
|
+
# Lanes: per lane, from the runner's own record
|
|
573
|
+
python3 - "$d" <<'PY'
|
|
574
|
+
import json, os, sys
|
|
575
|
+
d = sys.argv[1]
|
|
576
|
+
try:
|
|
577
|
+
with open(os.path.join(d, 'verification.lanes.json'), encoding='utf-8') as fh:
|
|
578
|
+
lanes = [l for l in json.load(fh).get('lanes') or [] if isinstance(l, dict) and l.get('name')]
|
|
579
|
+
except (OSError, ValueError, AttributeError):
|
|
580
|
+
sys.exit(0)
|
|
581
|
+
lines = ['FLAKY: lane %s failed once and passed on rerun' % l['name'] for l in lanes if l.get('state') == 'flaky']
|
|
582
|
+
lines += ['known failures only: lane %s' % l['name'] for l in lanes if l.get('state') == 'known']
|
|
583
|
+
failed = [l['name'] for l in lanes if l.get('state') == 'fail']
|
|
584
|
+
if failed:
|
|
585
|
+
lines.append('verification failed in lane%s %s: read %s' % ('s' if len(failed) > 1 else '', ', '.join(failed),
|
|
586
|
+
os.path.join(d, 'verification.log')))
|
|
587
|
+
if lines:
|
|
588
|
+
print('\n'.join(lines) + '\n')
|
|
589
|
+
PY
|
|
590
|
+
elif [ -s "$d/verification.flaky" ]; then
|
|
544
591
|
echo "FLAKY verification: the command failed once and passed on rerun — read $d/verification.log"
|
|
545
592
|
echo " before trusting this result; an intermittent failure can be a real bug."
|
|
546
593
|
echo
|
|
@@ -602,6 +649,7 @@ run_report_extras() { # run_report_extras <plan> [<verification dir>]
|
|
|
602
649
|
report_infra "$1"
|
|
603
650
|
report_escalations "$1"
|
|
604
651
|
report_known_issues "$1"
|
|
652
|
+
python3 "$SKILL_DIR/scripts/forge-sweep.py" report "$1" 2>/dev/null || true
|
|
605
653
|
report_guard_notes "$1"
|
|
606
654
|
report_verify_notes "${2:-$1}"
|
|
607
655
|
}
|