@giamme/forge 0.14.0 → 0.15.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 (44) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/SKILL.md +47 -14
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +2 -1
  5. package/docs/commands.md +301 -7
  6. package/docs/models.md +53 -0
  7. package/package.json +1 -1
  8. package/references/dataset.md +12 -3
  9. package/references/decompose.md +108 -7
  10. package/references/harnesses.md +21 -1
  11. package/references/planning.md +59 -0
  12. package/references/ui.md +39 -1
  13. package/scripts/forge-compare.py +6 -3
  14. package/scripts/forge-config.py +531 -4
  15. package/scripts/forge-dispatch.sh +132 -22
  16. package/scripts/forge-lib-plans.sh +19 -2
  17. package/scripts/forge-lib-review.sh +5 -3
  18. package/scripts/forge-lib-task.sh +119 -0
  19. package/scripts/forge-parallel-options.sh +12 -6
  20. package/scripts/forge-parallel.sh +572 -26
  21. package/scripts/forge-plan-check.py +591 -8
  22. package/scripts/forge-planner.py +480 -0
  23. package/scripts/forge-route.py +72 -23
  24. package/scripts/forge-runtime.py +157 -1
  25. package/scripts/forge-shadow.py +51 -7
  26. package/scripts/forge-solo.sh +81 -7
  27. package/scripts/forge_dataset/cli.py +10 -0
  28. package/scripts/forge_dataset/efforts.py +215 -0
  29. package/scripts/forge_dataset/harvest.py +44 -0
  30. package/scripts/forge_decide/__init__.py +19 -1
  31. package/scripts/forge_decide/builtin_profiles.json +25 -0
  32. package/scripts/forge_decide/cli.py +12 -0
  33. package/scripts/forge_decide/profiles.py +866 -0
  34. package/scripts/forge_decide/resolve.py +38 -6
  35. package/ui/docs/api.md +87 -8
  36. package/ui/forge_ui/control.py +173 -12
  37. package/ui/forge_ui/executions.py +28 -8
  38. package/ui/forge_ui/models.py +60 -1
  39. package/ui/forge_ui/reader.py +21 -1
  40. package/ui/forge_ui/static/leaderboard.js +5 -1
  41. package/ui/forge_ui/static/modelstats.js +25 -1
  42. package/ui/forge_ui/static/panel.js +19 -2
  43. package/ui/forge_ui/static/settings.js +788 -25
  44. package/ui/forge_ui/static/style.css +23 -0
@@ -264,6 +264,84 @@ def session_id(log: str, harness: str) -> str | None:
264
264
  return result_id if type(result_id) is str else None
265
265
 
266
266
 
267
+ _TIER_UNSUPPORTED = 'is not advertised as supported for model'
268
+
269
+
270
+ def read_speed(log: str, harness: str) -> tuple[str | None, str | None]:
271
+ """The speed the harness actually ran at, and why it was not fast.
272
+
273
+ claude: `usage.speed` of the last result, and `fast_mode_disabled_reason` when
274
+ that speed is not `fast`. codex: `default` and the error message when an
275
+ `item.completed` error says the tier is not advertised for the model; otherwise
276
+ the stream says nothing. Any other harness, or a log that does not say, is unknown.
277
+ """
278
+ if harness == 'codex':
279
+ reason = None
280
+ for event in _events(log)[0]:
281
+ if event.get('type') != 'item.completed':
282
+ continue
283
+ item = event.get('item')
284
+ if not isinstance(item, dict) or item.get('type') != 'error':
285
+ continue
286
+ message = item.get('message')
287
+ if isinstance(message, str) and _TIER_UNSUPPORTED in message:
288
+ reason = message
289
+ return ('default', reason) if reason else (None, None)
290
+ if harness != 'claude':
291
+ return None, None
292
+ speed = reason = None
293
+ saw = False
294
+ for event in _events(log)[0]:
295
+ if event.get('type') != 'result':
296
+ continue
297
+ saw = True
298
+ usage = event.get('usage')
299
+ value = usage.get('speed') if isinstance(usage, dict) else None
300
+ speed = value if isinstance(value, str) and value else None
301
+ disabled = event.get('fast_mode_disabled_reason')
302
+ reason = disabled if isinstance(disabled, str) and disabled else None
303
+ if not saw or not speed:
304
+ return None, None
305
+ if speed == 'fast':
306
+ return speed, None
307
+ return speed, reason
308
+
309
+
310
+ def speed_note(harness: str, asked: str | None, speed: str | None, reason: str | None) -> str | None:
311
+ """The one line to print when `asked` is fast and the log ran slower, else None."""
312
+ if asked != 'fast' or not speed or speed == 'fast':
313
+ return None
314
+ if harness == 'claude' and reason:
315
+ return '%s ran at %s speed: fast mode is unavailable (%s)' % (harness, speed, reason)
316
+ if reason:
317
+ return '%s ran at %s speed: %s' % (harness, speed, reason)
318
+ return '%s ran at %s speed' % (harness, speed)
319
+
320
+
321
+ def _resolved_service_tier(root: Path, role: str) -> str | None:
322
+ path = root / (role + '.resolved')
323
+ if not path.exists():
324
+ return None
325
+ found = None
326
+ prefix = 'service_tier='
327
+ for line in path.read_text(errors='replace').splitlines():
328
+ if line.startswith(prefix):
329
+ found = line[len(prefix):].strip() or None
330
+ return found
331
+
332
+
333
+ def speed_command(log: str, harness: str) -> None:
334
+ """Print the slower-speed note for a log, or nothing. Exit stays 0."""
335
+ try:
336
+ text = Path(log).read_text(errors='replace')
337
+ except OSError:
338
+ return
339
+ speed, reason = read_speed(text, harness)
340
+ note = speed_note(harness, 'fast', speed, reason)
341
+ if note:
342
+ print(note)
343
+
344
+
267
345
  def finish(attempt: str, root: str, role: str, harness: str, rc: str) -> None:
268
346
  try:
269
347
  _finish(Path(attempt), Path(root), role, harness, rc)
@@ -279,6 +357,7 @@ def _finish(attempt: Path, root: Path, role: str, harness: str, rc: str) -> None
279
357
  text = log.read_text(errors='replace') if structured and log.exists() else ''
280
358
  final, usage = extract(text, harness)
281
359
  found = session_id(text, harness)
360
+ speed, speed_reason = read_speed(text, harness)
282
361
  if not last.exists() or not last.stat().st_size:
283
362
  if final is not None:
284
363
  last.write_text(final + '\n')
@@ -292,6 +371,9 @@ def _finish(attempt: Path, root: Path, role: str, harness: str, rc: str) -> None
292
371
  harness=harness,
293
372
  prompt_bytes=prompt.stat().st_size if prompt_ready else None,
294
373
  session_id=found,
374
+ service_tier=_resolved_service_tier(root, role),
375
+ speed=speed,
376
+ speed_reason=speed_reason,
295
377
  **usage,
296
378
  )
297
379
  infra = root / (role + '.infra')
@@ -306,7 +388,7 @@ def _finish(attempt: Path, root: Path, role: str, harness: str, rc: str) -> None
306
388
  session_path.unlink(missing_ok=True)
307
389
  if found is not None:
308
390
  session_path.write_text(found + '\n')
309
- for suffix in ('prompt', 'last', 'log', 'clock', 'resolved', 'cmd', 'timedout', 'infra', 'orphans',
391
+ for suffix in ('prompt', 'last', 'log', 'clock', 'resolved', 'cmd', 'timedout', 'settled', 'infra', 'orphans',
310
392
  'session', 'continue'):
311
393
  if suffix == 'prompt' and not prompt_ready:
312
394
  continue
@@ -655,6 +737,72 @@ def classify(log: str, harness: str, rc: object, last: str = '', role: str = '',
655
737
  return None
656
738
 
657
739
 
740
+ # --- a final result the CLI stays open after (#110) ----------------------------------
741
+ # claude -p (and openclaude) stays up while a background task its session started is still open,
742
+ # even after the model's final result: one dwarf sat 47 minutes on a finished answer until the
743
+ # watchdog killed it as TIMEOUT. A result is not always the end, though: a background task that
744
+ # completes wakes the session for another turn, sometimes after a long wait (an hour and more on a
745
+ # slow suite). A new turn always opens with system/init, and until one does the only events after
746
+ # a result are the background tasks' own.
747
+ BACKGROUND_EVENTS = ('task_updated', 'task_notification', 'background_tasks_changed', 'hook_started', 'hook_response')
748
+ SETTLE_POLL_S = 5.0
749
+
750
+
751
+ def settled_result(text: str) -> dict | None:
752
+ """The last `result` event when only background-task events follow it: the model ended its turn and
753
+ began no other. None when the log has no result, or a turn is under way after it."""
754
+ found = None
755
+ for event in _events(text)[0]:
756
+ if event.get('type') == 'result':
757
+ found = event
758
+ elif not (event.get('type') == 'system' and event.get('subtype') in BACKGROUND_EVENTS):
759
+ found = None
760
+ return found
761
+
762
+
763
+ def settle(log: str, grace: str, pid: str) -> None:
764
+ """Returns once the harness log ends in a settled result (settled_result) and has not grown for `grace`
765
+ seconds of the machine's awake time; exits 1 once process `pid`, the harness, is gone. dispatch then ends
766
+ the harness: its answer is in, and only a background task keeps it open. An idle log whose last turn is
767
+ still under way (a long command) is never ended here; that is the watchdog's."""
768
+ grace_s, target = float(grace), int(pid)
769
+ poll = min(SETTLE_POLL_S, max(grace_s / 4, 0.05))
770
+ size, since, judged = None, time.monotonic(), None
771
+ while True:
772
+ try:
773
+ os.kill(target, 0)
774
+ except ProcessLookupError:
775
+ sys.exit(1)
776
+ except PermissionError:
777
+ pass
778
+ try:
779
+ now = os.stat(log).st_size
780
+ except OSError:
781
+ now = None
782
+ if now != size:
783
+ size, since = now, time.monotonic()
784
+ elif judged != size and time.monotonic() - since >= grace_s:
785
+ judged = size # read once per size: an idle log mid-turn is not read again and again
786
+ try:
787
+ text = Path(log).read_text(errors='replace')
788
+ except OSError:
789
+ text = ''
790
+ if settled_result(text) is not None:
791
+ return
792
+ time.sleep(poll)
793
+
794
+
795
+ def settled_command(log: str) -> None:
796
+ """Prints `ok`, or `error` for an is_error result, when LOG ends in a settled result; exits 1 otherwise."""
797
+ try:
798
+ event = settled_result(Path(log).read_text(errors='replace'))
799
+ except OSError:
800
+ event = None
801
+ if event is None:
802
+ sys.exit(1)
803
+ print('error' if event.get('is_error') is True else 'ok')
804
+
805
+
658
806
  def classify_command(log: str, harness: str, rc: str, last: str = '', role: str = '') -> None:
659
807
  try:
660
808
  hit = classify(log, harness, rc, last, role)
@@ -691,6 +839,14 @@ def main() -> None:
691
839
  classify_command(*args)
692
840
  elif command == 'clock':
693
841
  clock(*args)
842
+ elif command == 'settle':
843
+ settle(*args)
844
+ elif command == 'settled':
845
+ settled_command(*args)
846
+ elif command == 'speed':
847
+ if len(args) != 2:
848
+ raise ValueError('usage: forge-runtime.py speed LOG HARNESS')
849
+ speed_command(*args)
694
850
  else:
695
851
  raise ValueError('unknown runtime command: ' + command)
696
852
  except (OSError, ValueError, RuntimeError) as error:
@@ -11,7 +11,9 @@ turns this on for a sampled share of reviewed attempts (`--shadow-rate`, default
11
11
  dir under <plan>/shadow/<id>/<attempt>-<k>/, reviews a byte-identical copy of the
12
12
  primary's qa.input, and returns. Never exits nonzero.
13
13
  forge-shadow.py preflight --plan P
14
- Which listed shadow specs resolve here; writes <plan>/shadow_qa.ok. Never fails a run.
14
+ Which listed shadow specs resolve here; writes <plan>/shadow_qa.ok. A spec that
15
+ cannot run here is skipped. A fast-tier refusal stops the run with dispatch's
16
+ own message and exit code, before any model call.
15
17
 
16
18
  Guarantees, because the task waits for this process before it writes any status:
17
19
  - nothing reads the shadow's result in the run path; it changes no status, memory,
@@ -49,6 +51,36 @@ STOP_WAIT_S = 10
49
51
  PREPARE_TIMEOUT_S = 120
50
52
 
51
53
 
54
+ def plan_is_fractal(plan: Path) -> bool:
55
+ """True when this plan's saved selection says Fractal runs the dispatches."""
56
+ try:
57
+ data = json.loads((plan / 'fractal-selection.json').read_text())
58
+ except (OSError, ValueError):
59
+ return False
60
+ return isinstance(data, dict) and bool(data.get('enabled'))
61
+
62
+
63
+ def service_tier_args(plan: Path, role: str) -> list[str]:
64
+ """`--service-tier fast` when <role> is a line of <plan>/fast, and nothing otherwise.
65
+
66
+ Fractal dispatches through its own runner and does not take the option. A retry
67
+ preflights before that runner is selected, so a plan whose selection is already on
68
+ is the same case for every role it dispatches. A whole-run review is not one of them.
69
+ Specs never change.
70
+ """
71
+ if os.environ.get('FORGE_FRACTAL_RUN'):
72
+ return []
73
+ try:
74
+ text = (plan / 'fast').read_text()
75
+ except OSError:
76
+ return []
77
+ if role not in [line.strip() for line in text.splitlines() if line.strip()]:
78
+ return []
79
+ if role != 'review' and plan_is_fractal(plan):
80
+ return []
81
+ return ['--service-tier', 'fast']
82
+
83
+
52
84
  def rate_of(plan: Path) -> float:
53
85
  try:
54
86
  rate = float((plan / 'shadow_rate').read_text().strip())
@@ -207,6 +239,7 @@ def run(args) -> int:
207
239
  '--output', 'summary']
208
240
  if args.yolo:
209
241
  argv.append('--yolo')
242
+ argv.extend(service_tier_args(plan, 'qa'))
210
243
  with open(out / 'shadow.out', 'wb') as log:
211
244
  STATE['child'] = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT,
212
245
  env=env, close_fds=True)
@@ -269,16 +302,27 @@ def preflight(args) -> int:
269
302
  ok = []
270
303
  for spec in listed:
271
304
  flags = ['--yolo'] if (plan / 'yolo_qa').exists() else []
305
+ flags.extend(service_tier_args(plan, 'qa'))
272
306
  try:
273
307
  result = subprocess.run(['/bin/bash', str(DISPATCH), 'doctor', '--spec', spec, '--role', 'qa', *flags],
274
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=120)
275
- good = result.returncode == 0
308
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=120, text=True)
276
309
  except (OSError, subprocess.SubprocessError):
277
- good = False
278
- if good:
279
- ok.append(spec)
280
- else:
281
310
  print('forge: shadow review spec %s is not usable here; it is skipped' % spec, file=sys.stderr)
311
+ continue
312
+ if result.returncode == 0:
313
+ ok.append(spec)
314
+ continue
315
+ # Dispatch refuses a fast tier the harness cannot take (exit 3) before it checks
316
+ # that the binary exists, and both failures share that exit. The message is how
317
+ # they differ. Re-emit it unchanged and stop: skipping the shadow would let the
318
+ # dwarf and the primary review run and be billed.
319
+ text = result.stdout or ''
320
+ if result.returncode == 3 and 'has no per-invocation fast tier' in text:
321
+ sys.stderr.write(text)
322
+ if text and not text.endswith('\n'):
323
+ sys.stderr.write('\n')
324
+ return 3
325
+ print('forge: shadow review spec %s is not usable here; it is skipped' % spec, file=sys.stderr)
282
326
  write(plan / 'shadow_qa.ok', ','.join(ok) + '\n')
283
327
  if listed and not ok:
284
328
  print('forge: no shadow review spec is usable; shadow reviews are off for this run', file=sys.stderr)
@@ -20,6 +20,13 @@
20
20
  # [--approach <file>] [--yolo-dwarf] [--yolo-qa]
21
21
  # [--native-review] [--no-memory] [--timeout <s>] [--dry-run] [--ui]
22
22
  # [--fail-first] [--qa-threshold P0|P1|P2|P3|none]
23
+ # [--fast ROLES] dwarf, qa or none (planner, review and all are refused);
24
+ # kept in <run-dir>/fast. none removes it; omitting it keeps it
25
+ # [--profile NAME | --no-profile] a named profile (forge config profile list) picks
26
+ # the dwarf and qa (its medium pool, else its any pool), the QA
27
+ # threshold, the timeout and the fast roles that no flag gives;
28
+ # frozen in <run-dir>/profile.json, which later runs of the dir keep.
29
+ # With neither flag, that copy, else the default profile, applies
23
30
  #
24
31
  # Reads <run-dir>/prompt.md the implementation instruction (required)
25
32
  # <run-dir>/goal.txt one line, what the user asked for (optional)
@@ -29,6 +36,7 @@
29
36
  # <run-dir>/verdict PASS | FAIL | UNKNOWN, when qa emitted one (after the severity gate)
30
37
  # <run-dir>/qa.gate, known_issues.md the gate's decision and the tolerated findings
31
38
  # <run-dir>/qa_threshold with --qa-threshold: the blocking level (default P2)
39
+ # <run-dir>/profile.json with a profile: the frozen copy of it
32
40
  # <run-dir>/failfirst.json with --fail-first: do the change's tests fail without it?
33
41
  # <run-dir>/status RUNNING, then this invocation's outcome
34
42
  # <run-dir>/dwarf.spec, qa.spec and attempts.tsv
@@ -95,7 +103,7 @@ forge_metric_on_exit() {
95
103
  }
96
104
 
97
105
  if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
98
- sed -n '18,39s/^# *//p' "$0"
106
+ sed -n '18,47s/^# *//p' "$0"
99
107
  forge_fractal_help
100
108
  echo 'Explicit Fractal retry: repeat the original command with --retry.'
101
109
  exit 0
@@ -104,8 +112,12 @@ RUN="${1:-}"; [ -n "$RUN" ] || die "usage: forge-solo.sh <run-dir> --repo <dir>
104
112
  case "$RUN" in -*) die "first argument must be the run directory, got '$RUN'" ;; esac
105
113
  shift
106
114
 
115
+ # --- profiles (#48): the same reading, freezing and exporting as forge-parallel.sh's plan ---
116
+ forge_profile_py() { PYTHONPATH="$SKILL_DIR/scripts${PYTHONPATH:+:$PYTHONPATH}" python3 -m forge_decide.profiles "$@"; }
117
+
107
118
  OUTPUT=summary
108
119
  REPO="$PWD"; DWARF=""; QA="opus"; APPROACH=""; YD=""; YQ=""; NATIVE=""; TIMEOUT=""; DRY=0; FAIL_FIRST=0; QA_THR=
120
+ FAST_GIVEN=0; FAST_PARSED=""; QA_GIVEN=0; PF_NAME=""; PF_NONE=0
109
121
  while [ $# -gt 0 ]; do
110
122
  case "$1" in
111
123
  --fractal) forge_fractal_flag on || exit $?; shift ;;
@@ -116,7 +128,9 @@ while [ $# -gt 0 ]; do
116
128
  --output) OUTPUT="${2:?}"; shift 2 ;;
117
129
  --repo) REPO="${2:?--repo needs a value}"; shift 2 ;;
118
130
  --dwarf) DWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
119
- --qa) QA="${2:?--qa needs a spec}"; shift 2 ;;
131
+ --qa) QA="${2:?--qa needs a spec}"; QA_GIVEN=1; shift 2 ;;
132
+ --profile) PF_NAME="${2:?--profile needs a profile name}"; shift 2 ;;
133
+ --no-profile) PF_NONE=1; shift ;;
120
134
  --approach) APPROACH="${2:?--approach needs a file}"; shift 2 ;;
121
135
  --yolo-dwarf) YD="--yolo"; shift ;;
122
136
  --yolo-qa) YQ="--yolo"; shift ;;
@@ -126,6 +140,11 @@ while [ $# -gt 0 ]; do
126
140
  --timeout) TIMEOUT="${2:?--timeout needs seconds}"; shift 2 ;;
127
141
  --dry-run) DRY=1; shift ;;
128
142
  --fail-first) FAIL_FIRST=1; shift ;;
143
+ --fast)
144
+ [ -n "${2:-}" ] || die "--fast needs a comma list of roles (dwarf, qa, planner, review), all or none"
145
+ forge_fast_parse "$2" solo
146
+ FAST_GIVEN=1
147
+ shift 2 ;;
129
148
  --qa-threshold)
130
149
  QA_THR="$(printf '%s' "${2:?--qa-threshold needs P0, P1, P2, P3 or none}" | tr 'a-z' 'A-Z')"
131
150
  case "$QA_THR" in P0|P1|P2|P3) ;; NONE) QA_THR=none ;; *) die "--qa-threshold must be P0, P1, P2, P3 or none, got '$2'" 2 ;; esac
@@ -149,6 +168,48 @@ done
149
168
 
150
169
  case "$OUTPUT" in summary|full) ;; *) die "--output must be summary or full" ;; esac
151
170
 
171
+ # A profile (#48) stands in for the flags that were not given. Read and checked here, before the
172
+ # model is asked for and before anything is written: an unknown or invalid profile stops the run.
173
+ [ -z "$PF_NAME" ] || [ "$PF_NONE" = 0 ] || die "--profile and --no-profile are mutually exclusive"
174
+ pf_args=()
175
+ [ -z "$PF_NAME" ] || pf_args+=(--profile "$PF_NAME")
176
+ [ "$PF_NONE" = 0 ] || pf_args+=(--no-profile)
177
+ [ -z "$DWARF" ] || pf_args+=(--given dwarf)
178
+ [ "$QA_GIVEN" != 1 ] || pf_args+=(--given qa)
179
+ [ -z "$QA_THR" ] || pf_args+=(--given qa_threshold)
180
+ [ -z "$TIMEOUT" ] || pf_args+=(--given timeout)
181
+ [ "$FAST_GIVEN" != 1 ] || pf_args+=(--given fast)
182
+ pf_auto=0; pf_planner=0
183
+ for pf_arg in ${FRACTAL_ARGS[@]+"${FRACTAL_ARGS[@]}"}; do
184
+ case "$pf_arg" in
185
+ --dwarf-low|--dwarf-medium|--dwarf-high) pf_args+=(--given "${pf_arg#--}") ;;
186
+ --fractal-auto-decompose) pf_auto=1 ;;
187
+ --fractal-planner) pf_planner=1; pf_args+=(--given fractal-planner) ;;
188
+ esac
189
+ done
190
+ PF_LINE=""
191
+ pf_out="$(forge_profile_py solo "$RUN" --repo "$REPO" ${pf_args[@]+"${pf_args[@]}"})" || exit $?
192
+ while IFS="$(printf '\t')" read -r pf_key pf_val; do
193
+ case "$pf_key" in
194
+ dwarf) DWARF="$pf_val" ;;
195
+ qa) QA="$pf_val" ;;
196
+ qa_threshold) QA_THR="$pf_val" ;;
197
+ timeout) TIMEOUT="$pf_val" ;;
198
+ fast) forge_fast_parse "$pf_val" solo; FAST_GIVEN=1 ;;
199
+ # Fractal's tier pools and planner count only where Fractal is selected (and the planner
200
+ # only with automatic decomposition, which --fractal-planner needs).
201
+ pool.low) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-low "$pf_val") ;;
202
+ pool.medium) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-medium "$pf_val") ;;
203
+ pool.high) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-high "$pf_val") ;;
204
+ fractal_planner) [ "$FRACTAL_CHOICE$pf_auto$pf_planner" != on10 ] || FRACTAL_ARGS+=(--fractal-planner "$pf_val") ;;
205
+ line) PF_LINE="$pf_val" ;;
206
+ # The gates and budget of the copy this run uses, for it and everything it starts.
207
+ decide) [ -z "$pf_val" ] || export FORGE_DECIDE_PROFILE_JSON="$pf_val" ;;
208
+ esac
209
+ done <<EOF
210
+ $pf_out
211
+ EOF
212
+
152
213
  # Forge never picks the model: every dispatch spends the user's quota, and choosing
153
214
  # for them is not the tool's call.
154
215
  [ -n "$DWARF" ] || die "--dwarf is required"
@@ -165,6 +226,13 @@ case "$(cd "$RUN" && pwd)/" in
165
226
  esac
166
227
 
167
228
  RUN="$(cd "$RUN" && pwd)"
229
+ # The frozen copy, atomically. Only the process that holds the run's lock writes it (a refused
230
+ # second start, or a dry run, must not change what an active run froze): the first pass above
231
+ # only read and checked, and the re-exec under the lock chooses again from the same arguments.
232
+ if [ "$DRY" != 1 ] && [ "${FORGE_SOLO_LOCK:-}" = "$RUN" ]; then
233
+ forge_profile_py solo "$RUN" --repo "$REPO" --no-validate --write ${pf_args[@]+"${pf_args[@]}"} >/dev/null || exit $?
234
+ fi
235
+ [ -z "$PF_LINE" ] || [ -n "${FORGE_SOLO_LOCK:-}" ] || echo "$PF_LINE"
168
236
  # Freeze the selection now that the run dir is real and absolute. A retry of this
169
237
  # same run dir restores it rather than re-reading whatever flags are passed then.
170
238
  [ "$JEV_OPTS" = 1 ] && { forge_jev_restore "$RUN" || true; forge_jev_record "$RUN"; }
@@ -174,6 +242,8 @@ REPO="$(cd "$REPO" && pwd)"
174
242
  if [ "$DRY" != 1 ] && [ "${FORGE_SOLO_LOCK:-}" != "$RUN" ]; then
175
243
  exec python3 "$SKILL_DIR/scripts/forge-fractal.py" _lock "$RUN" "$0" "${ORIGINAL_ARGS[@]}"
176
244
  fi
245
+ # After the lock re-exec, so the process that dispatches is the one that writes it.
246
+ forge_fast_store "$RUN"
177
247
  RUN_ID="$(basename "$RUN")"
178
248
  export FORGE_CAPABILITY_CACHE="$RUN/capabilities"
179
249
  TFLAG=""; [ -n "$TIMEOUT" ] && TFLAG="--timeout $TIMEOUT"
@@ -183,6 +253,10 @@ FFLAGS=()
183
253
  [ -z "$YD" ] || FFLAGS+=(--yolo-dwarf)
184
254
  [ -z "$YQ" ] || FFLAGS+=(--yolo-qa)
185
255
  forge_fractal_select "$RUN" "$REPO" solo "$DRY" --dwarf "$DWARF" --qa "$QA" ${FFLAGS[@]+"${FFLAGS[@]}"} || exit $?
256
+ forge_fast_fractal_note "$RUN"
257
+ # Computed after Fractal selects, so a Fractal dispatch is not asked for the tier.
258
+ ft_dwarf="$(forge_fast_tier "$RUN" dwarf)"
259
+ ft_qa="$(forge_fast_tier "$RUN" qa)"
186
260
  if [ -n "${FORGE_FRACTAL_RUN:-}" ]; then
187
261
  # The UI choice is per invocation: a tmux resume replays these args and must not open it again.
188
262
  REMEMBER_ARGS=()
@@ -235,7 +309,7 @@ if [ "$DRY" = 1 ]; then
235
309
  echo "--- dry run ---"
236
310
  [ "$FORGE_UI_WANTED" != 1 ] || note "--ui ignored: a dry run starts no UI"
237
311
  /bin/bash "$DISPATCH" dwarf "$DWARF" --repo "$REPO" --run-dir "$RUN" \
238
- --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/dwarf.input" $YD $TFLAG --dry-run
312
+ --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/dwarf.input" $YD $TFLAG $ft_dwarf --dry-run
239
313
  echo
240
314
  echo "qa would be: $QA $NATIVE $YQ"
241
315
  echo "dwarf prompt: $RUN/dwarf.input ($(wc -l < "$RUN/dwarf.input" | tr -d ' ') lines)"
@@ -243,8 +317,8 @@ if [ "$DRY" = 1 ]; then
243
317
  fi
244
318
 
245
319
  forge_metric_phase preflight
246
- /bin/bash "$DISPATCH" doctor --spec "$DWARF" --role dwarf $YD $TFLAG || exit $?
247
- /bin/bash "$DISPATCH" doctor --spec "$QA" --role qa $YQ $NATIVE $TFLAG || exit $?
320
+ /bin/bash "$DISPATCH" doctor --spec "$DWARF" --role dwarf $YD $TFLAG $ft_dwarf || exit $?
321
+ /bin/bash "$DISPATCH" doctor --spec "$QA" --role qa $YQ $NATIVE $TFLAG $ft_qa || exit $?
248
322
  /bin/bash "$SKILL_DIR/scripts/forge-install-ripwire.sh" || true
249
323
  # After the _lock re-exec and the Fractal checkpoint exit, so it runs once per run.
250
324
  forge_ui_launch "$RUN"
@@ -260,7 +334,7 @@ forge_metric_phase dispatch
260
334
  note "dwarf $DWARF in $REPO"
261
335
  guard_before_dwarf "$REPO" "$RUN"
262
336
  /bin/bash "$DISPATCH" dwarf "$DWARF" --repo "$REPO" --run-dir "$RUN" \
263
- --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/dwarf.input" $YD $TFLAG --output "$OUTPUT"
337
+ --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/dwarf.input" $YD $TFLAG $ft_dwarf --output "$OUTPUT"
264
338
  rc=$?
265
339
  dur_dwarf="$(sed -n 's/^duration_s=//p' "$RUN/dwarf.resolved" 2>/dev/null | tail -1)"
266
340
  /bin/bash "$MEMORY" record "$REPO" --last "$RUN/dwarf.last" --role dwarf \
@@ -326,7 +400,7 @@ fi
326
400
  forge_metric_phase dispatch
327
401
  note "qa $QA on $(wc -l < "$RUN/changes.diff" | tr -d ' ') diff lines"
328
402
  /bin/bash "$DISPATCH" qa "$QA" --repo "$REVIEW" --review-base "$(cat "$RUN/review.base")" --run-dir "$RUN" \
329
- --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/qa.input" $YQ $NATIVE $TFLAG --output "$OUTPUT"
403
+ --ripwire-query-file "$RUN/prompt.md" --prompt-file "$RUN/qa.input" $YQ $NATIVE $TFLAG $ft_qa --output "$OUTPUT"
330
404
  rc=$?
331
405
  forge_metric_phase verification
332
406
  verdict="$(forge_verdict "$RUN/qa.last")"
@@ -201,6 +201,13 @@ def run_forecast(args) -> int:
201
201
  return forecast.main(args)
202
202
 
203
203
 
204
+ def slow_notes(args) -> int:
205
+ from . import efforts
206
+ for line in efforts.plan_notes(args.plan):
207
+ print(line)
208
+ return 0
209
+
210
+
204
211
  def parser() -> argparse.ArgumentParser:
205
212
  top = argparse.ArgumentParser(prog='forge dataset', description='The run dataset: every run\'s inputs and outcomes.')
206
213
  sub = top.add_subparsers(dest='command', required=True)
@@ -253,6 +260,9 @@ def parser() -> argparse.ArgumentParser:
253
260
  p.add_argument('--json', action='store_true')
254
261
  p.add_argument('--run', action='store_true', help=argparse.SUPPRESS) # forge-parallel.sh run: budgeted, silent, records
255
262
  p.set_defaults(func=run_forecast)
263
+ p = sub.add_parser('slow-notes', help=argparse.SUPPRESS) # forge-parallel.sh plan: under the table
264
+ p.add_argument('plan')
265
+ p.set_defaults(func=slow_notes)
256
266
  p = sub.add_parser('event', help=argparse.SUPPRESS)
257
267
  p.add_argument('name')
258
268
  p.add_argument('--dir')