@giamme/forge 0.14.1 → 0.16.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 +46 -0
- package/SKILL.md +47 -14
- package/VERSION +1 -1
- package/docs/artifacts.md +1 -1
- package/docs/commands.md +302 -9
- package/docs/forge-ui.md +14 -0
- package/docs/memory.md +22 -0
- package/docs/models.md +53 -0
- package/docs/reviews.md +7 -0
- package/forge +11 -0
- package/package.json +1 -1
- package/references/dataset.md +16 -4
- package/references/decompose.md +154 -9
- package/references/harnesses.md +21 -1
- package/references/planning.md +59 -0
- package/references/solo.md +5 -1
- package/references/ui.md +48 -1
- package/scripts/forge-artifact.sh +53 -0
- package/scripts/forge-compare.py +6 -3
- package/scripts/forge-config.py +531 -4
- package/scripts/forge-contract.py +55 -8
- package/scripts/forge-control.py +0 -2
- package/scripts/forge-dispatch.sh +84 -14
- package/scripts/forge-fail-first.py +3 -1
- package/scripts/forge-guard.py +247 -8
- package/scripts/forge-issues.py +12 -0
- package/scripts/forge-lib-adopt.sh +260 -0
- package/scripts/forge-lib-attribute.sh +10 -2
- package/scripts/forge-lib-plans.sh +35 -6
- package/scripts/forge-lib-review.sh +13 -5
- package/scripts/forge-lib-task.sh +138 -5
- package/scripts/forge-memory.sh +41 -4
- package/scripts/forge-metrics.sh +7 -0
- package/scripts/forge-parallel-options.sh +12 -6
- package/scripts/forge-parallel.sh +659 -32
- package/scripts/forge-plan-check.py +591 -8
- package/scripts/forge-planner.py +480 -0
- package/scripts/forge-route.py +16 -2
- package/scripts/forge-runs-rm.py +23 -7
- package/scripts/forge-runtime.py +111 -2
- package/scripts/forge-schedule.py +5 -2
- package/scripts/forge-shadow.py +53 -7
- package/scripts/forge-solo.sh +87 -7
- package/scripts/forge_dataset/cli.py +26 -0
- package/scripts/forge_dataset/efforts.py +215 -0
- package/scripts/forge_dataset/export.py +1 -0
- package/scripts/forge_dataset/harvest.py +55 -0
- package/scripts/forge_dataset/history.py +126 -0
- package/scripts/forge_dataset/worktrees.py +95 -0
- package/scripts/forge_decide/__init__.py +19 -1
- package/scripts/forge_decide/builtin_profiles.json +25 -0
- package/scripts/forge_decide/cli.py +12 -0
- package/scripts/forge_decide/profiles.py +866 -0
- package/scripts/forge_decide/resolve.py +38 -6
- package/scripts/forge_memory_list.py +153 -0
- package/scripts/forge_worktrees.py +88 -0
- package/ui/README.md +31 -0
- package/ui/docs/api.md +168 -12
- package/ui/forge_ui/__init__.py +14 -1
- package/ui/forge_ui/__main__.py +1 -1
- package/ui/forge_ui/control.py +250 -12
- package/ui/forge_ui/executions.py +28 -8
- package/ui/forge_ui/findings.py +7 -0
- package/ui/forge_ui/models.py +60 -1
- package/ui/forge_ui/projects.py +571 -0
- package/ui/forge_ui/reader.py +48 -8
- package/ui/forge_ui/static/app.js +99 -21
- package/ui/forge_ui/static/cloudui.js +6 -2
- package/ui/forge_ui/static/convo.js +1 -1
- package/ui/forge_ui/static/diffview.js +2 -2
- package/ui/forge_ui/static/files.js +1 -1
- package/ui/forge_ui/static/index.html +5 -1
- package/ui/forge_ui/static/leaderboard.js +5 -1
- package/ui/forge_ui/static/modelstats.js +25 -1
- package/ui/forge_ui/static/panel.js +47 -4
- package/ui/forge_ui/static/projectsview.js +372 -0
- package/ui/forge_ui/static/settings.js +924 -29
- package/ui/forge_ui/static/style.css +116 -3
- package/ui/forge_ui/static/uikit.js +94 -1
- package/ui/forge_ui/static/worktreesview.js +250 -0
- package/ui/forge_ui/worktrees.py +570 -0
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
#
|
|
7
7
|
# Usage:
|
|
8
8
|
# forge-parallel.sh plan <plan-dir> --repo <dir> [routing flags] [--decompose-level low|medium|high] [--ui]
|
|
9
|
-
# [--qa-threshold P0|P1|P2|P3|none|default]
|
|
9
|
+
# [--qa-threshold P0|P1|P2|P3|none|default] [--profile NAME | --no-profile]
|
|
10
|
+
# [--collapse-chains]
|
|
11
|
+
# forge-parallel.sh auto <plan-dir> --repo <dir> --goal-file <file> [--planner <spec>] [--decompose-level L]
|
|
12
|
+
# [--plan auto|always|never] [--one-task-difficulty low|medium|high]
|
|
13
|
+
# [--no-collapse] [--approved] [plan flags...] [-- run flags...]
|
|
10
14
|
# forge-parallel.sh run <plan-dir> [--max-parallel N] [--yolo-dwarf] [--yolo-qa]
|
|
11
15
|
# [--verify <command>] [--setup <command>] [--dry-run]
|
|
12
16
|
# [--timeout S] [--retry-failed N] [--infra-retries M]
|
|
@@ -15,13 +19,17 @@
|
|
|
15
19
|
# [--sweep-ahead | --no-sweep-ahead] [--attribute | --no-attribute]
|
|
16
20
|
# forge-parallel.sh retry <plan-dir> <task-id> [--dwarf <spec>] [--setup <command>]
|
|
17
21
|
# [--answer <text> | --answer-file <file>] (a NEEDS_INPUT task)
|
|
18
|
-
# [--decide retry=N|threshold=Pn
|
|
22
|
+
# [--decide retry=N|threshold=Pn] [--dwarf <spec>] --reason "<why>" --approved
|
|
19
23
|
# (a NEEDS_DECISION task)
|
|
24
|
+
# [--no-dispatch] (prepare it and start nothing: the next `run` dispatches it)
|
|
20
25
|
# [--timeout S] [--qa-threshold Pn|none|default] [--verify-retries N]
|
|
26
|
+
# [--retry-failed N] [--infra-retries M]
|
|
21
27
|
# forge-parallel.sh integrate <plan-dir> --approved [--verify-retries N] [--final-review <qa-spec>]
|
|
22
28
|
# forge-parallel.sh review <plan-dir> [--qa <spec>] [--yolo-qa] [--qa-threshold Pn|none|default]
|
|
23
29
|
# forge-parallel.sh attribute <plan-dir> [--force] (find a merge that breaks the failed verification)
|
|
24
30
|
# forge-parallel.sh accept <plan-dir> <task-id> --reason "<why>" --approved
|
|
31
|
+
# forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason "<why>" [--qa <spec>] [--approved]
|
|
32
|
+
# (a commit made outside forge, reviewed alone, comes into the run)
|
|
25
33
|
# forge-parallel.sh split <plan-dir> <new-plan> --tasks <id,id> [--dry-run]
|
|
26
34
|
# forge-parallel.sh combine <new-plan> <plan-a> <plan-b> [<plan>...] [--verify <command>] [--dry-run]
|
|
27
35
|
# forge-parallel.sh _task <plan-dir> <task-id> (internal; coordinator target)
|
|
@@ -51,11 +59,25 @@
|
|
|
51
59
|
# still what the review judged, and starts fresh whenever it cannot;
|
|
52
60
|
# each attempt is logged in tasks/<id>/implementer_sessions.tsv.
|
|
53
61
|
# `--no-implementer-session` turns it off (the default)
|
|
62
|
+
# --fast ROLES which of dwarf, qa, planner, review ask for the fast service tier
|
|
63
|
+
# (comma list, or all, or none). Kept in the plan; a re-plan without
|
|
64
|
+
# the flag keeps it, and none removes it. codex and claude only
|
|
65
|
+
# --profile NAME take the routing and policy values of a named profile (forge config
|
|
66
|
+
# profile list) instead of typing them: frozen into the plan as
|
|
67
|
+
# profile.json, shown in the table, and its decision-model gates and
|
|
68
|
+
# budget stay the plan's whatever decide.json says later. A flag of
|
|
69
|
+
# this call replaces just that one value. --no-profile uses none (and
|
|
70
|
+
# removes the plan's frozen copy); with neither, the plan keeps its
|
|
71
|
+
# copy, and a plan that has none gets the default profile, if one is set
|
|
54
72
|
# --explore E on by default at 0.2 (0 turns it off, and is kept): a row left
|
|
55
73
|
# to forge gets, with probability E/2, its neighbouring model
|
|
56
74
|
# (one tier away in the given pools) instead of its pool's turn;
|
|
57
75
|
# each decision and its odds go to tasks/<id>/route.jsonl
|
|
58
|
-
# (precedence: flag, this plan's earlier choice, FORGE_ROUTE_EXPLORE)
|
|
76
|
+
# (precedence: flag, profile, this plan's earlier choice, FORGE_ROUTE_EXPLORE)
|
|
77
|
+
# --collapse-chains this call only (not kept): after the task table is validated and
|
|
78
|
+
# before routing, merge a chain into one task named combined.
|
|
79
|
+
# A one-task or branching plan is left as it is, and collapsing
|
|
80
|
+
# a plan that is already collapsed is not an error
|
|
59
81
|
#
|
|
60
82
|
# The QA threshold (plan, run, retry, review; kept for the plan):
|
|
61
83
|
# --qa-threshold Pn the least severe CONFIRMED finding that still blocks (P0 worst ...
|
|
@@ -80,6 +102,28 @@
|
|
|
80
102
|
# --attribute when the run's combined verification fails, search the merge order for
|
|
81
103
|
# a merge that breaks it (kept for the plan; --no-attribute turns it off)
|
|
82
104
|
#
|
|
105
|
+
# auto (#87, #88): from a goal to a finished run in one blocking command, with no orchestrating
|
|
106
|
+
# session in between. In a NEW plan dir (created when missing; one that already has tasks.tsv
|
|
107
|
+
# is refused, exit 2): the goal is copied verbatim to <plan-dir>/request.md and `auto` is
|
|
108
|
+
# written to <plan-dir>/orchestrator (the plan event in the dataset records it). Then
|
|
109
|
+
# 1. the gate (--plan): auto = forge-planner.py gate; always = plan; never = one task
|
|
110
|
+
# 2. one task: forge-planner.py one-task --difficulty (--one-task-difficulty, default medium);
|
|
111
|
+
# no planner is dispatched
|
|
112
|
+
# 3. planning: the spec is --planner, else the routing.planner of the profile the plan flags
|
|
113
|
+
# select (neither: exit 2). A preflight (forge-dispatch.sh doctor) runs before any model
|
|
114
|
+
# call, the planner is dispatched into the plan dir (with the fast tier when planner is a
|
|
115
|
+
# fast role), and its reply is parsed strictly by forge-planner.py parse
|
|
116
|
+
# 4. `plan` with every flag before `--` that is not auto's own, plus --collapse-chains unless
|
|
117
|
+
# --no-collapse. When its gates send items back (plan.sendback.md, exit 4), the planner is
|
|
118
|
+
# re-dispatched once with that file appended and the reply planned again
|
|
119
|
+
# 5. without --approved: stop, exit 0, after printing the exact `run` command; nothing is
|
|
120
|
+
# dispatched after the planner. With --approved (the user's explicit pre-approval): `run`
|
|
121
|
+
# with the flags after `--`, and auto exits with its code
|
|
122
|
+
# auto exit codes: 0 stopped at approval, or the run's 0 | 2 usage (no planner, a plan dir that
|
|
123
|
+
# already has tasks.tsv, ...) | 4 the planner failed, its reply was refused, or the plan gates
|
|
124
|
+
# sent items back a second time | 8 the planner stopped on an infrastructure failure (nothing
|
|
125
|
+
# was dispatched after it) | otherwise the exit code of the preflight, of `plan` or of `run`
|
|
126
|
+
#
|
|
83
127
|
# Exit codes: 0 ok | 2 usage/validation | 3 precondition (not a git repo, etc.)
|
|
84
128
|
# 5 some task failed QA or verification failed | 6 integration conflict
|
|
85
129
|
# 8 paused on an infrastructure failure (quota, auth, network): no attempt was
|
|
@@ -103,7 +147,7 @@ JEV_OPTS=0
|
|
|
103
147
|
# Flags shared by several subcommands, then the helper libraries. Functions only, resolved
|
|
104
148
|
# at call time, so they may use die/note/field and friends defined below.
|
|
105
149
|
source "$SKILL_DIR/scripts/forge-parallel-options.sh"
|
|
106
|
-
for forge_lib in task gates verify attribute plans review; do
|
|
150
|
+
for forge_lib in task gates verify attribute plans review adopt; do
|
|
107
151
|
[ -f "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh" ] && source "$SKILL_DIR/scripts/forge-lib-$forge_lib.sh"
|
|
108
152
|
done
|
|
109
153
|
OUTPUT=summary
|
|
@@ -163,11 +207,113 @@ pool_pick() { # pool_pick <comma-list> <index>
|
|
|
163
207
|
echo "$last"
|
|
164
208
|
}
|
|
165
209
|
|
|
210
|
+
# --- profiles (#48) -------------------------------------------------------------
|
|
211
|
+
# A named profile is chosen at `plan` (or by forge-solo.sh), frozen as <dir>/profile.json
|
|
212
|
+
# and applied as the values its flags would have set. forge_decide.profiles does the
|
|
213
|
+
# reading, checking and freezing; these functions only carry its answers to the shell.
|
|
214
|
+
forge_profile_py() { PYTHONPATH="$SKILL_DIR/scripts${PYTHONPATH:+:$PYTHONPATH}" python3 -m forge_decide.profiles "$@"; }
|
|
215
|
+
|
|
216
|
+
# Gates and budget come from the frozen copy: FORGE_DECIDE_PROFILE_JSON is read by the
|
|
217
|
+
# decide resolution at its profile level, for this process and every child of it.
|
|
218
|
+
forge_profile_export() { # forge_profile_export <plan-dir>
|
|
219
|
+
local text
|
|
220
|
+
[ -f "${1:-}/profile.json" ] || return 0
|
|
221
|
+
text="$(forge_profile_py decide "$1/profile.json" 2>/dev/null)" || return 0
|
|
222
|
+
[ -z "$text" ] || export FORGE_DECIDE_PROFILE_JSON="$text"
|
|
223
|
+
return 0
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
# Before anything is written: an unknown or invalid profile stops `plan` here (exit 2).
|
|
227
|
+
forge_profile_precheck() { # forge_profile_precheck <plan-dir> <plan's arguments...>
|
|
228
|
+
local plan="$1" name="" none=0 repo="" prev="" arg; shift
|
|
229
|
+
for arg in "$@"; do
|
|
230
|
+
case "$prev" in
|
|
231
|
+
--profile) name="$arg"; prev=""; continue ;;
|
|
232
|
+
--repo) repo="$arg"; prev=""; continue ;;
|
|
233
|
+
esac
|
|
234
|
+
prev=""
|
|
235
|
+
case "$arg" in --profile|--repo) prev="$arg" ;; --no-profile) none=1 ;; esac
|
|
236
|
+
done
|
|
237
|
+
[ -z "$name" ] || [ "$none" = 0 ] || die "--profile and --no-profile are mutually exclusive"
|
|
238
|
+
[ -n "$repo" ] || repo="$(cat "$plan/repo" 2>/dev/null)"
|
|
239
|
+
local flags=()
|
|
240
|
+
[ -z "$name" ] || flags+=(--profile "$name")
|
|
241
|
+
[ "$none" = 0 ] || flags+=(--no-profile)
|
|
242
|
+
forge_profile_py freeze "$plan" ${repo:+--repo "$repo"} ${flags[@]+"${flags[@]}"} --check-only || exit $?
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
# Chooses, freezes and applies the plan's profile. Reads and sets do_plan's locals (dynamic
|
|
246
|
+
# scope, as forge_fast_parse does): a value a flag of this call gave is never replaced.
|
|
247
|
+
forge_profile_plan() {
|
|
248
|
+
local args=() out key val repo
|
|
249
|
+
[ -z "$D_ANY" ] || args+=(--given routing.dwarf.any)
|
|
250
|
+
[ -z "$D_LO" ] || args+=(--given routing.dwarf.low)
|
|
251
|
+
[ -z "$D_MD" ] || args+=(--given routing.dwarf.medium)
|
|
252
|
+
[ -z "$D_HI" ] || args+=(--given routing.dwarf.high)
|
|
253
|
+
[ -z "$Q_ANY" ] || args+=(--given routing.qa.any)
|
|
254
|
+
[ -z "$Q_LO" ] || args+=(--given routing.qa.low)
|
|
255
|
+
[ -z "$Q_MD" ] || args+=(--given routing.qa.medium)
|
|
256
|
+
[ -z "$Q_HI" ] || args+=(--given routing.qa.high)
|
|
257
|
+
[ -z "$PLANNER" ] || args+=(--given routing.planner)
|
|
258
|
+
[ -z "$SHADOW_QA" ] || args+=(--given policy.shadow_qa)
|
|
259
|
+
[ -z "$SHADOW_RATE" ] || args+=(--given policy.shadow_rate)
|
|
260
|
+
[ -z "$EXPLORE" ] || args+=(--given policy.explore)
|
|
261
|
+
[ "$FAST_GIVEN" != 1 ] || args+=(--given policy.fast)
|
|
262
|
+
[ "$PF_QT" != 1 ] || args+=(--given policy.qa_threshold)
|
|
263
|
+
[ -z "$PF_NAME" ] || args+=(--profile "$PF_NAME")
|
|
264
|
+
[ "$PF_NONE" = 0 ] || args+=(--no-profile)
|
|
265
|
+
repo="$REPO"; [ -n "$repo" ] || repo="$(cat "$PLAN/repo" 2>/dev/null)"
|
|
266
|
+
out="$(forge_profile_py freeze "$PLAN" ${repo:+--repo "$repo"} ${args[@]+"${args[@]}"})" || exit $?
|
|
267
|
+
while IFS="$(printf '\t')" read -r key val; do
|
|
268
|
+
case "$key" in
|
|
269
|
+
routing.dwarf.any) D_ANY="$val" ;;
|
|
270
|
+
routing.dwarf.low) D_LO="$val" ;;
|
|
271
|
+
routing.dwarf.medium) D_MD="$val" ;;
|
|
272
|
+
routing.dwarf.high) D_HI="$val" ;;
|
|
273
|
+
routing.qa.any) Q_ANY="$val" ;;
|
|
274
|
+
routing.qa.low) Q_LO="$val" ;;
|
|
275
|
+
routing.qa.medium) Q_MD="$val" ;;
|
|
276
|
+
routing.qa.high) Q_HI="$val" ;;
|
|
277
|
+
routing.planner) PLANNER="$val" ;;
|
|
278
|
+
policy.shadow_qa) SHADOW_QA="$val" ;;
|
|
279
|
+
policy.shadow_rate) SHADOW_RATE="$val" ;;
|
|
280
|
+
policy.explore) EXPLORE="$val" ;;
|
|
281
|
+
policy.fast) forge_fast_parse "$val" plan; FAST_GIVEN=1 ;;
|
|
282
|
+
esac
|
|
283
|
+
done <<EOF
|
|
284
|
+
$out
|
|
285
|
+
EOF
|
|
286
|
+
forge_profile_export "$PLAN"
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
# What `run` reads from the frozen profile when its flags do not say: the retry budgets,
|
|
290
|
+
# and the Fractal planner (only with --fractal-auto-decompose, which --fractal-planner needs).
|
|
291
|
+
forge_profile_run_values() { # forge_profile_run_values <plan-dir>
|
|
292
|
+
local key val arg auto=0 planner=0
|
|
293
|
+
[ -f "$1/profile.json" ] || return 0
|
|
294
|
+
for arg in ${FRACTAL_ARGS[@]+"${FRACTAL_ARGS[@]}"}; do
|
|
295
|
+
case "$arg" in --fractal-auto-decompose) auto=1 ;; --fractal-planner) planner=1 ;; esac
|
|
296
|
+
done
|
|
297
|
+
while IFS="$(printf '\t')" read -r key val; do
|
|
298
|
+
case "$key" in
|
|
299
|
+
policy.retry_failed) [ "$PP_RETRY_FAILED_SET" = 1 ] || PP_RETRY_FAILED="$val" ;;
|
|
300
|
+
policy.infra_retries) [ "$PP_INFRA_RETRIES_SET" = 1 ] || PP_INFRA_RETRIES="$val" ;;
|
|
301
|
+
routing.fractal_planner) [ "$auto$planner" != 10 ] || FRACTAL_ARGS+=(--fractal-planner "$val") ;;
|
|
302
|
+
esac
|
|
303
|
+
done <<EOF
|
|
304
|
+
$(forge_profile_py value "$1/profile.json" policy.retry_failed policy.infra_retries routing.fractal_planner 2>/dev/null)
|
|
305
|
+
EOF
|
|
306
|
+
}
|
|
307
|
+
|
|
166
308
|
do_plan() {
|
|
167
309
|
local PLAN="${1:?plan needs a plan dir}"; shift
|
|
310
|
+
local PF_NAME="" PF_NONE=0 PF_QT=0
|
|
311
|
+
forge_profile_precheck "$PLAN" "$@"
|
|
168
312
|
local REPO="" D_ANY="" D_HI="" D_MD="" D_LO="" Q_ANY="" Q_HI="" Q_MD="" Q_LO=""
|
|
169
313
|
PP_INFRA_FALLBACK=""
|
|
170
314
|
local PLANNER="" NOMEM=0 jev_rc=0 DLEVEL="" SHADOW_QA="" SHADOW_RATE="" EXPLORE="" FAIL_FIRST="" REVIEWER_SESSION="" IMPLEMENTER_SESSION="" PRE_REVIEW="" PRE_REVIEW_PARALLEL=""
|
|
315
|
+
local FAST_GIVEN=0 FAST_PARSED=""
|
|
316
|
+
local COLLAPSE=0 COLLAPSED_NOW=0
|
|
171
317
|
while [ $# -gt 0 ]; do
|
|
172
318
|
case "$1" in
|
|
173
319
|
--repo) REPO="${2:?}"; shift 2 ;;
|
|
@@ -177,6 +323,8 @@ do_plan() {
|
|
|
177
323
|
*) die "--decompose-level must be low, medium or high" ;; esac ;;
|
|
178
324
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
179
325
|
--no-memory) NOMEM=1; shift ;;
|
|
326
|
+
--profile) PF_NAME="${2:?--profile needs a profile name}"; shift 2 ;;
|
|
327
|
+
--no-profile) PF_NONE=1; shift ;;
|
|
180
328
|
--shadow-qa)
|
|
181
329
|
[ -n "${2:-}" ] || die "--shadow-qa needs a QA spec, a comma list of specs, or none"
|
|
182
330
|
SHADOW_QA="$2"; shift 2 ;;
|
|
@@ -184,6 +332,7 @@ do_plan() {
|
|
|
184
332
|
printf '%s' "${2:-}" | grep -Eq '^(0?\.[0-9]+|0|1|1\.0+)$' || die "--shadow-rate needs a share between 0 and 1"
|
|
185
333
|
SHADOW_RATE="$2"; shift 2 ;;
|
|
186
334
|
--explore) EXPLORE="${2:?--explore needs a share between 0 and 0.5}"; shift 2 ;;
|
|
335
|
+
--collapse-chains) COLLAPSE=1; shift ;;
|
|
187
336
|
--dwarf) D_ANY="${2:?}"; shift 2 ;;
|
|
188
337
|
--dwarf-high) D_HI="${2:?}"; shift 2 ;;
|
|
189
338
|
--dwarf-medium) D_MD="${2:?}"; shift 2 ;;
|
|
@@ -205,11 +354,19 @@ do_plan() {
|
|
|
205
354
|
--no-reviewer-session) REVIEWER_SESSION=off; shift ;;
|
|
206
355
|
--implementer-session) IMPLEMENTER_SESSION=on; shift ;;
|
|
207
356
|
--no-implementer-session) IMPLEMENTER_SESSION=off; shift ;;
|
|
357
|
+
--fast)
|
|
358
|
+
[ -n "${2:-}" ] || die "--fast needs a comma list of roles (dwarf, qa, planner, review), all or none"
|
|
359
|
+
forge_fast_parse "$2" plan
|
|
360
|
+
FAST_GIVEN=1
|
|
361
|
+
shift 2 ;;
|
|
208
362
|
*)
|
|
209
363
|
# `case` is not a loop, so `continue` here belongs to the enclosing while.
|
|
210
364
|
# The shared flags write into the plan dir (--qa-threshold), so it must exist first.
|
|
211
365
|
[ -d "$PLAN" ] || die "plan dir '$PLAN' does not exist"
|
|
212
|
-
if forge_pp_flag plan "$PLAN" "$@"; then
|
|
366
|
+
if forge_pp_flag plan "$PLAN" "$@"; then
|
|
367
|
+
[ "$1" != --qa-threshold ] || PF_QT=1
|
|
368
|
+
shift "$PP_SHIFT"; continue
|
|
369
|
+
fi
|
|
213
370
|
if [ "$JEV_OPTS" = 1 ]; then
|
|
214
371
|
forge_jev_flag "$@"; jev_rc=$?
|
|
215
372
|
case "$jev_rc" in
|
|
@@ -221,8 +378,11 @@ do_plan() {
|
|
|
221
378
|
;;
|
|
222
379
|
esac
|
|
223
380
|
done
|
|
224
|
-
[ "$JEV_OPTS" = 1 ] && forge_jev_export
|
|
225
381
|
[ -d "$PLAN" ] || die "plan dir '$PLAN' does not exist"
|
|
382
|
+
# The profile (#48) first: its gates and budget count for every decision-model step below,
|
|
383
|
+
# and its values stand in for the flags this call did not give.
|
|
384
|
+
forge_profile_plan
|
|
385
|
+
[ "$JEV_OPTS" = 1 ] && forge_jev_export
|
|
226
386
|
# Freeze the selection next to the task table, so run and retry restore it rather
|
|
227
387
|
# than re-deciding. Written on every plan: a re-plan is a new decision.
|
|
228
388
|
[ "$JEV_OPTS" = 1 ] && forge_jev_record "$PLAN"
|
|
@@ -258,6 +418,8 @@ do_plan() {
|
|
|
258
418
|
case "$REVIEWER_SESSION" in on) printf '%s\n' on > "$PLAN/reviewer_session" ;; off) rm -f "$PLAN/reviewer_session" ;; esac
|
|
259
419
|
# Implementer-session continuation (opt-in, #90): the same `on` file, read the same way.
|
|
260
420
|
case "$IMPLEMENTER_SESSION" in on) printf '%s\n' on > "$PLAN/implementer_session" ;; off) rm -f "$PLAN/implementer_session" ;; esac
|
|
421
|
+
# Which roles ask for the fast tier. Omitted on a re-plan, so an earlier choice stays.
|
|
422
|
+
forge_fast_store "$PLAN"
|
|
261
423
|
# Exploration is decided here and only here, so the table and preflight see what will run.
|
|
262
424
|
# On by default: choosing models from measured pass rates needs some randomized picks, and
|
|
263
425
|
# history had almost none (9 tasks ever ran on more than one spec). The flag wins, then
|
|
@@ -383,7 +545,46 @@ EOF
|
|
|
383
545
|
fi
|
|
384
546
|
fi
|
|
385
547
|
|
|
386
|
-
# ---
|
|
548
|
+
# --- collapse a chain, then resolve routing ---
|
|
549
|
+
# --collapse-chains acts on this call only. The gates have already run (drift may have
|
|
550
|
+
# added files). Validate, then collapse, then routing fills combined's `-` columns, and
|
|
551
|
+
# the declared copy is taken again so the declared tier is the combined task's. A second
|
|
552
|
+
# collapse (tasks.precollapse.tsv or collapsed.json already there) is not an error.
|
|
553
|
+
if [ "$COLLAPSE" = 1 ]; then
|
|
554
|
+
local vline vid vdeps vdiff vd
|
|
555
|
+
while IFS= read -r vline; do
|
|
556
|
+
case "$vline" in ''|'#'*) continue ;; esac
|
|
557
|
+
vid="$(printf '%s' "$vline" | awk -F'\t' '{print $1}')"
|
|
558
|
+
vdeps="$(printf '%s' "$vline" | awk -F'\t' '{print $2}')"
|
|
559
|
+
vdiff="$(printf '%s' "$vline" | awk -F'\t' '{print $3}')"
|
|
560
|
+
[ -n "$vid" ] || die "tasks.tsv has a row with no id"
|
|
561
|
+
case "$vdiff" in low|medium|high) ;; *) die "task '$vid' has difficulty '$vdiff' (expected low, medium or high)" ;; esac
|
|
562
|
+
if [ "$vdeps" != "-" ]; then
|
|
563
|
+
for vd in $(printf '%s' "$vdeps" | tr ',' ' '); do
|
|
564
|
+
all_ids "$T" | grep -qx "$vd" || die "task '$vid' depends on unknown task '$vd'"
|
|
565
|
+
done
|
|
566
|
+
fi
|
|
567
|
+
done < "$T"
|
|
568
|
+
local collapse_out collapse_err collapse_rc=0 collapse_msg
|
|
569
|
+
collapse_err="$PLAN/.collapse.err"
|
|
570
|
+
collapse_out="$(python3 "$SKILL_DIR/scripts/forge-plan-check.py" collapse "$PLAN" 2>"$collapse_err")" || collapse_rc=$?
|
|
571
|
+
collapse_msg="$(cat "$collapse_err" 2>/dev/null || true)"
|
|
572
|
+
rm -f "$collapse_err"
|
|
573
|
+
if [ "$collapse_rc" -ne 0 ]; then
|
|
574
|
+
case "$collapse_msg" in
|
|
575
|
+
*already\ exists*) ;;
|
|
576
|
+
*) die "could not collapse the plan${collapse_msg:+: $collapse_msg}" ;;
|
|
577
|
+
esac
|
|
578
|
+
else
|
|
579
|
+
case "$collapse_out" in
|
|
580
|
+
collapsed\ *)
|
|
581
|
+
cp "$T" "$PLAN/tasks.declared.tsv" || die "could not rewrite $PLAN/tasks.declared.tsv"
|
|
582
|
+
COLLAPSED_NOW=1
|
|
583
|
+
;;
|
|
584
|
+
esac
|
|
585
|
+
fi
|
|
586
|
+
fi
|
|
587
|
+
|
|
387
588
|
local tmp="$PLAN/.tasks.tsv.new"; : > "$tmp"
|
|
388
589
|
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
|
|
389
590
|
printf '# id\tdeps\tdifficulty\tfiles\tdwarf\tqa\ttitle\n' > "$tmp"
|
|
@@ -450,6 +651,11 @@ EOF
|
|
|
450
651
|
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$id" "$deps" "$diff" "$files" "$dw" "$qa" "$title" >> "$tmp"
|
|
451
652
|
done < "$T"
|
|
452
653
|
mv "$tmp" "$T"
|
|
654
|
+
# Which cells routing filled in, so a re-plan under another profile replaces those and no others.
|
|
655
|
+
# Kept current through a --no-profile re-plan too, once a profile has recorded any.
|
|
656
|
+
if [ -f "$PLAN/profile.json" ] || [ -f "$PLAN/routed.json" ]; then
|
|
657
|
+
forge_profile_py routed "$PLAN" 2>/dev/null || true
|
|
658
|
+
fi
|
|
453
659
|
|
|
454
660
|
compute_waves "$PLAN"
|
|
455
661
|
|
|
@@ -493,10 +699,22 @@ EOF
|
|
|
493
699
|
fi
|
|
494
700
|
fi
|
|
495
701
|
|
|
702
|
+
# After the last wave computation (a forward dep may have just changed it). Advisory:
|
|
703
|
+
# a failure is a note, and the table is still printed.
|
|
704
|
+
local shape_err="" shape_rc=0
|
|
705
|
+
shape_err="$(python3 "$SKILL_DIR/scripts/forge-plan-check.py" shape "$PLAN" --write 2>&1 >/dev/null)" || shape_rc=$?
|
|
706
|
+
if [ "$shape_rc" -ne 0 ]; then
|
|
707
|
+
note "plan shape could not be recorded (advisory)${shape_err:+: $shape_err}"
|
|
708
|
+
fi
|
|
709
|
+
|
|
496
710
|
render_table "$PLAN"
|
|
497
711
|
# What the gates did, from plan-gates.json: files and deps they added, prompts and
|
|
498
712
|
# requirements still flagged. Prints nothing when no gate recorded anything.
|
|
499
713
|
python3 "$SKILL_DIR/scripts/forge-plan-check.py" gates "$PLAN" 2>/dev/null || true
|
|
714
|
+
# Advisory, under the table: a spec measurably slower than a lower effort of the same model,
|
|
715
|
+
# once per distinct spec (doctor --spec says the same). Read from the dataset for the
|
|
716
|
+
# operator's screen only, so not by forge-plan-check.py, which builds a prompt.
|
|
717
|
+
python3 "$SKILL_DIR/scripts/forge-dataset.py" slow-notes "$PLAN" 2>/dev/null || true
|
|
500
718
|
# Advisory, under the table: a privacy floor that silences every gate, and which
|
|
501
719
|
# gates this plan's runs will ask. Prints nothing when it cannot tell.
|
|
502
720
|
[ "$jev_loaded" = 1 ] && forge_decide_plan_lines "${FORGE_DECIDE_REPO:-$REPO}"
|
|
@@ -594,6 +812,15 @@ render_table() {
|
|
|
594
812
|
if [ -f "$PLAN/implementer_session" ]; then
|
|
595
813
|
echo "implementer-session: a retry continues the implementer's earlier session when its spec is unchanged and its work is as the review left it (claude, openclaude; falls back to a fresh session)"
|
|
596
814
|
fi
|
|
815
|
+
if [ -s "$PLAN/fast" ]; then
|
|
816
|
+
local fast_roles
|
|
817
|
+
fast_roles="$(awk 'NF { printf "%s%s", (n++ ? ", " : ""), $0 }' "$PLAN/fast")"
|
|
818
|
+
echo "fast tier: $fast_roles — billed at a higher rate (codex service_tier=fast; claude fast mode needs extra usage enabled)"
|
|
819
|
+
fi
|
|
820
|
+
if [ -f "$PLAN/profile.json" ]; then
|
|
821
|
+
local profile_line; profile_line="$(forge_profile_py line "$PLAN/profile.json" 2>/dev/null)"
|
|
822
|
+
[ -z "$profile_line" ] || echo "$profile_line"
|
|
823
|
+
fi
|
|
597
824
|
# The plan-level threshold: at plan time no per-task file exists yet.
|
|
598
825
|
local qa_level qa_src
|
|
599
826
|
read -r qa_level qa_src <<EOF
|
|
@@ -631,6 +858,22 @@ EOF
|
|
|
631
858
|
done
|
|
632
859
|
echo
|
|
633
860
|
done
|
|
861
|
+
# A chain collapsed on this call, or a chain left as a chain. one and branches say nothing.
|
|
862
|
+
# COLLAPSED_NOW is do_plan's: collapsed.json from an earlier plan is not announced again.
|
|
863
|
+
local shape_note=""
|
|
864
|
+
if [ "${COLLAPSED_NOW:-0}" = 1 ] && [ -f "$PLAN/collapsed.json" ]; then
|
|
865
|
+
shape_note="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print("collapsed %d" % len(d.get("from") or []))' "$PLAN/collapsed.json" 2>/dev/null)" || shape_note=""
|
|
866
|
+
elif [ -f "$PLAN/plan-shape.json" ]; then
|
|
867
|
+
shape_note="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print("%s %s" % (d.get("shape"), d.get("tasks")))' "$PLAN/plan-shape.json" 2>/dev/null)" || shape_note=""
|
|
868
|
+
fi
|
|
869
|
+
case "$shape_note" in
|
|
870
|
+
collapsed\ *)
|
|
871
|
+
echo "collapsed a sequential plan of ${shape_note#collapsed } tasks into one (tasks.precollapse.tsv keeps the original)"
|
|
872
|
+
echo ;;
|
|
873
|
+
chain\ *)
|
|
874
|
+
echo "this plan runs sequentially: ${shape_note#chain } tasks, at most 1 in parallel; each pays its own implementation and review. One task would run once: re-plan with --collapse-chains"
|
|
875
|
+
echo ;;
|
|
876
|
+
esac
|
|
634
877
|
if [ "$starred" = 1 ]; then
|
|
635
878
|
echo "* picked by exploratory routing (--explore $(cat "$PLAN/explore" 2>/dev/null)) instead of the pool's turn;"
|
|
636
879
|
echo " to pin another model, put its spec in the dwarf column of tasks.tsv and re-plan"
|
|
@@ -679,27 +922,37 @@ dependencies_ready() {
|
|
|
679
922
|
}
|
|
680
923
|
|
|
681
924
|
preflight_plan() {
|
|
682
|
-
local plan="$1" id role flags
|
|
925
|
+
local plan="$1" id role flags ft spec key seen=";"
|
|
683
926
|
export FORGE_CAPABILITY_CACHE="$plan/capabilities"
|
|
684
927
|
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
685
928
|
for role in dwarf qa; do
|
|
686
929
|
flags=""; [ -f "$plan/yolo_$role" ] && flags=--yolo
|
|
687
|
-
|
|
930
|
+
ft="$(forge_fast_tier "$plan" "$role")"
|
|
931
|
+
spec="$(field "$plan/tasks.tsv" "$id" "$role")"
|
|
932
|
+
# Once per spec, role and options: the same arguments get the same answer, and a note doctor
|
|
933
|
+
# adds (a slow effort) is said once, not once per task.
|
|
934
|
+
key="$role|$spec|$flags|$ft"
|
|
935
|
+
case "$seen" in *";$key;"*) continue ;; esac
|
|
936
|
+
seen="$seen$key;"
|
|
937
|
+
/bin/bash "$DISPATCH" doctor --spec "$spec" --role "$role" $flags $ft || return $?
|
|
688
938
|
done
|
|
689
939
|
done
|
|
690
940
|
if [ -s "$plan/planner" ]; then
|
|
691
|
-
|
|
941
|
+
ft="$(forge_fast_tier "$plan" planner)"
|
|
942
|
+
/bin/bash "$DISPATCH" doctor --spec "$(cat "$plan/planner")" --role planner $ft || return $?
|
|
692
943
|
fi
|
|
693
944
|
# A shadow reviewer that cannot run here is dropped with a note, never a failed run.
|
|
945
|
+
# A fast-tier refusal is the exception: dispatch already refused it, and skipping the
|
|
946
|
+
# shadow would let the rest of the run be billed. That exit stops the run.
|
|
694
947
|
if [ -s "$plan/shadow_qa" ]; then
|
|
695
|
-
python3 "$SKILL_DIR/scripts/forge-shadow.py" preflight --plan "$plan" ||
|
|
948
|
+
python3 "$SKILL_DIR/scripts/forge-shadow.py" preflight --plan "$plan" || return $?
|
|
696
949
|
fi
|
|
697
950
|
}
|
|
698
951
|
|
|
699
952
|
# The implementer a sweep task gets when the plan has a low tier (or a plain --dwarf pool): checked
|
|
700
953
|
# with the rest, before any model is paid for, since no task may have used it yet.
|
|
701
954
|
sweep_preflight() { # sweep_preflight <plan>
|
|
702
|
-
local spec flags=""
|
|
955
|
+
local spec flags="" ft
|
|
703
956
|
spec="$(python3 -c 'import json, sys
|
|
704
957
|
try:
|
|
705
958
|
data = json.load(open(sys.argv[1]))
|
|
@@ -711,7 +964,8 @@ for tier in ("low", "any"):
|
|
|
711
964
|
print(specs[0]); break' "$1/fractal-routing.json" 2>/dev/null)"
|
|
712
965
|
[ -n "$spec" ] || return 0
|
|
713
966
|
[ -f "$1/yolo_dwarf" ] && flags=--yolo
|
|
714
|
-
|
|
967
|
+
ft="$(forge_fast_tier "$1" dwarf)"
|
|
968
|
+
/bin/bash "$DISPATCH" doctor --spec "$spec" --role dwarf $flags $ft
|
|
715
969
|
}
|
|
716
970
|
|
|
717
971
|
sweep_plan() { # sweep_plan <plan> --severity Pn [--plausible] [--max N]: the scheduler's _sweep
|
|
@@ -850,6 +1104,7 @@ ensure_worktree() { # ensure_worktree <repo> <wt> <br> <base> <tdir> <plan> <id>
|
|
|
850
1104
|
else
|
|
851
1105
|
(cd "$REPO" && git worktree add -b "$br" "$wt" "$base") >"$tdir/worktree.out" 2>&1
|
|
852
1106
|
fi || return 1
|
|
1107
|
+
forge_worktree_event created "$PLAN" "$REPO" "$wt" "$br" task "$id"
|
|
853
1108
|
run_worktree_setup "$PLAN" "$REPO" "$wt" "$tdir" "$id"
|
|
854
1109
|
}
|
|
855
1110
|
|
|
@@ -895,6 +1150,7 @@ do_task_body() (
|
|
|
895
1150
|
if [ -s "$PLAN/fractal-selection.json" ]; then
|
|
896
1151
|
forge_fractal_select "$PLAN" "$REPO" parallel 0 || return $?
|
|
897
1152
|
fi
|
|
1153
|
+
forge_fast_fractal_note "$PLAN"
|
|
898
1154
|
forge_metric_begin "$tdir" task
|
|
899
1155
|
dependencies_ready "$PLAN" "$id" || return 1
|
|
900
1156
|
echo RUNNING > "$tdir/status"
|
|
@@ -936,11 +1192,14 @@ do_task_body() (
|
|
|
936
1192
|
base="$(git -C "$(cat "$PLAN/wt_root")/_integration" rev-parse HEAD)"; printf '%s\n' "$base" > "$tdir/base_ref"
|
|
937
1193
|
fi
|
|
938
1194
|
|
|
939
|
-
local dw qa yd yq rc
|
|
1195
|
+
local dw qa yd yq rc ft_dwarf ft_qa
|
|
940
1196
|
dw="$(field "$T" "$id" dwarf)"; qa="$(field "$T" "$id" qa)"
|
|
941
1197
|
yd=""; yq=""
|
|
942
1198
|
[ -f "$PLAN/yolo_dwarf" ] && yd="--yolo"
|
|
943
1199
|
[ -f "$PLAN/yolo_qa" ] && yq="--yolo"
|
|
1200
|
+
# Empty when the role is not listed, so the recorded command line is unchanged.
|
|
1201
|
+
ft_dwarf="$(forge_fast_tier "$PLAN" dwarf)"
|
|
1202
|
+
ft_qa="$(forge_fast_tier "$PLAN" qa)"
|
|
944
1203
|
|
|
945
1204
|
if ! ensure_worktree "$REPO" "$wt" "$br" "$base" "$tdir" "$PLAN" "$id"; then
|
|
946
1205
|
echo ERROR > "$tdir/status"
|
|
@@ -983,7 +1242,7 @@ do_task_body() (
|
|
|
983
1242
|
is_reason=work-changed
|
|
984
1243
|
else
|
|
985
1244
|
FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$PLAN/capabilities}" \
|
|
986
|
-
/bin/bash "$DISPATCH" doctor --spec "$dw" --role dwarf $yd > "$tdir/dwarf.doctor" 2>&1 || : > "$tdir/dwarf.doctor"
|
|
1245
|
+
/bin/bash "$DISPATCH" doctor --spec "$dw" --role dwarf $yd $ft_dwarf > "$tdir/dwarf.doctor" 2>&1 || : > "$tdir/dwarf.doctor"
|
|
987
1246
|
IFS=$'\t' read -r is_mode is_reason is_id < <(review_session_decide \
|
|
988
1247
|
"$tdir/retry_findings.dwarf.session" "$tdir/retry_findings.dwarf.resolved" "$tdir/dwarf.doctor" "claude openclaude")
|
|
989
1248
|
if [ "$is_mode" = continued ]; then
|
|
@@ -994,7 +1253,7 @@ do_task_body() (
|
|
|
994
1253
|
fi
|
|
995
1254
|
forge_metric_phase dispatch
|
|
996
1255
|
local dwarf_cmd=(/bin/bash "$DISPATCH" dwarf "$dw" --repo "$wt" --run-dir "$tdir" \
|
|
997
|
-
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" ${yd:+"$yd"} --output "${FORGE_OUTPUT:-summary}")
|
|
1256
|
+
--ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/dwarf.input" ${yd:+"$yd"} $ft_dwarf --output "${FORGE_OUTPUT:-summary}")
|
|
998
1257
|
"${dwarf_cmd[@]}" ${is_cont[@]+"${is_cont[@]}"} >"$tdir/dwarf.out" 2>&1
|
|
999
1258
|
rc=$?
|
|
1000
1259
|
if [ "$rc" = 9 ] && [ "$is_mode" = continued ]; then
|
|
@@ -1109,6 +1368,7 @@ do_task_body() (
|
|
|
1109
1368
|
fi
|
|
1110
1369
|
review="$tdir/review-$attempt-$$"
|
|
1111
1370
|
forge_review_snapshot "$wt" "$base" "$reviewed" "$review" || { echo ERROR > "$tdir/status"; return 1; }
|
|
1371
|
+
forge_review_deps "$wt" "$review" "$tdir/review.deps"
|
|
1112
1372
|
source_fp="$(forge_fingerprint "$wt")" || return 1
|
|
1113
1373
|
# The review copy is a commit: an untracked file the reviewer leaves there (a test run's
|
|
1114
1374
|
# bytecode) changes nothing that merges, so only tracked content counts (#95).
|
|
@@ -1167,6 +1427,9 @@ do_task_body() (
|
|
|
1167
1427
|
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part head --kind "$qa_kind"
|
|
1168
1428
|
echo
|
|
1169
1429
|
[ ! -f "$PLAN/sweep_ahead" ] || python3 "$SKILL_DIR/scripts/forge-sweep.py" ahead "$PLAN" "$id" --role qa 2>/dev/null
|
|
1430
|
+
cat "$tdir/review.deps"
|
|
1431
|
+
[ -s "$tdir/failfirst.txt" ] || [ -s "$tdir/prereview.txt" ] || echo "Forge ran no tests of its own on this attempt, so nothing here stands in for yours."
|
|
1432
|
+
echo
|
|
1170
1433
|
if [ -s "$tdir/failfirst.txt" ]; then cat "$tdir/failfirst.txt"; echo; fi
|
|
1171
1434
|
if [ -s "$tdir/prereview.txt" ]; then cat "$tdir/prereview.txt"; echo; fi
|
|
1172
1435
|
if [ -s "$tdir/guard.txt" ]; then
|
|
@@ -1217,14 +1480,14 @@ do_task_body() (
|
|
|
1217
1480
|
rs_reason=first-round
|
|
1218
1481
|
else
|
|
1219
1482
|
FORGE_CAPABILITY_CACHE="${FORGE_CAPABILITY_CACHE:-$PLAN/capabilities}" \
|
|
1220
|
-
/bin/bash "$DISPATCH" doctor --spec "$qa" --role qa $yq > "$tdir/qa.doctor" 2>&1 || : > "$tdir/qa.doctor"
|
|
1483
|
+
/bin/bash "$DISPATCH" doctor --spec "$qa" --role qa $yq $ft_qa > "$tdir/qa.doctor" 2>&1 || : > "$tdir/qa.doctor"
|
|
1221
1484
|
IFS=$'\t' read -r rs_mode rs_reason rs_id < <(review_session_decide \
|
|
1222
1485
|
"$tdir/retry_findings.session" "$tdir/retry_findings.resolved" "$tdir/qa.doctor")
|
|
1223
1486
|
[ "$rs_mode" = continued ] && rs_cont=(--continue-session "$rs_id")
|
|
1224
1487
|
fi
|
|
1225
1488
|
fi
|
|
1226
1489
|
local qa_cmd=(/bin/bash "$DISPATCH" qa "$qa" --repo "$review" --run-dir "$tdir" \
|
|
1227
|
-
--review-base "$(cat "$tdir/review.base")" --ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/qa.input" ${yq:+"$yq"} --output "${FORGE_OUTPUT:-summary}")
|
|
1490
|
+
--review-base "$(cat "$tdir/review.base")" --ripwire-query-file "$tdir/prompt.md" --prompt-file "$tdir/qa.input" ${yq:+"$yq"} $ft_qa --output "${FORGE_OUTPUT:-summary}")
|
|
1228
1491
|
"${qa_cmd[@]}" ${rs_cont[@]+"${rs_cont[@]}"} >"$tdir/qa.out" 2>&1
|
|
1229
1492
|
rc=$?
|
|
1230
1493
|
if [ "$rc" = 9 ] && [ "$rs_mode" = continued ]; then
|
|
@@ -1320,6 +1583,7 @@ merge_task() { # merge_task <plan> <id> -> 0 merged, 1 conflicted
|
|
|
1320
1583
|
if [ -s "$PLAN/accepted.integration" ] && [ "$(git -C "$int_wt" rev-parse HEAD)" != "$(cat "$PLAN/accepted.integration")" ]; then
|
|
1321
1584
|
echo INVALIDATED > "$PLAN/tasks/$id/status"
|
|
1322
1585
|
forge_dataset_event merge --dir "$PLAN" --task "$id" --set status=INVALIDATED --set reason=integration-moved
|
|
1586
|
+
note "$id: the integration branch moved outside this run. To bring those commits into the run: forge-parallel.sh adopt $PLAN --head --reason \"...\""
|
|
1323
1587
|
return 1
|
|
1324
1588
|
fi
|
|
1325
1589
|
[ -z "$(git -C "$int_wt" status --porcelain -- . ':(exclude).forge')" ] || {
|
|
@@ -1367,7 +1631,7 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
|
1367
1631
|
local n=0 flag="" val="" novalue=0 rc=0 dwarf="" decide="" reason="" approved=0
|
|
1368
1632
|
while [ $# -gt 0 ]; do
|
|
1369
1633
|
case "$1" in
|
|
1370
|
-
--no-ripwire|--yolo-dwarf|--yolo-qa) shift ;;
|
|
1634
|
+
--no-ripwire|--yolo-dwarf|--yolo-qa|--no-dispatch) shift ;;
|
|
1371
1635
|
--output|--verify|--setup) [ $# -ge 2 ] || break; shift 2 ;;
|
|
1372
1636
|
--dwarf) [ $# -ge 2 ] || break; dwarf="$2"; shift 2 ;;
|
|
1373
1637
|
--decide) [ $# -ge 2 ] || break; decide="$2"; shift 2 ;;
|
|
@@ -1397,10 +1661,48 @@ _retry_answer_scan() { # _retry_answer_scan <scratch-dir> <retry args...>
|
|
|
1397
1661
|
# A failed task keeps its branch and worktree "so there is something to inspect and
|
|
1398
1662
|
# retry from" — this is the retry. It is a command a human types, not an automatic
|
|
1399
1663
|
# repair loop, which is what keeps forge's one-dwarf-then-QA rule intact.
|
|
1664
|
+
# The wait before `retry --infra-retries` dispatches again after an infrastructure stop: the provider's
|
|
1665
|
+
# retry-after when it gave one, else the plan's infra_backoff (the scheduler's own rule, its functions).
|
|
1666
|
+
retry_infra_wait() { # retry_infra_wait <plan> <task-dir> <cycle>
|
|
1667
|
+
local secs
|
|
1668
|
+
secs="$(python3 - "$SKILL_DIR/scripts/forge-schedule.py" "$1" "$2" "$3" <<'PY' 2>/dev/null
|
|
1669
|
+
import importlib.util, sys
|
|
1670
|
+
from pathlib import Path
|
|
1671
|
+
spec = importlib.util.spec_from_file_location('forge_schedule', sys.argv[1])
|
|
1672
|
+
module = importlib.util.module_from_spec(spec)
|
|
1673
|
+
sys.modules['forge_schedule'] = module
|
|
1674
|
+
spec.loader.exec_module(module)
|
|
1675
|
+
backoff = None
|
|
1676
|
+
try:
|
|
1677
|
+
text = (Path(sys.argv[2]) / 'infra_backoff').read_text().strip()
|
|
1678
|
+
backoff = (module.parse_backoff(text), text) if text else None
|
|
1679
|
+
except (OSError, ValueError):
|
|
1680
|
+
pass
|
|
1681
|
+
print(module.infra_wait(module.infra_info(Path(sys.argv[3])), int(sys.argv[4]), backoff)[0])
|
|
1682
|
+
PY
|
|
1683
|
+
)" || secs=""
|
|
1684
|
+
case "$secs" in ''|*[!0-9.]*) secs=60 ;; esac
|
|
1685
|
+
note "waiting ${secs}s for the infrastructure stop to clear"
|
|
1686
|
+
sleep "$secs"
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
report_untested() { # report_untested <plan> <id>...: verdicts that rest on reading alone (#117)
|
|
1690
|
+
local plan="$1" id tests_note untested=0; shift
|
|
1691
|
+
for id in "$@"; do
|
|
1692
|
+
tests_note="$(forge_tests_note "$plan/tasks/$id/qa.last")"
|
|
1693
|
+
if [ -n "$tests_note" ]; then
|
|
1694
|
+
[ "$untested" = 0 ] && echo "reviews whose tests could not run:"
|
|
1695
|
+
untested=1
|
|
1696
|
+
printf ' %-14s %s\n' "$id" "$tests_note"
|
|
1697
|
+
fi
|
|
1698
|
+
done
|
|
1699
|
+
[ "$untested" = 0 ] || echo
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1400
1702
|
do_retry() {
|
|
1401
1703
|
local PLAN="${1:?retry needs a plan dir}" id="${2:?retry needs a task id}"; shift 2
|
|
1402
1704
|
FORGE_RUN_STARTED="$(forge_now)"
|
|
1403
|
-
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0 DECIDE="" REASON="" APPROVED=0
|
|
1705
|
+
local NEWDWARF="" jev_rc=0 ANSWER="" ANSWER_FILE="" HAVE_ANSWER=0 DECIDE="" REASON="" APPROVED=0 NO_DISPATCH=0
|
|
1404
1706
|
# An answer is validated before any option below writes into the plan: a rejected answer
|
|
1405
1707
|
# changes nothing, --setup and --verify included. Only a NEEDS_INPUT task takes one. The
|
|
1406
1708
|
# arguments are walked the way the loop below walks them (a value is never taken for a flag),
|
|
@@ -1448,6 +1750,7 @@ do_retry() {
|
|
|
1448
1750
|
--decide) DECIDE="${2:?--decide needs retry=N or threshold=Pn}"; shift 2 ;;
|
|
1449
1751
|
--reason) REASON="${2?--reason needs a text}"; shift 2 ;;
|
|
1450
1752
|
--approved) APPROVED=1; shift ;;
|
|
1753
|
+
--no-dispatch) NO_DISPATCH=1; shift ;;
|
|
1451
1754
|
# The check above refuses an empty answer first; these hold when its walk could not run.
|
|
1452
1755
|
--answer) [ "$HAVE_ANSWER" = 0 ] || die "retry: give --answer or --answer-file once"
|
|
1453
1756
|
ANSWER="${2?--answer needs the answer text}"; HAVE_ANSWER=1; shift 2
|
|
@@ -1473,6 +1776,7 @@ do_retry() {
|
|
|
1473
1776
|
;;
|
|
1474
1777
|
esac
|
|
1475
1778
|
done
|
|
1779
|
+
forge_profile_run_values "$PLAN"
|
|
1476
1780
|
[ "$JEV_OPTS" = 1 ] && forge_jev_settle "$PLAN"
|
|
1477
1781
|
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
1478
1782
|
[ "$JEV_OPTS" = 1 ] && [ -s "$PLAN/repo" ] && forge_decide_env "$(cat "$PLAN/repo")" "$PLAN"
|
|
@@ -1484,7 +1788,23 @@ do_retry() {
|
|
|
1484
1788
|
[ -s "$PLAN/wt_root" ] || die "this plan has never been run — use 'run', not 'retry'"
|
|
1485
1789
|
local st; st="$(task_status "$PLAN" "$id")"
|
|
1486
1790
|
[ "$st" = "MERGED" ] && die "task '$id' already merged — nothing to retry"
|
|
1791
|
+
# A decision's grant is exactly what it says, and the profile's default budget of further attempts
|
|
1792
|
+
# does not stretch it: a task waiting for a decision (resumed by --decide or --dwarf), or an
|
|
1793
|
+
# infrastructure stop resumed while a decision's count is kept. Only a --retry-failed typed on this
|
|
1794
|
+
# line adds to a decision.
|
|
1795
|
+
if [ "$PP_RETRY_FAILED_SET" != 1 ] && { [ -n "$DECIDE" ] || [ "$st" = NEEDS_DECISION ] \
|
|
1796
|
+
|| { [ "$st" = INFRA ] && [ -n "$(decided_left "$tdir")" ]; }; }; then
|
|
1797
|
+
PP_RETRY_FAILED=0
|
|
1798
|
+
fi
|
|
1487
1799
|
[ "$HAVE_ANSWER" = 0 ] || [ "$st" = NEEDS_INPUT ] || die "retry: '$id' is $st, not waiting for an answer; --answer and --answer-file only answer a NEEDS_INPUT task"
|
|
1800
|
+
# The budgets are this call's own, and --no-dispatch ends the call before any attempt spends them.
|
|
1801
|
+
if [ "$NO_DISPATCH" = 1 ] && { [ "$PP_RETRY_FAILED_SET" = 1 ] || [ "$PP_INFRA_RETRIES_SET" = 1 ]; }; then
|
|
1802
|
+
die "retry: --retry-failed and --infra-retries apply to the attempts this call runs, and --no-dispatch runs none; give them to the run: forge-parallel.sh run $PLAN --retry-failed N" 2
|
|
1803
|
+
fi
|
|
1804
|
+
# A recorded decision is already what the next run does: a second one would stack onto its count.
|
|
1805
|
+
if [ -n "$DECIDE" ] && [ -f "$tdir/retry.prepared" ]; then
|
|
1806
|
+
die "retry: '$id' already has a decision recorded and waits for the next run; forge-parallel.sh run $PLAN starts it" 2
|
|
1807
|
+
fi
|
|
1488
1808
|
retry_decision_gate "$PLAN" "$id" "$st" "$DECIDE" "$NEWDWARF" "$REASON" "$APPROVED"
|
|
1489
1809
|
# A task at its attempt cap (#69) is refused with the decision commands unless --decide retry=N reaches past it.
|
|
1490
1810
|
if ! attempt_cap_gate "$PLAN" "$id" "$st" "$DECIDE"; then write_results "$PLAN"; return 2; fi
|
|
@@ -1511,7 +1831,8 @@ do_retry() {
|
|
|
1511
1831
|
prepare_retry "$PLAN" "$id" "$NEWDWARF" || prc=$?
|
|
1512
1832
|
# A person's plain retry ends what an earlier decision allowed; resuming after an
|
|
1513
1833
|
# infrastructure stop is not a new choice, so the allowance carries over.
|
|
1514
|
-
|
|
1834
|
+
# Nor is changing a prepared task's model: the count its decision granted still stands.
|
|
1835
|
+
[ "$prc" != 0 ] || [ "$st" = INFRA ] || [ -f "$tdir/retry.prepared" ] || rm -f "${tdir:?}/decided.left"
|
|
1515
1836
|
fi
|
|
1516
1837
|
if [ "$prc" != 0 ]; then
|
|
1517
1838
|
write_results "$PLAN"
|
|
@@ -1519,7 +1840,8 @@ do_retry() {
|
|
|
1519
1840
|
return "$prc"
|
|
1520
1841
|
fi
|
|
1521
1842
|
[ "${FORGE_RIPWIRE:-}" != off ] || touch "$PLAN/no_ripwire"
|
|
1522
|
-
|
|
1843
|
+
# --no-dispatch leaves the dependencies to the `run` that dispatches it: one can merge in that same run.
|
|
1844
|
+
[ "$NO_DISPATCH" = 1 ] || dependencies_ready "$PLAN" "$id" || { write_results "$PLAN"; return 5; }
|
|
1523
1845
|
local vrepo vcheckout; vrepo="$(cat "$PLAN/repo" 2>/dev/null)"; vcheckout="$(cat "$PLAN/wt_root")/_integration"
|
|
1524
1846
|
[ -d "$vcheckout" ] || vcheckout="$vrepo"
|
|
1525
1847
|
verify_lanes_check "$PLAN" "$vrepo" "$vcheckout"
|
|
@@ -1529,8 +1851,19 @@ do_retry() {
|
|
|
1529
1851
|
rm -f "$tdir/status"
|
|
1530
1852
|
# The pauses an earlier run ended with describe that run: this retry's summary must not report them.
|
|
1531
1853
|
rm -f "$PLAN/infra.last"
|
|
1854
|
+
# #118: `retry` holds the plan lock until its attempts end, so several tasks cannot resume side by
|
|
1855
|
+
# side. This stops once the retry is prepared, and the marker tells the next `run` that dispatch is
|
|
1856
|
+
# a person's retry. The decision's count is already in decided.left, which that run honours.
|
|
1857
|
+
if [ "$NO_DISPATCH" = 1 ]; then
|
|
1858
|
+
: > "$tdir/retry.prepared" || die "retry: could not record the prepared retry" 1
|
|
1859
|
+
write_results "$PLAN"
|
|
1860
|
+
note "$id is ready and nothing was dispatched; forge-parallel.sh run $PLAN starts it"
|
|
1861
|
+
return 0
|
|
1862
|
+
fi
|
|
1863
|
+
rm -f "$tdir/retry.prepared"
|
|
1532
1864
|
|
|
1533
1865
|
note "retrying $id with dwarf $(field "$T" "$id" dwarf)"
|
|
1866
|
+
forge_fast_fractal_note "$PLAN"
|
|
1534
1867
|
export FORGE_FRACTAL_RETRY=1
|
|
1535
1868
|
export FORGE_DATASET_TRIGGER=human
|
|
1536
1869
|
do_task "$PLAN" "$id"
|
|
@@ -1540,15 +1873,34 @@ do_retry() {
|
|
|
1540
1873
|
# stopped for a decision again, an empty diff, or a policy that finds no stronger model.
|
|
1541
1874
|
# The count is decided.left, so it survives a run that ended before the attempts were used.
|
|
1542
1875
|
local more; more="$(decided_left "$tdir")"; more="${more:-0}"
|
|
1543
|
-
|
|
1876
|
+
# --retry-failed N (or the frozen profile's) adds N further attempts for this call alone, spent after the
|
|
1877
|
+
# decided ones; --infra-retries M waits out that many infrastructure stops before giving up (#48).
|
|
1878
|
+
local rf_left="$PP_RETRY_FAILED" inf_left="$PP_INFRA_RETRIES" inf_cycle=0 from_decided
|
|
1879
|
+
while :; do
|
|
1880
|
+
if [ "$st" = INFRA ]; then
|
|
1881
|
+
# No attempt was spent and nothing was judged: wait the stop out as the scheduler does, and dispatch again.
|
|
1882
|
+
[ "$inf_left" -gt 0 ] || break
|
|
1883
|
+
inf_left=$(( inf_left - 1 ))
|
|
1884
|
+
retry_infra_wait "$PLAN" "$tdir" "$inf_cycle"; inf_cycle=$(( inf_cycle + 1 ))
|
|
1885
|
+
prepare_retry "$PLAN" "$id" || break
|
|
1886
|
+
rm -f "$tdir/status" "$PLAN/infra.last"
|
|
1887
|
+
note "retrying $id after an infrastructure stop ($inf_left more wait(s) allowed)"
|
|
1888
|
+
do_task "$PLAN" "$id"
|
|
1889
|
+
st="$(task_status "$PLAN" "$id")"
|
|
1890
|
+
continue
|
|
1891
|
+
fi
|
|
1892
|
+
{ [ "$st" = FAIL ] || [ "$st" = UNKNOWN ]; } && [ ! -e "$tdir/noretry" ] || break
|
|
1893
|
+
from_decided=0
|
|
1894
|
+
if [ "$more" -gt 0 ]; then from_decided=1; elif [ "$rf_left" -le 0 ]; then break; fi
|
|
1544
1895
|
# Each further attempt is spent against the cap (#69) like the scheduler's retries: an UNKNOWN review
|
|
1545
1896
|
# does not stop the task by itself, so the cap is checked here, and a task at it stops for a decision.
|
|
1546
1897
|
if ! attempt_cap_gate "$PLAN" "$id" "$st" ""; then st="$(task_status "$PLAN" "$id")"; break; fi
|
|
1547
|
-
more=$(( more - 1 ))
|
|
1898
|
+
if [ "$from_decided" = 1 ]; then more=$(( more - 1 )); else rf_left=$(( rf_left - 1 )); fi
|
|
1548
1899
|
prepare_retry "$PLAN" "$id" || break
|
|
1549
|
-
decided_left_set "$tdir" "$more" || break
|
|
1900
|
+
if [ "$from_decided" = 1 ]; then decided_left_set "$tdir" "$more" || break; fi
|
|
1550
1901
|
rm -f "$tdir/status"
|
|
1551
|
-
note "retrying $id (decided retry, $more more after this)"
|
|
1902
|
+
if [ "$from_decided" = 1 ]; then note "retrying $id (decided retry, $more more after this)"
|
|
1903
|
+
else note "retrying $id (--retry-failed, $rf_left more after this)"; fi
|
|
1552
1904
|
do_task "$PLAN" "$id"
|
|
1553
1905
|
st="$(task_status "$PLAN" "$id")"
|
|
1554
1906
|
done
|
|
@@ -1566,6 +1918,7 @@ do_retry() {
|
|
|
1566
1918
|
note "$id PASS but conflicted on merge — branch preserved"
|
|
1567
1919
|
fi
|
|
1568
1920
|
fi
|
|
1921
|
+
report_untested "$PLAN" "$id"
|
|
1569
1922
|
# Tasks still to run (#112): the run that dispatches them verifies the integration branch at its
|
|
1570
1923
|
# end, and integrate verifies its candidate, so verifying now would only be repeated.
|
|
1571
1924
|
local left="" lid
|
|
@@ -1897,6 +2250,24 @@ run_wait() { # run_wait <pid>
|
|
|
1897
2250
|
while kill -0 "$1" 2>/dev/null; do run_rc=0; wait "$1" || run_rc=$?; done
|
|
1898
2251
|
}
|
|
1899
2252
|
|
|
2253
|
+
# A standalone retry runs its dispatches in the foreground, and bash runs a trap only between
|
|
2254
|
+
# commands, so a TERM to the retry's pid alone ended it and left the dispatch, its harness and
|
|
2255
|
+
# the tools they started running in the task's worktree (#129). retry_stop sends TERM to
|
|
2256
|
+
# everything below the retry job (forge-guard.py stop-tree, which reads ps itself), and waits,
|
|
2257
|
+
# bounded, while each dispatch's EXIT trap stops its harness and reaps what it started. What
|
|
2258
|
+
# still runs then is killed, and the guard's backstop runs on any harness record a dispatch
|
|
2259
|
+
# left behind, as the scheduler's does.
|
|
2260
|
+
RETRY_STOP_WAIT=20 # seconds; a dispatch's EXIT trap needs about 1 s plus its ~6 s reap
|
|
2261
|
+
retry_stop() { # retry_stop <job pid> <plan> <task>
|
|
2262
|
+
local record
|
|
2263
|
+
python3 "$SKILL_DIR/scripts/forge-guard.py" stop-tree "$1" --wait "$RETRY_STOP_WAIT" >/dev/null 2>&1 \
|
|
2264
|
+
|| kill -TERM "$1" 2>/dev/null
|
|
2265
|
+
[ -n "$2" ] && [ -n "$3" ] || return 0
|
|
2266
|
+
for record in "$2/tasks/$3/dwarf.harness" "$2/tasks/$3/qa.harness"; do
|
|
2267
|
+
[ ! -e "$record" ] || python3 "$SKILL_DIR/scripts/forge-guard.py" stop "$record" >/dev/null 2>&1
|
|
2268
|
+
done
|
|
2269
|
+
}
|
|
2270
|
+
|
|
1900
2271
|
# The handler of do_run's subshell: a signal reaches the job in progress (the scheduler,
|
|
1901
2272
|
# then the verification) as TERM. Before any job exists there is nothing to clean up.
|
|
1902
2273
|
run_signal() {
|
|
@@ -1945,6 +2316,7 @@ do_run() {
|
|
|
1945
2316
|
;;
|
|
1946
2317
|
esac
|
|
1947
2318
|
done
|
|
2319
|
+
forge_profile_run_values "$PLAN"
|
|
1948
2320
|
[ "$JEV_OPTS" = 1 ] && forge_jev_settle "$PLAN"
|
|
1949
2321
|
[ -n "$PP_SWEEP" ] || [ "$PP_SWEEP_PLAUSIBLE$PP_SWEEP_MAX_SET" = 00 ] || die "--sweep-plausible and --sweep-max go with --sweep"
|
|
1950
2322
|
case "$OUTPUT" in summary|full) ;; *) die "--output must be summary or full" ;; esac
|
|
@@ -1967,6 +2339,7 @@ do_run() {
|
|
|
1967
2339
|
forge_ui_register "$PLAN"
|
|
1968
2340
|
fi
|
|
1969
2341
|
forge_fractal_parallel_run "$PLAN" "$REPO" "$DRY" ${fractal_pipeline_args[@]+"${fractal_pipeline_args[@]}"} || return $?
|
|
2342
|
+
forge_fast_fractal_note "$PLAN"
|
|
1970
2343
|
# Durable, beside the repo — never TMPDIR. A temp worktree root has destroyed
|
|
1971
2344
|
# real work here before: isolated worktrees are never pushed, so when the root
|
|
1972
2345
|
# goes, the only copy of that work goes with it.
|
|
@@ -2013,6 +2386,7 @@ do_run() {
|
|
|
2013
2386
|
if [ ! -d "$int_wt" ]; then
|
|
2014
2387
|
(cd "$REPO" && git worktree add "$int_wt" "$int_br" >/dev/null 2>&1) \
|
|
2015
2388
|
|| die "could not create integration worktree" 3
|
|
2389
|
+
forge_worktree_event created "$PLAN" "$REPO" "$int_wt" "$int_br" integration
|
|
2016
2390
|
# The integration worktree is where a merged result gets validated, so it needs
|
|
2017
2391
|
# the same setup the task worktrees get. Without it, the one checkout holding
|
|
2018
2392
|
# every task's merged work is the one checkout that cannot build or test it.
|
|
@@ -2021,7 +2395,7 @@ do_run() {
|
|
|
2021
2395
|
fi
|
|
2022
2396
|
|
|
2023
2397
|
if [ -s "$PLAN/accepted.integration" ] && [ "$(git -C "$int_wt" rev-parse HEAD)" != "$(cat "$PLAN/accepted.integration")" ]; then
|
|
2024
|
-
die "integration branch changed outside this run" 3
|
|
2398
|
+
die "integration branch changed outside this run. To bring those commits into the run: forge-parallel.sh adopt $PLAN --head --reason \"...\"" 3
|
|
2025
2399
|
fi
|
|
2026
2400
|
git -C "$int_wt" rev-parse HEAD > "$PLAN/accepted.integration"
|
|
2027
2401
|
local id failed=0
|
|
@@ -2076,7 +2450,9 @@ do_run() {
|
|
|
2076
2450
|
# branch so there is something to inspect and retry from.
|
|
2077
2451
|
if [ -s "$PLAN/results.tsv" ]; then
|
|
2078
2452
|
for id in $(awk -F'\t' '$2=="MERGED" {print $1}' "$PLAN/results.tsv"); do
|
|
2079
|
-
|
|
2453
|
+
[ -e "$wt_root/$id" ] || continue
|
|
2454
|
+
(cd "$REPO" && git worktree remove --force "$wt_root/$id" >/dev/null 2>&1) \
|
|
2455
|
+
&& forge_worktree_event removed "$PLAN" "$REPO" "$wt_root/$id" "forge/$run_id/$id" task "$id"
|
|
2080
2456
|
done
|
|
2081
2457
|
fi
|
|
2082
2458
|
|
|
@@ -2105,6 +2481,9 @@ do_run() {
|
|
|
2105
2481
|
done
|
|
2106
2482
|
[ "$drift" = 1 ] && echo
|
|
2107
2483
|
|
|
2484
|
+
# shellcheck disable=SC2046 # ids are single words
|
|
2485
|
+
report_untested "$PLAN" $(all_ids "$T")
|
|
2486
|
+
|
|
2108
2487
|
# From this run's own flags, never from a verification.status an earlier run left.
|
|
2109
2488
|
if [ "$interrupted" = 1 ]; then
|
|
2110
2489
|
if [ "$vstopped" = 1 ]; then echo "interrupted during verification, which was stopped and not rerun."
|
|
@@ -2201,6 +2580,7 @@ do_integrate() {
|
|
|
2201
2580
|
out="$PLAN/integrate-$(date +%s)-$$"; mkdir -p "$out"
|
|
2202
2581
|
candidate="$(cat "$PLAN/wt_root")/_candidate-$$"
|
|
2203
2582
|
git -C "$REPO" worktree add --detach "$candidate" "$parent" > "$out/setup.log" 2>&1 || return 3
|
|
2583
|
+
forge_worktree_event created "$PLAN" "$REPO" "$candidate" - candidate
|
|
2204
2584
|
if ! git -C "$candidate" merge --no-ff -m "forge: integrate run $run_id" "$target" > "$out/merge.log" 2>&1; then
|
|
2205
2585
|
forge_dataset_event integrate_conflict --dir "$PLAN" --set branch="$cur" --set parent="$parent" \
|
|
2206
2586
|
--set target="$target" --set conflicts="$(git -C "$candidate" diff --name-only --diff-filter=U 2>/dev/null | tr '\n' ' ')" \
|
|
@@ -2214,6 +2594,17 @@ do_integrate() {
|
|
|
2214
2594
|
report_known_issues "$PLAN"
|
|
2215
2595
|
# Opt-in whole-run review of the combined candidate, after verification and before the
|
|
2216
2596
|
# user's branch moves. Per-task review only ever saw one slice at a time.
|
|
2597
|
+
# A profile that names a final reviewer (#48) asks for this review: --final-review wins, then the spec
|
|
2598
|
+
# `review` or an earlier --final-review left in final_qa, then the profile's own.
|
|
2599
|
+
if [ -z "$PP_FINAL_REVIEW" ] && [ -f "$PLAN/profile.json" ]; then
|
|
2600
|
+
local pf_final; pf_final="$(forge_profile_py value "$PLAN/profile.json" routing.final_reviewer 2>/dev/null)"
|
|
2601
|
+
pf_final="${pf_final#*$'\t'}"
|
|
2602
|
+
if [ -n "$pf_final" ]; then
|
|
2603
|
+
PP_FINAL_REVIEW="$(head -1 "$PLAN/final_qa" 2>/dev/null | tr -d ' \r')"
|
|
2604
|
+
[ -n "$PP_FINAL_REVIEW" ] || PP_FINAL_REVIEW="$pf_final"
|
|
2605
|
+
note "final review: $PP_FINAL_REVIEW, from the plan's profile"
|
|
2606
|
+
fi
|
|
2607
|
+
fi
|
|
2217
2608
|
if [ -n "$PP_FINAL_REVIEW" ]; then
|
|
2218
2609
|
declare -F final_review_for_integrate >/dev/null || die "the final review is not available in this build" 3
|
|
2219
2610
|
final_review_for_integrate "$PLAN" "$parent" "$candidate_sha" "$candidate" "$out" "$PP_FINAL_REVIEW" || return $?
|
|
@@ -2228,16 +2619,235 @@ do_integrate() {
|
|
|
2228
2619
|
forge_dataset_event integrate_advanced --dir "$PLAN" --set branch="$cur" --set parent="$parent" \
|
|
2229
2620
|
--set candidate="$candidate_sha" --set target="$target" --set verification="$(cat "$out/verification.status" 2>/dev/null)"
|
|
2230
2621
|
git -C "$REPO" worktree remove "$candidate" || return 3
|
|
2622
|
+
forge_worktree_event removed "$PLAN" "$REPO" "$candidate" - candidate
|
|
2231
2623
|
echo "merged candidate of $int_br into $cur (verification: $(cat "$out/verification.status"))"
|
|
2232
2624
|
}
|
|
2233
2625
|
|
|
2626
|
+
# --- auto (#87, #88) -----------------------------------------------------------------
|
|
2627
|
+
# The profile `plan` will use for these flags, read without writing anything: the planner
|
|
2628
|
+
# spec and the fast-tier roles it names, as `key<TAB>value` lines. The choice is plan's own
|
|
2629
|
+
# (profiles._choose): --no-profile means none; with no --profile the plan's frozen
|
|
2630
|
+
# profile.json stays; otherwise the named profile, else the default. A frozen profile adds no
|
|
2631
|
+
# fast roles: plan stored those when it froze it.
|
|
2632
|
+
forge_auto_profile() { # forge_auto_profile <plan-dir> <repo> <profile name or empty> <no-profile 0|1>
|
|
2633
|
+
PYTHONPATH="$SKILL_DIR/scripts${PYTHONPATH:+:$PYTHONPATH}" python3 - "$@" <<'PY'
|
|
2634
|
+
import sys
|
|
2635
|
+
from pathlib import Path
|
|
2636
|
+
from forge_decide import profiles
|
|
2637
|
+
plan, repo, name, none = Path(sys.argv[1]), sys.argv[2] or None, sys.argv[3] or None, sys.argv[4] == '1'
|
|
2638
|
+
try:
|
|
2639
|
+
action, chosen = profiles._choose(repo, name, none, plan / profiles.FROZEN, False, False)
|
|
2640
|
+
except profiles.ProfileError as exc:
|
|
2641
|
+
print('forge: %s' % exc, file=sys.stderr)
|
|
2642
|
+
sys.exit(2)
|
|
2643
|
+
body = chosen.get('body') if isinstance(chosen, dict) else None
|
|
2644
|
+
values = profiles.flat(body) if body else {}
|
|
2645
|
+
planner = values.get('routing.planner')
|
|
2646
|
+
if isinstance(planner, str) and planner:
|
|
2647
|
+
print('routing.planner\t%s' % planner)
|
|
2648
|
+
print('action\t%s' % action)
|
|
2649
|
+
# As plan stores it: an empty list is `none`, which clears the roles an earlier call stored.
|
|
2650
|
+
if action == 'new' and isinstance(values.get('policy.fast'), list):
|
|
2651
|
+
print('policy.fast\t%s' % profiles._fast_roles(values['policy.fast'], profiles.FAST_ROLES))
|
|
2652
|
+
PY
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
# Forget what `parse` wrote, so the planner's next reply can be parsed: tasks.tsv and each
|
|
2656
|
+
# tasks/<id>/. request.md, the planner's records and plan.sendback.md stay.
|
|
2657
|
+
forge_auto_unparse() { # forge_auto_unparse <plan-dir>
|
|
2658
|
+
local id
|
|
2659
|
+
if [ -f "$1/tasks.tsv" ]; then
|
|
2660
|
+
for id in $(all_ids "$1/tasks.tsv"); do
|
|
2661
|
+
case "$id" in ''|.*|*/*) continue ;; esac
|
|
2662
|
+
rm -rf "$1/tasks/$id"
|
|
2663
|
+
done
|
|
2664
|
+
fi
|
|
2665
|
+
rm -f "$1/tasks.tsv" "$1/tasks.declared.tsv"
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
# One planner dispatch: prompt in $PLAN/planner.prompt, reply in $PLAN/planner.last. Sets
|
|
2669
|
+
# AUTO_RC (0, 4 or 8) for the caller instead of exiting, so a send-back can reuse it.
|
|
2670
|
+
forge_auto_dispatch() { # forge_auto_dispatch <plan-dir> <repo> <spec> <fast-option-or-empty>
|
|
2671
|
+
local plan="$1" repo="$2" spec="$3" tier="$4" rc=0
|
|
2672
|
+
AUTO_RC=0
|
|
2673
|
+
note "auto: dispatching the planner ($spec) for the whole plan"
|
|
2674
|
+
bash "$DISPATCH" planner "$spec" --repo "$repo" --run-dir "$plan" --prompt-file "$plan/planner.prompt" \
|
|
2675
|
+
--output summary ${tier:+$tier} >&2 || rc=$?
|
|
2676
|
+
if [ "$rc" -eq 8 ]; then
|
|
2677
|
+
note "auto: the planner stopped on an infrastructure failure (see $plan/planner.infra). Nothing was dispatched after the planner; fix the cause and run auto again"
|
|
2678
|
+
AUTO_RC=8
|
|
2679
|
+
elif [ "$rc" -ne 0 ]; then
|
|
2680
|
+
note "auto: the planner failed (exit $rc). Its last message is $plan/planner.last and its log $plan/planner.log"
|
|
2681
|
+
AUTO_RC=4
|
|
2682
|
+
fi
|
|
2683
|
+
return 0
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
do_auto() {
|
|
2687
|
+
local PLAN="${1:-}"
|
|
2688
|
+
[ -n "$PLAN" ] && [ "${PLAN#-}" = "$PLAN" ] || die "auto needs a plan dir: forge-parallel.sh auto <plan-dir> --repo DIR --goal-file FILE ..."
|
|
2689
|
+
shift
|
|
2690
|
+
local REPO="" GOAL="" PLANNER="" DLEVEL="" GATE=auto ONE_DIFF=medium COLLAPSE=1 APPROVED=0
|
|
2691
|
+
local PLAN_ARGS=() RUN_ARGS=() PF_NAME="" PF_NONE=0 FAST_GIVEN=0 FAST_PARSED="" arg
|
|
2692
|
+
while [ $# -gt 0 ]; do
|
|
2693
|
+
case "$1" in
|
|
2694
|
+
--) shift; RUN_ARGS=("$@"); break ;;
|
|
2695
|
+
--repo) [ $# -ge 2 ] || die "--repo needs a directory"; REPO="$2"; shift 2 ;;
|
|
2696
|
+
--goal-file) [ $# -ge 2 ] || die "--goal-file needs a file"; GOAL="$2"; shift 2 ;;
|
|
2697
|
+
--planner) [ -n "${2:-}" ] || die "--planner needs a spec"; PLANNER="$2"; PLAN_ARGS+=("$1" "$2"); shift 2 ;;
|
|
2698
|
+
--decompose-level)
|
|
2699
|
+
case "${2:-}" in low|medium|high) DLEVEL="$2"; shift 2 ;;
|
|
2700
|
+
*) die "--decompose-level must be low, medium or high" ;; esac ;;
|
|
2701
|
+
--plan)
|
|
2702
|
+
case "${2:-}" in auto|always|never) GATE="$2"; shift 2 ;;
|
|
2703
|
+
*) die "--plan must be auto, always or never" ;; esac ;;
|
|
2704
|
+
--one-task-difficulty)
|
|
2705
|
+
case "${2:-}" in low|medium|high) ONE_DIFF="$2"; shift 2 ;;
|
|
2706
|
+
*) die "--one-task-difficulty must be low, medium or high" ;; esac ;;
|
|
2707
|
+
--no-collapse) COLLAPSE=0; shift ;;
|
|
2708
|
+
--approved) APPROVED=1; shift ;;
|
|
2709
|
+
--profile) [ -n "${2:-}" ] || die "--profile needs a profile name"; PF_NAME="$2"; PLAN_ARGS+=("$1" "$2"); shift 2 ;;
|
|
2710
|
+
--no-profile) PF_NONE=1; PLAN_ARGS+=("$1"); shift ;;
|
|
2711
|
+
--fast)
|
|
2712
|
+
[ -n "${2:-}" ] || die "--fast needs a comma list of roles (dwarf, qa, planner, review), all or none"
|
|
2713
|
+
forge_fast_parse "$2" plan; FAST_GIVEN=1
|
|
2714
|
+
PLAN_ARGS+=("$1" "$2"); shift 2 ;;
|
|
2715
|
+
--no-ripwire) export FORGE_RIPWIRE=off; PLAN_ARGS+=("$1"); shift ;;
|
|
2716
|
+
*) PLAN_ARGS+=("$1"); shift ;;
|
|
2717
|
+
esac
|
|
2718
|
+
done
|
|
2719
|
+
[ -n "$REPO" ] || die "auto needs --repo DIR"
|
|
2720
|
+
[ -d "$REPO" ] || die "--repo '$REPO' is not a directory"
|
|
2721
|
+
REPO="$(cd "$REPO" && pwd)"
|
|
2722
|
+
[ -n "$GOAL" ] || die "auto needs --goal-file FILE"
|
|
2723
|
+
[ -f "$GOAL" ] && [ -r "$GOAL" ] || die "--goal-file '$GOAL' is not a readable file"
|
|
2724
|
+
[ ! -e "$PLAN/tasks.tsv" ] || die "auto starts a new plan; use plan and run on an existing one"
|
|
2725
|
+
(cd "$REPO" && git rev-parse --git-dir >/dev/null 2>&1) \
|
|
2726
|
+
|| die "'$REPO' is not a git repository. Decomposed runs need worktrees, and there is no honest fallback without them." 3
|
|
2727
|
+
mkdir -p "$PLAN" || die "could not create plan dir '$PLAN'" 3
|
|
2728
|
+
PLAN="$(cd "$PLAN" && pwd)"
|
|
2729
|
+
|
|
2730
|
+
# The request, verbatim, and who started this plan.
|
|
2731
|
+
if ! [ "$GOAL" -ef "$PLAN/request.md" ]; then
|
|
2732
|
+
cp "$GOAL" "$PLAN/request.md" || die "could not write $PLAN/request.md" 3
|
|
2733
|
+
fi
|
|
2734
|
+
printf 'auto\n' > "$PLAN/orchestrator" || die "could not write $PLAN/orchestrator" 3
|
|
2735
|
+
# The goal line the table, every task's "Overall goal", the final review and the dataset read:
|
|
2736
|
+
# the request's first non-empty line, a heading's marks dropped. One the user wrote stays.
|
|
2737
|
+
if [ ! -s "$PLAN/goal.txt" ]; then
|
|
2738
|
+
awk 'NF { sub(/^#+[[:space:]]*/, ""); print substr($0, 1, 200); exit }' "$PLAN/request.md" > "$PLAN/goal.txt" \
|
|
2739
|
+
|| die "could not write $PLAN/goal.txt" 3
|
|
2740
|
+
fi
|
|
2741
|
+
local PLANNER_PY="$SKILL_DIR/scripts/forge-planner.py" REQUEST="$PLAN/request.md" rc=0 from_planner=0 fast_tier=""
|
|
2742
|
+
PLAN_ARGS=(--repo "$REPO" ${PLAN_ARGS[@]+"${PLAN_ARGS[@]}"})
|
|
2743
|
+
[ -z "$DLEVEL" ] || PLAN_ARGS+=(--decompose-level "$DLEVEL")
|
|
2744
|
+
[ "$COLLAPSE" = 0 ] || PLAN_ARGS+=(--collapse-chains)
|
|
2745
|
+
|
|
2746
|
+
# 1. The gate.
|
|
2747
|
+
local decision
|
|
2748
|
+
case "$GATE" in
|
|
2749
|
+
always) decision=plan ;;
|
|
2750
|
+
never) decision=one-task ;;
|
|
2751
|
+
*)
|
|
2752
|
+
decision="$(python3 "$PLANNER_PY" gate --plan "$PLAN" --goal-file "$REQUEST")" || exit $?
|
|
2753
|
+
note "auto: the gate says $decision" ;;
|
|
2754
|
+
esac
|
|
2755
|
+
|
|
2756
|
+
if [ "$decision" = one-task ]; then
|
|
2757
|
+
# 2. One task, no planner.
|
|
2758
|
+
python3 "$PLANNER_PY" one-task --plan "$PLAN" --goal-file "$REQUEST" --difficulty "$ONE_DIFF" >/dev/null || exit $?
|
|
2759
|
+
else
|
|
2760
|
+
# 3. The planner: its spec, its preflight, its dispatch, its reply.
|
|
2761
|
+
local key val profile_planner="" profile_fast="" profile_action="" profile_lines
|
|
2762
|
+
forge_profile_precheck "$PLAN" "${PLAN_ARGS[@]}"
|
|
2763
|
+
profile_lines="$(forge_auto_profile "$PLAN" "$REPO" "$PF_NAME" "$PF_NONE")" || exit $?
|
|
2764
|
+
while IFS="$(printf '\t')" read -r key val; do
|
|
2765
|
+
case "$key" in
|
|
2766
|
+
routing.planner) profile_planner="$val" ;;
|
|
2767
|
+
policy.fast) profile_fast="$val" ;;
|
|
2768
|
+
action) profile_action="$val" ;;
|
|
2769
|
+
esac
|
|
2770
|
+
done <<AUTO_PROFILE
|
|
2771
|
+
$profile_lines
|
|
2772
|
+
AUTO_PROFILE
|
|
2773
|
+
if [ -z "$PLANNER" ] && [ -n "$profile_planner" ]; then
|
|
2774
|
+
PLANNER="$profile_planner"
|
|
2775
|
+
# `plan` takes routing.planner from a profile only when it freezes a new one. A kept
|
|
2776
|
+
# frozen profile names the planner but plan would not record it: hand it over.
|
|
2777
|
+
[ "$profile_action" = new ] || PLAN_ARGS+=(--planner "$PLANNER")
|
|
2778
|
+
fi
|
|
2779
|
+
[ -n "$PLANNER" ] || die "auto needs --planner SPEC, or a profile with routing.planner"
|
|
2780
|
+
# The fast roles `plan` is about to store: the flag, else the profile's. Written now so the
|
|
2781
|
+
# planner dispatch asks for the tier through the helper the other roles use.
|
|
2782
|
+
if [ "$FAST_GIVEN" != 1 ] && [ -n "$profile_fast" ]; then
|
|
2783
|
+
forge_fast_parse "$profile_fast" plan; FAST_GIVEN=1
|
|
2784
|
+
fi
|
|
2785
|
+
forge_fast_store "$PLAN"
|
|
2786
|
+
fast_tier="$(forge_fast_tier "$PLAN" planner)"
|
|
2787
|
+
|
|
2788
|
+
note "auto: checking the planner ($PLANNER) before any model call"
|
|
2789
|
+
bash "$DISPATCH" doctor --spec "$PLANNER" --role planner ${fast_tier:+$fast_tier} >&2 || exit $?
|
|
2790
|
+
python3 "$PLANNER_PY" prompt --plan "$PLAN" --goal-file "$REQUEST" ${DLEVEL:+--level "$DLEVEL"} >/dev/null || exit $?
|
|
2791
|
+
forge_auto_dispatch "$PLAN" "$REPO" "$PLANNER" "$fast_tier"
|
|
2792
|
+
[ "$AUTO_RC" -eq 0 ] || exit "$AUTO_RC"
|
|
2793
|
+
python3 "$PLANNER_PY" parse --plan "$PLAN" --reply "$PLAN/planner.last" || rc=$?
|
|
2794
|
+
case "$rc" in
|
|
2795
|
+
0) ;;
|
|
2796
|
+
4) note "auto: the planner's reply was refused (see $PLAN/planner.refused). Nothing was dispatched after the planner"
|
|
2797
|
+
exit 4 ;;
|
|
2798
|
+
*) exit "$rc" ;;
|
|
2799
|
+
esac
|
|
2800
|
+
from_planner=1
|
|
2801
|
+
fi
|
|
2802
|
+
|
|
2803
|
+
# 4. plan, and one send-back when the plan gates ask for it.
|
|
2804
|
+
bash "$SELF" plan "$PLAN" ${PLAN_ARGS[@]+"${PLAN_ARGS[@]}"}; rc=$?
|
|
2805
|
+
if [ "$rc" -eq 4 ] && [ "$from_planner" = 1 ] && [ -s "$PLAN/plan.sendback.md" ]; then
|
|
2806
|
+
note "auto: the plan gates sent items back; asking the planner once more"
|
|
2807
|
+
cp "$PLAN/planner.last" "$PLAN/planner.first.last" 2>/dev/null || true
|
|
2808
|
+
cp "$PLAN/planner.prompt" "$PLAN/planner.first.prompt" 2>/dev/null || true
|
|
2809
|
+
forge_auto_unparse "$PLAN"
|
|
2810
|
+
python3 "$PLANNER_PY" prompt --plan "$PLAN" --goal-file "$REQUEST" ${DLEVEL:+--level "$DLEVEL"} >/dev/null || exit $?
|
|
2811
|
+
{
|
|
2812
|
+
printf '\n\n## Your plan was sent back\n\n'
|
|
2813
|
+
printf 'forge checked your plan and sent the items below back. Reply with the whole corrected plan, in the same format.\n\n'
|
|
2814
|
+
cat "$PLAN/plan.sendback.md"
|
|
2815
|
+
} >> "$PLAN/planner.prompt"
|
|
2816
|
+
forge_auto_dispatch "$PLAN" "$REPO" "$PLANNER" "$fast_tier"
|
|
2817
|
+
[ "$AUTO_RC" -eq 0 ] || exit "$AUTO_RC"
|
|
2818
|
+
rc=0
|
|
2819
|
+
python3 "$PLANNER_PY" parse --plan "$PLAN" --reply "$PLAN/planner.last" || rc=$?
|
|
2820
|
+
case "$rc" in
|
|
2821
|
+
0) ;;
|
|
2822
|
+
4) note "auto: the planner's second reply was refused (see $PLAN/planner.refused). Nothing was dispatched after the planner"
|
|
2823
|
+
exit 4 ;;
|
|
2824
|
+
*) exit "$rc" ;;
|
|
2825
|
+
esac
|
|
2826
|
+
bash "$SELF" plan "$PLAN" ${PLAN_ARGS[@]+"${PLAN_ARGS[@]}"}; rc=$?
|
|
2827
|
+
if [ "$rc" -eq 4 ]; then
|
|
2828
|
+
note "auto: the plan gates sent items back a second time; stopping. See $PLAN/plan.sendback.md"
|
|
2829
|
+
fi
|
|
2830
|
+
fi
|
|
2831
|
+
[ "$rc" -eq 0 ] || exit "$rc"
|
|
2832
|
+
|
|
2833
|
+
# 5. Stop for approval, or run.
|
|
2834
|
+
if [ "$APPROVED" = 1 ]; then
|
|
2835
|
+
bash "$SELF" run "$PLAN" ${RUN_ARGS[@]+"${RUN_ARGS[@]}"}; exit $?
|
|
2836
|
+
fi
|
|
2837
|
+
local command_line
|
|
2838
|
+
command_line="$(printf '%q run %q' "$SELF" "$PLAN")"
|
|
2839
|
+
for arg in ${RUN_ARGS[@]+"${RUN_ARGS[@]}"}; do command_line="$command_line $(printf '%q' "$arg")"; done
|
|
2840
|
+
printf '\nauto: the plan is ready and nothing has run. To start it:\n %s\n' "$command_line"
|
|
2841
|
+
exit 0
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2234
2844
|
# --- main ---------------------------------------------------------------------
|
|
2235
2845
|
if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
|
|
2236
2846
|
awk '/^# Usage:/ {on=1} /^set -uo pipefail/ {on=0} on {sub(/^# ?/, ""); print}' "$SELF"
|
|
2237
2847
|
forge_fractal_help
|
|
2238
2848
|
exit 0
|
|
2239
2849
|
fi
|
|
2240
|
-
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|run|retry|accept|review|integrate|split|attribute|combine> <plan-dir> [...]"
|
|
2850
|
+
[ $# -ge 1 ] || die "usage: forge-parallel.sh <plan|auto|run|retry|accept|adopt|review|integrate|split|attribute|combine> <plan-dir> [...]"
|
|
2241
2851
|
CMD="$1"; shift
|
|
2242
2852
|
[ ! -f "${1:-}/no_ripwire" ] || export FORGE_RIPWIRE=off
|
|
2243
2853
|
if [ -d "${1:-}" ]; then
|
|
@@ -2245,7 +2855,7 @@ if [ -d "${1:-}" ]; then
|
|
|
2245
2855
|
fi
|
|
2246
2856
|
case "$CMD" in
|
|
2247
2857
|
# `combine` takes a plan dir that does not exist yet and locks its sources itself.
|
|
2248
|
-
run|retry|integrate|accept|review|split|attribute)
|
|
2858
|
+
run|retry|integrate|accept|adopt|review|split|attribute)
|
|
2249
2859
|
if [ "${FORGE_PLAN_LOCK:-}" != "${1:-}" ]; then
|
|
2250
2860
|
exec python3 "$SKILL_DIR/scripts/forge-schedule.py" lock "$SELF" "$CMD" "$@"
|
|
2251
2861
|
fi ;;
|
|
@@ -2254,7 +2864,7 @@ esac
|
|
|
2254
2864
|
# path (die included). Installed after the lock re-exec, so it fires once, in the process
|
|
2255
2865
|
# that did the work; `_task` and `_merge` are parts of a `run` and are not recorded alone.
|
|
2256
2866
|
case "$CMD" in
|
|
2257
|
-
plan|run|retry|integrate|accept|review|split|attribute|combine)
|
|
2867
|
+
plan|run|retry|integrate|accept|adopt|review|split|attribute|combine)
|
|
2258
2868
|
FORGE_DATASET_INVOCATION="inv-$(date +%s)-$$-$RANDOM"; export FORGE_DATASET_INVOCATION
|
|
2259
2869
|
FORGE_DATASET_STARTED="$(date +%s)"
|
|
2260
2870
|
FORGE_DATASET_ARGV=("$@")
|
|
@@ -2262,8 +2872,12 @@ case "$CMD" in
|
|
|
2262
2872
|
esac
|
|
2263
2873
|
# Subcommands implemented in the optional libraries fail clearly if the library is absent.
|
|
2264
2874
|
need_fn() { declare -F "$1" >/dev/null || die "'$CMD' is not available: $1 is missing" 3; }
|
|
2875
|
+
# A plan with a frozen profile asks its decision-model gates from that copy (`plan` does it itself,
|
|
2876
|
+
# after it freezes). The internal subcommands inherit it from the `run` that started them.
|
|
2877
|
+
case "$CMD" in run|retry|integrate|accept|adopt|review|split|attribute) forge_profile_export "${1:-}" ;; esac
|
|
2265
2878
|
case "$CMD" in
|
|
2266
2879
|
plan) do_plan "$@"; rc=$?; forge_update_notice; exit "$rc" ;;
|
|
2880
|
+
auto) do_auto "$@" ;;
|
|
2267
2881
|
run)
|
|
2268
2882
|
# The signal handler lives here, at the pid the user started: do_run is a subshell, and
|
|
2269
2883
|
# bash runs a trap only between commands, so it is started in the background and waited
|
|
@@ -2277,9 +2891,22 @@ case "$CMD" in
|
|
|
2277
2891
|
trap - TERM INT
|
|
2278
2892
|
[ "$run_signalled" = 1 ] && [ "$rc" -gt 128 ] && rc=130
|
|
2279
2893
|
forge_update_notice; exit "$rc" ;;
|
|
2280
|
-
retry)
|
|
2894
|
+
retry)
|
|
2895
|
+
# As run: the handler lives at the pid the user started, and do_retry runs in a background
|
|
2896
|
+
# job it waits for. A signal stops that job's whole tree (retry_stop, #129), and the retry
|
|
2897
|
+
# returns only once what it dispatched has stopped.
|
|
2898
|
+
retry_signalled=0 retry_job=""
|
|
2899
|
+
trap 'retry_signalled=1; [ -n "$retry_job" ] && retry_stop "$retry_job" "${1:-}" "${2:-}"' TERM INT
|
|
2900
|
+
( do_retry "$@" ) <&0 &
|
|
2901
|
+
retry_job=$!
|
|
2902
|
+
[ "$retry_signalled" = 1 ] && retry_stop "$retry_job" "${1:-}" "${2:-}"
|
|
2903
|
+
run_wait "$retry_job"; rc=$run_rc
|
|
2904
|
+
trap - TERM INT
|
|
2905
|
+
[ "$retry_signalled" = 1 ] && [ "$rc" -le 128 ] && rc=143
|
|
2906
|
+
exit "$rc" ;;
|
|
2281
2907
|
integrate) do_integrate "$@" ;;
|
|
2282
2908
|
accept) need_fn do_accept; do_accept "$@" ;;
|
|
2909
|
+
adopt) need_fn do_adopt; do_adopt "$@" ;;
|
|
2283
2910
|
review) need_fn do_review; do_review "$@" ;;
|
|
2284
2911
|
split) need_fn do_split; do_split "$@" ;;
|
|
2285
2912
|
attribute) need_fn do_attribute; do_attribute "$@" ;;
|