@giamme/forge 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +25 -15
- package/SKILL.md +137 -216
- package/VERSION +1 -1
- package/bin/forge.js +104 -0
- package/docs/README.md +2 -3
- package/docs/add-ons.md +5 -3
- package/docs/artifacts.md +17 -2
- package/docs/commands.md +85 -63
- package/docs/decomposed-runs.md +195 -21
- package/docs/development.md +12 -10
- package/docs/forge-ui.md +33 -4
- package/docs/install.md +127 -6
- package/docs/memory.md +6 -1
- package/docs/models.md +36 -10
- package/docs/reviews.md +50 -29
- package/docs/safety.md +27 -2
- package/docs/troubleshooting.md +8 -11
- package/forge +29 -4
- package/forge.cmd +56 -0
- package/package.json +6 -3
- package/references/dataset.md +10 -9
- package/references/decompose-integration.md +337 -0
- package/references/decompose-opt-in.md +527 -0
- package/references/decompose-recovery.md +569 -0
- package/references/decompose-review.md +256 -0
- package/references/decompose.md +99 -1606
- package/references/findings.md +68 -0
- package/references/harnesses.md +7 -12
- package/references/memory.md +13 -2
- package/references/planning.md +48 -18
- package/references/ripwire.md +38 -13
- package/references/runtime.md +22 -33
- package/references/setup.md +90 -0
- package/references/solo.md +13 -42
- package/references/ui.md +12 -5
- package/registry.tsv +40 -22
- package/scripts/forge-artifact.sh +148 -13
- package/scripts/forge-compare.py +5 -15
- package/scripts/forge-config.py +14 -1
- package/scripts/forge-contract.py +216 -53
- package/scripts/forge-control.py +781 -51
- package/scripts/forge-dispatch.sh +202 -42
- package/scripts/forge-du.py +13 -3
- package/scripts/forge-guard.py +137 -6
- package/scripts/forge-handoff.py +221 -39
- package/scripts/forge-install-ripwire.sh +100 -24
- package/scripts/forge-install.sh +100 -41
- package/scripts/forge-issues.py +6 -4
- package/scripts/forge-jev-options.sh +3 -5
- package/scripts/forge-lib-adopt.sh +169 -5
- package/scripts/forge-lib-attribute.sh +10 -3
- package/scripts/forge-lib-decompose.sh +454 -0
- package/scripts/forge-lib-env.sh +179 -0
- package/scripts/forge-lib-group.sh +9 -6
- package/scripts/forge-lib-plans.sh +38 -21
- package/scripts/forge-lib-review.sh +28 -8
- package/scripts/forge-lib-task.sh +263 -69
- package/scripts/forge-lib-verify.sh +59 -10
- package/scripts/forge-memory.sh +83 -4
- package/scripts/forge-metrics.sh +10 -3
- package/scripts/forge-parallel-options.sh +23 -4
- package/scripts/forge-parallel.sh +602 -217
- package/scripts/forge-plan-check.py +71 -8
- package/scripts/forge-planner.py +303 -17
- package/scripts/forge-pr.py +9 -1
- package/scripts/forge-prompt.py +2 -2
- package/scripts/forge-review-links.py +248 -0
- package/scripts/forge-ripwire.py +234 -16
- package/scripts/forge-route.py +19 -27
- package/scripts/forge-runs-rm.py +92 -21
- package/scripts/forge-runs.py +46 -5
- package/scripts/forge-runtime.py +39 -14
- package/scripts/forge-schedule.py +141 -33
- package/scripts/forge-setup-stale.py +236 -0
- package/scripts/forge-setup.py +804 -0
- package/scripts/forge-shadow.py +2 -20
- package/scripts/forge-solo-lock.py +46 -0
- package/scripts/forge-solo.sh +39 -58
- package/scripts/forge-sweep.py +3 -2
- package/scripts/forge-ui.py +8 -1
- package/scripts/forge-update.sh +8 -3
- package/scripts/forge-verify.py +17 -1
- package/scripts/forge-version.py +13 -1
- package/scripts/forge-watch.py +7 -2
- package/scripts/forge-win.sh +156 -0
- package/scripts/forge_brief/__init__.py +6 -1
- package/scripts/forge_brief/proposals.py +6 -1
- package/scripts/forge_dataset/__init__.py +1 -1
- package/scripts/forge_dataset/capture.py +0 -34
- package/scripts/forge_dataset/checks.py +0 -1
- package/scripts/forge_dataset/cli.py +5 -1
- package/scripts/forge_dataset/export.py +28 -6
- package/scripts/forge_dataset/facts.py +1 -2
- package/scripts/forge_dataset/forecast.py +1 -1
- package/scripts/forge_dataset/harvest.py +107 -7
- package/scripts/forge_dataset/importer.py +3 -2
- package/scripts/forge_dataset/pairs.py +3 -3
- package/scripts/forge_dataset/reviewers.py +4 -3
- package/scripts/forge_dataset/routing.py +6 -3
- package/scripts/forge_dataset/tiers.py +1 -1
- package/scripts/forge_decide/__init__.py +1 -1
- package/scripts/forge_decide/budget.py +12 -7
- package/scripts/forge_decide/profiles.py +11 -14
- package/scripts/forge_decide/replay.py +9 -4
- package/scripts/forge_decompose.py +987 -0
- package/scripts/forge_flock.py +17 -2
- package/scripts/forge_groups/review.py +6 -1
- package/scripts/forge_jev/__init__.py +1 -1
- package/scripts/forge_jev/cli.py +10 -1
- package/scripts/forge_jev/gates.py +10 -1
- package/scripts/forge_jev/verify.py +10 -2
- package/scripts/forge_legacy.py +86 -0
- package/scripts/forge_memory_home.py +57 -0
- package/scripts/forge_models.py +151 -0
- package/scripts/forge_posix.py +17 -0
- package/scripts/forge_prefs.py +138 -0
- package/scripts/forge_proc.py +108 -0
- package/scripts/forge_registry.py +2 -2
- package/scripts/forge_side/__init__.py +23 -4
- package/scripts/forge_storage.py +28 -15
- package/ui/README.md +22 -10
- package/ui/docs/api.md +121 -99
- package/ui/forge_ui/control.py +53 -16
- package/ui/forge_ui/export.py +0 -10
- package/ui/forge_ui/models.py +15 -2
- package/ui/forge_ui/projects.py +4 -1
- package/ui/forge_ui/reader.py +462 -60
- package/ui/forge_ui/server.py +0 -10
- package/ui/forge_ui/static/app.js +28 -9
- package/ui/forge_ui/static/checksview.js +12 -3
- package/ui/forge_ui/static/controls.js +147 -11
- package/ui/forge_ui/static/convo.js +5 -2
- package/ui/forge_ui/static/diffview.js +4 -5
- package/ui/forge_ui/static/panel.js +180 -77
- package/ui/forge_ui/static/projectsview.js +16 -2
- package/ui/forge_ui/static/runmodel.js +18 -4
- package/ui/forge_ui/static/scene3d.js +52 -31
- package/ui/forge_ui/static/settings.js +1 -1
- package/ui/forge_ui/static/storageview.js +2 -2
- package/ui/forge_ui/static/style.css +23 -6
- package/ui/forge_ui/static/worktreesview.js +8 -4
- package/ui/forge_ui/transcripts.py +6 -0
- package/ui/forge_ui/worktrees.py +13 -1
- package/docs/fractal.md +0 -181
- package/references/fractal-dashboard.md +0 -21
- package/references/fractal.md +0 -307
- package/scripts/forge-fractal-dispatch.sh +0 -4
- package/scripts/forge-fractal-options.sh +0 -54
- package/scripts/forge-fractal.py +0 -6
- package/scripts/forge-install-fractal.sh +0 -4
- package/scripts/forge_fractal/__init__.py +0 -88
- package/scripts/forge_fractal/bridge.py +0 -46
- package/scripts/forge_fractal/cli.py +0 -224
- package/scripts/forge_fractal/dashboard.css +0 -138
- package/scripts/forge_fractal/dashboard.html +0 -41
- package/scripts/forge_fractal/dashboard.js +0 -687
- package/scripts/forge_fractal/decomposition.py +0 -262
- package/scripts/forge_fractal/execution.py +0 -659
- package/scripts/forge_fractal/inspection.py +0 -261
- package/scripts/forge_fractal/install.py +0 -158
- package/scripts/forge_fractal/invocation.py +0 -95
- package/scripts/forge_fractal/pipeline.py +0 -125
- package/scripts/forge_fractal/selection.py +0 -180
- package/ui/forge_ui/fractal.py +0 -582
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# Usage:
|
|
8
8
|
# forge-parallel.sh plan <plan-dir> --repo <dir> [routing flags] [--decompose-level low|medium|high] [--ui]
|
|
9
9
|
# [--qa-threshold P0|P1|P2|P3|none|default] [--profile NAME | --no-profile]
|
|
10
|
-
# [--collapse-chains]
|
|
10
|
+
# [--collapse-chains] [--split-depth N] [--split-children N] [--split-nodes N]
|
|
11
11
|
# forge-parallel.sh auto <plan-dir> --repo <dir> --goal-file <file> [--planner <spec>] [--decompose-level L]
|
|
12
12
|
# [--plan auto|always|never] [--one-task-difficulty low|medium|high]
|
|
13
13
|
# [--no-collapse] [--approved] [plan flags...] [-- run flags...]
|
|
@@ -17,21 +17,27 @@
|
|
|
17
17
|
# [--qa-threshold P0|P1|P2|P3|none|default] [--verify-retries N] [--no-forecast]
|
|
18
18
|
# [--sweep P0|P1|P2|P3 [--sweep-plausible] [--sweep-max N]]
|
|
19
19
|
# [--sweep-ahead | --no-sweep-ahead] [--attribute | --no-attribute]
|
|
20
|
+
# [--auto-split [--split-planner <spec>] | --no-auto-split]
|
|
20
21
|
# forge-parallel.sh retry <plan-dir> <task-id> [--dwarf <spec>] [--setup <command>]
|
|
21
22
|
# [--answer <text> | --answer-file <file>] (a NEEDS_INPUT task)
|
|
22
23
|
# [--decide retry=N|threshold=Pn] [--dwarf <spec>] --reason "<why>" --approved
|
|
23
24
|
# (a NEEDS_DECISION task)
|
|
25
|
+
# [--decide split[=fresh] [--subtasks <file> | --planner <spec>] --reason "<why>" --approved]
|
|
26
|
+
# (split the task into subtasks: any task that has not passed)
|
|
24
27
|
# [--no-dispatch] (prepare it and start nothing: the next `run` dispatches it)
|
|
25
28
|
# [--timeout S] [--qa-threshold Pn|none|default] [--verify-retries N]
|
|
26
29
|
# [--retry-failed N] [--infra-retries M]
|
|
27
30
|
# forge-parallel.sh integrate <plan-dir> --approved [--verify-retries N] [--final-review <qa-spec>]
|
|
28
31
|
# forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold Pn|none|default]
|
|
29
32
|
# forge-parallel.sh attribute <plan-dir> [--force] (find a merge that breaks the failed verification)
|
|
33
|
+
# forge-parallel.sh verify <plan-dir> [--verify-retries N] [--verify-parallel N] (verify the integration branch again, nothing else)
|
|
30
34
|
# forge-parallel.sh accept <plan-dir> <task-id> --reason "<why>" --approved
|
|
31
35
|
# forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason "<why>" [--qa <spec>] [--approved]
|
|
32
36
|
# (a commit made outside forge, reviewed alone, comes into the run)
|
|
33
37
|
# forge-parallel.sh split <plan-dir> <new-plan> --tasks <id,id> [--dry-run]
|
|
34
38
|
# forge-parallel.sh combine <new-plan> <plan-a> <plan-b> [<plan>...] [--verify <command>] [--dry-run]
|
|
39
|
+
# forge-parallel.sh next <plan-dir> [<new-plan>] [--planner <spec>] [plan flags...]
|
|
40
|
+
# (plan the next stage of a goal larger than one plan, after <plan-dir> merged)
|
|
35
41
|
# forge-parallel.sh _task <plan-dir> <task-id> (internal; coordinator target)
|
|
36
42
|
# forge-parallel.sh _group <plan-dir> <group-id> (internal; one QA review of a review=group group, #140)
|
|
37
43
|
# forge-parallel.sh _group_settle <plan-dir> <group-id> [--tasks a,b]
|
|
@@ -117,6 +123,13 @@
|
|
|
117
123
|
# before routing, merge a chain into one task named combined.
|
|
118
124
|
# A one-task or branching plan is left as it is, and collapsing
|
|
119
125
|
# a plan that is already collapsed is not an error
|
|
126
|
+
# --split-depth N recursive decomposition (#153): how many levels of subtasks a task may be
|
|
127
|
+
# split into (default 2; 0 turns splitting off)
|
|
128
|
+
# --split-children N most subtasks one split may make (default 6)
|
|
129
|
+
# --split-nodes N most subtasks in the whole run, over every level (default 24)
|
|
130
|
+
# The three limits are shown under the task table, kept in
|
|
131
|
+
# decomposition.json and frozen by the first run: a split that would pass
|
|
132
|
+
# one is recorded as `bounded` and the task runs as one task
|
|
120
133
|
#
|
|
121
134
|
# The QA threshold (plan, run, retry, review; kept for the plan):
|
|
122
135
|
# --qa-threshold Pn the least severe CONFIRMED finding that still blocks (P0 worst ...
|
|
@@ -141,6 +154,20 @@
|
|
|
141
154
|
# on its way (kept for the plan; --no-sweep-ahead turns it off)
|
|
142
155
|
# --attribute when the run's combined verification fails, search the merge order for
|
|
143
156
|
# a merge that breaks it (kept for the plan; --no-attribute turns it off)
|
|
157
|
+
# --auto-split a task that stops for a decision on `split` is split into subtasks by the
|
|
158
|
+
# planner, within the plan's limits, without waiting for you; without it the
|
|
159
|
+
# task waits for your `retry --decide split`. The planner is --split-planner
|
|
160
|
+
# SPEC, else the one the plan was made with. Kept for the plan;
|
|
161
|
+
# --no-auto-split turns it off
|
|
162
|
+
#
|
|
163
|
+
# Subtasks (#153): a task can be split into subtasks, at plan time by the planner or later by
|
|
164
|
+
# `retry <plan> <task> --decide split`. The subtasks are a plan of their own in
|
|
165
|
+
# <plan-dir>/tasks/<task>/sub: they are routed with the plan's difficulty pools, own paths inside the
|
|
166
|
+
# task's files, run on the same scheduler under the run's one --max-parallel, and merge into the
|
|
167
|
+
# task's branch. The task is then reviewed on everything they produced. `split` keeps the task's
|
|
168
|
+
# existing work and the subtasks build on it; `split=fresh` starts over from the task's base and
|
|
169
|
+
# keeps the old work on refs/forge/kept/<run>/<task>. A subtask that fails is retried in its own
|
|
170
|
+
# plan (retry <plan-dir>/tasks/<task>/sub <subtask>); the next `run` of the plan picks the task up.
|
|
144
171
|
#
|
|
145
172
|
# auto (#87, #88): from a goal to a finished run in one blocking command, with no orchestrating
|
|
146
173
|
# session in between. In a NEW plan dir (created when missing; one that already has tasks.tsv
|
|
@@ -172,13 +199,16 @@ set -uo pipefail
|
|
|
172
199
|
|
|
173
200
|
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
|
|
174
201
|
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
202
|
+
# Windows: re-run inside MSYS2 when started from Git Bash (no-op elsewhere).
|
|
203
|
+
. "$SKILL_DIR/scripts/forge-win.sh"
|
|
204
|
+
source "$SKILL_DIR/scripts/forge-lib-env.sh"
|
|
205
|
+
forge_ensure_python3
|
|
175
206
|
DISPATCH="$SKILL_DIR/scripts/forge-dispatch.sh"
|
|
176
207
|
MEMORY="$SKILL_DIR/scripts/forge-memory.sh"
|
|
177
208
|
source "$SKILL_DIR/scripts/forge-artifact.sh"
|
|
178
209
|
source "$SKILL_DIR/scripts/forge-metrics.sh"
|
|
179
|
-
source "$SKILL_DIR/scripts/forge-fractal-options.sh"
|
|
180
210
|
source "$SKILL_DIR/scripts/forge-ui-options.sh"
|
|
181
|
-
#
|
|
211
|
+
# Sourced here, at the top: an option parser sourced from inside
|
|
182
212
|
# a function, after that function has already walked its arguments, cannot parse
|
|
183
213
|
# anything. Every --jev flag was rejected as "unknown option" until this line.
|
|
184
214
|
JEV_OPTS=0
|
|
@@ -187,7 +217,7 @@ JEV_OPTS=0
|
|
|
187
217
|
# Flags shared by several subcommands, then the helper libraries. Functions only, resolved
|
|
188
218
|
# at call time, so they may use die/note/field and friends defined below.
|
|
189
219
|
source "$SKILL_DIR/scripts/forge-parallel-options.sh"
|
|
190
|
-
for forge_lib in task gates verify attribute plans review adopt group; do
|
|
220
|
+
for forge_lib in task gates verify attribute plans review adopt group decompose; do
|
|
191
221
|
[ -f "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh" ] && source "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh"
|
|
192
222
|
done
|
|
193
223
|
OUTPUT=summary
|
|
@@ -209,6 +239,13 @@ field() { # field <tasks.tsv> <id> <colname>
|
|
|
209
239
|
}
|
|
210
240
|
all_ids() { awk -F'\t' '!/^#/ && NF {print $1}' "$1"; }
|
|
211
241
|
|
|
242
|
+
render_results_table() { # render_results_table <plan>
|
|
243
|
+
local w
|
|
244
|
+
w="$(id_col_width "$1/results.tsv" "$1/tasks.tsv")"
|
|
245
|
+
printf ' %-*s %-14s %s\n' "$w" id status branch
|
|
246
|
+
awk -F'\t' -v w="$w" '{printf " %-*s %-14s %s\n", w, $1, $2, $3}' "$1/results.tsv"
|
|
247
|
+
}
|
|
248
|
+
|
|
212
249
|
list_has() { # list_has <needle> <comma-list>
|
|
213
250
|
local n="$1" l="$2" w
|
|
214
251
|
[ "$l" = "-" ] && return 1
|
|
@@ -336,22 +373,17 @@ EOF
|
|
|
336
373
|
forge_profile_export "$PLAN"
|
|
337
374
|
}
|
|
338
375
|
|
|
339
|
-
# What `run` reads from the frozen profile when its flags do not say: the retry budgets
|
|
340
|
-
# and the Fractal planner (only with --fractal-auto-decompose, which --fractal-planner needs).
|
|
376
|
+
# What `run` reads from the frozen profile when its flags do not say: the retry budgets.
|
|
341
377
|
forge_profile_run_values() { # forge_profile_run_values <plan-dir>
|
|
342
|
-
local key val
|
|
378
|
+
local key val
|
|
343
379
|
[ -f "$1/profile.json" ] || return 0
|
|
344
|
-
for arg in ${FRACTAL_ARGS[@]+"${FRACTAL_ARGS[@]}"}; do
|
|
345
|
-
case "$arg" in --fractal-auto-decompose) auto=1 ;; --fractal-planner) planner=1 ;; esac
|
|
346
|
-
done
|
|
347
380
|
while IFS="$(printf '\t')" read -r key val; do
|
|
348
381
|
case "$key" in
|
|
349
382
|
policy.retry_failed) [ "$PP_RETRY_FAILED_SET" = 1 ] || PP_RETRY_FAILED="$val" ;;
|
|
350
383
|
policy.infra_retries) [ "$PP_INFRA_RETRIES_SET" = 1 ] || PP_INFRA_RETRIES="$val" ;;
|
|
351
|
-
routing.fractal_planner) [ "$auto$planner" != 10 ] || FRACTAL_ARGS+=(--fractal-planner "$val") ;;
|
|
352
384
|
esac
|
|
353
385
|
done <<EOF
|
|
354
|
-
$(forge_profile_py value "$1/profile.json" policy.retry_failed policy.infra_retries
|
|
386
|
+
$(forge_profile_py value "$1/profile.json" policy.retry_failed policy.infra_retries 2>/dev/null)
|
|
355
387
|
EOF
|
|
356
388
|
}
|
|
357
389
|
|
|
@@ -645,48 +677,21 @@ forge_groups_max_tasks() {
|
|
|
645
677
|
printf '%s' "${value:-6}"
|
|
646
678
|
}
|
|
647
679
|
|
|
648
|
-
# Put back the groups a refused derive replaced, or remove the ones it just wrote.
|
|
649
|
-
# A Fractal refusal must not leave a review=group groups.tsv that makes every later plan exit 2.
|
|
650
|
-
forge_groups_snap_restore() { # forge_groups_snap_restore <plan> <snap dir or empty>
|
|
651
|
-
local plan="$1" snap="${2:-}"
|
|
652
|
-
if [ -n "$snap" ] && [ -f "$snap/groups.tsv" ]; then cp "$snap/groups.tsv" "$plan/groups.tsv"
|
|
653
|
-
else rm -f "$plan/groups.tsv"; fi
|
|
654
|
-
if [ -n "$snap" ] && [ -f "$snap/groups.frozen" ]; then cp "$snap/groups.frozen" "$plan/groups.frozen"
|
|
655
|
-
else rm -f "$plan/groups.frozen"; fi
|
|
656
|
-
[ -z "$snap" ] || rm -rf "$snap"
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
forge_groups_snap_drop() { [ -z "${1:-}" ] || rm -rf "$1"; }
|
|
660
|
-
|
|
661
680
|
# forge_groups_plan <plan> <--groups value> <--group-review 0|1> <--group-max-tasks value>
|
|
662
681
|
forge_groups_plan() {
|
|
663
|
-
local plan="$1" src="$2" review="$3" max="$4" out=""
|
|
664
|
-
# derive and a --groups file replace groups.tsv before the Fractal check can refuse them.
|
|
665
|
-
if [ -f "$plan/groups.tsv" ] || [ -f "$plan/groups.frozen" ]; then
|
|
666
|
-
snap="$(mktemp -d)" || die "could not snapshot the plan's groups" 3
|
|
667
|
-
[ ! -f "$plan/groups.tsv" ] || cp "$plan/groups.tsv" "$snap/groups.tsv" \
|
|
668
|
-
|| { forge_groups_snap_drop "$snap"; die "could not snapshot $plan/groups.tsv" 3; }
|
|
669
|
-
[ ! -f "$plan/groups.frozen" ] || cp "$plan/groups.frozen" "$snap/groups.frozen" \
|
|
670
|
-
|| { forge_groups_snap_drop "$snap"; die "could not snapshot $plan/groups.frozen" 3; }
|
|
671
|
-
fi
|
|
682
|
+
local plan="$1" src="$2" review="$3" max="$4" out=""
|
|
672
683
|
if [ "$src" = waves ]; then
|
|
673
684
|
out="$(forge_groups_py derive "$plan" --review "$([ "$review" = 1 ] && echo group || echo task)" \
|
|
674
|
-
--max-tasks "$(forge_groups_max_tasks "$plan" "$max")" 2>&1)" ||
|
|
685
|
+
--max-tasks "$(forge_groups_max_tasks "$plan" "$max")" 2>&1)" || forge_groups_die "$out"
|
|
675
686
|
elif [ -n "$src" ]; then
|
|
676
|
-
cp "$src" "$plan/groups.tsv" ||
|
|
687
|
+
cp "$src" "$plan/groups.tsv" || die "could not copy '$src' to $plan/groups.tsv" 3
|
|
677
688
|
fi
|
|
678
689
|
if [ ! -f "$plan/groups.tsv" ] && [ ! -f "$plan/groups.frozen" ]; then
|
|
679
|
-
forge_groups_snap_drop "$snap"
|
|
680
690
|
return 0
|
|
681
691
|
fi
|
|
682
692
|
# validate, then resolve (writes the group qa back), then freeze
|
|
683
693
|
out="$(forge_groups_py validate "$plan" --max-tasks "$(forge_groups_max_tasks "$plan" "$max")" 2>&1)" \
|
|
684
|
-
||
|
|
685
|
-
if forge_groups_have_review "$plan" && forge_plan_is_fractal "$plan"; then
|
|
686
|
-
forge_groups_snap_restore "$plan" "$snap"
|
|
687
|
-
die "group review does not support Fractal yet" 2
|
|
688
|
-
fi
|
|
689
|
-
forge_groups_snap_drop "$snap"
|
|
694
|
+
|| forge_groups_die "$out"
|
|
690
695
|
out="$(forge_groups_py resolve "$plan" 2>&1)" || forge_groups_die "$out"
|
|
691
696
|
out="$(forge_groups_py freeze "$plan" 2>&1)" || forge_groups_die "$out"
|
|
692
697
|
return 0
|
|
@@ -772,6 +777,7 @@ do_plan() {
|
|
|
772
777
|
local RETRY_PER_MODEL=""
|
|
773
778
|
local COLLAPSE=0 COLLAPSED_NOW=0 FEAT_ERR="" GRP_SRC="" GRP_REVIEW=0 GRP_MAX="" GRP_DIFF=""
|
|
774
779
|
local CHAIN_PREV="" CHAIN_BASE="" CHAIN_MOVE=0
|
|
780
|
+
local SPLIT_DEPTH="" SPLIT_CHILDREN="" SPLIT_NODES="" DECOMPOSE_LINES=""
|
|
775
781
|
# The retro, brief and summaries choices, settled before anything is written: a refusal
|
|
776
782
|
# (a bad value, no model, a spec that does not resolve) leaves the plan dir as it was.
|
|
777
783
|
forge_features_scan "$@"
|
|
@@ -816,6 +822,14 @@ do_plan() {
|
|
|
816
822
|
printf '%s' "${2:-}" | grep -Eq '^[0-9]{1,9}$' && [ "$((10#$2))" -ge 1 ] || die "--group-max-diff-kb needs a positive integer"
|
|
817
823
|
GRP_DIFF="$((10#$2))"; shift 2 ;;
|
|
818
824
|
--collapse-chains) COLLAPSE=1; shift ;;
|
|
825
|
+
--split-depth|--split-children|--split-nodes)
|
|
826
|
+
printf '%s' "${2:-}" | grep -Eq '^[0-9]{1,3}$' || die "$1 needs a whole number" 2
|
|
827
|
+
case "$1" in
|
|
828
|
+
--split-depth) SPLIT_DEPTH="$((10#$2))" ;;
|
|
829
|
+
--split-children) SPLIT_CHILDREN="$((10#$2))" ;;
|
|
830
|
+
*) SPLIT_NODES="$((10#$2))" ;;
|
|
831
|
+
esac
|
|
832
|
+
shift 2 ;;
|
|
819
833
|
--dwarf) D_ANY="${2:?}"; shift 2 ;;
|
|
820
834
|
--dwarf-high) D_HI="${2:?}"; shift 2 ;;
|
|
821
835
|
--dwarf-medium) D_MD="${2:?}"; shift 2 ;;
|
|
@@ -867,12 +881,15 @@ do_plan() {
|
|
|
867
881
|
2) exit 2 ;;
|
|
868
882
|
esac
|
|
869
883
|
fi
|
|
884
|
+
forge_removed_flag "$1"
|
|
870
885
|
die "plan: unknown option '$1'"
|
|
871
886
|
;;
|
|
872
887
|
esac
|
|
873
888
|
done
|
|
874
889
|
[ -d "$PLAN" ] || die "plan dir '$PLAN' does not exist"
|
|
875
890
|
[ "$GRP_REVIEW" = 0 ] || [ "$GRP_SRC" = waves ] || die "--group-review goes with --groups waves (it sets the review of the groups waves derives)"
|
|
891
|
+
# The decomposition limits (#153): a bad value, or a change after the first run froze them, refuses the call.
|
|
892
|
+
forge_decompose_limits "$PLAN" "$SPLIT_DEPTH" "$SPLIT_CHILDREN" "$SPLIT_NODES"
|
|
876
893
|
# The profile (#48) first: its gates and budget count for every decision-model step below,
|
|
877
894
|
# and its values stand in for the flags this call did not give.
|
|
878
895
|
forge_profile_plan
|
|
@@ -970,16 +987,18 @@ do_plan() {
|
|
|
970
987
|
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
971
988
|
[ "$JEV_OPTS" = 1 ] && forge_decide_env "$REPO" "$PLAN"
|
|
972
989
|
[ -s "$PLAN/run_id" ] || basename "$PLAN" | sed 's/^forge-//' > "$PLAN/run_id"
|
|
973
|
-
# Every plan, --ui or not: forge-ui's view of this repo's runs reads the registry.
|
|
974
|
-
|
|
990
|
+
# Every plan, --ui or not: forge-ui's view of this repo's runs reads the registry. A sub-plan (#153)
|
|
991
|
+
# is reached through the plan it belongs to.
|
|
992
|
+
forge_is_sub_plan "$PLAN" || forge_ui_register "$PLAN"
|
|
975
993
|
[ "${FORGE_RIPWIRE:-}" != off ] || touch "$PLAN/no_ripwire"
|
|
976
994
|
# Persist plan choices for later run and retry processes.
|
|
977
|
-
[ "$NOMEM" = 1 ] && : > "$PLAN/no_memory"
|
|
995
|
+
{ [ "$NOMEM" = 1 ] || forge_repo_memory_off "$REPO"; } && : > "$PLAN/no_memory"
|
|
978
996
|
[ -n "$PLANNER" ] && printf '%s\n' "$PLANNER" > "$PLAN/planner"
|
|
979
|
-
|
|
997
|
+
# dwarf-routing.json; a plan made before 0.23 kept these pools under another name, read once here.
|
|
998
|
+
python3 - "$PLAN/dwarf-routing.json" "$(forge_pools_file "$PLAN")" "$D_ANY" "$D_LO" "$D_MD" "$D_HI" <<'PY'
|
|
980
999
|
import json,sys
|
|
981
1000
|
from pathlib import Path
|
|
982
|
-
p=Path(sys.argv[1]); data=json.loads(
|
|
1001
|
+
p=Path(sys.argv[1]); old=Path(sys.argv.pop(2)); data=json.loads(old.read_text()) if old.exists() else {}
|
|
983
1002
|
for key,value in zip(('any','low','medium','high'),sys.argv[2:]):
|
|
984
1003
|
if value: data[key]=[s.strip() for s in value.split(',') if s.strip()]
|
|
985
1004
|
p.write_text(json.dumps(data))
|
|
@@ -998,7 +1017,7 @@ PY
|
|
|
998
1017
|
# Uncommitted work is invisible to every dwarf, because worktrees branch from a
|
|
999
1018
|
# commit. That is the likeliest way to get a confusingly wrong result, so it is
|
|
1000
1019
|
# stated loudly rather than left for the user to deduce from an odd diff.
|
|
1001
|
-
if [ ! -s "$PLAN/after" ] && [ -z "${CHAIN_PREV:-}" ] && [ -n "$(
|
|
1020
|
+
if [ ! -s "$PLAN/after" ] && [ -z "${CHAIN_PREV:-}" ] && [ -n "$(user_tree_changes "$REPO")" ]; then
|
|
1002
1021
|
note "WARNING: '$REPO' has uncommitted changes. Task worktrees branch from HEAD,"
|
|
1003
1022
|
note " so those edits will NOT be visible to any dwarf. Commit or stash first"
|
|
1004
1023
|
note " if the tasks depend on them."
|
|
@@ -1106,8 +1125,14 @@ EOF
|
|
|
1106
1125
|
fi
|
|
1107
1126
|
fi
|
|
1108
1127
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1128
|
+
# A refused plan (a task left UNASSIGNED below) puts tasks.tsv back as it was, so nothing it
|
|
1129
|
+
# routed, such as the default reviewer, is frozen into the next plan (#178). The copy is only
|
|
1130
|
+
# made for a refusal, under one name, so an exit in between leaves at most this one file,
|
|
1131
|
+
# which the next plan removes.
|
|
1132
|
+
local tmp="$PLAN/.tasks.tsv.new" orig_tasks="$PLAN/.tasks.tsv.orig"
|
|
1133
|
+
: > "$tmp"
|
|
1134
|
+
rm -f "$orig_tasks"
|
|
1135
|
+
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 qa_kept_msg="" qa_flag_spec=""
|
|
1111
1136
|
printf '# id\tdeps\tdifficulty\tfiles\tdwarf\tqa\ttitle\n' > "$tmp"
|
|
1112
1137
|
local id deps diff files dw qa title line
|
|
1113
1138
|
while IFS= read -r line; do
|
|
@@ -1153,7 +1178,7 @@ EOF
|
|
|
1153
1178
|
if [ "$dw" != UNASSIGNED ]; then
|
|
1154
1179
|
local assigned
|
|
1155
1180
|
assigned="$(python3 "$SKILL_DIR/scripts/forge-route.py" assign --plan "$PLAN" --task "$id" \
|
|
1156
|
-
--tier "$diff" --epsilon "${EXPLORE:-0}" --default "$dw" --pools "$PLAN
|
|
1181
|
+
--tier "$diff" --epsilon "${EXPLORE:-0}" --default "$dw" --pools "$(forge_pools_file "$PLAN")" 2>/dev/null)"
|
|
1157
1182
|
[ -z "$assigned" ] || dw="$assigned"
|
|
1158
1183
|
fi
|
|
1159
1184
|
fi
|
|
@@ -1169,16 +1194,27 @@ EOF
|
|
|
1169
1194
|
if [ "$qa" = "-" ] || [ -z "$qa" ]; then
|
|
1170
1195
|
if [ -n "$Q_ANY" ]; then qa="$(pool_pick "$Q_ANY" "$qan_i")"; qan_i=$((qan_i+1)); else qa="opus"; fi
|
|
1171
1196
|
fi
|
|
1197
|
+
else
|
|
1198
|
+
qa_flag_spec=""
|
|
1199
|
+
case "$diff" in
|
|
1200
|
+
high) qa_flag_spec="${Q_HI:-$Q_ANY}" ;;
|
|
1201
|
+
medium) qa_flag_spec="${Q_MD:-$Q_ANY}" ;;
|
|
1202
|
+
low) qa_flag_spec="${Q_LO:-$Q_ANY}" ;;
|
|
1203
|
+
esac
|
|
1204
|
+
if [ -n "$qa_flag_spec" ] && ! list_has "$qa" "$qa_flag_spec"; then
|
|
1205
|
+
qa_kept_msg="${qa_kept_msg:+$qa_kept_msg, }$id ($qa)"
|
|
1206
|
+
fi
|
|
1172
1207
|
fi
|
|
1173
1208
|
# A column runs one spec; a list there would only fail later, at its first dispatch.
|
|
1174
1209
|
case "$dw" in *,*) die "task '$id': the dwarf column names one spec, not a list ('$dw'); pool models with a --dwarf flag" ;; esac
|
|
1175
1210
|
case "$qa" in *,*) die "task '$id': the qa column names one spec, not a list ('$qa'); pool reviewers with a --qa flag" ;; esac
|
|
1176
1211
|
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$id" "$deps" "$diff" "$files" "$dw" "$qa" "$title" >> "$tmp"
|
|
1177
1212
|
done < "$T"
|
|
1213
|
+
[ "$unassigned" -eq 0 ] || cp "$T" "$orig_tasks"
|
|
1178
1214
|
mv "$tmp" "$T"
|
|
1179
1215
|
# Which cells routing filled in, so a re-plan under another profile replaces those and no others.
|
|
1180
1216
|
# Kept current through a --no-profile re-plan too, once a profile has recorded any.
|
|
1181
|
-
if [ -f "$PLAN/profile.json" ] || [ -f "$PLAN/routed.json" ]; then
|
|
1217
|
+
if [ "$unassigned" -eq 0 ] && { [ -f "$PLAN/profile.json" ] || [ -f "$PLAN/routed.json" ]; }; then
|
|
1182
1218
|
forge_profile_py routed "$PLAN" 2>/dev/null || true
|
|
1183
1219
|
fi
|
|
1184
1220
|
|
|
@@ -1238,7 +1274,23 @@ EOF
|
|
|
1238
1274
|
# frozen fingerprint is of the table the run will use.
|
|
1239
1275
|
forge_groups_plan "$PLAN" "$GRP_SRC" "$GRP_REVIEW" "$GRP_MAX"
|
|
1240
1276
|
|
|
1277
|
+
# Recursive decomposition (#153), once the table is routed: the splits a planner proposed become
|
|
1278
|
+
# sub-plans within the limits, routed with this plan's pools, and every other task is recorded as
|
|
1279
|
+
# kept whole. Not for a plan that is about to be refused for an unassigned task.
|
|
1280
|
+
[ "$unassigned" -gt 0 ] || forge_decompose_settle "$PLAN"
|
|
1281
|
+
|
|
1282
|
+
# The brief each task starts from: a change after this is logged at the next dispatch (#220).
|
|
1283
|
+
local seen_id
|
|
1284
|
+
for seen_id in $(all_ids "$T"); do
|
|
1285
|
+
[ ! -d "$PLAN/tasks/$seen_id" ] || record_seen_inputs "$PLAN/tasks/$seen_id" || true
|
|
1286
|
+
done
|
|
1287
|
+
|
|
1241
1288
|
render_table "$PLAN"
|
|
1289
|
+
forge_decompose_table "$PLAN"
|
|
1290
|
+
if [ -n "$qa_kept_msg" ]; then
|
|
1291
|
+
echo "note: --qa left existing reviewer(s) unchanged on: $qa_kept_msg (set qa to '-' in tasks.tsv to let --qa fill them)"
|
|
1292
|
+
echo
|
|
1293
|
+
fi
|
|
1242
1294
|
# What the gates did, from plan-gates.json: files and deps they added, prompts and
|
|
1243
1295
|
# requirements still flagged. Prints nothing when no gate recorded anything.
|
|
1244
1296
|
python3 "$SKILL_DIR/scripts/forge-plan-check.py" gates "$PLAN" 2>/dev/null || true
|
|
@@ -1253,6 +1305,7 @@ EOF
|
|
|
1253
1305
|
forge_ui_launch "$PLAN"
|
|
1254
1306
|
|
|
1255
1307
|
if [ "$unassigned" -gt 0 ]; then
|
|
1308
|
+
mv -f "$orig_tasks" "$T"
|
|
1256
1309
|
note ""
|
|
1257
1310
|
note "$unassigned task(s) are UNASSIGNED: their difficulty tier has no --dwarf-<tier>"
|
|
1258
1311
|
note "rule and there is no plain --dwarf fallback. Assign them before running —"
|
|
@@ -1317,6 +1370,13 @@ try:
|
|
|
1317
1370
|
n = open(plan + '/retry_per_model', encoding='utf-8').read().strip()
|
|
1318
1371
|
except OSError:
|
|
1319
1372
|
sys.exit(0)
|
|
1373
|
+
# The scheduler and forge-route.py read only 1-99 and treat anything else as no file (#158): a
|
|
1374
|
+
# hand-edited value is named as ignored, never shown as the setting with a worst case that assumes it.
|
|
1375
|
+
if not re.fullmatch(r'[0-9]{1,9}', n) or not 1 <= int(n) <= 99:
|
|
1376
|
+
print('retry per model: ignored, %s holds %r and not a number from 1 to 99; the run uses --escalate-after '
|
|
1377
|
+
'(plan --retry-per-model N sets it, --no-retry-per-model removes the file)' % (plan + '/retry_per_model', n[:40]))
|
|
1378
|
+
sys.exit(0)
|
|
1379
|
+
n = str(int(n))
|
|
1320
1380
|
print('retry per model: %s (a task may fail %s times on each model the retry policy gives it, then it moves a rung up)' % (n, n))
|
|
1321
1381
|
try:
|
|
1322
1382
|
raw = subprocess.check_output([sys.executable, route, 'worst-case', '--plan', plan], text=True)
|
|
@@ -1428,27 +1488,34 @@ EOF
|
|
|
1428
1488
|
echo "QA effort: high where a reviewer spec names none (forge-dispatch.sh's default; planning stays at xhigh)"
|
|
1429
1489
|
fi
|
|
1430
1490
|
echo
|
|
1431
|
-
local w id dws starred=0
|
|
1491
|
+
local w id dws starred=0 id_w pad
|
|
1492
|
+
id_w="$(id_col_width "$T")"
|
|
1493
|
+
printf -v pad '%*s' $((id_w + 3)) ''
|
|
1432
1494
|
for w in $(awk -F'\t' '{print $1}' "$W" | sort -un); do
|
|
1433
1495
|
local cnt; cnt="$(awk -F'\t' -v w="$w" '$1==w' "$W" | wc -l | tr -d ' ')"
|
|
1434
1496
|
echo "wave $w ($cnt parallel)"
|
|
1435
|
-
printf '
|
|
1497
|
+
printf ' %-*s %-7s %-24s %-14s %s\n' "$id_w" id diff dwarf qa files
|
|
1436
1498
|
for id in $(awk -F'\t' -v w="$w" '$1==w {print $2}' "$W"); do
|
|
1437
1499
|
dws="$(field "$T" "$id" dwarf)"
|
|
1438
1500
|
if [ -s "$PLAN/tasks/$id/route.explored" ] && [ "$(cat "$PLAN/tasks/$id/route.explored")" = "$dws" ]; then
|
|
1439
1501
|
dws="$dws*"; starred=1
|
|
1440
1502
|
fi
|
|
1441
|
-
printf '
|
|
1442
|
-
"$id" "$(field "$T" "$id" difficulty)" "$dws" \
|
|
1503
|
+
printf ' %-*s %-7s %-24s %-14s %s\n' \
|
|
1504
|
+
"$id_w" "$id" "$(field "$T" "$id" difficulty)" "$dws" \
|
|
1443
1505
|
"$(field "$T" "$id" qa)" "$(field "$T" "$id" files)"
|
|
1444
1506
|
# The approach is shown here because this gate is the only moment a human can
|
|
1445
1507
|
# change the plan for free. After dispatch, changing it costs a whole run.
|
|
1446
1508
|
if [ -s "$PLAN/tasks/$id/approach.md" ]; then
|
|
1447
|
-
sed
|
|
1509
|
+
sed "s/^/${pad}| /" "$PLAN/tasks/$id/approach.md"
|
|
1448
1510
|
fi
|
|
1449
1511
|
done
|
|
1450
1512
|
echo
|
|
1451
1513
|
done
|
|
1514
|
+
# The model each spec runs today (#187): an alias moves to newer models over time, so the
|
|
1515
|
+
# table says which version `sol` or `astra` is before anything is spent.
|
|
1516
|
+
local models_block
|
|
1517
|
+
models_block="$(python3 "$SKILL_DIR/scripts/forge_models.py" legend "$T" 2>/dev/null)" || models_block=""
|
|
1518
|
+
[ -z "$models_block" ] || printf '%s\n\n' "$models_block"
|
|
1452
1519
|
render_groups "$PLAN"
|
|
1453
1520
|
# A chain collapsed on this call, or a chain left as a chain. one and branches say nothing.
|
|
1454
1521
|
# COLLAPSED_NOW is do_plan's: collapsed.json from an earlier plan is not announced again.
|
|
@@ -1557,7 +1624,7 @@ except Exception:
|
|
|
1557
1624
|
for tier in ("low", "any"):
|
|
1558
1625
|
specs = data.get(tier) if isinstance(data, dict) else None
|
|
1559
1626
|
if isinstance(specs, list) and specs and isinstance(specs[0], str) and specs[0]:
|
|
1560
|
-
print(specs[0]); break' "$1
|
|
1627
|
+
print(specs[0]); break' "$(forge_pools_file "$1")" 2>/dev/null)"
|
|
1561
1628
|
[ -n "$spec" ] || return 0
|
|
1562
1629
|
[ -f "$1/yolo_dwarf" ] && flags=--yolo
|
|
1563
1630
|
ft="$(forge_fast_tier "$1" dwarf)"
|
|
@@ -1593,12 +1660,14 @@ write_capsule() { # write_capsule <plan> <id> <role>
|
|
|
1593
1660
|
echo "Files this task owns: $(field "$T" "$me" files)"
|
|
1594
1661
|
echo
|
|
1595
1662
|
echo "## Run status"
|
|
1596
|
-
|
|
1663
|
+
local id_w
|
|
1664
|
+
id_w="$(id_col_width "$T")"
|
|
1665
|
+
printf '%-*s %-7s %-11s %s\n' "$id_w" id diff status files
|
|
1597
1666
|
for id in $(all_ids "$T"); do
|
|
1598
1667
|
if [ "$id" = "$me" ]; then st="THIS ONE"
|
|
1599
1668
|
elif [ -s "$PLAN/tasks/$id/reviewed.commit" ] && git -C "$(cat "$PLAN/repo")" merge-base --is-ancestor "$(cat "$PLAN/tasks/$id/reviewed.commit")" "$(cat "$PLAN/tasks/$me/base_ref")"; then st=MERGED
|
|
1600
1669
|
else st="NOT IN BASE"; fi
|
|
1601
|
-
printf '
|
|
1670
|
+
printf '%-*s %-7s %-11s %s\n' "$id_w" "$id" "$(field "$T" "$id" difficulty)" "$st" "$(field "$T" "$id" files)"
|
|
1602
1671
|
done
|
|
1603
1672
|
echo
|
|
1604
1673
|
echo "## Ground rules"
|
|
@@ -1675,17 +1744,24 @@ populate_submodules() { # populate_submodules <repo> <wt> <tdir> <id>
|
|
|
1675
1744
|
# work in — it just has to install things itself, which is the status quo this exists
|
|
1676
1745
|
# to improve on. Failing the task instead would turn a slow run into a dead one.
|
|
1677
1746
|
run_worktree_setup() { # run_worktree_setup <plan> <repo> <wt> <tdir> <id>
|
|
1678
|
-
local PLAN="$1" REPO="$2" wt="$3" tdir="$4" id="$5" cmd
|
|
1747
|
+
local PLAN="$1" REPO="$2" wt="$3" tdir="$4" id="$5" cmd before_ignored=""
|
|
1679
1748
|
# Every worktree forge makes reaches here once, right after it exists, so the submodules'
|
|
1680
1749
|
# files are in place before `.forge/setup` runs. The outcome lands in <tdir>/submodules.txt.
|
|
1681
1750
|
populate_submodules "$REPO" "$wt" "$tdir" "$id"
|
|
1682
1751
|
cmd="$(worktree_setup_command "$PLAN" "$REPO")"
|
|
1683
1752
|
[ -n "$cmd" ] || return 0
|
|
1753
|
+
before_ignored="$(mktemp "${TMPDIR:-/tmp}/forge-setup-ignored.XXXXXX" 2>/dev/null || true)"
|
|
1754
|
+
[ -z "$before_ignored" ] || forge_capture_ignored_before "$wt" "$before_ignored"
|
|
1684
1755
|
if (cd "$wt" && eval "$cmd") >"$tdir/setup.out" 2>&1; then
|
|
1685
1756
|
note "$id: worktree setup ok"
|
|
1757
|
+
python3 "$SKILL_DIR/scripts/forge-setup-stale.py" record-commit "$wt" --out "$tdir/setup.commit" 2>/dev/null || true
|
|
1686
1758
|
else
|
|
1687
1759
|
note "$id: worktree setup failed (continuing) — see $tdir/setup.out"
|
|
1688
1760
|
fi
|
|
1761
|
+
if [ -n "$before_ignored" ]; then
|
|
1762
|
+
forge_record_setup_generated "$wt" "$before_ignored"
|
|
1763
|
+
rm -f "$before_ignored"
|
|
1764
|
+
fi
|
|
1689
1765
|
}
|
|
1690
1766
|
|
|
1691
1767
|
add_task_worktree() { # add_task_worktree <repo> <wt> <br> <base>: on <br> when it exists, else a new <br> at <base>
|
|
@@ -1723,6 +1799,24 @@ dispatch_duration() { # dispatch_duration <tdir> <role>
|
|
|
1723
1799
|
#
|
|
1724
1800
|
# A warning, never a failure: a dwarf that genuinely had to touch one more file did
|
|
1725
1801
|
# the right thing, and failing the task for it would be worse than reporting it.
|
|
1802
|
+
# The run summary's scope drift of one task, on one line (#220): a path the task's current brief names
|
|
1803
|
+
# (prompt.md or approach.md, as a person may have added it mid-run) is marked as such, apart from paths
|
|
1804
|
+
# nothing explains.
|
|
1805
|
+
drift_labelled() { # drift_labelled <tdir>
|
|
1806
|
+
local tdir="$1" f out="" brief=()
|
|
1807
|
+
[ ! -f "$tdir/prompt.md" ] || brief+=("$tdir/prompt.md")
|
|
1808
|
+
[ ! -f "$tdir/approach.md" ] || brief+=("$tdir/approach.md")
|
|
1809
|
+
while IFS= read -r f; do
|
|
1810
|
+
[ -n "$f" ] || continue
|
|
1811
|
+
if [ "${#brief[@]}" -gt 0 ] && grep -qF -- "$f" "${brief[@]}" 2>/dev/null; then
|
|
1812
|
+
out="${out:+$out }$f (named in the brief)"
|
|
1813
|
+
else
|
|
1814
|
+
out="${out:+$out }$f"
|
|
1815
|
+
fi
|
|
1816
|
+
done < "$tdir/drift.txt"
|
|
1817
|
+
printf '%s' "$out"
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1726
1820
|
check_drift() { # check_drift <declared-comma-list> <tdir> <wt> <base>
|
|
1727
1821
|
local declared="$1" tdir="$2" wt="$3" base="$4" touched f d covered
|
|
1728
1822
|
: > "$tdir/drift.txt"
|
|
@@ -1787,11 +1881,96 @@ record_dispatched_inputs() { # record_dispatched_inputs <tdir>
|
|
|
1787
1881
|
done
|
|
1788
1882
|
}
|
|
1789
1883
|
|
|
1884
|
+
# The brief forge last accounted for (#220): prompt.md and approach.md as `plan` left them, then as each
|
|
1885
|
+
# change to them was logged (at a dispatch, or by a STALE check). prompt.seen is written last.
|
|
1886
|
+
record_seen_inputs() { # record_seen_inputs <tdir>
|
|
1887
|
+
local tdir="$1" f tmp
|
|
1888
|
+
for f in approach prompt; do
|
|
1889
|
+
tmp="$tdir/.$f.seen.tmp"
|
|
1890
|
+
if [ -f "$tdir/$f.md" ]; then cp "$tdir/$f.md" "$tmp" || { rm -f "$tmp"; return 1; }
|
|
1891
|
+
else : > "$tmp" || return 1; fi
|
|
1892
|
+
mv "$tmp" "$tdir/$f.seen" || { rm -f "$tmp"; return 1; }
|
|
1893
|
+
done
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
# One control.log entry for a change to a task's brief: actor scheduler, action prompt-changed, the attempt,
|
|
1897
|
+
# the files and when forge saw it (`during`: attempt, review or dispatch).
|
|
1898
|
+
audit_brief_change() { # audit_brief_change <plan> <id> <attempt> <during> <file>...
|
|
1899
|
+
python3 - "$SKILL_DIR/scripts/forge-control.py" "$@" <<'PY' 2>/dev/null || note "$2: control.log not updated with the brief change"
|
|
1900
|
+
import importlib.util, sys
|
|
1901
|
+
from pathlib import Path
|
|
1902
|
+
spec = importlib.util.spec_from_file_location('forge_control', sys.argv[1])
|
|
1903
|
+
module = importlib.util.module_from_spec(spec)
|
|
1904
|
+
sys.modules['forge_control'] = module
|
|
1905
|
+
spec.loader.exec_module(module)
|
|
1906
|
+
module.audit(Path(sys.argv[2]), 'scheduler', 'prompt-changed', sys.argv[3], 'prompt', int(sys.argv[4]), None,
|
|
1907
|
+
files=sys.argv[6:], during=sys.argv[5])
|
|
1908
|
+
PY
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
# At dispatch (#220): a brief edited since forge last saw it (between attempts, while the task waited for
|
|
1912
|
+
# a decision or its dependencies, or before its first dispatch) gets its control.log entry now, and its
|
|
1913
|
+
# diff in brief.diff, so every change after `plan` is on record. The baseline is prompt.seen, else the
|
|
1914
|
+
# previous attempt's prompt.dispatched; with neither (a plan from before #220) there is nothing to compare.
|
|
1915
|
+
audit_brief_at_dispatch() { # audit_brief_at_dispatch <plan> <id> <tdir> <attempt>
|
|
1916
|
+
local PLAN="$1" id="$2" tdir="$3" attempt="$4" f cur old ext=seen changed=() tmp="$3/.brief.diff.tmp"
|
|
1917
|
+
[ -f "$tdir/prompt.seen" ] || ext=dispatched
|
|
1918
|
+
[ -f "$tdir/prompt.$ext" ] || { record_seen_inputs "$tdir" || true; return 0; }
|
|
1919
|
+
: > "$tmp" || return 0
|
|
1920
|
+
for f in prompt approach; do
|
|
1921
|
+
cur="$tdir/$f.md"; [ -f "$cur" ] || cur=/dev/null
|
|
1922
|
+
old="$tdir/$f.$ext"; [ -f "$old" ] || old=/dev/null
|
|
1923
|
+
cmp -s "$old" "$cur" && continue
|
|
1924
|
+
changed+=("$f.md")
|
|
1925
|
+
diff -u --label "$f.md (as forge last saw it)" --label "$f.md (attempt $attempt)" "$old" "$cur" >> "$tmp" || true
|
|
1926
|
+
done
|
|
1927
|
+
if [ "${#changed[@]}" -gt 0 ]; then
|
|
1928
|
+
mv "$tmp" "$tdir/brief.diff" || rm -f "$tmp"
|
|
1929
|
+
audit_brief_change "$PLAN" "$id" "$attempt" dispatch "${changed[@]}"
|
|
1930
|
+
note "$id: its brief changed since forge last saw it (${changed[*]}); attempt $attempt gets the new text (see $tdir/brief.diff)"
|
|
1931
|
+
else
|
|
1932
|
+
rm -f "$tmp"
|
|
1933
|
+
fi
|
|
1934
|
+
record_seen_inputs "$tdir" || true
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
# Brief inputs the last completed review judged (#209), written in reverse order so
|
|
1938
|
+
# prompt.reviewed's presence marks the snapshot complete.
|
|
1939
|
+
record_reviewed_inputs() { # record_reviewed_inputs <tdir> <thr>
|
|
1940
|
+
local tdir="$1" thr="${2:-}" f tmp
|
|
1941
|
+
tmp="$tdir/.approach.reviewed.tmp"
|
|
1942
|
+
if [ -f "$tdir/approach.md" ]; then cp "$tdir/approach.md" "$tmp" || { rm -f "$tmp"; return 1; }
|
|
1943
|
+
else : > "$tmp" || return 1; fi
|
|
1944
|
+
mv "$tmp" "$tdir/approach.reviewed" || { rm -f "$tmp"; return 1; }
|
|
1945
|
+
tmp="$tdir/.qa.reviewed.threshold.tmp"
|
|
1946
|
+
printf '%s\n' "$thr" > "$tmp" && mv "$tmp" "$tdir/qa.reviewed.threshold" || { rm -f "$tmp"; return 1; }
|
|
1947
|
+
tmp="$tdir/.prompt.reviewed.tmp"
|
|
1948
|
+
if [ -f "$tdir/prompt.md" ]; then cp "$tdir/prompt.md" "$tmp" || { rm -f "$tmp"; return 1; }
|
|
1949
|
+
else : > "$tmp" || return 1; fi
|
|
1950
|
+
mv "$tmp" "$tdir/prompt.reviewed" || { rm -f "$tmp"; return 1; }
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
brief_changed_since_review() { # brief_changed_since_review <tdir> <thr> -> 0 when changed
|
|
1954
|
+
local tdir="$1" thr="${2:-}" f cur
|
|
1955
|
+
[ -f "$tdir/prompt.reviewed" ] || return 1
|
|
1956
|
+
for f in prompt approach; do
|
|
1957
|
+
cur="$tdir/$f.md"; [ -f "$cur" ] || cur=/dev/null
|
|
1958
|
+
cmp -s "$tdir/$f.reviewed" "$cur" || return 0
|
|
1959
|
+
done
|
|
1960
|
+
if [ -f "$tdir/qa.reviewed.threshold" ]; then
|
|
1961
|
+
[ "$(cat "$tdir/qa.reviewed.threshold" 2>/dev/null)" = "$thr" ] || return 0
|
|
1962
|
+
fi
|
|
1963
|
+
return 1
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1790
1966
|
# Whether the planner edited prompt.md or approach.md while the attempt ran (#150). Returns 0 when it did:
|
|
1791
1967
|
# the attempt is then STALE, written to stale.diff and control.log, and the caller stops before any review.
|
|
1792
1968
|
# Returns 1 when nothing changed, or when the attempt predates the .dispatched copies (no check possible).
|
|
1793
|
-
|
|
1794
|
-
|
|
1969
|
+
# With `review` (#212) the check runs after the review instead: an edit made while the reviewer worked means
|
|
1970
|
+
# its verdict judged the old text, so it does not count. The finished review is kept as qa.stale.last for the
|
|
1971
|
+
# next attempt to read, and the attempt is STALE all the same.
|
|
1972
|
+
prompt_drifted() { # prompt_drifted <plan> <id> <tdir> <attempt> [attempt|review]
|
|
1973
|
+
local PLAN="$1" id="$2" tdir="$3" attempt="$4" during="${5:-attempt}" f cur old changed=() tmp="$3/.stale.diff.tmp" what
|
|
1795
1974
|
[ -f "$tdir/prompt.dispatched" ] || return 1
|
|
1796
1975
|
: > "$tmp" || return 1
|
|
1797
1976
|
for f in prompt approach; do
|
|
@@ -1803,19 +1982,17 @@ prompt_drifted() { # prompt_drifted <plan> <id> <tdir> <attempt>
|
|
|
1803
1982
|
done
|
|
1804
1983
|
if [ "${#changed[@]}" -eq 0 ]; then rm -f "$tmp" "$tdir/stale.diff"; return 1; fi
|
|
1805
1984
|
mv "$tmp" "$tdir/stale.diff" || rm -f "$tmp"
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
from pathlib import Path
|
|
1810
|
-
spec = importlib.util.spec_from_file_location('forge_control', sys.argv[1])
|
|
1811
|
-
module = importlib.util.module_from_spec(spec)
|
|
1812
|
-
sys.modules['forge_control'] = module
|
|
1813
|
-
spec.loader.exec_module(module)
|
|
1814
|
-
module.audit(Path(sys.argv[2]), 'scheduler', 'prompt-changed', sys.argv[3], 'prompt', int(sys.argv[4]), None,
|
|
1815
|
-
files=sys.argv[5:])
|
|
1816
|
-
PY
|
|
1985
|
+
audit_brief_change "$PLAN" "$id" "$attempt" "$during" "${changed[@]}"
|
|
1986
|
+
# Logged once: the dispatch that follows compares with this, not with the attempt's copy (#220).
|
|
1987
|
+
record_seen_inputs "$tdir" || true
|
|
1817
1988
|
what="${changed[0]}"; [ "${#changed[@]}" -eq 1 ] || what="${changed[0]} and ${changed[1]}"
|
|
1818
|
-
|
|
1989
|
+
if [ "$during" = review ]; then
|
|
1990
|
+
rm -f "$tdir/qa.stale.last"
|
|
1991
|
+
[ ! -f "$tdir/qa.last" ] || mv -f "$tdir/qa.last" "$tdir/qa.stale.last"
|
|
1992
|
+
note "$id: $what changed during the review of attempt $attempt — its verdict does not count; the implementer gets the new text and the review's findings (no attempt spent)"
|
|
1993
|
+
else
|
|
1994
|
+
note "$id: $what changed during attempt $attempt — not reviewed; the implementer gets the new text (no attempt spent)"
|
|
1995
|
+
fi
|
|
1819
1996
|
echo STALE > "$tdir/status"
|
|
1820
1997
|
# The implementer has to run again, so a saved QA-only resume of this attempt no longer applies.
|
|
1821
1998
|
rm -f "$tdir/resume"
|
|
@@ -1921,10 +2098,6 @@ do_task_body() (
|
|
|
1921
2098
|
local reviewed review source_fp review_fp
|
|
1922
2099
|
REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"
|
|
1923
2100
|
tdir="$PLAN/tasks/$id"; mkdir -p "$tdir"
|
|
1924
|
-
if [ -s "$PLAN/fractal-selection.json" ]; then
|
|
1925
|
-
forge_fractal_select "$PLAN" "$REPO" parallel 0 || return $?
|
|
1926
|
-
fi
|
|
1927
|
-
forge_fast_fractal_note "$PLAN"
|
|
1928
2101
|
forge_metric_begin "$tdir" task
|
|
1929
2102
|
dependencies_ready "$PLAN" "$id" || return 1
|
|
1930
2103
|
echo RUNNING > "$tdir/status"
|
|
@@ -1976,7 +2149,7 @@ do_task_body() (
|
|
|
1976
2149
|
base="$(git -C "$(cat "$PLAN/wt_root")/_integration" rev-parse HEAD)"; printf '%s\n' "$base" > "$tdir/base_ref"
|
|
1977
2150
|
fi
|
|
1978
2151
|
|
|
1979
|
-
local dw qa yd yq rc ft_dwarf ft_qa
|
|
2152
|
+
local dw qa yd yq rc ft_dwarf ft_qa qa_thr
|
|
1980
2153
|
dw="$(field "$T" "$id" dwarf)"; qa="$(field "$T" "$id" qa)"
|
|
1981
2154
|
yd=""; yq=""
|
|
1982
2155
|
[ -f "$PLAN/yolo_dwarf" ] && yd="--yolo"
|
|
@@ -1984,6 +2157,8 @@ do_task_body() (
|
|
|
1984
2157
|
# Empty when the role is not listed, so the recorded command line is unchanged.
|
|
1985
2158
|
ft_dwarf="$(forge_fast_tier "$PLAN" dwarf)"
|
|
1986
2159
|
ft_qa="$(forge_fast_tier "$PLAN" qa)"
|
|
2160
|
+
# Read once per attempt: governs brief-change re-review (#209), the QA prompt, and qa_gate.
|
|
2161
|
+
qa_thr="$(qa_threshold_for "$PLAN" "$id")"
|
|
1987
2162
|
|
|
1988
2163
|
if ! ensure_worktree "$REPO" "$wt" "$br" "$base" "$tdir" "$PLAN" "$id"; then
|
|
1989
2164
|
echo ERROR > "$tdir/status"
|
|
@@ -1991,12 +2166,21 @@ do_task_body() (
|
|
|
1991
2166
|
return 1
|
|
1992
2167
|
fi
|
|
1993
2168
|
|
|
1994
|
-
local is_script=0
|
|
2169
|
+
local is_script=0 is_split=0
|
|
1995
2170
|
task_is_script "$PLAN" "$id" && is_script=1
|
|
2171
|
+
# A split task (#153) whose subtasks are not on its branch yet runs them here, where a model task
|
|
2172
|
+
# runs its implementer. Once they are (sub.merged), a retry is an ordinary one: its implementer
|
|
2173
|
+
# fixes the review's findings in the combined work, and no subtask runs twice.
|
|
2174
|
+
if forge_split_open "$PLAN" "$id"; then
|
|
2175
|
+
is_split=1
|
|
2176
|
+
if [ -n "$resume" ]; then resume=""; rm -f "$tdir/resume"; attempt=$(( attempt + 1 )); echo "$attempt" > "$tdir/attempt"; fi
|
|
2177
|
+
fi
|
|
1996
2178
|
if [ -z "$resume" ]; then
|
|
1997
2179
|
# Persist each source separately; QA receives complete context once.
|
|
1998
2180
|
write_capsule "$PLAN" "$id" dwarf >/dev/null
|
|
1999
2181
|
cp "$tdir/capsule.md" "$tdir/baseline.capsule"
|
|
2182
|
+
# A brief edited since forge last saw it is logged now, whenever the edit landed (#220).
|
|
2183
|
+
audit_brief_at_dispatch "$PLAN" "$id" "$tdir" "$attempt"
|
|
2000
2184
|
# What this attempt's implementer is given, to tell later whether the planner edited it (#150).
|
|
2001
2185
|
record_dispatched_inputs "$tdir" || { rm -f "$tdir/prompt.dispatched"; note "$id: could not record the dispatched prompt; a later edit will not be detected"; }
|
|
2002
2186
|
if [ "$is_script" = 1 ]; then
|
|
@@ -2005,21 +2189,30 @@ do_task_body() (
|
|
|
2005
2189
|
forge_metric_phase dispatch
|
|
2006
2190
|
run_script_task "$PLAN" "$id" "$tdir" "$wt" "$base" || return 1
|
|
2007
2191
|
fi
|
|
2192
|
+
if [ "$is_split" = 1 ]; then
|
|
2193
|
+
# The subtasks run as a plan of their own and merge into this task's branch. The snapshot and
|
|
2194
|
+
# everything after it are the same: one commit, then the review of the cumulative diff.
|
|
2195
|
+
forge_metric_phase dispatch
|
|
2196
|
+
run_split_task "$PLAN" "$id" "$tdir" "$wt" "$base" "$attempt" || return 1
|
|
2197
|
+
fi
|
|
2008
2198
|
# The implementer's part, from here to the snapshot, belongs to model tasks only (no reindent, to
|
|
2009
2199
|
# keep the diff of this section readable).
|
|
2010
|
-
if [ "$is_script" != 1 ]; then
|
|
2200
|
+
if [ "$is_script" != 1 ] && [ "$is_split" != 1 ]; then
|
|
2011
2201
|
# --task lets Jev narrow the injected slice to facts that bear on THIS task. Without
|
|
2012
2202
|
# it, or with Jev off, the full role slice is injected exactly as before.
|
|
2013
2203
|
/bin/bash "$MEMORY" inject "$REPO" dwarf --task "$tdir/prompt.md" \
|
|
2014
2204
|
--run-dir "$tdir" > "$tdir/dwarf.memory"
|
|
2205
|
+
# The messages queued for this task's next attempt (forge control steer, #134) are this attempt's.
|
|
2206
|
+
steer_take "$PLAN" "$id" "$attempt"
|
|
2015
2207
|
{
|
|
2016
2208
|
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"
|
|
2209
|
+
steer_section "$tdir" "$attempt" dwarf
|
|
2017
2210
|
[ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role dwarf 2>/dev/null
|
|
2018
2211
|
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."
|
|
2019
2212
|
echo "On retry, fix the findings in the existing work; preserve parts not criticised. Explain any finding you reject."
|
|
2020
|
-
# With repository verification configured, the whole suite runs
|
|
2213
|
+
# With repository verification configured, the whole suite runs once at the end of the run, never per attempt.
|
|
2021
2214
|
echo; python3 "$SKILL_DIR/scripts/forge-contract.py" dwarf $([ ! -f "$PLAN/pre_review_tests" ] || echo --pre-review) \
|
|
2022
|
-
$([ -z "$(verify_source_for "$PLAN" "$REPO")" ] || echo --verify-after-merge)
|
|
2215
|
+
$([ -z "$(verify_source_for "$PLAN" "$REPO" "$(cat "$PLAN/wt_root" 2>/dev/null)/_integration")" ] || echo --verify-after-merge)
|
|
2023
2216
|
echo; /bin/bash "$MEMORY" note dwarf
|
|
2024
2217
|
# Last, after the memory note. Nothing is printed when retro is off.
|
|
2025
2218
|
forge_retro_prompt "$PLAN" dwarf
|
|
@@ -2033,9 +2226,7 @@ do_task_body() (
|
|
|
2033
2226
|
# dispatch, and nothing here can abort the attempt: a doctor that fails means fresh.
|
|
2034
2227
|
local is_mode=fresh is_reason="" is_id="" is_fp="" is_cont=()
|
|
2035
2228
|
if [ -f "$PLAN/implementer_session" ]; then
|
|
2036
|
-
if [
|
|
2037
|
-
is_reason=fractal
|
|
2038
|
-
elif [ "$attempt" = 1 ]; then
|
|
2229
|
+
if [ "$attempt" = 1 ]; then
|
|
2039
2230
|
is_reason=first-attempt
|
|
2040
2231
|
elif [ ! -s "$tdir/retry_findings.md" ]; then
|
|
2041
2232
|
is_reason=no-findings
|
|
@@ -2054,7 +2245,8 @@ do_task_body() (
|
|
|
2054
2245
|
fi
|
|
2055
2246
|
forge_metric_phase dispatch
|
|
2056
2247
|
local dwarf_cmd=(/bin/bash "$DISPATCH" dwarf "$dw" --repo "$wt" --run-dir "$tdir" \
|
|
2057
|
-
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" ${yd:+"$yd"} $ft_dwarf --output "${FORGE_OUTPUT:-summary}"
|
|
2248
|
+
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" ${yd:+"$yd"} $ft_dwarf --output "${FORGE_OUTPUT:-summary}" \
|
|
2249
|
+
--steer "$PLAN" "$id" "$attempt")
|
|
2058
2250
|
"${dwarf_cmd[@]}" ${is_cont[@]+"${is_cont[@]}"} >"$tdir/dwarf.out" 2>&1
|
|
2059
2251
|
rc=$?
|
|
2060
2252
|
if [ "$rc" = 9 ] && [ "$is_mode" = continued ]; then
|
|
@@ -2119,9 +2311,7 @@ do_task_body() (
|
|
|
2119
2311
|
# .forge/ is forge's own memory, rewritten in the user's tree after every run.
|
|
2120
2312
|
# Left in, it would reach QA as if a dwarf had written it, and any task whose
|
|
2121
2313
|
# files touched it would collide with every other task in the wave planner.
|
|
2122
|
-
|
|
2123
|
-
[ -s "$tdir/changes.diff" ] && mv "$tdir/changes.diff" "$tdir/changes.prev.diff"
|
|
2124
|
-
fi
|
|
2314
|
+
[ -s "$tdir/changes.diff" ] && mv "$tdir/changes.diff" "$tdir/changes.prev.diff"
|
|
2125
2315
|
(cd "$wt" && git add -A -- . ":(exclude).forge" \
|
|
2126
2316
|
&& git diff --cached --binary "$base" -- . ":(exclude).forge") > "$tdir/changes.diff" 2>/dev/null || { echo ERROR > "$tdir/status"; return 1; }
|
|
2127
2317
|
if [ ! -s "$tdir/changes.diff" ]; then
|
|
@@ -2138,23 +2328,31 @@ do_task_body() (
|
|
|
2138
2328
|
echo "The script produced no changes." > "$tdir/qa.last"
|
|
2139
2329
|
note "$id: the script produced an empty diff"; return 1
|
|
2140
2330
|
fi
|
|
2331
|
+
if [ "$is_split" = 1 ]; then
|
|
2332
|
+
echo "The subtasks produced no changes at all." > "$tdir/qa.last"
|
|
2333
|
+
note "$id: its subtasks produced an empty diff"; return 1
|
|
2334
|
+
fi
|
|
2141
2335
|
echo "The dwarf produced no changes at all." > "$tdir/qa.last"
|
|
2142
2336
|
note "$id: dwarf produced an empty diff"; return 1
|
|
2143
2337
|
fi
|
|
2144
2338
|
# A bounced attempt (retry_findings.source `bounce`) was never reviewed, so a retry that keeps
|
|
2145
2339
|
# its code is reviewed rather than refused as identical: the refusal is for a diff a review
|
|
2146
|
-
# already judged.
|
|
2340
|
+
# already judged. The same applies when the brief or threshold changed since that review (#209).
|
|
2147
2341
|
if [ -s "$tdir/changes.prev.diff" ] && cmp -s "$tdir/changes.diff" "$tdir/changes.prev.diff" \
|
|
2148
|
-
&& [ "$(cat "$tdir/retry_findings.source" 2>/dev/null)" != bounce ]; then
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2342
|
+
&& [ "$is_split" != 1 ] && [ "$(cat "$tdir/retry_findings.source" 2>/dev/null)" != bounce ]; then
|
|
2343
|
+
if brief_changed_since_review "$tdir" "$qa_thr"; then
|
|
2344
|
+
note "$id: brief changed since the last review — reviewing the unchanged diff against the updated brief"
|
|
2345
|
+
else
|
|
2346
|
+
# A retry its CLI cancelled before it changed anything did not keep the code on purpose.
|
|
2347
|
+
if grep -qx 'class=cancelled' "$tdir/dwarf.infra" 2>/dev/null; then
|
|
2348
|
+
infra_stop "$tdir" "$id" dwarf "$attempt"; return 8
|
|
2349
|
+
fi
|
|
2350
|
+
echo FAIL > "$tdir/status"
|
|
2351
|
+
: > "$tdir/noretry"
|
|
2352
|
+
echo "The retry changed nothing: the diff is byte-identical to the previous attempt." \
|
|
2353
|
+
> "$tdir/qa.last"
|
|
2354
|
+
note "$id: retry produced no new changes — not re-reviewing identical code"; return 1
|
|
2152
2355
|
fi
|
|
2153
|
-
echo FAIL > "$tdir/status"
|
|
2154
|
-
: > "$tdir/noretry"
|
|
2155
|
-
echo "The retry changed nothing: the diff is byte-identical to the previous attempt." \
|
|
2156
|
-
> "$tdir/qa.last"
|
|
2157
|
-
note "$id: retry produced no new changes — not re-reviewing identical code"; return 1
|
|
2158
2356
|
fi
|
|
2159
2357
|
|
|
2160
2358
|
if ! git -C "$wt" diff --cached --quiet "$base" -- .forge; then
|
|
@@ -2166,7 +2364,7 @@ do_task_body() (
|
|
|
2166
2364
|
fi
|
|
2167
2365
|
|
|
2168
2366
|
(cd "$wt" && git -c user.name=forge -c user.email=forge@local \
|
|
2169
|
-
commit --allow-empty -q -m "forge($id) attempt $attempt: $(field "$T" "$id" title)$([ "$is_script" != 1 ] || echo ' (script)')") >/dev/null 2>&1 || {
|
|
2367
|
+
commit --allow-empty -q -m "forge($id) attempt $attempt: $(field "$T" "$id" title)$([ "$is_script" != 1 ] || echo ' (script)')$([ "$is_split" != 1 ] || echo ' (subtasks)')") >/dev/null 2>&1 || {
|
|
2170
2368
|
echo ERROR > "$tdir/status"; return 1;
|
|
2171
2369
|
}
|
|
2172
2370
|
reviewed="$(git -C "$wt" rev-parse HEAD)" || return 1
|
|
@@ -2224,6 +2422,7 @@ do_task_body() (
|
|
|
2224
2422
|
FORGE_REVIEW_SNAPSHOT="$review" # forge_metric_begin's EXIT trap removes it, whatever the outcome
|
|
2225
2423
|
forge_review_snapshot "$wt" "$base" "$reviewed" "$review" || { echo ERROR > "$tdir/status"; return 1; }
|
|
2226
2424
|
forge_review_deps "$wt" "$review" "$tdir/review.deps"
|
|
2425
|
+
forge_review_submodules "$wt" "$review" "$tdir/review.deps"
|
|
2227
2426
|
source_fp="$(forge_fingerprint "$wt")" || return 1
|
|
2228
2427
|
# The review copy is a commit: an untracked file the reviewer leaves there (a test run's
|
|
2229
2428
|
# bytecode) changes nothing that merges, so only tracked content counts (#95).
|
|
@@ -2232,8 +2431,7 @@ do_task_body() (
|
|
|
2232
2431
|
echo "$review_fp" > "$tdir/review.fingerprint"
|
|
2233
2432
|
|
|
2234
2433
|
forge_metric_phase preparation
|
|
2235
|
-
local
|
|
2236
|
-
qa_thr="$(qa_threshold_for "$PLAN" "$id")"
|
|
2434
|
+
local rs_on=0
|
|
2237
2435
|
# Read once per round, like the threshold: continuing the earlier reviewer's session is an
|
|
2238
2436
|
# opt-in experiment (plan --reviewer-session), and a round never changes its mind midway.
|
|
2239
2437
|
[ -f "$PLAN/reviewer_session" ] && rs_on=1
|
|
@@ -2253,23 +2451,17 @@ do_task_body() (
|
|
|
2253
2451
|
note "$id: the tests this attempt affects fail — sent back to the implementer without a review (see $tdir/prereview.md)"
|
|
2254
2452
|
return 0
|
|
2255
2453
|
fi
|
|
2256
|
-
# What changed since the review whose findings this reviewer is handed.
|
|
2257
|
-
# today's prompt unless it retries, as changes.prev.diff does. dwarf.last is the reply of
|
|
2454
|
+
# What changed since the review whose findings this reviewer is handed. dwarf.last is the reply of
|
|
2258
2455
|
# the attempt under review: a dwarf run just rewrote it, or $resume (the validated QA-only
|
|
2259
2456
|
# path, never the raw marker) guarantees the reviewed commit is the one it describes.
|
|
2260
|
-
local prompt_extra=()
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
if [ -s "$tdir/retry_findings.md" ] && [ -s "$tdir/dwarf.last" ]; then
|
|
2269
|
-
prompt_extra+=(--reply "$tdir/dwarf.last")
|
|
2270
|
-
fi
|
|
2271
|
-
else
|
|
2272
|
-
rm -f "$tdir/changes.since.diff" "$tdir/changes.since.range" "$tdir/changes.since.stat"
|
|
2457
|
+
local prompt_extra=(--role qa)
|
|
2458
|
+
attempt_delta "$tdir" "$wt" "$reviewed"
|
|
2459
|
+
if [ -s "$tdir/changes.since.diff" ]; then
|
|
2460
|
+
prompt_extra+=(--retry-diff "$tdir/changes.since.diff" --retry-stat "$tdir/changes.since.stat"
|
|
2461
|
+
--retry-range "$(awk '{ print substr($1, 1, 7) ".." substr($2, 1, 7) }' "$tdir/changes.since.range")")
|
|
2462
|
+
fi
|
|
2463
|
+
if [ -s "$tdir/retry_findings.md" ] && [ -s "$tdir/dwarf.last" ]; then
|
|
2464
|
+
prompt_extra+=(--reply "$tdir/dwarf.last")
|
|
2273
2465
|
fi
|
|
2274
2466
|
# A finding sweep's fix task gets the narrow review: one FIXED / NOT FIXED line per finding.
|
|
2275
2467
|
local qa_kind=task
|
|
@@ -2289,6 +2481,7 @@ do_task_body() (
|
|
|
2289
2481
|
[ "$(wc -c < "$tdir/.qa.diff" | tr -d ' ')" -le "$REVIEW_DIFF_LIMIT" ] || qa_inline=0
|
|
2290
2482
|
{
|
|
2291
2483
|
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"
|
|
2484
|
+
steer_section "$tdir" "$attempt" qa
|
|
2292
2485
|
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part head --kind "$qa_kind"
|
|
2293
2486
|
echo
|
|
2294
2487
|
if [ "$is_script" = 1 ]; then
|
|
@@ -2335,7 +2528,14 @@ for r in json.load(sys.stdin):
|
|
|
2335
2528
|
echo "matters because another task may own those files."
|
|
2336
2529
|
echo
|
|
2337
2530
|
fi
|
|
2338
|
-
|
|
2531
|
+
local qa_test_mins="" qa_test_mins_flag=()
|
|
2532
|
+
for _tmf in "$tdir/qa_test_minutes" "$PLAN/qa_test_minutes"; do
|
|
2533
|
+
if [ -f "$_tmf" ]; then
|
|
2534
|
+
qa_test_mins="$(head -1 "$_tmf" 2>/dev/null | tr -d ' \r')"
|
|
2535
|
+
case "$qa_test_mins" in ''|*[!0-9]*) qa_test_mins="" ;; *) qa_test_mins_flag=(--test-minutes "$qa_test_mins") ; break ;; esac
|
|
2536
|
+
fi
|
|
2537
|
+
done
|
|
2538
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind "$qa_kind" --threshold "$qa_thr" ${qa_test_mins_flag[@]+"${qa_test_mins_flag[@]}"}
|
|
2339
2539
|
echo
|
|
2340
2540
|
if [ "$qa_inline" = 1 ]; then
|
|
2341
2541
|
echo '```diff'; cat "$tdir/.qa.diff"; echo '```'
|
|
@@ -2359,7 +2559,7 @@ for r in json.load(sys.stdin):
|
|
|
2359
2559
|
# how often two reviewers agree. It reviews its own snapshot from its own dir under
|
|
2360
2560
|
# $PLAN/shadow/, and nothing in this script ever reads its result.
|
|
2361
2561
|
local shadow_pid=""
|
|
2362
|
-
if [ -s "$PLAN/shadow_qa" ]
|
|
2562
|
+
if [ -s "$PLAN/shadow_qa" ]; then
|
|
2363
2563
|
python3 "$SKILL_DIR/scripts/forge-shadow.py" run --plan "$PLAN" --task "$id" --worktree "$wt" \
|
|
2364
2564
|
--base "$base" --reviewed "$reviewed" --attempt "$attempt" --qa "$qa" --tdir "$tdir" ${yq:+--yolo} \
|
|
2365
2565
|
</dev/null >/dev/null 2>&1 &
|
|
@@ -2370,9 +2570,7 @@ for r in json.load(sys.stdin):
|
|
|
2370
2570
|
# fresh dispatch, and nothing here can abort the round: a doctor that fails means fresh.
|
|
2371
2571
|
local rs_mode=fresh rs_reason="" rs_id="" rs_row=1 rs_cont=()
|
|
2372
2572
|
if [ "$rs_on" = 1 ]; then
|
|
2373
|
-
if [ -
|
|
2374
|
-
rs_reason=fractal
|
|
2375
|
-
elif [ -f "$PLAN/reviewer_session_rate" ] && ! grep -qxF "$id" "$PLAN/reviewer_session_tasks" 2>/dev/null; then
|
|
2573
|
+
if [ -f "$PLAN/reviewer_session_rate" ] && ! grep -qxF "$id" "$PLAN/reviewer_session_tasks" 2>/dev/null; then
|
|
2376
2574
|
rs_reason=not-sampled # the comparison half of --reviewer-session-rate: every round is fresh
|
|
2377
2575
|
elif [ ! -s "$tdir/retry_findings.md" ]; then
|
|
2378
2576
|
rs_reason=first-round
|
|
@@ -2445,6 +2643,9 @@ for r in json.load(sys.stdin):
|
|
|
2445
2643
|
echo review > "$tdir/invalidated.reason"
|
|
2446
2644
|
echo INVALIDATED > "$tdir/status"; note "$id: artifact changed during review"; return 1
|
|
2447
2645
|
fi
|
|
2646
|
+
# The brief edited while the reviewer worked (#212): the verdict judged text that is gone, so it does not
|
|
2647
|
+
# count. STALE as before review, nothing spent; the next attempt gets the new text and these findings.
|
|
2648
|
+
if prompt_drifted "$PLAN" "$id" "$tdir" "$attempt" review; then return 0; fi
|
|
2448
2649
|
local verdict
|
|
2449
2650
|
verdict="$(forge_verdict "$tdir/qa.last")"
|
|
2450
2651
|
/bin/bash "$MEMORY" record "$REPO" --last "$tdir/qa.last" --role qa \
|
|
@@ -2464,6 +2665,7 @@ for r in json.load(sys.stdin):
|
|
|
2464
2665
|
# FAIL. qa_thr is the value the review prompt was built with, so the prompt and the gate of
|
|
2465
2666
|
# one attempt agree. Before record_attempt, so attempts.tsv shows the gated status.
|
|
2466
2667
|
qa_gate "$PLAN" "$id" "$tdir" "$verdict" "$qa_thr"
|
|
2668
|
+
record_reviewed_inputs "$tdir" "$qa_thr" || true
|
|
2467
2669
|
return 0
|
|
2468
2670
|
)
|
|
2469
2671
|
|
|
@@ -2473,7 +2675,15 @@ do_task() {
|
|
|
2473
2675
|
local rc
|
|
2474
2676
|
do_task_body "$@"; rc=$?
|
|
2475
2677
|
record_attempt "$1" "$2"
|
|
2476
|
-
|
|
2678
|
+
# A split task waiting for its subtasks (#153) was not attempted: nothing to judge or escalate.
|
|
2679
|
+
[ -s "$1/tasks/$2/sub.waiting" ] || post_attempt "$1" "$2"
|
|
2680
|
+
# run --auto-split (#153): a task that just stopped on `split` is split by the planner, and its
|
|
2681
|
+
# subtasks run now, in this same entry, so the scheduler sees one task that took longer.
|
|
2682
|
+
if forge_auto_split "$1" "$2"; then
|
|
2683
|
+
do_task_body "$@"; rc=$?
|
|
2684
|
+
record_attempt "$1" "$2"
|
|
2685
|
+
[ -s "$1/tasks/$2/sub.waiting" ] || post_attempt "$1" "$2"
|
|
2686
|
+
fi
|
|
2477
2687
|
return $rc
|
|
2478
2688
|
}
|
|
2479
2689
|
|
|
@@ -2506,13 +2716,16 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
|
|
|
2506
2716
|
return 1
|
|
2507
2717
|
fi
|
|
2508
2718
|
if (cd "$int_wt" && git merge --no-ff -m "forge: merge $id" "$reviewed" >/dev/null 2>&1); then
|
|
2509
|
-
|
|
2719
|
+
local integration
|
|
2720
|
+
integration="$(git -C "$int_wt" rev-parse HEAD)"
|
|
2721
|
+
printf '%s\n' "$integration" > "$PLAN/accepted.integration"
|
|
2722
|
+
mark_verification_stale "$PLAN" "$integration"
|
|
2510
2723
|
touch "$PLAN/tasks/$id/merged"
|
|
2511
2724
|
rm -f "$tdir/conflict.files"
|
|
2512
2725
|
# Which of a sweep task's findings its reviewer marked fixed: what `forge issues` leaves out.
|
|
2513
2726
|
[ ! -f "$tdir/sweep.json" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" settle "$PLAN" "$id" >/dev/null 2>&1 || true
|
|
2514
2727
|
forge_dataset_event merge --dir "$PLAN" --task "$id" --set status=MERGED --set commit="$reviewed" \
|
|
2515
|
-
--set integration="$
|
|
2728
|
+
--set integration="$integration"
|
|
2516
2729
|
return 0
|
|
2517
2730
|
fi
|
|
2518
2731
|
# Which files collided is the label for whether two tasks were coupled, and the abort
|
|
@@ -2521,7 +2734,7 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
|
|
|
2521
2734
|
(cd "$int_wt" && git merge --abort >/dev/null 2>&1)
|
|
2522
2735
|
echo CONFLICT > "$PLAN/tasks/$id/status"
|
|
2523
2736
|
forge_dataset_event merge --dir "$PLAN" --task "$id" --set status=CONFLICT --set commit="$reviewed" \
|
|
2524
|
-
--set conflicts="$(tr '\n' ' ' < "$tdir/conflict.files"
|
|
2737
|
+
--set conflicts="$(tr '\n' ' ' 2>/dev/null < "$tdir/conflict.files")"
|
|
2525
2738
|
return 1
|
|
2526
2739
|
}
|
|
2527
2740
|
|
|
@@ -2536,7 +2749,7 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
|
2536
2749
|
while [ $# -gt 0 ]; do
|
|
2537
2750
|
case "$1" in
|
|
2538
2751
|
--no-ripwire|--yolo-dwarf|--yolo-qa|--no-dispatch) shift ;;
|
|
2539
|
-
--output|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
|
|
2752
|
+
--output|--verify|--setup|--subtasks|--planner) [ $# -ge 2 ] || break; shift 2 ;;
|
|
2540
2753
|
--dwarf) [ $# -ge 2 ] || break; dwarf="$2"; shift 2 ;;
|
|
2541
2754
|
--decide) [ $# -ge 2 ] || break; decide="$2"; shift 2 ;;
|
|
2542
2755
|
--reason) [ $# -ge 2 ] || break; reason="$2"; shift 2 ;;
|
|
@@ -2591,13 +2804,14 @@ PY
|
|
|
2591
2804
|
}
|
|
2592
2805
|
|
|
2593
2806
|
report_untested() { # report_untested <plan> <id>...: verdicts that rest on reading alone (#117)
|
|
2594
|
-
local plan="$1" id tests_note untested=0; shift
|
|
2807
|
+
local plan="$1" id tests_note untested=0 id_w; shift
|
|
2808
|
+
id_w="$(id_col_width "$plan/tasks.tsv")"
|
|
2595
2809
|
for id in "$@"; do
|
|
2596
2810
|
tests_note="$(forge_tests_note "$plan/tasks/$id/qa.last")"
|
|
2597
2811
|
if [ -n "$tests_note" ]; then
|
|
2598
|
-
[ "$untested" = 0 ] && echo "reviews whose tests
|
|
2812
|
+
[ "$untested" = 0 ] && echo "reviews whose tests did not complete:"
|
|
2599
2813
|
untested=1
|
|
2600
|
-
printf '
|
|
2814
|
+
printf ' %-*s %s\n' "$id_w" "$id" "$tests_note"
|
|
2601
2815
|
fi
|
|
2602
2816
|
done
|
|
2603
2817
|
[ "$untested" = 0 ] || echo
|
|
@@ -2606,7 +2820,9 @@ report_untested() { # report_untested <plan> <id>...: verdicts that rest on read
|
|
|
2606
2820
|
do_retry() {
|
|
2607
2821
|
local PLAN="${1:?retry needs a plan dir}" id="${2:?retry needs a task id}"; shift 2
|
|
2608
2822
|
FORGE_RUN_STARTED="$(forge_now)"
|
|
2823
|
+
forge_refuse_fractal_run "$PLAN" retry
|
|
2609
2824
|
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0 DECIDE="" REASON="" APPROVED=0 NO_DISPATCH=0
|
|
2825
|
+
local SUBTASKS="" SPLIT_PLANNER=""
|
|
2610
2826
|
# An answer is validated before any option below writes into the plan: a rejected answer
|
|
2611
2827
|
# changes nothing, --setup and --verify included. Only a NEEDS_INPUT task takes one. The
|
|
2612
2828
|
# arguments are walked the way the loop below walks them (a value is never taken for a flag),
|
|
@@ -2653,7 +2869,9 @@ do_retry() {
|
|
|
2653
2869
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
2654
2870
|
--output) OUTPUT="${2:?}"; shift 2 ;;
|
|
2655
2871
|
--dwarf) NEWDWARF="${2:?--dwarf needs a spec}"; shift 2 ;;
|
|
2656
|
-
--decide) DECIDE="${2:?--decide needs retry=N
|
|
2872
|
+
--decide) DECIDE="${2:?--decide needs retry=N, threshold=Pn or split}"; shift 2 ;;
|
|
2873
|
+
--subtasks) SUBTASKS="${2:?--subtasks needs a file}"; shift 2 ;;
|
|
2874
|
+
--planner) SPLIT_PLANNER="${2:?--planner needs a spec}"; shift 2 ;;
|
|
2657
2875
|
--reason) REASON="${2?--reason needs a text}"; shift 2 ;;
|
|
2658
2876
|
--approved) APPROVED=1; shift ;;
|
|
2659
2877
|
--no-dispatch) NO_DISPATCH=1; shift ;;
|
|
@@ -2678,6 +2896,7 @@ do_retry() {
|
|
|
2678
2896
|
2) exit 2 ;;
|
|
2679
2897
|
esac
|
|
2680
2898
|
fi
|
|
2899
|
+
forge_removed_flag "$1"
|
|
2681
2900
|
die "retry: unknown option '$1'"
|
|
2682
2901
|
;;
|
|
2683
2902
|
esac
|
|
@@ -2713,8 +2932,19 @@ do_retry() {
|
|
|
2713
2932
|
die "retry: '$id' already has a decision recorded and waits for the next run; forge-parallel.sh run $PLAN starts it" 2
|
|
2714
2933
|
fi
|
|
2715
2934
|
retry_decision_gate "$PLAN" "$id" "$st" "$DECIDE" "$NEWDWARF" "$REASON" "$APPROVED"
|
|
2935
|
+
# A split (#153): --subtasks and --planner belong to it alone, and it does not name a model for the task.
|
|
2936
|
+
local is_split_decision=0 cap_decide="$DECIDE"
|
|
2937
|
+
if forge_decide_is_split "$DECIDE"; then
|
|
2938
|
+
is_split_decision=1
|
|
2939
|
+
cap_decide="retry=1" # the split grants the one attempt that reviews the whole task
|
|
2940
|
+
[ -z "$NEWDWARF" ] || die "retry: --decide split does not take --dwarf: the subtasks are routed with the plan's pools" 2
|
|
2941
|
+
[ -z "$SUBTASKS" ] || [ -z "$SPLIT_PLANNER" ] || die "retry: give --subtasks FILE or --planner SPEC, not both" 2
|
|
2942
|
+
[ -n "$SUBTASKS" ] || [ -n "$SPLIT_PLANNER" ] || SPLIT_PLANNER="$(forge_split_planner "$PLAN")"
|
|
2943
|
+
else
|
|
2944
|
+
[ -z "$SUBTASKS$SPLIT_PLANNER" ] || die "retry: --subtasks and --planner go with --decide split" 2
|
|
2945
|
+
fi
|
|
2716
2946
|
# A task at its attempt cap (#69) is refused with the decision commands unless --decide retry=N reaches past it.
|
|
2717
|
-
if ! attempt_cap_gate "$PLAN" "$id" "$st" "$
|
|
2947
|
+
if ! attempt_cap_gate "$PLAN" "$id" "$st" "$cap_decide"; then write_results "$PLAN"; return 2; fi
|
|
2718
2948
|
# The user's answer to a NEEDS_INPUT task's question (validated above): written before
|
|
2719
2949
|
# anything else is prepared, atomically, and kept when the preparation then refuses (the
|
|
2720
2950
|
# same answer can be retried).
|
|
@@ -2732,7 +2962,10 @@ do_retry() {
|
|
|
2732
2962
|
# A refusal (the retry policy found no stronger model, or the escalation could not be
|
|
2733
2963
|
# written) must stop here: past this point the status is cleared and a dwarf dispatched.
|
|
2734
2964
|
local prc=0
|
|
2735
|
-
if [ "$
|
|
2965
|
+
if [ "$is_split_decision" = 1 ]; then
|
|
2966
|
+
# The sub-plan is made and the decision recorded; the task's next entry runs its subtasks.
|
|
2967
|
+
retry_split "$PLAN" "$id" "$DECIDE" "$REASON" "$SUBTASKS" "$SPLIT_PLANNER" user || prc=$?
|
|
2968
|
+
elif [ "$st" = NEEDS_DECISION ]; then
|
|
2736
2969
|
retry_decided "$PLAN" "$id" "$DECIDE" "$NEWDWARF" "$REASON" || prc=$?
|
|
2737
2970
|
else
|
|
2738
2971
|
prepare_retry "$PLAN" "$id" "$NEWDWARF" || prc=$?
|
|
@@ -2744,6 +2977,7 @@ do_retry() {
|
|
|
2744
2977
|
if [ "$prc" != 0 ]; then
|
|
2745
2978
|
write_results "$PLAN"
|
|
2746
2979
|
[ "$prc" = 3 ] && return 2
|
|
2980
|
+
[ "$prc" = 6 ] && return 3 # --decide files+= refused (#199): nothing was written
|
|
2747
2981
|
return "$prc"
|
|
2748
2982
|
fi
|
|
2749
2983
|
[ "${FORGE_RIPWIRE:-}" != off ] || touch "$PLAN/no_ripwire"
|
|
@@ -2769,9 +3003,8 @@ do_retry() {
|
|
|
2769
3003
|
fi
|
|
2770
3004
|
rm -f "$tdir/retry.prepared"
|
|
2771
3005
|
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
export FORGE_FRACTAL_RETRY=1
|
|
3006
|
+
if forge_split_open "$PLAN" "$id"; then note "running the subtasks of $id"
|
|
3007
|
+
else note "retrying $id with dwarf $(field "$T" "$id" dwarf)"; fi
|
|
2775
3008
|
export FORGE_DATASET_TRIGGER=human
|
|
2776
3009
|
do_task "$PLAN" "$id"
|
|
2777
3010
|
st="$(task_status "$PLAN" "$id")"
|
|
@@ -2833,7 +3066,10 @@ do_retry() {
|
|
|
2833
3066
|
for lid in $(all_ids "$T"); do
|
|
2834
3067
|
case "$(task_status "$PLAN" "$lid")" in PENDING|BLOCKED) left="${left:+$left }$lid" ;; esac
|
|
2835
3068
|
done
|
|
2836
|
-
if
|
|
3069
|
+
if forge_is_sub_plan "$PLAN"; then
|
|
3070
|
+
# A sub-plan (#153) has no verification of its own; its task picks the work up at the next run.
|
|
3071
|
+
note "$PLAN is the sub-plan of a split task: forge-parallel.sh run $(forge_decompose_py root "$PLAN" 2>/dev/null) brings its merged subtasks into the task and reviews it"
|
|
3072
|
+
elif [ -n "$left" ]; then
|
|
2837
3073
|
note "verification deferred: tasks still to run ($left); the next run, or integrate, verifies the integration branch"
|
|
2838
3074
|
else
|
|
2839
3075
|
verify_result "$PLAN" "$(cat "$PLAN/wt_root")/_integration" "$PLAN" || { write_results "$PLAN"; run_report_extras "$PLAN"; return 5; }
|
|
@@ -2841,8 +3077,7 @@ do_retry() {
|
|
|
2841
3077
|
write_results "$PLAN"
|
|
2842
3078
|
echo
|
|
2843
3079
|
# 14 covers NEEDS_DECISION; 9 pushes the branch column out for IMPLEMENTED (11) too.
|
|
2844
|
-
|
|
2845
|
-
awk -F'\t' '{printf " %-14s %-14s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
|
|
3080
|
+
render_results_table "$PLAN"
|
|
2846
3081
|
run_report_extras "$PLAN"
|
|
2847
3082
|
report_decisions "$PLAN"
|
|
2848
3083
|
[ "$(task_status "$PLAN" "$id")" = "MERGED" ] || return 5
|
|
@@ -2871,16 +3106,28 @@ verify_group_stop() { # TERM the verify command's group; KILL it after FORGE_VER
|
|
|
2871
3106
|
# Until the guard's setsid there is no group: the TERM goes to the guard itself, which dies
|
|
2872
3107
|
# of it before it starts the command. A group that forms all the same gets its TERM from
|
|
2873
3108
|
# the timer.
|
|
2874
|
-
|
|
3109
|
+
if forge_is_windows && [ -r "/proc/$group/winpid" ]; then
|
|
3110
|
+
forge_kill_group "$group" TERM
|
|
3111
|
+
kill -TERM "$group" 2>/dev/null || true
|
|
3112
|
+
else
|
|
3113
|
+
kill -TERM -- "-$group" 2>/dev/null || { termed=0; kill -TERM "$group" 2>/dev/null; }
|
|
3114
|
+
fi
|
|
2875
3115
|
# The timer polls in short naps rather than sleeping the whole grace in one: it ends by
|
|
2876
3116
|
# itself within a nap of the group's last member, and a long sleep left behind would hold
|
|
2877
3117
|
# the plan lock it inherited.
|
|
2878
3118
|
( trap - TERM INT
|
|
2879
3119
|
ticks=$((FORGE_VERIFY_GRACE * 10))
|
|
2880
|
-
while kill -0 -- "-$group" 2>/dev/null || { [ "$termed" = 0 ] && kill -0 "$group" 2>/dev/null; }; do
|
|
3120
|
+
while kill -0 -- "-$group" 2>/dev/null || { [ "$termed" = 0 ] && kill -0 "$group" 2>/dev/null; } || { forge_is_windows && [ -r "/proc/$group/winpid" ] && kill -0 "$group" 2>/dev/null; }; do
|
|
2881
3121
|
if [ "$termed" = 0 ] && kill -TERM -- "-$group" 2>/dev/null; then termed=1; fi
|
|
2882
3122
|
if [ "$ticks" -le 0 ]; then
|
|
2883
|
-
if
|
|
3123
|
+
if forge_is_windows && [ -r "/proc/$group/winpid" ]; then
|
|
3124
|
+
forge_kill_group "$group" KILL
|
|
3125
|
+
kill -KILL "$group" 2>/dev/null
|
|
3126
|
+
elif [ "$termed" = 1 ]; then
|
|
3127
|
+
kill -KILL -- "-$group" 2>/dev/null
|
|
3128
|
+
else
|
|
3129
|
+
kill -KILL "$group" 2>/dev/null
|
|
3130
|
+
fi
|
|
2884
3131
|
break
|
|
2885
3132
|
fi
|
|
2886
3133
|
sleep 0.1
|
|
@@ -2895,20 +3142,25 @@ verify_signal() { # trap handler of a stoppable verification
|
|
|
2895
3142
|
}
|
|
2896
3143
|
|
|
2897
3144
|
verify_exec() { # verify_exec <checkout> <command> <log> [grace seconds, default 5] -> the command's exit code, 130 when stopped
|
|
2898
|
-
local wt="$1" cmd="$2" log="$3" rc=0 group deadline
|
|
3145
|
+
local wt="$1" cmd="$2" log="$3" rc=0 group deadline guard_py="$SKILL_DIR/scripts/forge-guard.py"
|
|
2899
3146
|
if [ "${FORGE_RUN_STOPPABLE:-0}" != 1 ]; then
|
|
2900
3147
|
(cd "$wt" && /bin/bash -c "$cmd") > "$log" 2>&1
|
|
2901
3148
|
return $?
|
|
2902
3149
|
fi
|
|
2903
3150
|
FORGE_VERIFY_GRACE="${4:-5}"
|
|
2904
3151
|
[ "$FORGE_VERIFY_STOP" = 1 ] && return 130
|
|
3152
|
+
! forge_is_windows || guard_py="$(forge_host_path "$guard_py")"
|
|
2905
3153
|
# A background job ignores SIGINT and SIGQUIT, and the command would inherit that; the
|
|
2906
3154
|
# wrapper restores both before the guard puts the command in a session of its own.
|
|
2907
|
-
(cd "$wt" && exec python3 -c 'import os, signal, sys
|
|
2908
|
-
for
|
|
2909
|
-
signal
|
|
3155
|
+
(cd "$wt" && { ! forge_is_windows || export MSYS_NO_PATHCONV=1; } && exec python3 -c 'import os, signal, subprocess, sys
|
|
3156
|
+
for sig_name in ("SIGINT", "SIGQUIT"):
|
|
3157
|
+
sig = getattr(signal, sig_name, None)
|
|
3158
|
+
if sig is not None:
|
|
3159
|
+
signal.signal(sig, signal.SIG_DFL)
|
|
3160
|
+
if os.name == "nt":
|
|
3161
|
+
sys.exit(subprocess.run([sys.executable] + sys.argv[1:]).returncode)
|
|
2910
3162
|
os.execv(sys.executable, [sys.executable] + sys.argv[1:])' \
|
|
2911
|
-
"$
|
|
3163
|
+
"$guard_py" session -- /bin/bash -c "$cmd") > "$log" 2>&1 <&0 &
|
|
2912
3164
|
group=$!
|
|
2913
3165
|
FORGE_VERIFY_GROUP="$group"
|
|
2914
3166
|
[ "$FORGE_VERIFY_STOP" = 1 ] && verify_group_stop
|
|
@@ -2951,6 +3203,13 @@ verify_result() ( verify_result_body "$@" ) # plan, checkout, artifact directory
|
|
|
2951
3203
|
# finished verification's verification.command or verification.lanes.d/). It replaces
|
|
2952
3204
|
# verify_source_for and verify-discover, so a re-run judges by the predicate that verification
|
|
2953
3205
|
# used, whatever the plan, the repository or discovery would say now.
|
|
3206
|
+
verify_mark_stale_if_needed() { # verify_mark_stale_if_needed <out> <stale_status> <stale_reason>
|
|
3207
|
+
local out="$1" st="${2:-}" reason="${3:-}"
|
|
3208
|
+
[ "$st" = STALE ] || return 0
|
|
3209
|
+
printf '%s\n' "${reason:-setup inputs changed}" > "$out/verification.stale_setup"
|
|
3210
|
+
note "warning: verification ran against stale setup (${reason:-lockfile or setup input merged since setup}); pass --setup-before-verify or prepend setup to the verify command"
|
|
3211
|
+
}
|
|
3212
|
+
|
|
2954
3213
|
verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
2955
3214
|
local plan="$1" wt="$2" out="$3" cmd="" before after rc=0 repo jev_loaded=0 vretries
|
|
2956
3215
|
FORGE_VERIFY_STOP=0 FORGE_VERIFY_GROUP="" FORGE_VERIFY_TIMER="" FORGE_VERIFY_GRACE=5
|
|
@@ -2959,9 +3218,10 @@ verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
|
2959
3218
|
forge_metric_begin "$out" verification
|
|
2960
3219
|
forge_metric_phase verification
|
|
2961
3220
|
repo="$(cat "$plan/repo")"
|
|
2962
|
-
rm -f "$out/verification.
|
|
3221
|
+
rm -f "$out/verification.status" "$out/verification.exit" \
|
|
3222
|
+
"$out/verification.flaky" "$out/verification.retry.log" "$out/verification.failing.log" "$out/verification.coverage.txt" \
|
|
2963
3223
|
"$out/verification.runs.tsv" "$out"/verification.run-*.log "$out/verification.commit" \
|
|
2964
|
-
"$out/verification.lanes.json" "$out"/verification.lane.*.log
|
|
3224
|
+
"$out/verification.lanes.json" "$out"/verification.lane.*.log "$out/verification.stale_setup"
|
|
2965
3225
|
# The commit being verified, named before any early return, so every outcome (FAIL and
|
|
2966
3226
|
# UNVERIFIED included) can be joined to the code it judged.
|
|
2967
3227
|
git -C "$wt" rev-parse HEAD > "$out/verification.commit" 2>/dev/null || rm -f "$out/verification.commit"
|
|
@@ -2991,7 +3251,12 @@ verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
|
2991
3251
|
note "combined result UNVERIFIED: the fixed verification source $fixed is missing or empty"; return 0
|
|
2992
3252
|
fi
|
|
2993
3253
|
else
|
|
2994
|
-
vsource="$(verify_source_for "$plan" "$repo")"
|
|
3254
|
+
vsource="$(verify_source_for "$plan" "$repo" "$wt")"
|
|
3255
|
+
# The checkout's own lanes or command run (#151): say where the root's copy differs.
|
|
3256
|
+
case "${vsource%%$'\t'*}" in
|
|
3257
|
+
*:checkout) local diffline
|
|
3258
|
+
while IFS= read -r diffline; do note "$diffline"; done < <(verify_root_difference "$vsource" "$repo") ;;
|
|
3259
|
+
esac
|
|
2995
3260
|
fi
|
|
2996
3261
|
case "$vsource" in command:*) cmd="$(cat "${vsource#*$'\t'}")" ;; esac
|
|
2997
3262
|
# A lanes snapshot belongs to the verification that wrote it: a run on a command, or on
|
|
@@ -3001,10 +3266,40 @@ verify_result_body() { # plan, checkout, artifact directory[, fixed source]
|
|
|
3001
3266
|
echo FAIL > "$out/verification.status"
|
|
3002
3267
|
note "verification checkout has source changes outside its commit"; return 1
|
|
3003
3268
|
fi
|
|
3269
|
+
local stale_status="" stale_reason="" setup_cmd_now=""
|
|
3270
|
+
setup_cmd_now="$(worktree_setup_command "$plan" "$repo")"
|
|
3271
|
+
if [ -n "$setup_cmd_now" ]; then
|
|
3272
|
+
local stale_out="" setup_commit_arg=""
|
|
3273
|
+
# The integration worktree's record, only for that checkout: integrate's candidate and
|
|
3274
|
+
# attribute's scratch have their own setup (or none), read from their git-dir marker.
|
|
3275
|
+
if [ -s "$plan/tasks/_integration/setup.commit" ] && [ -s "$plan/wt_root" ] \
|
|
3276
|
+
&& [ "$wt" -ef "$(cat "$plan/wt_root")/_integration" ]; then
|
|
3277
|
+
setup_commit_arg="$plan/tasks/_integration/setup.commit"
|
|
3278
|
+
fi
|
|
3279
|
+
stale_out="$(python3 "$SKILL_DIR/scripts/forge-setup-stale.py" check "$plan" "$wt" "$repo" ${setup_commit_arg:+--setup-commit "$setup_commit_arg"} 2>/dev/null || true)"
|
|
3280
|
+
stale_status="${stale_out%%$'\t'*}"
|
|
3281
|
+
stale_reason="${stale_out#*$'\t'}"
|
|
3282
|
+
if [ "$stale_status" = RERUN ]; then
|
|
3283
|
+
note "setup: re-running before verification ($stale_reason)"
|
|
3284
|
+
local setup_log="$out/setup.verify.out"
|
|
3285
|
+
[ -d "$out/tasks/_integration" ] && setup_log="$out/tasks/_integration/setup.verify.out"
|
|
3286
|
+
if (cd "$wt" && eval "$setup_cmd_now") >"$setup_log" 2>&1; then
|
|
3287
|
+
note "setup before verification ok"
|
|
3288
|
+
local commit_out="$out/setup.commit"
|
|
3289
|
+
[ -d "$out/tasks/_integration" ] && commit_out="$out/tasks/_integration/setup.commit"
|
|
3290
|
+
python3 "$SKILL_DIR/scripts/forge-setup-stale.py" record-commit "$wt" --out "$commit_out" 2>/dev/null || true
|
|
3291
|
+
else
|
|
3292
|
+
note "setup before verification failed (continuing) — see $setup_log"
|
|
3293
|
+
fi
|
|
3294
|
+
stale_status=""
|
|
3295
|
+
fi
|
|
3296
|
+
fi
|
|
3004
3297
|
case "$vsource" in
|
|
3005
3298
|
lanes:*)
|
|
3006
|
-
|
|
3007
|
-
|
|
3299
|
+
local vrc=0
|
|
3300
|
+
verify_lanes_run "$plan" "$wt" "$out" "${vsource#*$'\t'}" "$vretries" || vrc=$?
|
|
3301
|
+
[ "$vrc" = 0 ] || verify_mark_stale_if_needed "$out" "$stale_status" "$stale_reason"
|
|
3302
|
+
return "$vrc" ;;
|
|
3008
3303
|
esac
|
|
3009
3304
|
# Only when nothing is configured: ask Jev to name a command that actually exists
|
|
3010
3305
|
# in the repo. Its exit code, not its stdout text, decides whether a judgment was
|
|
@@ -3097,6 +3392,7 @@ with open(out + "/verification.jev.json", "w") as fh:
|
|
|
3097
3392
|
if [ "$rc3" != 0 ] && [ "$rc3" != 126 ] && [ "$rc3" != 127 ] && [ "$b3" = "$a3" ]; then
|
|
3098
3393
|
echo FAIL > "$out/verification.status"
|
|
3099
3394
|
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"
|
|
3395
|
+
verify_mark_stale_if_needed "$out" "$stale_status" "$stale_reason"
|
|
3100
3396
|
return 1
|
|
3101
3397
|
fi
|
|
3102
3398
|
fi
|
|
@@ -3127,6 +3423,7 @@ with open(out + "/verification.jev.json", "w") as fh:
|
|
|
3127
3423
|
fi
|
|
3128
3424
|
echo FAIL > "$out/verification.status"
|
|
3129
3425
|
note "combined verification failed or changed source; see $out/verification.log"
|
|
3426
|
+
verify_mark_stale_if_needed "$out" "$stale_status" "$stale_reason"
|
|
3130
3427
|
return 1
|
|
3131
3428
|
fi
|
|
3132
3429
|
echo PASS > "$out/verification.status"
|
|
@@ -3211,9 +3508,32 @@ forge_brief_start() { # forge_brief_start <plan>
|
|
|
3211
3508
|
PYTHONPATH="$SKILL_DIR/scripts${PYTHONPATH:+:$PYTHONPATH}" python3 -c \
|
|
3212
3509
|
'import sys, forge_brief; forge_brief.note_missing_groups(sys.argv[1])' "$plan" || true
|
|
3213
3510
|
python3 - "$plan" "$SKILL_DIR/scripts/forge-brief.py" <<'PY' || { note "brief: could not start the question writer"; return 0; }
|
|
3214
|
-
import os, subprocess, sys
|
|
3511
|
+
import os, subprocess, sys, time
|
|
3215
3512
|
plan, script = sys.argv[1], sys.argv[2]
|
|
3216
3513
|
pidfile = os.path.join(plan, 'brief.pid')
|
|
3514
|
+
if not hasattr(os, 'fork'):
|
|
3515
|
+
worker = (
|
|
3516
|
+
'import os, subprocess, sys\n'
|
|
3517
|
+
'plan, script, pidfile = sys.argv[1], sys.argv[2], sys.argv[3]\n'
|
|
3518
|
+
'try:\n'
|
|
3519
|
+
' with open(pidfile, "w") as handle:\n'
|
|
3520
|
+
' handle.write("%d\\n" % os.getpid())\n'
|
|
3521
|
+
' subprocess.run([sys.executable, script, "write", plan], stdin=subprocess.DEVNULL)\n'
|
|
3522
|
+
'finally:\n'
|
|
3523
|
+
' try: os.unlink(pidfile)\n'
|
|
3524
|
+
' except OSError: pass\n'
|
|
3525
|
+
)
|
|
3526
|
+
flags = getattr(subprocess, 'CREATE_NEW_PROCESS_GROUP', 0) | getattr(subprocess, 'DETACHED_PROCESS', 0)
|
|
3527
|
+
with open(os.path.join(plan, 'brief.out'), 'ab') as out:
|
|
3528
|
+
proc = subprocess.Popen(
|
|
3529
|
+
[sys.executable, '-c', worker, plan, script, pidfile],
|
|
3530
|
+
stdin=subprocess.DEVNULL, stdout=out, stderr=out,
|
|
3531
|
+
creationflags=flags, close_fds=True,
|
|
3532
|
+
)
|
|
3533
|
+
deadline = time.monotonic() + 2.0
|
|
3534
|
+
while time.monotonic() < deadline and not os.path.exists(pidfile) and proc.poll() is None:
|
|
3535
|
+
time.sleep(0.02)
|
|
3536
|
+
sys.exit(0)
|
|
3217
3537
|
ready, signal_ready = os.pipe()
|
|
3218
3538
|
child = os.fork()
|
|
3219
3539
|
if child:
|
|
@@ -3289,16 +3609,15 @@ forge_brief_stale() { # forge_brief_stale <plan> <merged-task>
|
|
|
3289
3609
|
# A failure here is one note; the run goes on. run.flags.json describes this run of the plan,
|
|
3290
3610
|
# not a choice a split or rerun copies, so it is not in the plan option lists.
|
|
3291
3611
|
forge_run_flags_write() { # forge_run_flags_write <plan> <max-parallel> [argv...]
|
|
3292
|
-
local plan="$1" maxp="$2" timeout_file="" verify_file=""
|
|
3612
|
+
local plan="$1" maxp="$2" timeout_file="" verify_file="" ahead=0 sweep_max=""
|
|
3293
3613
|
shift 2
|
|
3294
3614
|
[ ! -s "$plan/timeout" ] || timeout_file="$plan/timeout"
|
|
3295
3615
|
[ ! -f "$plan/verify_cmd" ] || verify_file="$plan/verify_cmd"
|
|
3296
|
-
forge_plan_is_fractal "$plan" && fractal=1
|
|
3297
3616
|
[ ! -f "$plan/sweep_ahead" ] || ahead=1
|
|
3298
3617
|
[ "$PP_SWEEP_MAX_SET" = 1 ] && sweep_max="$PP_SWEEP_MAX"
|
|
3299
3618
|
python3 - "$plan/run.flags.json" \
|
|
3300
3619
|
"$PP_RETRY_FAILED" "$PP_INFRA_RETRIES" "$PP_SWEEP" "$sweep_max" \
|
|
3301
|
-
"$PP_SWEEP_PLAUSIBLE" "$ahead" "$maxp" "$timeout_file" "$verify_file"
|
|
3620
|
+
"$PP_SWEEP_PLAUSIBLE" "$ahead" "$maxp" "$timeout_file" "$verify_file" \
|
|
3302
3621
|
-- "$@" <<'PY' >/dev/null 2>&1 || note "could not write $plan/run.flags.json"
|
|
3303
3622
|
import json, os, sys, tempfile, time
|
|
3304
3623
|
|
|
@@ -3313,10 +3632,10 @@ def whole(value):
|
|
|
3313
3632
|
return int(value) if value != '' else None
|
|
3314
3633
|
|
|
3315
3634
|
args = sys.argv[1:]
|
|
3316
|
-
if len(args) <
|
|
3635
|
+
if len(args) < 11 or args[10] != '--':
|
|
3317
3636
|
sys.exit(1)
|
|
3318
3637
|
dest = args[0]
|
|
3319
|
-
retry, infra, sweep, sweep_max, plausible, ahead, maxp, timeout_file, verify_file
|
|
3638
|
+
retry, infra, sweep, sweep_max, plausible, ahead, maxp, timeout_file, verify_file = args[1:10]
|
|
3320
3639
|
timeout = text(timeout_file)
|
|
3321
3640
|
data = {
|
|
3322
3641
|
'retry_failed': int(retry),
|
|
@@ -3328,8 +3647,7 @@ data = {
|
|
|
3328
3647
|
'max_parallel': int(maxp),
|
|
3329
3648
|
'timeout': int(timeout.strip()) if timeout is not None else None,
|
|
3330
3649
|
'verify': text(verify_file),
|
|
3331
|
-
'
|
|
3332
|
-
'argv': args[12:],
|
|
3650
|
+
'argv': args[11:],
|
|
3333
3651
|
'at': time.time(),
|
|
3334
3652
|
}
|
|
3335
3653
|
parent = os.path.dirname(dest) or '.'
|
|
@@ -3355,15 +3673,15 @@ do_run() {
|
|
|
3355
3673
|
trap run_signal TERM INT
|
|
3356
3674
|
local PLAN="${1:?run needs a plan dir}"; shift
|
|
3357
3675
|
FORGE_RUN_STARTED="$(forge_now)" # the summary's overridden verdicts are this run's
|
|
3358
|
-
local
|
|
3359
|
-
local MAXP=3 DRY=0 jev_rc=0 FORECAST=1
|
|
3676
|
+
local run_argv=("$@")
|
|
3677
|
+
local MAXP=3 DRY=0 jev_rc=0 FORECAST=1 AUTO_SPLIT="" SPLIT_PLANNER="" is_sub=0
|
|
3678
|
+
forge_is_sub_plan "$PLAN" && is_sub=1
|
|
3360
3679
|
while [ $# -gt 0 ]; do
|
|
3361
3680
|
case "$1" in
|
|
3362
3681
|
--no-forecast) FORECAST=0; shift ;;
|
|
3363
|
-
--
|
|
3364
|
-
--
|
|
3365
|
-
--
|
|
3366
|
-
--fractal-*) FRACTAL_ARGS+=("$1" "${2:?}"); shift 2 ;;
|
|
3682
|
+
--auto-split) AUTO_SPLIT=on; shift ;;
|
|
3683
|
+
--no-auto-split) AUTO_SPLIT=off; shift ;;
|
|
3684
|
+
--split-planner) SPLIT_PLANNER="${2:?--split-planner needs a spec}"; shift 2 ;;
|
|
3367
3685
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
3368
3686
|
--output) OUTPUT="${2:?}"; shift 2 ;;
|
|
3369
3687
|
--max-parallel) MAXP="${2:?}"; shift 2 ;;
|
|
@@ -3382,20 +3700,30 @@ do_run() {
|
|
|
3382
3700
|
2) exit 2 ;;
|
|
3383
3701
|
esac
|
|
3384
3702
|
fi
|
|
3703
|
+
forge_removed_flag "$1"
|
|
3385
3704
|
die "run: unknown option '$1'"
|
|
3386
3705
|
;;
|
|
3387
3706
|
esac
|
|
3388
3707
|
done
|
|
3708
|
+
forge_refuse_fractal_run "$PLAN" run
|
|
3389
3709
|
forge_profile_run_values "$PLAN"
|
|
3390
3710
|
[ "$JEV_OPTS" = 1 ] && forge_jev_settle "$PLAN"
|
|
3391
3711
|
[ -n "$PP_SWEEP" ] || [ "$PP_SWEEP_PLAUSIBLE$PP_SWEEP_MAX_SET" = 00 ] || die "--sweep-plausible and --sweep-max go with --sweep"
|
|
3712
|
+
# Auto-split (#153): kept for the plan, and refused now when there is no planner to ask.
|
|
3713
|
+
forge_auto_split_store "$PLAN" "$AUTO_SPLIT" "$SPLIT_PLANNER"
|
|
3392
3714
|
case "$OUTPUT" in summary|full) ;; *) die "--output must be summary or full" ;; esac
|
|
3393
3715
|
export FORGE_OUTPUT="$OUTPUT"
|
|
3394
3716
|
case "$MAXP" in ''|*[!0-9]*) die "--max-parallel must be positive" ;; esac
|
|
3395
3717
|
[ "$MAXP" -gt 0 ] || die "--max-parallel must be positive"
|
|
3396
3718
|
# Said once, before any dispatch. The run itself still follows retry_per_model.
|
|
3397
|
-
if [ -f "$PLAN/retry_per_model" ]
|
|
3398
|
-
|
|
3719
|
+
if [ -f "$PLAN/retry_per_model" ]; then
|
|
3720
|
+
local rpm; rpm="$(tr -d '[:space:]' < "$PLAN/retry_per_model")"
|
|
3721
|
+
# The reading forge-route.py and the scheduler use: 1 to 99, at most 9 digits.
|
|
3722
|
+
if [[ "$rpm" =~ ^[0-9]{1,9}$ ]] && [ "$((10#$rpm))" -ge 1 ] && [ "$((10#$rpm))" -le 99 ]; then
|
|
3723
|
+
[ ! -f "$PLAN/escalate_after" ] || note "retry-per-model $((10#$rpm)) replaces --escalate-after for this plan"
|
|
3724
|
+
else
|
|
3725
|
+
note "retry_per_model holds '$(printf '%.40s' "$rpm")', not a number from 1 to 99, so this run ignores it"
|
|
3726
|
+
fi
|
|
3399
3727
|
fi
|
|
3400
3728
|
local T="$PLAN/tasks.tsv" W="$PLAN/waves.tsv"
|
|
3401
3729
|
[ -s "$W" ] || die "no waves.tsv — run the plan subcommand first"
|
|
@@ -3405,9 +3733,6 @@ do_run() {
|
|
|
3405
3733
|
if [ -f "$PLAN/groups.tsv" ] || [ -f "$PLAN/groups.frozen" ]; then
|
|
3406
3734
|
local groups_out
|
|
3407
3735
|
groups_out="$(forge_groups_py check "$PLAN" 2>&1)" || forge_groups_die "$groups_out"
|
|
3408
|
-
if forge_groups_have_review "$PLAN" && { [ "${FRACTAL_CHOICE:-}" = on ] || forge_plan_is_fractal "$PLAN"; }; then
|
|
3409
|
-
die "group review does not support Fractal yet" 2
|
|
3410
|
-
fi
|
|
3411
3736
|
fi
|
|
3412
3737
|
|
|
3413
3738
|
compute_waves "$PLAN"
|
|
@@ -3420,32 +3745,19 @@ do_run() {
|
|
|
3420
3745
|
if [ "$DRY" != 1 ]; then
|
|
3421
3746
|
# The concurrency limit this run was given, for forge-ui to draw; a later run rewrites it.
|
|
3422
3747
|
printf '%s\n' "$MAXP" > "$PLAN/max_parallel"
|
|
3423
|
-
# Plan registers too; this also picks up plans made before it did.
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
# n is the same as --no-fractal, so it is not asked twice.
|
|
3432
|
-
if [ "$DRY" != 1 ] && [ -t 0 ] && [ -z "${FRACTAL_CHOICE:-}" ] \
|
|
3433
|
-
&& [ ! -e "$PLAN/fractal-selection.json" ] && ! forge_plan_is_fractal "$PLAN" \
|
|
3434
|
-
&& forge_groups_have_review "$PLAN"; then
|
|
3435
|
-
printf 'Use Fractal for this run? [y/N] ' >&2
|
|
3436
|
-
IFS= read -r fractal_answer || fractal_answer=""
|
|
3437
|
-
fractal_answer="$(printf '%s' "$fractal_answer" | tr -d '\r' | tr '[:upper:]' '[:lower:]')"
|
|
3438
|
-
case "$fractal_answer" in
|
|
3439
|
-
y) die "group review does not support Fractal yet" 2 ;;
|
|
3440
|
-
esac
|
|
3441
|
-
forge_fractal_flag off || exit $?
|
|
3748
|
+
# Plan registers too; this also picks up plans made before it did. A sub-plan (#153) is reached
|
|
3749
|
+
# through the plan it belongs to, and its limits are that plan's.
|
|
3750
|
+
if [ "$is_sub" = 0 ]; then
|
|
3751
|
+
forge_ui_register "$PLAN"
|
|
3752
|
+
forge_storage_check "$PLAN" "$REPO"
|
|
3753
|
+
# The decomposition limits do not change once the plan runs.
|
|
3754
|
+
forge_decompose_py freeze "$PLAN" >/dev/null 2>&1 || note "could not freeze the decomposition limits (decomposition.json)"
|
|
3755
|
+
fi
|
|
3442
3756
|
fi
|
|
3443
|
-
forge_fractal_parallel_run "$PLAN" "$REPO" "$DRY" ${fractal_pipeline_args[@]+"${fractal_pipeline_args[@]}"} || return $?
|
|
3444
|
-
forge_fast_fractal_note "$PLAN"
|
|
3445
3757
|
# Durable, beside the repo — never TMPDIR. A temp worktree root has destroyed
|
|
3446
3758
|
# real work here before: isolated worktrees are never pushed, so when the root
|
|
3447
3759
|
# goes, the only copy of that work goes with it.
|
|
3448
|
-
wt_root="$(cd "$REPO/.." && pwd)/.forge-worktrees/$run_id"
|
|
3760
|
+
wt_root="$(forge_host_path "$(cd "$REPO/.." && pwd)/.forge-worktrees/$run_id")"
|
|
3449
3761
|
echo "$wt_root" > "$PLAN/wt_root"
|
|
3450
3762
|
# Sibling, not parent: git refs are files, so a branch `forge/<run>` makes
|
|
3451
3763
|
# `forge/<run>/<task>` impossible ("cannot lock ref ... exists; cannot create").
|
|
@@ -3465,7 +3777,7 @@ do_run() {
|
|
|
3465
3777
|
fi
|
|
3466
3778
|
|
|
3467
3779
|
# run.flags.json describes this run of the plan, not a choice a split or rerun copies.
|
|
3468
|
-
forge_run_flags_write "$PLAN" "$MAXP" ${
|
|
3780
|
+
forge_run_flags_write "$PLAN" "$MAXP" ${run_argv[@]+"${run_argv[@]}"}
|
|
3469
3781
|
|
|
3470
3782
|
forge_metric_begin "$PLAN" parallel
|
|
3471
3783
|
forge_metric_phase preflight
|
|
@@ -3473,6 +3785,10 @@ do_run() {
|
|
|
3473
3785
|
[ ! -f "$PLAN/no_ripwire" ] || export FORGE_RIPWIRE=off
|
|
3474
3786
|
preflight_plan "$PLAN" || return $?
|
|
3475
3787
|
[ -z "$PP_SWEEP" ] || sweep_preflight "$PLAN" || return $?
|
|
3788
|
+
# The planner --auto-split would ask, checked with the rest before any model is paid for.
|
|
3789
|
+
if [ -f "$PLAN/auto_split" ] && [ -n "$(forge_split_planner "$PLAN")" ]; then
|
|
3790
|
+
/bin/bash "$DISPATCH" doctor --spec "$(forge_split_planner "$PLAN")" --role planner $(forge_fast_tier "$PLAN" planner) || return $?
|
|
3791
|
+
fi
|
|
3476
3792
|
/bin/bash "$SKILL_DIR/scripts/forge-install-ripwire.sh" || true
|
|
3477
3793
|
forge_metric_phase preparation
|
|
3478
3794
|
mkdir -p "$wt_root"
|
|
@@ -3511,7 +3827,8 @@ do_run() {
|
|
|
3511
3827
|
# history says may bounce. Advisory, budgeted and silent without history; it never stops a run.
|
|
3512
3828
|
[ "$FORECAST" = 1 ] && forecast_report "$PLAN"
|
|
3513
3829
|
# Invalid verification lanes stop the run here, before any model is paid for, so before the question writer below.
|
|
3514
|
-
|
|
3830
|
+
# A sub-plan (#153) has no verification of its own: its task's review and the root plan's verification judge it.
|
|
3831
|
+
[ "$is_sub" = 1 ] || verify_lanes_check "$PLAN" "$REPO" "$int_wt"
|
|
3515
3832
|
# Brief mode (#135), when the plan has it on. Strict asks first and refuses to start while a question of a
|
|
3516
3833
|
# task that has not started is unanswered; advisory and gated write the questions beside the scheduler.
|
|
3517
3834
|
local brief_level
|
|
@@ -3521,7 +3838,14 @@ do_run() {
|
|
|
3521
3838
|
advisory|gated) forge_brief_start "$PLAN" ;;
|
|
3522
3839
|
esac
|
|
3523
3840
|
# Say now, before any model is paid for, which suites the verify command will not run.
|
|
3524
|
-
verify_coverage_report "$REPO" "$(verify_command_for "$PLAN" "$REPO")" "$PLAN/verification.coverage.txt"
|
|
3841
|
+
[ "$is_sub" = 1 ] || verify_coverage_report "$REPO" "$(verify_command_for "$PLAN" "$REPO" "$int_wt")" "$PLAN/verification.coverage.txt"
|
|
3842
|
+
# What a split task's own run of its subtasks takes from this run (#153): the budgets, and one
|
|
3843
|
+
# --max-parallel for the whole tree, counted in the root plan.
|
|
3844
|
+
export FORGE_RUN_RETRY_FAILED="$PP_RETRY_FAILED" FORGE_RUN_INFRA_RETRIES="$PP_INFRA_RETRIES"
|
|
3845
|
+
if [ "$is_sub" = 0 ] || [ -z "${FORGE_TREE_ROOT:-}" ]; then
|
|
3846
|
+
FORGE_TREE_ROOT="$(forge_decompose_py root "$PLAN" 2>/dev/null)"; FORGE_TREE_ROOT="${FORGE_TREE_ROOT:-$PLAN}"
|
|
3847
|
+
export FORGE_TREE_ROOT FORGE_TREE_CAP="$MAXP"
|
|
3848
|
+
fi
|
|
3525
3849
|
local sched_rc=0 paused=0 sched_args=()
|
|
3526
3850
|
[ "$PP_RETRY_FAILED" -gt 0 ] && sched_args+=(--retry-failed "$PP_RETRY_FAILED")
|
|
3527
3851
|
[ "$PP_INFRA_RETRIES" -gt 0 ] && sched_args+=(--infra-retries "$PP_INFRA_RETRIES")
|
|
@@ -3547,7 +3871,7 @@ do_run() {
|
|
|
3547
3871
|
# verifying; the next `run` resumes and verifies at its end. An interrupted run has
|
|
3548
3872
|
# merged only part of its work: a verification of that is not worth its minutes, and it
|
|
3549
3873
|
# would run again as the rerun if it were killed.
|
|
3550
|
-
if [ "$paused" = 0 ] && [ "$interrupted" = 0 ]; then
|
|
3874
|
+
if [ "$paused" = 0 ] && [ "$interrupted" = 0 ] && [ "$is_sub" = 0 ]; then
|
|
3551
3875
|
run_phase=verification
|
|
3552
3876
|
( verify_result_body "$PLAN" "$int_wt" "$PLAN" ) <&0 &
|
|
3553
3877
|
run_child=$!
|
|
@@ -3581,8 +3905,7 @@ do_run() {
|
|
|
3581
3905
|
echo "results (integration branch: $int_br)"
|
|
3582
3906
|
echo "artifacts: $PLAN/tasks/<id>/{dwarf,qa}.{last,log}; results: $PLAN/results.tsv"
|
|
3583
3907
|
# 14 covers NEEDS_DECISION; 9 pushes the branch column out for IMPLEMENTED (11) too.
|
|
3584
|
-
|
|
3585
|
-
awk -F'\t' '{printf " %-14s %-14s %s\n", $1, $2, $3}' "$PLAN/results.tsv"
|
|
3908
|
+
render_results_table "$PLAN"
|
|
3586
3909
|
echo
|
|
3587
3910
|
if [ -n "$retro_line" ]; then printf '%s\n\n' "$retro_line"; fi
|
|
3588
3911
|
run_report_extras "$PLAN"
|
|
@@ -3594,12 +3917,13 @@ do_run() {
|
|
|
3594
3917
|
|
|
3595
3918
|
# Undeclared files are reported here rather than buried in a task log, because
|
|
3596
3919
|
# this is the list that explains any CONFLICT above.
|
|
3597
|
-
local drift=0
|
|
3920
|
+
local drift=0 id_w
|
|
3921
|
+
id_w="$(id_col_width "$T")"
|
|
3598
3922
|
for id in $(all_ids "$T"); do
|
|
3599
3923
|
if [ -s "$PLAN/tasks/$id/drift.txt" ]; then
|
|
3600
3924
|
[ "$drift" = 0 ] && echo "scope drift (touched files the task did not declare):"
|
|
3601
3925
|
drift=1
|
|
3602
|
-
printf '
|
|
3926
|
+
printf ' %-*s %s\n' "$id_w" "$id" "$(drift_labelled "$PLAN/tasks/$id")"
|
|
3603
3927
|
fi
|
|
3604
3928
|
done
|
|
3605
3929
|
[ "$drift" = 1 ] && echo
|
|
@@ -3631,6 +3955,8 @@ do_run() {
|
|
|
3631
3955
|
fi
|
|
3632
3956
|
# Tasks stopped for a decision (#69): why, and the choices. Not failures to retry either.
|
|
3633
3957
|
report_decisions "$PLAN"
|
|
3958
|
+
# Split tasks whose subtasks have not all merged (#153): not failures of the task either.
|
|
3959
|
+
report_subtasks "$PLAN"
|
|
3634
3960
|
# Members implemented and waiting for their group's review (#140): not failures either.
|
|
3635
3961
|
local implemented; implemented="$(awk -F'\t' '$2=="IMPLEMENTED" {print $1}' "$PLAN/results.tsv")"
|
|
3636
3962
|
if [ -n "$implemented" ]; then
|
|
@@ -3651,6 +3977,9 @@ do_run() {
|
|
|
3651
3977
|
fi
|
|
3652
3978
|
if [ "$failed" = 1 ] && [ "$paused" = 0 ] && [ "$interrupted" = 0 ] && [ "$(cat "$PLAN/verification.status" 2>/dev/null)" = FAIL ]; then
|
|
3653
3979
|
echo "combined verification failed: see $PLAN/verification.log"
|
|
3980
|
+
if [ -s "$PLAN/verification.stale_setup" ]; then
|
|
3981
|
+
echo "warning: stale setup — generated files may predate merged setup inputs ($(cat "$PLAN/verification.stale_setup")); rerun with --setup-before-verify or prepend setup to the verify command"
|
|
3982
|
+
fi
|
|
3654
3983
|
echo
|
|
3655
3984
|
if [ -f "$PLAN/attribute_on" ] && declare -F attribute_search >/dev/null; then
|
|
3656
3985
|
# This run holds the plan lock: the search function, never the subcommand.
|
|
@@ -3672,11 +4001,24 @@ do_run() {
|
|
|
3672
4001
|
/bin/bash "$MEMORY" spend "$REPO" --run "$run_id" 2>/dev/null | sed 's/^/ /'
|
|
3673
4002
|
echo
|
|
3674
4003
|
fi
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
4004
|
+
# A goal larger than this plan (#153): once this stage has merged, the next one can be planned.
|
|
4005
|
+
[ "$failed" = 1 ] || [ "$interrupted" = 1 ] || [ "$paused" = 1 ] || report_later "$PLAN"
|
|
4006
|
+
local mem_home=""
|
|
4007
|
+
[ -f "$PLAN/no_memory" ] || mem_home="$(/bin/bash "$MEMORY" where "$REPO" 2>/dev/null)"
|
|
4008
|
+
if [ -n "$mem_home" ] && [ -s "$mem_home/.forge/memory.md" ]; then
|
|
4009
|
+
if [ "$mem_home" = "$REPO" ]; then
|
|
4010
|
+
echo "project memory: $(grep -c '^- ' "$mem_home/.forge/memory.md") fact(s) in .forge/ —"
|
|
4011
|
+
echo " uncommitted, and the only thing forge wrote outside its own branches."
|
|
4012
|
+
echo
|
|
4013
|
+
echo "Your branch and working tree were not touched, apart from .forge/ above."
|
|
4014
|
+
else
|
|
4015
|
+
# #159: a linked worktree's learnings live in the main checkout, so removing it loses none.
|
|
4016
|
+
echo "project memory: $(grep -c '^- ' "$mem_home/.forge/memory.md") fact(s) in $mem_home/.forge/ —"
|
|
4017
|
+
echo " the main checkout's, since $REPO is a linked worktree: removing that worktree loses none of them."
|
|
4018
|
+
echo " Uncommitted, and the only thing forge wrote outside its own branches."
|
|
4019
|
+
echo
|
|
4020
|
+
echo "Your branch and working tree were not touched."
|
|
4021
|
+
fi
|
|
3680
4022
|
else
|
|
3681
4023
|
echo "Your branch and working tree were not touched."
|
|
3682
4024
|
fi
|
|
@@ -3686,6 +4028,45 @@ do_run() {
|
|
|
3686
4028
|
return 0
|
|
3687
4029
|
}
|
|
3688
4030
|
|
|
4031
|
+
# The changes in the user's checkout that make it dirty, as `git status --porcelain` lines, leaving
|
|
4032
|
+
# out forge's own project memory (#156): .forge/memory.md and .forge/ledger.tsv are written into the
|
|
4033
|
+
# repository by forge and never committed by it, so they must not block forge's own integrate, nor be
|
|
4034
|
+
# what a person is told to commit or stash.
|
|
4035
|
+
user_tree_changes() { # user_tree_changes <repo>
|
|
4036
|
+
git -C "$1" status --porcelain -- . ':(exclude).forge/memory.md' ':(exclude).forge/ledger.tsv' 2>/dev/null
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
# --- verify -------------------------------------------------------------------
|
|
4040
|
+
# The plan's verification of its integration branch, and nothing else (#151): after a lane was
|
|
4041
|
+
# fixed, or to tell a flaky failure from a real one, without a `run` that has nothing to dispatch.
|
|
4042
|
+
# The same lanes or command a run would use, on the same checkout, with its results in the plan.
|
|
4043
|
+
do_verify() {
|
|
4044
|
+
local PLAN="${1:?verify needs a plan dir}"; shift
|
|
4045
|
+
while [ $# -gt 0 ]; do
|
|
4046
|
+
if forge_pp_flag verify "$PLAN" "$@"; then shift "$PP_SHIFT"; else die "verify: unknown option '$1'"; fi
|
|
4047
|
+
done
|
|
4048
|
+
[ -s "$PLAN/tasks.tsv" ] || die "no tasks.tsv in '$PLAN'" 3
|
|
4049
|
+
[ -s "$PLAN/wt_root" ] && [ -s "$PLAN/repo" ] && [ -s "$PLAN/accepted.integration" ] \
|
|
4050
|
+
|| die "this plan has never been run, so it has no integration branch to verify" 3
|
|
4051
|
+
local REPO int_wt
|
|
4052
|
+
REPO="$(cat "$PLAN/repo")"; int_wt="$(cat "$PLAN/wt_root")/_integration"
|
|
4053
|
+
[ -e "$int_wt/.git" ] || die "the integration worktree $int_wt is missing" 3
|
|
4054
|
+
[ "$(git -C "$int_wt" rev-parse HEAD 2>/dev/null)" = "$(cat "$PLAN/accepted.integration")" ] \
|
|
4055
|
+
|| die "integration branch changed outside this run. To bring those commits into the run: forge-parallel.sh adopt $PLAN --head --reason \"...\"" 3
|
|
4056
|
+
verify_lanes_check "$PLAN" "$REPO" "$int_wt"
|
|
4057
|
+
local left="" lid
|
|
4058
|
+
for lid in $(all_ids "$PLAN/tasks.tsv"); do
|
|
4059
|
+
case "$(task_status "$PLAN" "$lid")" in PENDING|BLOCKED|RUNNING) left="${left:+$left }$lid" ;; esac
|
|
4060
|
+
done
|
|
4061
|
+
[ -z "$left" ] || note "tasks still to run ($left): this verifies the integration branch as it is now, without them"
|
|
4062
|
+
local rc=0
|
|
4063
|
+
verify_result "$PLAN" "$int_wt" "$PLAN" || rc=$?
|
|
4064
|
+
write_results "$PLAN"
|
|
4065
|
+
report_verify_notes "$PLAN"
|
|
4066
|
+
echo "verification of $(git -C "$int_wt" rev-parse --short HEAD 2>/dev/null): $(cat "$PLAN/verification.status" 2>/dev/null || echo UNVERIFIED)"
|
|
4067
|
+
case "$rc" in 0) return 0 ;; 130) return 130 ;; *) return 5 ;; esac
|
|
4068
|
+
}
|
|
4069
|
+
|
|
3689
4070
|
# --- integrate ----------------------------------------------------------------
|
|
3690
4071
|
do_integrate() {
|
|
3691
4072
|
local PLAN="${1:?}"; shift
|
|
@@ -3697,13 +4078,16 @@ do_integrate() {
|
|
|
3697
4078
|
esac
|
|
3698
4079
|
done
|
|
3699
4080
|
[ "$APPROVED" = 1 ] || die "integrate needs --approved: it merges forge's work into YOUR current branch"
|
|
4081
|
+
! forge_is_sub_plan "$PLAN" || die "integrate: '$PLAN' is the sub-plan of a split task; its work merges into that task. Integrate the plan it belongs to: $(forge_decompose_py root "$PLAN" 2>/dev/null)" 3
|
|
3700
4082
|
report_unmerged "$PLAN"
|
|
3701
4083
|
local REPO run_id int_br cur
|
|
3702
4084
|
REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"; int_br="forge/$run_id-integration"
|
|
3703
4085
|
cur="$(cd "$REPO" && git rev-parse --abbrev-ref HEAD)"
|
|
3704
4086
|
[ "$cur" = HEAD ] && die "integration requires a checked-out user branch" 3
|
|
3705
4087
|
[ "$cur" = "$int_br" ] && die "you are already on $int_br"
|
|
3706
|
-
|
|
4088
|
+
local dirty; dirty="$(user_tree_changes "$REPO")"
|
|
4089
|
+
[ -z "$dirty" ] || die "working tree is dirty — commit or stash before integrating (forge's own .forge/memory.md and .forge/ledger.tsv do not count):
|
|
4090
|
+
$(printf '%s\n' "$dirty" | head -10)"
|
|
3707
4091
|
# Verify the actual combined candidate, including changes on the user's branch.
|
|
3708
4092
|
local parent target candidate candidate_sha out
|
|
3709
4093
|
parent="$(git -C "$REPO" rev-parse HEAD)" || return 3
|
|
@@ -3746,7 +4130,7 @@ do_integrate() {
|
|
|
3746
4130
|
[ "$(git -C "$REPO" rev-parse --abbrev-ref HEAD)" = "$cur" ] &&
|
|
3747
4131
|
[ "$(git -C "$REPO" rev-parse HEAD)" = "$parent" ] &&
|
|
3748
4132
|
[ "$(git -C "$REPO" rev-parse "$int_br")" = "$target" ] &&
|
|
3749
|
-
[ -z "$(
|
|
4133
|
+
[ -z "$(user_tree_changes "$REPO")" ] || die "branch or working tree changed during verification" 3
|
|
3750
4134
|
git -C "$REPO" merge --ff-only "$candidate_sha" || return 6
|
|
3751
4135
|
# The user's branch has moved: the run shipped. Recorded now, because the cleanup below
|
|
3752
4136
|
# can still fail and make the command's exit code say otherwise.
|
|
@@ -4023,10 +4407,9 @@ AUTO_PROFILE
|
|
|
4023
4407
|
# --- main ---------------------------------------------------------------------
|
|
4024
4408
|
if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
|
|
4025
4409
|
awk '/^# Usage:/ {on=1} /^set -uo pipefail/ {on=0} on {sub(/^# ?/, ""); print}' "$SELF"
|
|
4026
|
-
forge_fractal_help
|
|
4027
4410
|
exit 0
|
|
4028
4411
|
fi
|
|
4029
|
-
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|auto|run|retry|accept|adopt|review|integrate|split|attribute|combine> <plan-dir> [...]"
|
|
4412
|
+
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|auto|run|retry|accept|adopt|review|integrate|split|attribute|verify|combine|next> <plan-dir> [...]"
|
|
4030
4413
|
CMD="$1"; shift
|
|
4031
4414
|
[ ! -f "${1:-}/no_ripwire" ] || export FORGE_RIPWIRE=off
|
|
4032
4415
|
if [ -d "${1:-}" ]; then
|
|
@@ -4034,8 +4417,8 @@ if [ -d "${1:-}" ]; then
|
|
|
4034
4417
|
fi
|
|
4035
4418
|
case "$CMD" in
|
|
4036
4419
|
# `combine` takes a plan dir that does not exist yet and locks its sources itself.
|
|
4037
|
-
run|retry|integrate|accept|adopt|review|split|attribute)
|
|
4038
|
-
if [ "${FORGE_PLAN_LOCK:-}" != "${1:-}" ]; then
|
|
4420
|
+
run|retry|integrate|accept|adopt|review|split|attribute|verify)
|
|
4421
|
+
if [ "$(forge_posix_path "${FORGE_PLAN_LOCK:-}")" != "${1:-}" ]; then
|
|
4039
4422
|
exec python3 "$SKILL_DIR/scripts/forge-schedule.py" lock "$SELF" "$CMD" "$@"
|
|
4040
4423
|
fi ;;
|
|
4041
4424
|
esac
|
|
@@ -4043,7 +4426,7 @@ esac
|
|
|
4043
4426
|
# path (die included). Installed after the lock re-exec, so it fires once, in the process
|
|
4044
4427
|
# that did the work; `_task` and `_merge` are parts of a `run` and are not recorded alone.
|
|
4045
4428
|
case "$CMD" in
|
|
4046
|
-
plan|run|retry|integrate|accept|adopt|review|split|attribute|combine)
|
|
4429
|
+
plan|run|retry|integrate|accept|adopt|review|split|attribute|verify|combine)
|
|
4047
4430
|
FORGE_DATASET_INVOCATION="inv-$(date +%s)-$$-$RANDOM"; export FORGE_DATASET_INVOCATION
|
|
4048
4431
|
FORGE_DATASET_STARTED="$(date +%s)"
|
|
4049
4432
|
FORGE_DATASET_ARGV=("$@")
|
|
@@ -4054,7 +4437,7 @@ esac
|
|
|
4054
4437
|
need_fn() { declare -F "$1" >/dev/null || die "'$CMD' is not available: $1 is missing" 3; }
|
|
4055
4438
|
# A plan with a frozen profile asks its decision-model gates from that copy (`plan` does it itself,
|
|
4056
4439
|
# after it freezes). The internal subcommands inherit it from the `run` that started them.
|
|
4057
|
-
case "$CMD" in run|retry|integrate|accept|adopt|review|split|attribute) forge_profile_export "${1:-}" ;; esac
|
|
4440
|
+
case "$CMD" in run|retry|integrate|accept|adopt|review|split|attribute|verify) forge_profile_export "${1:-}" ;; esac
|
|
4058
4441
|
case "$CMD" in
|
|
4059
4442
|
plan) do_plan "$@"; rc=$?; forge_update_notice; exit "$rc" ;;
|
|
4060
4443
|
auto) do_auto "$@" ;;
|
|
@@ -4092,7 +4475,9 @@ case "$CMD" in
|
|
|
4092
4475
|
review) need_fn do_review; do_review "$@" ;;
|
|
4093
4476
|
split) need_fn do_split; do_split "$@" ;;
|
|
4094
4477
|
attribute) need_fn do_attribute; do_attribute "$@" ;;
|
|
4478
|
+
verify) do_verify "$@" ;;
|
|
4095
4479
|
combine) need_fn do_combine; do_combine "$@" ;;
|
|
4480
|
+
next) need_fn do_next; do_next "$@" ;;
|
|
4096
4481
|
_task) do_task "$@" ;;
|
|
4097
4482
|
_merge) merge_task "$@" ;;
|
|
4098
4483
|
_group) need_fn do_group; do_group "$@" ;;
|