@giamme/forge 0.14.1 → 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 (42) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/SKILL.md +47 -14
  3. package/VERSION +1 -1
  4. package/docs/commands.md +288 -6
  5. package/docs/models.md +53 -0
  6. package/package.json +1 -1
  7. package/references/dataset.md +12 -3
  8. package/references/decompose.md +103 -4
  9. package/references/harnesses.md +17 -0
  10. package/references/planning.md +59 -0
  11. package/references/ui.md +39 -1
  12. package/scripts/forge-compare.py +6 -3
  13. package/scripts/forge-config.py +531 -4
  14. package/scripts/forge-dispatch.sh +56 -2
  15. package/scripts/forge-lib-plans.sh +19 -2
  16. package/scripts/forge-lib-review.sh +5 -3
  17. package/scripts/forge-lib-task.sh +119 -0
  18. package/scripts/forge-parallel-options.sh +12 -6
  19. package/scripts/forge-parallel.sh +565 -21
  20. package/scripts/forge-plan-check.py +591 -8
  21. package/scripts/forge-planner.py +480 -0
  22. package/scripts/forge-runtime.py +86 -0
  23. package/scripts/forge-shadow.py +51 -7
  24. package/scripts/forge-solo.sh +81 -7
  25. package/scripts/forge_dataset/cli.py +10 -0
  26. package/scripts/forge_dataset/efforts.py +215 -0
  27. package/scripts/forge_dataset/harvest.py +44 -0
  28. package/scripts/forge_decide/__init__.py +19 -1
  29. package/scripts/forge_decide/builtin_profiles.json +25 -0
  30. package/scripts/forge_decide/cli.py +12 -0
  31. package/scripts/forge_decide/profiles.py +866 -0
  32. package/scripts/forge_decide/resolve.py +38 -6
  33. package/ui/docs/api.md +87 -8
  34. package/ui/forge_ui/control.py +173 -12
  35. package/ui/forge_ui/executions.py +28 -8
  36. package/ui/forge_ui/models.py +60 -1
  37. package/ui/forge_ui/reader.py +21 -1
  38. package/ui/forge_ui/static/leaderboard.js +5 -1
  39. package/ui/forge_ui/static/modelstats.js +25 -1
  40. package/ui/forge_ui/static/panel.js +19 -2
  41. package/ui/forge_ui/static/settings.js +788 -25
  42. package/ui/forge_ui/static/style.css +23 -0
@@ -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)
@@ -206,7 +212,7 @@ if [ "$ROLE" = report ]; then python3 "$RUNTIME" report "${1:?report needs a run
206
212
  PREFLIGHT=0
207
213
  if [ "$ROLE" = doctor ]; then
208
214
  if [ $# = 0 ]; then doctor; exit $?; fi
209
- [ "${1:-}" = --spec ] || die "doctor accepts --spec <spec> [--role dwarf|qa|planner]"
215
+ [ "${1:-}" = --spec ] || die "doctor accepts --spec <spec> [--role dwarf|qa|planner] [--service-tier fast]"
210
216
  SPEC_CHECK="${2:?--spec needs a spec}"; shift 2
211
217
  ROLE=dwarf
212
218
  if [ "${1:-}" = --role ]; then ROLE="${2:?}"; shift 2; fi
@@ -227,7 +233,7 @@ SPEC="$1"; shift
227
233
 
228
234
  RIPWIRE_QUERY=""
229
235
  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=""
236
+ 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
237
  while [ $# -gt 0 ]; do
232
238
  case "$1" in
233
239
  --no-ripwire) export FORGE_RIPWIRE=off; shift ;;
@@ -241,6 +247,7 @@ while [ $# -gt 0 ]; do
241
247
  --continue-session) [ $# -ge 2 ] || die "--continue-session needs a session id"; CONTINUE_ID="$2"; CONTINUE_GIVEN=1; shift 2 ;;
242
248
  --agy-timeout) AGY_TIMEOUT="${2:?--agy-timeout needs a value}"; shift 2 ;;
243
249
  --timeout) TIMEOUT_FLAG="${2:?--timeout needs a value in seconds, 0 to disable}"; shift 2 ;;
250
+ --service-tier) [ $# -ge 2 ] || die "--service-tier needs a value"; [ "$2" = fast ] || die "--service-tier accepts only fast"; SERVICE_TIER=fast; shift 2 ;;
244
251
  --yolo) YOLO=1; shift ;;
245
252
  --dry-run) DRY=1; shift ;;
246
253
  *) die "unknown option '$1'" ;;
@@ -354,6 +361,13 @@ if [ -n "$EFFORT" ] && [ -n "$LADDER" ] && [ "$(idx_in "$EFFORT" "$LADDER")" -lt
354
361
  die "invalid effort '$EFFORT' for $HARNESS"
355
362
  fi
356
363
 
364
+ # codex and claude can ask for the fast tier on this invocation. The others cannot
365
+ # (opencode's fast mode is per-model config; the rest have none). Refuse before
366
+ # preflight, so doctor --spec and a dispatch both stop before those CLIs start.
367
+ if [ "$SERVICE_TIER" = fast ] && [ "$HARNESS" != codex ] && [ "$HARNESS" != claude ]; then
368
+ 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
369
+ fi
370
+
357
371
  # --- resolve timeout ----------------------------------------------------------
358
372
  # Explicit (--timeout, FORGE_TIMEOUT) wins as given, including 0. Otherwise the registry
359
373
  # row's `timeout` column, then 2700. Only those two defaults scale with the resolved
@@ -520,6 +534,7 @@ build_cmd() {
520
534
  # subshell cd below.
521
535
  CMD=(codex exec review --json -m "$MODEL" --skip-git-repo-check -o "$LAST")
522
536
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
537
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
523
538
  if [ -n "$REVIEW_BASE" ]; then CMD+=(--base "$REVIEW_BASE"); else CMD+=(--uncommitted); fi
524
539
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox); fi
525
540
  elif [ -n "$CONTINUE_ID" ]; then
@@ -531,6 +546,7 @@ build_cmd() {
531
546
  case "$CONTINUE_ID" in -*) ;; *) CMD+=("$CONTINUE_ID") ;; esac
532
547
  CMD+=(--json -m "$MODEL" --skip-git-repo-check -o "$LAST")
533
548
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
549
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
534
550
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox)
535
551
  else CMD+=(-c 'sandbox_mode="read-only"'); fi
536
552
  case "$CONTINUE_ID" in -*) CMD+=(-- "$CONTINUE_ID") ;; esac
@@ -539,6 +555,7 @@ build_cmd() {
539
555
  else
540
556
  CMD=(codex exec --json -m "$MODEL" -C "$REPO" --skip-git-repo-check -o "$LAST")
541
557
  [ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
558
+ [ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
542
559
  # --approve-for-me and --dangerously-bypass-... are mutually exclusive.
543
560
  if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox)
544
561
  elif [ "$ROLE" = "dwarf" ]; then CMD+=(--approve-for-me)
@@ -557,6 +574,9 @@ build_cmd() {
557
574
  # takes the final message and the tokens from. stream-json needs --verbose with -p.
558
575
  CMD+=(--output-format stream-json --verbose)
559
576
  [ -n "$EFFORT" ] && CMD+=(--effort "$EFFORT")
577
+ # Hidden: claude --help does not list it. openclaude has no per-invocation tier
578
+ # and is refused before build_cmd; this guard keeps the flag off its argv too.
579
+ [ "$SERVICE_TIER" = fast ] && [ "$HARNESS" = claude ] && CMD+=(--fast-mode on)
560
580
  # Before the variadic flags below, which would otherwise swallow it.
561
581
  # --resume takes an optional value, so an id that starts with '-' is joined with '='.
562
582
  case "$CONTINUE_ID" in
@@ -667,6 +687,8 @@ unadvertised_flag() { # unadvertised_flag <help text>
667
687
  -*) flag="${arg%%=*}"
668
688
  # grok's help hides this one; preflight_command checks it with a probe instead.
669
689
  [ "$HARNESS $flag" = "grok --background-wait-timeout" ] && continue
690
+ # claude's help hides this one. Unlike grok's, nothing probes it: this exemption is the whole check.
691
+ [ "$HARNESS $flag" = "claude --fast-mode" ] && continue
670
692
  printf '%s\n' "$1" | grep -E -- "(^|[[:space:],|])$flag([=[:space:],|]|$)" >/dev/null || { printf '%s' "$flag"; return 0; } ;;
671
693
  esac
672
694
  done
@@ -715,6 +737,7 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
715
737
  echo "harness=$HARNESS"
716
738
  echo "model=$MODEL"
717
739
  echo "effort=${EFFORT:-<harness default>}"
740
+ [ "$SERVICE_TIER" = fast ] && echo "service_tier=fast"
718
741
  echo "yolo=$([ "$YOLO" = 1 ] && echo ON || echo off)"
719
742
  echo "passthrough=$([ "$PASSTHRU" = 1 ] && echo yes || echo no)"
720
743
  [ -n "$CLAMPED" ] && echo "clamped=$CLAMPED"
@@ -729,6 +752,31 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
729
752
  } | tee "$RUN_DIR/$ROLE.resolved"
730
753
 
731
754
  if [ "$PREFLIGHT" = 1 ]; then
755
+ # Stderr only, and only here: the block above is parsed from stdout and $ROLE.resolved,
756
+ # and a dispatch would repeat this at every task's preflight. A failure to say it
757
+ # changes nothing, including the exit code. The module's cwd is scripts/, so a
758
+ # relative FORGE_REGISTRY or FORGE_DATA_HOME is the caller's path made absolute first.
759
+ # Opened from scripts/, the registry would miss the file this shell already resolved
760
+ # (the note would vanish) and the dataset would miss the caller's store (the built-in
761
+ # table would speak over measured rows). A FORGE_DATA_HOME that starts with ~ is left
762
+ # for Python's expanduser; prefixing $PWD would point it at a directory named "~".
763
+ _slow_registry="${FORGE_REGISTRY:-}"
764
+ case "$_slow_registry" in
765
+ ""|/*) ;;
766
+ *) _slow_registry="$PWD/$_slow_registry" ;;
767
+ esac
768
+ _slow_home="${FORGE_DATA_HOME:-}"
769
+ case "$_slow_home" in
770
+ ""|/*|~*) ;;
771
+ *) _slow_home="$PWD/$_slow_home" ;;
772
+ esac
773
+ _slow="$(
774
+ cd "$SKILL_DIR/scripts" || exit 1
775
+ if [ -n "$_slow_registry" ]; then export FORGE_REGISTRY="$_slow_registry"; fi
776
+ if [ -n "$_slow_home" ]; then export FORGE_DATA_HOME="$_slow_home"; fi
777
+ python3 -m forge_dataset.efforts "$SPEC" 2>/dev/null
778
+ )" || _slow=""
779
+ if [ -n "$_slow" ]; then note "note: $_slow"; fi
732
780
  echo "offline preflight passed; authentication, quota and live model availability unverified"
733
781
  exit 0
734
782
  fi
@@ -869,6 +917,12 @@ if [ "$GUARD_ON" = 1 ]; then
869
917
  fi
870
918
  reaped=1
871
919
  rm -f "$RUN_DIR/$ROLE.harness"
920
+ # Neither CLI refuses a fast request it cannot honour: it runs slower and still exits 0.
921
+ # One note when the log shows that. The exit below stays the one the harness already returned.
922
+ if [ "$SERVICE_TIER" = fast ]; then
923
+ slow="$(python3 "$RUNTIME" speed "$LOG" "$HARNESS" 2>/dev/null)" || slow=""
924
+ [ -z "$slow" ] || note "$slow"
925
+ fi
872
926
  python3 "$RUNTIME" phase "$ATTEMPT" finalization
873
927
  DURATION=$(( $(date +%s) - t0 ))
874
928
  echo "duration_s=$DURATION" >> "$RUN_DIR/$ROLE.resolved"
@@ -130,7 +130,7 @@ plans_make_integration() { # plans_make_integration <repo> <branch> <commit> <wt
130
130
 
131
131
  # Per-plan option files carried to a derived plan. The cost-bearing choices a user made
132
132
  # for this plan apply to the plan made from it; `planner` does not (nothing plans again).
133
- PLANS_OPTION_FILES="no_ripwire no_memory yolo_dwarf yolo_qa reviewer_session implementer_session pre_review_tests pre_review_parallel qa_threshold timeout verify_retries verify_cmd verify_parallel setup_cmd final_qa shadow_qa shadow_rate explore escalate_after fractal-routing.json fractal-selection.json jev-selection.json"
133
+ PLANS_OPTION_FILES="no_ripwire no_memory yolo_dwarf yolo_qa reviewer_session implementer_session fast pre_review_tests pre_review_parallel qa_threshold timeout verify_retries verify_cmd verify_parallel setup_cmd final_qa shadow_qa shadow_rate explore escalate_after fractal-routing.json fractal-selection.json jev-selection.json profile.json routed.json"
134
134
 
135
135
  # --- accept ---------------------------------------------------------------------
136
136
  # A reviewer's FAIL is the QA gate; overriding it is the user's call and never forge's or
@@ -547,7 +547,7 @@ Retry or accept them (or split them off into their own plan) first." 3
547
547
  done
548
548
  all=1; for p in "${SRC[@]}"; do [ -f "$p/pre_review_tests" ] || all=0; done
549
549
  [ "$all" = 1 ] && : > "$NEW/pre_review_tests"
550
- for f in qa_threshold timeout verify_retries verify_parallel pre_review_parallel; do
550
+ for f in qa_threshold timeout verify_retries verify_parallel pre_review_parallel fast; do
551
551
  same=1
552
552
  for p in "${SRC[@]}"; do
553
553
  if [ ! -f "$p/$f" ] || ! cmp -s "$p/$f" "${SRC[0]}/$f"; then same=0; fi
@@ -559,6 +559,23 @@ Retry or accept them (or split them off into their own plan) first." 3
559
559
  done
560
560
  fi
561
561
  done
562
+ # A frozen profile (#48) carries over when every source froze the same one: its name, level and
563
+ # body (the time it was frozen and the flags that replaced a value do not tell profiles apart).
564
+ same=1
565
+ for p in "${SRC[@]}"; do
566
+ [ -f "$p/profile.json" ] && python3 -c '
567
+ import json, sys
568
+ def key(path):
569
+ data = json.load(open(path))
570
+ return [data.get(k) for k in ("name", "level", "body")]
571
+ sys.exit(0 if key(sys.argv[1]) == key(sys.argv[2]) else 1)' "$p/profile.json" "${SRC[0]}/profile.json" 2>/dev/null || same=0
572
+ done
573
+ if [ "$same" = 1 ]; then cp -p "${SRC[0]}/profile.json" "$NEW/profile.json"
574
+ else
575
+ for p in "${SRC[@]}"; do
576
+ if [ -f "$p/profile.json" ]; then note "the plans do not agree on profile.json; the combined plan leaves it unset"; break; fi
577
+ done
578
+ fi
562
579
  # The integration worktree needs a setup step to build and test the combined result, and
563
580
  # no task is ever dispatched here, so the first source's is as good as any.
564
581
  for p in "${SRC[@]}"; do [ -s "$p/setup_cmd" ] && { cp -p "$p/setup_cmd" "$NEW/setup_cmd"; break; }; done
@@ -359,7 +359,7 @@ PY
359
359
  # it is called from inside do_integrate.
360
360
  final_review() {
361
361
  local plan="$1" base="$2" tip="$3" src="$4" out="$5" spec="$6" yolo="${7:-}"
362
- local review n rc verdict thr gate_line gate_forced source_fp review_fp vdir tflag="" inline=1 diff_n
362
+ local review n rc verdict thr gate_line gate_forced source_fp review_fp vdir tflag="" inline=1 diff_n ft
363
363
  local plan_real prev="" prev_rel=none prev_tip="" since=none integration="" prev_note=""
364
364
  [ -n "$yolo" ] && yolo=--yolo
365
365
  [ -n "$spec" ] || { note "final review: no QA spec given"; return 3; }
@@ -378,8 +378,10 @@ final_review() {
378
378
  fi
379
379
 
380
380
  # Offline, and before anything is built or paid for: a spec that cannot resolve fails here.
381
+ # The fast-file role is review; dispatch's own role stays qa (a review is a read-only pass).
382
+ ft="$(forge_fast_tier "$plan" review)"
381
383
  FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$plan/capabilities}" \
382
- /bin/bash "$DISPATCH" doctor --spec "$spec" --role qa $yolo > "$out/doctor.out" 2>&1
384
+ /bin/bash "$DISPATCH" doctor --spec "$spec" --role qa $yolo $ft > "$out/doctor.out" 2>&1
383
385
  rc=$?
384
386
  if [ "$rc" -ne 0 ]; then
385
387
  cat "$out/doctor.out" >&2
@@ -497,7 +499,7 @@ final_review() {
497
499
  fi
498
500
  local qa_cmd=(/bin/bash "$DISPATCH" qa "$spec" --repo "$review" --run-dir "$out"
499
501
  --review-base "$(cat "$out/review.base")" --ripwire-query-file "$out/context.md"
500
- --prompt-file "$out/qa.input" ${yolo:+"$yolo"} $tflag --output "${FORGE_OUTPUT:-summary}")
502
+ --prompt-file "$out/qa.input" ${yolo:+"$yolo"} $ft $tflag --output "${FORGE_OUTPUT:-summary}")
501
503
  FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$plan/capabilities}" \
502
504
  "${qa_cmd[@]}" ${rs_cont[@]+"${rs_cont[@]}"} > "$out/qa.out" 2>&1
503
505
  rc=$?
@@ -89,6 +89,125 @@ except Exception:
89
89
  sys.exit(1)' "$1/fractal-selection.json"
90
90
  }
91
91
 
92
+ # --- fast service tier (--fast, #68) ---------------------------------------------------
93
+ # A plan or solo run keeps the roles that should ask for the fast tier in <dir>/fast,
94
+ # one role per line, in the order dwarf, qa, planner, review. Specs never change: the
95
+ # dispatch and its preflight doctor get `--service-tier fast` only for a listed role.
96
+ # Fractal dispatches through its own runner and ignores the file.
97
+ #
98
+ # forge_fast_parse sets FAST_PARSED (dynamic scope: the caller's local, when it has one)
99
+ # to `none` or the roles. forge_fast_store writes that when --fast was given this time;
100
+ # a re-plan that omits the flag leaves the file alone.
101
+ forge_fast_parse() { # forge_fast_parse <roles> <plan|solo>
102
+ local raw="$1" mode="$2" token rest seen="" w more=0
103
+ # Trim the ends only. A space inside a token is part of it: "dwa rf" is not the
104
+ # role dwarf, and deleting every space would turn that typo into a billed role.
105
+ raw="${raw#"${raw%%[![:space:]]*}"}"
106
+ raw="${raw%"${raw##*[![:space:]]}"}"
107
+ [ -n "$raw" ] || die "--fast needs a comma list of roles (dwarf, qa, planner, review), all or none"
108
+ case "$mode" in
109
+ plan|solo) ;;
110
+ *) die "--fast: internal mode '$mode'" ;;
111
+ esac
112
+ case "$raw" in
113
+ none) FAST_PARSED=none; return 0 ;;
114
+ all)
115
+ # `all` is the four plan roles. A solo run has no planner or review, so it cannot
116
+ # mean the same thing there; the user names dwarf and qa instead.
117
+ if [ "$mode" = solo ]; then
118
+ die "--fast: 'all' includes planner and review, which a solo run does not dispatch (expected dwarf, qa or none)"
119
+ fi
120
+ FAST_PARSED="dwarf
121
+ qa
122
+ planner
123
+ review"
124
+ return 0 ;;
125
+ esac
126
+ rest="$raw"
127
+ while true; do
128
+ token="${rest%%,*}"
129
+ token="${token#"${token%%[![:space:]]*}"}"
130
+ token="${token%"${token##*[![:space:]]}"}"
131
+ # A trailing comma is an empty role (`dwarf,`), so the loop must visit that field too.
132
+ case "$rest" in
133
+ *,*) rest="${rest#*,}"; more=1 ;;
134
+ *) rest=""; more=0 ;;
135
+ esac
136
+ if [ -z "$token" ]; then
137
+ if [ "$mode" = solo ]; then
138
+ die "--fast: '' is not a role of a solo run (expected dwarf, qa or none)"
139
+ fi
140
+ die "--fast: '' is not a role (expected dwarf, qa, planner, review, all or none)"
141
+ fi
142
+ if [ "$token" = all ] || [ "$token" = none ]; then
143
+ die "--fast: '$token' must be the whole value, not combined with other roles"
144
+ fi
145
+ case "$mode" in
146
+ solo) case "$token" in dwarf|qa) ;; *) die "--fast: '$token' is not a role of a solo run (expected dwarf, qa or none)" ;; esac ;;
147
+ *) case "$token" in dwarf|qa|planner|review) ;; *) die "--fast: '$token' is not a role (expected dwarf, qa, planner, review, all or none)" ;; esac ;;
148
+ esac
149
+ case " $seen " in
150
+ *" $token "*) ;;
151
+ *) seen="$seen $token" ;;
152
+ esac
153
+ [ "$more" = 1 ] || break
154
+ done
155
+ # Canonical order, whatever order the user typed. A solo run never stores planner or review.
156
+ FAST_PARSED=""
157
+ for w in dwarf qa planner review; do
158
+ [ "$mode" = solo ] && case "$w" in planner|review) continue ;; esac
159
+ case " $seen " in
160
+ *" $w "*)
161
+ if [ -n "$FAST_PARSED" ]; then FAST_PARSED="$FAST_PARSED
162
+ $w"
163
+ else FAST_PARSED="$w"; fi ;;
164
+ esac
165
+ done
166
+ }
167
+
168
+ forge_fast_store() { # forge_fast_store <dir> — honour FAST_GIVEN / FAST_PARSED from the caller
169
+ [ "${FAST_GIVEN:-0}" = 1 ] || return 0
170
+ if [ "$FAST_PARSED" = none ]; then
171
+ rm -f "$1/fast"
172
+ else
173
+ printf '%s\n' "$FAST_PARSED" > "$1/fast" || die "could not write $1/fast"
174
+ fi
175
+ }
176
+
177
+ # Prints `--service-tier fast` when <role> is listed in <dir>/fast, and nothing otherwise.
178
+ # Fractal's runner does not take the option. That is FORGE_FRACTAL_RUN once the runner is
179
+ # selected, and also a saved selection: retry preflights before the runner is selected, so
180
+ # the variable is still unset. A whole-run review is not a Fractal dispatch and still asks.
181
+ forge_fast_tier() { # forge_fast_tier <dir> <role>
182
+ local line found=0
183
+ [ -n "${FORGE_FRACTAL_RUN:-}" ] && return 0
184
+ [ -f "$1/fast" ] || return 0
185
+ while IFS= read -r line || [ -n "$line" ]; do
186
+ line="${line%$'\r'}"
187
+ line="${line#"${line%%[![:space:]]*}"}"
188
+ line="${line%"${line##*[![:space:]]}"}"
189
+ if [ "$line" = "$2" ]; then found=1; break; fi
190
+ done < "$1/fast"
191
+ [ "$found" = 1 ] || return 0
192
+ if [ "$2" != review ] && forge_plan_is_fractal "$1"; then return 0; fi
193
+ printf '%s %s\n' --service-tier fast
194
+ }
195
+
196
+ # One note per invocation, and only where this invocation's dispatches go through Fractal
197
+ # (FORGE_FRACTAL_RUN already set) or are about to (a retry of a plan whose selection is on).
198
+ # A whole-run review is not one of those dispatches, so it still asks for the tier.
199
+ # No fast file, or no fractal selection to consult, returns before any python.
200
+ forge_fast_fractal_note() { # forge_fast_fractal_note <dir>
201
+ [ -s "$1/fast" ] || return 0
202
+ [ -n "${FORGE_FAST_FRACTAL_NOTED:-}" ] && return 0
203
+ if [ -z "${FORGE_FRACTAL_RUN:-}" ]; then
204
+ [ -s "$1/fractal-selection.json" ] || return 0
205
+ forge_plan_is_fractal "$1" || return 0
206
+ fi
207
+ export FORGE_FAST_FRACTAL_NOTED=1
208
+ note "fast tier is not applied to Fractal dispatches"
209
+ }
210
+
92
211
  # The pin's spec: the first line, trimmed, a single token (it lands in a TSV column).
93
212
  # Prints nothing when the file is not a regular file or holds no usable spec.
94
213
  pin_spec() { # pin_spec <file>
@@ -11,6 +11,10 @@
11
11
  # 1 not ours, or not accepted by this subcommand
12
12
  # A malformed value exits through die (2).
13
13
  #
14
+ # A profile (plan --profile, frozen as $PLAN/profile.json) supplies --retry-failed and
15
+ # --infra-retries when `run` or `retry` is not given them; a flag wins. On `retry` they are
16
+ # the further attempts after this one (while its review fails) and the waits out of an infrastructure stop.
17
+ #
14
18
  # Persisted options become files in the plan dir, like --verify and --setup, so a later
15
19
  # `retry` or the scheduler's task processes see them. Cost-bearing options that change
16
20
  # what a run is allowed to spend (--retry-failed, --infra-retries) are deliberately NOT
@@ -19,8 +23,8 @@
19
23
  # `forge control` can change them live; the scheduler removes those files when it exits.
20
24
  #
21
25
  # --timeout S run retry $PLAN/timeout dispatch timeout, seconds (0 = none)
22
- # --retry-failed N run (this run only) automatic reviewer-driven retries
23
- # --infra-retries M run (this run only) waits out quota/auth/network stops
26
+ # --retry-failed N run retry (this run only) automatic reviewer-driven retries
27
+ # --infra-retries M run retry (this run only) waits out quota/auth/network stops
24
28
  # --infra-backoff SHAPE run $PLAN/infra_backoff waits between those stops: exp:B[,C],
25
29
  # linear:S,T[,C] or list:a,b,... (default exp:60)
26
30
  # --infra-fallback run $PLAN/infra_fallback a dwarf's stop that another model can take (capacity,
@@ -60,6 +64,8 @@
60
64
  PP_SHIFT=2
61
65
  PP_RETRY_FAILED=0
62
66
  PP_INFRA_RETRIES=0
67
+ PP_RETRY_FAILED_SET=0 # given on this command line, so a frozen profile's value does not replace it
68
+ PP_INFRA_RETRIES_SET=0
63
69
  PP_FINAL_REVIEW=""
64
70
  PP_SWEEP=""
65
71
  PP_SWEEP_MAX=5
@@ -97,11 +103,11 @@ forge_pp_flag() {
97
103
  pp_nonneg --timeout "${2:-}"
98
104
  printf '%s' "$2" > "$plan/timeout" ;;
99
105
  --retry-failed)
100
- [ "$cmd" = run ] || return 1
101
- pp_nonneg --retry-failed "${2:-}"; PP_RETRY_FAILED="$2" ;;
106
+ [ "$cmd" = run ] || [ "$cmd" = retry ] || return 1
107
+ pp_nonneg --retry-failed "${2:-}"; PP_RETRY_FAILED="$2"; PP_RETRY_FAILED_SET=1 ;;
102
108
  --infra-retries)
103
- [ "$cmd" = run ] || return 1
104
- pp_nonneg --infra-retries "${2:-}"; PP_INFRA_RETRIES="$2" ;;
109
+ [ "$cmd" = run ] || [ "$cmd" = retry ] || return 1
110
+ pp_nonneg --infra-retries "${2:-}"; PP_INFRA_RETRIES="$2"; PP_INFRA_RETRIES_SET=1 ;;
105
111
  --infra-fallback)
106
112
  [ "$cmd" = run ] || return 1
107
113
  PP_SHIFT=1; printf 'on\n' > "$plan/infra_fallback" ;;