@giamme/forge 0.13.1 → 0.14.1
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.
- package/CHANGELOG.md +38 -0
- package/SKILL.md +17 -11
- package/VERSION +1 -1
- package/docs/artifacts.md +2 -0
- package/docs/commands.md +134 -8
- package/docs/development.md +3 -0
- package/docs/reviews.md +2 -0
- package/docs/troubleshooting.md +5 -1
- package/forge +28 -1
- package/package.json +1 -1
- package/references/dataset.md +3 -1
- package/references/decompose.md +201 -61
- package/references/harnesses.md +4 -1
- package/references/runtime.md +29 -0
- package/references/ui.md +10 -0
- package/scripts/forge-compare.py +491 -0
- package/scripts/forge-config.py +3 -3
- package/scripts/forge-contract.py +34 -8
- package/scripts/forge-control.py +105 -13
- package/scripts/forge-dispatch.sh +85 -25
- package/scripts/forge-jev-options.sh +17 -4
- package/scripts/forge-ledger.py +387 -0
- package/scripts/forge-lib-plans.sh +11 -2
- package/scripts/forge-lib-task.sh +390 -28
- package/scripts/forge-parallel-options.sh +20 -4
- package/scripts/forge-parallel.sh +123 -17
- package/scripts/forge-plan-check.py +68 -3
- package/scripts/forge-pr.py +276 -0
- package/scripts/forge-route.py +403 -38
- package/scripts/forge-runs.py +18 -1
- package/scripts/forge-runtime.py +94 -8
- package/scripts/forge-schedule.py +303 -46
- package/scripts/forge-verify-failed.py +111 -0
- package/scripts/forge-watch.py +372 -0
- package/scripts/forge_dataset/harvest.py +3 -1
- package/scripts/forge_fractal/cli.py +23 -6
- package/scripts/forge_infra.py +274 -0
- package/scripts/forge_jev/client.py +13 -9
- package/ui/docs/api.md +51 -8
- package/ui/forge_ui/export.py +6 -2
- package/ui/forge_ui/reader.py +172 -6
- package/ui/forge_ui/static/app.js +2 -2
- package/ui/forge_ui/static/checksview.js +20 -7
- package/ui/forge_ui/static/controls.js +6 -3
- package/ui/forge_ui/static/panel.js +69 -4
- package/ui/forge_ui/static/runmodel.js +30 -4
- package/ui/forge_ui/static/scene3d.js +3 -2
- 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
|
|
@@ -404,11 +422,13 @@ EOF
|
|
|
404
422
|
# Exploration (--explore): now and then the neighbouring tier's model instead, with the
|
|
405
423
|
# odds recorded, so `forge dataset routing` can compare two models on tasks neither was
|
|
406
424
|
# routed to by design. The pool's turn above was still taken, so other rows are unchanged.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
425
|
+
# Explored or not, the pick's tier is recorded (running.tier), so an escalation or pin that
|
|
426
|
+
# this re-plan replaces no longer says which tier a lateral move stays in (#106).
|
|
427
|
+
if [ "$dw" != UNASSIGNED ]; then
|
|
428
|
+
local assigned
|
|
429
|
+
assigned="$(python3 "$SKILL_DIR/scripts/forge-route.py" assign --plan "$PLAN" --task "$id" \
|
|
430
|
+
--tier "$diff" --epsilon "${EXPLORE:-0}" --default "$dw" --pools "$PLAN/fractal-routing.json" 2>/dev/null)"
|
|
431
|
+
[ -z "$assigned" ] || dw="$assigned"
|
|
412
432
|
fi
|
|
413
433
|
fi
|
|
414
434
|
# resolve qa: the same grammar as the dwarf, a comma-list round-robins within its tier.
|
|
@@ -941,7 +961,9 @@ do_task_body() (
|
|
|
941
961
|
[ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role dwarf 2>/dev/null
|
|
942
962
|
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
963
|
echo "On retry, fix the findings in the existing work; preserve parts not criticised. Explain any finding you reject."
|
|
944
|
-
|
|
964
|
+
# With repository verification configured, the whole suite runs after the merge, never per attempt.
|
|
965
|
+
echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf $([ ! -f "$PLAN/pre_review_tests" ] || echo --pre-review) \
|
|
966
|
+
$([ -z "$(verify_source_for "$PLAN" "$REPO")" ] || echo --verify-after-merge)
|
|
945
967
|
echo; /bin/bash "$MEMORY" note dwarf
|
|
946
968
|
} > "$tdir/dwarf.input"
|
|
947
969
|
guard_before_dwarf "$wt" "$tdir"
|
|
@@ -1274,13 +1296,17 @@ do_task_body() (
|
|
|
1274
1296
|
# Entry point for both the scheduler's `_task` and `retry`: runs the pipeline, then logs
|
|
1275
1297
|
# the attempt (including infrastructure stops, which spend nothing) for later audit.
|
|
1276
1298
|
do_task() {
|
|
1277
|
-
local rc
|
|
1299
|
+
local rc crc=0 stop_before
|
|
1278
1300
|
do_task_body "$@"; rc=$?
|
|
1279
1301
|
record_attempt "$1" "$2"
|
|
1280
1302
|
# The retry policy's state (escalation.next or escalation.stop), decided now rather than
|
|
1281
1303
|
# at the next retry so a spent retry budget still reports it and the scheduler sees it.
|
|
1304
|
+
stop_before="$(cat "$1/tasks/$2/escalation.stop" 2>/dev/null)"
|
|
1282
1305
|
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 ||
|
|
1306
|
+
--qa-only-next "$(qa_only_next_flag "$1" "$2")" >/dev/null 2>&1 || crc=$?
|
|
1307
|
+
# A FAIL that does not converge, or that the policy could not move to a stronger model, waits
|
|
1308
|
+
# for a person (NEEDS_DECISION). attempts.tsv was written above and keeps FAIL.
|
|
1309
|
+
decision_after_attempt "$1" "$2" "$stop_before" "$crc"
|
|
1284
1310
|
return $rc
|
|
1285
1311
|
}
|
|
1286
1312
|
|
|
@@ -1338,11 +1364,15 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
|
|
|
1338
1364
|
# into the real plan. Leaves n (how many answer flags), flag, val and novalue in the scratch dir.
|
|
1339
1365
|
_retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
1340
1366
|
local sd="$1"; shift
|
|
1341
|
-
local n=0 flag="" val="" novalue=0 rc=0
|
|
1367
|
+
local n=0 flag="" val="" novalue=0 rc=0 dwarf="" decide="" reason="" approved=0
|
|
1342
1368
|
while [ $# -gt 0 ]; do
|
|
1343
1369
|
case "$1" in
|
|
1344
1370
|
--no-ripwire|--yolo-dwarf|--yolo-qa) shift ;;
|
|
1345
|
-
--output|--
|
|
1371
|
+
--output|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
|
|
1372
|
+
--dwarf) [ $# -ge 2 ] || break; dwarf="$2"; shift 2 ;;
|
|
1373
|
+
--decide) [ $# -ge 2 ] || break; decide="$2"; shift 2 ;;
|
|
1374
|
+
--reason) [ $# -ge 2 ] || break; reason="$2"; shift 2 ;;
|
|
1375
|
+
--approved) approved=1; shift ;;
|
|
1346
1376
|
--answer|--answer-file)
|
|
1347
1377
|
n=$((n + 1)); flag="$1"
|
|
1348
1378
|
if [ $# -ge 2 ]; then val="$2"; shift 2; else novalue=1; shift; fi ;;
|
|
@@ -1359,6 +1389,8 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
|
1359
1389
|
esac
|
|
1360
1390
|
done
|
|
1361
1391
|
printf '%s' "$n" > "$sd/n"; printf '%s' "$flag" > "$sd/flag"; printf '%s' "$val" > "$sd/val"
|
|
1392
|
+
printf '%s' "$dwarf" > "$sd/dwarf"; printf '%s' "$decide" > "$sd/decide"
|
|
1393
|
+
printf '%s' "$reason" > "$sd/reason"; printf '%s' "$approved" > "$sd/approved"
|
|
1362
1394
|
[ "$novalue" = 0 ] || : > "$sd/novalue"
|
|
1363
1395
|
}
|
|
1364
1396
|
|
|
@@ -1368,18 +1400,21 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
|
1368
1400
|
do_retry() {
|
|
1369
1401
|
local PLAN="${1:?retry needs a plan dir}" id="${2:?retry needs a task id}"; shift 2
|
|
1370
1402
|
FORGE_RUN_STARTED="$(forge_now)"
|
|
1371
|
-
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0
|
|
1403
|
+
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0 DECIDE="" REASON="" APPROVED=0
|
|
1372
1404
|
# An answer is validated before any option below writes into the plan: a rejected answer
|
|
1373
1405
|
# changes nothing, --setup and --verify included. Only a NEEDS_INPUT task takes one. The
|
|
1374
1406
|
# arguments are walked the way the loop below walks them (a value is never taken for a flag),
|
|
1375
1407
|
# in a subshell against a scratch plan dir, so nothing real is written by the walk.
|
|
1376
1408
|
local pre_dir="$PLAN/.answer-scan.$$" pre_n=0 pre_have="" pre_val="" pre_novalue=0 pre_ok=0
|
|
1409
|
+
local pre_dwarf="" pre_decide="" pre_reason="" pre_approved=0
|
|
1377
1410
|
rm -rf "$pre_dir"
|
|
1378
1411
|
if mkdir "$pre_dir" 2>/dev/null; then
|
|
1379
1412
|
if ( _retry_answer_scan "$pre_dir" "$@" ) >/dev/null 2>&1; then
|
|
1380
1413
|
pre_ok=1
|
|
1381
1414
|
pre_n="$(<"$pre_dir/n")"; pre_have="$(<"$pre_dir/flag")"; pre_val="$(<"$pre_dir/val")"
|
|
1382
1415
|
[ ! -f "$pre_dir/novalue" ] || pre_novalue=1
|
|
1416
|
+
pre_dwarf="$(<"$pre_dir/dwarf")"; pre_decide="$(<"$pre_dir/decide")"
|
|
1417
|
+
pre_reason="$(<"$pre_dir/reason")"; pre_approved="$(<"$pre_dir/approved")"
|
|
1383
1418
|
# `$(<f)` drops trailing newlines, so an answer of only newlines needs the size check.
|
|
1384
1419
|
[ -s "$pre_dir/val" ] || pre_val=""
|
|
1385
1420
|
fi
|
|
@@ -1400,11 +1435,19 @@ do_retry() {
|
|
|
1400
1435
|
[ -n "$pre_val" ] || die "retry: the answer is empty"
|
|
1401
1436
|
fi
|
|
1402
1437
|
fi
|
|
1438
|
+
# A decision is judged the same way, before any option writes: a NEEDS_DECISION task is resumed
|
|
1439
|
+
# only by --decide or --dwarf with --reason and --approved, and --decide is for no other task.
|
|
1440
|
+
if [ "$pre_ok" = 1 ] && [ -s "$PLAN/tasks.tsv" ] && all_ids "$PLAN/tasks.tsv" | grep -qx "$id"; then
|
|
1441
|
+
retry_decision_gate "$PLAN" "$id" "$(task_status "$PLAN" "$id")" "$pre_decide" "$pre_dwarf" "$pre_reason" "$pre_approved"
|
|
1442
|
+
fi
|
|
1403
1443
|
while [ $# -gt 0 ]; do
|
|
1404
1444
|
case "$1" in
|
|
1405
1445
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
1406
1446
|
--output) OUTPUT="${2:?}"; shift 2 ;;
|
|
1407
1447
|
--dwarf) NEWDWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
|
|
1448
|
+
--decide) DECIDE="${2:?--decide needs retry=N or threshold=Pn}"; shift 2 ;;
|
|
1449
|
+
--reason) REASON="${2?--reason needs a text}"; shift 2 ;;
|
|
1450
|
+
--approved) APPROVED=1; shift ;;
|
|
1408
1451
|
# The check above refuses an empty answer first; these hold when its walk could not run.
|
|
1409
1452
|
--answer) [ "$HAVE_ANSWER" = 0 ] || die "retry: give --answer or --answer-file once"
|
|
1410
1453
|
ANSWER="${2?--answer needs the answer text}"; HAVE_ANSWER=1; shift 2
|
|
@@ -1442,6 +1485,9 @@ do_retry() {
|
|
|
1442
1485
|
local st; st="$(task_status "$PLAN" "$id")"
|
|
1443
1486
|
[ "$st" = "MERGED" ] && die "task '$id' already merged — nothing to retry"
|
|
1444
1487
|
[ "$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"
|
|
1488
|
+
retry_decision_gate "$PLAN" "$id" "$st" "$DECIDE" "$NEWDWARF" "$REASON" "$APPROVED"
|
|
1489
|
+
# A task at its attempt cap (#69) is refused with the decision commands unless --decide retry=N reaches past it.
|
|
1490
|
+
if ! attempt_cap_gate "$PLAN" "$id" "$st" "$DECIDE"; then write_results "$PLAN"; return 2; fi
|
|
1445
1491
|
# The user's answer to a NEEDS_INPUT task's question (validated above): written before
|
|
1446
1492
|
# anything else is prepared, atomically, and kept when the preparation then refuses (the
|
|
1447
1493
|
# same answer can be retried).
|
|
@@ -1459,7 +1505,14 @@ do_retry() {
|
|
|
1459
1505
|
# A refusal (the retry policy found no stronger model, or the escalation could not be
|
|
1460
1506
|
# written) must stop here: past this point the status is cleared and a dwarf dispatched.
|
|
1461
1507
|
local prc=0
|
|
1462
|
-
|
|
1508
|
+
if [ "$st" = NEEDS_DECISION ]; then
|
|
1509
|
+
retry_decided "$PLAN" "$id" "$DECIDE" "$NEWDWARF" "$REASON" || prc=$?
|
|
1510
|
+
else
|
|
1511
|
+
prepare_retry "$PLAN" "$id" "$NEWDWARF" || prc=$?
|
|
1512
|
+
# A person's plain retry ends what an earlier decision allowed; resuming after an
|
|
1513
|
+
# infrastructure stop is not a new choice, so the allowance carries over.
|
|
1514
|
+
[ "$prc" != 0 ] || [ "$st" = INFRA ] || rm -f "${tdir:?}/decided.left"
|
|
1515
|
+
fi
|
|
1463
1516
|
if [ "$prc" != 0 ]; then
|
|
1464
1517
|
write_results "$PLAN"
|
|
1465
1518
|
[ "$prc" = 3 ] && return 2
|
|
@@ -1474,12 +1527,31 @@ do_retry() {
|
|
|
1474
1527
|
preflight_plan "$PLAN" || return $?
|
|
1475
1528
|
/bin/bash "$SKILL_DIR/scripts/forge-install-ripwire.sh" || true
|
|
1476
1529
|
rm -f "$tdir/status"
|
|
1530
|
+
# The pauses an earlier run ended with describe that run: this retry's summary must not report them.
|
|
1531
|
+
rm -f "$PLAN/infra.last"
|
|
1477
1532
|
|
|
1478
1533
|
note "retrying $id with dwarf $(field "$T" "$id" dwarf)"
|
|
1479
1534
|
export FORGE_FRACTAL_RETRY=1
|
|
1480
1535
|
export FORGE_DATASET_TRIGGER=human
|
|
1481
1536
|
do_task "$PLAN" "$id"
|
|
1482
1537
|
st="$(task_status "$PLAN" "$id")"
|
|
1538
|
+
# A decision of retry=N is N attempts in all: this one, then N-1 more while the reviews fail.
|
|
1539
|
+
# Any other decision is this one attempt. The same stops apply as to any retry: a task that
|
|
1540
|
+
# stopped for a decision again, an empty diff, or a policy that finds no stronger model.
|
|
1541
|
+
# The count is decided.left, so it survives a run that ended before the attempts were used.
|
|
1542
|
+
local more; more="$(decided_left "$tdir")"; more="${more:-0}"
|
|
1543
|
+
while [ "$more" -gt 0 ] && { [ "$st" = FAIL ] || [ "$st" = UNKNOWN ]; } && [ ! -e "$tdir/noretry" ]; do
|
|
1544
|
+
# Each further attempt is spent against the cap (#69) like the scheduler's retries: an UNKNOWN review
|
|
1545
|
+
# does not stop the task by itself, so the cap is checked here, and a task at it stops for a decision.
|
|
1546
|
+
if ! attempt_cap_gate "$PLAN" "$id" "$st" ""; then st="$(task_status "$PLAN" "$id")"; break; fi
|
|
1547
|
+
more=$(( more - 1 ))
|
|
1548
|
+
prepare_retry "$PLAN" "$id" || break
|
|
1549
|
+
decided_left_set "$tdir" "$more" || break
|
|
1550
|
+
rm -f "$tdir/status"
|
|
1551
|
+
note "retrying $id (decided retry, $more more after this)"
|
|
1552
|
+
do_task "$PLAN" "$id"
|
|
1553
|
+
st="$(task_status "$PLAN" "$id")"
|
|
1554
|
+
done
|
|
1483
1555
|
if [ "$st" = "INFRA" ]; then
|
|
1484
1556
|
# Nothing was judged and no attempt was spent: skip verification, say how to resume.
|
|
1485
1557
|
write_results "$PLAN"
|
|
@@ -1494,12 +1566,23 @@ do_retry() {
|
|
|
1494
1566
|
note "$id PASS but conflicted on merge — branch preserved"
|
|
1495
1567
|
fi
|
|
1496
1568
|
fi
|
|
1497
|
-
|
|
1569
|
+
# Tasks still to run (#112): the run that dispatches them verifies the integration branch at its
|
|
1570
|
+
# end, and integrate verifies its candidate, so verifying now would only be repeated.
|
|
1571
|
+
local left="" lid
|
|
1572
|
+
for lid in $(all_ids "$T"); do
|
|
1573
|
+
case "$(task_status "$PLAN" "$lid")" in PENDING|BLOCKED) left="${left:+$left }$lid" ;; esac
|
|
1574
|
+
done
|
|
1575
|
+
if [ -n "$left" ]; then
|
|
1576
|
+
note "verification deferred: tasks still to run ($left); the next run, or integrate, verifies the integration branch"
|
|
1577
|
+
else
|
|
1578
|
+
verify_result "$PLAN" "$(cat "$PLAN/wt_root")/_integration" "$PLAN" || { write_results "$PLAN"; run_report_extras "$PLAN"; return 5; }
|
|
1579
|
+
fi
|
|
1498
1580
|
write_results "$PLAN"
|
|
1499
1581
|
echo
|
|
1500
1582
|
printf ' %-14s %-9s %s\n' id status branch
|
|
1501
1583
|
awk -F'\t' '{printf " %-14s %-9s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
|
|
1502
1584
|
run_report_extras "$PLAN"
|
|
1585
|
+
report_decisions "$PLAN"
|
|
1503
1586
|
[ "$(task_status "$PLAN" "$id")" = "MERGED" ] || return 5
|
|
1504
1587
|
return 0
|
|
1505
1588
|
}
|
|
@@ -1614,7 +1697,7 @@ verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
|
1614
1697
|
forge_metric_begin "$out" verification
|
|
1615
1698
|
forge_metric_phase verification
|
|
1616
1699
|
repo="$(cat "$plan/repo")"
|
|
1617
|
-
rm -f "$out/verification.flaky" "$out/verification.retry.log" "$out/verification.coverage.txt" \
|
|
1700
|
+
rm -f "$out/verification.flaky" "$out/verification.retry.log" "$out/verification.failing.log" "$out/verification.coverage.txt" \
|
|
1618
1701
|
"$out/verification.runs.tsv" "$out"/verification.run-*.log "$out/verification.commit" \
|
|
1619
1702
|
"$out/verification.lanes.json" "$out"/verification.lane.*.log
|
|
1620
1703
|
# The commit being verified, named before any early return, so every outcome (FAIL and
|
|
@@ -1730,10 +1813,31 @@ with open(out + "/verification.jev.json", "w") as fh:
|
|
|
1730
1813
|
verify_stopped "$out" && return 130
|
|
1731
1814
|
echo "$before" > "$out/verification.fingerprint"
|
|
1732
1815
|
if [ "$rc" != 0 ] || [ "$before" != "$after" ]; then
|
|
1733
|
-
local flaked=0 n_retry=0 rc3 b3 a3
|
|
1816
|
+
local flaked=0 n_retry=0 rc3 b3 a3 fcmd
|
|
1734
1817
|
# The rerun itself is the evidence: it needs no model and no recorded trap. A tree
|
|
1735
1818
|
# change is never retried.
|
|
1736
1819
|
if [ "$rc" != 0 ] && [ "$before" = "$after" ] && [ "$vretries" -gt 0 ]; then
|
|
1820
|
+
# First the failing tests alone, through .forge/verify-subset (#112): failing again on their own
|
|
1821
|
+
# confirms a regression without a second full suite. Their pass says nothing about the rest of
|
|
1822
|
+
# the command, so the full rerun below still decides a flaky result.
|
|
1823
|
+
if [ -s "$repo/.forge/verify-subset" ] && fcmd="$(python3 "$SKILL_DIR/scripts/forge-verify-failed.py" command \
|
|
1824
|
+
--checkout "$wt" --log "$out/verification.log" --subset "$repo/.forge/verify-subset" 2>/dev/null)"; then
|
|
1825
|
+
rc3=0
|
|
1826
|
+
note "verification failed (exit $rc); rerunning only the failing tests first: $fcmd"
|
|
1827
|
+
b3="$(forge_fingerprint "$wt")" || return 1
|
|
1828
|
+
vt0="$(date +%s)"
|
|
1829
|
+
verify_stopped "$out" && return 130
|
|
1830
|
+
verify_exec "$wt" "$fcmd" "$out/verification.failing.log" || rc3=$?
|
|
1831
|
+
a3="$(forge_fingerprint "$wt")" || { verify_stopped "$out" && return 130; return 1; }
|
|
1832
|
+
verify_run_note "$out" failing "$rc3" "$b3" "$a3" verification.failing.log "$vt0"
|
|
1833
|
+
verify_stopped "$out" && return 130
|
|
1834
|
+
# 126 and 127: the subset command itself could not run, which confirms nothing.
|
|
1835
|
+
if [ "$rc3" != 0 ] && [ "$rc3" != 126 ] && [ "$rc3" != 127 ] && [ "$b3" = "$a3" ]; then
|
|
1836
|
+
echo FAIL > "$out/verification.status"
|
|
1837
|
+
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"
|
|
1838
|
+
return 1
|
|
1839
|
+
fi
|
|
1840
|
+
fi
|
|
1737
1841
|
while [ "$n_retry" -lt "$vretries" ] && [ "$flaked" = 0 ]; do
|
|
1738
1842
|
n_retry=$((n_retry+1)); rc3=0
|
|
1739
1843
|
note "verification failed (exit $rc); rerunning to tell a flaky lane from a regression ($n_retry/$vretries)"
|
|
@@ -2023,10 +2127,12 @@ do_run() {
|
|
|
2023
2127
|
done
|
|
2024
2128
|
echo
|
|
2025
2129
|
fi
|
|
2130
|
+
# Tasks stopped for a decision (#69): why, and the choices. Not failures to retry either.
|
|
2131
|
+
report_decisions "$PLAN"
|
|
2026
2132
|
# The retry hint is for tasks that actually failed; a run that only failed verification,
|
|
2027
2133
|
# 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
|
|
2134
|
+
# has its own hint above, a task waiting for an answer or a decision its own block.
|
|
2135
|
+
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
2136
|
echo "retry a failed task with its reviewer's findings:"
|
|
2031
2137
|
echo " forge-parallel.sh retry $PLAN <task-id> [--dwarf <spec>]"
|
|
2032
2138
|
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,
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|