@giamme/forge 0.14.1 → 0.16.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 +46 -0
- package/SKILL.md +47 -14
- package/VERSION +1 -1
- package/docs/artifacts.md +1 -1
- package/docs/commands.md +302 -9
- package/docs/forge-ui.md +14 -0
- package/docs/memory.md +22 -0
- package/docs/models.md +53 -0
- package/docs/reviews.md +7 -0
- package/forge +11 -0
- package/package.json +1 -1
- package/references/dataset.md +16 -4
- package/references/decompose.md +154 -9
- package/references/harnesses.md +21 -1
- package/references/planning.md +59 -0
- package/references/solo.md +5 -1
- package/references/ui.md +48 -1
- package/scripts/forge-artifact.sh +53 -0
- package/scripts/forge-compare.py +6 -3
- package/scripts/forge-config.py +531 -4
- package/scripts/forge-contract.py +55 -8
- package/scripts/forge-control.py +0 -2
- package/scripts/forge-dispatch.sh +84 -14
- package/scripts/forge-fail-first.py +3 -1
- package/scripts/forge-guard.py +247 -8
- package/scripts/forge-issues.py +12 -0
- package/scripts/forge-lib-adopt.sh +260 -0
- package/scripts/forge-lib-attribute.sh +10 -2
- package/scripts/forge-lib-plans.sh +35 -6
- package/scripts/forge-lib-review.sh +13 -5
- package/scripts/forge-lib-task.sh +138 -5
- package/scripts/forge-memory.sh +41 -4
- package/scripts/forge-metrics.sh +7 -0
- package/scripts/forge-parallel-options.sh +12 -6
- package/scripts/forge-parallel.sh +659 -32
- package/scripts/forge-plan-check.py +591 -8
- package/scripts/forge-planner.py +480 -0
- package/scripts/forge-route.py +16 -2
- package/scripts/forge-runs-rm.py +23 -7
- package/scripts/forge-runtime.py +111 -2
- package/scripts/forge-schedule.py +5 -2
- package/scripts/forge-shadow.py +53 -7
- package/scripts/forge-solo.sh +87 -7
- package/scripts/forge_dataset/cli.py +26 -0
- package/scripts/forge_dataset/efforts.py +215 -0
- package/scripts/forge_dataset/export.py +1 -0
- package/scripts/forge_dataset/harvest.py +55 -0
- package/scripts/forge_dataset/history.py +126 -0
- package/scripts/forge_dataset/worktrees.py +95 -0
- package/scripts/forge_decide/__init__.py +19 -1
- package/scripts/forge_decide/builtin_profiles.json +25 -0
- package/scripts/forge_decide/cli.py +12 -0
- package/scripts/forge_decide/profiles.py +866 -0
- package/scripts/forge_decide/resolve.py +38 -6
- package/scripts/forge_memory_list.py +153 -0
- package/scripts/forge_worktrees.py +88 -0
- package/ui/README.md +31 -0
- package/ui/docs/api.md +168 -12
- package/ui/forge_ui/__init__.py +14 -1
- package/ui/forge_ui/__main__.py +1 -1
- package/ui/forge_ui/control.py +250 -12
- package/ui/forge_ui/executions.py +28 -8
- package/ui/forge_ui/findings.py +7 -0
- package/ui/forge_ui/models.py +60 -1
- package/ui/forge_ui/projects.py +571 -0
- package/ui/forge_ui/reader.py +48 -8
- package/ui/forge_ui/static/app.js +99 -21
- package/ui/forge_ui/static/cloudui.js +6 -2
- package/ui/forge_ui/static/convo.js +1 -1
- package/ui/forge_ui/static/diffview.js +2 -2
- package/ui/forge_ui/static/files.js +1 -1
- package/ui/forge_ui/static/index.html +5 -1
- package/ui/forge_ui/static/leaderboard.js +5 -1
- package/ui/forge_ui/static/modelstats.js +25 -1
- package/ui/forge_ui/static/panel.js +47 -4
- package/ui/forge_ui/static/projectsview.js +372 -0
- package/ui/forge_ui/static/settings.js +924 -29
- package/ui/forge_ui/static/style.css +116 -3
- package/ui/forge_ui/static/uikit.js +94 -1
- package/ui/forge_ui/static/worktreesview.js +250 -0
- package/ui/forge_ui/worktrees.py +570 -0
package/scripts/forge-guard.py
CHANGED
|
@@ -11,11 +11,27 @@
|
|
|
11
11
|
be signalled or reaped as a unit. macOS has no `setsid` binary; this is why the
|
|
12
12
|
helper exists.
|
|
13
13
|
|
|
14
|
-
forge-guard.py reap <pgid> <orphans-file>
|
|
14
|
+
forge-guard.py reap <pgid> <orphans-file> [--tracked <file>]
|
|
15
15
|
After the harness exited: anything still alive in its process group is an orphan
|
|
16
16
|
the implementer abandoned. List it (only when something is found), TERM, wait a
|
|
17
17
|
bounded ~2s, KILL, print how many were found. Never exits nonzero for an ordinary
|
|
18
|
-
outcome, and never touches its own or its caller's group.
|
|
18
|
+
outcome, and never touches its own or its caller's group. With --tracked, also every
|
|
19
|
+
process `track` recorded that is still alive with its recorded start time, and its
|
|
20
|
+
descendants now, whatever group or session it moved to (#129).
|
|
21
|
+
|
|
22
|
+
forge-guard.py track <pid> <file> [--interval S]
|
|
23
|
+
While the harness runs: every S seconds (default 2), append each new descendant of
|
|
24
|
+
<pid>, and of every process already recorded and still alive, as
|
|
25
|
+
`<pid><TAB><start time><TAB><command>`. A tool that starts a session of its own (a
|
|
26
|
+
test runner's web server) leaves the harness's group, but not its ancestry, so this is
|
|
27
|
+
how `reap --tracked` finds it. Runs until TERM, or until its parent is gone.
|
|
28
|
+
|
|
29
|
+
forge-guard.py stop-tree <pid> [--wait S]
|
|
30
|
+
A controller's interrupt (a standalone retry, #129): TERM the pid and every descendant it
|
|
31
|
+
has now, in any group or session, then wait up to S seconds (default 20) while they
|
|
32
|
+
clean up (a dispatch's EXIT trap stops its harness and reaps), then KILL what is left.
|
|
33
|
+
Each pid is matched by its start time, so a reused one is never signalled. Prints how
|
|
34
|
+
many processes were signalled.
|
|
19
35
|
|
|
20
36
|
forge-guard.py identity <pid>
|
|
21
37
|
Print the process's start time, which survives exec. Dispatch records it with the
|
|
@@ -29,6 +45,8 @@
|
|
|
29
45
|
pid with another start time was reused and is left alone. A dead pid's group may
|
|
30
46
|
still hold the harness's background jobs, and cannot have been reused while they
|
|
31
47
|
live, so it is reaped. The record is removed; prints how many processes were signalled.
|
|
48
|
+
A `<role>.tracked` file beside a `<role>.harness` record is reaped as `reap --tracked`
|
|
49
|
+
would, so a dispatch that died early leaves no tool behind either.
|
|
32
50
|
|
|
33
51
|
forge-guard.py promises <file> [--tail-bytes N]
|
|
34
52
|
Scan the tail of an implementer's final message for promises of later work ("it is
|
|
@@ -166,8 +184,200 @@ def _reap_group(pgid: int, orphans_file: str | None) -> int:
|
|
|
166
184
|
return len(found)
|
|
167
185
|
|
|
168
186
|
|
|
169
|
-
|
|
170
|
-
|
|
187
|
+
# --- track / tracked reap --------------------------------------------------------
|
|
188
|
+
TRACK_INTERVAL_S = 2.0
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def ps_table():
|
|
192
|
+
"""{pid: (ppid, start time, command)} of every live process but zombies, or None when ps is
|
|
193
|
+
unavailable. The start time is `identity`'s, whitespace-normalised the same way."""
|
|
194
|
+
for ps in PS_CANDIDATES:
|
|
195
|
+
if not os.access(ps, os.X_OK):
|
|
196
|
+
continue
|
|
197
|
+
try:
|
|
198
|
+
out = subprocess.run([ps, '-axo', 'pid=,ppid=,stat=,lstart=,command='], stdout=subprocess.PIPE,
|
|
199
|
+
stderr=subprocess.DEVNULL, timeout=5,
|
|
200
|
+
env=dict(os.environ, LC_ALL='C')).stdout.decode(errors='replace')
|
|
201
|
+
except (OSError, subprocess.SubprocessError):
|
|
202
|
+
continue
|
|
203
|
+
table = {}
|
|
204
|
+
for line in out.splitlines():
|
|
205
|
+
parts = line.split(None, 8) # pid ppid stat + lstart's five words + command
|
|
206
|
+
if len(parts) < 8:
|
|
207
|
+
continue
|
|
208
|
+
try:
|
|
209
|
+
pid, ppid = int(parts[0]), int(parts[1])
|
|
210
|
+
except ValueError:
|
|
211
|
+
continue
|
|
212
|
+
if parts[2].startswith('Z'):
|
|
213
|
+
continue
|
|
214
|
+
table[pid] = (ppid, ' '.join(parts[3:8]), parts[8].strip() if len(parts) > 8 else '')
|
|
215
|
+
return table
|
|
216
|
+
return None
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def descendants(table, roots):
|
|
220
|
+
"""Every live descendant of `roots` in a ps_table, the roots excluded."""
|
|
221
|
+
children = {}
|
|
222
|
+
for pid, (ppid, _start, _command) in table.items():
|
|
223
|
+
children.setdefault(ppid, []).append(pid)
|
|
224
|
+
out, todo = set(), [r for r in roots if r > 1]
|
|
225
|
+
while todo:
|
|
226
|
+
for child in children.get(todo.pop(), ()):
|
|
227
|
+
if child not in out and child not in roots:
|
|
228
|
+
out.add(child)
|
|
229
|
+
todo.append(child)
|
|
230
|
+
return out
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def read_tracked(path):
|
|
234
|
+
"""{pid: start time} of a track file; a torn last line is skipped."""
|
|
235
|
+
found = {}
|
|
236
|
+
try:
|
|
237
|
+
with open(path, errors='replace') as handle:
|
|
238
|
+
for line in handle:
|
|
239
|
+
if not line.endswith('\n'):
|
|
240
|
+
break
|
|
241
|
+
pid_text, _, rest = line.partition('\t')
|
|
242
|
+
start = rest.split('\t', 1)[0].strip()
|
|
243
|
+
try:
|
|
244
|
+
pid = int(pid_text)
|
|
245
|
+
except ValueError:
|
|
246
|
+
continue
|
|
247
|
+
if pid > 1 and start:
|
|
248
|
+
found[pid] = start
|
|
249
|
+
except OSError:
|
|
250
|
+
pass
|
|
251
|
+
return found
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _mine(table, known):
|
|
255
|
+
"""The recorded processes still alive with their recorded start time (not a reused pid)."""
|
|
256
|
+
return {pid for pid, start in known.items() if pid in table and table[pid][1] == start}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def track(root: int, path: str, interval: float = TRACK_INTERVAL_S) -> int:
|
|
260
|
+
known = read_tracked(path)
|
|
261
|
+
parent = os.getppid()
|
|
262
|
+
stopping = []
|
|
263
|
+
signal.signal(signal.SIGTERM, lambda *_: stopping.append(1))
|
|
264
|
+
while not stopping:
|
|
265
|
+
table = ps_table()
|
|
266
|
+
if table is None:
|
|
267
|
+
return 0
|
|
268
|
+
new = []
|
|
269
|
+
for pid in sorted(descendants(table, {root} | _mine(table, known))):
|
|
270
|
+
start = table[pid][1]
|
|
271
|
+
if known.get(pid) != start and pid != os.getpid():
|
|
272
|
+
known[pid] = start
|
|
273
|
+
new.append('%d\t%s\t%s\n' % (pid, start, ' '.join(table[pid][2].split()).replace('\t', ' ')))
|
|
274
|
+
if new:
|
|
275
|
+
try:
|
|
276
|
+
with open(path, 'a') as handle:
|
|
277
|
+
handle.write(''.join(new))
|
|
278
|
+
except OSError:
|
|
279
|
+
pass
|
|
280
|
+
if os.getppid() != parent:
|
|
281
|
+
return 0 # the dispatch is gone; its EXIT trap reaps
|
|
282
|
+
deadline = time.monotonic() + interval
|
|
283
|
+
while not stopping and time.monotonic() < deadline:
|
|
284
|
+
time.sleep(0.05)
|
|
285
|
+
return 0
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def _never(table) -> set:
|
|
289
|
+
"""Pids a tracked reap never signals: init, this process and its ancestors."""
|
|
290
|
+
never, pid = {0, 1}, os.getpid()
|
|
291
|
+
while pid and pid not in never:
|
|
292
|
+
never.add(pid)
|
|
293
|
+
pid = table.get(pid, (0,))[0] if table else 0
|
|
294
|
+
return never
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _reap_tracked(path: str, skip_group: int | None) -> list:
|
|
298
|
+
"""TERM, then KILL, what a track file recorded that is still ours, and its descendants now;
|
|
299
|
+
[(pid, command)] of what was found. Members of `skip_group` are left to the group reap."""
|
|
300
|
+
known = read_tracked(path) if path else {}
|
|
301
|
+
if not known:
|
|
302
|
+
return []
|
|
303
|
+
found = {}
|
|
304
|
+
for sig, wait in ((signal.SIGTERM, TERM_WAIT_S), (signal.SIGKILL, KILL_WAIT_S)):
|
|
305
|
+
table = ps_table()
|
|
306
|
+
if table is None:
|
|
307
|
+
break
|
|
308
|
+
never = _never(table)
|
|
309
|
+
targets = _mine(table, known)
|
|
310
|
+
targets |= descendants(table, targets)
|
|
311
|
+
targets -= never
|
|
312
|
+
if skip_group is not None:
|
|
313
|
+
targets = {pid for pid in targets if _pgid(pid) != skip_group}
|
|
314
|
+
if not targets:
|
|
315
|
+
break
|
|
316
|
+
for pid in targets:
|
|
317
|
+
found.setdefault(pid, table[pid][2])
|
|
318
|
+
try:
|
|
319
|
+
os.kill(pid, sig)
|
|
320
|
+
except OSError:
|
|
321
|
+
pass
|
|
322
|
+
deadline = time.monotonic() + wait
|
|
323
|
+
while time.monotonic() < deadline:
|
|
324
|
+
table = ps_table() or {}
|
|
325
|
+
if not any(pid in table for pid in targets):
|
|
326
|
+
break
|
|
327
|
+
time.sleep(0.05)
|
|
328
|
+
return sorted(found.items())
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _pgid(pid: int):
|
|
332
|
+
try:
|
|
333
|
+
return os.getpgid(pid)
|
|
334
|
+
except OSError:
|
|
335
|
+
return None
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _write_orphans(orphans_file, rows, append=False):
|
|
339
|
+
if not orphans_file or not rows:
|
|
340
|
+
return
|
|
341
|
+
try:
|
|
342
|
+
with open(orphans_file, 'a' if append else 'w') as handle:
|
|
343
|
+
for pid, command in rows:
|
|
344
|
+
handle.write('%s\t%s\n' % (pid or '?', ' '.join(command.split()) or '?'))
|
|
345
|
+
except OSError:
|
|
346
|
+
pass
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def stop_tree(root: int, wait: float) -> int:
|
|
350
|
+
table = ps_table()
|
|
351
|
+
if table is None or root <= 1:
|
|
352
|
+
print(0)
|
|
353
|
+
return 0
|
|
354
|
+
targets = (({root} if root in table else set()) | descendants(table, {root})) - _never(table)
|
|
355
|
+
starts = {pid: table[pid][1] for pid in targets}
|
|
356
|
+
for pid in targets:
|
|
357
|
+
try:
|
|
358
|
+
os.kill(pid, signal.SIGTERM)
|
|
359
|
+
except OSError:
|
|
360
|
+
pass
|
|
361
|
+
deadline = time.monotonic() + wait
|
|
362
|
+
left = set(targets)
|
|
363
|
+
while left and time.monotonic() < deadline:
|
|
364
|
+
time.sleep(0.2)
|
|
365
|
+
now = ps_table() or {}
|
|
366
|
+
left = {pid for pid in left if pid in now and now[pid][1] == starts[pid]}
|
|
367
|
+
for pid in left:
|
|
368
|
+
try:
|
|
369
|
+
os.kill(pid, signal.SIGKILL)
|
|
370
|
+
except OSError:
|
|
371
|
+
pass
|
|
372
|
+
print(len(targets))
|
|
373
|
+
return 0
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def reap(pgid: int, orphans_file: str, tracked: str | None = None) -> int:
|
|
377
|
+
count = _reap_group(pgid, orphans_file)
|
|
378
|
+
extra = _reap_tracked(tracked, pgid) if tracked else []
|
|
379
|
+
_write_orphans(orphans_file, extra, append=count > 0)
|
|
380
|
+
print(count + len(extra))
|
|
171
381
|
return 0
|
|
172
382
|
|
|
173
383
|
|
|
@@ -270,6 +480,8 @@ def stop(record: str) -> int:
|
|
|
270
480
|
count = _stop_live(pid)
|
|
271
481
|
else:
|
|
272
482
|
count = _reap_group(pid, None)
|
|
483
|
+
if record.endswith('.harness'):
|
|
484
|
+
count += len(_reap_tracked(record[:-len('.harness')] + '.tracked', None))
|
|
273
485
|
try:
|
|
274
486
|
os.unlink(record)
|
|
275
487
|
except OSError:
|
|
@@ -355,8 +567,10 @@ def promises(path: str, tail_bytes: int = 3000) -> int:
|
|
|
355
567
|
# --- cli ----------------------------------------------------------------------
|
|
356
568
|
def main(argv: list[str]) -> int:
|
|
357
569
|
if not argv:
|
|
358
|
-
print('usage: forge-guard.py ping | session -- CMD... | reap <pgid> <orphans-file> | '
|
|
359
|
-
'
|
|
570
|
+
print('usage: forge-guard.py ping | session -- CMD... | reap <pgid> <orphans-file> [--tracked FILE] | '
|
|
571
|
+
'track <pid> <file> [--interval S] | stop-tree <pid> [--wait S] | identity <pid> | '
|
|
572
|
+
'stop <record-file> | '
|
|
573
|
+
'promises <file> [--tail-bytes N]', file=sys.stderr)
|
|
360
574
|
return 2
|
|
361
575
|
command, rest = argv[0], argv[1:]
|
|
362
576
|
try:
|
|
@@ -368,10 +582,35 @@ def main(argv: list[str]) -> int:
|
|
|
368
582
|
rest = rest[1:]
|
|
369
583
|
return session(rest)
|
|
370
584
|
if command == 'reap':
|
|
585
|
+
tracked = None
|
|
586
|
+
if '--tracked' in rest:
|
|
587
|
+
index = rest.index('--tracked')
|
|
588
|
+
tracked = rest[index + 1]
|
|
589
|
+
rest = rest[:index] + rest[index + 2:]
|
|
590
|
+
if len(rest) != 2:
|
|
591
|
+
print('usage: forge-guard.py reap <pgid> <orphans-file> [--tracked FILE]', file=sys.stderr)
|
|
592
|
+
return 2
|
|
593
|
+
return reap(int(rest[0]), rest[1], tracked)
|
|
594
|
+
if command == 'stop-tree':
|
|
595
|
+
wait = 20.0
|
|
596
|
+
if '--wait' in rest:
|
|
597
|
+
index = rest.index('--wait')
|
|
598
|
+
wait = float(rest[index + 1])
|
|
599
|
+
rest = rest[:index] + rest[index + 2:]
|
|
600
|
+
if len(rest) != 1:
|
|
601
|
+
print('usage: forge-guard.py stop-tree <pid> [--wait S]', file=sys.stderr)
|
|
602
|
+
return 2
|
|
603
|
+
return stop_tree(int(rest[0]), max(0.0, wait))
|
|
604
|
+
if command == 'track':
|
|
605
|
+
interval = TRACK_INTERVAL_S
|
|
606
|
+
if '--interval' in rest:
|
|
607
|
+
index = rest.index('--interval')
|
|
608
|
+
interval = float(rest[index + 1])
|
|
609
|
+
rest = rest[:index] + rest[index + 2:]
|
|
371
610
|
if len(rest) != 2:
|
|
372
|
-
print('usage: forge-guard.py
|
|
611
|
+
print('usage: forge-guard.py track <pid> <file> [--interval S]', file=sys.stderr)
|
|
373
612
|
return 2
|
|
374
|
-
return
|
|
613
|
+
return track(int(rest[0]), rest[1], max(0.1, interval))
|
|
375
614
|
if command == 'identity':
|
|
376
615
|
if len(rest) != 1:
|
|
377
616
|
print('usage: forge-guard.py identity <pid>', file=sys.stderr)
|
package/scripts/forge-issues.py
CHANGED
|
@@ -566,6 +566,18 @@ def collect_plan(plan_dir: Path, include_plausible):
|
|
|
566
566
|
if review:
|
|
567
567
|
items, _ = task_findings(review, plan_dir, include_plausible, {}, review=True)
|
|
568
568
|
found += [{**f, "task": None} for f in items]
|
|
569
|
+
# What an adopted range kept (`adopt`), read as an accepted task's are: its known_issues.md holds what fell
|
|
570
|
+
# below the threshold and, under `--approved`, the findings a person kept. Its review never goes stale.
|
|
571
|
+
for row in read(plan_dir / "adoptions.tsv").splitlines() if (plan_dir / "adoptions.tsv").is_file() else []:
|
|
572
|
+
cols = row.split("\t")
|
|
573
|
+
adopted = plan_dir / cols[6] if len(cols) > 6 and cols[6] else None
|
|
574
|
+
if adopted and adopted.is_dir():
|
|
575
|
+
meta = {"task": adopted.name, "commit": cols[2], "reviewer": cols[5],
|
|
576
|
+
"threshold": effective_threshold(adopted, plan_dir)}
|
|
577
|
+
found += known_findings(read(adopted / "known_issues.md"), adopted, meta)
|
|
578
|
+
if include_plausible:
|
|
579
|
+
found += [{**f, **meta, "origin": "plausible", "review": None}
|
|
580
|
+
for f in parse_findings(read(adopted / "qa.last")) if f["confidence"] == "PLAUSIBLE"]
|
|
569
581
|
for f in found:
|
|
570
582
|
f["plan"], f["plan_dir"] = plan_dir.name, str(plan_dir)
|
|
571
583
|
return found, notes
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# `adopt` for forge-parallel.sh (#79): a commit made outside forge comes into a run's integration
|
|
3
|
+
# branch, reviewed on its own by the run's QA. Sourced; functions only.
|
|
4
|
+
#
|
|
5
|
+
# forge-parallel.sh adopt <plan-dir> <commit|a..b> --reason "<why>" [--qa <spec>] [--yolo-qa] [--approved]
|
|
6
|
+
# forge-parallel.sh adopt <plan-dir> --head --reason "<why>" [--qa <spec>] [--yolo-qa] [--approved]
|
|
7
|
+
#
|
|
8
|
+
# The first cherry-picks onto the integration branch. --head takes what is already on it past the
|
|
9
|
+
# revision the run accepted, the case `review` refuses. Either way the reviewer sees only that range.
|
|
10
|
+
# PASS moves accepted.integration. A FAIL or an unknown verdict puts the branch back unless --approved
|
|
11
|
+
# overrides it, which is recorded; a review that concluded nothing (an infrastructure stop, a crash, a
|
|
12
|
+
# timeout) always puts it back. A worktree that changed during the review is left as it is: resetting
|
|
13
|
+
# it would destroy the change.
|
|
14
|
+
# adopt-<epoch>-<pid>/ keeps the review; adoptions.tsv holds one row per adopted range: epoch, base,
|
|
15
|
+
# tip, verdict, approved (0|1), spec, the review's directory name, reason. There is no task row: nothing here
|
|
16
|
+
# was a model's implementation, and a final review reads the whole range anyway.
|
|
17
|
+
|
|
18
|
+
adopt_rows() { # adopt_rows <plan>: the adopted ranges, as lines for a prompt
|
|
19
|
+
[ -s "$1/adoptions.tsv" ] || return 0
|
|
20
|
+
echo "Commits adopted from outside this run, each reviewed alone (they are in the diff below):"
|
|
21
|
+
awk -F'\t' '{ printf " - %s..%s (%s%s): %s\n", substr($2, 1, 12), substr($3, 1, 12), $4, ($5 == 1 ? ", approved over it" : ""), $8 }' "$1/adoptions.tsv"
|
|
22
|
+
echo
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
do_adopt() {
|
|
26
|
+
local PLAN="${1:?adopt needs a plan dir}"; shift
|
|
27
|
+
local target="" head=0 reason="" approved=0 spec="" yolo_given=""
|
|
28
|
+
while [ $# -gt 0 ]; do
|
|
29
|
+
case "$1" in
|
|
30
|
+
--head) head=1; shift ;;
|
|
31
|
+
--reason) [ $# -ge 2 ] || die "adopt: --reason needs a text"; reason="$2"; shift 2 ;;
|
|
32
|
+
--qa) [ $# -ge 2 ] || die "adopt: --qa needs a spec"; spec="$2"; shift 2 ;;
|
|
33
|
+
--yolo-qa) yolo_given=1; shift ;;
|
|
34
|
+
--approved) approved=1; shift ;;
|
|
35
|
+
-*) die "adopt: unknown option '$1'" ;;
|
|
36
|
+
*) [ -z "$target" ] || die "adopt: unexpected argument '$1'"; target="$1"; shift ;;
|
|
37
|
+
esac
|
|
38
|
+
done
|
|
39
|
+
{ [ -n "$target" ] && [ "$head" = 0 ]; } || { [ -z "$target" ] && [ "$head" = 1 ]; } \
|
|
40
|
+
|| die "usage: forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason \"<why>\" [--qa <spec>] [--yolo-qa] [--approved]"
|
|
41
|
+
reason="$(printf '%s' "$reason" | tr '\n\r\t' ' ' | sed 's/^ *//; s/ *$//')"
|
|
42
|
+
[ -n "$reason" ] || die "adopt needs --reason \"<why this commit belongs in the run>\": the reviewer judges against it, and it is recorded"
|
|
43
|
+
|
|
44
|
+
local T="$PLAN/tasks.tsv" int_wt base now tip commits=() n
|
|
45
|
+
[ -s "$T" ] || die "no tasks.tsv in '$PLAN'" 3
|
|
46
|
+
[ -s "$PLAN/wt_root" ] && [ -s "$PLAN/run_id" ] && [ -s "$PLAN/repo" ] && [ -s "$PLAN/accepted.integration" ] \
|
|
47
|
+
|| die "this plan has never been run, so it has no integration branch to adopt into" 3
|
|
48
|
+
int_wt="$(cat "$PLAN/wt_root")/_integration"
|
|
49
|
+
[ -e "$int_wt/.git" ] || die "the integration worktree $int_wt is missing" 3
|
|
50
|
+
[ -z "$(git -C "$int_wt" status --porcelain -- . ':(exclude).forge' 2>/dev/null)" ] \
|
|
51
|
+
|| die "the integration worktree $int_wt has uncommitted changes; commit them, or clean it, first" 3
|
|
52
|
+
base="$(cat "$PLAN/accepted.integration")"
|
|
53
|
+
now="$(git -C "$int_wt" rev-parse HEAD)" || die "cannot read the integration worktree $int_wt" 3
|
|
54
|
+
|
|
55
|
+
if [ "$head" = 1 ]; then
|
|
56
|
+
[ "$now" != "$base" ] || die "the integration branch is at the revision this run accepted; there is nothing to adopt" 3
|
|
57
|
+
git -C "$int_wt" merge-base --is-ancestor "$base" "$now" \
|
|
58
|
+
|| die "the integration branch no longer contains the revision this run accepted ($(printf '%.12s' "$base")); it was rewritten, and adopt only takes commits on top of it" 3
|
|
59
|
+
else
|
|
60
|
+
[ "$now" = "$base" ] || die "the integration branch has moved past the revision this run accepted; adopt that first with --head" 3
|
|
61
|
+
local range
|
|
62
|
+
case "$target" in
|
|
63
|
+
*..*) range="$target" ;;
|
|
64
|
+
*) git -C "$int_wt" rev-parse --verify --quiet "$target^{commit}" >/dev/null || die "adopt: '$target' is not a commit here" 3
|
|
65
|
+
range="$target^!" ;;
|
|
66
|
+
esac
|
|
67
|
+
# shellcheck disable=SC2207 # commit ids are single words
|
|
68
|
+
commits=($(git -C "$int_wt" rev-list --reverse "$range" 2>/dev/null)) || die "adopt: '$target' is not a commit range here" 3
|
|
69
|
+
[ "${#commits[@]}" -gt 0 ] || die "adopt: '$target' holds no commits" 3
|
|
70
|
+
[ -z "$(git -C "$int_wt" rev-list --min-parents=2 "$range" 2>/dev/null)" ] \
|
|
71
|
+
|| die "adopt: '$target' includes a merge commit; adopt the commits it merged" 3
|
|
72
|
+
for n in "${commits[@]}"; do
|
|
73
|
+
git -C "$int_wt" merge-base --is-ancestor "$n" "$base" && die "adopt: $(printf '%.12s' "$n") is already on the integration branch" 3
|
|
74
|
+
done
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
# Everything that can refuse without a model goes first, so a bad spec moves nothing.
|
|
78
|
+
[ -n "$spec" ] || spec="$(cat "$PLAN/final_qa" 2>/dev/null)"
|
|
79
|
+
[ -n "$spec" ] || spec="$(field "$T" "$(all_ids "$T" | head -1)" qa)"
|
|
80
|
+
[ -n "$spec" ] || die "adopt: no QA spec; name one with --qa" 3
|
|
81
|
+
local out ft rc=0 yolo tflag=""
|
|
82
|
+
out="$PLAN/adopt-$(date +%s)-$$"
|
|
83
|
+
mkdir -p "$out" && out="$(cd "$out" && pwd)" || die "adopt: cannot create $out" 3
|
|
84
|
+
ft="$(forge_fast_tier "$PLAN" review)"
|
|
85
|
+
yolo="$(review_yolo_flag "$PLAN" "$yolo_given")"
|
|
86
|
+
[ -s "$PLAN/timeout" ] && tflag="--timeout $(cat "$PLAN/timeout")"
|
|
87
|
+
FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$PLAN/capabilities}" \
|
|
88
|
+
/bin/bash "$DISPATCH" doctor --spec "$spec" --role qa $yolo $ft > "$out/doctor.out" 2>&1 \
|
|
89
|
+
|| { cat "$out/doctor.out" >&2; die "adopt: QA spec '$spec' cannot be used (see above); nothing was applied" 3; }
|
|
90
|
+
|
|
91
|
+
# Back to the accepted revision, for every outcome that does not adopt. A range that was only on
|
|
92
|
+
# this branch (--head) keeps a ref: the branch was its one home. A worktree that changed since its
|
|
93
|
+
# fingerprint was taken stays as it is, and says how to go on.
|
|
94
|
+
local source_fp="" review_fp="" tip="$now"
|
|
95
|
+
adopt_rollback() {
|
|
96
|
+
trap - INT TERM
|
|
97
|
+
if [ -n "$source_fp" ] && [ "$(forge_fingerprint "$int_wt" 2>/dev/null)" != "$source_fp" ]; then
|
|
98
|
+
echo "the integration worktree changed during the review, so forge left it as it is. Nothing was adopted: accepted.integration is still $(printf '%.12s' "$base")."
|
|
99
|
+
if [ -n "$(git -C "$int_wt" status --porcelain -- . ':(exclude).forge' 2>/dev/null)" ]; then
|
|
100
|
+
echo "keep what it holds: commit the edits in $int_wt, then: forge-parallel.sh adopt $PLAN --head --reason \"...\""
|
|
101
|
+
else
|
|
102
|
+
echo "keep what it holds with: forge-parallel.sh adopt $PLAN --head --reason \"...\""
|
|
103
|
+
fi
|
|
104
|
+
echo "or put it back with: git -C $int_wt reset --hard $base"
|
|
105
|
+
return 0
|
|
106
|
+
fi
|
|
107
|
+
git -C "$int_wt" cherry-pick --abort >/dev/null 2>&1
|
|
108
|
+
git -C "$int_wt" reset -q --hard "$base" || note "adopt: could not put the integration branch back at $base"
|
|
109
|
+
if [ "$head" = 1 ]; then
|
|
110
|
+
git -C "$int_wt" update-ref "refs/forge/adopt-refused/$(basename "$out")" "$tip" 2>/dev/null
|
|
111
|
+
echo "the integration branch is back at $(printf '%.12s' "$base"); your commits are at $tip (ref refs/forge/adopt-refused/$(basename "$out"))"
|
|
112
|
+
else
|
|
113
|
+
echo "the integration branch is back at $(printf '%.12s' "$base")"
|
|
114
|
+
fi
|
|
115
|
+
}
|
|
116
|
+
# A signal must not leave the range on the branch with accepted.integration behind it: that refuses
|
|
117
|
+
# every later review, run and accept.
|
|
118
|
+
trap 'adopt_rollback; exit 130' INT
|
|
119
|
+
trap 'adopt_rollback; exit 143' TERM
|
|
120
|
+
|
|
121
|
+
if [ "$head" = 0 ]; then
|
|
122
|
+
if ! git -C "$int_wt" cherry-pick "${commits[@]}" > "$out/apply.log" 2>&1; then
|
|
123
|
+
trap - INT TERM
|
|
124
|
+
git -C "$int_wt" cherry-pick --abort >/dev/null 2>&1
|
|
125
|
+
git -C "$int_wt" reset -q --hard "$base"
|
|
126
|
+
die "adopt: '$target' does not apply cleanly on the integration branch (see $out/apply.log); nothing was adopted" 6
|
|
127
|
+
fi
|
|
128
|
+
fi
|
|
129
|
+
tip="$(git -C "$int_wt" rev-parse HEAD)"
|
|
130
|
+
|
|
131
|
+
local review="$out/review" thr verdict gate_line decision kept inline=1
|
|
132
|
+
forge_review_snapshot "$int_wt" "$base" "$tip" "$review" > "$out/snapshot.log" 2>&1 \
|
|
133
|
+
|| { adopt_rollback; die "adopt: cannot build the review snapshot (see $out/snapshot.log)" 3; }
|
|
134
|
+
forge_review_deps "$int_wt" "$review" "$out/review.deps"
|
|
135
|
+
source_fp="$(forge_fingerprint "$int_wt")" && review_fp="$(forge_fingerprint "$review" --tracked)" \
|
|
136
|
+
|| { adopt_rollback; die "adopt: cannot fingerprint the checkouts" 3; }
|
|
137
|
+
thr="$(qa_threshold_for "$PLAN" __adopt__)"
|
|
138
|
+
printf '%s\n' "$thr" > "$out/qa_threshold" # what forge issues reads the kept findings under
|
|
139
|
+
git -C "$int_wt" diff --binary --irreversible-delete "$base" "$tip" -- . ':(exclude).forge' | head -c $((REVIEW_DIFF_LIMIT + 1)) > "$out/range.diff"
|
|
140
|
+
if [ "$(wc -c < "$out/range.diff" | tr -d ' ')" -gt "$REVIEW_DIFF_LIMIT" ]; then inline=0; rm -f "$out/range.diff"; fi
|
|
141
|
+
{
|
|
142
|
+
if [ -s "$PLAN/goal.txt" ]; then echo "## The run's goal"; echo; cat "$PLAN/goal.txt"; echo; fi
|
|
143
|
+
echo "## Why this is being adopted"; echo; printf '%s\n' "$reason"; echo
|
|
144
|
+
echo "## The commits"; echo; git -C "$int_wt" log --format='%h %an: %s' "$base..$tip"; echo
|
|
145
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part head --kind adopt
|
|
146
|
+
echo
|
|
147
|
+
cat "$out/review.deps"
|
|
148
|
+
echo "Forge ran no tests of its own on this range, so nothing here stands in for yours."
|
|
149
|
+
echo
|
|
150
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind adopt --threshold "$thr"
|
|
151
|
+
echo
|
|
152
|
+
if [ "$inline" = 1 ]; then
|
|
153
|
+
echo '```diff'; cat "$out/range.diff"; echo '```'
|
|
154
|
+
else
|
|
155
|
+
# The snapshot presents the range as one commit over its base, so HEAD~1..HEAD is it.
|
|
156
|
+
echo "The diff is larger than $((REVIEW_DIFF_LIMIT / 1024)) KB, so it is not inlined. Read it in your working directory:"
|
|
157
|
+
echo " git diff HEAD~1 HEAD -- . ':(exclude).forge'"
|
|
158
|
+
fi
|
|
159
|
+
} > "$out/qa.input"
|
|
160
|
+
|
|
161
|
+
FORGE_DATASET_TRIGGER=human FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$PLAN/capabilities}" \
|
|
162
|
+
/bin/bash "$DISPATCH" qa "$spec" --repo "$review" --run-dir "$out" --review-base "$(cat "$out/review.base")" \
|
|
163
|
+
--prompt-file "$out/qa.input" ${yolo:+"$yolo"} $ft $tflag --output "${FORGE_OUTPUT:-summary}" > "$out/qa.out" 2>&1
|
|
164
|
+
rc=$?
|
|
165
|
+
case "$rc" in
|
|
166
|
+
0) ;;
|
|
167
|
+
8) note "adopt: the reviewer hit an infrastructure failure; nothing was judged"
|
|
168
|
+
review_infra "$out"; adopt_rollback; return 8 ;;
|
|
169
|
+
2|3) note "adopt: the QA dispatch could not start (exit $rc); see $out/qa.out"
|
|
170
|
+
adopt_rollback; return 3 ;;
|
|
171
|
+
# A crash or a timeout concluded nothing, whatever the reply says, as in a final review.
|
|
172
|
+
*) note "adopt: the QA dispatch failed (exit $rc), so nothing was concluded and nothing was adopted; see $out/qa.out"
|
|
173
|
+
printf 'UNKNOWN\n' > "$out/verdict"
|
|
174
|
+
adopt_rollback
|
|
175
|
+
forge_dataset_event adopt --dir "$PLAN" --set base="$base" --set tip="$tip" --set verdict=UNKNOWN \
|
|
176
|
+
--set approved=0 --set adopted=0 --set spec="$spec" --set reason="$reason"
|
|
177
|
+
write_results "$PLAN"
|
|
178
|
+
return 5 ;;
|
|
179
|
+
esac
|
|
180
|
+
if [ "$(forge_fingerprint "$int_wt")" != "$source_fp" ] || [ "$(forge_fingerprint "$review" --tracked)" != "$review_fp" ]; then
|
|
181
|
+
note "adopt: a checkout changed during the review, so its verdict says nothing"
|
|
182
|
+
adopt_rollback; return 5
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
verdict="$(forge_verdict "$out/qa.last" 2>/dev/null)"; verdict="${verdict:-UNKNOWN}"
|
|
186
|
+
gate_line="$(python3 "$SKILL_DIR/scripts/forge-contract.py" gate --verdict "$verdict" --qa-last "$out/qa.last" \
|
|
187
|
+
--threshold "$thr" --known-issues "$out/known_issues.md" 2>/dev/null)" || gate_line=""
|
|
188
|
+
decision="$(printf '%s' "$gate_line" | awk -F'\t' '{print $1}')"
|
|
189
|
+
[ -z "$gate_line" ] || printf '%s\t%s\n' "$thr" "$gate_line" > "$out/qa.gate"
|
|
190
|
+
case "$decision" in accept) verdict=PASS ;; fail) verdict=FAIL ;; esac
|
|
191
|
+
printf '%s\n' "$verdict" > "$out/verdict"
|
|
192
|
+
|
|
193
|
+
kept=0
|
|
194
|
+
if [ "$verdict" != PASS ]; then
|
|
195
|
+
echo
|
|
196
|
+
sed -n '1,200p' "$out/qa.last" 2>/dev/null
|
|
197
|
+
echo
|
|
198
|
+
if [ "$approved" = 1 ]; then
|
|
199
|
+
kept=1; echo "adopt: the reviewer said $verdict; --approved keeps it, and that is recorded"
|
|
200
|
+
# What `accept` writes: forge issues and the run's report read the findings it kept from here.
|
|
201
|
+
local body who
|
|
202
|
+
body="$(plans_reviewer_text "$out" "$verdict")"
|
|
203
|
+
who="${USER:-${LOGNAME:-unknown}}"
|
|
204
|
+
{
|
|
205
|
+
if [ -s "$out/known_issues.md" ]; then cat "$out/known_issues.md"; echo; fi
|
|
206
|
+
echo "## Accepted by a human despite the reviewer's $verdict verdict"
|
|
207
|
+
echo
|
|
208
|
+
echo "Reason: $reason"
|
|
209
|
+
echo "Adopted by $who (range $(printf '%.12s' "$base")..$(printf '%.12s' "$tip")). None of it was fixed."
|
|
210
|
+
echo
|
|
211
|
+
[ -z "$body" ] || printf '%s\n' "$body"
|
|
212
|
+
if [ "$(printf '%s\n' "$body" | grep -c '^- ')" = 0 ]; then
|
|
213
|
+
echo
|
|
214
|
+
echo "- [$verdict] the reviewer left no itemised findings; read $(basename "$out")/qa.last"
|
|
215
|
+
fi
|
|
216
|
+
} > "$out/.known_issues.new" && mv "$out/.known_issues.new" "$out/known_issues.md"
|
|
217
|
+
printf 'status=%s\nreason=%s\nby=%s\nat=%s\nepoch=%s\nreviewed_commit=%s\n' "$verdict" "$reason" "$who" \
|
|
218
|
+
"$(date '+%Y-%m-%dT%H:%M:%S%z')" "$(date +%s)" "$tip" > "$out/accepted.by"
|
|
219
|
+
else
|
|
220
|
+
echo "adopt: the reviewer said $verdict, so nothing was adopted (see $out/qa.last)."
|
|
221
|
+
adopt_rollback
|
|
222
|
+
forge_dataset_event adopt --dir "$PLAN" --set base="$base" --set tip="$tip" --set verdict="$verdict" \
|
|
223
|
+
--set approved=0 --set adopted=0 --set spec="$spec" --set reason="$reason"
|
|
224
|
+
write_results "$PLAN"
|
|
225
|
+
return 5
|
|
226
|
+
fi
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
trap - INT TERM
|
|
230
|
+
printf '%s\n' "$tip" > "$PLAN/.accepted.integration.tmp" && mv "$PLAN/.accepted.integration.tmp" "$PLAN/accepted.integration" \
|
|
231
|
+
|| { adopt_rollback; die "adopt: could not record the accepted revision" 1; }
|
|
232
|
+
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date +%s)" "$base" "$tip" "$verdict" "$kept" "$spec" "$(basename "$out")" "$reason" \
|
|
233
|
+
>> "$PLAN/adoptions.tsv"
|
|
234
|
+
python3 - "$PLAN/control.log" "$base" "$tip" "$verdict" "$kept" "$spec" "$reason" "${USER:-${LOGNAME:-unknown}}" <<'PY' \
|
|
235
|
+
|| note "adopt: could not add this to control.log"
|
|
236
|
+
import json, sys, time
|
|
237
|
+
log, base, tip, verdict, kept, spec, reason, who = sys.argv[1:]
|
|
238
|
+
with open(log, 'a') as handle:
|
|
239
|
+
handle.write(json.dumps(dict(at=time.time(), actor='cli', action='adopt', task=None, key='integration', value=tip,
|
|
240
|
+
previous=base, verdict=verdict, approved=kept == '1', spec=spec, reason=reason, by=who)) + '\n')
|
|
241
|
+
PY
|
|
242
|
+
forge_dataset_event adopt --dir "$PLAN" --set base="$base" --set tip="$tip" --set verdict="$verdict" \
|
|
243
|
+
--set approved="$kept" --set adopted=1 --set spec="$spec" --set reason="$reason" \
|
|
244
|
+
--set authors="$(git -C "$int_wt" log --format='%an' "$base..$tip" | sort -u | awk 'NR > 1 { printf "," } { printf "%s", $0 }')"
|
|
245
|
+
echo "adopted $(printf '%.12s' "$base")..$(printf '%.12s' "$tip") ($verdict) into the integration branch"
|
|
246
|
+
|
|
247
|
+
# As a retry does: the verification follows the merge, and never undoes it.
|
|
248
|
+
local left="" lid
|
|
249
|
+
for lid in $(all_ids "$T"); do
|
|
250
|
+
case "$(task_status "$PLAN" "$lid")" in PENDING|BLOCKED) left="${left:+$left }$lid" ;; esac
|
|
251
|
+
done
|
|
252
|
+
write_results "$PLAN"
|
|
253
|
+
if [ -n "$left" ]; then
|
|
254
|
+
note "verification deferred: tasks still to run ($left); the next run, or integrate, verifies the integration branch"
|
|
255
|
+
else
|
|
256
|
+
verify_result "$PLAN" "$int_wt" "$PLAN" || { write_results "$PLAN"; run_report_extras "$PLAN"; return 5; }
|
|
257
|
+
fi
|
|
258
|
+
write_results "$PLAN"
|
|
259
|
+
return 0
|
|
260
|
+
}
|
|
@@ -54,7 +54,9 @@ attribute_scratch_pick() { # attribute_scratch_pick <wt_root>
|
|
|
54
54
|
|
|
55
55
|
attribute_scratch_remove() {
|
|
56
56
|
[ "${ATTR_SCRATCH_OWNED:-0}" = 1 ] && [ -n "${ATTR_SCRATCH:-}" ] || return 0
|
|
57
|
-
git -C "$ATTR_REPO" worktree remove --force "$ATTR_SCRATCH" >/dev/null 2>&1
|
|
57
|
+
if git -C "$ATTR_REPO" worktree remove --force "$ATTR_SCRATCH" >/dev/null 2>&1; then
|
|
58
|
+
forge_worktree_event removed "$ATTR_PLAN" "$ATTR_REPO" "$ATTR_SCRATCH" - attribute
|
|
59
|
+
fi
|
|
58
60
|
rm -rf "$ATTR_SCRATCH"
|
|
59
61
|
git -C "$ATTR_REPO" worktree prune >/dev/null 2>&1
|
|
60
62
|
return 0
|
|
@@ -80,6 +82,7 @@ attribute_verify() { # attribute_verify <k>
|
|
|
80
82
|
ATTR_REASON="could not create the scratch worktree for prefix $k: $(tail -1 "$dir/worktree.out")"
|
|
81
83
|
return 2
|
|
82
84
|
fi
|
|
85
|
+
forge_worktree_event created "$ATTR_PLAN" "$ATTR_REPO" "$ATTR_SCRATCH" - attribute
|
|
83
86
|
note "attribute: verifying prefix $k of $ATTR_N (${commit:0:12})"
|
|
84
87
|
populate_submodules "$ATTR_REPO" "$ATTR_SCRATCH" "$dir" "prefix $k"
|
|
85
88
|
setup_cmd="$(worktree_setup_command "$ATTR_PLAN" "$ATTR_REPO")"
|
|
@@ -187,6 +190,7 @@ attribute_write_log() { # attribute_write_log <prefix k>
|
|
|
187
190
|
local k="$1" commit id dir log tmp
|
|
188
191
|
commit="$(attribute_commit "$k")"
|
|
189
192
|
id="$(awk -F'\t' -v k="$k" '$1 == k { print $3; exit }' "$ATTR_DIR/merges.tsv")"
|
|
193
|
+
case "$id" in adopt-*) return 0 ;; esac # no task dir: the summary names the range
|
|
190
194
|
dir="$ATTR_DIR/$k-${commit:0:12}"
|
|
191
195
|
log="$dir/verification.log"
|
|
192
196
|
[ -f "$log" ] || log="$ATTR_PLAN/verification.log" # the tip, known FAIL from the run itself
|
|
@@ -340,8 +344,12 @@ attribute_search() { # attribute_search <plan> <force 0|1>
|
|
|
340
344
|
: > "$ATTR_DIR/steps.tsv"
|
|
341
345
|
|
|
342
346
|
# The merges, oldest first, as forge-sweep.py merged_since reads the subjects.
|
|
347
|
+
# An adopted range is a step of its own, named for its tip: it can break verification as a merge can.
|
|
343
348
|
git -C "$ATTR_REPO" log --first-parent --reverse --format='%H %s' "$ATTR_BASE..$ATTR_TIP" 2>/dev/null \
|
|
344
|
-
| awk
|
|
349
|
+
| awk -v tips="$(awk -F'\t' '{ printf "%s ", $3 }' "$ATTR_PLAN/adoptions.tsv" 2>/dev/null)" '
|
|
350
|
+
BEGIN { split(tips, t, " "); for (i in t) adopted[t[i]] = 1 }
|
|
351
|
+
{ if ($1 in adopted) { n++; printf "%d\t%s\tadopt-%s\n", n, $1, substr($1, 1, 12) }
|
|
352
|
+
else if (match($0, /^[0-9a-f]+ forge: merge [^ ]+ *$/)) { n++; printf "%d\t%s\t%s\n", n, $1, $4 } }' > "$ATTR_DIR/merges.tsv"
|
|
345
353
|
ATTR_N="$(wc -l < "$ATTR_DIR/merges.tsv" | tr -d ' ')"
|
|
346
354
|
|
|
347
355
|
# The run's own predicate. Lanes win: a lanes verification leaves a verification.command that
|