@giamme/forge 0.17.0 → 0.18.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 (76) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/SKILL.md +16 -3
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +8 -0
  5. package/docs/commands.md +70 -6
  6. package/docs/dataset.md +5 -0
  7. package/docs/decomposed-runs.md +8 -0
  8. package/docs/forge-ui.md +23 -2
  9. package/docs/memory.md +2 -0
  10. package/docs/safety.md +8 -0
  11. package/forge +24 -1
  12. package/package.json +1 -1
  13. package/references/dataset.md +19 -0
  14. package/references/decompose.md +134 -1
  15. package/references/solo.md +2 -1
  16. package/references/ui.md +5 -2
  17. package/scripts/forge-artifact.sh +14 -0
  18. package/scripts/forge-brief.py +132 -0
  19. package/scripts/forge-compare.py +11 -1
  20. package/scripts/forge-config.py +176 -9
  21. package/scripts/forge-contract.py +46 -3
  22. package/scripts/forge-control.py +86 -13
  23. package/scripts/forge-dispatch.sh +14 -10
  24. package/scripts/forge-du.py +167 -0
  25. package/scripts/forge-lib-adopt.sh +1 -0
  26. package/scripts/forge-lib-plans.sh +5 -2
  27. package/scripts/forge-lib-review.sh +29 -1
  28. package/scripts/forge-metrics.sh +7 -3
  29. package/scripts/forge-parallel-options.sh +4 -0
  30. package/scripts/forge-parallel.sh +503 -9
  31. package/scripts/forge-prompt.py +120 -0
  32. package/scripts/forge-retro.py +115 -0
  33. package/scripts/forge-runs-compact.py +443 -0
  34. package/scripts/forge-runs-rm.py +2 -0
  35. package/scripts/forge-runs.py +18 -3
  36. package/scripts/forge-schedule.py +279 -4
  37. package/scripts/forge-shadow.py +7 -1
  38. package/scripts/forge-solo.sh +2 -0
  39. package/scripts/forge-summarize.py +698 -0
  40. package/scripts/forge-ui-options.sh +10 -0
  41. package/scripts/forge_brief/__init__.py +587 -0
  42. package/scripts/forge_brief/answers.py +459 -0
  43. package/scripts/forge_dataset/__init__.py +10 -0
  44. package/scripts/forge_dataset/export.py +18 -4
  45. package/scripts/forge_dataset/facts.py +6 -4
  46. package/scripts/forge_dataset/harvest.py +40 -6
  47. package/scripts/forge_dataset/history.py +5 -3
  48. package/scripts/forge_decide/__init__.py +11 -1
  49. package/scripts/forge_locations.py +366 -0
  50. package/scripts/forge_registry.py +19 -0
  51. package/scripts/forge_retro/__init__.py +417 -0
  52. package/scripts/forge_retro/issues.py +1193 -0
  53. package/scripts/forge_retro/report.py +671 -0
  54. package/scripts/forge_side/__init__.py +477 -0
  55. package/scripts/forge_storage.py +515 -0
  56. package/ui/README.md +68 -8
  57. package/ui/docs/api.md +205 -17
  58. package/ui/forge_ui/control.py +92 -11
  59. package/ui/forge_ui/export.py +24 -5
  60. package/ui/forge_ui/links.py +337 -0
  61. package/ui/forge_ui/models.py +57 -4
  62. package/ui/forge_ui/projects.py +4 -1
  63. package/ui/forge_ui/reader.py +661 -30
  64. package/ui/forge_ui/static/app.js +86 -4
  65. package/ui/forge_ui/static/briefview.js +302 -0
  66. package/ui/forge_ui/static/checksview.js +6 -2
  67. package/ui/forge_ui/static/controls.js +5 -0
  68. package/ui/forge_ui/static/index.html +3 -0
  69. package/ui/forge_ui/static/panel.js +268 -2
  70. package/ui/forge_ui/static/runmodel.js +13 -1
  71. package/ui/forge_ui/static/storageview.js +271 -0
  72. package/ui/forge_ui/static/style.css +99 -3
  73. package/ui/forge_ui/static/worktreesview.js +3 -3
  74. package/ui/forge_ui/storage.py +136 -0
  75. package/ui/forge_ui/transcripts.py +35 -10
  76. package/ui/forge_ui/worktrees.py +154 -13
@@ -26,7 +26,8 @@
26
26
  # qa.out, verdict (PASS | FAIL | UNKNOWN | INVALIDATED | ACCEPTED; absent when nothing was
27
27
  # judged), qa.gate and known_issues.md (with a threshold), qa.infra (infrastructure stop),
28
28
  # review.meta, context.md, notes.md, tasks.summary, combined.diff (when inlined),
29
- # source/review.fingerprint and review-<pid>/ (the disposable checkout the reviewer ran in).
29
+ # source/review.fingerprint and review-<pid>/ (the disposable checkout the reviewer ran in, removed
30
+ # when the review ends; FORGE_KEEP_SNAPSHOTS=1 keeps it).
30
31
  # `review` also keeps $PLAN/final-review (a link to the newest directory) and
31
32
  # $PLAN/final-review.verdict (a copy of its verdict).
32
33
  #
@@ -357,7 +358,19 @@ PY
357
358
  # src is a repository or worktree that contains both revisions; it is also the checkout
358
359
  # whose fingerprint must not change while the reviewer runs. Never uses `die`/`exit`:
359
360
  # it is called from inside do_integrate.
361
+ # The review snapshot goes once the review is over, on every return (#139). A signal that ends the
362
+ # process first leaves it, and the next final review of the plan removes it: they hold the plan's
363
+ # lock, so one runs at a time and any snapshot already there is an interrupted one's.
360
364
  final_review() {
365
+ local final_rc
366
+ FINAL_REVIEW_SNAPSHOT=""
367
+ final_review_body "$@"; final_rc=$?
368
+ forge_drop_snapshot "$FINAL_REVIEW_SNAPSHOT"
369
+ FINAL_REVIEW_SNAPSHOT=""
370
+ return "$final_rc"
371
+ }
372
+
373
+ final_review_body() {
361
374
  local plan="$1" base="$2" tip="$3" src="$4" out="$5" spec="$6" yolo="${7:-}"
362
375
  local review n rc verdict thr gate_line gate_forced source_fp review_fp vdir tflag="" inline=1 diff_n ft
363
376
  local plan_real prev="" prev_rel=none prev_tip="" since=none integration="" prev_note=""
@@ -391,8 +404,13 @@ final_review() {
391
404
 
392
405
  # `forge_review_snapshot` writes review.base beside the snapshot, so it gets a directory
393
406
  # of its own under the artifact dir.
407
+ local stale
408
+ for stale in "$out"/review-* "$plan"/final-review*/review-* "$plan"/integrate-*/final-review/review-*; do
409
+ [ -d "$stale/.git" ] && forge_drop_snapshot "$stale"
410
+ done
394
411
  review="$out/review-$$"; n=0
395
412
  while [ -e "$review" ]; do n=$((n+1)); review="$out/review-$$-$n"; done
413
+ FINAL_REVIEW_SNAPSHOT="$review"
396
414
  forge_review_snapshot "$src" "$base" "$tip" "$review" > "$out/snapshot.log" 2>&1 ||
397
415
  { note "final review: cannot build the review snapshot (see $out/snapshot.log)"; return 3; }
398
416
  forge_review_deps "$src" "$review" "$out/review.deps"
@@ -482,6 +500,9 @@ final_review() {
482
500
  echo " git diff HEAD~1 HEAD -- . ':(exclude).forge'"
483
501
  echo "(and 'git diff --stat HEAD~1 HEAD' for the overview)."
484
502
  fi
503
+ # Last. A shadow of a task review copies qa.input itself; this prompt is the final
504
+ # review's, and nothing copies it onward. Off prints nothing.
505
+ forge_retro_prompt "$plan" review
485
506
  } > "$out/qa.input"
486
507
 
487
508
  [ -s "$plan/timeout" ] && tflag="--timeout $(cat "$plan/timeout")"
@@ -516,12 +537,19 @@ final_review() {
516
537
  fi
517
538
  rs_mode=fresh
518
539
  mv "$out/qa.out" "$out/qa.continue.out" 2>/dev/null || true
540
+ # The fresh dispatch deletes qa.last and qa.log as it starts. Record the continuation
541
+ # first; a failure to record does not change rc, which the fresh dispatch sets next.
542
+ forge_retro_record "$plan" qa "$out"
519
543
  FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$plan/capabilities}" \
520
544
  "${qa_cmd[@]}" > "$out/qa.out" 2>&1
521
545
  rc=$?
522
546
  fi
523
547
  [ ! -f "$plan/reviewer_session" ] || { echo "session=$rs_mode"; echo "session_reason=$rs_reason"; } >> "$out/review.meta"
524
548
  if [ "${FORGE_OUTPUT:-summary}" = full ]; then cat "$out/qa.out"; fi
549
+ # The dispatch role is qa, so the notes are in qa.last. No task: this is the whole run.
550
+ # Record and the regenerated report never change rc; the case below still decides it.
551
+ forge_retro_record "$plan" qa "$out"
552
+ forge_retro_report "$plan"
525
553
  case "$rc" in
526
554
  0) ;;
527
555
  8) note "final review: the reviewer hit an infrastructure failure; nothing was judged"
@@ -5,8 +5,9 @@ forge_metric_begin() {
5
5
  FORGE_METRIC="$(python3 "$SKILL_DIR/scripts/forge-runtime.py" begin "$1" "$2")" || return 3
6
6
  # Dispatches started from here name this execution as their parent in the run dataset.
7
7
  export FORGE_DATASET_PARENT="${FORGE_METRIC##*/}"
8
- # The hook, when the caller defines it, records status before finish and Fractal's _outcome.
9
- trap 'metric_rc=$?; ! declare -F forge_metric_on_exit >/dev/null || forge_metric_on_exit "$metric_rc"; python3 "$SKILL_DIR/scripts/forge-runtime.py" finish "$FORGE_METRIC" "$FORGE_METRIC_ROOT" "$FORGE_METRIC_ROLE" pipeline "$metric_rc"; if [ -n "${FORGE_FRACTAL_RUN:-}" ]; then python3 "$SKILL_DIR/scripts/forge-fractal.py" _outcome "$FORGE_METRIC_ROOT" "$metric_rc"; fi; exit "$metric_rc"' EXIT
8
+ # The hook, when the caller defines it, records status before finish and Fractal's _outcome. A review
9
+ # snapshot the runner names in FORGE_REVIEW_SNAPSHOT is removed on every way out (#139).
10
+ trap 'metric_rc=$?; [ -z "${FORGE_REVIEW_SNAPSHOT:-}" ] || ! declare -F forge_drop_snapshot >/dev/null || forge_drop_snapshot "$FORGE_REVIEW_SNAPSHOT"; ! declare -F forge_metric_on_exit >/dev/null || forge_metric_on_exit "$metric_rc"; python3 "$SKILL_DIR/scripts/forge-runtime.py" finish "$FORGE_METRIC" "$FORGE_METRIC_ROOT" "$FORGE_METRIC_ROLE" pipeline "$metric_rc"; if [ -n "${FORGE_FRACTAL_RUN:-}" ]; then python3 "$SKILL_DIR/scripts/forge-fractal.py" _outcome "$FORGE_METRIC_ROOT" "$metric_rc"; fi; exit "$metric_rc"' EXIT
10
11
  }
11
12
  forge_metric_phase() {
12
13
  python3 "$SKILL_DIR/scripts/forge-runtime.py" phase "$FORGE_METRIC" "$1"
@@ -25,8 +26,11 @@ forge_dataset_event() { # forge_dataset_event <name> --dir <dir> [--task id] [--
25
26
  }
26
27
  # A worktree forge added or removed (#125): forge-ui's Worktrees screen lists every one, removed ones too.
27
28
  # <kind> is task, integration, candidate or attribute (scripts/forge_worktrees.py); <branch> is - when detached.
28
- # Off with the dataset (FORGE_DATASET=off), as forge_dataset_event is.
29
+ # Always into forge's location list (forge_locations.py, off only with FORGE_RUN_REGISTRY=off), so forge knows
30
+ # where its worktrees are whatever the dataset says; the dataset event is off with FORGE_DATASET=off.
29
31
  forge_worktree_event() { # forge_worktree_event created|removed <run dir> <repo> <path> <branch|-> <kind> [task]
32
+ python3 -I "$SKILL_DIR/scripts/forge_locations.py" worktree "$1" "$2" "$3" "$4" "$5" "$6" ${7:+"$7"} \
33
+ </dev/null >/dev/null 2>&1 || true
30
34
  forge_dataset_event "worktree_$1" --dir "$2" ${7:+--task "$7"} --set repo_path="$3" --set path="$4" \
31
35
  --set branch="$5" --set kind="$6"
32
36
  }
@@ -15,6 +15,10 @@
15
15
  # --infra-retries when `run` or `retry` is not given them; a flag wins. On `retry` they are
16
16
  # the further attempts after this one (while its review fails) and the waits out of an infrastructure stop.
17
17
  #
18
+ # `plan` also writes retro, brief, brief_scope, brief_model, summaries and summaries_model
19
+ # (--retro, --brief, --brief-scope, --brief-model, --summaries, --summaries-model; #132, #133,
20
+ # #135). They are plan-only flags, parsed in do_plan, not here; see forge_features_resolve.
21
+ #
18
22
  # Persisted options become files in the plan dir, like --verify and --setup, so a later
19
23
  # `retry` or the scheduler's task processes see them. Cost-bearing options that change
20
24
  # what a run is allowed to spend (--retry-failed, --infra-retries) are deliberately NOT