@giamme/forge 0.12.1 → 0.13.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.
- package/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/SKILL.md +29 -12
- package/VERSION +1 -1
- package/docs/add-ons.md +11 -6
- package/docs/artifacts.md +12 -6
- package/docs/commands.md +179 -17
- package/docs/decomposed-runs.md +13 -5
- package/docs/forge-ui.md +7 -3
- package/docs/memory.md +2 -1
- package/docs/models.md +4 -2
- package/docs/reviews.md +49 -20
- package/docs/troubleshooting.md +3 -1
- package/forge +17 -1
- package/package.json +1 -1
- package/references/dataset.md +39 -13
- package/references/decision-models.md +759 -0
- package/references/decompose.md +166 -29
- package/references/harnesses.md +10 -3
- package/references/planning.md +8 -0
- package/references/solo.md +13 -3
- package/scripts/forge-artifact.sh +30 -4
- package/scripts/forge-config.py +238 -29
- package/scripts/forge-contract.py +95 -56
- package/scripts/forge-control.py +40 -9
- package/scripts/forge-decide.py +6 -0
- package/scripts/forge-dispatch.sh +38 -16
- package/scripts/forge-fail-first.py +2 -2
- package/scripts/forge-gate-addressed.sh +40 -0
- package/scripts/forge-gate-message.sh +64 -0
- package/scripts/forge-issues.py +321 -33
- package/scripts/forge-jev-options.sh +269 -42
- package/scripts/forge-lib-attribute.sh +447 -0
- package/scripts/forge-lib-gates.sh +32 -0
- package/scripts/forge-lib-plans.sh +17 -6
- package/scripts/forge-lib-review.sh +22 -17
- package/scripts/forge-lib-task.sh +217 -38
- package/scripts/forge-lib-verify.sh +45 -8
- package/scripts/forge-memory.sh +3 -3
- package/scripts/forge-parallel-options.sh +18 -5
- package/scripts/forge-parallel.sh +455 -303
- package/scripts/forge-plan-check.py +35 -1
- package/scripts/forge-pre-review.py +437 -0
- package/scripts/forge-prompt.py +25 -5
- package/scripts/forge-route.py +2 -2
- package/scripts/forge-runtime.py +10 -4
- package/scripts/forge-schedule.py +21 -5
- package/scripts/forge-shadow.py +2 -2
- package/scripts/forge-solo.sh +38 -9
- package/scripts/forge-submodules.py +389 -0
- package/scripts/forge_dataset/cli.py +12 -6
- package/scripts/forge_dataset/export.py +55 -45
- package/scripts/forge_dataset/harvest.py +33 -5
- package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
- package/scripts/forge_decide/__init__.py +141 -0
- package/scripts/forge_decide/budget.py +149 -0
- package/scripts/forge_decide/cache.py +66 -0
- package/scripts/forge_decide/cli.py +953 -0
- package/scripts/forge_decide/doctor.py +221 -0
- package/scripts/forge_decide/label_addressed.py +75 -0
- package/scripts/forge_decide/label_attribution.py +62 -0
- package/scripts/forge_decide/label_coverage.py +81 -0
- package/scripts/forge_decide/label_message.py +38 -0
- package/scripts/forge_decide/label_prompt.py +139 -0
- package/scripts/forge_decide/labels.py +328 -0
- package/scripts/forge_decide/metrics.py +125 -0
- package/scripts/forge_decide/migrate.py +226 -0
- package/scripts/forge_decide/providers.py +292 -0
- package/scripts/forge_decide/replay.py +350 -0
- package/scripts/forge_decide/report.py +382 -0
- package/scripts/forge_decide/resolve.py +397 -0
- package/scripts/forge_decide/sites.py +377 -0
- package/scripts/forge_jev/__init__.py +202 -104
- package/scripts/forge_jev/addressed.py +171 -0
- package/scripts/forge_jev/attribution.py +198 -0
- package/scripts/forge_jev/cli.py +460 -382
- package/scripts/forge_jev/client.py +155 -77
- package/scripts/forge_jev/coupling.py +19 -87
- package/scripts/forge_jev/coverage.py +303 -0
- package/scripts/forge_jev/findings.py +219 -0
- package/scripts/forge_jev/gates.py +225 -27
- package/scripts/forge_jev/memory.py +65 -4
- package/scripts/forge_jev/message.py +134 -0
- package/scripts/forge_jev/plan_gates.py +294 -0
- package/scripts/forge_jev/questions.py +173 -313
- package/scripts/forge_jev/verify.py +130 -104
- package/ui/README.md +2 -2
- package/ui/docs/api.md +60 -32
- package/ui/forge_ui/control.py +60 -11
- package/ui/forge_ui/export.py +2 -1
- package/ui/forge_ui/models.py +1 -0
- package/ui/forge_ui/reader.py +87 -14
- package/ui/forge_ui/static/app.js +2 -2
- package/ui/forge_ui/static/controls.js +20 -13
- package/ui/forge_ui/static/panel.js +63 -17
- package/ui/forge_ui/static/runmodel.js +23 -1
- package/ui/forge_ui/static/scene3d.js +2 -15
- package/ui/forge_ui/static/settings.js +336 -41
- package/ui/forge_ui/static/style.css +19 -7
- package/references/jev.md +0 -865
- package/scripts/forge_jev/backtest.py +0 -322
- package/scripts/forge_jev/corpus.py +0 -156
- package/scripts/forge_jev/features.py +0 -24
- package/scripts/forge_jev/predict.py +0 -204
- package/scripts/forge_jev/review.py +0 -73
- package/scripts/forge_jev/routing.py +0 -271
- package/scripts/forge_jev/subset.py +0 -123
|
@@ -6,16 +6,19 @@
|
|
|
6
6
|
#
|
|
7
7
|
# Usage:
|
|
8
8
|
# forge-parallel.sh plan <plan-dir> --repo <dir> [routing flags] [--decompose-level low|medium|high] [--ui]
|
|
9
|
+
# [--qa-threshold P0|P1|P2|P3|none|default]
|
|
9
10
|
# forge-parallel.sh run <plan-dir> [--max-parallel N] [--yolo-dwarf] [--yolo-qa]
|
|
10
11
|
# [--verify <command>] [--setup <command>] [--dry-run]
|
|
11
12
|
# [--timeout S] [--retry-failed N] [--infra-retries M]
|
|
12
|
-
# [--qa-threshold P0|P1|P2|P3] [--verify-retries N] [--no-forecast]
|
|
13
|
+
# [--qa-threshold P0|P1|P2|P3|none|default] [--verify-retries N] [--no-forecast]
|
|
13
14
|
# [--sweep P0|P1|P2|P3 [--sweep-plausible] [--sweep-max N]]
|
|
14
|
-
# [--sweep-ahead | --no-sweep-ahead]
|
|
15
|
+
# [--sweep-ahead | --no-sweep-ahead] [--attribute | --no-attribute]
|
|
15
16
|
# forge-parallel.sh retry <plan-dir> <task-id> [--dwarf <spec>] [--setup <command>]
|
|
16
|
-
# [--
|
|
17
|
+
# [--answer <text> | --answer-file <file>] (a NEEDS_INPUT task)
|
|
18
|
+
# [--timeout S] [--qa-threshold Pn|none|default] [--verify-retries N]
|
|
17
19
|
# forge-parallel.sh integrate <plan-dir> --approved [--verify-retries N] [--final-review <qa-spec>]
|
|
18
|
-
# forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold Pn]
|
|
20
|
+
# forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold Pn|none|default]
|
|
21
|
+
# forge-parallel.sh attribute <plan-dir> [--force] (find a merge that breaks the failed verification)
|
|
19
22
|
# forge-parallel.sh accept <plan-dir> <task-id> --reason "<why>" --approved
|
|
20
23
|
# forge-parallel.sh split <plan-dir> <new-plan> --tasks <id,id> [--dry-run]
|
|
21
24
|
# forge-parallel.sh combine <new-plan> <plan-a> <plan-b> [<plan>...] [--verify <command>] [--dry-run]
|
|
@@ -41,18 +44,30 @@
|
|
|
41
44
|
# unchanged, and starts fresh whenever it cannot; each round is
|
|
42
45
|
# logged in tasks/<id>/review_sessions.tsv and tagged in the
|
|
43
46
|
# dataset. `--no-reviewer-session` turns it off (the default)
|
|
47
|
+
# --implementer-session opt-in: a retry continues the implementer's earlier session
|
|
48
|
+
# (claude, openclaude) when its spec is unchanged and its work is
|
|
49
|
+
# still what the review judged, and starts fresh whenever it cannot;
|
|
50
|
+
# each attempt is logged in tasks/<id>/implementer_sessions.tsv.
|
|
51
|
+
# `--no-implementer-session` turns it off (the default)
|
|
44
52
|
# --explore E on by default at 0.2 (0 turns it off, and is kept): a row left
|
|
45
53
|
# to forge gets, with probability E/2, its neighbouring model
|
|
46
54
|
# (one tier away in the given pools) instead of its pool's turn;
|
|
47
55
|
# each decision and its odds go to tasks/<id>/route.jsonl
|
|
48
56
|
# (precedence: flag, this plan's earlier choice, FORGE_ROUTE_EXPLORE)
|
|
49
57
|
#
|
|
58
|
+
# The QA threshold (plan, run, retry, review; kept for the plan):
|
|
59
|
+
# --qa-threshold Pn the least severe CONFIRMED finding that still blocks (P0 worst ...
|
|
60
|
+
# P3 mildest; P2 when not set). forge decides the verdict from the
|
|
61
|
+
# findings: a PASS that lists a CONFIRMED finding at Pn or worse (or
|
|
62
|
+
# one with no severity) becomes FAIL; a FAIL made only of findings
|
|
63
|
+
# less severe than Pn is accepted as PASS-with-known-issues, and those
|
|
64
|
+
# are recorded in known_issues.md. `none` (or `off`) = P3, every
|
|
65
|
+
# CONFIRMED finding blocks; `default` goes back to P2
|
|
66
|
+
#
|
|
50
67
|
# Opt-in run behaviour (all off unless asked):
|
|
51
68
|
# --retry-failed N re-queue a task whose reviewer said FAIL up to N more times,
|
|
52
69
|
# inside the same run, while the other tasks keep going
|
|
53
70
|
# --infra-retries M wait out quota/auth/network stops up to M times instead of pausing
|
|
54
|
-
# --qa-threshold Pn a reviewer FAIL made only of findings less severe than Pn is
|
|
55
|
-
# accepted as PASS-with-known-issues (P0 worst ... P3 mildest)
|
|
56
71
|
# --sweep Pn once every task has merged, before verification: the open findings
|
|
57
72
|
# at Pn or worse (tolerated, and PLAUSIBLE with --sweep-plausible) become
|
|
58
73
|
# at most --sweep-max N fix tasks (default 5), one per file, each with a
|
|
@@ -60,6 +75,8 @@
|
|
|
60
75
|
# plan; what it does not fix stays for `forge issues`
|
|
61
76
|
# --sweep-ahead a task is also told the open findings in files it owns, to fix only
|
|
62
77
|
# on its way (kept for the plan; --no-sweep-ahead turns it off)
|
|
78
|
+
# --attribute when the run's combined verification fails, search the merge order for
|
|
79
|
+
# a merge that breaks it (kept for the plan; --no-attribute turns it off)
|
|
63
80
|
#
|
|
64
81
|
# Exit codes: 0 ok | 2 usage/validation | 3 precondition (not a git repo, etc.)
|
|
65
82
|
# 5 some task failed QA or verification failed | 6 integration conflict
|
|
@@ -84,7 +101,7 @@ JEV_OPTS=0
|
|
|
84
101
|
# Flags shared by several subcommands, then the helper libraries. Functions only, resolved
|
|
85
102
|
# at call time, so they may use die/note/field and friends defined below.
|
|
86
103
|
source "$SKILL_DIR/scripts/forge-parallel-options.sh"
|
|
87
|
-
for forge_lib in task verify plans review; do
|
|
104
|
+
for forge_lib in task gates verify attribute plans review; do
|
|
88
105
|
[ -f "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh" ] && source "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh"
|
|
89
106
|
done
|
|
90
107
|
OUTPUT=summary
|
|
@@ -147,7 +164,7 @@ pool_pick() { # pool_pick <comma-list> <index>
|
|
|
147
164
|
do_plan() {
|
|
148
165
|
local PLAN="${1:?plan needs a plan dir}"; shift
|
|
149
166
|
local REPO="" D_ANY="" D_HI="" D_MD="" D_LO="" Q_ANY="" Q_HI="" Q_MD="" Q_LO=""
|
|
150
|
-
local PLANNER="" NOMEM=0 jev_rc=0 DLEVEL="" SHADOW_QA="" SHADOW_RATE="" EXPLORE="" FAIL_FIRST="" REVIEWER_SESSION=""
|
|
167
|
+
local PLANNER="" NOMEM=0 jev_rc=0 DLEVEL="" SHADOW_QA="" SHADOW_RATE="" EXPLORE="" FAIL_FIRST="" REVIEWER_SESSION="" IMPLEMENTER_SESSION="" PRE_REVIEW="" PRE_REVIEW_PARALLEL=""
|
|
151
168
|
while [ $# -gt 0 ]; do
|
|
152
169
|
case "$1" in
|
|
153
170
|
--repo) REPO="${2:?}"; shift 2 ;;
|
|
@@ -175,12 +192,23 @@ do_plan() {
|
|
|
175
192
|
--ui|--no-ui) forge_ui_flag "$1"; shift ;;
|
|
176
193
|
--fail-first) FAIL_FIRST=on; shift ;;
|
|
177
194
|
--no-fail-first) FAIL_FIRST=off; shift ;;
|
|
195
|
+
--pre-review-tests) PRE_REVIEW=on; shift ;;
|
|
196
|
+
--no-pre-review-tests) PRE_REVIEW=off; shift ;;
|
|
197
|
+
--pre-review-parallel)
|
|
198
|
+
printf '%s' "${2:-}" | grep -Eq '^[0-9]{1,2}$' && [ "$2" -ge 1 ] && [ "$2" -le 64 ] \
|
|
199
|
+
|| die "--pre-review-parallel needs an integer from 1 to 64" 2
|
|
200
|
+
PRE_REVIEW_PARALLEL="$((10#$2))"; shift 2 ;;
|
|
178
201
|
--reviewer-session) REVIEWER_SESSION=on; shift ;;
|
|
179
202
|
--no-reviewer-session) REVIEWER_SESSION=off; shift ;;
|
|
203
|
+
--implementer-session) IMPLEMENTER_SESSION=on; shift ;;
|
|
204
|
+
--no-implementer-session) IMPLEMENTER_SESSION=off; shift ;;
|
|
180
205
|
*)
|
|
181
206
|
# `case` is not a loop, so `continue` here belongs to the enclosing while.
|
|
207
|
+
# The shared flags write into the plan dir (--qa-threshold), so it must exist first.
|
|
208
|
+
[ -d "$PLAN" ] || die "plan dir '$PLAN' does not exist"
|
|
209
|
+
if forge_pp_flag plan "$PLAN" "$@"; then shift "$PP_SHIFT"; continue; fi
|
|
182
210
|
if [ "$JEV_OPTS" = 1 ]; then
|
|
183
|
-
forge_jev_flag "
|
|
211
|
+
forge_jev_flag "$@"; jev_rc=$?
|
|
184
212
|
case "$jev_rc" in
|
|
185
213
|
0) shift "$JEV_SHIFT"; continue ;;
|
|
186
214
|
2) exit 2 ;;
|
|
@@ -212,9 +240,16 @@ do_plan() {
|
|
|
212
240
|
|| printf '%s\n' "$SHADOW_RATE" > "$PLAN/shadow_rate"
|
|
213
241
|
# Fail-first evidence (opt-in, advisory) is part of the plan too: every task's review gets it.
|
|
214
242
|
case "$FAIL_FIRST" in on) : > "$PLAN/fail_first" ;; off) rm -f "$PLAN/fail_first" ;; esac
|
|
243
|
+
# Pre-review tests (opt-in, #85): each attempt's affected tests run before its review, and a
|
|
244
|
+
# red result goes back to the implementer without one.
|
|
245
|
+
case "$PRE_REVIEW" in on) : > "$PLAN/pre_review_tests" ;; off) rm -f "$PLAN/pre_review_tests" ;; esac
|
|
246
|
+
# How many checks run at once across the plan's tasks (forge_pre_review's slots; default 2).
|
|
247
|
+
[ -z "$PRE_REVIEW_PARALLEL" ] || printf '%s\n' "$PRE_REVIEW_PARALLEL" > "$PLAN/pre_review_parallel"
|
|
215
248
|
# Reviewer-session continuation (opt-in experiment): the file holds `on`. Readers only
|
|
216
249
|
# test that it exists; the dataset records its content.
|
|
217
250
|
case "$REVIEWER_SESSION" in on) printf '%s\n' on > "$PLAN/reviewer_session" ;; off) rm -f "$PLAN/reviewer_session" ;; esac
|
|
251
|
+
# Implementer-session continuation (opt-in, #90): the same `on` file, read the same way.
|
|
252
|
+
case "$IMPLEMENTER_SESSION" in on) printf '%s\n' on > "$PLAN/implementer_session" ;; off) rm -f "$PLAN/implementer_session" ;; esac
|
|
218
253
|
# Exploration is decided here and only here, so the table and preflight see what will run.
|
|
219
254
|
# On by default: choosing models from measured pass rates needs some randomized picks, and
|
|
220
255
|
# history had almost none (9 tasks ever ran on more than one spec). The flag wins, then
|
|
@@ -239,6 +274,8 @@ do_plan() {
|
|
|
239
274
|
fi
|
|
240
275
|
[ -s "$PLAN/repo" ] || die "plan needs --repo the first time"
|
|
241
276
|
REPO="$(cat "$PLAN/repo")"
|
|
277
|
+
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
278
|
+
[ "$JEV_OPTS" = 1 ] && forge_decide_env "$REPO" "$PLAN"
|
|
242
279
|
[ -s "$PLAN/run_id" ] || basename "$PLAN" | sed 's/^forge-//' > "$PLAN/run_id"
|
|
243
280
|
# Every plan, --ui or not: forge-ui's view of this repo's runs reads the registry.
|
|
244
281
|
forge_ui_register "$PLAN"
|
|
@@ -264,54 +301,68 @@ PY
|
|
|
264
301
|
note " if the tasks depend on them."
|
|
265
302
|
fi
|
|
266
303
|
|
|
267
|
-
# --- jev:
|
|
268
|
-
#
|
|
269
|
-
#
|
|
270
|
-
# removed on 2026-10-17 without ever having acted; models are chosen from measured pass
|
|
271
|
-
# rates instead (plan --explore, `forge dataset routing`).
|
|
304
|
+
# --- jev: plan-time gates ------------------------------------------------------
|
|
305
|
+
# Prompt adequacy and drift: warnings about the task text and its declared files. Drift
|
|
306
|
+
# `on` adds the files it predicts to tasks.tsv (inside score-plan); `shadow` only records.
|
|
272
307
|
local jev_loaded=0
|
|
273
308
|
if [ -f "$SKILL_DIR/scripts/forge-jev-options.sh" ]; then
|
|
274
309
|
source "$SKILL_DIR/scripts/forge-jev-options.sh" 2>/dev/null && jev_loaded=1
|
|
275
310
|
fi
|
|
276
|
-
if [ "$jev_loaded" = 1 ] &&
|
|
311
|
+
if [ "$jev_loaded" = 1 ] && { forge_decide_active prompt || forge_decide_active drift; }; then
|
|
277
312
|
local jev_scores jev_rc
|
|
278
313
|
jev_scores="$(python3 "$SKILL_DIR/scripts/forge-jev.py" score-plan \
|
|
279
314
|
--plan "$PLAN" --repo "$REPO" 2>/dev/null)"
|
|
280
315
|
jev_rc=$?
|
|
316
|
+
# A gate in shadow is asked and recorded by score-plan, which leaves it out of
|
|
317
|
+
# these rows: what is printed here is only what an `on` gate has to say.
|
|
318
|
+
# --jev-shadow before migration keeps its gates `on` and prints a count for the
|
|
319
|
+
# warnings, as it always did; what a gate ADDED is still said, whatever the flag.
|
|
281
320
|
if [ "$jev_rc" -eq 0 ] && [ -n "$jev_scores" ]; then
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
#
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
*prompt_adequacy*) note "jev: $jid — the prompt may be too vague for QA to judge correctness against" ;;
|
|
299
|
-
esac
|
|
300
|
-
case "$jwarn" in
|
|
301
|
-
*independently_verifiable*) note "jev: $jid — may not be verifiable on its own (decompose.md forbids splitting this finely)" ;;
|
|
302
|
-
esac
|
|
303
|
-
fi
|
|
304
|
-
if [ -n "$jdrift" ] && [ "$jdrift" != "-" ]; then
|
|
305
|
-
note "jev: $jid may also edit undeclared files: $jdrift"
|
|
306
|
-
note " undeclared files break wave disjointness — add them to the files column or split the task"
|
|
307
|
-
fi
|
|
308
|
-
done <<EOF
|
|
321
|
+
local jid jwarn jdrift
|
|
322
|
+
# The columns score-plan prints: id, warnings, drift. Read in lockstep with
|
|
323
|
+
# cmd_score_plan.
|
|
324
|
+
while IFS="$(printf '\t')" read -r jid jwarn jdrift; do
|
|
325
|
+
[ -n "$jid" ] || continue
|
|
326
|
+
if [ "${FORGE_JEV_SHADOW:-}" != on ]; then
|
|
327
|
+
case "$jwarn" in
|
|
328
|
+
*prompt_adequacy*) note "jev: $jid — the prompt may be too vague for QA to judge correctness against" ;;
|
|
329
|
+
esac
|
|
330
|
+
fi
|
|
331
|
+
if [ -n "$jdrift" ] && [ "$jdrift" != "-" ]; then
|
|
332
|
+
# The drift field only names files score-plan ADDED (drift `on`): a shadowed gate
|
|
333
|
+
# prints '-', so there is no "may edit undeclared files" case left to hint at.
|
|
334
|
+
note "drift added to $jid: $jdrift"
|
|
335
|
+
fi
|
|
336
|
+
done <<EOF
|
|
309
337
|
$jev_scores
|
|
310
338
|
EOF
|
|
339
|
+
if [ "${FORGE_JEV_SHADOW:-}" = on ]; then
|
|
340
|
+
note "jev: scored $(printf '%s\n' "$jev_scores" | grep -c .) task(s) in shadow mode (no change)"
|
|
311
341
|
fi
|
|
312
342
|
fi
|
|
313
343
|
fi
|
|
314
344
|
|
|
345
|
+
# Coverage: does some task's acceptance criteria deliver each requirement of request.md?
|
|
346
|
+
# `on` marks the ones no task covers pending in plan-gates.json; the send-back file below
|
|
347
|
+
# says which, so nothing is printed here.
|
|
348
|
+
if [ "$jev_loaded" = 1 ] && forge_decide_active coverage; then
|
|
349
|
+
python3 "$SKILL_DIR/scripts/forge-jev.py" coverage --plan "$PLAN" --repo "$REPO" >/dev/null 2>&1 || true
|
|
350
|
+
fi
|
|
351
|
+
|
|
352
|
+
# The one send-back step of this call, after every pre-resolve gate: prompt and coverage
|
|
353
|
+
# mark what to rewrite, and exit 4 hands it back before validation, waves and the table.
|
|
354
|
+
# An item is sent back once; the re-plan lists what is still wrong under the table.
|
|
355
|
+
if [ "$jev_loaded" = 1 ] && { forge_decide_active prompt || forge_decide_active coverage; }; then
|
|
356
|
+
local sendback_out sendback_rc=0 sendback_n
|
|
357
|
+
sendback_out="$(python3 "$SKILL_DIR/scripts/forge-plan-check.py" sendback "$PLAN" 2>/dev/null)" || sendback_rc=$?
|
|
358
|
+
if [ "$sendback_rc" -eq 4 ]; then
|
|
359
|
+
printf '%s\n' "$sendback_out"
|
|
360
|
+
sendback_n="$(printf '%s\n' "$sendback_out" | grep -c '^- ')"
|
|
361
|
+
note "plan gates sent $sendback_n item(s) back: rewrite them as $PLAN/plan.sendback.md says, then run plan again (once)"
|
|
362
|
+
return 4
|
|
363
|
+
fi
|
|
364
|
+
fi
|
|
365
|
+
|
|
315
366
|
# --- validate + resolve routing ---
|
|
316
367
|
local tmp="$PLAN/.tasks.tsv.new"; : > "$tmp"
|
|
317
368
|
local hi_i=0 md_i=0 lo_i=0 an_i=0 qhi_i=0 qmd_i=0 qlo_i=0 qan_i=0 unassigned=0
|
|
@@ -380,50 +431,53 @@ EOF
|
|
|
380
431
|
|
|
381
432
|
compute_waves "$PLAN"
|
|
382
433
|
|
|
383
|
-
# ---
|
|
384
|
-
#
|
|
385
|
-
#
|
|
386
|
-
#
|
|
387
|
-
#
|
|
388
|
-
if [ "$
|
|
389
|
-
python3 "$SKILL_DIR/scripts/forge-jev.py" first-pass --plan "$PLAN" --repo "$REPO" >/dev/null 2>&1 || true
|
|
390
|
-
fi
|
|
391
|
-
|
|
392
|
-
# --- jev: advisory wave coupling ------------------------------------------------
|
|
393
|
-
# Disjoint files bound parallelism structurally, but they cannot see the conflict
|
|
394
|
-
# where one task in a wave changes an interface another task in the SAME wave
|
|
395
|
-
# consumes -- both diffs are clean against their own baseline, and the merge is
|
|
396
|
-
# broken. This is advisory only: it never edits tasks.tsv, never adds a dep, and
|
|
397
|
-
# never changes waves.tsv, so it must run after compute_waves and before the table
|
|
398
|
-
# that reports the plan is printed.
|
|
399
|
-
if [ "$jev_loaded" = 1 ] && forge_jev_active gates; then
|
|
434
|
+
# --- jev: forward dependency ----------------------------------------------------
|
|
435
|
+
# Wave order is structural, but it cannot see an earlier-wave task written against
|
|
436
|
+
# an interface a later-wave task builds. Forward `on` adds that dep to tasks.tsv (inside
|
|
437
|
+
# `coupling`, refusing a cycle), so the waves are computed again below when it did;
|
|
438
|
+
# otherwise the gate only advises. It runs after compute_waves and before the table.
|
|
439
|
+
if [ "$jev_loaded" = 1 ] && forge_decide_active forward; then
|
|
400
440
|
local jev_coupling jev_coupling_rc
|
|
401
441
|
jev_coupling="$(python3 "$SKILL_DIR/scripts/forge-jev.py" coupling \
|
|
402
442
|
--plan "$PLAN" --repo "$REPO" 2>/dev/null)"
|
|
403
443
|
jev_coupling_rc=$?
|
|
444
|
+
# A shadowed forward gate is recorded in jev-coupling.json and prints no row; --jev-shadow
|
|
445
|
+
# before migration counts the advisory rows, as it always did. Rows an `on` gate acted
|
|
446
|
+
# on (`added`, `cycle`) are said and acted on whatever the flag.
|
|
404
447
|
if [ "$jev_coupling_rc" -eq 0 ] && [ -n "$jev_coupling" ]; then
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
note "
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
448
|
+
local ca cb cp ckind dep_added=0 advisory=0
|
|
449
|
+
while IFS="$(printf '\t')" read -r ca cb cp ckind; do
|
|
450
|
+
[ -n "$ca" ] || continue
|
|
451
|
+
# An earlier task written against work that has not been built yet, which its own
|
|
452
|
+
# review cannot catch. The last column says what `on` did about it.
|
|
453
|
+
case "$ckind" in
|
|
454
|
+
added)
|
|
455
|
+
dep_added=1
|
|
456
|
+
note "forward: task '$ca' now waits for '$cb' ($cp) — it may depend on what '$cb' builds" ;;
|
|
457
|
+
cycle)
|
|
458
|
+
note "forward: '$ca' may depend on '$cb' ($cp), but that dependency would form a cycle — not added" ;;
|
|
459
|
+
*)
|
|
460
|
+
advisory=$((advisory+1))
|
|
461
|
+
[ "${FORGE_JEV_SHADOW:-}" = on ] ||
|
|
462
|
+
note "jev: task '$ca' runs before '$cb' and may depend on what it builds ($cp) — consider a dep" ;;
|
|
463
|
+
esac
|
|
464
|
+
done <<EOF
|
|
420
465
|
$jev_coupling
|
|
421
466
|
EOF
|
|
467
|
+
if [ "$advisory" -gt 0 ] && [ "${FORGE_JEV_SHADOW:-}" = on ]; then
|
|
468
|
+
note "jev: found $advisory coupled pair(s) in shadow mode (no change)"
|
|
422
469
|
fi
|
|
470
|
+
if [ "$dep_added" = 1 ]; then compute_waves "$PLAN"; fi
|
|
423
471
|
fi
|
|
424
472
|
fi
|
|
425
473
|
|
|
426
474
|
render_table "$PLAN"
|
|
475
|
+
# What the gates did, from plan-gates.json: files and deps they added, prompts and
|
|
476
|
+
# requirements still flagged. Prints nothing when no gate recorded anything.
|
|
477
|
+
python3 "$SKILL_DIR/scripts/forge-plan-check.py" gates "$PLAN" 2>/dev/null || true
|
|
478
|
+
# Advisory, under the table: a privacy floor that silences every gate, and which
|
|
479
|
+
# gates this plan's runs will ask. Prints nothing when it cannot tell.
|
|
480
|
+
[ "$jev_loaded" = 1 ] && forge_decide_plan_lines "${FORGE_DECIDE_REPO:-$REPO}"
|
|
427
481
|
# Before the UNASSIGNED return, so the URL prints under the table either way.
|
|
428
482
|
forge_ui_launch "$PLAN"
|
|
429
483
|
|
|
@@ -505,9 +559,34 @@ render_table() {
|
|
|
505
559
|
echo "fail-first: on, but $(cat "$PLAN/repo")/.forge/verify-subset (a test command with {files}) is missing, so nothing will run"
|
|
506
560
|
fi
|
|
507
561
|
fi
|
|
562
|
+
if [ -f "$PLAN/pre_review_tests" ]; then
|
|
563
|
+
if [ -s "$(cat "$PLAN/repo")/.forge/verify-subset" ]; then
|
|
564
|
+
echo "pre-review tests: on — each attempt's affected tests run before its review; a red attempt goes back to its implementer unreviewed"
|
|
565
|
+
else
|
|
566
|
+
echo "pre-review tests: on, but $(cat "$PLAN/repo")/.forge/verify-subset (a test command with {files} or {changed}) is missing, so nothing will run"
|
|
567
|
+
fi
|
|
568
|
+
fi
|
|
508
569
|
if [ -f "$PLAN/reviewer_session" ]; then
|
|
509
570
|
echo "reviewer-session: a later review round continues the reviewer's earlier session when its QA spec is unchanged (experiment; falls back to a fresh session)"
|
|
510
571
|
fi
|
|
572
|
+
if [ -f "$PLAN/implementer_session" ]; then
|
|
573
|
+
echo "implementer-session: a retry continues the implementer's earlier session when its spec is unchanged and its work is as the review left it (claude, openclaude; falls back to a fresh session)"
|
|
574
|
+
fi
|
|
575
|
+
# The plan-level threshold: at plan time no per-task file exists yet.
|
|
576
|
+
local qa_level qa_src
|
|
577
|
+
read -r qa_level qa_src <<EOF
|
|
578
|
+
$(qa_threshold_walk "$PLAN" "")
|
|
579
|
+
EOF
|
|
580
|
+
case "$qa_level" in
|
|
581
|
+
P3) echo "QA threshold: P3 ($qa_src) — every CONFIRMED finding blocks" ;;
|
|
582
|
+
P0) echo "QA threshold: P0 ($qa_src) — P0 blocks; a CONFIRMED P1–P3 is recorded as a known issue" ;;
|
|
583
|
+
P1) echo "QA threshold: P1 ($qa_src) — P0–P1 block; a CONFIRMED P2–P3 is recorded as a known issue" ;;
|
|
584
|
+
*) echo "QA threshold: P2 ($qa_src) — P0–P2 block; a CONFIRMED P3 is recorded as a known issue" ;;
|
|
585
|
+
esac
|
|
586
|
+
# A reviewer spec that names no effort reviews at forge-dispatch.sh's QA default (#89).
|
|
587
|
+
if awk -F'\t' '$0 !~ /^#/ && NF >= 6 { split($6, s, ":"); if (s[2] == "") found = 1 } END { exit !found }' "$T"; then
|
|
588
|
+
echo "QA effort: high where a reviewer spec names none (forge-dispatch.sh's default; planning stays at xhigh)"
|
|
589
|
+
fi
|
|
511
590
|
echo
|
|
512
591
|
local w id dws starred=0
|
|
513
592
|
for w in $(awk -F'\t' '{print $1}' "$W" | sort -un); do
|
|
@@ -655,6 +734,16 @@ write_capsule() { # write_capsule <plan> <id> <role>
|
|
|
655
734
|
echo "- MERGED means present in this task's pinned baseline; later merges are not included."
|
|
656
735
|
echo "- The review diff is only this task's work against that baseline."
|
|
657
736
|
echo "- Implementation must respect other tasks' ownership; report necessary scope changes."
|
|
737
|
+
if [ -s "$PLAN/tasks/$me/submodules.txt" ]; then
|
|
738
|
+
local sm_st sm_path
|
|
739
|
+
while IFS="$(printf '\t')" read -r sm_st sm_path _; do
|
|
740
|
+
if [ "$sm_st" = missing ]; then
|
|
741
|
+
echo "- Submodule \`$sm_path\` is not available in this worktree (its directory is empty)."
|
|
742
|
+
else
|
|
743
|
+
echo "- \`$sm_path\` is a submodule: its files are here to read and build with. Changes there are not part of your change and are never committed or reviewed."
|
|
744
|
+
fi
|
|
745
|
+
done < "$PLAN/tasks/$me/submodules.txt"
|
|
746
|
+
fi
|
|
658
747
|
|
|
659
748
|
} > "$out"
|
|
660
749
|
echo "$out"
|
|
@@ -695,11 +784,29 @@ worktree_setup_command() { # worktree_setup_command <plan> <repo>
|
|
|
695
784
|
return 0
|
|
696
785
|
}
|
|
697
786
|
|
|
787
|
+
# Exports each submodule's files into a fresh worktree (offline, no `.git`, so they stay
|
|
788
|
+
# invisible to every diff and fingerprint). Never fatal: a failure leaves the directory empty.
|
|
789
|
+
populate_submodules() { # populate_submodules <repo> <wt> <tdir> <id>
|
|
790
|
+
local repo="$1" wt="$2" tdir="$3" id="$4" st path _sha detail err
|
|
791
|
+
rm -f "$tdir/submodules.txt"
|
|
792
|
+
err="$(python3 "$SKILL_DIR/scripts/forge-submodules.py" populate --source "$repo" --worktree "$wt" \
|
|
793
|
+
--out "$tdir/submodules.txt" 2>&1 >/dev/null)" \
|
|
794
|
+
|| note "$id: submodule population failed (continuing): $(printf '%s' "$err" | tail -1)"
|
|
795
|
+
[ -s "$tdir/submodules.txt" ] || return 0
|
|
796
|
+
while IFS="$(printf '\t')" read -r st path _sha detail; do
|
|
797
|
+
[ "$st" = missing ] && note "$id: submodule $path is not available in this worktree ($detail)"
|
|
798
|
+
done < "$tdir/submodules.txt"
|
|
799
|
+
return 0
|
|
800
|
+
}
|
|
801
|
+
|
|
698
802
|
# Non-fatal by design. A setup step that fails leaves a worktree the dwarf can still
|
|
699
803
|
# work in — it just has to install things itself, which is the status quo this exists
|
|
700
804
|
# to improve on. Failing the task instead would turn a slow run into a dead one.
|
|
701
805
|
run_worktree_setup() { # run_worktree_setup <plan> <repo> <wt> <tdir> <id>
|
|
702
806
|
local PLAN="$1" REPO="$2" wt="$3" tdir="$4" id="$5" cmd
|
|
807
|
+
# Every worktree forge makes reaches here once, right after it exists, so the submodules'
|
|
808
|
+
# files are in place before `.forge/setup` runs. The outcome lands in <tdir>/submodules.txt.
|
|
809
|
+
populate_submodules "$REPO" "$wt" "$tdir" "$id"
|
|
703
810
|
cmd="$(worktree_setup_command "$PLAN" "$REPO")"
|
|
704
811
|
[ -n "$cmd" ] || return 0
|
|
705
812
|
if (cd "$wt" && eval "$cmd") >"$tdir/setup.out" 2>&1; then
|
|
@@ -790,14 +897,12 @@ do_task_body() (
|
|
|
790
897
|
if [ -z "$resume" ]; then
|
|
791
898
|
attempt=$(( attempt + 1 ))
|
|
792
899
|
echo "$attempt" > "$tdir/attempt"
|
|
793
|
-
# Silent: Clef's guess at whether this retry passes with the findings it was handed.
|
|
794
|
-
# Only a real new dwarf attempt (not a QA-only resume); recorded in clef.retry_pass.<n>
|
|
795
|
-
# and the run dataset, never read by the run, and it can never fail the task.
|
|
796
|
-
if [ "$attempt" -gt 1 ] && [ -s "$tdir/retry_findings.md" ] && [ "${FORGE_JEV:-}" != off ]; then
|
|
797
|
-
python3 "$SKILL_DIR/scripts/forge-jev.py" retry-pass --plan "$PLAN" --repo "$REPO" --task "$id" \
|
|
798
|
-
--attempt "$attempt" >/dev/null 2>&1 || true
|
|
799
|
-
fi
|
|
800
900
|
fi
|
|
901
|
+
# The gate's decision belongs to the review that made it. A review that ends before the gate
|
|
902
|
+
# (invalidated, timed out, no changes) must not leave an earlier attempt's decision for the
|
|
903
|
+
# next retry note or `accept` to read; prepare_retry has already carried it forward.
|
|
904
|
+
rm -f "$tdir/qa.gate" "$tdir/known_issues.md" "$tdir/invalidated.reason" "$tdir/prereview.failed" \
|
|
905
|
+
"$tdir/bounced" "$tdir/message.failed"
|
|
801
906
|
|
|
802
907
|
# The base is pinned per task on first creation and reused by every retry. The
|
|
803
908
|
# integration branch moves as later waves land, so re-reading the run-level
|
|
@@ -830,18 +935,73 @@ do_task_body() (
|
|
|
830
935
|
/bin/bash "$MEMORY" inject "$REPO" dwarf --task "$tdir/prompt.md" \
|
|
831
936
|
--run-dir "$tdir" > "$tdir/dwarf.memory"
|
|
832
937
|
{
|
|
833
|
-
python3 "$SKILL_DIR/scripts/forge-prompt.py" --requirements "$tdir/prompt.md" --capsule "$tdir/baseline.capsule" --approach "$tdir/approach.md" --retry "$tdir/retry_findings.md" --memory "$tdir/dwarf.memory"
|
|
938
|
+
python3 "$SKILL_DIR/scripts/forge-prompt.py" --requirements "$tdir/prompt.md" --capsule "$tdir/baseline.capsule" --approach "$tdir/approach.md" --retry "$tdir/retry_findings.md" --retry-source "$(cat "$tdir/retry_findings.source" 2>/dev/null || echo review)" --memory "$tdir/dwarf.memory"
|
|
834
939
|
[ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role dwarf 2>/dev/null
|
|
835
940
|
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."
|
|
836
941
|
echo "On retry, fix the findings in the existing work; preserve parts not criticised. Explain any finding you reject."
|
|
837
|
-
echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf
|
|
942
|
+
echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf $([ ! -f "$PLAN/pre_review_tests" ] || echo --pre-review)
|
|
838
943
|
echo; /bin/bash "$MEMORY" note dwarf
|
|
839
944
|
} > "$tdir/dwarf.input"
|
|
840
945
|
guard_before_dwarf "$wt" "$tdir"
|
|
946
|
+
# Whether this attempt continues the implementer's earlier session (plan
|
|
947
|
+
# --implementer-session, #90): only a retry of judged work that is still exactly what was
|
|
948
|
+
# judged, on the harness, model and effort that made it. Every other answer is a fresh
|
|
949
|
+
# dispatch, and nothing here can abort the attempt: a doctor that fails means fresh.
|
|
950
|
+
local is_mode=fresh is_reason="" is_id="" is_fp="" is_cont=()
|
|
951
|
+
if [ -f "$PLAN/implementer_session" ]; then
|
|
952
|
+
if [ -n "${FORGE_FRACTAL_RUN:-}" ] || forge_plan_is_fractal "$PLAN"; then
|
|
953
|
+
is_reason=fractal
|
|
954
|
+
elif [ "$attempt" = 1 ]; then
|
|
955
|
+
is_reason=first-attempt
|
|
956
|
+
elif [ ! -s "$tdir/retry_findings.md" ]; then
|
|
957
|
+
is_reason=no-findings
|
|
958
|
+
elif ! implementer_work_unchanged "$tdir" "$wt"; then
|
|
959
|
+
is_reason=work-changed
|
|
960
|
+
else
|
|
961
|
+
FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$PLAN/capabilities}" \
|
|
962
|
+
/bin/bash "$DISPATCH" doctor --spec "$dw" --role dwarf $yd > "$tdir/dwarf.doctor" 2>&1 || : > "$tdir/dwarf.doctor"
|
|
963
|
+
IFS=$'\t' read -r is_mode is_reason is_id < <(review_session_decide \
|
|
964
|
+
"$tdir/retry_findings.dwarf.session" "$tdir/retry_findings.dwarf.resolved" "$tdir/dwarf.doctor" "claude openclaude")
|
|
965
|
+
if [ "$is_mode" = continued ]; then
|
|
966
|
+
is_cont=(--continue-session "$is_id")
|
|
967
|
+
is_fp="$(forge_fingerprint "$wt")" || is_fp=""
|
|
968
|
+
fi
|
|
969
|
+
fi
|
|
970
|
+
fi
|
|
841
971
|
forge_metric_phase dispatch
|
|
842
|
-
/bin/bash "$DISPATCH" dwarf "$dw" --repo "$wt" --run-dir "$tdir" \
|
|
843
|
-
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" $yd --output "${FORGE_OUTPUT:-summary}"
|
|
972
|
+
local dwarf_cmd=(/bin/bash "$DISPATCH" dwarf "$dw" --repo "$wt" --run-dir "$tdir" \
|
|
973
|
+
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" ${yd:+"$yd"} --output "${FORGE_OUTPUT:-summary}")
|
|
974
|
+
"${dwarf_cmd[@]}" ${is_cont[@]+"${is_cont[@]}"} >"$tdir/dwarf.out" 2>&1
|
|
844
975
|
rc=$?
|
|
976
|
+
if [ "$rc" = 9 ] && [ "$is_mode" = continued ]; then
|
|
977
|
+
# The session was not continued (the harness cannot, or it failed). Why comes from the
|
|
978
|
+
# continued dispatch's record, which a fresh one clears.
|
|
979
|
+
if [ "$(sed -n 's/^reason=//p' "$tdir/dwarf.continue" 2>/dev/null | head -1)" = unsupported ]; then
|
|
980
|
+
is_reason=continue-unsupported
|
|
981
|
+
else
|
|
982
|
+
is_reason=continue-failed
|
|
983
|
+
fi
|
|
984
|
+
mv "$tdir/dwarf.out" "$tdir/dwarf.continue.out" 2>/dev/null || true
|
|
985
|
+
if [ -n "$is_fp" ] && [ "$(forge_fingerprint "$wt")" = "$is_fp" ]; then
|
|
986
|
+
# It changed nothing, so the same input goes to a fresh session, which decides the attempt.
|
|
987
|
+
is_mode=fresh
|
|
988
|
+
"${dwarf_cmd[@]}" >"$tdir/dwarf.out" 2>&1
|
|
989
|
+
rc=$?
|
|
990
|
+
else
|
|
991
|
+
# It worked on the task before it failed: that is a failed implementer, as when a fresh
|
|
992
|
+
# one fails, and running a fresh one on top would pay for the attempt twice.
|
|
993
|
+
is_mode=failed
|
|
994
|
+
cp "$tdir/dwarf.continue.out" "$tdir/dwarf.out" 2>/dev/null || true
|
|
995
|
+
rc=4
|
|
996
|
+
note "$id: the continued implementer session failed after changing files — not running a fresh one on top"
|
|
997
|
+
fi
|
|
998
|
+
fi
|
|
999
|
+
if [ -f "$PLAN/implementer_session" ]; then
|
|
1000
|
+
# One row per attempt, describing the dispatch whose result counts.
|
|
1001
|
+
local is_row=1
|
|
1002
|
+
[ ! -f "$tdir/implementer_sessions.tsv" ] || is_row=$(( $(wc -l < "$tdir/implementer_sessions.tsv") + 1 ))
|
|
1003
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$is_row" "$attempt" "$is_mode" "$is_reason" "$is_id" >> "$tdir/implementer_sessions.tsv"
|
|
1004
|
+
fi
|
|
845
1005
|
if [ "${FORGE_OUTPUT:-summary}" = full ]; then cat "$tdir/dwarf.out"; fi
|
|
846
1006
|
if [ "$rc" -ne 0 ]; then
|
|
847
1007
|
case "$rc" in
|
|
@@ -857,6 +1017,8 @@ do_task_body() (
|
|
|
857
1017
|
--duration "$(dispatch_duration "$tdir" dwarf)" >/dev/null 2>&1
|
|
858
1018
|
|
|
859
1019
|
guard_after_dwarf "$wt" "$tdir" "$id"
|
|
1020
|
+
# Before the snapshot, so a dwarf that only asked a question (and changed nothing) still reaches it.
|
|
1021
|
+
forge_post_dwarf_gates "$PLAN" "$id" "$tdir" "$wt" "$attempt" || return 0
|
|
860
1022
|
forge_metric_phase snapshot
|
|
861
1023
|
# Capture the real diff, including new files, then commit on the task branch.
|
|
862
1024
|
# Diffed against the task's pinned base rather than the branch head, so a retry
|
|
@@ -881,7 +1043,11 @@ do_task_body() (
|
|
|
881
1043
|
echo "The dwarf produced no changes at all." > "$tdir/qa.last"
|
|
882
1044
|
note "$id: dwarf produced an empty diff"; return 1
|
|
883
1045
|
fi
|
|
884
|
-
|
|
1046
|
+
# A bounced attempt (retry_findings.source `bounce`) was never reviewed, so a retry that keeps
|
|
1047
|
+
# its code is reviewed rather than refused as identical: the refusal is for a diff a review
|
|
1048
|
+
# already judged.
|
|
1049
|
+
if [ -s "$tdir/changes.prev.diff" ] && cmp -s "$tdir/changes.diff" "$tdir/changes.prev.diff" \
|
|
1050
|
+
&& [ "$(cat "$tdir/retry_findings.source" 2>/dev/null)" != bounce ]; then
|
|
885
1051
|
echo FAIL > "$tdir/status"
|
|
886
1052
|
: > "$tdir/noretry"
|
|
887
1053
|
echo "The retry changed nothing: the diff is byte-identical to the previous attempt." \
|
|
@@ -908,47 +1074,46 @@ do_task_body() (
|
|
|
908
1074
|
echo INVALIDATED > "$tdir/status"; return 1
|
|
909
1075
|
fi
|
|
910
1076
|
echo "$reviewed" > "$tdir/reviewed.commit"
|
|
1077
|
+
# The implementer session that made this commit, and what it ran as: the one a retry of
|
|
1078
|
+
# these findings may continue (plan --implementer-session; carried with the findings).
|
|
1079
|
+
rm -f "$tdir/reviewed.dwarf.session" "$tdir/reviewed.dwarf.resolved"
|
|
1080
|
+
[ ! -s "$tdir/dwarf.session" ] || cp "$tdir/dwarf.session" "$tdir/reviewed.dwarf.session"
|
|
1081
|
+
[ ! -s "$tdir/dwarf.resolved" ] || cp "$tdir/dwarf.resolved" "$tdir/reviewed.dwarf.resolved"
|
|
1082
|
+
forge_pre_qa_gates "$PLAN" "$id" "$tdir" "$wt" "$attempt" "$reviewed" || return 0
|
|
911
1083
|
else
|
|
912
1084
|
reviewed="$(cat "$tdir/reviewed.commit")"
|
|
913
1085
|
fi
|
|
914
1086
|
review="$tdir/review-$attempt-$$"
|
|
915
1087
|
forge_review_snapshot "$wt" "$base" "$reviewed" "$review" || { echo ERROR > "$tdir/status"; return 1; }
|
|
916
1088
|
source_fp="$(forge_fingerprint "$wt")" || return 1
|
|
917
|
-
|
|
1089
|
+
# The review copy is a commit: an untracked file the reviewer leaves there (a test run's
|
|
1090
|
+
# bytecode) changes nothing that merges, so only tracked content counts (#95).
|
|
1091
|
+
review_fp="$(forge_fingerprint "$review" --tracked)" || return 1
|
|
918
1092
|
echo "$source_fp" > "$tdir/source.fingerprint"
|
|
919
1093
|
echo "$review_fp" > "$tdir/review.fingerprint"
|
|
920
1094
|
|
|
921
1095
|
forge_metric_phase preparation
|
|
922
|
-
local
|
|
1096
|
+
local qa_thr rs_on=0
|
|
923
1097
|
qa_thr="$(qa_threshold_for "$PLAN" "$id")"
|
|
924
1098
|
# Read once per round, like the threshold: continuing the earlier reviewer's session is an
|
|
925
1099
|
# opt-in experiment (plan --reviewer-session), and a round never changes its mind midway.
|
|
926
1100
|
[ -f "$PLAN/reviewer_session" ] && rs_on=1
|
|
927
1101
|
|
|
928
|
-
# A SEPARATE file from .forge/verify, and opt-in. It must contain {files}, because
|
|
929
|
-
# only the project knows how its runner takes a file list -- `pytest -q {files}` works,
|
|
930
|
-
# `npm test -- {files}` needs the dashes, and `go test ./...` cannot do it at all.
|
|
931
|
-
# Absent, this whole feature stays off and nothing extra runs.
|
|
932
|
-
[ -s "$REPO/.forge/verify-subset" ] && subset_cmd="$(cat "$REPO/.forge/verify-subset")"
|
|
933
|
-
if [ -f "$SKILL_DIR/scripts/forge-jev-options.sh" ]; then
|
|
934
|
-
source "$SKILL_DIR/scripts/forge-jev-options.sh" 2>/dev/null && jev_loaded_qa=1
|
|
935
|
-
fi
|
|
936
|
-
# Early feedback for the reviewer: run the tests this change most likely broke, in a
|
|
937
|
-
# throwaway export. Requires a configured verify command -- without one there is no
|
|
938
|
-
# runner to point at a file list, and inventing one is not this feature's job.
|
|
939
|
-
if [ -n "$subset_cmd" ] && [ "$jev_loaded_qa" = 1 ] && forge_jev_active tests; then
|
|
940
|
-
git -C "$wt" diff --name-only "$(cat "$tdir/review.base")" "$reviewed" \
|
|
941
|
-
> "$tdir/changed.txt" 2>/dev/null || : > "$tdir/changed.txt"
|
|
942
|
-
python3 "$SKILL_DIR/scripts/forge-jev.py" test-subset --repo "$wt" \
|
|
943
|
-
--commit "$reviewed" --task "$tdir/prompt.md" --command "$subset_cmd" \
|
|
944
|
-
--changed "$tdir/changed.txt" --base "$(cat "$tdir/review.base")" \
|
|
945
|
-
--run-dir "$tdir" > "$tdir/subset.jev.txt" 2>/dev/null \
|
|
946
|
-
|| : > "$tdir/subset.jev.txt"
|
|
947
|
-
fi
|
|
948
1102
|
# Opt-in (plan --fail-first): do this attempt's new tests fail without its change? Read-only
|
|
949
|
-
# on the review snapshot,
|
|
1103
|
+
# on the review snapshot, so the task worktree is untouched; the reviewer gets the evidence.
|
|
950
1104
|
rm -f "$tdir/failfirst.json" "$tdir/failfirst.txt"
|
|
951
1105
|
[ ! -f "$PLAN/fail_first" ] || forge_fail_first "$review" "$tdir" "$REPO"
|
|
1106
|
+
# Opt-in (plan --pre-review-tests, #85): the tests this attempt affects, before paying for a
|
|
1107
|
+
# review. Red: the attempt fails unreviewed and its findings are the test output. A QA-only
|
|
1108
|
+
# resume re-reviews work that already passed this check, and keeps its evidence.
|
|
1109
|
+
[ -f "$PLAN/pre_review_tests" ] || rm -f "$tdir/prereview.json" "$tdir/prereview.txt" "$tdir/prereview.md"
|
|
1110
|
+
if [ -f "$PLAN/pre_review_tests" ] && [ -z "$resume" ] && ! forge_pre_review "$review" "$tdir" "$REPO" "$PLAN"; then
|
|
1111
|
+
: > "$tdir/prereview.failed"
|
|
1112
|
+
rm -f "$tdir/qa.last" # an earlier attempt's review describes other code
|
|
1113
|
+
echo FAIL > "$tdir/status"
|
|
1114
|
+
note "$id: the tests this attempt affects fail — sent back to the implementer without a review (see $tdir/prereview.md)"
|
|
1115
|
+
return 0
|
|
1116
|
+
fi
|
|
952
1117
|
# What changed since the review whose findings this reviewer is handed. Fractal keeps
|
|
953
1118
|
# today's prompt unless it retries, as changes.prev.diff does. dwarf.last is the reply of
|
|
954
1119
|
# the attempt under review: a dwarf run just rewrote it, or $resume (the validated QA-only
|
|
@@ -974,22 +1139,12 @@ do_task_body() (
|
|
|
974
1139
|
/bin/bash "$MEMORY" inject "$REPO" qa --task "$tdir/prompt.md" \
|
|
975
1140
|
--run-dir "$tdir" > "$tdir/qa.memory"
|
|
976
1141
|
{
|
|
977
|
-
python3 "$SKILL_DIR/scripts/forge-prompt.py" --requirements "$tdir/prompt.md" --capsule "$tdir/baseline.capsule" --approach "$tdir/approach.md" --retry "$tdir/retry_findings.md" ${prompt_extra[@]+"${prompt_extra[@]}"} --memory "$tdir/dwarf.memory" --memory "$tdir/qa.memory"
|
|
1142
|
+
python3 "$SKILL_DIR/scripts/forge-prompt.py" --requirements "$tdir/prompt.md" --capsule "$tdir/baseline.capsule" --approach "$tdir/approach.md" --retry "$tdir/retry_findings.md" --retry-source "$(cat "$tdir/retry_findings.source" 2>/dev/null || echo review)" ${prompt_extra[@]+"${prompt_extra[@]}"} --memory "$tdir/dwarf.memory" --memory "$tdir/qa.memory"
|
|
978
1143
|
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part head --kind "$qa_kind"
|
|
979
1144
|
echo
|
|
980
1145
|
[ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role qa 2>/dev/null
|
|
981
1146
|
if [ -s "$tdir/failfirst.txt" ]; then cat "$tdir/failfirst.txt"; echo; fi
|
|
982
|
-
|
|
983
|
-
# from the diff. It runs in a throwaway export of the reviewed commit, so the task
|
|
984
|
-
# worktree is untouched and no fingerprint can change. It never replaces
|
|
985
|
-
# verification -- the full suite still runs at integration exactly as before.
|
|
986
|
-
if [ -s "$tdir/subset.jev.txt" ]; then
|
|
987
|
-
cat "$tdir/subset.jev.txt"
|
|
988
|
-
echo
|
|
989
|
-
echo "That is a subset chosen by relevance, not the full suite, so a pass would"
|
|
990
|
-
echo "prove nothing and is not reported. A failure here is real."
|
|
991
|
-
echo
|
|
992
|
-
fi
|
|
1147
|
+
if [ -s "$tdir/prereview.txt" ]; then cat "$tdir/prereview.txt"; echo; fi
|
|
993
1148
|
if [ -s "$tdir/guard.txt" ]; then
|
|
994
1149
|
# Facts forge observed about how the implementer worked. On a first attempt the reviewer
|
|
995
1150
|
# never sees the implementer's own report (a retry's reviewer gets the reply, to check
|
|
@@ -1009,7 +1164,7 @@ do_task_body() (
|
|
|
1009
1164
|
echo "matters because another task may own those files."
|
|
1010
1165
|
echo
|
|
1011
1166
|
fi
|
|
1012
|
-
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind "$qa_kind"
|
|
1167
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind "$qa_kind" --threshold "$qa_thr"
|
|
1013
1168
|
echo
|
|
1014
1169
|
# --irreversible-delete: a deleted file shows as a header, not every line it had (one deleted
|
|
1015
1170
|
# data directory once made a 7.1M-character prompt that the reviewer's CLI refused).
|
|
@@ -1086,7 +1241,10 @@ do_task_body() (
|
|
|
1086
1241
|
rm -f "$tdir/resume"
|
|
1087
1242
|
|
|
1088
1243
|
forge_metric_phase verification
|
|
1089
|
-
if [ "$(forge_fingerprint "$wt")" != "$source_fp" ] || [ "$(forge_fingerprint "$review")" != "$review_fp" ]; then
|
|
1244
|
+
if [ "$(forge_fingerprint "$wt")" != "$source_fp" ] || [ "$(forge_fingerprint "$review" --tracked)" != "$review_fp" ]; then
|
|
1245
|
+
# The committed work is untouched, so --retry-failed may review it again (reason `review`);
|
|
1246
|
+
# the merge-time invalidations below leave no reason and wait for a human.
|
|
1247
|
+
echo review > "$tdir/invalidated.reason"
|
|
1090
1248
|
echo INVALIDATED > "$tdir/status"; note "$id: artifact changed during review"; return 1
|
|
1091
1249
|
fi
|
|
1092
1250
|
local verdict
|
|
@@ -1103,43 +1261,11 @@ do_task_body() (
|
|
|
1103
1261
|
# pass would merge unreviewed code, so it is fail-safe by construction.
|
|
1104
1262
|
*) echo UNKNOWN > "$tdir/status" ;;
|
|
1105
1263
|
esac
|
|
1106
|
-
#
|
|
1107
|
-
# accepted PASS-with-known-issues
|
|
1108
|
-
# prompt was built with, so the prompt and the gate of
|
|
1264
|
+
# The gate at the effective threshold: a FAIL made only of tolerated findings becomes an
|
|
1265
|
+
# accepted PASS-with-known-issues, a PASS that lists a blocking CONFIRMED finding becomes
|
|
1266
|
+
# FAIL. qa_thr is the value the review prompt was built with, so the prompt and the gate of
|
|
1267
|
+
# one attempt agree. Before record_attempt, so attempts.tsv shows the gated status.
|
|
1109
1268
|
qa_gate "$PLAN" "$id" "$tdir" "$verdict" "$qa_thr"
|
|
1110
|
-
|
|
1111
|
-
# Annotate a FAIL that looks unsound. Note what this does NOT do: the status file is
|
|
1112
|
-
# already written above and nothing below rewrites it. A model that could talk a
|
|
1113
|
-
# reviewer out of a FAIL would produce confident PASSes on code nobody checked, which
|
|
1114
|
-
# is worth less than having no reviewer at all. Only a human acts on this line.
|
|
1115
|
-
if [ "$verdict" = FAIL ] && [ "$(cat "$tdir/status")" = FAIL ]; then
|
|
1116
|
-
# do_task is a subshell and does not inherit do_plan's copy, so source it here.
|
|
1117
|
-
# A missing or broken options file leaves jev_loaded=0 and this block does nothing.
|
|
1118
|
-
local jev_loaded=0 jev_rc
|
|
1119
|
-
if [ -f "$SKILL_DIR/scripts/forge-jev-options.sh" ]; then
|
|
1120
|
-
source "$SKILL_DIR/scripts/forge-jev-options.sh" 2>/dev/null && jev_loaded=1
|
|
1121
|
-
fi
|
|
1122
|
-
if [ "$jev_loaded" = 1 ] && forge_jev_active gates; then
|
|
1123
|
-
# One request, not two: asking the same question twice costs twice and can come
|
|
1124
|
-
# back with two different answers, and the record must match what was printed.
|
|
1125
|
-
python3 "$SKILL_DIR/scripts/forge-jev.py" review-triage --review "$tdir/qa.last" \
|
|
1126
|
-
--diff "$tdir/changes.diff" --run-dir "$tdir" --json > "$tdir/qa.jev.json" 2>/dev/null
|
|
1127
|
-
jev_rc=$?
|
|
1128
|
-
if [ "$jev_rc" -eq 0 ]; then
|
|
1129
|
-
note "$id: FAIL stands, but jev flags the review — $(python3 -c '
|
|
1130
|
-
import json, sys
|
|
1131
|
-
try:
|
|
1132
|
-
data = json.load(open(sys.argv[1]))
|
|
1133
|
-
except Exception:
|
|
1134
|
-
sys.exit(0)
|
|
1135
|
-
print("; ".join(data.get("reasons") or []))
|
|
1136
|
-
' "$tdir/qa.jev.json" 2>/dev/null)"
|
|
1137
|
-
else
|
|
1138
|
-
# Exit 1 means the review looked sound; there is nothing to say and no file to keep.
|
|
1139
|
-
rm -f "$tdir/qa.jev.json" 2>/dev/null || true
|
|
1140
|
-
fi
|
|
1141
|
-
fi
|
|
1142
|
-
fi
|
|
1143
1269
|
return 0
|
|
1144
1270
|
)
|
|
1145
1271
|
|
|
@@ -1204,17 +1330,86 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
|
|
|
1204
1330
|
}
|
|
1205
1331
|
|
|
1206
1332
|
# --- retry --------------------------------------------------------------------
|
|
1333
|
+
# The answer arguments of `retry`, found by walking the option list as do_retry's own loop does,
|
|
1334
|
+
# so the value of another option (--setup '--answer') is never mistaken for one. Run it in a
|
|
1335
|
+
# subshell with a scratch directory as the plan: the shared option parsers write into it, not
|
|
1336
|
+
# into the real plan. Leaves n (how many answer flags), flag, val and novalue in the scratch dir.
|
|
1337
|
+
_retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
1338
|
+
local sd="$1"; shift
|
|
1339
|
+
local n=0 flag="" val="" novalue=0 rc=0
|
|
1340
|
+
while [ $# -gt 0 ]; do
|
|
1341
|
+
case "$1" in
|
|
1342
|
+
--no-ripwire|--yolo-dwarf|--yolo-qa) shift ;;
|
|
1343
|
+
--output|--dwarf|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
|
|
1344
|
+
--answer|--answer-file)
|
|
1345
|
+
n=$((n + 1)); flag="$1"
|
|
1346
|
+
if [ $# -ge 2 ]; then val="$2"; shift 2; else novalue=1; shift; fi ;;
|
|
1347
|
+
*)
|
|
1348
|
+
if forge_pp_flag retry "$sd" "$@"; then shift "$PP_SHIFT"; continue; fi
|
|
1349
|
+
if [ "${JEV_OPTS:-0}" = 1 ]; then
|
|
1350
|
+
forge_jev_flag "$@"; rc=$?
|
|
1351
|
+
case "$rc" in
|
|
1352
|
+
0) shift "$JEV_SHIFT"; continue ;;
|
|
1353
|
+
2) exit 2 ;;
|
|
1354
|
+
esac
|
|
1355
|
+
fi
|
|
1356
|
+
break ;;
|
|
1357
|
+
esac
|
|
1358
|
+
done
|
|
1359
|
+
printf '%s' "$n" > "$sd/n"; printf '%s' "$flag" > "$sd/flag"; printf '%s' "$val" > "$sd/val"
|
|
1360
|
+
[ "$novalue" = 0 ] || : > "$sd/novalue"
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1207
1363
|
# A failed task keeps its branch and worktree "so there is something to inspect and
|
|
1208
1364
|
# retry from" — this is the retry. It is a command a human types, not an automatic
|
|
1209
1365
|
# repair loop, which is what keeps forge's one-dwarf-then-QA rule intact.
|
|
1210
1366
|
do_retry() {
|
|
1211
1367
|
local PLAN="${1:?retry needs a plan dir}" id="${2:?retry needs a task id}"; shift 2
|
|
1212
|
-
|
|
1368
|
+
FORGE_RUN_STARTED="$(forge_now)"
|
|
1369
|
+
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0
|
|
1370
|
+
# An answer is validated before any option below writes into the plan: a rejected answer
|
|
1371
|
+
# changes nothing, --setup and --verify included. Only a NEEDS_INPUT task takes one. The
|
|
1372
|
+
# arguments are walked the way the loop below walks them (a value is never taken for a flag),
|
|
1373
|
+
# in a subshell against a scratch plan dir, so nothing real is written by the walk.
|
|
1374
|
+
local pre_dir="$PLAN/.answer-scan.$$" pre_n=0 pre_have="" pre_val="" pre_novalue=0 pre_ok=0
|
|
1375
|
+
rm -rf "$pre_dir"
|
|
1376
|
+
if mkdir "$pre_dir" 2>/dev/null; then
|
|
1377
|
+
if ( _retry_answer_scan "$pre_dir" "$@" ) >/dev/null 2>&1; then
|
|
1378
|
+
pre_ok=1
|
|
1379
|
+
pre_n="$(<"$pre_dir/n")"; pre_have="$(<"$pre_dir/flag")"; pre_val="$(<"$pre_dir/val")"
|
|
1380
|
+
[ ! -f "$pre_dir/novalue" ] || pre_novalue=1
|
|
1381
|
+
# `$(<f)` drops trailing newlines, so an answer of only newlines needs the size check.
|
|
1382
|
+
[ -s "$pre_dir/val" ] || pre_val=""
|
|
1383
|
+
fi
|
|
1384
|
+
rm -rf "$pre_dir"
|
|
1385
|
+
else
|
|
1386
|
+
die "retry: cannot write to the plan dir $PLAN"
|
|
1387
|
+
fi
|
|
1388
|
+
if [ "$pre_ok" = 1 ] && [ "$pre_n" != 0 ]; then
|
|
1389
|
+
[ "$pre_n" = 1 ] || die "retry: give --answer or --answer-file once"
|
|
1390
|
+
[ "$pre_novalue" = 0 ] || die "retry: $pre_have needs a value"
|
|
1391
|
+
[ -s "$PLAN/tasks.tsv" ] && all_ids "$PLAN/tasks.tsv" | grep -qx "$id" || die "no task '$id' in this plan"
|
|
1392
|
+
local pre_st; pre_st="$(task_status "$PLAN" "$id")"
|
|
1393
|
+
[ "$pre_st" = NEEDS_INPUT ] || die "retry: '$id' is $pre_st, not waiting for an answer; --answer and --answer-file only answer a NEEDS_INPUT task"
|
|
1394
|
+
if [ "$pre_have" = --answer-file ]; then
|
|
1395
|
+
[ -f "$pre_val" ] && [ -r "$pre_val" ] || die "retry: --answer-file '$pre_val' is not a readable file"
|
|
1396
|
+
[ -s "$pre_val" ] || die "retry: --answer-file '$pre_val' is empty"
|
|
1397
|
+
else
|
|
1398
|
+
[ -n "$pre_val" ] || die "retry: the answer is empty"
|
|
1399
|
+
fi
|
|
1400
|
+
fi
|
|
1213
1401
|
while [ $# -gt 0 ]; do
|
|
1214
1402
|
case "$1" in
|
|
1215
1403
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
1216
1404
|
--output) OUTPUT="${2:?}"; shift 2 ;;
|
|
1217
1405
|
--dwarf) NEWDWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
|
|
1406
|
+
# The check above refuses an empty answer first; these hold when its walk could not run.
|
|
1407
|
+
--answer) [ "$HAVE_ANSWER" = 0 ] || die "retry: give --answer or --answer-file once"
|
|
1408
|
+
ANSWER="${2?--answer needs the answer text}"; HAVE_ANSWER=1; shift 2
|
|
1409
|
+
[ -n "$ANSWER" ] || die "retry: the answer is empty" ;;
|
|
1410
|
+
--answer-file) [ "$HAVE_ANSWER" = 0 ] || die "retry: give --answer or --answer-file once"
|
|
1411
|
+
ANSWER_FILE="${2:?--answer-file needs a file}"; HAVE_ANSWER=2; shift 2
|
|
1412
|
+
[ -s "$ANSWER_FILE" ] || die "retry: --answer-file '$ANSWER_FILE' is empty or missing" ;;
|
|
1218
1413
|
--yolo-dwarf) touch "$PLAN/yolo_dwarf"; shift ;;
|
|
1219
1414
|
--yolo-qa) touch "$PLAN/yolo_qa"; shift ;;
|
|
1220
1415
|
--verify) printf '%s' "${2:?--verify needs a command}" > "$PLAN/verify_cmd"; rm -rf "$PLAN/verify.d"; PP_LANES_FRESH=0; shift 2 ;;
|
|
@@ -1223,7 +1418,7 @@ do_retry() {
|
|
|
1223
1418
|
# `case` is not a loop, so `continue` here belongs to the enclosing while.
|
|
1224
1419
|
if forge_pp_flag retry "$PLAN" "$@"; then shift "$PP_SHIFT"; continue; fi
|
|
1225
1420
|
if [ "$JEV_OPTS" = 1 ]; then
|
|
1226
|
-
forge_jev_flag "
|
|
1421
|
+
forge_jev_flag "$@"; jev_rc=$?
|
|
1227
1422
|
case "$jev_rc" in
|
|
1228
1423
|
0) shift "$JEV_SHIFT"; continue ;;
|
|
1229
1424
|
2) exit 2 ;;
|
|
@@ -1234,6 +1429,8 @@ do_retry() {
|
|
|
1234
1429
|
esac
|
|
1235
1430
|
done
|
|
1236
1431
|
[ "$JEV_OPTS" = 1 ] && forge_jev_settle "$PLAN"
|
|
1432
|
+
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
1433
|
+
[ "$JEV_OPTS" = 1 ] && [ -s "$PLAN/repo" ] && forge_decide_env "$(cat "$PLAN/repo")" "$PLAN"
|
|
1237
1434
|
case "$OUTPUT" in summary|full) ;; *) die "--output must be summary or full" ;; esac
|
|
1238
1435
|
export FORGE_OUTPUT="$OUTPUT"
|
|
1239
1436
|
local T="$PLAN/tasks.tsv" tdir="$PLAN/tasks/$id"
|
|
@@ -1242,6 +1439,18 @@ do_retry() {
|
|
|
1242
1439
|
[ -s "$PLAN/wt_root" ] || die "this plan has never been run — use 'run', not 'retry'"
|
|
1243
1440
|
local st; st="$(task_status "$PLAN" "$id")"
|
|
1244
1441
|
[ "$st" = "MERGED" ] && die "task '$id' already merged — nothing to retry"
|
|
1442
|
+
[ "$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"
|
|
1443
|
+
# The user's answer to a NEEDS_INPUT task's question (validated above): written before
|
|
1444
|
+
# anything else is prepared, atomically, and kept when the preparation then refuses (the
|
|
1445
|
+
# same answer can be retried).
|
|
1446
|
+
if [ "$HAVE_ANSWER" != 0 ]; then
|
|
1447
|
+
if [ "$HAVE_ANSWER" = 2 ]; then
|
|
1448
|
+
cp "$ANSWER_FILE" "$tdir/.answer.md.tmp" || { rm -f "$tdir/.answer.md.tmp"; die "retry: could not write the answer" 1; }
|
|
1449
|
+
else
|
|
1450
|
+
printf '%s\n' "$ANSWER" > "$tdir/.answer.md.tmp" || { rm -f "$tdir/.answer.md.tmp"; die "retry: could not write the answer" 1; }
|
|
1451
|
+
fi
|
|
1452
|
+
mv "$tdir/.answer.md.tmp" "$tdir/answer.md" || die "retry: could not write the answer" 1
|
|
1453
|
+
fi
|
|
1245
1454
|
|
|
1246
1455
|
# Findings carry-forward, the optional --dwarf escalation and the QA-only resume
|
|
1247
1456
|
# decision are shared with the scheduler's automatic retries.
|
|
@@ -1288,42 +1497,11 @@ do_retry() {
|
|
|
1288
1497
|
echo
|
|
1289
1498
|
printf ' %-14s %-9s %s\n' id status branch
|
|
1290
1499
|
awk -F'\t' '{printf " %-14s %-9s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
|
|
1291
|
-
forge_jev_review_flags "$PLAN"
|
|
1292
1500
|
run_report_extras "$PLAN"
|
|
1293
1501
|
[ "$(task_status "$PLAN" "$id")" = "MERGED" ] || return 5
|
|
1294
1502
|
return 0
|
|
1295
1503
|
}
|
|
1296
1504
|
|
|
1297
|
-
# Print any Jev review-triage flags under the results table.
|
|
1298
|
-
#
|
|
1299
|
-
# do_task's notes go to tasks/<id>/task.out, which the scheduler only echoes when
|
|
1300
|
-
# FORGE_OUTPUT=full -- the right call for parallel dispatch, where interleaved output is
|
|
1301
|
-
# unreadable. But it meant this particular note was written where nobody would read it,
|
|
1302
|
-
# and it is the only signal that a FAIL may not be sound. A human has to see it to act
|
|
1303
|
-
# on it, and the default output mode is `summary`.
|
|
1304
|
-
#
|
|
1305
|
-
# qa.jev.json exists only when the review was flagged: review-triage deletes it when the
|
|
1306
|
-
# review looks sound, so its presence is the signal and no new file is needed.
|
|
1307
|
-
forge_jev_review_flags() {
|
|
1308
|
-
local plan="$1" id notice printed=0
|
|
1309
|
-
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
1310
|
-
[ -s "$plan/tasks/$id/qa.jev.json" ] || continue
|
|
1311
|
-
notice="$(python3 -c '
|
|
1312
|
-
import json, sys
|
|
1313
|
-
try:
|
|
1314
|
-
data = json.load(open(sys.argv[1]))
|
|
1315
|
-
except Exception:
|
|
1316
|
-
sys.exit(0)
|
|
1317
|
-
print("; ".join(data.get("reasons") or []))
|
|
1318
|
-
' "$plan/tasks/$id/qa.jev.json" 2>/dev/null)"
|
|
1319
|
-
[ -n "$notice" ] || continue
|
|
1320
|
-
[ "$printed" = 0 ] && { echo; printed=1; }
|
|
1321
|
-
printf ' jev: %s — the FAIL stands; %s\n' "$id" "$notice"
|
|
1322
|
-
done
|
|
1323
|
-
[ "$printed" = 1 ] && printf ' A flagged review is not an overturned one. Read it before retrying.\n'
|
|
1324
|
-
return 0
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
1505
|
# One row per execution of the verify command, with its own copy of the log: the
|
|
1328
1506
|
# deterministic rerun and Jev's retry both write verification.retry.log, so without this
|
|
1329
1507
|
# only the last of them would survive.
|
|
@@ -1417,12 +1595,16 @@ verify_stopped() { # verify_stopped <out>
|
|
|
1417
1595
|
verify_mark_interrupted "$1"
|
|
1418
1596
|
}
|
|
1419
1597
|
|
|
1420
|
-
verify_result() ( verify_result_body "$@" ) # plan, checkout, artifact directory
|
|
1598
|
+
verify_result() ( verify_result_body "$@" ) # plan, checkout, artifact directory[, fixed source]
|
|
1421
1599
|
|
|
1422
1600
|
# The body is a function of its own so `run` can start it as `( verify_result_body ... ) &`:
|
|
1423
1601
|
# that one subshell is the background job, the home of the signal handler above and of
|
|
1424
1602
|
# forge_metric_begin's EXIT trap.
|
|
1425
|
-
|
|
1603
|
+
# An optional fourth argument fixes the verification: "command:<file>" or "lanes:<dir>" (a
|
|
1604
|
+
# finished verification's verification.command or verification.lanes.d/). It replaces
|
|
1605
|
+
# verify_source_for and verify-discover, so a re-run judges by the predicate that verification
|
|
1606
|
+
# used, whatever the plan, the repository or discovery would say now.
|
|
1607
|
+
verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
1426
1608
|
local plan="$1" wt="$2" out="$3" cmd="" before after rc=0 repo jev_loaded=0 vretries
|
|
1427
1609
|
FORGE_VERIFY_STOP=0 FORGE_VERIFY_GROUP="" FORGE_VERIFY_TIMER="" FORGE_VERIFY_GRACE=5
|
|
1428
1610
|
[ "${FORGE_RUN_STOPPABLE:-0}" = 1 ] && trap verify_signal TERM INT
|
|
@@ -1442,23 +1624,38 @@ verify_result_body() { # plan, checkout, artifact directory
|
|
|
1442
1624
|
vretries="$(cat "$plan/verify_retries" 2>/dev/null)"
|
|
1443
1625
|
case "$vretries" in ''|*[!0-9]*) vretries=1 ;; esac
|
|
1444
1626
|
# Sourced unconditionally (cheap: local function/var definitions, no network) so
|
|
1445
|
-
#
|
|
1627
|
+
# forge_decide_active is available below. verify_result is itself a subshell, so this
|
|
1446
1628
|
# never leaks state into the caller. A missing or broken options file just leaves
|
|
1447
1629
|
# jev_loaded=0 and every Jev branch below falls through to today's behaviour.
|
|
1448
1630
|
if [ -f "$SKILL_DIR/scripts/forge-jev-options.sh" ]; then
|
|
1449
1631
|
source "$SKILL_DIR/scripts/forge-jev-options.sh" 2>/dev/null && jev_loaded=1
|
|
1450
1632
|
fi
|
|
1451
|
-
local vsource
|
|
1633
|
+
local vsource fixed="${4:-}"
|
|
1634
|
+
if [ -n "$fixed" ]; then
|
|
1635
|
+
vsource="$(verify_fixed_source "$fixed")" || { echo UNVERIFIED > "$out/verification.status"
|
|
1636
|
+
note "combined result UNVERIFIED: unusable fixed verification source: $fixed"; return 0; }
|
|
1637
|
+
# A fixed source that is missing or empty is not a reason to look elsewhere.
|
|
1638
|
+
case "$vsource" in
|
|
1639
|
+
lanes:*) verify_lanes_present "${vsource#*$'\t'}" || vsource="none" ;;
|
|
1640
|
+
*) [ -s "${vsource#*$'\t'}" ] || vsource="none" ;;
|
|
1641
|
+
esac
|
|
1642
|
+
if [ "$vsource" = none ]; then
|
|
1643
|
+
echo UNVERIFIED > "$out/verification.status"
|
|
1644
|
+
note "combined result UNVERIFIED: the fixed verification source $fixed is missing or empty"; return 0
|
|
1645
|
+
fi
|
|
1646
|
+
else
|
|
1647
|
+
vsource="$(verify_source_for "$plan" "$repo")"
|
|
1648
|
+
fi
|
|
1452
1649
|
case "$vsource" in command:*) cmd="$(cat "${vsource#*$'\t'}")" ;; esac
|
|
1650
|
+
# A lanes snapshot belongs to the verification that wrote it: a run on a command, or on
|
|
1651
|
+
# other lanes, leaves none behind (verify_lanes_run makes the new one).
|
|
1652
|
+
case "$vsource" in lanes:*) ;; *) rm -rf "$out/verification.lanes.d" ;; esac
|
|
1453
1653
|
if [ "$(forge_tree "$wt")" != "$(git -C "$wt" rev-parse HEAD^{tree})" ]; then
|
|
1454
1654
|
echo FAIL > "$out/verification.status"
|
|
1455
1655
|
note "verification checkout has source changes outside its commit"; return 1
|
|
1456
1656
|
fi
|
|
1457
1657
|
case "$vsource" in
|
|
1458
1658
|
lanes:*)
|
|
1459
|
-
if [ "$jev_loaded" = 1 ] && forge_jev_active tests; then
|
|
1460
|
-
note "jev: flake triage applies to a single verify command; lanes rerun their own failures"
|
|
1461
|
-
fi
|
|
1462
1659
|
verify_lanes_run "$plan" "$wt" "$out" "${vsource#*$'\t'}" "$vretries"
|
|
1463
1660
|
return $? ;;
|
|
1464
1661
|
esac
|
|
@@ -1467,8 +1664,8 @@ verify_result_body() { # plan, checkout, artifact directory
|
|
|
1467
1664
|
# produced — any non-zero exit (no key, disabled, nothing suitable, a traceback)
|
|
1468
1665
|
# falls straight through to the exact UNVERIFIED behaviour below. A Jev failure
|
|
1469
1666
|
# must never change the outcome of a run.
|
|
1470
|
-
if [ -z "$cmd" ] && [ "$jev_loaded" = 1 ] &&
|
|
1471
|
-
local jev_json jev_rc jev_cmd
|
|
1667
|
+
if [ -z "$cmd" ] && [ -z "$fixed" ] && [ "$jev_loaded" = 1 ] && forge_decide_active verify-discover; then
|
|
1668
|
+
local jev_json jev_rc jev_cmd jev_note
|
|
1472
1669
|
# --json rather than the bare form: the record exists so a human can audit why a
|
|
1473
1670
|
# command ran, and "confidence: null" answers nothing. The exit code still decides.
|
|
1474
1671
|
jev_json="$(python3 "$SKILL_DIR/scripts/forge-jev.py" verify-discover --repo "$repo" --json --run-dir "$out" 2>/dev/null)"
|
|
@@ -1485,9 +1682,22 @@ except ValueError:
|
|
|
1485
1682
|
fi
|
|
1486
1683
|
if [ -n "$jev_cmd" ]; then
|
|
1487
1684
|
cmd="$jev_cmd"
|
|
1685
|
+
# Coverage (#42): the pick's evidence names fewer languages than the repo has. The
|
|
1686
|
+
# pick stands and its run still decides; only the announcement says so.
|
|
1687
|
+
jev_note="$(printf '%s' "$jev_json" | python3 -c '
|
|
1688
|
+
import json, sys
|
|
1689
|
+
try:
|
|
1690
|
+
coverage = (json.load(sys.stdin) or {}).get("coverage") or {}
|
|
1691
|
+
except ValueError:
|
|
1692
|
+
coverage = {}
|
|
1693
|
+
covered = coverage.get("covered") or []
|
|
1694
|
+
missing = [language for language in coverage.get("present") or [] if language not in covered]
|
|
1695
|
+
if covered and missing:
|
|
1696
|
+
print(" — it may cover only part of the repo (covers %s; the repo also has %s)" % (", ".join(covered), ", ".join(missing)))
|
|
1697
|
+
' 2>/dev/null)"
|
|
1488
1698
|
# Loud on purpose: an unreviewed command is about to run on the user's behalf,
|
|
1489
1699
|
# and they must never discover that later from a log instead of right here.
|
|
1490
|
-
note "jev chose a verification command (no --verify or .forge/verify configured): $cmd"
|
|
1700
|
+
note "jev chose a verification command (no --verify or .forge/verify configured): $cmd$jev_note"
|
|
1491
1701
|
printf '%s' "$jev_json" | python3 -c '
|
|
1492
1702
|
import json, sys
|
|
1493
1703
|
out = sys.argv[1]
|
|
@@ -1518,11 +1728,10 @@ with open(out + "/verification.jev.json", "w") as fh:
|
|
|
1518
1728
|
verify_stopped "$out" && return 130
|
|
1519
1729
|
echo "$before" > "$out/verification.fingerprint"
|
|
1520
1730
|
if [ "$rc" != 0 ] || [ "$before" != "$after" ]; then
|
|
1521
|
-
local flaked=0
|
|
1522
|
-
#
|
|
1523
|
-
#
|
|
1731
|
+
local flaked=0 n_retry=0 rc3 b3 a3
|
|
1732
|
+
# The rerun itself is the evidence: it needs no model and no recorded trap. A tree
|
|
1733
|
+
# change is never retried.
|
|
1524
1734
|
if [ "$rc" != 0 ] && [ "$before" = "$after" ] && [ "$vretries" -gt 0 ]; then
|
|
1525
|
-
det_retried=1
|
|
1526
1735
|
while [ "$n_retry" -lt "$vretries" ] && [ "$flaked" = 0 ]; do
|
|
1527
1736
|
n_retry=$((n_retry+1)); rc3=0
|
|
1528
1737
|
note "verification failed (exit $rc); rerunning to tell a flaky lane from a regression ($n_retry/$vretries)"
|
|
@@ -1544,96 +1753,6 @@ with open(out + "/verification.jev.json", "w") as fh:
|
|
|
1544
1753
|
fi
|
|
1545
1754
|
done
|
|
1546
1755
|
fi
|
|
1547
|
-
# A tree change is never a flake — it stays FAIL immediately, no triage. Beyond
|
|
1548
|
-
# that, act on a "known_flake" verdict ONLY when Forge's own memory already
|
|
1549
|
-
# records a `trap` for this repo: a model alone deciding a failure was a flake
|
|
1550
|
-
# is exactly how a real regression ships, so the verdict needs corroboration
|
|
1551
|
-
# from Forge's own records, not just the model's word.
|
|
1552
|
-
if [ "$rc" != 0 ] && [ "$before" = "$after" ] && [ "$jev_loaded" = 1 ] \
|
|
1553
|
-
&& [ "$det_retried" = 0 ] \
|
|
1554
|
-
&& forge_jev_active tests \
|
|
1555
|
-
&& [ -s "$repo/.forge/memory.md" ] \
|
|
1556
|
-
&& awk '/^## Known traps$/{f=1;next} /^## /{f=0} f && NF{c++} END{exit !(c>0)}' "$repo/.forge/memory.md"
|
|
1557
|
-
then
|
|
1558
|
-
local triage_json triage_rc verdict="" confidence="" flake_act="0.90" parsed corroborated=0 retried=0 rc2="" before2 after2
|
|
1559
|
-
triage_json="$(python3 "$SKILL_DIR/scripts/forge-jev.py" verify-triage --repo "$repo" \
|
|
1560
|
-
--command "$cmd" --log "$out/verification.log" --json --run-dir "$out" 2>/dev/null)"
|
|
1561
|
-
triage_rc=$?
|
|
1562
|
-
if [ "$triage_rc" -eq 0 ] && [ -n "$triage_json" ]; then
|
|
1563
|
-
parsed="$(printf '%s' "$triage_json" | python3 -c '
|
|
1564
|
-
import json, sys
|
|
1565
|
-
try:
|
|
1566
|
-
data = json.load(sys.stdin)
|
|
1567
|
-
except ValueError:
|
|
1568
|
-
data = {}
|
|
1569
|
-
print(data.get("verdict") or "")
|
|
1570
|
-
c = data.get("confidence")
|
|
1571
|
-
print(c if c is not None else "")
|
|
1572
|
-
print(bool(data.get("corroborated")))
|
|
1573
|
-
' 2>/dev/null)"
|
|
1574
|
-
verdict="$(printf '%s\n' "$parsed" | sed -n 1p)"
|
|
1575
|
-
confidence="$(printf '%s\n' "$parsed" | sed -n 2p)"
|
|
1576
|
-
# triage() reports whether a recorded trap shares a distinctive token with this
|
|
1577
|
-
# failure's output. Without that, one flaky test noted months ago would excuse
|
|
1578
|
-
# every future failure in the repo.
|
|
1579
|
-
[ "$(printf '%s\n' "$parsed" | sed -n 3p)" = "True" ] && corroborated=1 || corroborated=0
|
|
1580
|
-
if [ -n "$FORGE_JEV_STATUS_JSON" ]; then
|
|
1581
|
-
local threshold_read
|
|
1582
|
-
threshold_read="$(printf '%s' "$FORGE_JEV_STATUS_JSON" | python3 -c '
|
|
1583
|
-
import json, sys
|
|
1584
|
-
try:
|
|
1585
|
-
data = json.load(sys.stdin)
|
|
1586
|
-
except ValueError:
|
|
1587
|
-
data = {}
|
|
1588
|
-
v = (data.get("thresholds") or {}).get("flake_act")
|
|
1589
|
-
print(v if v is not None else "0.90")
|
|
1590
|
-
' 2>/dev/null)"
|
|
1591
|
-
[ -n "$threshold_read" ] && flake_act="$threshold_read"
|
|
1592
|
-
fi
|
|
1593
|
-
if [ "$verdict" = known_flake ] && [ -n "$confidence" ] && [ "$corroborated" = 1 ] \
|
|
1594
|
-
&& awk -v a="$confidence" -v b="$flake_act" 'BEGIN{exit !(a+0 >= b+0)}'
|
|
1595
|
-
then
|
|
1596
|
-
retried=1
|
|
1597
|
-
note "jev: known_flake (confidence $confidence >= $flake_act), corroborated by a recorded trap — retrying once"
|
|
1598
|
-
before2="$(forge_fingerprint "$wt")" || return 1
|
|
1599
|
-
vt0="$(date +%s)"
|
|
1600
|
-
verify_stopped "$out" && return 130
|
|
1601
|
-
verify_exec "$wt" "$cmd" "$out/verification.retry.log" || rc2=$?
|
|
1602
|
-
rc2="${rc2:-0}"
|
|
1603
|
-
after2="$(forge_fingerprint "$wt")" || { verify_stopped "$out" && return 130; return 1; }
|
|
1604
|
-
verify_run_note "$out" jev_retry "$rc2" "$before2" "$after2" verification.retry.log "$vt0"
|
|
1605
|
-
verify_stopped "$out" && return 130
|
|
1606
|
-
if [ "$rc2" = 0 ] && [ "$before2" = "$after2" ]; then
|
|
1607
|
-
flaked=1
|
|
1608
|
-
note "jev: retry passed — treating as a corroborated flake, not a regression"
|
|
1609
|
-
else
|
|
1610
|
-
note "jev: retry also failed (exit $rc2) — keeping FAIL"
|
|
1611
|
-
fi
|
|
1612
|
-
fi
|
|
1613
|
-
python3 -c '
|
|
1614
|
-
import json, sys
|
|
1615
|
-
out, verdict, confidence, threshold, corroborated, retried, first_rc, retry_rc = sys.argv[1:9]
|
|
1616
|
-
path = out + "/verification.jev.json"
|
|
1617
|
-
try:
|
|
1618
|
-
with open(path) as fh:
|
|
1619
|
-
data = json.load(fh)
|
|
1620
|
-
except (OSError, ValueError):
|
|
1621
|
-
data = {}
|
|
1622
|
-
data["triage"] = {
|
|
1623
|
-
"verdict": verdict or None,
|
|
1624
|
-
"confidence": float(confidence) if confidence else None,
|
|
1625
|
-
"flake_act_threshold": float(threshold),
|
|
1626
|
-
"trap_corroboration": corroborated == "1",
|
|
1627
|
-
"retried": retried == "1",
|
|
1628
|
-
"first_exit": int(first_rc),
|
|
1629
|
-
"retry_exit": int(retry_rc) if retry_rc != "" else None,
|
|
1630
|
-
}
|
|
1631
|
-
with open(path, "w") as fh:
|
|
1632
|
-
json.dump(data, fh, indent=2, sort_keys=True)
|
|
1633
|
-
fh.write("\n")
|
|
1634
|
-
' "$out" "$verdict" "$confidence" "$flake_act" "$corroborated" "$retried" "$rc" "$rc2" 2>/dev/null || true
|
|
1635
|
-
fi
|
|
1636
|
-
fi
|
|
1637
1756
|
if [ "$flaked" = 1 ]; then
|
|
1638
1757
|
echo PASS > "$out/verification.status"
|
|
1639
1758
|
return 0
|
|
@@ -1688,6 +1807,7 @@ do_run() {
|
|
|
1688
1807
|
FORGE_RUN_STOPPABLE=1
|
|
1689
1808
|
trap run_signal TERM INT
|
|
1690
1809
|
local PLAN="${1:?run needs a plan dir}"; shift
|
|
1810
|
+
FORGE_RUN_STARTED="$(forge_now)" # the summary's overridden verdicts are this run's
|
|
1691
1811
|
local fractal_pipeline_args=("$@")
|
|
1692
1812
|
local MAXP=3 DRY=0 jev_rc=0 FORECAST=1
|
|
1693
1813
|
while [ $# -gt 0 ]; do
|
|
@@ -1709,7 +1829,7 @@ do_run() {
|
|
|
1709
1829
|
# `case` is not a loop, so `continue` here belongs to the enclosing while.
|
|
1710
1830
|
if forge_pp_flag run "$PLAN" "$@"; then shift "$PP_SHIFT"; continue; fi
|
|
1711
1831
|
if [ "$JEV_OPTS" = 1 ]; then
|
|
1712
|
-
forge_jev_flag "
|
|
1832
|
+
forge_jev_flag "$@"; jev_rc=$?
|
|
1713
1833
|
case "$jev_rc" in
|
|
1714
1834
|
0) shift "$JEV_SHIFT"; continue ;;
|
|
1715
1835
|
2) exit 2 ;;
|
|
@@ -1732,6 +1852,8 @@ do_run() {
|
|
|
1732
1852
|
compute_waves "$PLAN"
|
|
1733
1853
|
local REPO run_id wt_root int_wt int_br
|
|
1734
1854
|
REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"
|
|
1855
|
+
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
1856
|
+
[ "$JEV_OPTS" = 1 ] && forge_decide_env "$REPO" "$PLAN"
|
|
1735
1857
|
if [ "$DRY" != 1 ]; then
|
|
1736
1858
|
# The concurrency limit this run was given, for forge-ui to draw; a later run rewrites it.
|
|
1737
1859
|
printf '%s\n' "$MAXP" > "$PLAN/max_parallel"
|
|
@@ -1857,9 +1979,13 @@ do_run() {
|
|
|
1857
1979
|
echo "artifacts: $PLAN/tasks/<id>/{dwarf,qa}.{last,log}; results: $PLAN/results.tsv"
|
|
1858
1980
|
printf ' %-14s %-9s %s\n' id status branch
|
|
1859
1981
|
awk -F'\t' '{printf " %-14s %-9s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
|
|
1860
|
-
forge_jev_review_flags "$PLAN"
|
|
1861
1982
|
echo
|
|
1862
1983
|
run_report_extras "$PLAN"
|
|
1984
|
+
# Pre-review tests (#85): every check of the plan, and the reviews the red ones saved.
|
|
1985
|
+
local pre_review
|
|
1986
|
+
pre_review="$(cat "$PLAN"/tasks/*/prereview.log 2>/dev/null | awk -F'\t' 'NF >= 3 { n++; if ($2 == "failed") f++; s += $3 }
|
|
1987
|
+
END { if (n) printf "pre-review tests: %d check(s), %d attempt(s) sent back without a review, %ds of test time\n", n, f, s }')"
|
|
1988
|
+
[ -z "$pre_review" ] || { echo "$pre_review"; echo; }
|
|
1863
1989
|
|
|
1864
1990
|
# Undeclared files are reported here rather than buried in a task log, because
|
|
1865
1991
|
# this is the list that explains any CONFLICT above.
|
|
@@ -1884,10 +2010,21 @@ do_run() {
|
|
|
1884
2010
|
for id in $stopped_ids; do echo " forge-parallel.sh retry $PLAN $id"; done
|
|
1885
2011
|
fi
|
|
1886
2012
|
[ "$interrupted" = 1 ] || [ -n "$stopped_ids" ] && echo
|
|
2013
|
+
# Tasks stopped for the user's answer: the question as it was asked, and the command that
|
|
2014
|
+
# answers it. Not failures, so the retry hint below does not count them.
|
|
2015
|
+
local waiting; waiting="$(awk -F'\t' '$2=="NEEDS_INPUT" {print $1}' "$PLAN/results.tsv")"
|
|
2016
|
+
if [ -n "$waiting" ]; then
|
|
2017
|
+
echo "waiting for your answer:"
|
|
2018
|
+
for id in $waiting; do
|
|
2019
|
+
printf ' %s: %s\n' "$id" "$(awk 'NF { print substr($0, 1, 120); exit }' "$PLAN/tasks/$id/needs_input.md" 2>/dev/null)"
|
|
2020
|
+
echo " answer with: forge-parallel.sh retry $PLAN $id --answer \"<text>\""
|
|
2021
|
+
done
|
|
2022
|
+
echo
|
|
2023
|
+
fi
|
|
1887
2024
|
# The retry hint is for tasks that actually failed; a run that only failed verification,
|
|
1888
2025
|
# or only paused on infrastructure, has nothing to retry task by task. An interrupted task
|
|
1889
|
-
# has its own hint above.
|
|
1890
|
-
if [ "$(awk -F'\t' '$2!="MERGED" && $2!="INFRA" && $2!="PENDING" && $2!="BLOCKED" && $2!="INTERRUPTED" {n++} END {print n+0}' "$PLAN/results.tsv")" -gt 0 ]; then
|
|
2026
|
+
# has its own hint above, a task waiting for an answer its own block.
|
|
2027
|
+
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
|
|
1891
2028
|
echo "retry a failed task with its reviewer's findings:"
|
|
1892
2029
|
echo " forge-parallel.sh retry $PLAN <task-id> [--dwarf <spec>]"
|
|
1893
2030
|
echo "or let a run retry them itself: forge-parallel.sh run $PLAN --retry-failed 1"
|
|
@@ -1896,6 +2033,20 @@ do_run() {
|
|
|
1896
2033
|
if [ "$failed" = 1 ] && [ "$paused" = 0 ] && [ "$interrupted" = 0 ] && [ "$(cat "$PLAN/verification.status" 2>/dev/null)" = FAIL ]; then
|
|
1897
2034
|
echo "combined verification failed: see $PLAN/verification.log"
|
|
1898
2035
|
echo
|
|
2036
|
+
if [ -f "$PLAN/attribute_on" ] && declare -F attribute_search >/dev/null; then
|
|
2037
|
+
# This run holds the plan lock: the search function, never the subcommand.
|
|
2038
|
+
run_phase=attribute
|
|
2039
|
+
( attribute_search "$PLAN" 0 ) <&0 &
|
|
2040
|
+
run_child=$!
|
|
2041
|
+
[ "$run_stop" = 1 ] && kill -TERM "$run_child" 2>/dev/null
|
|
2042
|
+
run_wait "$run_child"
|
|
2043
|
+
run_child=""
|
|
2044
|
+
[ "$run_stop" = 1 ] && interrupted=1
|
|
2045
|
+
echo
|
|
2046
|
+
else
|
|
2047
|
+
echo "find a merge that broke it: forge-parallel.sh attribute $PLAN"
|
|
2048
|
+
echo
|
|
2049
|
+
fi
|
|
1899
2050
|
fi
|
|
1900
2051
|
|
|
1901
2052
|
if [ ! -f "$PLAN/no_memory" ]; then
|
|
@@ -1978,7 +2129,7 @@ if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
|
|
|
1978
2129
|
forge_fractal_help
|
|
1979
2130
|
exit 0
|
|
1980
2131
|
fi
|
|
1981
|
-
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|run|retry|accept|review|integrate|split|combine> <plan-dir> [...]"
|
|
2132
|
+
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|run|retry|accept|review|integrate|split|attribute|combine> <plan-dir> [...]"
|
|
1982
2133
|
CMD="$1"; shift
|
|
1983
2134
|
[ ! -f "${1:-}/no_ripwire" ] || export FORGE_RIPWIRE=off
|
|
1984
2135
|
if [ -d "${1:-}" ]; then
|
|
@@ -1986,7 +2137,7 @@ if [ -d "${1:-}" ]; then
|
|
|
1986
2137
|
fi
|
|
1987
2138
|
case "$CMD" in
|
|
1988
2139
|
# `combine` takes a plan dir that does not exist yet and locks its sources itself.
|
|
1989
|
-
run|retry|integrate|accept|review|split)
|
|
2140
|
+
run|retry|integrate|accept|review|split|attribute)
|
|
1990
2141
|
if [ "${FORGE_PLAN_LOCK:-}" != "${1:-}" ]; then
|
|
1991
2142
|
exec python3 "$SKILL_DIR/scripts/forge-schedule.py" lock "$SELF" "$CMD" "$@"
|
|
1992
2143
|
fi ;;
|
|
@@ -1995,7 +2146,7 @@ esac
|
|
|
1995
2146
|
# path (die included). Installed after the lock re-exec, so it fires once, in the process
|
|
1996
2147
|
# that did the work; `_task` and `_merge` are parts of a `run` and are not recorded alone.
|
|
1997
2148
|
case "$CMD" in
|
|
1998
|
-
plan|run|retry|integrate|accept|review|split|combine)
|
|
2149
|
+
plan|run|retry|integrate|accept|review|split|attribute|combine)
|
|
1999
2150
|
FORGE_DATASET_INVOCATION="inv-$(date +%s)-$$-$RANDOM"; export FORGE_DATASET_INVOCATION
|
|
2000
2151
|
FORGE_DATASET_STARTED="$(date +%s)"
|
|
2001
2152
|
FORGE_DATASET_ARGV=("$@")
|
|
@@ -2023,6 +2174,7 @@ case "$CMD" in
|
|
|
2023
2174
|
accept) need_fn do_accept; do_accept "$@" ;;
|
|
2024
2175
|
review) need_fn do_review; do_review "$@" ;;
|
|
2025
2176
|
split) need_fn do_split; do_split "$@" ;;
|
|
2177
|
+
attribute) need_fn do_attribute; do_attribute "$@" ;;
|
|
2026
2178
|
combine) need_fn do_combine; do_combine "$@" ;;
|
|
2027
2179
|
_task) do_task "$@" ;;
|
|
2028
2180
|
_merge) merge_task "$@" ;;
|