@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
@@ -59,33 +59,15 @@ STOP_WAIT_S = 10
59
59
  PREPARE_TIMEOUT_S = 120
60
60
 
61
61
 
62
- def plan_is_fractal(plan: Path) -> bool:
63
- """True when this plan's saved selection says Fractal runs the dispatches."""
64
- try:
65
- data = json.loads((plan / 'fractal-selection.json').read_text())
66
- except (OSError, ValueError):
67
- return False
68
- return isinstance(data, dict) and bool(data.get('enabled'))
69
-
70
-
71
62
  def service_tier_args(plan: Path, role: str) -> list[str]:
72
63
  """`--service-tier fast` when <role> is a line of <plan>/fast, and nothing otherwise.
73
-
74
- Fractal dispatches through its own runner and does not take the option. A retry
75
- preflights before that runner is selected, so a plan whose selection is already on
76
- is the same case for every role it dispatches. A whole-run review is not one of them.
77
- Specs never change.
78
- """
79
- if os.environ.get('FORGE_FRACTAL_RUN'):
80
- return []
64
+ Specs never change."""
81
65
  try:
82
66
  text = (plan / 'fast').read_text()
83
67
  except OSError:
84
68
  return []
85
69
  if role not in [line.strip() for line in text.splitlines() if line.strip()]:
86
70
  return []
87
- if role != 'review' and plan_is_fractal(plan):
88
- return []
89
71
  return ['--service-tier', 'fast']
90
72
 
91
73
 
@@ -241,7 +223,7 @@ def run(args) -> int:
241
223
  parent = os.getppid()
242
224
  status, out, spec, why, review = 'skipped', None, None, None, None
243
225
  try:
244
- if os.environ.get('FORGE_FRACTAL_RUN') or not sampled(plan, args.task, args.attempt, rate_of(plan)):
226
+ if not sampled(plan, args.task, args.attempt, rate_of(plan)):
245
227
  return 0
246
228
  spec, why = pick(candidates(plan), args.qa)
247
229
  if not spec:
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env python3
2
+ """Take a solo run's lock, then run forge-solo.sh under it.
3
+
4
+ forge-solo-lock.py <run-dir> <script> [args...]
5
+
6
+ `<run-dir>/pipeline.lock` is held for the whole run: the re-executed script inherits the open
7
+ file, and FORGE_SOLO_LOCK names the run directory so it knows it is the one holding it. A second
8
+ run of the same directory, `forge runs rm` and `forge runs compact` find the lock busy. Exit 3
9
+ when another process holds it.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import os
14
+ import sys
15
+ from pathlib import Path
16
+
17
+ _SCRIPTS = str(Path(__file__).resolve().parent)
18
+ if _SCRIPTS not in sys.path:
19
+ sys.path.insert(0, _SCRIPTS)
20
+ import forge_flock as fcntl # noqa: E402
21
+ import forge_proc # noqa: E402
22
+
23
+
24
+ def main(argv: list) -> int:
25
+ if len(argv) < 2:
26
+ print(__doc__.strip(), file=sys.stderr)
27
+ return 2
28
+ run = argv[0]
29
+ try:
30
+ handle = (Path(run) / 'pipeline.lock').open('a')
31
+ fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB)
32
+ except BlockingIOError:
33
+ print('forge: another forge-solo.sh run of ' + run + ' is still going; wait for it to end, '
34
+ 'or use a new run directory', file=sys.stderr)
35
+ return 3
36
+ except OSError as error:
37
+ print('forge: could not take the lock of ' + run + ': ' + str(error), file=sys.stderr)
38
+ return 3
39
+ os.set_inheritable(handle.fileno(), True)
40
+ forge_proc.exec_or_exit(forge_proc.bash_cmd(*argv[1:]), env=dict(os.environ, FORGE_SOLO_LOCK=run),
41
+ inherit_fds=True)
42
+ return 0
43
+
44
+
45
+ if __name__ == '__main__':
46
+ sys.exit(main(sys.argv[1:]))
@@ -19,7 +19,7 @@
19
19
  # forge-solo.sh <run-dir> --repo <dir> --dwarf <spec> [--qa <spec>]
20
20
  # [--approach <file>] [--yolo-dwarf] [--yolo-qa]
21
21
  # [--native-review] [--no-memory] [--timeout <s>] [--dry-run] [--ui]
22
- # [--fail-first] [--qa-threshold P0|P1|P2|P3|none]
22
+ # [--fail-first] [--qa-threshold P0|P1|P2|P3|none] [--qa-test-minutes N]
23
23
  # [--fast ROLES] dwarf, qa or none (planner, review and all are refused);
24
24
  # kept in <run-dir>/fast. none removes it; omitting it keeps it
25
25
  # [--profile NAME | --no-profile] a named profile (forge config profile list) picks
@@ -56,7 +56,6 @@ DISPATCH="$SKILL_DIR/scripts/forge-dispatch.sh"
56
56
  MEMORY="$SKILL_DIR/scripts/forge-memory.sh"
57
57
  source "$SKILL_DIR/scripts/forge-artifact.sh"
58
58
  source "$SKILL_DIR/scripts/forge-metrics.sh"
59
- source "$SKILL_DIR/scripts/forge-fractal-options.sh"
60
59
  source "$SKILL_DIR/scripts/forge-ui-options.sh"
61
60
  source "$SKILL_DIR/scripts/forge-lib-task.sh"
62
61
  JEV_OPTS=0
@@ -67,8 +66,8 @@ ORIGINAL_ARGS=("$@")
67
66
  die() { printf 'forge: %s\n' "$1" >&2; exit "${2:-2}"; }
68
67
  note() { printf 'forge: %s\n' "$*" >&2; }
69
68
 
70
- # forge_metric_begin's EXIT trap calls this, before runtime finish and Fractal's
71
- # _outcome read status. Only this script defines it. It must not change the exit code.
69
+ # forge_metric_begin's EXIT trap calls this, before runtime finish reads status.
70
+ # Only this script defines it. It must not change the exit code.
72
71
  forge_metric_on_exit() {
73
72
  local rc="${1:-}" status="" word="" cls="" n=0 pick=""
74
73
  [ -n "${RUN:-}" ] || return 0
@@ -108,8 +107,6 @@ forge_metric_on_exit() {
108
107
 
109
108
  if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
110
109
  sed -n '18,47s/^# *//p' "$0"
111
- forge_fractal_help
112
- echo 'Explicit Fractal retry: repeat the original command with --retry.'
113
110
  exit 0
114
111
  fi
115
112
  RUN="${1:-}"; [ -n "$RUN" ] || die "usage: forge-solo.sh <run-dir> --repo <dir> --dwarf <spec> [--qa <spec>]"
@@ -120,15 +117,10 @@ shift
120
117
  forge_profile_py() { PYTHONPATH="$SKILL_DIR/scripts${PYTHONPATH:+:$PYTHONPATH}" python3 -m forge_decide.profiles "$@"; }
121
118
 
122
119
  OUTPUT=summary
123
- REPO="$PWD"; DWARF=""; QA="opus"; APPROACH=""; YD=""; YQ=""; NATIVE=""; TIMEOUT=""; DRY=0; FAIL_FIRST=0; QA_THR=
120
+ REPO="$PWD"; DWARF=""; QA="opus"; APPROACH=""; YD=""; YQ=""; NATIVE=""; TIMEOUT=""; DRY=0; FAIL_FIRST=0; QA_THR=; QA_TEST_MINS=
124
121
  FAST_GIVEN=0; FAST_PARSED=""; QA_GIVEN=0; PF_NAME=""; PF_NONE=0
125
122
  while [ $# -gt 0 ]; do
126
123
  case "$1" in
127
- --fractal) forge_fractal_flag on || exit $?; shift ;;
128
- --fractal-auto-decompose) forge_fractal_flag on || exit $?; FRACTAL_ARGS+=("$1"); shift ;;
129
- --no-fractal) forge_fractal_flag off || exit $?; shift ;;
130
- --retry) export FORGE_FRACTAL_RETRY=1; shift ;;
131
- --fractal-*|--dwarf-low|--dwarf-medium|--dwarf-high) FRACTAL_ARGS+=("$1" "${2:?}"); shift 2 ;;
132
124
  --output) OUTPUT="${2:?}"; shift 2 ;;
133
125
  --repo) REPO="${2:?--repo needs a value}"; shift 2 ;;
134
126
  --dwarf) DWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
@@ -153,6 +145,10 @@ while [ $# -gt 0 ]; do
153
145
  QA_THR="$(printf '%s' "${2:?--qa-threshold needs P0, P1, P2, P3 or none}" | tr 'a-z' 'A-Z')"
154
146
  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
155
147
  shift 2 ;;
148
+ --qa-test-minutes)
149
+ case "${2:-}" in ''|*[!0-9]*) die "--qa-test-minutes needs a non-negative integer, got '${2:-}'" 2 ;; esac
150
+ QA_TEST_MINS="$2"
151
+ shift 2 ;;
156
152
  --ui|--no-ui) forge_ui_flag "$1"; shift ;;
157
153
  *)
158
154
  # `case` is not a loop, so `continue` here belongs to the enclosing while.
@@ -163,6 +159,11 @@ while [ $# -gt 0 ]; do
163
159
  2) exit 2 ;;
164
160
  esac
165
161
  fi
162
+ forge_removed_flag "$1"
163
+ # Solo took these only to route Fractal's child tasks.
164
+ case "$1" in --dwarf-low|--dwarf-medium|--dwarf-high|--retry)
165
+ die "$1 was removed with Fractal in forge $FORGE_FRACTAL_REMOVED_IN: a solo run has one implementer, --dwarf" ;;
166
+ esac
166
167
  die "unknown option '$1'" ;;
167
168
  esac
168
169
  done
@@ -183,14 +184,6 @@ pf_args=()
183
184
  [ -z "$QA_THR" ] || pf_args+=(--given qa_threshold)
184
185
  [ -z "$TIMEOUT" ] || pf_args+=(--given timeout)
185
186
  [ "$FAST_GIVEN" != 1 ] || pf_args+=(--given fast)
186
- pf_auto=0; pf_planner=0
187
- for pf_arg in ${FRACTAL_ARGS[@]+"${FRACTAL_ARGS[@]}"}; do
188
- case "$pf_arg" in
189
- --dwarf-low|--dwarf-medium|--dwarf-high) pf_args+=(--given "${pf_arg#--}") ;;
190
- --fractal-auto-decompose) pf_auto=1 ;;
191
- --fractal-planner) pf_planner=1; pf_args+=(--given fractal-planner) ;;
192
- esac
193
- done
194
187
  PF_LINE=""
195
188
  pf_out="$(forge_profile_py solo "$RUN" --repo "$REPO" ${pf_args[@]+"${pf_args[@]}"})" || exit $?
196
189
  while IFS="$(printf '\t')" read -r pf_key pf_val; do
@@ -200,12 +193,6 @@ while IFS="$(printf '\t')" read -r pf_key pf_val; do
200
193
  qa_threshold) QA_THR="$pf_val" ;;
201
194
  timeout) TIMEOUT="$pf_val" ;;
202
195
  fast) forge_fast_parse "$pf_val" solo; FAST_GIVEN=1 ;;
203
- # Fractal's tier pools and planner count only where Fractal is selected (and the planner
204
- # only with automatic decomposition, which --fractal-planner needs).
205
- pool.low) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-low "$pf_val") ;;
206
- pool.medium) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-medium "$pf_val") ;;
207
- pool.high) [ "$FRACTAL_CHOICE" != on ] || FRACTAL_ARGS+=(--dwarf-high "$pf_val") ;;
208
- fractal_planner) [ "$FRACTAL_CHOICE$pf_auto$pf_planner" != on10 ] || FRACTAL_ARGS+=(--fractal-planner "$pf_val") ;;
209
196
  line) PF_LINE="$pf_val" ;;
210
197
  # The gates and budget of the copy this run uses, for it and everything it starts.
211
198
  decide) [ -z "$pf_val" ] || export FORGE_DECIDE_PROFILE_JSON="$pf_val" ;;
@@ -230,6 +217,8 @@ case "$(cd "$RUN" && pwd)/" in
230
217
  esac
231
218
 
232
219
  RUN="$(cd "$RUN" && pwd)"
220
+ # A run directory an earlier forge ran under Fractal is read, never run again (#154).
221
+ [ "$DRY" = 1 ] || forge_refuse_fractal_run "$RUN" forge-solo.sh
233
222
  # The frozen copy, atomically. Only the process that holds the run's lock writes it (a refused
234
223
  # second start, or a dry run, must not change what an active run froze): the first pass above
235
224
  # only read and checked, and the re-exec under the lock chooses again from the same arguments.
@@ -241,10 +230,11 @@ fi
241
230
  # same run dir restores it rather than re-reading whatever flags are passed then.
242
231
  [ "$JEV_OPTS" = 1 ] && { forge_jev_restore "$RUN" || true; forge_jev_record "$RUN"; }
243
232
  REPO="$(cd "$REPO" && pwd)"
233
+ forge_repo_memory_off "$REPO" && export FORGE_MEMORY=off # forge setup: memory off here
244
234
  # Before any decision-model step: the privacy floor and the run budget read these.
245
235
  [ "$JEV_OPTS" = 1 ] && forge_decide_env "$REPO" "$RUN"
246
236
  if [ "$DRY" != 1 ] && [ "$(forge_posix_path "${FORGE_SOLO_LOCK:-}")" != "$RUN" ]; then
247
- exec python3 "$SKILL_DIR/scripts/forge-fractal.py" _lock "$RUN" "$0" "${ORIGINAL_ARGS[@]}"
237
+ exec python3 "$SKILL_DIR/scripts/forge-solo-lock.py" "$RUN" "$0" "${ORIGINAL_ARGS[@]}"
248
238
  fi
249
239
  # After the lock re-exec, so the process that dispatches is the one that writes it.
250
240
  forge_fast_store "$RUN"
@@ -253,28 +243,8 @@ export FORGE_CAPABILITY_CACHE="$RUN/capabilities"
253
243
  TFLAG=""; [ -n "$TIMEOUT" ] && TFLAG="--timeout $TIMEOUT"
254
244
  GOAL="$(head -1 "$RUN/goal.txt" 2>/dev/null || true)"
255
245
 
256
- FFLAGS=()
257
- [ -z "$YD" ] || FFLAGS+=(--yolo-dwarf)
258
- [ -z "$YQ" ] || FFLAGS+=(--yolo-qa)
259
- forge_fractal_select "$RUN" "$REPO" solo "$DRY" --dwarf "$DWARF" --qa "$QA" ${FFLAGS[@]+"${FFLAGS[@]}"} || exit $?
260
- forge_fast_fractal_note "$RUN"
261
- # Computed after Fractal selects, so a Fractal dispatch is not asked for the tier.
262
246
  ft_dwarf="$(forge_fast_tier "$RUN" dwarf)"
263
247
  ft_qa="$(forge_fast_tier "$RUN" qa)"
264
- if [ -n "${FORGE_FRACTAL_RUN:-}" ]; then
265
- # The UI choice is per invocation: a tmux resume replays these args and must not open it again.
266
- REMEMBER_ARGS=()
267
- for arg in "${ORIGINAL_ARGS[@]}"; do
268
- case "$arg" in --ui|--no-ui) ;; *) REMEMBER_ARGS+=("$arg") ;; esac
269
- done
270
- python3 "$SKILL_DIR/scripts/forge-fractal.py" _remember "$0" ${REMEMBER_ARGS[@]+"${REMEMBER_ARGS[@]}"} || exit $?
271
- fi
272
- if [ -n "${FORGE_FRACTAL_RUN:-}" ] && [ "$DRY" != 1 ] && [ "${FORGE_FRACTAL_RETRY:-}" != 1 ]; then
273
- python3 "$SKILL_DIR/scripts/forge-fractal.py" _checkpoint "$REPO"
274
- checkpoint_rc=$?
275
- [ "$checkpoint_rc" != 0 ] || exit 0
276
- [ "$checkpoint_rc" = 1 ] || exit "$checkpoint_rc"
277
- fi
278
248
 
279
249
  # The dispatches see a review snapshot, not the repo, so the run dir names it for the dataset.
280
250
  [ "$DRY" = 1 ] || printf '%s\n' "$REPO" > "$RUN/repo"
@@ -325,14 +295,10 @@ forge_metric_phase preflight
325
295
  /bin/bash "$DISPATCH" doctor --spec "$DWARF" --role dwarf $YD $TFLAG $ft_dwarf || exit $?
326
296
  /bin/bash "$DISPATCH" doctor --spec "$QA" --role qa $YQ $NATIVE $TFLAG $ft_qa || exit $?
327
297
  /bin/bash "$SKILL_DIR/scripts/forge-install-ripwire.sh" || true
328
- # After the _lock re-exec and the Fractal checkpoint exit, so it runs once per run.
298
+ # After the lock re-exec, so it runs once per run.
329
299
  forge_ui_launch "$RUN"
330
300
  forge_metric_phase snapshot
331
- if [ -n "${FORGE_FRACTAL_RUN:-}" ] && [ -s "$RUN/start.tree" ]; then
332
- START="$(cat "$RUN/start.tree")"
333
- else
334
- START="$(forge_tree "$REPO")" || die "cannot record starting snapshot" 3
335
- fi
301
+ START="$(forge_tree "$REPO")" || die "cannot record starting snapshot" 3
336
302
  echo "$START" > "$RUN/start.tree"
337
303
  git -C "$REPO" diff --binary HEAD "$START" -- . ':(exclude).forge' > "$RUN/existing.diff"
338
304
  forge_metric_phase dispatch
@@ -371,6 +337,7 @@ REVIEW="$RUN/review-$(date +%s)-$$"
371
337
  FORGE_REVIEW_SNAPSHOT="$REVIEW" # forge_metric_begin's EXIT trap removes it, whatever the outcome (#139)
372
338
  forge_review_snapshot "$REPO" "$START" "$END" "$REVIEW" || die "cannot create review snapshot" 3
373
339
  forge_review_deps "$REPO" "$REVIEW" "$RUN/review.deps"
340
+ forge_review_submodules "$REPO" "$REVIEW" "$RUN/review.deps"
374
341
  SOURCE_FP="$(forge_fingerprint "$REPO")" || exit 3
375
342
  [ "$(forge_tree "$REPO")" = "$END" ] || { echo INVALIDATED > "$RUN/verdict"; die "source changed while preparing QA" 5; }
376
343
  # The review snapshot is a commit; the reviewer's untracked leftovers there do not count (#95).
@@ -400,7 +367,11 @@ fi
400
367
  [ -s "$RUN/failfirst.txt" ] || echo "Forge ran no tests of its own on this attempt, so nothing here stands in for yours."
401
368
  echo
402
369
  if [ -s "$RUN/failfirst.txt" ]; then cat "$RUN/failfirst.txt"; echo; fi
403
- python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind solo --threshold "$THR"
370
+ [ -z "$QA_TEST_MINS" ] || printf '%s\n' "$QA_TEST_MINS" > "$RUN/qa_test_minutes"
371
+ _SOLO_TM="$(head -1 "$RUN/qa_test_minutes" 2>/dev/null | tr -d ' \r')"
372
+ _SOLO_TM_FLAG=()
373
+ case "$_SOLO_TM" in ''|*[!0-9]*) ;; *) _SOLO_TM_FLAG=(--test-minutes "$_SOLO_TM") ;; esac
374
+ python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind solo --threshold "$THR" ${_SOLO_TM_FLAG[@]+"${_SOLO_TM_FLAG[@]}"}
404
375
  echo
405
376
  # --irreversible-delete: a deleted file shows as a header, not every line it had (one deleted
406
377
  # data directory once made a 7.1M-character prompt that the reviewer's CLI refused).
@@ -435,7 +406,7 @@ dur_qa="$(sed -n 's/^duration_s=//p' "$RUN/qa.resolved" 2>/dev/null | tail -1)"
435
406
  # that cannot run (no output) keeps the reviewer's verdict.
436
407
  gate_note=""
437
408
  tests_note="$(forge_tests_note "$RUN/qa.last")"
438
- [ -z "$tests_note" ] || note "the reviewer's tests could not run: $tests_note"
409
+ [ -z "$tests_note" ] || note "the reviewer's tests did not complete: $tests_note"
439
410
  if [ -z "$NATIVE" ]; then
440
411
  gate_line="$(python3 "$SKILL_DIR/scripts/forge-contract.py" gate --verdict "${verdict:-UNKNOWN}" \
441
412
  --qa-last "$RUN/qa.last" --threshold "$THR" --known-issues "$RUN/known_issues.md" 2>/dev/null)" || gate_line=""
@@ -443,7 +414,13 @@ if [ -z "$NATIVE" ]; then
443
414
  printf '%s\t%s\n' "$THR" "$gate_line" > "$RUN/qa.gate"
444
415
  case "$(printf '%s' "$gate_line" | awk -F'\t' '{print $1}')" in
445
416
  accept) verdict=PASS; gate_note=" (accepted with known issues: $RUN/known_issues.md)" ;;
446
- fail) verdict=FAIL; gate_note=" (the reviewer said PASS, but listed a CONFIRMED finding at or above the $THR threshold — forge made it FAIL)" ;;
417
+ fail)
418
+ verdict=FAIL
419
+ if [ "$(printf '%s' "$gate_line" | awk -F'\t' '{print $6}')" = tests ]; then
420
+ gate_note=" (the reviewer said PASS, but reported failing tests — forge made it FAIL)"
421
+ else
422
+ gate_note=" (the reviewer said PASS, but listed a CONFIRMED finding at or above the $THR threshold — forge made it FAIL)"
423
+ fi ;;
447
424
  esac
448
425
  fi
449
426
  fi
@@ -63,6 +63,7 @@ SCRIPTS = Path(__file__).resolve().parent
63
63
  if str(SCRIPTS) not in sys.path:
64
64
  sys.path.insert(0, str(SCRIPTS))
65
65
  import forge_flock as fcntl # noqa: E402
66
+ import forge_legacy # noqa: E402
66
67
  import forge_posix # noqa: E402
67
68
  SEVERITIES = ('P0', 'P1', 'P2', 'P3')
68
69
  DEFAULT_MAX = 5 # fix tasks one sweep may add
@@ -371,7 +372,7 @@ def groups(kept: list, limit: int) -> tuple:
371
372
 
372
373
  def pools(plan: Path) -> dict:
373
374
  try:
374
- data = json.loads(read(plan / 'fractal-routing.json') or '{}')
375
+ data = json.loads(read(forge_legacy.pools_path(plan)) or '{}')
375
376
  except ValueError:
376
377
  return {}
377
378
  return data if isinstance(data, dict) else {}
@@ -190,7 +190,14 @@ def terminate(pid) -> bool:
190
190
 
191
191
 
192
192
  def read_only_wanted() -> bool:
193
- return os.environ.get('FORGE_UI_READONLY', '').strip().lower() in ('1', 'true', 'yes', 'on')
193
+ """FORGE_UI_READONLY, or `forge setup` answered ui_controls off."""
194
+ if os.environ.get('FORGE_UI_READONLY', '').strip().lower() in ('1', 'true', 'yes', 'on'):
195
+ return True
196
+ try:
197
+ import forge_prefs
198
+ except ImportError:
199
+ return False
200
+ return forge_prefs.get('ui_controls') == 'off'
194
201
 
195
202
 
196
203
  def is_read_only(answer) -> bool:
@@ -62,10 +62,10 @@ main() {
62
62
  fi
63
63
  # Updating Forge does not offer installation of optional dependencies.
64
64
  if [ "$dry" = 1 ]; then
65
- FORGE_RIPWIRE=off /bin/bash "$source_dir/scripts/forge-install.sh" --dry-run || return $?
65
+ FORGE_RIPWIRE=off FORGE_SETUP=off /bin/bash "$source_dir/scripts/forge-install.sh" --dry-run || return $?
66
66
  echo 'forge: preview only; remote changes and live harness availability are not verified'
67
67
  else
68
- FORGE_RIPWIRE=off /bin/bash "$source_dir/scripts/forge-install.sh" || {
68
+ FORGE_RIPWIRE=off FORGE_SETUP=off /bin/bash "$source_dir/scripts/forge-install.sh" || {
69
69
  echo 'forge: source retained; some installations failed. Fix the reported cause and retry with --local' >&2; return 1;
70
70
  }
71
71
  echo 'forge: installations refreshed; restart active harness sessions to load the updated skill'
@@ -281,6 +281,21 @@ def _file_mode() -> int:
281
281
  return 0o666 & ~mask
282
282
 
283
283
 
284
+ def _replace(tmp: str, path: Path) -> None:
285
+ """os.replace, which on Windows is refused (PermissionError) while another process has the
286
+ target open: forge-ui or a watcher reading lanes.json. The reader holds it for a moment, so
287
+ try again for up to 2 s instead of ending the whole verification on a read."""
288
+ deadline = time.monotonic() + 2
289
+ while True:
290
+ try:
291
+ os.replace(tmp, path)
292
+ return
293
+ except PermissionError:
294
+ if os.name != 'nt' or time.monotonic() >= deadline:
295
+ raise
296
+ time.sleep(0.01)
297
+
298
+
284
299
  def write_atomic(path: Path, text: str) -> None:
285
300
  """Write through a temp file and rename. mkstemp makes the file 0600; the lane logs
286
301
  follow the umask, so the state files get the same mode (a forge-ui server may read them
@@ -290,7 +305,7 @@ def write_atomic(path: Path, text: str) -> None:
290
305
  os.fchmod(fd, _file_mode())
291
306
  with os.fdopen(fd, 'w') as fh:
292
307
  fh.write(text)
293
- os.replace(tmp, path)
308
+ _replace(tmp, path)
294
309
  except BaseException:
295
310
  try:
296
311
  os.unlink(tmp)
@@ -161,12 +161,24 @@ def check(source: Path, info: dict) -> dict:
161
161
 
162
162
 
163
163
  def disabled() -> bool:
164
- if os.environ.get('FORGE_UPDATE_CHECK', '').strip().lower() in _OFF:
164
+ if os.environ.get('FORGE_UPDATE_CHECK', '').strip().lower() in _OFF or setup_off():
165
165
  return True
166
166
  ci = os.environ.get('CI', '').strip().lower()
167
167
  return bool(ci) and ci not in _OFF
168
168
 
169
169
 
170
+ def setup_off() -> bool:
171
+ """`forge setup` answered update_check off (setup.json); a missing helper means on."""
172
+ try:
173
+ here = str(Path(__file__).resolve().parent)
174
+ if here not in sys.path:
175
+ sys.path.insert(0, here)
176
+ import forge_prefs
177
+ except ImportError:
178
+ return False
179
+ return forge_prefs.update_check_off()
180
+
181
+
170
182
  def available_line(latest: str, current: str, info: dict | None = None) -> str:
171
183
  return f'forge {latest} is available (you have {current}): {update_command(info or {})}'
172
184
 
@@ -3,7 +3,8 @@
3
3
 
4
4
  Follow forge runs from the terminal and hear about them without keeping forge-ui open.
5
5
 
6
- A line is printed whenever a task changes status. A run that finishes or fails, a task that fails
6
+ A line is printed whenever a task changes status; the subtasks of a task that was split are
7
+ followed too, named by their path (`d/a` is subtask a of task d). A run that finishes or fails, a task that fails
7
8
  and a final review's verdict are also events: each raises a desktop notification where one can be
8
9
  shown (notify-send on Linux, osascript on macOS; on a headless machine or in CI there is no
9
10
  notifier and the events only print), and runs the optional hooks:
@@ -68,7 +69,11 @@ def run_state(summary: dict) -> str:
68
69
 
69
70
 
70
71
  def statuses(summary: dict) -> dict:
71
- return {item['id']: item['status'] for item in summary.get('task_statuses') or []}
72
+ """Every task's status, and every subtask's under a task that was split (#153), named by its path (`d/a`)."""
73
+ found = {item['id']: item['status'] for item in summary.get('task_statuses') or []}
74
+ for item in (summary.get('decomposition') or {}).get('statuses') or []:
75
+ found[item['id']] = item['status']
76
+ return found
72
77
 
73
78
 
74
79
  def goal_of(summary: dict) -> str:
@@ -17,7 +17,7 @@ can still be answered from old runs.
17
17
 
18
18
  Capture is fail-open in the same way Jev is. Every entry point swallows its own errors
19
19
  into errors.log, never prints, never raises, and bounds its wait on the database with the
20
- SQLite busy timeout. It uses no signals, because Fractal captures from worker threads.
20
+ SQLite busy timeout. It uses no signals, so a capture may run from any thread.
21
21
  record_strict() is the one exception, for a caller that must know an event is stored (it
22
22
  raises DatasetError instead of returning 0).
23
23
  FORGE_DATASET=off turns it off.
@@ -213,40 +213,6 @@ def jev(*, site, key, canonical: bytes, ok, reason, latency, model, usage, quest
213
213
  log_error('jev:' + str(site), error)
214
214
 
215
215
 
216
- def fractal_step(task_dir, node: dict, step_dir, *, phase: str, iteration, rc, cost, resolved) -> None:
217
- """One Fractal step, keyed by its own step uuid.
218
-
219
- node.json is mutable (a retry resets `iteration` to 0), so a step is recorded by
220
- the uuid of the dir it ran in rather than by (node, iteration), which can repeat.
221
- Called from worker threads: no signals, a connection per call.
222
- """
223
- if not enabled():
224
- return
225
- try:
226
- task_dir, step_dir = Path(task_dir), Path(step_dir)
227
- ctx = h.fractal_context(task_dir, create=True)
228
- if location_refused(ctx['repo']):
229
- return
230
- record([h.fractal_step_event(task_dir, node, step_dir, ctx, phase=phase, iteration=iteration, rc=rc,
231
- cost=cost, resolved=resolved)], repo=ctx['repo'], where='fractal_step')
232
- except Exception as error:
233
- log_error('fractal_step', error)
234
-
235
-
236
- def fractal_outcome(task_dir) -> None:
237
- """Every node's final state and the task outcome, once per distinct state."""
238
- if not enabled():
239
- return
240
- try:
241
- task_dir = Path(task_dir)
242
- ctx = h.fractal_context(task_dir, create=True)
243
- if location_refused(ctx['repo']):
244
- return
245
- record(h.fractal_task_events(task_dir, ctx), repo=ctx['repo'], where='fractal_outcome')
246
- except Exception as error:
247
- log_error('fractal_outcome', error)
248
-
249
-
250
216
  def plan_snapshot(plan: str) -> None:
251
217
  """Every routing, decomposition and scheduling decision made before the first dispatch."""
252
218
  if not enabled():
@@ -10,7 +10,6 @@ from __future__ import annotations
10
10
  import json
11
11
  import sqlite3
12
12
  import time
13
- from pathlib import Path
14
13
 
15
14
  from . import dataset_dir
16
15
 
@@ -292,7 +292,7 @@ def parser() -> argparse.ArgumentParser:
292
292
  p = sub.add_parser('import', help='capture run dirs, archives and ledgers that predate live capture')
293
293
  p.add_argument('paths', nargs='*', help='run/plan dirs, dirs to scan, or .tar.gz archives')
294
294
  p.add_argument('--registry', action='store_true', help='every run dir listed in the Jev runs registry')
295
- p.add_argument('--fractal', action='store_true', help='the Fractal state dir')
295
+ p.add_argument('--fractal', action='store_true', help='the state dir of Fractal (removed in forge 0.23): its old runs, to import before deleting it')
296
296
  p.add_argument('--ledger', action='append', default=[], metavar='REPO', help="a repo's .forge/ledger.tsv")
297
297
  p.add_argument('--include-temp', action='store_true', help='also import runs whose repo is a temp dir (test runs)')
298
298
  p.add_argument('--dry-run', action='store_true')
@@ -303,6 +303,7 @@ def parser() -> argparse.ArgumentParser:
303
303
  help='only this slice; repeatable (default: all)')
304
304
  p.add_argument('--limit', type=int, help='at most this many cases per slice, spread across runs')
305
305
  p.add_argument('--seed', type=int, default=7)
306
+ p.add_argument('--include-steered', action='store_true', help='keep attempts a person steered (forge control steer); left out by default')
306
307
  p.set_defaults(func=run_export)
307
308
  p = sub.add_parser('outcomes', help='what happened to integrated work afterwards (read-only git)')
308
309
  p.add_argument('--horizon-days', type=int, default=14, help='how long after integrate to look (default 14)')
@@ -317,11 +318,13 @@ def parser() -> argparse.ArgumentParser:
317
318
  p.add_argument('--repo', help='only this repo')
318
319
  p.add_argument('--since', type=float, metavar='DAYS', help='only tasks first attempted in the last DAYS days')
319
320
  p.add_argument('--json', action='store_true')
321
+ p.add_argument('--include-steered', action='store_true', help='keep attempts a person steered (forge control steer); left out by default')
320
322
  p.set_defaults(func=run_routing)
321
323
  p = sub.add_parser('reviewers', help='how often work each reviewer passed was later reverted or rewritten (advisory)')
322
324
  p.add_argument('--horizon-days', type=int, default=14, help='the outcomes recorded at this horizon (default 14)')
323
325
  p.add_argument('--repo', help='only this repo')
324
326
  p.add_argument('--json', action='store_true')
327
+ p.add_argument('--include-steered', action='store_true', help='keep attempts a person steered (forge control steer); left out by default')
325
328
  p.set_defaults(func=run_reviewers)
326
329
  p = sub.add_parser('facts', help="the reach, origin and evidence reviewers give findings: agreement, and what "
327
330
  "a gate on them would have changed (advisory)")
@@ -332,6 +335,7 @@ def parser() -> argparse.ArgumentParser:
332
335
  'from model and family comparisons and controls (advisory)')
333
336
  p.add_argument('--repo', help='only this repo')
334
337
  p.add_argument('--json', action='store_true')
338
+ p.add_argument('--include-steered', action='store_true', help='keep attempts a person steered (forge control steer); left out by default')
335
339
  p.set_defaults(func=run_pairs)
336
340
  p = sub.add_parser('risk', help="tasks by difficulty and risk together: how often they differ, and how each "
337
341
  "pair fared (advisory)")
@@ -222,10 +222,16 @@ def review_survives() -> dict:
222
222
  # --- indexes ---------------------------------------------------------------------------
223
223
 
224
224
  class Runs:
225
- """Plans, attempts and dispatches of every run, joined by (run, task)."""
225
+ """Plans, attempts and dispatches of every run, joined by (run, task).
226
226
 
227
- def __init__(self, store: Store):
227
+ A task a person steered (`forge control steer`, #134) is its own measure from the first steered
228
+ attempt on: that attempt and every later one (and their dispatches) are left out unless
229
+ `include_steered`. `steered` names those tasks, {(run, task): first steered attempt}, either way.
230
+ """
231
+
232
+ def __init__(self, store: Store, include_steered: bool = False):
228
233
  self.store = store
234
+ self.include_steered = include_steered
229
235
  self.plans = defaultdict(list)
230
236
  for e in store.of('plan'):
231
237
  self.plans[e['run']].append(e)
@@ -237,6 +243,14 @@ class Runs:
237
243
  self.attempts[(e['run'], e['task'])].append(e)
238
244
  for rows in self.attempts.values():
239
245
  rows.sort(key=lambda e: (e['attempt'] or 0, e['d'].get('wall_started') or e['ts']))
246
+ self.steered = {}
247
+ for key, rows in self.attempts.items():
248
+ marked = [e['attempt'] or 0 for e in rows if e['d'].get('steered')]
249
+ if marked:
250
+ self.steered[key] = min(marked)
251
+ if not include_steered:
252
+ for key, first in self.steered.items():
253
+ self.attempts[key] = [e for e in self.attempts[key] if (e['attempt'] or 0) < first]
240
254
  self.dispatches = defaultdict(list)
241
255
  for e in store.of('dispatch'):
242
256
  # A group review names no task. scope group stays out of per-task indexes even
@@ -247,6 +261,11 @@ class Runs:
247
261
  # the attempt ended on, so each list is chronological; a tie keeps store order.
248
262
  for rows in self.dispatches.values():
249
263
  rows.sort(key=lambda e: (e['attempt'] or 0, e['d'].get('wall_started') or e['ts']))
264
+ if not include_steered:
265
+ for (run, task, role), rows in self.dispatches.items():
266
+ first = self.steered.get((run, task))
267
+ if first is not None:
268
+ rows[:] = [e for e in rows if (e['attempt'] or 0) < first]
250
269
  self.accepted = {(e['run'], e['d'].get('task')) for e in store.of('invocation')
251
270
  if e['d'].get('command') == 'accept' and e['d'].get('exit') == 0}
252
271
  self.interrupted = {(e['run'], e['task']) for e in store.of('event')
@@ -255,7 +274,8 @@ class Runs:
255
274
  # What `forge dataset outcomes` saw after integration, per reviewed commit; the
256
275
  # longest horizon observed wins, since it is the stronger observation.
257
276
  self.reviewed = {(e['run'], e['task'], e['attempt']): e['d']['reviewed_commit']
258
- for e in store.of('attempt') if e['d'].get('reviewed_commit')}
277
+ for e in store.of('attempt') if e['d'].get('reviewed_commit')
278
+ and (include_steered or (e['attempt'] or 0) < self.steered.get((e['run'], e['task']), 1 << 30))}
259
279
  self.survival = {}
260
280
  for e in store.of('outcome'):
261
281
  d = e['d']
@@ -1042,10 +1062,11 @@ def _sample(cases: list, limit: int | None, seed: int) -> list:
1042
1062
  return picked
1043
1063
 
1044
1064
 
1045
- def build(db, *, slices=SLICES, limit: int | None = None, seed: int = 7, stats: dict | None = None) -> list:
1065
+ def build(db, *, slices=SLICES, limit: int | None = None, seed: int = 7, stats: dict | None = None,
1066
+ include_steered: bool = False) -> list:
1046
1067
  """Every case of the given slices. `stats`, when given, receives the censored-label counts."""
1047
1068
  store = Store(db)
1048
- runs = Runs(store)
1069
+ runs = Runs(store, include_steered=include_steered)
1049
1070
  builders = dict(routing=lambda: routing_cases(runs), retry=lambda: retry_cases(runs),
1050
1071
  review=lambda: review_cases(runs),
1051
1072
  drift=lambda: drift_cases(runs, seed), citation=lambda: citation_cases(runs, seed),
@@ -1106,7 +1127,8 @@ def main(args) -> int:
1106
1127
  db = connect()
1107
1128
  try:
1108
1129
  stats = {}
1109
- cases = build(db, slices=args.slices or SLICES, limit=args.limit, seed=args.seed, stats=stats)
1130
+ cases = build(db, slices=args.slices or SLICES, limit=args.limit, seed=args.seed, stats=stats,
1131
+ include_steered=getattr(args, 'include_steered', False))
1110
1132
  finally:
1111
1133
  db.close()
1112
1134
  if args.out:
@@ -25,11 +25,10 @@ from __future__ import annotations
25
25
  import json
26
26
  import os
27
27
  import re
28
- import sys
29
28
  from collections import Counter, defaultdict
30
29
 
31
30
  from . import connect, dataset_dir, is_side_role
32
- from .export import Runs, Store, _ending_qa, _gate_decision, not_an_attempt, shadow_pairs
31
+ from .export import Runs, Store, _ending_qa, not_an_attempt, shadow_pairs
33
32
 
34
33
  FACTS = {'reach': ('main', 'realistic', 'unusual'), 'origin': ('new', 'existing'),
35
34
  'evidence': ('ran', 'traced', 'suspected')}
@@ -31,7 +31,7 @@ import time
31
31
  from collections import defaultdict
32
32
  from pathlib import Path
33
33
 
34
- from . import SKILL, connect, dataset_dir, record
34
+ from . import connect, dataset_dir, record
35
35
  from .export import Runs, Store
36
36
  from .names import registry_models # noqa: F401 (forge-route, forge-compare and efforts import it from here)
37
37
  from .routing import tasks as routing_tasks, wilson