@giamme/forge 0.13.0 → 0.14.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/SKILL.md +17 -11
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +1 -0
  5. package/docs/commands.md +121 -7
  6. package/docs/development.md +3 -0
  7. package/docs/forge-ui.md +7 -1
  8. package/docs/reviews.md +2 -0
  9. package/docs/troubleshooting.md +5 -1
  10. package/forge +28 -1
  11. package/package.json +1 -1
  12. package/references/dataset.md +3 -1
  13. package/references/decision-models.md +5 -1
  14. package/references/decompose.md +199 -61
  15. package/references/runtime.md +29 -0
  16. package/references/ui.md +10 -0
  17. package/scripts/forge-compare.py +491 -0
  18. package/scripts/forge-config.py +3 -3
  19. package/scripts/forge-contract.py +34 -8
  20. package/scripts/forge-control.py +105 -13
  21. package/scripts/forge-dispatch.sh +9 -5
  22. package/scripts/forge-jev-options.sh +17 -4
  23. package/scripts/forge-ledger.py +387 -0
  24. package/scripts/forge-lib-plans.sh +16 -2
  25. package/scripts/forge-lib-task.sh +390 -28
  26. package/scripts/forge-parallel-options.sh +20 -4
  27. package/scripts/forge-parallel.sh +118 -12
  28. package/scripts/forge-plan-check.py +68 -3
  29. package/scripts/forge-pr.py +276 -0
  30. package/scripts/forge-route.py +350 -34
  31. package/scripts/forge-runs.py +18 -1
  32. package/scripts/forge-runtime.py +23 -7
  33. package/scripts/forge-schedule.py +303 -46
  34. package/scripts/forge-solo.sh +1 -0
  35. package/scripts/forge-ui-options.sh +25 -0
  36. package/scripts/forge-verify-failed.py +111 -0
  37. package/scripts/forge-watch.py +372 -0
  38. package/scripts/forge_dataset/export.py +87 -41
  39. package/scripts/forge_dataset/harvest.py +3 -1
  40. package/scripts/forge_decide/budget.py +39 -8
  41. package/scripts/forge_decide/doctor.py +49 -0
  42. package/scripts/forge_fractal/cli.py +23 -6
  43. package/scripts/forge_infra.py +274 -0
  44. package/scripts/forge_jev/client.py +13 -9
  45. package/ui/docs/api.md +83 -15
  46. package/ui/forge_ui/control.py +11 -3
  47. package/ui/forge_ui/export.py +6 -2
  48. package/ui/forge_ui/models.py +16 -16
  49. package/ui/forge_ui/reader.py +217 -13
  50. package/ui/forge_ui/repos.py +428 -0
  51. package/ui/forge_ui/static/app.js +24 -5
  52. package/ui/forge_ui/static/checksview.js +20 -7
  53. package/ui/forge_ui/static/cloudmodel.js +8 -5
  54. package/ui/forge_ui/static/controls.js +6 -3
  55. package/ui/forge_ui/static/modelstats.js +12 -8
  56. package/ui/forge_ui/static/panel.js +69 -4
  57. package/ui/forge_ui/static/runmodel.js +55 -10
  58. package/ui/forge_ui/static/scene3d.js +3 -2
  59. package/ui/forge_ui/static/settings.js +147 -29
  60. package/ui/forge_ui/static/style.css +49 -7
@@ -0,0 +1,387 @@
1
+ #!/usr/bin/env python3
2
+ """The findings ledger (GitHub #69, part 1): what each task's reviews found, and whether they converge.
3
+
4
+ A task can fail review round after round, each round with new findings, and nothing in forge
5
+ notices. This keeps one row per review of a task in tasks/<id>/ledger.tsv and computes a signal
6
+ over the last rows. A later change wires the signal into the runner; this file is the measurement.
7
+
8
+ append <plan> <id>
9
+ Appends the row of the task's latest review with a PASS or FAIL verdict. A review already in
10
+ the ledger is not added twice. Exits 0 when there is nothing to append.
11
+ signal <task-dir> [--window N] [--share S]
12
+ Prints `fire<TAB><summary>` and exits 0 when the signal fires; exits 1 (printing nothing) when not.
13
+ replay <plan-dir> [--window N]
14
+ Rebuilds every task's rows from its review dirs, in order, and prints them with the row where
15
+ the signal would first fire. Writes nothing. For calibration, and for runs recorded before
16
+ the ledger existed. Unlike the runner it does not apply decisions.tsv.
17
+
18
+ The window defaults to <plan>/converge_window when that file exists, else 4. Stdlib only.
19
+ """
20
+ from __future__ import annotations
21
+
22
+ import argparse
23
+ import importlib.util
24
+ import json
25
+ import re
26
+ import sys
27
+ from pathlib import Path
28
+
29
+ COLUMNS = ('epoch', 'attempt', 'review', 'verdict', 'gate', 'worst', 'confirmed', 'new', 'carried',
30
+ 'diff_bytes', 'delta_bytes')
31
+ DEFAULT_WINDOW = 4
32
+ DEFAULT_SHARE = 0.5
33
+ JACCARD = 0.5
34
+
35
+ _VERDICT = re.compile(r'^FORGE_VERDICT: (PASS|FAIL)([ \t]+(—|–|-)( .*)?)?[ \t]*$')
36
+ # What a finding block leads with before its location: the bullet, then tags such as `[P1]`,
37
+ # `[CONFIRMED]`, `P1:` or `(P2)`. A bracketed or parenthesised tag never holds a line number, so a
38
+ # location wrapped in brackets is not taken for a tag.
39
+ _TAGS = re.compile(r'(?:\s*(?:\[(?![^\]\n]*:\d)[^\]\n]*\]|\((?![^)\n]*:\d)[^)\n]*\)|[-+•–]|\d{1,3}[.)]\s|#{1,6}'
40
+ r'|P[0-3](?![\w/.\\-])[:.]?|CONFIRMED\b|PLAUSIBLE\b|UNSTATED\b))*\s*')
41
+ # Markdown emphasis and code marks are never part of a path: `**src/a.py:10**` names src/a.py.
42
+ _MARKUP = re.compile(r'[*`]')
43
+ # The file of a finding's location: everything up to the `:line` that follows it. A path may hold spaces
44
+ # (`src/first dir/cache.py:10`), so it is not cut at the first space; it stops before a ` — ` or `: `.
45
+ _LOCATION = re.compile(r'((?:(?!\s[—–-]\s|:\s).)+?):\d+')
46
+ _LEADING = re.compile(r'^[^\w./\\-]+')
47
+ _EXTENSION = re.compile(r'\.\w+$')
48
+ _WORD = re.compile(r'[a-z]{4,}')
49
+
50
+
51
+ def _load_contract():
52
+ """forge-contract.py, loaded by path: its file name is not importable (forge-issues.py does the same)."""
53
+ path = Path(__file__).resolve().parent / 'forge-contract.py'
54
+ spec = importlib.util.spec_from_file_location('forge_contract', path)
55
+ module = importlib.util.module_from_spec(spec)
56
+ spec.loader.exec_module(module)
57
+ return module
58
+
59
+
60
+ contract = _load_contract()
61
+
62
+
63
+ # --- matching findings -----------------------------------------------------------
64
+
65
+ def _file(finding):
66
+ """The file a finding names, from its first line; None when the finding names no file."""
67
+ first = _MARKUP.sub('', finding.text.split('\n', 1)[0])
68
+ match = _LOCATION.match(first, _TAGS.match(first).end())
69
+ if match is None:
70
+ return None
71
+ path = _LEADING.sub('', match.group(1)).removeprefix('./')
72
+ return path if _is_file(path) else None
73
+
74
+
75
+ def _is_file(path: str) -> bool:
76
+ """A path names a file when its last part has an extension (`cache.py`) or has no space (`Dockerfile`,
77
+ `one/Makefile`). A last part with a space is prose that happens to end in `:digits`, as in `runs 3:30`."""
78
+ last = re.split(r'[/\\]', path)[-1]
79
+ return bool(last) and (bool(_EXTENSION.search(last)) or ' ' not in last)
80
+
81
+
82
+ def _words(finding) -> set:
83
+ return set(_WORD.findall(finding.text.lower()))
84
+
85
+
86
+ def same_finding(a, b) -> bool:
87
+ """The same problem, reworded: the same file (two unlocated findings count), and content words
88
+ that overlap by at least JACCARD. Both arguments are Findings from forge-contract.parse_findings."""
89
+ if _file(a) != _file(b):
90
+ return False
91
+ ours, theirs = _words(a), _words(b)
92
+ union = ours | theirs
93
+ return bool(union) and len(ours & theirs) / len(union) >= JACCARD
94
+
95
+
96
+ def verdict_of(text: str) -> str:
97
+ """forge_verdict (forge-artifact.sh) in Python: only a standalone last line counts."""
98
+ lines = [line for line in text.splitlines() if line.strip()]
99
+ match = _VERDICT.match(lines[-1].rstrip('\r')) if lines else None
100
+ return match.group(1) if match else 'UNKNOWN'
101
+
102
+
103
+ def _confirmed(text: str) -> list:
104
+ return [finding for finding in contract.parse_findings(text) if finding.status == 'CONFIRMED']
105
+
106
+
107
+ # --- reading a task dir ----------------------------------------------------------
108
+
109
+ def _read(path: Path):
110
+ try:
111
+ return path.read_text(encoding='utf-8', errors='replace')
112
+ except OSError:
113
+ return None
114
+
115
+
116
+ def _json(path: Path) -> dict:
117
+ try:
118
+ value = json.loads(path.read_text(encoding='utf-8'))
119
+ except (OSError, ValueError):
120
+ return {}
121
+ return value if isinstance(value, dict) else {}
122
+
123
+
124
+ def _int(text):
125
+ return int(text.strip()) if text is not None and text.strip().isdigit() else None
126
+
127
+
128
+ def _size(path: Path):
129
+ return path.stat().st_size if path.is_file() else '-'
130
+
131
+
132
+ def _started(review: Path) -> float:
133
+ started = _json(review / 'metrics.json').get('wall_started')
134
+ if isinstance(started, (int, float)):
135
+ return float(started)
136
+ return (review / 'qa.last').stat().st_mtime
137
+
138
+
139
+ def _attempt_rows(task_dir: Path) -> list:
140
+ rows = []
141
+ for line in (_read(task_dir / 'attempts.tsv') or '').splitlines():
142
+ fields = line.split('\t')
143
+ if len(fields) >= 2 and fields[0].isdigit() and fields[1].isdigit():
144
+ rows.append((int(fields[0]), int(fields[1])))
145
+ return rows
146
+
147
+
148
+ def _attempt_of(task_dir: Path, started: float) -> int:
149
+ """The attempt a review belongs to. A review dir records no attempt number, but attempts.tsv
150
+ gets one row per attempt, written when the attempt ends. So the first row written at or after
151
+ the review started is its attempt. The row's epoch is whole seconds (date +%s), but the review's
152
+ start is compared exactly: a review that starts at 100.9 after an attempt recorded at 100 is the
153
+ next attempt, not that one. A review after the last recorded attempt (still running, or not yet
154
+ recorded) is the attempt the counter holds. A QA-only resume after an infrastructure stop maps
155
+ to the attempt after the stopped one: the mapping is approximate there."""
156
+ for epoch, attempt in _attempt_rows(task_dir):
157
+ if started <= epoch:
158
+ return attempt
159
+ return _int(_read(task_dir / 'attempt')) or 0
160
+
161
+
162
+ def _gate(task_dir: Path) -> str:
163
+ """The decision column of qa.gate: the latest review's gate, or `-`."""
164
+ fields = (_read(task_dir / 'qa.gate') or '').split('\n', 1)[0].split('\t')
165
+ return fields[1] if len(fields) > 1 and fields[1] else '-'
166
+
167
+
168
+ def review_dirs(task_dir: Path) -> list:
169
+ """The task's review dirs (attempts/qa-<uuid>/) with a PASS or FAIL verdict, oldest first."""
170
+ found = []
171
+ for review in (task_dir / 'attempts').glob('qa-*'):
172
+ text = _read(review / 'qa.last')
173
+ if text is not None and verdict_of(text) != 'UNKNOWN':
174
+ found.append(review)
175
+ return sorted(found, key=lambda review: (_started(review), review.name))
176
+
177
+
178
+ def review_row(task_dir: Path, review: Path, previous, gate: str = '-') -> dict:
179
+ """One ledger row for a review. `previous` is the review before it, or None for the first.
180
+
181
+ A CONFIRMED finding is carried when a CONFIRMED finding of the previous review matches it
182
+ (same_finding); each previous finding carries at most one. Otherwise it is new. The first
183
+ review's findings are all new. diff_bytes and delta_bytes are the task's current changes.diff
184
+ and changes.since.diff, so they are the reviewed diff for the latest review only.
185
+ """
186
+ text = _read(review / 'qa.last') or ''
187
+ confirmed = _confirmed(text)
188
+ unused = _confirmed(_read(previous / 'qa.last') or '') if previous is not None else []
189
+ carried = 0
190
+ for finding in confirmed:
191
+ hit = next((i for i, other in enumerate(unused) if same_finding(finding, other)), None)
192
+ if hit is not None:
193
+ del unused[hit]
194
+ carried += 1
195
+ labelled = [finding.severity for finding in confirmed if finding.severity is not None]
196
+ started = _started(review)
197
+ return dict(
198
+ epoch=int(started), attempt=_attempt_of(task_dir, started), review=review.name,
199
+ verdict=verdict_of(text), gate=gate, worst='P%d' % min(labelled) if labelled else '-',
200
+ confirmed=len(confirmed), new=len(confirmed) - carried, carried=carried,
201
+ diff_bytes=_size(task_dir / 'changes.diff'), delta_bytes=_size(task_dir / 'changes.since.diff'))
202
+
203
+
204
+ def task_rows(task_dir: Path) -> list:
205
+ """Every review row of a task, rebuilt from its review dirs in order."""
206
+ reviews = review_dirs(task_dir)
207
+ rows = []
208
+ for index, review in enumerate(reviews):
209
+ previous = reviews[index - 1] if index else None
210
+ gate = _gate(task_dir) if index == len(reviews) - 1 else '-'
211
+ rows.append(review_row(task_dir, review, previous, gate))
212
+ return rows
213
+
214
+
215
+ def _value(text: str):
216
+ return int(text) if text.isdigit() else text
217
+
218
+
219
+ def read_ledger(path: Path) -> list:
220
+ rows = []
221
+ for line in (_read(path) or '').splitlines():
222
+ fields = line.split('\t')
223
+ if len(fields) == len(COLUMNS):
224
+ rows.append({name: _value(text) for name, text in zip(COLUMNS, fields)})
225
+ return rows
226
+
227
+
228
+ def format_row(row: dict) -> str:
229
+ return '\t'.join(str(row[name]) for name in COLUMNS)
230
+
231
+
232
+ def after_decision(rows: list, decisions_path: Path) -> list:
233
+ """The rows whose attempt is later than the last attempt in decisions.tsv (epoch, attempt,
234
+ choice, reason). A decision restarts the count: with no decisions file, every row counts."""
235
+ decided = []
236
+ for line in (_read(Path(decisions_path)) or '').splitlines():
237
+ fields = line.split('\t')
238
+ if len(fields) > 1 and fields[1].isdigit():
239
+ decided.append(int(fields[1]))
240
+ if not decided:
241
+ return list(rows)
242
+ last = max(decided)
243
+ return [row for row in rows if row['attempt'] > last]
244
+
245
+
246
+ # --- the signal ------------------------------------------------------------------
247
+
248
+ def _failed(row: dict) -> bool:
249
+ return row['verdict'] == 'FAIL' or row['gate'] == 'fail'
250
+
251
+
252
+ def _severity(worst: str) -> int:
253
+ """P0 is the most severe. An unlabelled CONFIRMED finding blocks at every threshold, so `-` ranks as P0."""
254
+ return 0 if worst == '-' else int(worst[1:])
255
+
256
+
257
+ def converging(rows: list, window: int = DEFAULT_WINDOW, share: float = DEFAULT_SHARE):
258
+ """Whether the last `window` reviews are a moving target, and a one-line summary either way.
259
+
260
+ It fires when every one of those reviews failed (verdict FAIL, or the gate turned it into a
261
+ fail) with at least one CONFIRMED finding; when the findings of reviews 2..window are new at
262
+ least `share` of the time; and when the last review's worst severity is no better than the
263
+ first's. Window 0 never fires, and neither does window 1: there is nothing to compare.
264
+ """
265
+ if window < 2:
266
+ return False, 'window %d never fires' % window
267
+ if len(rows) < window:
268
+ return False, 'fewer than %d reviews' % window
269
+ recent = rows[-window:]
270
+ if not all(_failed(row) and row['confirmed'] for row in recent):
271
+ return False, 'a review in the window passed, or had no CONFIRMED finding'
272
+ later = recent[1:]
273
+ new = sum(row['new'] for row in later)
274
+ confirmed = sum(row['confirmed'] for row in later)
275
+ first, last = recent[0]['worst'], recent[-1]['worst']
276
+ if new / confirmed < share:
277
+ return False, '%d of %d findings new' % (new, confirmed)
278
+ if _severity(last) > _severity(first):
279
+ return False, 'worst improved %s → %s' % (first, last)
280
+ return True, '%d failed reviews in a row, %d of %d findings new, worst %s → %s' % (
281
+ window, new, confirmed, first, last)
282
+
283
+
284
+ def first_fire(rows: list, window: int, share: float):
285
+ """(row count, summary) at the first row where the signal fires, or None."""
286
+ for count in range(1, len(rows) + 1):
287
+ fired, summary = converging(rows[:count], window, share)
288
+ if fired:
289
+ return count, summary
290
+ return None
291
+
292
+
293
+ # --- command line ----------------------------------------------------------------
294
+
295
+ def _window(plan: Path, given) -> int:
296
+ if given is not None:
297
+ return given
298
+ text = _read(plan / 'converge_window')
299
+ try:
300
+ return int(text) if text is not None else DEFAULT_WINDOW
301
+ except ValueError:
302
+ return DEFAULT_WINDOW
303
+
304
+
305
+ def _append(plan: Path, task_id: str) -> int:
306
+ task_dir = plan / 'tasks' / task_id
307
+ reviews = review_dirs(task_dir) if task_dir.is_dir() else []
308
+ if not reviews:
309
+ return 0
310
+ latest = reviews[-1]
311
+ ledger = task_dir / 'ledger.tsv'
312
+ if any(row['review'] == latest.name for row in read_ledger(ledger)):
313
+ return 0
314
+ previous = reviews[-2] if len(reviews) > 1 else None
315
+ row = review_row(task_dir, latest, previous, _gate(task_dir))
316
+ with ledger.open('a', encoding='utf-8') as handle:
317
+ handle.write(format_row(row) + '\n')
318
+ return 0
319
+
320
+
321
+ def _signal(task_dir: Path, window, share: float) -> int:
322
+ task_dir = task_dir.resolve()
323
+ rows = after_decision(read_ledger(task_dir / 'ledger.tsv'), task_dir / 'decisions.tsv')
324
+ fired, summary = converging(rows, _window(task_dir.parent.parent, window), share)
325
+ if not fired:
326
+ return 1
327
+ print('fire\t' + summary)
328
+ return 0
329
+
330
+
331
+ def _replay(plan: Path, window) -> int:
332
+ if not plan.is_dir():
333
+ sys.stderr.write('forge-ledger: no plan directory %s\n' % plan)
334
+ return 2
335
+ size = _window(plan, window)
336
+ for task_dir in sorted(path for path in (plan / 'tasks').glob('*') if path.is_dir()):
337
+ rows = task_rows(task_dir)
338
+ if not rows:
339
+ continue
340
+ fire = first_fire(rows, size, DEFAULT_SHARE)
341
+ print(task_dir.name)
342
+ print(' attempt verdict gate confirmed new worst')
343
+ for count, row in enumerate(rows, 1):
344
+ line = ' %7d %-7s %-6s %9d %3d %s' % (
345
+ row['attempt'], row['verdict'], row['gate'], row['confirmed'], row['new'], row['worst'])
346
+ if fire is not None and count == fire[0]:
347
+ line += ' <- signal fires: ' + fire[1]
348
+ print(line)
349
+ if fire is None:
350
+ print(' the signal does not fire')
351
+ return 0
352
+
353
+
354
+ def _parser() -> argparse.ArgumentParser:
355
+ parser = argparse.ArgumentParser(
356
+ prog='forge-ledger.py', formatter_class=argparse.RawDescriptionHelpFormatter,
357
+ description='The findings ledger of a task, and the signal for reviews that do not converge.',
358
+ epilog='The signal fires when the last N reviews of a task all failed, mostly with new findings, '
359
+ 'and the worst severity did not improve. Calibrated: window 4 (the default) stopped no task '
360
+ 'that later passed. Exit codes: append 0; signal 0 fired, 1 did not; replay 0 (2 for a missing plan).')
361
+ sub = parser.add_subparsers(dest='command', required=True)
362
+ append = sub.add_parser('append', help="append the task's latest review to tasks/<id>/ledger.tsv")
363
+ append.add_argument('plan', help='the plan directory')
364
+ append.add_argument('id', help='the task id')
365
+ signal = sub.add_parser('signal', help='print fire<TAB>summary when the signal fires (exit 0), else exit 1')
366
+ signal.add_argument('task_dir', help='tasks/<id> of the plan')
367
+ signal.add_argument('--window', type=int, default=None, metavar='N',
368
+ help='reviews the signal looks at (default: <plan>/converge_window, else %d)' % DEFAULT_WINDOW)
369
+ signal.add_argument('--share', type=float, default=DEFAULT_SHARE, metavar='S',
370
+ help='least share of the findings of reviews 2..N that must be new (default %s)' % DEFAULT_SHARE)
371
+ replay = sub.add_parser('replay', help='rebuild every task of a plan from its review dirs and print the signal, writing nothing')
372
+ replay.add_argument('plan_dir', help='the plan directory')
373
+ replay.add_argument('--window', type=int, default=None, metavar='N', help='as for signal')
374
+ return parser
375
+
376
+
377
+ def main(argv=None) -> int:
378
+ args = _parser().parse_args(argv)
379
+ if args.command == 'append':
380
+ return _append(Path(args.plan), args.id)
381
+ if args.command == 'signal':
382
+ return _signal(Path(args.task_dir), args.window, args.share)
383
+ return _replay(Path(args.plan_dir), args.window)
384
+
385
+
386
+ if __name__ == '__main__':
387
+ sys.exit(main())
@@ -147,7 +147,7 @@ plans_why_not() { # plans_why_not <plan> <id> <status>: exit 3 with advice for a
147
147
  ERROR|TIMEOUT|INFRA|INTERRUPTED) die "task '$id' is $st: no reviewer verdict exists to override. Use 'forge-parallel.sh retry $plan $id' (or 'run')" 3 ;;
148
148
  BLOCKED|PENDING) die "task '$id' is $st: it has not been reviewed yet, so there is nothing to override" 3 ;;
149
149
  RUNNING) die "task '$id' is RUNNING (or a run was killed): re-run 'forge-parallel.sh run $plan' so it settles first" 3 ;;
150
- *) die "task '$id' has status '$st'; only a FAIL or UNKNOWN task can be accepted" 3 ;;
150
+ *) die "task '$id' has status '$st'; only a FAIL, UNKNOWN or NEEDS_DECISION task can be accepted" 3 ;;
151
151
  esac
152
152
  }
153
153
 
@@ -192,7 +192,16 @@ do_accept() {
192
192
  int_wt="$(cat "$PLAN/wt_root")/_integration"
193
193
 
194
194
  st="$(task_status "$PLAN" "$id")"
195
- case "$st" in FAIL|UNKNOWN) ;; *) plans_why_not "$PLAN" "$id" "$st" ;; esac
195
+ case "$st" in
196
+ FAIL|UNKNOWN) ;;
197
+ NEEDS_DECISION)
198
+ # The attempt cap stops a task from any status: only a reviewed one has a verdict to override.
199
+ st="$(decision_from "$tdir")"
200
+ case "$st" in FAIL|UNKNOWN) ;; *)
201
+ die "task '$id' stopped for a decision after a $st attempt: no reviewer verdict exists to override. Decide with 'forge-parallel.sh retry $PLAN $id --decide retry=N --reason \"...\" --approved' (see $tdir/decision.md)" 3 ;;
202
+ esac ;;
203
+ *) plans_why_not "$PLAN" "$id" "$st" ;;
204
+ esac
196
205
 
197
206
  # The reviewed work must be exactly what is on disk: same commit on the branch, same
198
207
  # tree, index and HEAD in the worktree as when QA finished.
@@ -500,6 +509,9 @@ Retry or accept them (or split them off into their own plan) first." 3
500
509
  for p in "${SRC[@]}"; do awk -F'\t' '!/^#/ && NF' "$p/tasks.tsv"; done
501
510
  } > "$tsv" || ok=0
502
511
  printf '%s\n' "$repo_text" > "$NEW/repo" || ok=0
512
+ # The same repository as the first source, so its identity carries over (none when it has none).
513
+ # Best effort: a copy that fails leaves no file and never fails the combine.
514
+ [ ! -f "${SRC[0]}/repo.identity" ] || cp -p "${SRC[0]}/repo.identity" "$NEW/repo.identity" 2>/dev/null || rm -f "$NEW/repo.identity"
503
515
  printf '%s\n' "$NEWRID" > "$NEW/run_id" || ok=0
504
516
  printf '%s\n' "$NEWWTR" > "$NEW/wt_root" || ok=0
505
517
  git -C "$NEWINT" rev-parse HEAD > "$NEW/accepted.integration" || ok=0
@@ -750,6 +762,8 @@ except Exception:
750
762
  }' "$T"
751
763
  } > "$NEW/tasks.tsv" || ok=0
752
764
  printf '%s\n' "$repo_text" > "$NEW/repo" || ok=0
765
+ # Best effort, as in combine: a copy that fails leaves no file and never fails the split.
766
+ [ ! -f "$PLAN/repo.identity" ] || cp -p "$PLAN/repo.identity" "$NEW/repo.identity" 2>/dev/null || rm -f "$NEW/repo.identity"
753
767
  printf '%s\n' "$NEWRID" > "$NEW/run_id" || ok=0
754
768
  printf '%s\n' "$NEWWTR" > "$NEW/wt_root" || ok=0
755
769
  printf '%s\n' "$acc" > "$NEW/accepted.integration" || ok=0