@giamme/forge 0.13.1 → 0.14.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 (47) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/SKILL.md +17 -11
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +1 -0
  5. package/docs/commands.md +121 -7
  6. package/docs/development.md +3 -0
  7. package/docs/reviews.md +2 -0
  8. package/docs/troubleshooting.md +5 -1
  9. package/forge +28 -1
  10. package/package.json +1 -1
  11. package/references/dataset.md +3 -1
  12. package/references/decompose.md +199 -61
  13. package/references/runtime.md +29 -0
  14. package/references/ui.md +10 -0
  15. package/scripts/forge-compare.py +491 -0
  16. package/scripts/forge-config.py +3 -3
  17. package/scripts/forge-contract.py +34 -8
  18. package/scripts/forge-control.py +105 -13
  19. package/scripts/forge-dispatch.sh +9 -5
  20. package/scripts/forge-jev-options.sh +17 -4
  21. package/scripts/forge-ledger.py +387 -0
  22. package/scripts/forge-lib-plans.sh +11 -2
  23. package/scripts/forge-lib-task.sh +390 -28
  24. package/scripts/forge-parallel-options.sh +20 -4
  25. package/scripts/forge-parallel.sh +116 -12
  26. package/scripts/forge-plan-check.py +68 -3
  27. package/scripts/forge-pr.py +276 -0
  28. package/scripts/forge-route.py +350 -34
  29. package/scripts/forge-runs.py +18 -1
  30. package/scripts/forge-runtime.py +23 -7
  31. package/scripts/forge-schedule.py +303 -46
  32. package/scripts/forge-verify-failed.py +111 -0
  33. package/scripts/forge-watch.py +372 -0
  34. package/scripts/forge_dataset/harvest.py +3 -1
  35. package/scripts/forge_fractal/cli.py +23 -6
  36. package/scripts/forge_infra.py +274 -0
  37. package/scripts/forge_jev/client.py +13 -9
  38. package/ui/docs/api.md +51 -8
  39. package/ui/forge_ui/export.py +6 -2
  40. package/ui/forge_ui/reader.py +172 -6
  41. package/ui/forge_ui/static/app.js +2 -2
  42. package/ui/forge_ui/static/checksview.js +20 -7
  43. package/ui/forge_ui/static/controls.js +6 -3
  44. package/ui/forge_ui/static/panel.js +69 -4
  45. package/ui/forge_ui/static/runmodel.js +30 -4
  46. package/ui/forge_ui/static/scene3d.js +3 -2
  47. package/ui/forge_ui/static/style.css +11 -4
@@ -15,6 +15,8 @@
15
15
  # [--sweep-ahead | --no-sweep-ahead] [--attribute | --no-attribute]
16
16
  # forge-parallel.sh retry <plan-dir> <task-id> [--dwarf <spec>] [--setup <command>]
17
17
  # [--answer <text> | --answer-file <file>] (a NEEDS_INPUT task)
18
+ # [--decide retry=N|threshold=Pn | --dwarf <spec>] --reason "<why>" --approved
19
+ # (a NEEDS_DECISION task)
18
20
  # [--timeout S] [--qa-threshold Pn|none|default] [--verify-retries N]
19
21
  # forge-parallel.sh integrate <plan-dir> --approved [--verify-retries N] [--final-review <qa-spec>]
20
22
  # forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold Pn|none|default]
@@ -164,6 +166,7 @@ pool_pick() { # pool_pick <comma-list> <index>
164
166
  do_plan() {
165
167
  local PLAN="${1:?plan needs a plan dir}"; shift
166
168
  local REPO="" D_ANY="" D_HI="" D_MD="" D_LO="" Q_ANY="" Q_HI="" Q_MD="" Q_LO=""
169
+ PP_INFRA_FALLBACK=""
167
170
  local PLANNER="" NOMEM=0 jev_rc=0 DLEVEL="" SHADOW_QA="" SHADOW_RATE="" EXPLORE="" FAIL_FIRST="" REVIEWER_SESSION="" IMPLEMENTER_SESSION="" PRE_REVIEW="" PRE_REVIEW_PARALLEL=""
168
171
  while [ $# -gt 0 ]; do
169
172
  case "$1" in
@@ -228,6 +231,11 @@ do_plan() {
228
231
  # The table as the planner or orchestrator wrote it, before Jev or route resolution
229
232
  # rewrites any column: which tier a task was DECLARED is a label of its own.
230
233
  cp "$T" "$PLAN/tasks.declared.tsv"
234
+ # A lateral move on an infrastructure stop is on for a new plan; one without the file stays off. A re-plan
235
+ # keeps what the plan has, as it keeps its routing files: only --no-infra-fallback changes it here.
236
+ if [ -n "$PP_INFRA_FALLBACK" ] || [ ! -f "$PLAN/infra_fallback" ]; then
237
+ printf '%s\n' "${PP_INFRA_FALLBACK:-on}" > "$PLAN/infra_fallback" || die "could not write $PLAN/infra_fallback"
238
+ fi
231
239
  [ -z "$DLEVEL" ] || printf '%s\n' "$DLEVEL" > "$PLAN/decompose_level"
232
240
  # Shadow reviews are part of the plan, like its routing: frozen here, shown in the table
233
241
  # and read by every task process. `none` turns them off again.
@@ -292,6 +300,16 @@ p=Path(sys.argv[1]); data=json.loads(p.read_text()) if p.exists() else {}
292
300
  for key,value in zip(('any','low','medium','high'),sys.argv[2:]):
293
301
  if value: data[key]=[s.strip() for s in value.split(',') if s.strip()]
294
302
  p.write_text(json.dumps(data))
303
+ PY
304
+ # The reviewer pools, kept as the dwarf pools are: the round-robin below forgets them, and a review
305
+ # stopped on infrastructure moves to a peer of its pool (forge-route.py qa-fallback).
306
+ python3 - "$PLAN/qa-routing.json" "$Q_ANY" "$Q_LO" "$Q_MD" "$Q_HI" <<'PY'
307
+ import json,sys
308
+ from pathlib import Path
309
+ p=Path(sys.argv[1]); data=json.loads(p.read_text()) if p.exists() else {}
310
+ for key,value in zip(('any','low','medium','high'),sys.argv[2:]):
311
+ if value: data[key]=[s.strip() for s in value.split(',') if s.strip()]
312
+ p.write_text(json.dumps(data))
295
313
  PY
296
314
 
297
315
  # Uncommitted work is invisible to every dwarf, because worktrees branch from a
@@ -941,7 +959,9 @@ do_task_body() (
941
959
  [ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role dwarf 2>/dev/null
942
960
  echo "Implement this task in the repository. Follow the intended approach unless it is wrong; explain deviations. Run the task's requested verification and report results."
943
961
  echo "On retry, fix the findings in the existing work; preserve parts not criticised. Explain any finding you reject."
944
- echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf $([ ! -f "$PLAN/pre_review_tests" ] || echo --pre-review)
962
+ # With repository verification configured, the whole suite runs after the merge, never per attempt.
963
+ echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf $([ ! -f "$PLAN/pre_review_tests" ] || echo --pre-review) \
964
+ $([ -z "$(verify_source_for "$PLAN" "$REPO")" ] || echo --verify-after-merge)
945
965
  echo; /bin/bash "$MEMORY" note dwarf
946
966
  } > "$tdir/dwarf.input"
947
967
  guard_before_dwarf "$wt" "$tdir"
@@ -1274,13 +1294,17 @@ do_task_body() (
1274
1294
  # Entry point for both the scheduler's `_task` and `retry`: runs the pipeline, then logs
1275
1295
  # the attempt (including infrastructure stops, which spend nothing) for later audit.
1276
1296
  do_task() {
1277
- local rc
1297
+ local rc crc=0 stop_before
1278
1298
  do_task_body "$@"; rc=$?
1279
1299
  record_attempt "$1" "$2"
1280
1300
  # The retry policy's state (escalation.next or escalation.stop), decided now rather than
1281
1301
  # at the next retry so a spent retry budget still reports it and the scheduler sees it.
1302
+ stop_before="$(cat "$1/tasks/$2/escalation.stop" 2>/dev/null)"
1282
1303
  python3 "$SKILL_DIR/scripts/forge-route.py" escalation --plan "$1" --task "$2" --check \
1283
- --qa-only-next "$(qa_only_next_flag "$1" "$2")" >/dev/null 2>&1 || true
1304
+ --qa-only-next "$(qa_only_next_flag "$1" "$2")" >/dev/null 2>&1 || crc=$?
1305
+ # A FAIL that does not converge, or that the policy could not move to a stronger model, waits
1306
+ # for a person (NEEDS_DECISION). attempts.tsv was written above and keeps FAIL.
1307
+ decision_after_attempt "$1" "$2" "$stop_before" "$crc"
1284
1308
  return $rc
1285
1309
  }
1286
1310
 
@@ -1338,11 +1362,15 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
1338
1362
  # into the real plan. Leaves n (how many answer flags), flag, val and novalue in the scratch dir.
1339
1363
  _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
1340
1364
  local sd="$1"; shift
1341
- local n=0 flag="" val="" novalue=0 rc=0
1365
+ local n=0 flag="" val="" novalue=0 rc=0 dwarf="" decide="" reason="" approved=0
1342
1366
  while [ $# -gt 0 ]; do
1343
1367
  case "$1" in
1344
1368
  --no-ripwire|--yolo-dwarf|--yolo-qa) shift ;;
1345
- --output|--dwarf|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
1369
+ --output|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
1370
+ --dwarf) [ $# -ge 2 ] || break; dwarf="$2"; shift 2 ;;
1371
+ --decide) [ $# -ge 2 ] || break; decide="$2"; shift 2 ;;
1372
+ --reason) [ $# -ge 2 ] || break; reason="$2"; shift 2 ;;
1373
+ --approved) approved=1; shift ;;
1346
1374
  --answer|--answer-file)
1347
1375
  n=$((n + 1)); flag="$1"
1348
1376
  if [ $# -ge 2 ]; then val="$2"; shift 2; else novalue=1; shift; fi ;;
@@ -1359,6 +1387,8 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
1359
1387
  esac
1360
1388
  done
1361
1389
  printf '%s' "$n" > "$sd/n"; printf '%s' "$flag" > "$sd/flag"; printf '%s' "$val" > "$sd/val"
1390
+ printf '%s' "$dwarf" > "$sd/dwarf"; printf '%s' "$decide" > "$sd/decide"
1391
+ printf '%s' "$reason" > "$sd/reason"; printf '%s' "$approved" > "$sd/approved"
1362
1392
  [ "$novalue" = 0 ] || : > "$sd/novalue"
1363
1393
  }
1364
1394
 
@@ -1368,18 +1398,21 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
1368
1398
  do_retry() {
1369
1399
  local PLAN="${1:?retry needs a plan dir}" id="${2:?retry needs a task id}"; shift 2
1370
1400
  FORGE_RUN_STARTED="$(forge_now)"
1371
- local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0
1401
+ local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0 DECIDE="" REASON="" APPROVED=0
1372
1402
  # An answer is validated before any option below writes into the plan: a rejected answer
1373
1403
  # changes nothing, --setup and --verify included. Only a NEEDS_INPUT task takes one. The
1374
1404
  # arguments are walked the way the loop below walks them (a value is never taken for a flag),
1375
1405
  # in a subshell against a scratch plan dir, so nothing real is written by the walk.
1376
1406
  local pre_dir="$PLAN/.answer-scan.$$" pre_n=0 pre_have="" pre_val="" pre_novalue=0 pre_ok=0
1407
+ local pre_dwarf="" pre_decide="" pre_reason="" pre_approved=0
1377
1408
  rm -rf "$pre_dir"
1378
1409
  if mkdir "$pre_dir" 2>/dev/null; then
1379
1410
  if ( _retry_answer_scan "$pre_dir" "$@" ) >/dev/null 2>&1; then
1380
1411
  pre_ok=1
1381
1412
  pre_n="$(<"$pre_dir/n")"; pre_have="$(<"$pre_dir/flag")"; pre_val="$(<"$pre_dir/val")"
1382
1413
  [ ! -f "$pre_dir/novalue" ] || pre_novalue=1
1414
+ pre_dwarf="$(<"$pre_dir/dwarf")"; pre_decide="$(<"$pre_dir/decide")"
1415
+ pre_reason="$(<"$pre_dir/reason")"; pre_approved="$(<"$pre_dir/approved")"
1383
1416
  # `$(<f)` drops trailing newlines, so an answer of only newlines needs the size check.
1384
1417
  [ -s "$pre_dir/val" ] || pre_val=""
1385
1418
  fi
@@ -1400,11 +1433,19 @@ do_retry() {
1400
1433
  [ -n "$pre_val" ] || die "retry: the answer is empty"
1401
1434
  fi
1402
1435
  fi
1436
+ # A decision is judged the same way, before any option writes: a NEEDS_DECISION task is resumed
1437
+ # only by --decide or --dwarf with --reason and --approved, and --decide is for no other task.
1438
+ if [ "$pre_ok" = 1 ] && [ -s "$PLAN/tasks.tsv" ] && all_ids "$PLAN/tasks.tsv" | grep -qx "$id"; then
1439
+ retry_decision_gate "$PLAN" "$id" "$(task_status "$PLAN" "$id")" "$pre_decide" "$pre_dwarf" "$pre_reason" "$pre_approved"
1440
+ fi
1403
1441
  while [ $# -gt 0 ]; do
1404
1442
  case "$1" in
1405
1443
  --no-ripwire) export FORGE_RIPWIRE=off; shift ;;
1406
1444
  --output) OUTPUT="${2:?}"; shift 2 ;;
1407
1445
  --dwarf) NEWDWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
1446
+ --decide) DECIDE="${2:?--decide needs retry=N or threshold=Pn}"; shift 2 ;;
1447
+ --reason) REASON="${2?--reason needs a text}"; shift 2 ;;
1448
+ --approved) APPROVED=1; shift ;;
1408
1449
  # The check above refuses an empty answer first; these hold when its walk could not run.
1409
1450
  --answer) [ "$HAVE_ANSWER" = 0 ] || die "retry: give --answer or --answer-file once"
1410
1451
  ANSWER="${2?--answer needs the answer text}"; HAVE_ANSWER=1; shift 2
@@ -1442,6 +1483,9 @@ do_retry() {
1442
1483
  local st; st="$(task_status "$PLAN" "$id")"
1443
1484
  [ "$st" = "MERGED" ] && die "task '$id' already merged — nothing to retry"
1444
1485
  [ "$HAVE_ANSWER" = 0 ] || [ "$st" = NEEDS_INPUT ] || die "retry: '$id' is $st, not waiting for an answer; --answer and --answer-file only answer a NEEDS_INPUT task"
1486
+ retry_decision_gate "$PLAN" "$id" "$st" "$DECIDE" "$NEWDWARF" "$REASON" "$APPROVED"
1487
+ # A task at its attempt cap (#69) is refused with the decision commands unless --decide retry=N reaches past it.
1488
+ if ! attempt_cap_gate "$PLAN" "$id" "$st" "$DECIDE"; then write_results "$PLAN"; return 2; fi
1445
1489
  # The user's answer to a NEEDS_INPUT task's question (validated above): written before
1446
1490
  # anything else is prepared, atomically, and kept when the preparation then refuses (the
1447
1491
  # same answer can be retried).
@@ -1459,7 +1503,14 @@ do_retry() {
1459
1503
  # A refusal (the retry policy found no stronger model, or the escalation could not be
1460
1504
  # written) must stop here: past this point the status is cleared and a dwarf dispatched.
1461
1505
  local prc=0
1462
- prepare_retry "$PLAN" "$id" "$NEWDWARF" || prc=$?
1506
+ if [ "$st" = NEEDS_DECISION ]; then
1507
+ retry_decided "$PLAN" "$id" "$DECIDE" "$NEWDWARF" "$REASON" || prc=$?
1508
+ else
1509
+ prepare_retry "$PLAN" "$id" "$NEWDWARF" || prc=$?
1510
+ # A person's plain retry ends what an earlier decision allowed; resuming after an
1511
+ # infrastructure stop is not a new choice, so the allowance carries over.
1512
+ [ "$prc" != 0 ] || [ "$st" = INFRA ] || rm -f "${tdir:?}/decided.left"
1513
+ fi
1463
1514
  if [ "$prc" != 0 ]; then
1464
1515
  write_results "$PLAN"
1465
1516
  [ "$prc" = 3 ] && return 2
@@ -1474,12 +1525,31 @@ do_retry() {
1474
1525
  preflight_plan "$PLAN" || return $?
1475
1526
  /bin/bash "$SKILL_DIR/scripts/forge-install-ripwire.sh" || true
1476
1527
  rm -f "$tdir/status"
1528
+ # The pauses an earlier run ended with describe that run: this retry's summary must not report them.
1529
+ rm -f "$PLAN/infra.last"
1477
1530
 
1478
1531
  note "retrying $id with dwarf $(field "$T" "$id" dwarf)"
1479
1532
  export FORGE_FRACTAL_RETRY=1
1480
1533
  export FORGE_DATASET_TRIGGER=human
1481
1534
  do_task "$PLAN" "$id"
1482
1535
  st="$(task_status "$PLAN" "$id")"
1536
+ # A decision of retry=N is N attempts in all: this one, then N-1 more while the reviews fail.
1537
+ # Any other decision is this one attempt. The same stops apply as to any retry: a task that
1538
+ # stopped for a decision again, an empty diff, or a policy that finds no stronger model.
1539
+ # The count is decided.left, so it survives a run that ended before the attempts were used.
1540
+ local more; more="$(decided_left "$tdir")"; more="${more:-0}"
1541
+ while [ "$more" -gt 0 ] && { [ "$st" = FAIL ] || [ "$st" = UNKNOWN ]; } && [ ! -e "$tdir/noretry" ]; do
1542
+ # Each further attempt is spent against the cap (#69) like the scheduler's retries: an UNKNOWN review
1543
+ # does not stop the task by itself, so the cap is checked here, and a task at it stops for a decision.
1544
+ if ! attempt_cap_gate "$PLAN" "$id" "$st" ""; then st="$(task_status "$PLAN" "$id")"; break; fi
1545
+ more=$(( more - 1 ))
1546
+ prepare_retry "$PLAN" "$id" || break
1547
+ decided_left_set "$tdir" "$more" || break
1548
+ rm -f "$tdir/status"
1549
+ note "retrying $id (decided retry, $more more after this)"
1550
+ do_task "$PLAN" "$id"
1551
+ st="$(task_status "$PLAN" "$id")"
1552
+ done
1483
1553
  if [ "$st" = "INFRA" ]; then
1484
1554
  # Nothing was judged and no attempt was spent: skip verification, say how to resume.
1485
1555
  write_results "$PLAN"
@@ -1494,12 +1564,23 @@ do_retry() {
1494
1564
  note "$id PASS but conflicted on merge — branch preserved"
1495
1565
  fi
1496
1566
  fi
1497
- verify_result "$PLAN" "$(cat "$PLAN/wt_root")/_integration" "$PLAN" || { write_results "$PLAN"; run_report_extras "$PLAN"; return 5; }
1567
+ # Tasks still to run (#112): the run that dispatches them verifies the integration branch at its
1568
+ # end, and integrate verifies its candidate, so verifying now would only be repeated.
1569
+ local left="" lid
1570
+ for lid in $(all_ids "$T"); do
1571
+ case "$(task_status "$PLAN" "$lid")" in PENDING|BLOCKED) left="${left:+$left }$lid" ;; esac
1572
+ done
1573
+ if [ -n "$left" ]; then
1574
+ note "verification deferred: tasks still to run ($left); the next run, or integrate, verifies the integration branch"
1575
+ else
1576
+ verify_result "$PLAN" "$(cat "$PLAN/wt_root")/_integration" "$PLAN" || { write_results "$PLAN"; run_report_extras "$PLAN"; return 5; }
1577
+ fi
1498
1578
  write_results "$PLAN"
1499
1579
  echo
1500
1580
  printf ' %-14s %-9s %s\n' id status branch
1501
1581
  awk -F'\t' '{printf " %-14s %-9s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
1502
1582
  run_report_extras "$PLAN"
1583
+ report_decisions "$PLAN"
1503
1584
  [ "$(task_status "$PLAN" "$id")" = "MERGED" ] || return 5
1504
1585
  return 0
1505
1586
  }
@@ -1614,7 +1695,7 @@ verify_result_body() { # plan, checkout, artifact directory[, fixed source]
1614
1695
  forge_metric_begin "$out" verification
1615
1696
  forge_metric_phase verification
1616
1697
  repo="$(cat "$plan/repo")"
1617
- rm -f "$out/verification.flaky" "$out/verification.retry.log" "$out/verification.coverage.txt" \
1698
+ rm -f "$out/verification.flaky" "$out/verification.retry.log" "$out/verification.failing.log" "$out/verification.coverage.txt" \
1618
1699
  "$out/verification.runs.tsv" "$out"/verification.run-*.log "$out/verification.commit" \
1619
1700
  "$out/verification.lanes.json" "$out"/verification.lane.*.log
1620
1701
  # The commit being verified, named before any early return, so every outcome (FAIL and
@@ -1730,10 +1811,31 @@ with open(out + "/verification.jev.json", "w") as fh:
1730
1811
  verify_stopped "$out" && return 130
1731
1812
  echo "$before" > "$out/verification.fingerprint"
1732
1813
  if [ "$rc" != 0 ] || [ "$before" != "$after" ]; then
1733
- local flaked=0 n_retry=0 rc3 b3 a3
1814
+ local flaked=0 n_retry=0 rc3 b3 a3 fcmd
1734
1815
  # The rerun itself is the evidence: it needs no model and no recorded trap. A tree
1735
1816
  # change is never retried.
1736
1817
  if [ "$rc" != 0 ] && [ "$before" = "$after" ] && [ "$vretries" -gt 0 ]; then
1818
+ # First the failing tests alone, through .forge/verify-subset (#112): failing again on their own
1819
+ # confirms a regression without a second full suite. Their pass says nothing about the rest of
1820
+ # the command, so the full rerun below still decides a flaky result.
1821
+ if [ -s "$repo/.forge/verify-subset" ] && fcmd="$(python3 "$SKILL_DIR/scripts/forge-verify-failed.py" command \
1822
+ --checkout "$wt" --log "$out/verification.log" --subset "$repo/.forge/verify-subset" 2>/dev/null)"; then
1823
+ rc3=0
1824
+ note "verification failed (exit $rc); rerunning only the failing tests first: $fcmd"
1825
+ b3="$(forge_fingerprint "$wt")" || return 1
1826
+ vt0="$(date +%s)"
1827
+ verify_stopped "$out" && return 130
1828
+ verify_exec "$wt" "$fcmd" "$out/verification.failing.log" || rc3=$?
1829
+ a3="$(forge_fingerprint "$wt")" || { verify_stopped "$out" && return 130; return 1; }
1830
+ verify_run_note "$out" failing "$rc3" "$b3" "$a3" verification.failing.log "$vt0"
1831
+ verify_stopped "$out" && return 130
1832
+ # 126 and 127: the subset command itself could not run, which confirms nothing.
1833
+ if [ "$rc3" != 0 ] && [ "$rc3" != 126 ] && [ "$rc3" != 127 ] && [ "$b3" = "$a3" ]; then
1834
+ echo FAIL > "$out/verification.status"
1835
+ note "the failing tests fail again on their own (exit $rc3): a regression, not a flaky test, so the full command is not rerun; see $out/verification.log"
1836
+ return 1
1837
+ fi
1838
+ fi
1737
1839
  while [ "$n_retry" -lt "$vretries" ] && [ "$flaked" = 0 ]; do
1738
1840
  n_retry=$((n_retry+1)); rc3=0
1739
1841
  note "verification failed (exit $rc); rerunning to tell a flaky lane from a regression ($n_retry/$vretries)"
@@ -2023,10 +2125,12 @@ do_run() {
2023
2125
  done
2024
2126
  echo
2025
2127
  fi
2128
+ # Tasks stopped for a decision (#69): why, and the choices. Not failures to retry either.
2129
+ report_decisions "$PLAN"
2026
2130
  # The retry hint is for tasks that actually failed; a run that only failed verification,
2027
2131
  # or only paused on infrastructure, has nothing to retry task by task. An interrupted task
2028
- # has its own hint above, a task waiting for an answer its own block.
2029
- if [ "$(awk -F'\t' '$2!="MERGED" && $2!="INFRA" && $2!="PENDING" && $2!="BLOCKED" && $2!="INTERRUPTED" && $2!="NEEDS_INPUT" {n++} END {print n+0}' "$PLAN/results.tsv")" -gt 0 ]; then
2132
+ # has its own hint above, a task waiting for an answer or a decision its own block.
2133
+ if [ "$(awk -F'\t' '$2!="MERGED" && $2!="INFRA" && $2!="PENDING" && $2!="BLOCKED" && $2!="INTERRUPTED" && $2!="NEEDS_INPUT" && $2!="NEEDS_DECISION" {n++} END {print n+0}' "$PLAN/results.tsv")" -gt 0 ]; then
2030
2134
  echo "retry a failed task with its reviewer's findings:"
2031
2135
  echo " forge-parallel.sh retry $PLAN <task-id> [--dwarf <spec>]"
2032
2136
  echo "or let a run retry them itself: forge-parallel.sh run $PLAN --retry-failed 1"
@@ -2,9 +2,10 @@
2
2
  """Advisory checks on a plan's tasks, printed under the approval table. Never fails a plan.
3
3
 
4
4
  forge-plan-check.py size --plan P
5
- Names the tasks that are large by the measure that predicts a failed first attempt, and
6
- the tasks whose prompt.md has no acceptance criteria. Prints nothing when every task is
7
- fine. Exit status is always 0.
5
+ Names the tasks that are large by the measure that predicts a failed first attempt, the
6
+ tasks whose prompt.md has no acceptance criteria, and the tasks whose acceptance criteria
7
+ ask for the whole suite (each attempt would run it; the run's verification already does,
8
+ after each merge). Prints nothing when every task is fine. Exit status is always 0.
8
9
 
9
10
  forge-plan-check.py gates PLAN
10
11
  Prints the decision-model gate block (what drift, forward, prompt and coverage did to this
@@ -40,6 +41,13 @@ FILE_BIN = (9, 29, 107)
40
41
  HEADING = re.compile(r'^(#{1,6})\s+acceptance criteria\s*:?\s*$', re.IGNORECASE)
41
42
  ANY_HEADING = re.compile(r'^(#{1,6})\s')
42
43
  FENCE = re.compile(r'^\s*(```|~~~)')
44
+ # A whole-suite run named as a command: forge's own check.sh, bare discovery, or an ecosystem's
45
+ # default test target with no selection. A command that names tests (`cargo test foo`) is fine.
46
+ WHOLE_SUITE = re.compile(
47
+ r'(?:(?:ba)?sh\s+|\./)?[\w./-]*check\.sh'
48
+ r'|python3?\s+-m\s+(?:unittest(?:\s+discover(?:\s+-s\s+\S+)?)?|pytest)|pytest|tox'
49
+ r'|(?:npm|pnpm|yarn)(?:\s+run)?\s+test|make\s+(?:test|check)|cargo\s+test|go\s+test\s+\./\.\.\.')
50
+ COMMAND_SPAN = re.compile(r'`([^`\n]+)`')
43
51
 
44
52
 
45
53
  def has_acceptance_criteria(text: str) -> bool:
@@ -66,6 +74,57 @@ def has_acceptance_criteria(text: str) -> bool:
66
74
  return False
67
75
 
68
76
 
77
+ def acceptance_lines(text: str) -> list:
78
+ """The lines of the `Acceptance criteria` sections, fenced code included."""
79
+ out, fenced, level = [], False, None
80
+ for line in text.splitlines():
81
+ if FENCE.match(line):
82
+ fenced = not fenced
83
+ continue
84
+ if not fenced:
85
+ heading = ANY_HEADING.match(line)
86
+ if level is not None and heading and len(heading.group(1)) <= level:
87
+ level = None
88
+ match = HEADING.match(line)
89
+ if match:
90
+ level = len(match.group(1))
91
+ continue
92
+ if level is not None:
93
+ out.append(line)
94
+ return out
95
+
96
+
97
+ def verify_commands(plan: Path) -> set:
98
+ """Each command of the plan's --verify and the repository's .forge/verify, whitespace collapsed."""
99
+ sources = [plan / 'verify_cmd']
100
+ try:
101
+ sources.append(Path((plan / 'repo').read_text().strip()) / '.forge' / 'verify')
102
+ except OSError:
103
+ pass
104
+ out = set()
105
+ for source in sources:
106
+ try:
107
+ text = source.read_text(errors='replace')
108
+ except OSError:
109
+ continue
110
+ for part in re.split(r'&&|\|\||;|\n', text):
111
+ part = ' '.join(part.split())
112
+ if len(part) >= 6:
113
+ out.add(part)
114
+ return out
115
+
116
+
117
+ def whole_suite_asked(prompt: str, configured: set):
118
+ """The first whole-suite command the acceptance criteria name, or None."""
119
+ for line in acceptance_lines(prompt):
120
+ spans = COMMAND_SPAN.findall(line) or [line]
121
+ for span in spans:
122
+ command = ' '.join(span.split())
123
+ if WHOLE_SUITE.fullmatch(command) or command in configured:
124
+ return command
125
+ return None
126
+
127
+
69
128
  def rows(plan: Path) -> list:
70
129
  out = []
71
130
  try:
@@ -82,6 +141,7 @@ def rows(plan: Path) -> list:
82
141
 
83
142
  def size_notes(plan: Path) -> list:
84
143
  notes = []
144
+ configured = verify_commands(plan)
85
145
  for row in rows(plan):
86
146
  try:
87
147
  prompt = (plan / 'tasks' / row['id'] / 'prompt.md').read_text(errors='replace')
@@ -103,6 +163,11 @@ def size_notes(plan: Path) -> list:
103
163
  if not has_acceptance_criteria(prompt):
104
164
  notes.append((row['id'], 'no acceptance criteria: end prompt.md with an "## Acceptance criteria" '
105
165
  'section of checks the reviewer can verify'))
166
+ command = whole_suite_asked(prompt, configured)
167
+ if command:
168
+ notes.append((row['id'], 'acceptance criteria ask for the whole suite (`%s`): every attempt would run '
169
+ 'it; name the task\'s own tests instead, the run\'s verification runs the suite after '
170
+ 'each merge' % command))
106
171
  return notes
107
172
 
108
173