@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
|
@@ -14,6 +14,115 @@
|
|
|
14
14
|
# adopt-<epoch>-<pid>/ keeps the review; adoptions.tsv holds one row per adopted range: epoch, base,
|
|
15
15
|
# tip, verdict, approved (0|1), spec, the review's directory name, reason. There is no task row: nothing here
|
|
16
16
|
# was a model's implementation, and a final review reads the whole range anyway.
|
|
17
|
+
#
|
|
18
|
+
# Resubmissions (#155). Each review records its submission in adopt-*/submission (base, tip, source = the
|
|
19
|
+
# last commit of the range as given, lineage = the first submission's directory, n). A range whose source
|
|
20
|
+
# extends the source of a refused submission (or one named with --resubmit <adopt dir>) is the next
|
|
21
|
+
# submission of that lineage: its reviewer gets the previous review's findings, the commits and the diff
|
|
22
|
+
# since that submission, and is asked to settle each earlier finding, and its siblings, before looking for
|
|
23
|
+
# new ones. A lineage refused --escalate-after times (the plan's escalate_after, 3 when unset, 0 = no limit)
|
|
24
|
+
# stops as NEEDS_DECISION: the next resubmission is refused before any model is paid for unless it says
|
|
25
|
+
# --decide resubmit (one more round) or --approved (keep it whatever the review says); a split range starts
|
|
26
|
+
# a lineage of its own.
|
|
27
|
+
|
|
28
|
+
# adopt_submission_value <adopt dir> <key>: one key=value of a submission record.
|
|
29
|
+
adopt_submission_value() { sed -n "s/^$2=//p" "$1/submission" 2>/dev/null | head -1; }
|
|
30
|
+
|
|
31
|
+
# adopt_previous <plan> <checkout> <source>: the refused submission this range extends, so it is the next
|
|
32
|
+
# submission of the same work: of the refused submissions whose source is an ancestor of <source> (and not
|
|
33
|
+
# <source> itself), the one furthest along its lineage (highest n), then the newest. Prints its directory.
|
|
34
|
+
adopt_previous() {
|
|
35
|
+
local plan="$1" wt="$2" source="$3" d src n best="" best_n=0
|
|
36
|
+
# Newest first by the directory's epoch, then pid: a tie on n goes to the first one seen.
|
|
37
|
+
while IFS= read -r d; do
|
|
38
|
+
[ "$(adopt_submission_value "$d" refused)" = 1 ] || continue
|
|
39
|
+
src="$(adopt_submission_value "$d" source)"
|
|
40
|
+
[ -n "$src" ] && [ "$src" != "$source" ] || continue
|
|
41
|
+
git -C "$wt" merge-base --is-ancestor "$src" "$source" 2>/dev/null || continue
|
|
42
|
+
n="$(adopt_submission_value "$d" n)"
|
|
43
|
+
case "$n" in ''|*[!0-9]*) n=1 ;; esac
|
|
44
|
+
if [ "$n" -gt "$best_n" ]; then best="$d"; best_n="$n"; fi
|
|
45
|
+
done < <(for d in "$plan"/adopt-*/submission; do [ -f "$d" ] && printf '%s\n' "${d%/submission}"; done \
|
|
46
|
+
| awk -F- '{ print $(NF-1) "\t" $NF "\t" $0 }' | sort -t "$(printf '\t')" -k1,1nr -k2,2nr | awk -F'\t' '{ sub(/^[^\t]*\t[^\t]*\t/, ""); print }')
|
|
47
|
+
[ -z "$best" ] || printf '%s\n' "$best"
|
|
48
|
+
return 0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# adopt_cap <plan>: refused submissions of one lineage before it waits for a decision (escalate_after; 3
|
|
52
|
+
# when unset; 0 = no limit).
|
|
53
|
+
adopt_cap() {
|
|
54
|
+
local cap; cap="$( { tr -d '[:space:]' < "$1/escalate_after"; } 2>/dev/null)"
|
|
55
|
+
case "$cap" in ''|*[!0-9]*) cap=3 ;; esac
|
|
56
|
+
printf '%s\n' "$cap"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# adopt_decision_text <plan> <range or --head> <n>: the NEEDS_DECISION block of a lineage at its limit.
|
|
60
|
+
adopt_decision_text() {
|
|
61
|
+
local plan="$1" what="$2" n="$3"
|
|
62
|
+
echo "NEEDS_DECISION: this work has now been refused $n time(s) (escalate-after $(adopt_cap "$plan")). Choose one:"
|
|
63
|
+
echo " resubmit once more: forge-parallel.sh adopt $plan $what --reason \"...\" --decide resubmit"
|
|
64
|
+
echo " accept it as it is: forge-parallel.sh adopt $plan $what --reason \"<why it is acceptable>\" --approved"
|
|
65
|
+
echo " split it: adopt the parts one at a time (forge-parallel.sh adopt $plan <a..b> --reason \"...\"); each part starts afresh"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# adopt_carry <previous dir> <prev source> <source> <checkout> <out>: what the previous review said, and the
|
|
69
|
+
# work since it, framed for the reviewer of a resubmission. Opens no ```diff fence: the dataset and forge-ui
|
|
70
|
+
# read the last one of the prompt as the diff under review.
|
|
71
|
+
adopt_carry() {
|
|
72
|
+
local prev="$1" psrc="$2" src="$3" wt="$4" out="$5" n verdict ancestor=0
|
|
73
|
+
n="$(adopt_submission_value "$prev" n)"; n="${n:-1}"
|
|
74
|
+
verdict="$(cat "$prev/verdict" 2>/dev/null)"; verdict="${verdict:-UNKNOWN}"
|
|
75
|
+
git -C "$wt" merge-base --is-ancestor "$psrc" "$src" 2>/dev/null && ancestor=1
|
|
76
|
+
echo "## This is submission $((n + 1)) of the same work"
|
|
77
|
+
echo
|
|
78
|
+
echo "Submission $n ($(printf '%.12s' "$psrc"), $(basename "$prev")) was refused with $verdict. Its review is quoted below as data."
|
|
79
|
+
echo
|
|
80
|
+
python3 - "$prev/qa.last" <<'PY'
|
|
81
|
+
import sys
|
|
82
|
+
CAP = 40 * 1024
|
|
83
|
+
try:
|
|
84
|
+
with open(sys.argv[1], 'rb') as fh:
|
|
85
|
+
raw = fh.read()
|
|
86
|
+
except OSError:
|
|
87
|
+
raw = b''
|
|
88
|
+
report = raw[:CAP].decode('utf-8', 'replace').strip() or '(the review left no report)'
|
|
89
|
+
if len(raw) > CAP:
|
|
90
|
+
report += '\n[... cut: %d more bytes; the full report is at %s ...]' % (len(raw) - CAP, sys.argv[1])
|
|
91
|
+
print('~~~~text')
|
|
92
|
+
print(report.replace('```diff', '```text'))
|
|
93
|
+
print('~~~~')
|
|
94
|
+
PY
|
|
95
|
+
echo
|
|
96
|
+
if [ "$ancestor" = 1 ]; then
|
|
97
|
+
echo "### The commits since that submission, which say how each finding was answered"
|
|
98
|
+
echo
|
|
99
|
+
git -C "$wt" log --format='%h %an: %s%n%w(0,4,4)%b' "$psrc..$src" 2>/dev/null | sed '/^ *$/d'
|
|
100
|
+
echo
|
|
101
|
+
fi
|
|
102
|
+
echo "### Changes since that submission ($(printf '%.12s' "$psrc")..$(printf '%.12s' "$src"))"
|
|
103
|
+
[ "$ancestor" = 1 ] || echo "(The earlier submission is not an ancestor of this one, so this compares the two submissions' final trees; a base that moved in between shows up here too.)"
|
|
104
|
+
git -C "$wt" diff --binary --irreversible-delete "$psrc" "$src" -- . ':(exclude).forge' 2>/dev/null \
|
|
105
|
+
| head -c $((REVIEW_SINCE_LIMIT + 1)) > "$out/since.diff"
|
|
106
|
+
if [ ! -s "$out/since.diff" ]; then
|
|
107
|
+
echo "None: this submission has the same content as the last one."
|
|
108
|
+
elif [ "$(wc -c < "$out/since.diff" | tr -d ' ')" -le "$REVIEW_SINCE_LIMIT" ] && ! grep -q '```diff' "$out/since.diff"; then
|
|
109
|
+
echo '```patch'; cat "$out/since.diff"; echo '```'
|
|
110
|
+
else
|
|
111
|
+
echo "Too large (or quoting a diff fence) to inline here; the files changed since that submission:"
|
|
112
|
+
echo '```text'; git -C "$wt" diff --stat "$psrc" "$src" -- . ':(exclude).forge' 2>/dev/null; echo '```'
|
|
113
|
+
fi
|
|
114
|
+
rm -f "$out/since.diff"
|
|
115
|
+
echo
|
|
116
|
+
echo "Before anything else, settle each finding of that review against this range: fixed, still present,"
|
|
117
|
+
echo "or no longer applicable. Report every one still present again, in the usual labelled format with its"
|
|
118
|
+
echo "severity (\`- [Px][CONFIRMED|PLAUSIBLE] ...\`); mention the others only in plain sentences, never in that"
|
|
119
|
+
echo "format, since every labelled line is filed as an open finding. For each earlier finding, also look for"
|
|
120
|
+
echo "its siblings in the same pass: is there any other input, case or caller the same check skips, or the"
|
|
121
|
+
echo "same mistake elsewhere in the range? Report those now, so this round closes the whole class rather than"
|
|
122
|
+
echo "one instance of it. Then review the whole range, paying particular attention to the changes since"
|
|
123
|
+
echo "that submission."
|
|
124
|
+
echo
|
|
125
|
+
}
|
|
17
126
|
|
|
18
127
|
adopt_rows() { # adopt_rows <plan>: the adopted ranges, as lines for a prompt
|
|
19
128
|
[ -s "$1/adoptions.tsv" ] || return 0
|
|
@@ -24,7 +133,7 @@ adopt_rows() { # adopt_rows <plan>: the adopted ranges, as lines for a prompt
|
|
|
24
133
|
|
|
25
134
|
do_adopt() {
|
|
26
135
|
local PLAN="${1:?adopt needs a plan dir}"; shift
|
|
27
|
-
local target="" head=0 reason="" approved=0 spec="" yolo_given=""
|
|
136
|
+
local target="" head=0 reason="" approved=0 spec="" yolo_given="" resubmit="" decide=""
|
|
28
137
|
while [ $# -gt 0 ]; do
|
|
29
138
|
case "$1" in
|
|
30
139
|
--head) head=1; shift ;;
|
|
@@ -32,12 +141,15 @@ do_adopt() {
|
|
|
32
141
|
--qa) [ $# -ge 2 ] || die "adopt: --qa needs a spec"; spec="$2"; shift 2 ;;
|
|
33
142
|
--yolo-qa) yolo_given=1; shift ;;
|
|
34
143
|
--approved) approved=1; shift ;;
|
|
144
|
+
--resubmit) [ $# -ge 2 ] || die "adopt: --resubmit needs an adopt directory"; resubmit="$2"; shift 2 ;;
|
|
145
|
+
--decide) [ $# -ge 2 ] || die "adopt: --decide needs resubmit"
|
|
146
|
+
[ "$2" = resubmit ] || die "adopt: --decide takes resubmit (to accept, use --approved)"; decide="$2"; shift 2 ;;
|
|
35
147
|
-*) die "adopt: unknown option '$1'" ;;
|
|
36
148
|
*) [ -z "$target" ] || die "adopt: unexpected argument '$1'"; target="$1"; shift ;;
|
|
37
149
|
esac
|
|
38
150
|
done
|
|
39
151
|
{ [ -n "$target" ] && [ "$head" = 0 ]; } || { [ -z "$target" ] && [ "$head" = 1 ]; } \
|
|
40
|
-
|| die "usage: forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason \"<why>\" [--qa <spec>] [--yolo-qa] [--approved]"
|
|
152
|
+
|| die "usage: forge-parallel.sh adopt <plan-dir> <commit|a..b> | --head --reason \"<why>\" [--qa <spec>] [--yolo-qa] [--approved] [--resubmit <adopt dir>] [--decide resubmit]"
|
|
41
153
|
reason="$(printf '%s' "$reason" | tr '\n\r\t' ' ' | sed 's/^ *//; s/ *$//')"
|
|
42
154
|
[ -n "$reason" ] || die "adopt needs --reason \"<why this commit belongs in the run>\": the reviewer judges against it, and it is recorded"
|
|
43
155
|
|
|
@@ -74,6 +186,34 @@ do_adopt() {
|
|
|
74
186
|
done
|
|
75
187
|
fi
|
|
76
188
|
|
|
189
|
+
# The submission: the last commit of the range as given, and the refused submission it extends (#155).
|
|
190
|
+
local source prev="" psrc="" lineage="" sub_n=1 prev_n cap what
|
|
191
|
+
if [ "$head" = 1 ]; then source="$now"; what="--head"; else source="${commits[${#commits[@]}-1]}"; what="$target"; fi
|
|
192
|
+
if [ -n "$resubmit" ]; then
|
|
193
|
+
case "$resubmit" in /*) prev="$resubmit" ;; *) prev="$PLAN/${resubmit#./}" ;; esac
|
|
194
|
+
prev="${prev%/}"
|
|
195
|
+
case "$(basename "$prev")" in adopt-*) ;; *) die "adopt: --resubmit names an adopt directory of this plan (adopt-<epoch>-<pid>)" 3 ;; esac
|
|
196
|
+
[ "$(cd "$(dirname "$prev")" 2>/dev/null && pwd -P)" = "$(cd "$PLAN" && pwd -P)" ] && [ -s "$prev/qa.last" ] \
|
|
197
|
+
|| die "adopt: --resubmit $resubmit is not a reviewed adopt directory of this plan" 3
|
|
198
|
+
else
|
|
199
|
+
prev="$(adopt_previous "$PLAN" "$int_wt" "$source")"
|
|
200
|
+
fi
|
|
201
|
+
if [ -n "$prev" ]; then
|
|
202
|
+
psrc="$(adopt_submission_value "$prev" source)"
|
|
203
|
+
# A review from before submissions were recorded: its tip is the best source there is.
|
|
204
|
+
[ -n "$psrc" ] || psrc="$(git -C "$int_wt" rev-parse -q --verify "refs/forge/adopt-refused/$(basename "$prev")" 2>/dev/null)"
|
|
205
|
+
git -C "$int_wt" rev-parse -q --verify "${psrc:-none}^{commit}" >/dev/null 2>&1 \
|
|
206
|
+
|| die "adopt: the earlier submission's commits ($(basename "$prev")) are not in this repository" 3
|
|
207
|
+
prev_n="$(adopt_submission_value "$prev" n)"; prev_n="${prev_n:-1}"
|
|
208
|
+
lineage="$(adopt_submission_value "$prev" lineage)"; lineage="${lineage:-$(basename "$prev")}"
|
|
209
|
+
sub_n=$((prev_n + 1))
|
|
210
|
+
cap="$(adopt_cap "$PLAN")"
|
|
211
|
+
if [ "$cap" -gt 0 ] && [ "$prev_n" -ge "$cap" ] && [ "$decide" != resubmit ] && [ "$approved" = 0 ]; then
|
|
212
|
+
adopt_decision_text "$PLAN" "$what" "$prev_n" >&2
|
|
213
|
+
die "adopt: this is a resubmission of $(basename "$prev"), and the work waits for your decision; nothing was reviewed" 3
|
|
214
|
+
fi
|
|
215
|
+
fi
|
|
216
|
+
|
|
77
217
|
# Everything that can refuse without a model goes first, so a bad spec moves nothing.
|
|
78
218
|
[ -n "$spec" ] || spec="$(cat "$PLAN/final_qa" 2>/dev/null)"
|
|
79
219
|
[ -n "$spec" ] || spec="$(field "$T" "$(all_ids "$T" | head -1)" qa)"
|
|
@@ -81,6 +221,9 @@ do_adopt() {
|
|
|
81
221
|
local out ft rc=0 yolo tflag=""
|
|
82
222
|
out="$PLAN/adopt-$(date +%s)-$$"
|
|
83
223
|
mkdir -p "$out" && out="$(cd "$out" && pwd)" || die "adopt: cannot create $out" 3
|
|
224
|
+
[ -n "$lineage" ] || lineage="$(basename "$out")"
|
|
225
|
+
printf 'base=%s\nsource=%s\nlineage=%s\nn=%s\nprevious=%s\n' "$base" "$source" "$lineage" "$sub_n" \
|
|
226
|
+
"$([ -n "$prev" ] && basename "$prev")" > "$out/submission"
|
|
84
227
|
ft="$(forge_fast_tier "$PLAN" review)"
|
|
85
228
|
yolo="$(review_yolo_flag "$PLAN" "$yolo_given")"
|
|
86
229
|
[ -s "$PLAN/timeout" ] && tflag="--timeout $(cat "$PLAN/timeout")"
|
|
@@ -110,6 +253,8 @@ do_adopt() {
|
|
|
110
253
|
git -C "$int_wt" update-ref "refs/forge/adopt-refused/$(basename "$out")" "$tip" 2>/dev/null
|
|
111
254
|
echo "the integration branch is back at $(printf '%.12s' "$base"); your commits are at $tip (ref refs/forge/adopt-refused/$(basename "$out"))"
|
|
112
255
|
else
|
|
256
|
+
# The range as given stays reachable, so a resubmission can be compared with it (#155).
|
|
257
|
+
git -C "$int_wt" update-ref "refs/forge/adopt-refused/$(basename "$out")" "$source" 2>/dev/null
|
|
113
258
|
echo "the integration branch is back at $(printf '%.12s' "$base")"
|
|
114
259
|
fi
|
|
115
260
|
}
|
|
@@ -127,12 +272,14 @@ do_adopt() {
|
|
|
127
272
|
fi
|
|
128
273
|
fi
|
|
129
274
|
tip="$(git -C "$int_wt" rev-parse HEAD)"
|
|
275
|
+
printf 'tip=%s\n' "$tip" >> "$out/submission"
|
|
130
276
|
|
|
131
277
|
local review="$out/review" thr verdict gate_line decision kept inline=1 vcmd
|
|
132
278
|
FORGE_REVIEW_SNAPSHOT="$review" # the EXIT trap of forge-parallel.sh removes it on every exit (#139)
|
|
133
279
|
forge_review_snapshot "$int_wt" "$base" "$tip" "$review" > "$out/snapshot.log" 2>&1 \
|
|
134
280
|
|| { adopt_rollback; die "adopt: cannot build the review snapshot (see $out/snapshot.log)" 3; }
|
|
135
281
|
forge_review_deps "$int_wt" "$review" "$out/review.deps"
|
|
282
|
+
forge_review_submodules "$int_wt" "$review" "$out/review.deps"
|
|
136
283
|
source_fp="$(forge_fingerprint "$int_wt")" && review_fp="$(forge_fingerprint "$review" --tracked)" \
|
|
137
284
|
|| { adopt_rollback; die "adopt: cannot fingerprint the checkouts" 3; }
|
|
138
285
|
thr="$(qa_threshold_for "$PLAN" __adopt__)"
|
|
@@ -148,13 +295,19 @@ do_adopt() {
|
|
|
148
295
|
cat "$out/review.deps"
|
|
149
296
|
echo "Forge ran no tests of its own on this range, so nothing here stands in for yours."
|
|
150
297
|
# The run's verification, named and not run: it runs after this review, on the whole branch (#131).
|
|
151
|
-
vcmd="$(verify_command_for "$PLAN" "$(cat "$PLAN/repo")" | head -c 4000)"
|
|
298
|
+
vcmd="$(verify_command_for "$PLAN" "$(cat "$PLAN/repo")" "$int_wt" | head -c 4000)"
|
|
152
299
|
if [ -n "$vcmd" ]; then
|
|
153
300
|
echo "The run verifies its integration branch with the command below, after this review. Run the parts of it that touch this range:"
|
|
154
301
|
echo '```sh'; printf '%s\n' "$vcmd"; echo '```'
|
|
155
302
|
fi
|
|
156
303
|
echo
|
|
157
|
-
|
|
304
|
+
[ -z "$prev" ] || adopt_carry "$prev" "$psrc" "$source" "$int_wt" "$out"
|
|
305
|
+
local _tm="" _tm_flag=()
|
|
306
|
+
if [ -f "$PLAN/qa_test_minutes" ]; then
|
|
307
|
+
_tm="$(head -1 "$PLAN/qa_test_minutes" 2>/dev/null | tr -d ' \r')"
|
|
308
|
+
case "$_tm" in ''|*[!0-9]*) ;; *) _tm_flag=(--test-minutes "$_tm") ;; esac
|
|
309
|
+
fi
|
|
310
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind adopt --threshold "$thr" ${_tm_flag[@]+"${_tm_flag[@]}"}
|
|
158
311
|
echo
|
|
159
312
|
if [ "$inline" = 1 ]; then
|
|
160
313
|
echo '```diff'; cat "$out/range.diff"; echo '```'
|
|
@@ -225,9 +378,18 @@ do_adopt() {
|
|
|
225
378
|
"$(date '+%Y-%m-%dT%H:%M:%S%z')" "$(date +%s)" "$tip" > "$out/accepted.by"
|
|
226
379
|
else
|
|
227
380
|
echo "adopt: the reviewer said $verdict, so nothing was adopted (see $out/qa.last)."
|
|
381
|
+
printf 'refused=1\n' >> "$out/submission"
|
|
228
382
|
adopt_rollback
|
|
383
|
+
cap="$(adopt_cap "$PLAN")"
|
|
384
|
+
if [ "$cap" -gt 0 ] && [ "$sub_n" -ge "$cap" ]; then
|
|
385
|
+
echo
|
|
386
|
+
adopt_decision_text "$PLAN" "$what" "$sub_n" | tee "$out/needs_decision"
|
|
387
|
+
else
|
|
388
|
+
echo "fix the findings on top of this range and adopt it again: the next review is told what this one found."
|
|
389
|
+
fi
|
|
229
390
|
forge_dataset_event adopt --dir "$PLAN" --set base="$base" --set tip="$tip" --set verdict="$verdict" \
|
|
230
|
-
--set approved=0 --set adopted=0 --set spec="$spec" --set reason="$reason"
|
|
391
|
+
--set approved=0 --set adopted=0 --set spec="$spec" --set reason="$reason" \
|
|
392
|
+
--set lineage="$lineage" --set submission="$sub_n"
|
|
231
393
|
write_results "$PLAN"
|
|
232
394
|
return 5
|
|
233
395
|
fi
|
|
@@ -236,6 +398,7 @@ do_adopt() {
|
|
|
236
398
|
trap - INT TERM
|
|
237
399
|
printf '%s\n' "$tip" > "$PLAN/.accepted.integration.tmp" && mv "$PLAN/.accepted.integration.tmp" "$PLAN/accepted.integration" \
|
|
238
400
|
|| { adopt_rollback; die "adopt: could not record the accepted revision" 1; }
|
|
401
|
+
mark_verification_stale "$PLAN" "$tip"
|
|
239
402
|
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date +%s)" "$base" "$tip" "$verdict" "$kept" "$spec" "$(basename "$out")" "$reason" \
|
|
240
403
|
>> "$PLAN/adoptions.tsv"
|
|
241
404
|
python3 - "$PLAN/control.log" "$base" "$tip" "$verdict" "$kept" "$spec" "$reason" "${USER:-${LOGNAME:-unknown}}" <<'PY' \
|
|
@@ -248,6 +411,7 @@ with open(log, 'a') as handle:
|
|
|
248
411
|
PY
|
|
249
412
|
forge_dataset_event adopt --dir "$PLAN" --set base="$base" --set tip="$tip" --set verdict="$verdict" \
|
|
250
413
|
--set approved="$kept" --set adopted=1 --set spec="$spec" --set reason="$reason" \
|
|
414
|
+
--set lineage="$lineage" --set submission="$sub_n" \
|
|
251
415
|
--set authors="$(git -C "$int_wt" log --format='%an' "$base..$tip" | sort -u | awk 'NR > 1 { printf "," } { printf "%s", $0 }')"
|
|
252
416
|
echo "adopted $(printf '%.12s' "$base")..$(printf '%.12s' "$tip") ($verdict) into the integration branch"
|
|
253
417
|
|
|
@@ -107,6 +107,8 @@ attribute_verify() { # attribute_verify <k>
|
|
|
107
107
|
attribute_scratch_remove
|
|
108
108
|
return 1
|
|
109
109
|
fi
|
|
110
|
+
# The scratch checkout's own setup record, so verification's stale-setup check sees it fresh.
|
|
111
|
+
python3 "$SKILL_DIR/scripts/forge-setup-stale.py" record-commit "$ATTR_SCRATCH" 2>/dev/null || true
|
|
110
112
|
fi
|
|
111
113
|
t0="$(date +%s)"
|
|
112
114
|
# In the background, as `run` does: a stop reaches this shell, which passes it on, and the
|
|
@@ -231,8 +233,13 @@ attribute_evidence() { # attribute_evidence <plan> <force>
|
|
|
231
233
|
[ -s "$plan/wt_root" ] && [ -s "$plan/repo" ] || die "this plan has never been run: there is nothing to attribute"
|
|
232
234
|
repo="$(cat "$plan/repo")"; run_id="$(cat "$plan/run_id" 2>/dev/null)"
|
|
233
235
|
if [ "$force" != 1 ]; then
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
local vstatus
|
|
237
|
+
vstatus="$(cat "$plan/verification.status" 2>/dev/null)"
|
|
238
|
+
if [ "$vstatus" = STALE ]; then
|
|
239
|
+
die "the failed verification was not of the accepted integration commit (verification.status is 'STALE'): it says nothing about the tip; --force verifies the tip itself"
|
|
240
|
+
fi
|
|
241
|
+
[ "$vstatus" = FAIL ] \
|
|
242
|
+
|| die "the run's verification did not fail (verification.status is '$vstatus'): nothing to attribute; --force verifies the tip itself"
|
|
236
243
|
[ -s "$plan/verification.commit" ] && [ -s "$plan/accepted.integration" ] \
|
|
237
244
|
&& [ "$(cat "$plan/verification.commit")" = "$(cat "$plan/accepted.integration")" ] \
|
|
238
245
|
|| die "the failed verification was not of the accepted integration commit: it says nothing about the tip; --force verifies the tip itself"
|
|
@@ -357,7 +364,7 @@ attribute_search() { # attribute_search <plan> <force 0|1>
|
|
|
357
364
|
if verify_lanes_present "$ATTR_PLAN/verification.lanes.d"; then ATTR_SOURCE="lanes:$ATTR_PLAN/verification.lanes.d"
|
|
358
365
|
elif [ -s "$ATTR_PLAN/verification.command" ]; then ATTR_SOURCE="command:$ATTR_PLAN/verification.command"
|
|
359
366
|
elif [ "$force" = 1 ]; then
|
|
360
|
-
src="$(verify_source_for "$ATTR_PLAN" "$ATTR_REPO")"; kind="${src%%$'\t'*}"; loc="${src#*$'\t'}"
|
|
367
|
+
src="$(verify_source_for "$ATTR_PLAN" "$ATTR_REPO" "$(cat "$ATTR_PLAN/wt_root" 2>/dev/null)/_integration")"; kind="${src%%$'\t'*}"; loc="${src#*$'\t'}"
|
|
361
368
|
case "$kind" in
|
|
362
369
|
lanes:*) ATTR_SOURCE="lanes:$loc" ;;
|
|
363
370
|
command:*) ATTR_SOURCE="command:$loc" ;;
|