@giamme/forge 0.22.0 → 0.23.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 (153) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +19 -12
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/docs/README.md +2 -3
  6. package/docs/add-ons.md +5 -3
  7. package/docs/artifacts.md +17 -2
  8. package/docs/commands.md +85 -63
  9. package/docs/decomposed-runs.md +195 -21
  10. package/docs/development.md +11 -9
  11. package/docs/forge-ui.md +33 -4
  12. package/docs/install.md +37 -5
  13. package/docs/memory.md +6 -1
  14. package/docs/models.md +36 -10
  15. package/docs/reviews.md +44 -25
  16. package/docs/safety.md +27 -2
  17. package/docs/troubleshooting.md +7 -10
  18. package/forge +25 -4
  19. package/package.json +2 -1
  20. package/references/dataset.md +10 -9
  21. package/references/decompose-integration.md +337 -0
  22. package/references/decompose-opt-in.md +527 -0
  23. package/references/decompose-recovery.md +569 -0
  24. package/references/decompose-review.md +256 -0
  25. package/references/decompose.md +99 -1606
  26. package/references/findings.md +68 -0
  27. package/references/harnesses.md +7 -12
  28. package/references/memory.md +13 -2
  29. package/references/planning.md +48 -18
  30. package/references/ripwire.md +38 -13
  31. package/references/runtime.md +22 -33
  32. package/references/setup.md +90 -0
  33. package/references/solo.md +13 -42
  34. package/references/ui.md +12 -5
  35. package/registry.tsv +40 -22
  36. package/scripts/forge-artifact.sh +143 -12
  37. package/scripts/forge-compare.py +5 -15
  38. package/scripts/forge-config.py +14 -1
  39. package/scripts/forge-contract.py +216 -53
  40. package/scripts/forge-control.py +777 -54
  41. package/scripts/forge-dispatch.sh +95 -12
  42. package/scripts/forge-du.py +13 -3
  43. package/scripts/forge-handoff.py +221 -39
  44. package/scripts/forge-install-ripwire.sh +100 -24
  45. package/scripts/forge-install.sh +18 -32
  46. package/scripts/forge-issues.py +6 -4
  47. package/scripts/forge-jev-options.sh +3 -5
  48. package/scripts/forge-lib-adopt.sh +169 -5
  49. package/scripts/forge-lib-attribute.sh +10 -3
  50. package/scripts/forge-lib-decompose.sh +454 -0
  51. package/scripts/forge-lib-env.sh +21 -0
  52. package/scripts/forge-lib-group.sh +4 -1
  53. package/scripts/forge-lib-plans.sh +30 -18
  54. package/scripts/forge-lib-review.sh +28 -8
  55. package/scripts/forge-lib-task.sh +225 -56
  56. package/scripts/forge-lib-verify.sh +59 -10
  57. package/scripts/forge-memory.sh +81 -4
  58. package/scripts/forge-metrics.sh +4 -2
  59. package/scripts/forge-parallel-options.sh +23 -4
  60. package/scripts/forge-parallel.sh +447 -175
  61. package/scripts/forge-plan-check.py +71 -8
  62. package/scripts/forge-planner.py +303 -17
  63. package/scripts/forge-pr.py +9 -1
  64. package/scripts/forge-prompt.py +2 -2
  65. package/scripts/forge-review-links.py +248 -0
  66. package/scripts/forge-ripwire.py +234 -16
  67. package/scripts/forge-route.py +19 -27
  68. package/scripts/forge-runs-rm.py +92 -21
  69. package/scripts/forge-runs.py +46 -5
  70. package/scripts/forge-runtime.py +37 -12
  71. package/scripts/forge-schedule.py +124 -33
  72. package/scripts/forge-setup-stale.py +236 -0
  73. package/scripts/forge-setup.py +804 -0
  74. package/scripts/forge-shadow.py +2 -20
  75. package/scripts/forge-solo-lock.py +46 -0
  76. package/scripts/forge-solo.sh +33 -56
  77. package/scripts/forge-sweep.py +2 -1
  78. package/scripts/forge-ui.py +8 -1
  79. package/scripts/forge-update.sh +2 -2
  80. package/scripts/forge-verify.py +16 -1
  81. package/scripts/forge-version.py +13 -1
  82. package/scripts/forge-watch.py +7 -2
  83. package/scripts/forge_dataset/__init__.py +1 -1
  84. package/scripts/forge_dataset/capture.py +0 -34
  85. package/scripts/forge_dataset/checks.py +0 -1
  86. package/scripts/forge_dataset/cli.py +5 -1
  87. package/scripts/forge_dataset/export.py +28 -6
  88. package/scripts/forge_dataset/facts.py +1 -2
  89. package/scripts/forge_dataset/forecast.py +1 -1
  90. package/scripts/forge_dataset/harvest.py +107 -7
  91. package/scripts/forge_dataset/importer.py +3 -2
  92. package/scripts/forge_dataset/pairs.py +3 -3
  93. package/scripts/forge_dataset/reviewers.py +4 -3
  94. package/scripts/forge_dataset/routing.py +6 -3
  95. package/scripts/forge_dataset/tiers.py +1 -1
  96. package/scripts/forge_decide/__init__.py +1 -1
  97. package/scripts/forge_decide/profiles.py +11 -14
  98. package/scripts/forge_decompose.py +987 -0
  99. package/scripts/forge_groups/review.py +6 -1
  100. package/scripts/forge_jev/__init__.py +1 -1
  101. package/scripts/forge_jev/cli.py +10 -1
  102. package/scripts/forge_jev/gates.py +10 -1
  103. package/scripts/forge_jev/verify.py +10 -2
  104. package/scripts/forge_legacy.py +86 -0
  105. package/scripts/forge_memory_home.py +57 -0
  106. package/scripts/forge_models.py +151 -0
  107. package/scripts/forge_prefs.py +138 -0
  108. package/scripts/forge_side/__init__.py +10 -0
  109. package/scripts/forge_storage.py +28 -15
  110. package/ui/README.md +22 -10
  111. package/ui/docs/api.md +121 -99
  112. package/ui/forge_ui/control.py +46 -14
  113. package/ui/forge_ui/export.py +0 -10
  114. package/ui/forge_ui/models.py +15 -2
  115. package/ui/forge_ui/projects.py +4 -1
  116. package/ui/forge_ui/reader.py +456 -59
  117. package/ui/forge_ui/server.py +0 -10
  118. package/ui/forge_ui/static/app.js +28 -9
  119. package/ui/forge_ui/static/checksview.js +12 -3
  120. package/ui/forge_ui/static/controls.js +147 -11
  121. package/ui/forge_ui/static/convo.js +5 -2
  122. package/ui/forge_ui/static/diffview.js +4 -5
  123. package/ui/forge_ui/static/panel.js +180 -77
  124. package/ui/forge_ui/static/projectsview.js +16 -2
  125. package/ui/forge_ui/static/runmodel.js +18 -4
  126. package/ui/forge_ui/static/scene3d.js +29 -29
  127. package/ui/forge_ui/static/settings.js +1 -1
  128. package/ui/forge_ui/static/storageview.js +2 -2
  129. package/ui/forge_ui/static/style.css +23 -6
  130. package/ui/forge_ui/static/worktreesview.js +8 -4
  131. package/ui/forge_ui/transcripts.py +6 -0
  132. package/ui/forge_ui/worktrees.py +13 -1
  133. package/docs/fractal.md +0 -181
  134. package/references/fractal-dashboard.md +0 -21
  135. package/references/fractal.md +0 -307
  136. package/scripts/forge-fractal-dispatch.sh +0 -4
  137. package/scripts/forge-fractal-options.sh +0 -54
  138. package/scripts/forge-fractal.py +0 -6
  139. package/scripts/forge-install-fractal.sh +0 -4
  140. package/scripts/forge_fractal/__init__.py +0 -88
  141. package/scripts/forge_fractal/bridge.py +0 -46
  142. package/scripts/forge_fractal/cli.py +0 -224
  143. package/scripts/forge_fractal/dashboard.css +0 -138
  144. package/scripts/forge_fractal/dashboard.html +0 -41
  145. package/scripts/forge_fractal/dashboard.js +0 -687
  146. package/scripts/forge_fractal/decomposition.py +0 -262
  147. package/scripts/forge_fractal/execution.py +0 -659
  148. package/scripts/forge_fractal/inspection.py +0 -261
  149. package/scripts/forge_fractal/install.py +0 -158
  150. package/scripts/forge_fractal/invocation.py +0 -95
  151. package/scripts/forge_fractal/pipeline.py +0 -125
  152. package/scripts/forge_fractal/selection.py +0 -180
  153. package/ui/forge_ui/fractal.py +0 -582
@@ -13,6 +13,9 @@
13
13
  # (claude, openclaude, codex; custom prompt only)
14
14
  # forge-dispatch.sh dwarf <spec> ... --continue-session <id> continue that implementer session
15
15
  # (claude, openclaude)
16
+ # forge-dispatch.sh dwarf <spec> ... --steer <plan> <task> <attempt> live steering (#252): a claude or
17
+ # openclaude implementer takes the task's `forge control steer --now`
18
+ # messages while it runs (stream-json input fed by forge-control.py)
16
19
  # forge-dispatch.sh side <spec> --prompt-file <f> [--repo <dir>] [--run-dir <d>] [--yolo] [--dry-run]
17
20
  # read-only; a brief or summary dispatch (default effort low)
18
21
  # any role: [--no-ripwire] [--ripwire-query-file <requirements>]
@@ -39,11 +42,15 @@
39
42
  #
40
43
  # Environment: FORGE_REGISTRY alternate registry file (default: <skill>/registry.tsv)
41
44
  # FORGE_ORPHAN_GUARD off = do not run the harness in its own process group
42
- # (default on; also skipped under FORGE_FRACTAL_RUN)
45
+ # (default on)
43
46
  # FORGE_RESULT_GRACE claude/openclaude: seconds a log that ends in the model's final
44
47
  # result may stay silent before forge ends the harness (an open
45
48
  # background task keeps it up); default 1800, 0 = off. Either way
46
49
  # a dispatch killed after that result is not a timeout.
50
+ # FORGE_LIVE_STEER off = never run an implementer live, --steer or not (default on)
51
+ # FORGE_LIVE_GRACE live steering: seconds of silence after the final result, with no
52
+ # background task open, before forge ends the harness (default 10;
53
+ # its input stays open, so it never exits by itself)
47
54
  #
48
55
  # Exit codes: 0 ok | 2 usage/resolution error | 3 harness missing or unusable
49
56
  # (including a --service-tier fast the harness cannot take per invocation)
@@ -288,6 +295,7 @@ SPEC="$1"; shift
288
295
  RIPWIRE_QUERY=""
289
296
  OUTPUT=full
290
297
  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=""
298
+ LIVE=0; LIVE_PLAN=""; LIVE_TASK=""; LIVE_ATTEMPT=""
291
299
  while [ $# -gt 0 ]; do
292
300
  case "$1" in
293
301
  --no-ripwire) export FORGE_RIPWIRE=off; shift ;;
@@ -304,6 +312,8 @@ while [ $# -gt 0 ]; do
304
312
  --service-tier) [ $# -ge 2 ] || die "--service-tier needs a value"; [ "$2" = fast ] || die "--service-tier accepts only fast"; SERVICE_TIER=fast; shift 2 ;;
305
313
  --yolo) YOLO=1; shift ;;
306
314
  --dry-run) DRY=1; shift ;;
315
+ --steer) [ $# -ge 4 ] || die "--steer needs a plan dir, a task id and an attempt number"
316
+ LIVE_PLAN="$2"; LIVE_TASK="$3"; LIVE_ATTEMPT="$4"; shift 4 ;;
307
317
  *) die "unknown option '$1'" ;;
308
318
  esac
309
319
  done
@@ -337,7 +347,14 @@ else
337
347
  # never seen, and guessing wrong burns a real dispatch.
338
348
  [ -n "$HARNESS" ] || die "'$ALIAS' is not a known alias. Either add it to $REGISTRY or name the harness explicitly, e.g. --dwarf $ALIAS:high:opencode"
339
349
  if [ -n "$(awk -F'\t' -v a="$ALIAS" '!/^#/ && $1 == a {print; exit}' "$REGISTRY")" ]; then
340
- note "alias '$ALIAS' has no row for harness '$HARNESS' — using it as a literal model id"
350
+ # An alias is one model on every harness (#187): another version a harness serves has a
351
+ # versioned alias of its own (opus-4.6 on antigravity). Name those, so the fix is one word.
352
+ VERSIONED="$(awk -F'\t' -v a="$ALIAS-" -v h="$HARNESS" '!/^#/ && index($1, a) == 1 && $2 == h {printf "%s%s", sep, $1; sep=", "}' "$REGISTRY")"
353
+ if [ -n "$VERSIONED" ]; then
354
+ note "alias '$ALIAS' has no row for harness '$HARNESS' — using it as a literal model id ($HARNESS serves $VERSIONED)"
355
+ else
356
+ note "alias '$ALIAS' has no row for harness '$HARNESS' — using it as a literal model id"
357
+ fi
341
358
  else
342
359
  note "'$ALIAS' is not in the registry — using it as a literal model id on $HARNESS"
343
360
  fi
@@ -455,6 +472,24 @@ RESULT_GRACE="${FORGE_RESULT_GRACE:-1800}"
455
472
  case "$RESULT_GRACE" in ''|*[!0-9]*) die "FORGE_RESULT_GRACE must be a nonnegative integer" ;; esac
456
473
  [ "${#RESULT_GRACE}" -gt 9 ] || RESULT_GRACE=$((10#$RESULT_GRACE))
457
474
 
475
+ # --- live steering (#252) -------------------------------------------------------
476
+ # A claude or openclaude implementer given --steer reads stream-json on stdin: forge-control.py
477
+ # _steer-feed sends the prompt as the first user message, then each `forge control steer --now`
478
+ # message, which the CLI takes in at its next tool boundary. Windows has no FIFO for the feed, so
479
+ # it dispatches as before. Preflight turns it off for a CLI whose help lacks the input flags.
480
+ LIVE_GRACE="${FORGE_LIVE_GRACE:-10}"
481
+ case "$LIVE_GRACE" in ''|*[!0-9]*) die "FORGE_LIVE_GRACE must be a nonnegative integer" ;; esac
482
+ if [ -n "$LIVE_PLAN" ]; then
483
+ case "$LIVE_ATTEMPT" in ''|0*|*[!0-9]*) die "--steer needs a positive attempt number" ;; esac
484
+ [ -d "$LIVE_PLAN" ] || die "--steer: '$LIVE_PLAN' is not a directory"
485
+ LIVE_PLAN="$(cd "$LIVE_PLAN" && pwd)"
486
+ case "${FORGE_LIVE_STEER:-on}" in off|OFF|Off|0|no|false) ;; *)
487
+ if [ "$ROLE" = dwarf ] && ! forge_is_windows; then
488
+ case "$HARNESS" in claude|openclaude) LIVE=1 ;; esac
489
+ fi ;;
490
+ esac
491
+ fi
492
+
458
493
  # --- run dir & prompt ---------------------------------------------------------
459
494
  [ -d "$REPO" ] || die "--repo '$REPO' is not a directory"
460
495
  REPO="$(cd "$REPO" && pwd)"
@@ -481,6 +516,8 @@ if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
481
516
  # dispatch and must not be the thing that hangs it.
482
517
  exit_cleanup() {
483
518
  [ -z "${tpid:-}" ] || kill -TERM "$tpid" 2>/dev/null
519
+ # Live steering: the feeder ends with its harness; its unsent messages go back to the queue.
520
+ [ "${LIVE:-0}" != 1 ] || [ -z "${FEED_STOP:-}" ] || { : > "$FEED_STOP"; } 2>/dev/null
484
521
  local _hw="${hwinpid:-${hpid:-}}"
485
522
  if [ -n "${hpid:-}" ] && kill -0 "$hpid" 2>/dev/null; then
486
523
  [ "${GUARD_ON:-0}" != 1 ] || forge_kill_group "$hpid" TERM
@@ -657,6 +694,9 @@ build_cmd() {
657
694
  # its conversation (forge-ui reads it), ending in the `result` line forge-runtime.py
658
695
  # takes the final message and the tokens from. stream-json needs --verbose with -p.
659
696
  CMD+=(--output-format stream-json --verbose)
697
+ # Live steering (#252): the prompt and later messages come as stream-json user messages, and
698
+ # the log replays each one where the CLI took it in (forge-ui shows them in the conversation).
699
+ [ "$LIVE" != 1 ] || CMD+=(--input-format stream-json --replay-user-messages)
660
700
  [ -n "$EFFORT" ] && CMD+=(--effort "$EFFORT")
661
701
  # Hidden: claude --help does not list it. openclaude has no per-invocation tier
662
702
  # and is refused before build_cmd; this guard keeps the flag off its argv too.
@@ -810,6 +850,16 @@ preflight_command() {
810
850
  codex) help_args=(exec --help); continue_args=(exec resume --help); [ "$NATIVE_REVIEW" = 1 ] && help_args=(exec review --help) ;;
811
851
  opencode) help_args=(run --help) ;;
812
852
  esac
853
+ # A CLI that does not advertise the stream-json input runs as before, without live steering.
854
+ if [ "$LIVE" = 1 ]; then
855
+ help="$(capability_help "$bin" --help 2>/dev/null)" || help=""
856
+ for flag in --input-format --replay-user-messages; do
857
+ printf '%s\n' "$help" | grep -E -- "(^|[[:space:],|])$flag([=[:space:],|]|$)" >/dev/null && continue
858
+ LIVE=0; build_cmd
859
+ note "$HARNESS does not advertise $flag; this implementer runs without live steering"
860
+ break
861
+ done
862
+ fi
813
863
  # grok's help hides --background-wait-timeout, which every grok recipe passes. grok checks
814
864
  # every flag and its value before it answers --help, so a help call with the flag in front
815
865
  # proves it exists.
@@ -852,6 +902,7 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
852
902
  echo "timeout=$LIMIT"
853
903
  echo "timeout_source=$LIMIT_SOURCE"
854
904
  case "$HARNESS" in claude|openclaude) echo "result_grace=$RESULT_GRACE" ;; esac
905
+ [ "$LIVE" != 1 ] || echo "steer=live"
855
906
  # Native review ignores the assembled prompt, so whether it reached the model is a fact
856
907
  # worth recording rather than inferring from the role and harness later.
857
908
  echo "delivery=$([ "$NATIVE_REVIEW" = 1 ] && echo native_review || echo custom)"
@@ -927,19 +978,27 @@ t0="$(date +%s)"
927
978
  # process running after dispatch returns, mutating the tree under whoever reads it next.
928
979
  # forge-guard.py does setsid() and then exec()s the harness, so $! is still the harness
929
980
  # pid and is now also its group id; after the harness exits, anything left in the group is
930
- # reaped and listed. Off by kill switch, and under Fractal (which manages its own process
931
- # groups and would otherwise lose the ability to signal this one). If the helper cannot
981
+ # reaped and listed. Off by kill switch. If the helper cannot
932
982
  # even start, fall back to the plain exec: a guard failure must never cost the run.
933
983
  GUARD_ON=0; reaped=0
934
984
  case "${FORGE_ORPHAN_GUARD:-on}" in off|OFF|Off|0|no|false) ;; *)
935
- if [ -z "${FORGE_FRACTAL_RUN:-}" ] && [ -r "$GUARD" ] && [ "$(python3 "$GUARD" ping 2>/dev/null)" = ok ]; then GUARD_ON=1; fi ;;
985
+ if [ -r "$GUARD" ] && [ "$(python3 "$GUARD" ping 2>/dev/null)" = ok ]; then GUARD_ON=1; fi ;;
936
986
  esac
937
987
  RUNCMD=("${CMD[@]}")
938
988
  # Windows MSYS2 mode (forge-win.sh): the harness gets the PATH it had in Git Bash, not MSYS2's.
939
989
  [ -z "${FORGE_WIN_AGENT_PATH:-}" ] || RUNCMD=(env -u MSYS -u FORGE_WIN_AGENT_PATH "PATH=$FORGE_WIN_AGENT_PATH" "MSYSTEM=${FORGE_WIN_MSYSTEM-}" "${CMD[@]}")
940
990
  [ "$GUARD_ON" != 1 ] || RUNCMD=(python3 "$D_GUARD" session -- "${RUNCMD[@]}")
941
991
  role_env() { [ -z "$D_ROLE_TMP" ] || export TMPDIR="$D_ROLE_TMP" TMP="$D_ROLE_TMP" TEMP="$D_ROLE_TMP"; }
942
- if [ "$PROMPT_VIA_STDIN" = 1 ]; then
992
+ FEED_STOP="$RUN_DIR/$ROLE.feed.stop"; FEED_PID="$RUN_DIR/$ROLE.feed.pid"
993
+ if [ "$LIVE" = 1 ]; then
994
+ # The feeder is the harness's stdin, and the harness becomes its parent through the exec: it stops
995
+ # when the model ends its turn, when the harness is gone, or when FEED_STOP appears. Its own
996
+ # messages go to $ROLE.feed, never into the log forge parses.
997
+ rm -f "$FEED_STOP" "$FEED_PID"
998
+ ( cd "$REPO" && role_env && exec "${RUNCMD[@]}" < <(exec python3 "$SKILL_DIR/scripts/forge-control.py" _steer-feed "$LIVE_PLAN" "$LIVE_TASK" \
999
+ "$LIVE_ATTEMPT" "$PROMPT_FILE" "$LOG" --harness "$HARNESS" --stop "$FEED_STOP" --pidfile "$FEED_PID" \
1000
+ </dev/null 2>>"$RUN_DIR/$ROLE.feed") ) > "$LOG" 2>&1 &
1001
+ elif [ "$PROMPT_VIA_STDIN" = 1 ]; then
943
1002
  ( cd "$REPO" && role_env && { ! forge_is_windows || export MSYS_NO_PATHCONV=1; } && exec "${RUNCMD[@]}" < "$PROMPT_FILE" ) > "$LOG" 2>&1 &
944
1003
  else
945
1004
  ( cd "$REPO" && role_env && { ! forge_is_windows || export MSYS_NO_PATHCONV=1; } && exec "${RUNCMD[@]}" </dev/null ) > "$LOG" 2>&1 &
@@ -972,6 +1031,18 @@ if [ "$GUARD_ON" = 1 ]; then
972
1031
  python3 "$GUARD" track "$hwinpid" "$RUN_DIR/$ROLE.tracked" </dev/null >/dev/null 2>&1 & tpid=$!
973
1032
  fi
974
1033
 
1034
+ stop_feeder() {
1035
+ local fp n=0
1036
+ : > "$FEED_STOP" 2>/dev/null
1037
+ fp="$(cat "$FEED_PID" 2>/dev/null)"
1038
+ case "$fp" in ''|*[!0-9]*) fp="" ;; esac
1039
+ while [ -n "$fp" ] && kill -0 "$fp" 2>/dev/null && [ "$n" -lt 30 ]; do sleep 0.1; n=$((n + 1)); done
1040
+ [ -z "$fp" ] || kill -TERM "$fp" 2>/dev/null
1041
+ n="$(python3 "$SKILL_DIR/scripts/forge-control.py" _steer-close "$LIVE_PLAN" "$LIVE_TASK" 2>/dev/null)" || n=0
1042
+ case "$n" in ''|*[!0-9]*|0) ;; *) note "$n live message(s) arrived after the implementer's final result; they wait for the task's next attempt" ;; esac
1043
+ rm -f "$FEED_STOP" "$FEED_PID"
1044
+ }
1045
+
975
1046
  # Ends the harness: the whole process group first when the harness has its own (GUARD_ON),
976
1047
  # then children, then the process itself, then SIGKILL for a CLI that traps TERM and takes
977
1048
  # its time. Without the guard there is no group to signal as a unit.
@@ -1002,13 +1073,19 @@ if [ "${LIMIT:-0}" != "0" ]; then
1002
1073
  fi
1003
1074
  # A final result the CLI stays open after (#110): once the log ends in it and has been silent for
1004
1075
  # the grace, the harness is ended like a timeout, but the result stands (see below).
1005
- spid=""
1076
+ # Live, its input stays open, so the CLI never exits by itself: with no background task open,
1077
+ # FORGE_LIVE_GRACE of silence after the result is enough.
1078
+ spid=""; LIVE_QUICK=""; [ "$LIVE" != 1 ] || LIVE_QUICK="$LIVE_GRACE"
1079
+ rm -f "$RUN_DIR/.$ROLE.settle"
1006
1080
  case "$HARNESS" in claude|openclaude)
1007
- if [ "$RESULT_GRACE" != 0 ]; then
1081
+ if [ "$RESULT_GRACE" != 0 ] || [ "$LIVE" = 1 ]; then
1008
1082
  (
1009
- python3 "$RUNTIME" settle "$LOG" "$RESULT_GRACE" "$hwinpid" </dev/null || exit 0
1083
+ # Straight into the file, not through $(...): the settler stays this watcher's own child, so
1084
+ # the kill after `wait` below reaches it (a grandchild would outlive the dispatch, holding
1085
+ # whatever it inherited, such as a solo run's lock).
1086
+ python3 "$RUNTIME" settle "$LOG" "$RESULT_GRACE" "$hwinpid" ${LIVE_QUICK:+"$LIVE_QUICK"} </dev/null > "$RUN_DIR/.$ROLE.settle" || exit 0
1010
1087
  kill -0 "$hpid" 2>/dev/null || exit 0
1011
- : > "$RUN_DIR/$ROLE.settled"
1088
+ mv -f "$RUN_DIR/.$ROLE.settle" "$RUN_DIR/$ROLE.settled"
1012
1089
  stop_harness
1013
1090
  ) >/dev/null 2>&1 &
1014
1091
  spid=$!
@@ -1031,12 +1108,16 @@ for watcher in $wpid $spid; do
1031
1108
  kill "$watcher" 2>/dev/null
1032
1109
  wait "$watcher" 2>/dev/null
1033
1110
  done
1111
+ rm -f "$RUN_DIR/.$ROLE.settle"
1034
1112
  # Anything the harness left running in its group is an abandoned background job, and so is
1035
1113
  # anything the tracker saw it start that is still alive, in whatever session: a timeout stops
1036
1114
  # the harness, not the test servers its tools started (#129). Kill them before reading the
1037
1115
  # tree, and leave the list for the caller. Bounded (~6s) and advisory: a reaper failure
1038
1116
  # changes nothing about the exit code.
1039
1117
  if [ -n "$tpid" ]; then kill -TERM "$tpid" 2>/dev/null; wait "$tpid" 2>/dev/null; tpid=""; fi
1118
+ # The feeder is forge's, not the harness's: it is stopped (at most ~3s) before the reap below could
1119
+ # count it as an orphan, and what it left unsent goes back to the queue for the next attempt.
1120
+ [ "$LIVE" != 1 ] || stop_feeder
1040
1121
  if [ "$GUARD_ON" = 1 ]; then
1041
1122
  orphans_found="$(python3 "$GUARD" reap "$hwinpid" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" 2>/dev/null)"
1042
1123
  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
@@ -1062,12 +1143,14 @@ if [ -f "$RUN_DIR/$ROLE.settled" ] || [ -f "$RUN_DIR/$ROLE.timedout" ]; then
1062
1143
  case "$HARNESS" in claude|openclaude)
1063
1144
  if verdict="$(python3 "$RUNTIME" settled "$LOG" 2>/dev/null)"; then
1064
1145
  # The marker is written before the harness is stopped, so it says the grace came first.
1065
- if [ -f "$RUN_DIR/$ROLE.settled" ]; then after="${RESULT_GRACE}s of silence"; ended_by=grace
1146
+ if [ "$(cat "$RUN_DIR/$ROLE.settled" 2>/dev/null)" = quick ]; then after="${LIVE_GRACE}s of silence"; ended_by=live
1147
+ elif [ -f "$RUN_DIR/$ROLE.settled" ]; then after="${RESULT_GRACE}s of silence"; ended_by=grace
1066
1148
  else after="the ${LIMIT}s timeout"; ended_by=timeout; fi
1067
1149
  printf 'ended_by=%s\nbackend_exit=%s\n' "$ended_by" "$rc" > "$RUN_DIR/$ROLE.settled"
1068
1150
  rm -f "$RUN_DIR/$ROLE.timedout"
1069
1151
  if [ "$verdict" = error ]; then rc=1; else rc=0; fi
1070
- note "$HARNESS gave its final result, then stayed open on a background task; forge ended it after $after — the result stands"
1152
+ # Live, that is how every implementer ends: its input stays open, so it never exits by itself.
1153
+ [ "$ended_by" = live ] || note "$HARNESS gave its final result, then stayed open on a background task; forge ended it after $after — the result stands"
1071
1154
  elif [ -f "$RUN_DIR/$ROLE.settled" ]; then
1072
1155
  rm -f "$RUN_DIR/$ROLE.settled"; : > "$RUN_DIR/$ROLE.timedout"
1073
1156
  note "$HARNESS began another turn while forge was ending it after its final result — see $LOG"
@@ -11,18 +11,19 @@ every repository with `--all`:
11
11
  worktrees each run's worktree folder (<repo>/../.forge-worktrees/<run id>); forge-ui's Worktrees
12
12
  screen has the state of each one and the command that removes it safely
13
13
  data home the dataset (kept: it is what forge learns from), its blobs, archives, exports, legacy
14
+ removed what a removed part of forge left behind: the state directory of Fractal (removed in 0.23),
15
+ with the command that deletes it. forge never deletes it for you
14
16
 
15
17
  Sizes are disk usage, as `du` counts it (forge_storage.py has the rules). It reads only, and measuring a
16
18
  large tree takes a while: every file is visited. The repository's total is kept for the storage.warn-gb
17
19
  check at run start.
18
20
 
19
- --json prints {repo, computed, complete, runs, strays, worktrees, data_home, totals, commands}.
21
+ --json prints {repo, computed, complete, runs, strays, worktrees, data_home, totals, removed, commands}.
20
22
  """
21
23
  from __future__ import annotations
22
24
 
23
25
  import argparse
24
26
  import json
25
- import os
26
27
  from pathlib import Path
27
28
  import shlex
28
29
  import subprocess
@@ -62,6 +63,10 @@ def commands(result: dict) -> list[dict]:
62
63
  if result['worktrees']:
63
64
  out.append(dict(label='see each worktree\'s state and the command that removes it safely', command='forge ui open',
64
65
  bytes=result['totals']['worktrees'], note='then open Worktrees'))
66
+ for left in result.get('removed') or []:
67
+ out.append(dict(label='delete what %s left behind (forge %s removed it; nothing reads this directory, and old '
68
+ 'runs stay readable without it)' % (left['name'], left['since']),
69
+ command='rm -rf -- %s' % shlex.quote(left['path']), bytes=left['bytes']))
65
70
  return out
66
71
 
67
72
 
@@ -95,7 +100,7 @@ def print_text(result: dict, top: int) -> None:
95
100
  name = run['run_id'] if len(run['run_id']) <= 28 else run['run_id'][:27] + '…'
96
101
  print(' %-28s %9s %10s %9s %9s %12s %12s %s' % (
97
102
  name, size_text(run['total']), size_text(run['snapshots']), size_text(run['logs'] + run['gz']),
98
- size_text(run['other'] + run['fractal']), size_text(run['strays']) if run['strays'] else '-',
103
+ size_text(run['other']), size_text(run['strays']) if run['strays'] else '-',
99
104
  size_text(run['reclaimable']), age(run['updated'], now)))
100
105
  print(' %s' % run['path'])
101
106
  if result['strays']:
@@ -115,6 +120,8 @@ def print_text(result: dict, top: int) -> None:
115
120
  '(forge dataset export writes them again); legacy %s; other %s'
116
121
  % (size_text(p['dataset']), size_text(p['blobs']), size_text(p['archive']), size_text(p['exports']),
117
122
  size_text(p['legacy']), size_text(p['storage'] + p['other'])))
123
+ for left in result.get('removed') or []:
124
+ print('\nleft by %s, which forge %s removed: %s in %s' % (left['name'], left['since'], size_text(left['bytes']), left['path']))
118
125
  if result['commands']:
119
126
  print('\nto take space back:')
120
127
  for c in result['commands']:
@@ -158,6 +165,9 @@ def main(argv=None) -> int:
158
165
  print('forge du: no registered runs for %s' % (repo or 'any repository'))
159
166
  if result['data_home']:
160
167
  print('data home %s: %s' % (result['data_home']['path'], size_text(result['data_home']['bytes'])))
168
+ for left in result['removed']:
169
+ print('left by %s, which forge %s removed: %s in %s\n to delete it: rm -rf -- %s'
170
+ % (left['name'], left['since'], size_text(left['bytes']), left['path'], shlex.quote(left['path'])))
161
171
  return 0
162
172
  print_text(result, args.top)
163
173
  return 0