@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/SKILL.md +47 -14
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +1 -1
  5. package/docs/commands.md +302 -9
  6. package/docs/forge-ui.md +14 -0
  7. package/docs/memory.md +22 -0
  8. package/docs/models.md +53 -0
  9. package/docs/reviews.md +7 -0
  10. package/forge +11 -0
  11. package/package.json +1 -1
  12. package/references/dataset.md +16 -4
  13. package/references/decompose.md +154 -9
  14. package/references/harnesses.md +21 -1
  15. package/references/planning.md +59 -0
  16. package/references/solo.md +5 -1
  17. package/references/ui.md +48 -1
  18. package/scripts/forge-artifact.sh +53 -0
  19. package/scripts/forge-compare.py +6 -3
  20. package/scripts/forge-config.py +531 -4
  21. package/scripts/forge-contract.py +55 -8
  22. package/scripts/forge-control.py +0 -2
  23. package/scripts/forge-dispatch.sh +84 -14
  24. package/scripts/forge-fail-first.py +3 -1
  25. package/scripts/forge-guard.py +247 -8
  26. package/scripts/forge-issues.py +12 -0
  27. package/scripts/forge-lib-adopt.sh +260 -0
  28. package/scripts/forge-lib-attribute.sh +10 -2
  29. package/scripts/forge-lib-plans.sh +35 -6
  30. package/scripts/forge-lib-review.sh +13 -5
  31. package/scripts/forge-lib-task.sh +138 -5
  32. package/scripts/forge-memory.sh +41 -4
  33. package/scripts/forge-metrics.sh +7 -0
  34. package/scripts/forge-parallel-options.sh +12 -6
  35. package/scripts/forge-parallel.sh +659 -32
  36. package/scripts/forge-plan-check.py +591 -8
  37. package/scripts/forge-planner.py +480 -0
  38. package/scripts/forge-route.py +16 -2
  39. package/scripts/forge-runs-rm.py +23 -7
  40. package/scripts/forge-runtime.py +111 -2
  41. package/scripts/forge-schedule.py +5 -2
  42. package/scripts/forge-shadow.py +53 -7
  43. package/scripts/forge-solo.sh +87 -7
  44. package/scripts/forge_dataset/cli.py +26 -0
  45. package/scripts/forge_dataset/efforts.py +215 -0
  46. package/scripts/forge_dataset/export.py +1 -0
  47. package/scripts/forge_dataset/harvest.py +55 -0
  48. package/scripts/forge_dataset/history.py +126 -0
  49. package/scripts/forge_dataset/worktrees.py +95 -0
  50. package/scripts/forge_decide/__init__.py +19 -1
  51. package/scripts/forge_decide/builtin_profiles.json +25 -0
  52. package/scripts/forge_decide/cli.py +12 -0
  53. package/scripts/forge_decide/profiles.py +866 -0
  54. package/scripts/forge_decide/resolve.py +38 -6
  55. package/scripts/forge_memory_list.py +153 -0
  56. package/scripts/forge_worktrees.py +88 -0
  57. package/ui/README.md +31 -0
  58. package/ui/docs/api.md +168 -12
  59. package/ui/forge_ui/__init__.py +14 -1
  60. package/ui/forge_ui/__main__.py +1 -1
  61. package/ui/forge_ui/control.py +250 -12
  62. package/ui/forge_ui/executions.py +28 -8
  63. package/ui/forge_ui/findings.py +7 -0
  64. package/ui/forge_ui/models.py +60 -1
  65. package/ui/forge_ui/projects.py +571 -0
  66. package/ui/forge_ui/reader.py +48 -8
  67. package/ui/forge_ui/static/app.js +99 -21
  68. package/ui/forge_ui/static/cloudui.js +6 -2
  69. package/ui/forge_ui/static/convo.js +1 -1
  70. package/ui/forge_ui/static/diffview.js +2 -2
  71. package/ui/forge_ui/static/files.js +1 -1
  72. package/ui/forge_ui/static/index.html +5 -1
  73. package/ui/forge_ui/static/leaderboard.js +5 -1
  74. package/ui/forge_ui/static/modelstats.js +25 -1
  75. package/ui/forge_ui/static/panel.js +47 -4
  76. package/ui/forge_ui/static/projectsview.js +372 -0
  77. package/ui/forge_ui/static/settings.js +924 -29
  78. package/ui/forge_ui/static/style.css +116 -3
  79. package/ui/forge_ui/static/uikit.js +94 -1
  80. package/ui/forge_ui/static/worktreesview.js +250 -0
  81. package/ui/forge_ui/worktrees.py +570 -0
@@ -55,7 +55,7 @@ lowercase prose do not count. The severity is the first P0-P3 token of the block
55
55
  line (`[P2]`, `(P2)`, `**P2**`, `P2:`, `P2 -` or a standalone `P2`; uppercase only).
56
56
 
57
57
  Phantom findings. A reviewer may echo the contract it was given. Three layers keep that
58
- from creating findings or blocking: (1) FORGE_VERDICT and FORGE_LEARNING text is removed
58
+ from creating findings or blocking: (1) FORGE_VERDICT, FORGE_LEARNING and FORGE_TESTS text is removed
59
59
  before parsing (the verdict line itself says "CONFIRMED"); (2) any line that is a
60
60
  contiguous fragment of this module's own contract text (all parts, kinds and thresholds,
61
61
  whitespace-collapsed, at least 25 characters, list marker ignored) is removed, which
@@ -78,7 +78,7 @@ import sys
78
78
 
79
79
  SEVERITIES = ('P0', 'P1', 'P2', 'P3')
80
80
  PLACEHOLDER = 'path/file.py:123'
81
- KINDS = ('task', 'final', 'solo', 'sweep')
81
+ KINDS = ('task', 'final', 'solo', 'sweep', 'adopt')
82
82
  DEFAULT_THRESHOLD = 'P2'
83
83
  QA_TEST_MINUTES = 5 # the reviewer's own test time, beyond which it says the check is too broad (#89)
84
84
 
@@ -130,6 +130,12 @@ _HEAD = {
130
130
  'diff did not change, and do not report other problems you notice there: they are not this',
131
131
  "task's work.",
132
132
  ] + _NO_TRUST,
133
+ 'adopt': [
134
+ "This range was made outside forge, by a person or another agent, and is about to enter this run's",
135
+ 'integration branch. Review the diff below for correctness bugs, and for whether it does what the',
136
+ 'reason above says. Also say if it changes anything that reason does not cover.',
137
+ "Do not trust the reason's claims about which checks ran or passed; judge the diff itself.",
138
+ ],
133
139
  'final': [
134
140
  'This is the final, whole-run review. The diff below is the COMBINED result of several',
135
141
  'tasks that were implemented independently and each reviewed on its own slice only.',
@@ -163,7 +169,12 @@ _VERIFY = [
163
169
  'spend at most about %d minutes running tests. Use any test evidence forge gives you above' % QA_TEST_MINUTES,
164
170
  'before running a test yourself. When the targeted tests would take longer, or the change',
165
171
  'touches shared infrastructure (a test helper, a build file, a lockfile), say so instead of',
166
- 'running everything.',
172
+ 'running everything. If a test needs a dependency your checkout does not have, do not look for',
173
+ 'it elsewhere and do not install anything: report that it could not run.',
174
+ 'Say whether tests ran, on a line of its own before the verdict, in exactly one of these forms:',
175
+ ' FORGE_TESTS: RAN',
176
+ ' FORGE_TESTS: NOT NEEDED — why',
177
+ ' FORGE_TESTS: COULD NOT RUN — why',
167
178
  ]
168
179
 
169
180
  _SEVERITY = [
@@ -225,7 +236,7 @@ def qa_text(part: str, kind: str = 'task', threshold=None) -> str:
225
236
  if part != 'tail':
226
237
  raise ValueError('part must be head or tail')
227
238
  lines = list(_SWEEP_FINDINGS if kind == 'sweep' else _FINDINGS)
228
- if kind in ('task', 'solo'):
239
+ if kind in ('task', 'solo', 'adopt'):
229
240
  lines += _ALL_CONFIRMED + _SOLO_EXTRA
230
241
  lines += [''] + _VERIFY
231
242
  lines += [''] + _SEVERITY
@@ -289,7 +300,7 @@ def dwarf_text(pre_review: bool = False, verify_after_merge: bool = False) -> st
289
300
 
290
301
  # --- parsing ---------------------------------------------------------------------
291
302
 
292
- _PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING):.*$')
303
+ _PROTOCOL = re.compile(r'FORGE_(?:VERDICT|LEARNING|TESTS):.*$')
293
304
  _QUOTE = re.compile(r'^\s*(?:>[ \t]?)+')
294
305
  _MARKER = re.compile(r'^(?:[-*+•–]|\d{1,3}[.)]|#{1,6})\s+')
295
306
  _HEADING = re.compile(r'^ {0,3}#{1,6}[ \t]+\S')
@@ -327,7 +338,7 @@ def _clean(text: str) -> list:
327
338
  for number, raw in enumerate(text.replace('\r\n', '\n').replace('\r', '\n').split('\n'), 1):
328
339
  raw = raw.expandtabs(4)
329
340
  line = _PROTOCOL.sub('', raw)
330
- if line != raw and not line.strip():
341
+ if line != raw and not line.strip(' \t*_`>+-'):
331
342
  continue
332
343
  line = _QUOTE.sub('', line).rstrip()
333
344
  core = _collapse(_MARKER.sub('', line.strip()))
@@ -427,6 +438,35 @@ def gate(verdict: str, text: str, threshold=None) -> GateResult:
427
438
  return GateResult(decision, worst, len(confirmed), unlabelled, len(below), below)
428
439
 
429
440
 
441
+ # A reviewer's own word on whether its tests ran (#117). Only a line of its own counts, the last one
442
+ # when it repeats: a quoted example in prose is not its report. Unlike the verdict, nothing gates on
443
+ # this line and it exists to be seen, so markup and any separator are forgiven, and a line that says
444
+ # something else is `unclear` rather than silence. The forms' own "why" is the prompt echoed.
445
+ _TESTS_LINE = re.compile(r'^[ \t>*_`+-]*FORGE_TESTS:[ \t*_`]*(.*?)[ \t*_`]*$', re.M)
446
+ _TESTS_VALUE = re.compile(r'(RAN|NOT[ _]NEEDED|COULD[ _]NOT[ _]RUN)\b(.*)$', re.I)
447
+ _TESTS_STATUS = {'RAN': 'ran', 'NOT NEEDED': 'not_needed', 'COULD NOT RUN': 'could_not_run'}
448
+ _TESTS_TRIM = ' \t—–-:()'
449
+ _TESTS_REASON_MAX = 300
450
+
451
+
452
+ def _tests_reason(text: str) -> str | None:
453
+ return ''.join(ch for ch in text.strip(_TESTS_TRIM) if ch.isprintable())[:_TESTS_REASON_MAX] or None
454
+
455
+
456
+ def tests_report(text) -> dict | None:
457
+ """{status: ran|not_needed|could_not_run|unclear, reason} from a QA reply, or None when it does not say."""
458
+ report = None
459
+ for value in _TESTS_LINE.findall((text or '').replace('\r\n', '\n')):
460
+ match = _TESTS_VALUE.match(value)
461
+ if not match:
462
+ report = dict(status='unclear', reason=_tests_reason(value))
463
+ continue
464
+ reason = _tests_reason(match.group(2))
465
+ if (reason or '').lower() != 'why':
466
+ report = dict(status=_TESTS_STATUS[match.group(1).upper().replace('_', ' ')], reason=reason)
467
+ return report
468
+
469
+
430
470
  def known_issues_text(threshold, tolerated) -> str:
431
471
  name = SEVERITIES[_rank(threshold)]
432
472
  lines = ['## Known issues (QA findings below blocking threshold %s)' % name, '',
@@ -468,8 +508,8 @@ def _parser() -> argparse.ArgumentParser:
468
508
  qa.add_argument('--part', required=True, choices=('head', 'tail'),
469
509
  help='head = review preamble, tail = findings format + verdict contract')
470
510
  qa.add_argument('--kind', choices=KINDS, default='task',
471
- help='task (default), final (whole-run review), solo (solo wording) or sweep (a finding '
472
- 'sweep task: per-finding FIXED lines, regressions only)')
511
+ help='task (default), final (whole-run review), solo (solo wording), sweep (a finding '
512
+ 'sweep task: per-finding FIXED lines, regressions only) or adopt (a range made outside forge)')
473
513
  qa.add_argument('--threshold', type=_threshold_arg, default=None, metavar='P0..P3|none',
474
514
  help='least severe level that still blocks; none = P3 (default: %s)' % DEFAULT_THRESHOLD)
475
515
  dwarf = sub.add_parser('dwarf', help='print the implementer rules block')
@@ -485,6 +525,8 @@ def _parser() -> argparse.ArgumentParser:
485
525
  % DEFAULT_THRESHOLD)
486
526
  gate_parser.add_argument('--known-issues', metavar='OUT', default=None,
487
527
  help='write tolerated findings here when there are any')
528
+ tests = sub.add_parser('tests', help='print what the reply says about its tests: status, a tab, the reason')
529
+ tests.add_argument('--qa-last', required=True, metavar='FILE', help='the QA reply')
488
530
  return parser
489
531
 
490
532
 
@@ -502,6 +544,11 @@ def main(argv=None) -> int:
502
544
  except OSError as error:
503
545
  sys.stderr.write('forge-contract: cannot read %s: %s\n' % (args.qa_last, error))
504
546
  return 3
547
+ if args.command == 'tests':
548
+ report = tests_report(text)
549
+ if report:
550
+ _emit('%s\t%s\n' % (report['status'], report['reason'] or ''))
551
+ return 0
505
552
  result = gate(args.verdict, text, args.threshold)
506
553
  if args.known_issues and result.n_below >= 1:
507
554
  temporary = args.known_issues + '.%d.tmp' % os.getpid()
@@ -845,8 +845,6 @@ def decision_of(plan, args, dwarf):
845
845
  if line.strip())
846
846
  raise Refused(f'task {args.task} is waiting for your decision, and only a decision resumes it: {head or "see decision.md"} '
847
847
  '(retry --decide retry=N | threshold=Pn, or --dwarf SPEC, each with --reason TEXT --approved)')
848
- if args.decide is not None and dwarf is not None:
849
- raise Invalid('give --decide or --dwarf, not both: a decision is one choice')
850
848
  if args.decide is not None and not DECISION.fullmatch(args.decide):
851
849
  raise Invalid('--decide takes retry=N (1 to 20) or threshold=P0|P1|P2|P3')
852
850
  reason = re.sub(r'\s+', ' ', args.reason or '').strip()
@@ -15,6 +15,11 @@
15
15
  # (claude, openclaude)
16
16
  # any role: [--no-ripwire] [--ripwire-query-file <requirements>]
17
17
  # any role: [--timeout <seconds>] 0 disables the watchdog
18
+ # any role: [--service-tier fast] codex and claude only; any other harness exits 3
19
+ # before it runs. doctor --spec takes the same option.
20
+ # forge-dispatch.sh doctor --spec <spec> [--role dwarf|qa|planner] [--service-tier fast]
21
+ # A measured slowdown is `forge: note: …` on stderr, never in
22
+ # the resolved block. A plain dispatch does not print it.
18
23
  # forge-dispatch.sh efforts --spec <spec>
19
24
  # the efforts this pairing accepts, weakest first, one per
20
25
  # line. Prints nothing when the pairing has no ladder or no
@@ -39,6 +44,7 @@
39
44
  # a dispatch killed after that result is not a timeout.
40
45
  #
41
46
  # Exit codes: 0 ok | 2 usage/resolution error | 3 harness missing or unusable
47
+ # (including a --service-tier fast the harness cannot take per invocation)
42
48
  # 4 backend ran but failed | 7 backend exceeded --timeout and was killed
43
49
  # (not when its log ended in a final result and only background tasks kept it up:
44
50
  # that result stands, as after FORGE_RESULT_GRACE; $ROLE.settled says which)
@@ -50,8 +56,9 @@
50
56
  # 9 the session was not continued (--continue-session only): the harness cannot
51
57
  # continue one, or it ran and failed. The caller may dispatch fresh; dispatch
52
58
  # never does, so each dispatch keeps its own record. $ROLE.continue says why.
53
- # A process still alive in the harness's group after it exited is killed and listed in
54
- # $ROLE.orphans (only written when there is something to list).
59
+ # A process still alive in the harness's group after it exited, or one the harness started
60
+ # that moved to a session of its own (#129), is killed and listed in $ROLE.orphans (only
61
+ # written when there is something to list). A timeout ends them the same way.
55
62
  set -uo pipefail
56
63
 
57
64
  SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -206,7 +213,7 @@ if [ "$ROLE" = report ]; then python3 "$RUNTIME" report "${1:?report needs a run
206
213
  PREFLIGHT=0
207
214
  if [ "$ROLE" = doctor ]; then
208
215
  if [ $# = 0 ]; then doctor; exit $?; fi
209
- [ "${1:-}" = --spec ] || die "doctor accepts --spec <spec> [--role dwarf|qa|planner]"
216
+ [ "${1:-}" = --spec ] || die "doctor accepts --spec <spec> [--role dwarf|qa|planner] [--service-tier fast]"
210
217
  SPEC_CHECK="${2:?--spec needs a spec}"; shift 2
211
218
  ROLE=dwarf
212
219
  if [ "${1:-}" = --role ]; then ROLE="${2:?}"; shift 2; fi
@@ -227,7 +234,7 @@ SPEC="$1"; shift
227
234
 
228
235
  RIPWIRE_QUERY=""
229
236
  OUTPUT=full
230
- REPO="$PWD"; RUN_DIR=""; PROMPT_FILE=""; YOLO=0; DRY=0; REVIEW_BASE=""; PROMPT_VIA_STDIN=0; NATIVE_REVIEW=0; CONTINUE_ID=""; CONTINUE_GIVEN=0; AGY_TIMEOUT="30m"; TIMEOUT_FLAG=""
237
+ REPO="$PWD"; RUN_DIR=""; PROMPT_FILE=""; YOLO=0; DRY=0; REVIEW_BASE=""; PROMPT_VIA_STDIN=0; NATIVE_REVIEW=0; CONTINUE_ID=""; CONTINUE_GIVEN=0; AGY_TIMEOUT="30m"; TIMEOUT_FLAG=""; SERVICE_TIER=""
231
238
  while [ $# -gt 0 ]; do
232
239
  case "$1" in
233
240
  --no-ripwire) export FORGE_RIPWIRE=off; shift ;;
@@ -241,6 +248,7 @@ while [ $# -gt 0 ]; do
241
248
  --continue-session) [ $# -ge 2 ] || die "--continue-session needs a session id"; CONTINUE_ID="$2"; CONTINUE_GIVEN=1; shift 2 ;;
242
249
  --agy-timeout) AGY_TIMEOUT="${2:?--agy-timeout needs a value}"; shift 2 ;;
243
250
  --timeout) TIMEOUT_FLAG="${2:?--timeout needs a value in seconds, 0 to disable}"; shift 2 ;;
251
+ --service-tier) [ $# -ge 2 ] || die "--service-tier needs a value"; [ "$2" = fast ] || die "--service-tier accepts only fast"; SERVICE_TIER=fast; shift 2 ;;
244
252
  --yolo) YOLO=1; shift ;;
245
253
  --dry-run) DRY=1; shift ;;
246
254
  *) die "unknown option '$1'" ;;
@@ -354,6 +362,13 @@ if [ -n "$EFFORT" ] && [ -n "$LADDER" ] && [ "$(idx_in "$EFFORT" "$LADDER")" -lt
354
362
  die "invalid effort '$EFFORT' for $HARNESS"
355
363
  fi
356
364
 
365
+ # codex and claude can ask for the fast tier on this invocation. The others cannot
366
+ # (opencode's fast mode is per-model config; the rest have none). Refuse before
367
+ # preflight, so doctor --spec and a dispatch both stop before those CLIs start.
368
+ if [ "$SERVICE_TIER" = fast ] && [ "$HARNESS" != codex ] && [ "$HARNESS" != claude ]; then
369
+ die "$HARNESS has no per-invocation fast tier (#68); drop the fast tier for the $ROLE role or pick a codex or claude spec" 3
370
+ fi
371
+
357
372
  # --- resolve timeout ----------------------------------------------------------
358
373
  # Explicit (--timeout, FORGE_TIMEOUT) wins as given, including 0. Otherwise the registry
359
374
  # row's `timeout` column, then 2700. Only those two defaults scale with the resolved
@@ -403,7 +418,7 @@ write_continue() { :; } # redefined below once there is an attempt to archive
403
418
  ATTEMPT=""
404
419
  if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
405
420
  ATTEMPT="$(python3 "$RUNTIME" begin "$RUN_DIR" "$ROLE")" || exit 3
406
- rm -f "$RUN_DIR/$ROLE.last" "$RUN_DIR/$ROLE.log" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.resolved" "$RUN_DIR/$ROLE.cmd" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.settled" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.session" "$RUN_DIR/$ROLE.continue" "$RUN_DIR/$ROLE.harness"
421
+ rm -f "$RUN_DIR/$ROLE.last" "$RUN_DIR/$ROLE.log" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.resolved" "$RUN_DIR/$ROLE.cmd" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.settled" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.session" "$RUN_DIR/$ROLE.continue" "$RUN_DIR/$ROLE.harness" "$RUN_DIR/$ROLE.tracked"
407
422
  trap 'exit 143' TERM
408
423
  trap 'exit 130' INT
409
424
  # GUARD_ON is 1 only when the harness was started in its own process group (see the
@@ -411,17 +426,22 @@ if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
411
426
  # signalled. Every wait here is bounded: this runs on the way out of an interrupted
412
427
  # dispatch and must not be the thing that hangs it.
413
428
  exit_cleanup() {
429
+ [ -z "${tpid:-}" ] || kill -TERM "$tpid" 2>/dev/null
414
430
  if [ -n "${hpid:-}" ] && kill -0 "$hpid" 2>/dev/null; then
415
431
  [ "${GUARD_ON:-0}" != 1 ] || kill -s TERM -- "-$hpid" 2>/dev/null
416
432
  pkill -TERM -P "$hpid" 2>/dev/null; kill -TERM "$hpid" 2>/dev/null
417
- if [ "${GUARD_ON:-0}" = 1 ]; then sleep 1; kill -s KILL -- "-$hpid" 2>/dev/null; fi
433
+ if [ "${GUARD_ON:-0}" = 1 ]; then
434
+ sleep 1; kill -s KILL -- "-$hpid" 2>/dev/null
435
+ # what it started in sessions of their own (#129)
436
+ python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" >/dev/null 2>&1
437
+ fi
418
438
  elif [ "${GUARD_ON:-0}" = 1 ] && [ "${reaped:-0}" != 1 ] && [ -n "${hpid:-}" ]; then
419
439
  # Interrupted after the harness exited but before the normal reap.
420
- python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" >/dev/null 2>&1
440
+ python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" >/dev/null 2>&1
421
441
  fi
422
442
  for watcher in ${wpid:-} ${spid:-}; do pkill -P "$watcher" 2>/dev/null; kill "$watcher" 2>/dev/null; done
423
443
  [ -z "${cpid:-}" ] || kill "$cpid" 2>/dev/null
424
- rm -f "$RUN_DIR/$ROLE.harness"
444
+ rm -f "$RUN_DIR/$ROLE.harness" "$RUN_DIR/$ROLE.tracked"
425
445
  }
426
446
  # What the EXIT trap's `finish` archives. Pessimistic until an outcome is known, so every
427
447
  # path out of a continue request (a signal, a usage error after this point) leaves a record.
@@ -520,6 +540,7 @@ build_cmd() {
520
540
  # subshell cd below.
521
541
  CMD=(codex exec review --json -m "$MODEL" --skip-git-repo-check -o "$LAST")
522
542
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
543
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
523
544
  if [ -n "$REVIEW_BASE" ]; then CMD+=(--base "$REVIEW_BASE"); else CMD+=(--uncommitted); fi
524
545
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox); fi
525
546
  elif [ -n "$CONTINUE_ID" ]; then
@@ -531,6 +552,7 @@ build_cmd() {
531
552
  case "$CONTINUE_ID" in -*) ;; *) CMD+=("$CONTINUE_ID") ;; esac
532
553
  CMD+=(--json -m "$MODEL" --skip-git-repo-check -o "$LAST")
533
554
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
555
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
534
556
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox)
535
557
  else CMD+=(-c 'sandbox_mode="read-only"'); fi
536
558
  case "$CONTINUE_ID" in -*) CMD+=(-- "$CONTINUE_ID") ;; esac
@@ -539,6 +561,7 @@ build_cmd() {
539
561
  else
540
562
  CMD=(codex exec --json -m "$MODEL" -C "$REPO" --skip-git-repo-check -o "$LAST")
541
563
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
564
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
542
565
  # --approve-for-me and --dangerously-bypass-... are mutually exclusive.
543
566
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox)
544
567
  elif [ "$ROLE" = "dwarf" ]; then CMD+=(--approve-for-me)
@@ -557,6 +580,9 @@ build_cmd() {
557
580
  # takes the final message and the tokens from. stream-json needs --verbose with -p.
558
581
  CMD+=(--output-format stream-json --verbose)
559
582
  [ -n "$EFFORT" ] && CMD+=(--effort "$EFFORT")
583
+ # Hidden: claude --help does not list it. openclaude has no per-invocation tier
584
+ # and is refused before build_cmd; this guard keeps the flag off its argv too.
585
+ [ "$SERVICE_TIER" = fast ] && [ "$HARNESS" = claude ] && CMD+=(--fast-mode on)
560
586
  # Before the variadic flags below, which would otherwise swallow it.
561
587
  # --resume takes an optional value, so an id that starts with '-' is joined with '='.
562
588
  case "$CONTINUE_ID" in
@@ -667,6 +693,8 @@ unadvertised_flag() { # unadvertised_flag <help text>
667
693
  -*) flag="${arg%%=*}"
668
694
  # grok's help hides this one; preflight_command checks it with a probe instead.
669
695
  [ "$HARNESS $flag" = "grok --background-wait-timeout" ] && continue
696
+ # claude's help hides this one. Unlike grok's, nothing probes it: this exemption is the whole check.
697
+ [ "$HARNESS $flag" = "claude --fast-mode" ] && continue
670
698
  printf '%s\n' "$1" | grep -E -- "(^|[[:space:],|])$flag([=[:space:],|]|$)" >/dev/null || { printf '%s' "$flag"; return 0; } ;;
671
699
  esac
672
700
  done
@@ -715,6 +743,7 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
715
743
  echo "harness=$HARNESS"
716
744
  echo "model=$MODEL"
717
745
  echo "effort=${EFFORT:-<harness default>}"
746
+ [ "$SERVICE_TIER" = fast ] && echo "service_tier=fast"
718
747
  echo "yolo=$([ "$YOLO" = 1 ] && echo ON || echo off)"
719
748
  echo "passthrough=$([ "$PASSTHRU" = 1 ] && echo yes || echo no)"
720
749
  [ -n "$CLAMPED" ] && echo "clamped=$CLAMPED"
@@ -729,6 +758,31 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
729
758
  } | tee "$RUN_DIR/$ROLE.resolved"
730
759
 
731
760
  if [ "$PREFLIGHT" = 1 ]; then
761
+ # Stderr only, and only here: the block above is parsed from stdout and $ROLE.resolved,
762
+ # and a dispatch would repeat this at every task's preflight. A failure to say it
763
+ # changes nothing, including the exit code. The module's cwd is scripts/, so a
764
+ # relative FORGE_REGISTRY or FORGE_DATA_HOME is the caller's path made absolute first.
765
+ # Opened from scripts/, the registry would miss the file this shell already resolved
766
+ # (the note would vanish) and the dataset would miss the caller's store (the built-in
767
+ # table would speak over measured rows). A FORGE_DATA_HOME that starts with ~ is left
768
+ # for Python's expanduser; prefixing $PWD would point it at a directory named "~".
769
+ _slow_registry="${FORGE_REGISTRY:-}"
770
+ case "$_slow_registry" in
771
+ ""|/*) ;;
772
+ *) _slow_registry="$PWD/$_slow_registry" ;;
773
+ esac
774
+ _slow_home="${FORGE_DATA_HOME:-}"
775
+ case "$_slow_home" in
776
+ ""|/*|~*) ;;
777
+ *) _slow_home="$PWD/$_slow_home" ;;
778
+ esac
779
+ _slow="$(
780
+ cd "$SKILL_DIR/scripts" || exit 1
781
+ if [ -n "$_slow_registry" ]; then export FORGE_REGISTRY="$_slow_registry"; fi
782
+ if [ -n "$_slow_home" ]; then export FORGE_DATA_HOME="$_slow_home"; fi
783
+ python3 -m forge_dataset.efforts "$SPEC" 2>/dev/null
784
+ )" || _slow=""
785
+ if [ -n "$_slow" ]; then note "note: $_slow"; fi
732
786
  echo "offline preflight passed; authentication, quota and live model availability unverified"
733
787
  exit 0
734
788
  fi
@@ -760,7 +814,7 @@ fi
760
814
  # when a stale $LAST is already there. That is harmless when each run gets a fresh
761
815
  # run-dir, and silently wrong for `forge-parallel.sh retry`, which reuses the task
762
816
  # directory — it would read the first attempt's result and never notice.
763
- rm -f "$LAST" "$LOG" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.clock.stop" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.settled" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.harness"
817
+ rm -f "$LAST" "$LOG" "$RUN_DIR/$ROLE.clock" "$RUN_DIR/$ROLE.clock.stop" "$RUN_DIR/$ROLE.timedout" "$RUN_DIR/$ROLE.settled" "$RUN_DIR/$ROLE.infra" "$RUN_DIR/$ROLE.orphans" "$RUN_DIR/$ROLE.harness" "$RUN_DIR/$ROLE.tracked"
764
818
  python3 "$RUNTIME" phase "$ATTEMPT" model
765
819
  t0="$(date +%s)"
766
820
  # Process-group guard. A dwarf that starts `npm test &` and ends its turn leaves that
@@ -800,6 +854,13 @@ if [ "$GUARD_ON" = 1 ]; then
800
854
  && mv -f "$RUN_DIR/.$ROLE.harness.tmp" "$RUN_DIR/$ROLE.harness"
801
855
  fi
802
856
  fi
857
+ # The harness's descendants, sampled while it runs (#129). A tool that starts a session of its
858
+ # own (a test runner's web server) leaves the group the reap below signals, but the tracker saw
859
+ # it as a descendant, so the reap finds it by pid and start time. Advisory, like the guard.
860
+ tpid=""
861
+ if [ "$GUARD_ON" = 1 ]; then
862
+ python3 "$GUARD" track "$hpid" "$RUN_DIR/$ROLE.tracked" </dev/null >/dev/null 2>&1 & tpid=$!
863
+ fi
803
864
 
804
865
  # Ends the harness: the whole process group first when the harness has its own (GUARD_ON),
805
866
  # then children, then the process itself, then SIGKILL for a CLI that traps TERM and takes
@@ -860,15 +921,24 @@ for watcher in $wpid $spid; do
860
921
  kill "$watcher" 2>/dev/null
861
922
  wait "$watcher" 2>/dev/null
862
923
  done
863
- # Anything the harness left running in its group is an abandoned background job. Kill it
864
- # before reading the tree, and leave the list for the caller. Bounded (~3s) and advisory:
865
- # a reaper failure changes nothing about the exit code.
924
+ # Anything the harness left running in its group is an abandoned background job, and so is
925
+ # anything the tracker saw it start that is still alive, in whatever session: a timeout stops
926
+ # the harness, not the test servers its tools started (#129). Kill them before reading the
927
+ # tree, and leave the list for the caller. Bounded (~6s) and advisory: a reaper failure
928
+ # changes nothing about the exit code.
929
+ if [ -n "$tpid" ]; then kill -TERM "$tpid" 2>/dev/null; wait "$tpid" 2>/dev/null; tpid=""; fi
866
930
  if [ "$GUARD_ON" = 1 ]; then
867
- orphans_found="$(python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" 2>/dev/null)"
931
+ orphans_found="$(python3 "$GUARD" reap "$hpid" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" 2>/dev/null)"
868
932
  case "$orphans_found" in ''|*[!0-9]*|0) ;; *) note "$HARNESS left $orphans_found process(es) running after it exited; killed — see $RUN_DIR/$ROLE.orphans" ;; esac
869
933
  fi
870
934
  reaped=1
871
- rm -f "$RUN_DIR/$ROLE.harness"
935
+ rm -f "$RUN_DIR/$ROLE.harness" "$RUN_DIR/$ROLE.tracked"
936
+ # Neither CLI refuses a fast request it cannot honour: it runs slower and still exits 0.
937
+ # One note when the log shows that. The exit below stays the one the harness already returned.
938
+ if [ "$SERVICE_TIER" = fast ]; then
939
+ slow="$(python3 "$RUNTIME" speed "$LOG" "$HARNESS" 2>/dev/null)" || slow=""
940
+ [ -z "$slow" ] || note "$slow"
941
+ fi
872
942
  python3 "$RUNTIME" phase "$ATTEMPT" finalization
873
943
  DURATION=$(( $(date +%s) - t0 ))
874
944
  echo "duration_s=$DURATION" >> "$RUN_DIR/$ROLE.resolved"
@@ -44,7 +44,9 @@ TEST_PATH = re.compile(r'(^|/)(tests?|spec|specs|__tests__)/'
44
44
  r'|(^|/)test_[^/]*$|_test\.[^/]+$|\.(test|spec)\.[^/]+$')
45
45
  CODE_SUFFIXES = ('.py', '.go', '.js', '.jsx', '.ts', '.tsx', '.rb', '.rs', '.java',
46
46
  '.kt', '.php', '.sh', '.mjs', '.cjs')
47
- DEP_DIRS = ('node_modules', '.venv', 'venv', 'vendor')
47
+ # forge-artifact.sh's FORGE_DEP_DIRS: where package managers install into a checkout (#127)
48
+ DEP_DIRS = ('node_modules', 'bower_components', '.venv', 'venv', 'vendor', '.bundle', 'Pods', 'deps', '_build',
49
+ '.dart_tool', 'elm-stuff', '.build')
48
50
  MAX_FILES = 20
49
51
  TAIL = 2000
50
52