@giamme/forge 0.21.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 (165) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +25 -15
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/bin/forge.js +104 -0
  6. package/docs/README.md +2 -3
  7. package/docs/add-ons.md +5 -3
  8. package/docs/artifacts.md +17 -2
  9. package/docs/commands.md +85 -63
  10. package/docs/decomposed-runs.md +195 -21
  11. package/docs/development.md +12 -10
  12. package/docs/forge-ui.md +33 -4
  13. package/docs/install.md +127 -6
  14. package/docs/memory.md +6 -1
  15. package/docs/models.md +36 -10
  16. package/docs/reviews.md +50 -29
  17. package/docs/safety.md +27 -2
  18. package/docs/troubleshooting.md +8 -11
  19. package/forge +29 -4
  20. package/forge.cmd +56 -0
  21. package/package.json +6 -3
  22. package/references/dataset.md +10 -9
  23. package/references/decompose-integration.md +337 -0
  24. package/references/decompose-opt-in.md +527 -0
  25. package/references/decompose-recovery.md +569 -0
  26. package/references/decompose-review.md +256 -0
  27. package/references/decompose.md +99 -1606
  28. package/references/findings.md +68 -0
  29. package/references/harnesses.md +7 -12
  30. package/references/memory.md +13 -2
  31. package/references/planning.md +48 -18
  32. package/references/ripwire.md +38 -13
  33. package/references/runtime.md +22 -33
  34. package/references/setup.md +90 -0
  35. package/references/solo.md +13 -42
  36. package/references/ui.md +12 -5
  37. package/registry.tsv +40 -22
  38. package/scripts/forge-artifact.sh +148 -13
  39. package/scripts/forge-compare.py +5 -15
  40. package/scripts/forge-config.py +14 -1
  41. package/scripts/forge-contract.py +216 -53
  42. package/scripts/forge-control.py +781 -51
  43. package/scripts/forge-dispatch.sh +202 -42
  44. package/scripts/forge-du.py +13 -3
  45. package/scripts/forge-guard.py +137 -6
  46. package/scripts/forge-handoff.py +221 -39
  47. package/scripts/forge-install-ripwire.sh +100 -24
  48. package/scripts/forge-install.sh +100 -41
  49. package/scripts/forge-issues.py +6 -4
  50. package/scripts/forge-jev-options.sh +3 -5
  51. package/scripts/forge-lib-adopt.sh +169 -5
  52. package/scripts/forge-lib-attribute.sh +10 -3
  53. package/scripts/forge-lib-decompose.sh +454 -0
  54. package/scripts/forge-lib-env.sh +179 -0
  55. package/scripts/forge-lib-group.sh +9 -6
  56. package/scripts/forge-lib-plans.sh +38 -21
  57. package/scripts/forge-lib-review.sh +28 -8
  58. package/scripts/forge-lib-task.sh +263 -69
  59. package/scripts/forge-lib-verify.sh +59 -10
  60. package/scripts/forge-memory.sh +83 -4
  61. package/scripts/forge-metrics.sh +10 -3
  62. package/scripts/forge-parallel-options.sh +23 -4
  63. package/scripts/forge-parallel.sh +602 -217
  64. package/scripts/forge-plan-check.py +71 -8
  65. package/scripts/forge-planner.py +303 -17
  66. package/scripts/forge-pr.py +9 -1
  67. package/scripts/forge-prompt.py +2 -2
  68. package/scripts/forge-review-links.py +248 -0
  69. package/scripts/forge-ripwire.py +234 -16
  70. package/scripts/forge-route.py +19 -27
  71. package/scripts/forge-runs-rm.py +92 -21
  72. package/scripts/forge-runs.py +46 -5
  73. package/scripts/forge-runtime.py +39 -14
  74. package/scripts/forge-schedule.py +141 -33
  75. package/scripts/forge-setup-stale.py +236 -0
  76. package/scripts/forge-setup.py +804 -0
  77. package/scripts/forge-shadow.py +2 -20
  78. package/scripts/forge-solo-lock.py +46 -0
  79. package/scripts/forge-solo.sh +39 -58
  80. package/scripts/forge-sweep.py +3 -2
  81. package/scripts/forge-ui.py +8 -1
  82. package/scripts/forge-update.sh +8 -3
  83. package/scripts/forge-verify.py +17 -1
  84. package/scripts/forge-version.py +13 -1
  85. package/scripts/forge-watch.py +7 -2
  86. package/scripts/forge-win.sh +156 -0
  87. package/scripts/forge_brief/__init__.py +6 -1
  88. package/scripts/forge_brief/proposals.py +6 -1
  89. package/scripts/forge_dataset/__init__.py +1 -1
  90. package/scripts/forge_dataset/capture.py +0 -34
  91. package/scripts/forge_dataset/checks.py +0 -1
  92. package/scripts/forge_dataset/cli.py +5 -1
  93. package/scripts/forge_dataset/export.py +28 -6
  94. package/scripts/forge_dataset/facts.py +1 -2
  95. package/scripts/forge_dataset/forecast.py +1 -1
  96. package/scripts/forge_dataset/harvest.py +107 -7
  97. package/scripts/forge_dataset/importer.py +3 -2
  98. package/scripts/forge_dataset/pairs.py +3 -3
  99. package/scripts/forge_dataset/reviewers.py +4 -3
  100. package/scripts/forge_dataset/routing.py +6 -3
  101. package/scripts/forge_dataset/tiers.py +1 -1
  102. package/scripts/forge_decide/__init__.py +1 -1
  103. package/scripts/forge_decide/budget.py +12 -7
  104. package/scripts/forge_decide/profiles.py +11 -14
  105. package/scripts/forge_decide/replay.py +9 -4
  106. package/scripts/forge_decompose.py +987 -0
  107. package/scripts/forge_flock.py +17 -2
  108. package/scripts/forge_groups/review.py +6 -1
  109. package/scripts/forge_jev/__init__.py +1 -1
  110. package/scripts/forge_jev/cli.py +10 -1
  111. package/scripts/forge_jev/gates.py +10 -1
  112. package/scripts/forge_jev/verify.py +10 -2
  113. package/scripts/forge_legacy.py +86 -0
  114. package/scripts/forge_memory_home.py +57 -0
  115. package/scripts/forge_models.py +151 -0
  116. package/scripts/forge_posix.py +17 -0
  117. package/scripts/forge_prefs.py +138 -0
  118. package/scripts/forge_proc.py +108 -0
  119. package/scripts/forge_registry.py +2 -2
  120. package/scripts/forge_side/__init__.py +23 -4
  121. package/scripts/forge_storage.py +28 -15
  122. package/ui/README.md +22 -10
  123. package/ui/docs/api.md +121 -99
  124. package/ui/forge_ui/control.py +53 -16
  125. package/ui/forge_ui/export.py +0 -10
  126. package/ui/forge_ui/models.py +15 -2
  127. package/ui/forge_ui/projects.py +4 -1
  128. package/ui/forge_ui/reader.py +462 -60
  129. package/ui/forge_ui/server.py +0 -10
  130. package/ui/forge_ui/static/app.js +28 -9
  131. package/ui/forge_ui/static/checksview.js +12 -3
  132. package/ui/forge_ui/static/controls.js +147 -11
  133. package/ui/forge_ui/static/convo.js +5 -2
  134. package/ui/forge_ui/static/diffview.js +4 -5
  135. package/ui/forge_ui/static/panel.js +180 -77
  136. package/ui/forge_ui/static/projectsview.js +16 -2
  137. package/ui/forge_ui/static/runmodel.js +18 -4
  138. package/ui/forge_ui/static/scene3d.js +52 -31
  139. package/ui/forge_ui/static/settings.js +1 -1
  140. package/ui/forge_ui/static/storageview.js +2 -2
  141. package/ui/forge_ui/static/style.css +23 -6
  142. package/ui/forge_ui/static/worktreesview.js +8 -4
  143. package/ui/forge_ui/transcripts.py +6 -0
  144. package/ui/forge_ui/worktrees.py +13 -1
  145. package/docs/fractal.md +0 -181
  146. package/references/fractal-dashboard.md +0 -21
  147. package/references/fractal.md +0 -307
  148. package/scripts/forge-fractal-dispatch.sh +0 -4
  149. package/scripts/forge-fractal-options.sh +0 -54
  150. package/scripts/forge-fractal.py +0 -6
  151. package/scripts/forge-install-fractal.sh +0 -4
  152. package/scripts/forge_fractal/__init__.py +0 -88
  153. package/scripts/forge_fractal/bridge.py +0 -46
  154. package/scripts/forge_fractal/cli.py +0 -224
  155. package/scripts/forge_fractal/dashboard.css +0 -138
  156. package/scripts/forge_fractal/dashboard.html +0 -41
  157. package/scripts/forge_fractal/dashboard.js +0 -687
  158. package/scripts/forge_fractal/decomposition.py +0 -262
  159. package/scripts/forge_fractal/execution.py +0 -659
  160. package/scripts/forge_fractal/inspection.py +0 -261
  161. package/scripts/forge_fractal/install.py +0 -158
  162. package/scripts/forge_fractal/invocation.py +0 -95
  163. package/scripts/forge_fractal/pipeline.py +0 -125
  164. package/scripts/forge_fractal/selection.py +0 -180
  165. package/ui/forge_ui/fractal.py +0 -582
@@ -75,14 +75,14 @@ do_group() (
75
75
  # 1. Status and round.
76
76
  mkdir -p "$G" || die "could not create $G" 3
77
77
  local round REPO run_id wt_root
78
- round="$(tr -dc '0-9' < "$G/round" 2>/dev/null)"
78
+ round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
79
79
  round=$(( ${round:-0} + 1 ))
80
80
  printf '%s\n' "$round" > "$G/round.tmp" && mv -f "$G/round.tmp" "$G/round"
81
81
  # What an earlier round left that this one would otherwise be read as. attribution.json and
82
82
  # qa.round-<n>.last stay: the next prompt quotes them.
83
83
  rm -f "$G/qa.last" "$G/qa.input" "$G/qa.out" "$G/qa.gate" "$G/known_issues.md" "$G/infra.txt" "$G/decision.md" \
84
84
  "$G/conflict.files" "$G/candidate.base" "$G/candidate.commit" "$G/fingerprint" "$G/combined.diff" \
85
- "$G/merge.out" "$G/members.paths" "$G/review.base" "$G/invalidated.reason"
85
+ "$G/merge.out" "$G/members.paths" "$G/review.base" "$G/review.deps" "$G/invalidated.reason"
86
86
  group_set_status "$G" REVIEWING
87
87
  REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"; wt_root="$(cat "$PLAN/wt_root")"
88
88
  # --timeout given to run/retry is kept in the plan and wins over the environment, as for a task.
@@ -176,6 +176,8 @@ do_group() (
176
176
  note "group $gid: could not make the review snapshot"
177
177
  group_end "$G" "$round" ERROR "$qa"; return 0
178
178
  fi
179
+ run_worktree_setup "$PLAN" "$REPO" "$cand" "$G" "group-$gid"
180
+ forge_review_deps "$cand" "$snap" "$G/review.deps"
179
181
  cand_fp="$(forge_fingerprint "$cand")" || { group_end "$G" "$round" ERROR "$qa"; return 0; }
180
182
  # A commit: an untracked file the reviewer leaves behind merges nothing, so only tracked content counts (#95).
181
183
  snap_fp="$(forge_fingerprint "$snap" --tracked)" || { group_end "$G" "$round" ERROR "$qa"; return 0; }
@@ -400,7 +402,7 @@ do_group_settle() (
400
402
  done
401
403
  for id in "${ids[@]}"; do case ",${named// /}," in *",$id,"*) want+=("$id") ;; esac; done
402
404
  fi
403
- round="$(tr -dc '0-9' < "$G/round" 2>/dev/null)"
405
+ round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
404
406
  [ -n "$round" ] || die "group $gid has not been reviewed" 2
405
407
  # One settle per round, however often it is asked.
406
408
  [ "$(cat "$G/settled.round" 2>/dev/null)" = "$round" ] && return 0
@@ -532,7 +534,7 @@ merge_group() { # merge_group <plan> <gid> -> 0 merged, 1 not
532
534
  if [ "$st" != PASS ]; then note "group $gid: ${st:-not reviewed}, not PASS — nothing to merge"; return 1; fi
533
535
  REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"
534
536
  int_wt="$(cat "$PLAN/wt_root")/_integration"
535
- round="$(tr -dc '0-9' < "$G/round" 2>/dev/null)"
537
+ round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
536
538
  local ids=()
537
539
  IFS=, read -ra ids <<< "$members"
538
540
 
@@ -607,13 +609,14 @@ merge_group() { # merge_group <plan> <gid> -> 0 merged, 1 not
607
609
  for id in "${ids[@]}"; do rm -f "$PLAN/tasks/$id/.qa.last.merge.tmp"; echo CONFLICT > "$PLAN/tasks/$id/status"; done
608
610
  group_set_status "$G" CONFLICT
609
611
  forge_dataset_event group_merge --dir "$PLAN" --set group="$gid" --set status=CONFLICT --set commit="$commit" \
610
- --set conflicts="$(tr '\n' ' ' < "$G/conflict.files" 2>/dev/null)"
611
- note "group $gid: conflicts with the integration branch: $(tr '\n' ' ' < "$G/conflict.files" 2>/dev/null)"
612
+ --set conflicts="$(tr '\n' ' ' 2>/dev/null < "$G/conflict.files")"
613
+ note "group $gid: conflicts with the integration branch: $(tr '\n' ' ' 2>/dev/null < "$G/conflict.files")"
612
614
  return 1
613
615
  fi
614
616
  git -C "$int_wt" rev-parse HEAD > "$PLAN/accepted.integration"
615
617
  local tdir integration
616
618
  integration="$(cat "$PLAN/accepted.integration")"
619
+ mark_verification_stale "$PLAN" "$integration"
617
620
  for id in "${ids[@]}"; do
618
621
  tdir="$PLAN/tasks/$id"
619
622
  touch "$tdir/merged"
@@ -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 reviewer_session_rate reviewer_session_tasks 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 retry_per_model fractal-routing.json fractal-selection.json jev-selection.json profile.json routed.json retro_mode brief brief_scope brief_model summaries summaries_model groups.tsv groups.frozen group_max_tasks group_max_diff_kb after"
133
+ PLANS_OPTION_FILES="no_ripwire no_memory yolo_dwarf yolo_qa reviewer_session reviewer_session_rate reviewer_session_tasks implementer_session fast pre_review_tests pre_review_parallel qa_threshold qa_test_minutes timeout verify_retries verify_cmd verify_parallel setup_cmd setup_before_verify final_qa shadow_qa shadow_rate explore escalate_after retry_per_model dwarf-routing.json fractal-routing.json jev-selection.json profile.json routed.json retro_mode brief brief_scope brief_model summaries summaries_model groups.tsv groups.frozen group_max_tasks group_max_diff_kb after"
134
134
 
135
135
  # --- plan --after: a plan that starts from another plan's integration branch (#143) -------
136
136
  # $PLAN/after holds the previous plan's absolute path; $PLAN/integration.base the commit its work
@@ -550,14 +550,16 @@ do_accept() {
550
550
  sha="$(cat "$tdir/reviewed.commit")"
551
551
  body="$(plans_reviewer_text "$tdir" "$st")"
552
552
  n="$(printf '%s\n' "$body" | grep -c '^- ')"
553
- local gthr='' gdec=''
553
+ local gthr='' gdec='' greason=''
554
554
  if [ -f "$tdir/qa.gate" ]; then
555
- IFS="$(printf '\t')" read -r gthr gdec _ < "$tdir/qa.gate" || true
555
+ IFS="$(printf '\t')" read -r gthr gdec _ _ _ _ greason < "$tdir/qa.gate" || true
556
556
  fi
557
557
  rm -f "$kibak"; [ -f "$ki" ] && cp -p "$ki" "$kibak"
558
558
  {
559
559
  if [ -s "$ki" ]; then cat "$ki"; echo; fi
560
- if [ "${gdec:-}" = fail ]; then
560
+ if [ "${gdec:-}" = fail ] && [ "${greason:-}" = tests ]; then
561
+ echo "## Accepted by a human despite forge's FAIL (the reviewer said PASS, but reported failing tests)"
562
+ elif [ "${gdec:-}" = fail ]; then
561
563
  echo "## Accepted by a human despite forge's FAIL (the reviewer said PASS, but listed findings at or above $gthr)"
562
564
  else
563
565
  echo "## Accepted by a human despite the reviewer's $st verdict"
@@ -596,14 +598,21 @@ do_accept() {
596
598
  write_results "$PLAN"
597
599
  die "task '$id' could not be merged (status now $(task_status "$PLAN" "$id")); nothing was accepted. See 'git -C $int_wt status' and the task branch $br" 6
598
600
  fi
599
- rm -f "$kibak"
601
+ rm -f "$kibak" "$tdir/decision.md" "$tdir/decision.from"
600
602
  record_attempt "$PLAN" "$id"
601
603
  write_results "$PLAN"
602
604
  echo "$id accepted by a human and merged"
603
605
  echo "known issues recorded in $ki"
604
606
  # A live run starts the tasks that waited on it by itself.
605
- if [ -z "${FORGE_ACCEPT_LIVE:-}" ] && [ "$(awk -F'\t' '$2!="MERGED" {n++} END {print n+0}' "$PLAN/results.tsv")" -gt 0 ]; then
606
- echo "tasks that were waiting on it are unchanged; continue with: forge-parallel.sh run $PLAN"
607
+ if [ -z "${FORGE_ACCEPT_LIVE:-}" ]; then
608
+ local rem
609
+ rem="$(awk -F'\t' '$2!="MERGED" {n++} END {print n+0}' "$PLAN/results.tsv")"
610
+ if [ "$rem" -gt 0 ]; then
611
+ echo "tasks that were waiting on it are unchanged; continue with: forge-parallel.sh run $PLAN"
612
+ fi
613
+ if [ "$(cat "$PLAN/verification.status" 2>/dev/null)" = STALE ] || [ "$rem" -eq 0 ]; then
614
+ echo "merged result is unverified until 'run' or 'integrate' verifies it: forge-parallel.sh run $PLAN"
615
+ fi
607
616
  fi
608
617
  return 0
609
618
  }
@@ -613,8 +622,13 @@ do_accept() {
613
622
  # very integration branch being merged). The lock is taken by re-exec, like the router's
614
623
  # own lock for run/retry/integrate, so the file descriptors stay open for bash.
615
624
  PLANS_LOCK_PY='
616
- import fcntl, os, sys
625
+ import os, sys
617
626
  script, count = sys.argv[1], int(sys.argv[2])
627
+ _scripts = os.path.dirname(os.path.abspath(script))
628
+ if _scripts not in sys.path:
629
+ sys.path.insert(0, _scripts)
630
+ import forge_flock as fcntl
631
+ import forge_proc
618
632
  held = []
619
633
  for path in sys.argv[3:3 + count]:
620
634
  try:
@@ -627,7 +641,7 @@ for path in sys.argv[3:3 + count]:
627
641
  os.set_inheritable(handle.fileno(), True)
628
642
  held.append(handle)
629
643
  env = dict(os.environ, FORGE_COMBINE_LOCKED="1")
630
- os.execve("/bin/bash", ["/bin/bash", script, "combine"] + sys.argv[3 + count:], env)
644
+ forge_proc.exec_or_exit(forge_proc.bash_cmd(script, "combine", *sys.argv[3 + count:]), env=env, inherit_fds=True)
631
645
  '
632
646
 
633
647
  plans_predict_conflict() { # 0 merges cleanly, 1 would conflict, 2 cannot tell (old git)
@@ -656,6 +670,8 @@ do_combine() {
656
670
  p="$(cd "$p" && pwd)"
657
671
  [ -f "$p/tasks.tsv" ] || die "combine: '$p' is not a forge plan (no tasks.tsv)" 3
658
672
  [ "$p" != "$NEW" ] || die "combine: the new plan cannot be one of its sources" 3
673
+ # The subtasks of a split task (#153) merge into that task; they are not a plan to combine.
674
+ ! forge_is_sub_plan "$p" || die "combine: '$p' holds the subtasks of a split task: its work merges into that task, not into a combined plan" 3
659
675
  case "$seen" in *"|$p|"*) die "combine: plan '$p' is listed twice" 3 ;; esac
660
676
  seen="$seen|$p|"
661
677
  norm+=("$p")
@@ -869,7 +885,9 @@ Retry or accept them (or split them off into their own plan) first." 3
869
885
  done
870
886
  all=1; for p in "${SRC[@]}"; do [ -f "$p/pre_review_tests" ] || all=0; done
871
887
  [ "$all" = 1 ] && : > "$NEW/pre_review_tests"
872
- for f in qa_threshold timeout verify_retries verify_parallel pre_review_parallel fast retry_per_model; do
888
+ all=1; for p in "${SRC[@]}"; do [ -f "$p/setup_before_verify" ] || all=0; done
889
+ [ "$all" = 1 ] && printf '%s\n' on > "$NEW/setup_before_verify"
890
+ for f in qa_threshold qa_test_minutes timeout verify_retries verify_parallel pre_review_parallel fast retry_per_model; do
873
891
  same=1
874
892
  for p in "${SRC[@]}"; do
875
893
  if [ ! -f "$p/$f" ] || ! cmp -s "$p/$f" "${SRC[0]}/$f"; then same=0; fi
@@ -909,7 +927,7 @@ sys.exit(0 if key(sys.argv[1]) == key(sys.argv[2]) else 1)' "$p/profile.json" "$
909
927
  [ -s "$p/verify_cmd" ] && { cp -p "$p/verify_cmd" "$NEW/verify_cmd"; break; }
910
928
  done
911
929
  fi
912
- for f in fractal-routing.json jev-selection.json; do
930
+ for f in dwarf-routing.json fractal-routing.json jev-selection.json; do
913
931
  for p in "${SRC[@]}"; do [ -f "$p/$f" ] && { cp -p "$p/$f" "$NEW/$f"; break; }; done
914
932
  done
915
933
  {
@@ -971,16 +989,15 @@ do_split() {
971
989
  done
972
990
  PICKED="$(printf '%s' "$SEL" | sed 's/^ *//; s/ *$//')"
973
991
 
974
- # Fractal binds a task's state to hashed output paths under the plan directory; moving
975
- # the task out would orphan it, and no honest way to re-bind it exists.
976
- if [ -s "$PLAN/fractal-selection.json" ]; then
977
- python3 -c 'import json, sys
978
- try:
979
- sys.exit(0 if json.load(open(sys.argv[1])).get("enabled") is False else 1)
980
- except Exception:
981
- sys.exit(1)' "$PLAN/fractal-selection.json" \
982
- || die "this plan runs under Fractal, which binds each task to output paths under the plan directory; a Fractal-backed plan cannot be split" 3
983
- fi
992
+ # A plan made with Fractal (removed in forge 0.23) kept each task's state under paths of its own
993
+ # runtime: its tasks cannot be moved to a plan that runs.
994
+ forge_refuse_fractal_run "$PLAN" split
995
+ # #153: a split task's subtasks are a plan under this run's id, on its branches. They stay with
996
+ # the run: neither they nor the task they belong to move to another plan.
997
+ ! forge_is_sub_plan "$PLAN" || die "split: '$PLAN' holds the subtasks of a split task; they stay with that task" 3
998
+ for id in $PICKED; do
999
+ ! forge_is_split "$PLAN" "$id" || die "split: task '$id' is split into subtasks ($PLAN/tasks/$id/sub), which stay with this run; it cannot move to another plan" 3
1000
+ done
984
1001
  for f in repo run_id wt_root accepted.integration; do
985
1002
  [ -s "$PLAN/$f" ] || die "plan has no $f: it has not run far enough to split ('run' it first)" 3
986
1003
  done
@@ -202,7 +202,16 @@ else:
202
202
  except (ValueError, AttributeError):
203
203
  pass
204
204
  if status and status.strip():
205
- ver.append('status: %s' % text(status))
205
+ status_text = text(status)
206
+ if status_text == 'STALE':
207
+ vcommit = read(os.path.join(vdir, 'verification.commit'))
208
+ short_sha = text(vcommit)[:7] if vcommit and vcommit.strip() else ''
209
+ if short_sha:
210
+ ver.append('status: STALE (verified %s, before later merges)' % short_sha)
211
+ else:
212
+ ver.append('status: STALE (verified an earlier commit, before later merges)')
213
+ else:
214
+ ver.append('status: %s' % status_text)
206
215
  cmd = read(os.path.join(vdir, 'verification.command'))
207
216
  if lanes is not None:
208
217
  # Lanes: each one's state; a flaky lane passed only on its rerun, a known lane failed
@@ -414,6 +423,7 @@ final_review_body() {
414
423
  forge_review_snapshot "$src" "$base" "$tip" "$review" > "$out/snapshot.log" 2>&1 ||
415
424
  { note "final review: cannot build the review snapshot (see $out/snapshot.log)"; return 3; }
416
425
  forge_review_deps "$src" "$review" "$out/review.deps"
426
+ forge_review_submodules "$src" "$review" "$out/review.deps"
417
427
  source_fp="$(forge_fingerprint "$src")" && review_fp="$(forge_fingerprint "$review" --tracked)" ||
418
428
  { note "final review: cannot fingerprint the checkouts"; return 3; }
419
429
  printf '%s\n' "$source_fp" > "$out/source.fingerprint"
@@ -489,7 +499,12 @@ final_review_body() {
489
499
  adopt_rows "$plan"
490
500
  cat "$out/notes.md"
491
501
  [ -s "$out/previous.md" ] && cat "$out/previous.md"
492
- python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind final --threshold "$thr"
502
+ local _tm="" _tm_flag=()
503
+ if [ -f "$plan/qa_test_minutes" ]; then
504
+ _tm="$(head -1 "$plan/qa_test_minutes" 2>/dev/null | tr -d ' \r')"
505
+ case "$_tm" in ''|*[!0-9]*) ;; *) _tm_flag=(--test-minutes "$_tm") ;; esac
506
+ fi
507
+ python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind final --threshold "$thr" ${_tm_flag[@]+"${_tm_flag[@]}"}
493
508
  echo
494
509
  if [ "$inline" = 1 ]; then
495
510
  echo '```diff'; cat "$out/combined.diff"; echo '```'
@@ -511,9 +526,7 @@ final_review_body() {
511
526
  # as this one does, by the same rule as per-task QA. Anything else is a fresh dispatch.
512
527
  local rs_mode=fresh rs_reason="" rs_id="" rs_cont=()
513
528
  if [ -f "$plan/reviewer_session" ]; then
514
- if [ -n "${FORGE_FRACTAL_RUN:-}" ] || forge_plan_is_fractal "$plan"; then
515
- rs_reason=fractal
516
- elif [ -z "$prev" ]; then
529
+ if [ -z "$prev" ]; then
517
530
  rs_reason=first-round
518
531
  else
519
532
  IFS=$'\t' read -r rs_mode rs_reason rs_id < <(review_session_decide \
@@ -583,7 +596,7 @@ final_review_body() {
583
596
  verdict="${verdict:-UNKNOWN}"
584
597
  local tests_note
585
598
  tests_note="$(forge_tests_note "$out/qa.last")"
586
- [ -z "$tests_note" ] || note "final review: the reviewer's tests could not run: $tests_note"
599
+ [ -z "$tests_note" ] || note "final review: the reviewer's tests did not complete: $tests_note"
587
600
  # Same gate as per-task QA, both ways: a FAIL made only of labelled findings below the
588
601
  # threshold is accepted with known issues; a PASS listing a blocking CONFIRMED finding fails.
589
602
  gate_line="$(python3 "$SKILL_DIR/scripts/forge-contract.py" gate --verdict "$verdict" \
@@ -593,7 +606,12 @@ final_review_body() {
593
606
  printf '%s\t%s\n' "$thr" "$gate_line" > "$out/qa.gate"
594
607
  case "$(printf '%s' "$gate_line" | awk -F'\t' '{print $1}')" in
595
608
  accept) verdict=ACCEPTED ;;
596
- fail) [ "$verdict" = PASS ] && { verdict=FAIL; gate_forced=1; } ;;
609
+ fail)
610
+ if [ "$verdict" = PASS ]; then
611
+ verdict=FAIL
612
+ gate_forced="$(printf '%s' "$gate_line" | awk -F'\t' '{print $6}')"
613
+ : "${gate_forced:=finding}"
614
+ fi ;;
597
615
  esac
598
616
  fi
599
617
  printf '%s\n' "$verdict" > "$out/verdict"
@@ -608,7 +626,9 @@ final_review_body() {
608
626
  echo " known issues: $out/known_issues.md"
609
627
  echo " report: $out/qa.last" ;;
610
628
  FAIL)
611
- if [ -n "$gate_forced" ]; then
629
+ if [ "$gate_forced" = tests ]; then
630
+ echo "final review ($spec): verdict FAIL (blocking) — the reviewer said PASS, but reported failing tests — forge made it FAIL."
631
+ elif [ -n "$gate_forced" ]; then
612
632
  echo "final review ($spec): verdict FAIL (blocking) — the reviewer said PASS, but listed a CONFIRMED finding at or above the $thr threshold — forge made it FAIL."
613
633
  else
614
634
  echo "final review ($spec): verdict FAIL (blocking) — the reviewer confirmed at least one defect in the combined result."