@giamme/forge 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/README.md +1 -1
- package/SKILL.md +31 -12
- package/VERSION +1 -1
- package/docs/add-ons.md +11 -6
- package/docs/artifacts.md +18 -6
- package/docs/commands.md +189 -17
- package/docs/decomposed-runs.md +13 -5
- package/docs/forge-ui.md +34 -4
- package/docs/memory.md +2 -1
- package/docs/models.md +4 -2
- package/docs/reviews.md +81 -19
- package/docs/troubleshooting.md +3 -1
- package/forge +17 -1
- package/package.json +1 -1
- package/references/dataset.md +40 -14
- package/references/decision-models.md +759 -0
- package/references/decompose.md +197 -28
- package/references/harnesses.md +10 -3
- package/references/planning.md +8 -0
- package/references/solo.md +13 -3
- package/references/ui.md +11 -0
- package/scripts/forge-artifact.sh +30 -4
- package/scripts/forge-config.py +238 -29
- package/scripts/forge-contract.py +127 -58
- package/scripts/forge-control.py +40 -9
- package/scripts/forge-decide.py +6 -0
- package/scripts/forge-dispatch.sh +47 -15
- package/scripts/forge-fail-first.py +2 -2
- package/scripts/forge-gate-addressed.sh +40 -0
- package/scripts/forge-gate-message.sh +64 -0
- package/scripts/forge-issues.py +368 -36
- package/scripts/forge-jev-options.sh +269 -42
- package/scripts/forge-lib-attribute.sh +447 -0
- package/scripts/forge-lib-gates.sh +32 -0
- package/scripts/forge-lib-plans.sh +17 -6
- package/scripts/forge-lib-review.sh +24 -19
- package/scripts/forge-lib-task.sh +219 -39
- package/scripts/forge-lib-verify.sh +45 -8
- package/scripts/forge-memory.sh +3 -3
- package/scripts/forge-parallel-options.sh +44 -5
- package/scripts/forge-parallel.sh +503 -304
- package/scripts/forge-plan-check.py +35 -1
- package/scripts/forge-pre-review.py +437 -0
- package/scripts/forge-prompt.py +25 -5
- package/scripts/forge-route.py +2 -2
- package/scripts/forge-runtime.py +55 -1
- package/scripts/forge-schedule.py +70 -9
- package/scripts/forge-shadow.py +2 -2
- package/scripts/forge-solo.sh +41 -10
- package/scripts/forge-submodules.py +389 -0
- package/scripts/forge-sweep.py +542 -0
- package/scripts/forge_dataset/cli.py +12 -6
- package/scripts/forge_dataset/export.py +55 -45
- package/scripts/forge_dataset/forecast.py +4 -1
- package/scripts/forge_dataset/harvest.py +33 -5
- package/scripts/{forge_jev/outcome.py → forge_dataset/states.py} +21 -7
- package/scripts/forge_decide/__init__.py +141 -0
- package/scripts/forge_decide/budget.py +149 -0
- package/scripts/forge_decide/cache.py +66 -0
- package/scripts/forge_decide/cli.py +953 -0
- package/scripts/forge_decide/doctor.py +221 -0
- package/scripts/forge_decide/label_addressed.py +75 -0
- package/scripts/forge_decide/label_attribution.py +62 -0
- package/scripts/forge_decide/label_coverage.py +81 -0
- package/scripts/forge_decide/label_message.py +38 -0
- package/scripts/forge_decide/label_prompt.py +139 -0
- package/scripts/forge_decide/labels.py +328 -0
- package/scripts/forge_decide/metrics.py +125 -0
- package/scripts/forge_decide/migrate.py +226 -0
- package/scripts/forge_decide/providers.py +292 -0
- package/scripts/forge_decide/replay.py +350 -0
- package/scripts/forge_decide/report.py +382 -0
- package/scripts/forge_decide/resolve.py +397 -0
- package/scripts/forge_decide/sites.py +377 -0
- package/scripts/forge_jev/__init__.py +202 -104
- package/scripts/forge_jev/addressed.py +171 -0
- package/scripts/forge_jev/attribution.py +198 -0
- package/scripts/forge_jev/cli.py +460 -382
- package/scripts/forge_jev/client.py +155 -77
- package/scripts/forge_jev/coupling.py +19 -87
- package/scripts/forge_jev/coverage.py +303 -0
- package/scripts/forge_jev/findings.py +219 -0
- package/scripts/forge_jev/gates.py +225 -27
- package/scripts/forge_jev/memory.py +65 -4
- package/scripts/forge_jev/message.py +134 -0
- package/scripts/forge_jev/plan_gates.py +294 -0
- package/scripts/forge_jev/questions.py +173 -313
- package/scripts/forge_jev/verify.py +130 -104
- package/ui/README.md +41 -10
- package/ui/docs/api.md +212 -44
- package/ui/forge_ui/checks.py +331 -0
- package/ui/forge_ui/control.py +60 -11
- package/ui/forge_ui/export.py +8 -3
- package/ui/forge_ui/models.py +1 -0
- package/ui/forge_ui/reader.py +436 -26
- package/ui/forge_ui/server.py +13 -0
- package/ui/forge_ui/static/app.js +15 -8
- package/ui/forge_ui/static/checksview.js +449 -0
- package/ui/forge_ui/static/controls.js +20 -13
- package/ui/forge_ui/static/convo.js +11 -2
- package/ui/forge_ui/static/findingsview.js +6 -4
- package/ui/forge_ui/static/index.html +1 -0
- package/ui/forge_ui/static/panel.js +105 -17
- package/ui/forge_ui/static/runmodel.js +40 -2
- package/ui/forge_ui/static/scene3d.js +2 -15
- package/ui/forge_ui/static/settings.js +336 -41
- package/ui/forge_ui/static/style.css +72 -7
- package/ui/forge_ui/transcripts.py +225 -54
- package/references/jev.md +0 -865
- package/scripts/forge_jev/backtest.py +0 -322
- package/scripts/forge_jev/corpus.py +0 -156
- package/scripts/forge_jev/features.py +0 -24
- package/scripts/forge_jev/predict.py +0 -204
- package/scripts/forge_jev/review.py +0 -73
- package/scripts/forge_jev/routing.py +0 -271
- package/scripts/forge_jev/subset.py +0 -123
|
@@ -11,6 +11,11 @@ Two opt-in behaviours live here, both off by default so a plain `run` is unchang
|
|
|
11
11
|
stops dispatching, lets running tasks drain and exits 8: nothing was the task's fault
|
|
12
12
|
and no attempt was spent, so the next `run` simply resumes.
|
|
13
13
|
|
|
14
|
+
A third, ``--sweep Pn``, also per invocation: once every task has merged, the open review
|
|
15
|
+
findings at Pn or worse become fix tasks (``forge-parallel.sh _sweep``, forge-sweep.py) that
|
|
16
|
+
this run then dispatches like any other, once per plan. A fix task that fails leaves its
|
|
17
|
+
findings for ``forge issues`` and does not fail the run.
|
|
18
|
+
|
|
14
19
|
Both numbers are per invocation, but while the scheduler runs they are mirrored into the
|
|
15
20
|
plan dir (retry_budget, infra_budget, tasks/<id>/retry_budget) and re-read at every
|
|
16
21
|
decision, so `forge control` can change them mid-run. See "live control files" below.
|
|
@@ -429,7 +434,12 @@ def stop_harnesses(plan: object, names: object) -> None:
|
|
|
429
434
|
# is left after it withdraws liveness, under the same lock, so no request outlives its run.
|
|
430
435
|
REQUESTS = 'control.requests'
|
|
431
436
|
REQUEST_MAX = 64 * 1024
|
|
432
|
-
|
|
437
|
+
# NEEDS_INPUT is in neither: a task stopped for the user's answer resumes only through
|
|
438
|
+
# `retry <plan> <id> --answer`, whose preparation refuses without one.
|
|
439
|
+
RETRYABLE = ('FAIL', 'UNKNOWN', 'TIMEOUT', 'ERROR', 'INTERRUPTED', 'BLOCKED', 'INVALIDATED')
|
|
440
|
+
# What --retry-failed retries on its own. INVALIDATED only for a review voided while the committed
|
|
441
|
+
# work stayed as it was (tasks/<id>/invalidated.reason is `review`): that retry is a fresh review.
|
|
442
|
+
AUTO_RETRY = ('FAIL', 'UNKNOWN', 'INVALIDATED')
|
|
433
443
|
|
|
434
444
|
|
|
435
445
|
def list_requests(plan: object) -> list:
|
|
@@ -527,7 +537,8 @@ def live_stop(plan: object, names: object) -> None:
|
|
|
527
537
|
|
|
528
538
|
|
|
529
539
|
def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
530
|
-
infra_retries: int = 0
|
|
540
|
+
infra_retries: int = 0, sweep: str | None = None, sweep_max: int = 5,
|
|
541
|
+
sweep_plausible: bool = False) -> int:
|
|
531
542
|
if capacity <= 0:
|
|
532
543
|
raise ValueError('capacity must be positive')
|
|
533
544
|
if retry_failed < 0 or infra_retries < 0:
|
|
@@ -569,6 +580,7 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
569
580
|
human = set() # tasks whose next dispatch is a `forge control retry` (dataset trigger human)
|
|
570
581
|
fractal = _fractal_plan(plan)
|
|
571
582
|
drain_told = False # the drained message was printed for this drain
|
|
583
|
+
sweep_asked = False # this invocation already asked for the finding sweep
|
|
572
584
|
|
|
573
585
|
def status(name: str) -> str:
|
|
574
586
|
root = plan / 'tasks' / name
|
|
@@ -599,10 +611,18 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
599
611
|
value = _read_budget(plan, 'infra_budget')
|
|
600
612
|
return infra_retries if value is None else value
|
|
601
613
|
|
|
614
|
+
def review_voided(name: str) -> bool:
|
|
615
|
+
file = plan / 'tasks' / name / 'invalidated.reason'
|
|
616
|
+
try:
|
|
617
|
+
return file.read_text().strip() == 'review'
|
|
618
|
+
except OSError:
|
|
619
|
+
return False
|
|
620
|
+
|
|
602
621
|
def retryable(name: str) -> bool:
|
|
603
622
|
root = plan / 'tasks' / name
|
|
604
623
|
return (
|
|
605
|
-
status(name) in
|
|
624
|
+
status(name) in AUTO_RETRY
|
|
625
|
+
and (status(name) != 'INVALIDATED' or review_voided(name))
|
|
606
626
|
and retries.get(name, 0) < budget(name)
|
|
607
627
|
# A task that produced no new work (empty diff, byte-identical retry) would
|
|
608
628
|
# only repeat itself; its marker says so and it is left for a human.
|
|
@@ -825,6 +845,9 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
825
845
|
return 'refused', 'the task is merged'
|
|
826
846
|
if state == 'INFRA':
|
|
827
847
|
return 'refused', 'an infrastructure stop is resumed by the scheduler itself'
|
|
848
|
+
if state == 'NEEDS_INPUT':
|
|
849
|
+
return 'refused', (name + ' is waiting for an answer: forge-parallel.sh retry ' + str(plan)
|
|
850
|
+
+ ' ' + name + ' --answer \u2026')
|
|
828
851
|
if state not in RETRYABLE:
|
|
829
852
|
return 'refused', 'a ' + state + ' task is not retried'
|
|
830
853
|
command = ['/bin/bash', script, '_prepare_retry', str(plan), name] + (['--dwarf', dwarf] if dwarf else [])
|
|
@@ -880,6 +903,38 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
880
903
|
_warn('waves.tsv was not refreshed for ' + name + '; the task still runs')
|
|
881
904
|
return 'applied', None
|
|
882
905
|
|
|
906
|
+
def is_fix(name: str) -> bool:
|
|
907
|
+
"""A finding sweep's fix task."""
|
|
908
|
+
return (plan / 'tasks' / name / 'sweep.json').is_file()
|
|
909
|
+
|
|
910
|
+
def sweep_due() -> bool:
|
|
911
|
+
"""--sweep was given, every task merged, nothing stops or holds the run, and this plan was
|
|
912
|
+
never swept (sweep/plan.json is the planner's record, and its marker)."""
|
|
913
|
+
return (bool(sweep) and not sweep_asked and not interrupted and not graceful and not paused
|
|
914
|
+
and not drained(plan) and not (plan / 'sweep' / 'plan.json').exists()
|
|
915
|
+
and all(status(name) == 'MERGED' for name in tasks))
|
|
916
|
+
|
|
917
|
+
def start_sweep() -> int:
|
|
918
|
+
"""Plan the finding sweep and queue its fix tasks; how many were queued. Whatever goes
|
|
919
|
+
wrong here ends the run without a sweep, never with a failure."""
|
|
920
|
+
nonlocal sweep_asked
|
|
921
|
+
sweep_asked = True
|
|
922
|
+
command = ['/bin/bash', script, '_sweep', str(plan), '--severity', sweep, '--max', str(sweep_max)]
|
|
923
|
+
result = subprocess.run(command + (['--plausible'] if sweep_plausible else []),
|
|
924
|
+
stdout=subprocess.PIPE, text=True)
|
|
925
|
+
if result.returncode:
|
|
926
|
+
_warn('the finding sweep could not be planned (exit ' + str(result.returncode)
|
|
927
|
+
+ '); its findings stay for forge issues')
|
|
928
|
+
return 0
|
|
929
|
+
queued = 0
|
|
930
|
+
for name in result.stdout.split():
|
|
931
|
+
outcome, reason = apply_add({'task': name})
|
|
932
|
+
if outcome == 'applied':
|
|
933
|
+
queued += 1
|
|
934
|
+
else:
|
|
935
|
+
_warn('sweep task ' + name + ' was not queued: ' + str(reason))
|
|
936
|
+
return queued
|
|
937
|
+
|
|
883
938
|
def handle_requests() -> None:
|
|
884
939
|
"""Apply or refuse each queued request; the outcome is logged under the control lock."""
|
|
885
940
|
for name in list_requests(plan):
|
|
@@ -926,7 +981,7 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
926
981
|
elif state == 'INFRA':
|
|
927
982
|
infra_stopped(name)
|
|
928
983
|
elif allow_requeue and not interrupted and not graceful \
|
|
929
|
-
and state in
|
|
984
|
+
and state in AUTO_RETRY and retryable(name):
|
|
930
985
|
requeue(name)
|
|
931
986
|
if not reaped:
|
|
932
987
|
return
|
|
@@ -952,7 +1007,7 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
952
1007
|
merge(name)
|
|
953
1008
|
if state == 'RUNNING':
|
|
954
1009
|
mark(name, 'INTERRUPTED')
|
|
955
|
-
if state in
|
|
1010
|
+
if state in AUTO_RETRY and not interrupted and retryable(name):
|
|
956
1011
|
requeue(name)
|
|
957
1012
|
if state == 'INFRA' and not interrupted and not resume(name):
|
|
958
1013
|
pending.remove(name)
|
|
@@ -960,7 +1015,7 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
960
1015
|
if status(name) not in ('PENDING', 'BLOCKED', 'INFRA'):
|
|
961
1016
|
pending.remove(name)
|
|
962
1017
|
swept = time.monotonic()
|
|
963
|
-
while pending or active or waiting_scopes():
|
|
1018
|
+
while pending or active or waiting_scopes() or sweep_due():
|
|
964
1019
|
# Reap before honouring the stop. A signal during the sleep, and a task
|
|
965
1020
|
# that exits while another merge is still running, have already written
|
|
966
1021
|
# a result; breaking first used to skip them and mark them INTERRUPTED.
|
|
@@ -983,7 +1038,7 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
983
1038
|
for name in tasks:
|
|
984
1039
|
if name in pending or name in active or name in ended:
|
|
985
1040
|
continue
|
|
986
|
-
if not interrupted and not graceful and status(name) in
|
|
1041
|
+
if not interrupted and not graceful and status(name) in AUTO_RETRY \
|
|
987
1042
|
and retryable(name) and refused.get(name) != budget(name):
|
|
988
1043
|
requeue(name)
|
|
989
1044
|
if paused and not active and infra_seen and not graceful and infra_cycles < infra_budget():
|
|
@@ -1071,6 +1126,8 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
1071
1126
|
# BLOCKED would turn "the provider was down" into a recorded failure.
|
|
1072
1127
|
# A task held back by its pin is still an infrastructure stop.
|
|
1073
1128
|
break
|
|
1129
|
+
if not pending and sweep_due() and start_sweep():
|
|
1130
|
+
continue
|
|
1074
1131
|
for name in pending:
|
|
1075
1132
|
mark(name, 'BLOCKED')
|
|
1076
1133
|
break
|
|
@@ -1125,7 +1182,8 @@ def schedule(script: str, plan: str, capacity: int, retry_failed: int = 0,
|
|
|
1125
1182
|
if paused or any(live_pause(pause) for pause in pauses.values()) \
|
|
1126
1183
|
or any(status(name) == 'INFRA' for name in tasks):
|
|
1127
1184
|
return INFRA_EXIT
|
|
1128
|
-
|
|
1185
|
+
# A fix task that did not merge leaves its findings for `forge issues`; the run's own work is done.
|
|
1186
|
+
return 0 if all(status(name) == 'MERGED' for name in tasks if not is_fix(name)) else 5
|
|
1129
1187
|
|
|
1130
1188
|
|
|
1131
1189
|
def main() -> None:
|
|
@@ -1153,9 +1211,12 @@ def main() -> None:
|
|
|
1153
1211
|
parser.add_argument('capacity', type=int)
|
|
1154
1212
|
parser.add_argument('--retry-failed', type=int, default=0, metavar='N')
|
|
1155
1213
|
parser.add_argument('--infra-retries', type=int, default=0, metavar='M')
|
|
1214
|
+
parser.add_argument('--sweep', choices=('P0', 'P1', 'P2', 'P3'))
|
|
1215
|
+
parser.add_argument('--sweep-max', type=int, default=5, metavar='N')
|
|
1216
|
+
parser.add_argument('--sweep-plausible', action='store_true')
|
|
1156
1217
|
args = parser.parse_args(sys.argv[1:])
|
|
1157
1218
|
sys.exit(schedule(args.script, args.plan, args.capacity, args.retry_failed,
|
|
1158
|
-
args.infra_retries))
|
|
1219
|
+
args.infra_retries, args.sweep, args.sweep_max, args.sweep_plausible))
|
|
1159
1220
|
except (OSError, ValueError, KeyError) as error:
|
|
1160
1221
|
print('forge scheduler: ' + str(error), file=sys.stderr)
|
|
1161
1222
|
sys.exit(3)
|
package/scripts/forge-shadow.py
CHANGED
|
@@ -197,7 +197,7 @@ def run(args) -> int:
|
|
|
197
197
|
if bash('forge_review_snapshot', args.worktree, args.base, args.reviewed, str(review)).returncode:
|
|
198
198
|
status = 'error'
|
|
199
199
|
return 0
|
|
200
|
-
before = bash('forge_fingerprint', str(review)).stdout.strip()
|
|
200
|
+
before = bash('forge_fingerprint', str(review), '--tracked').stdout.strip()
|
|
201
201
|
shutil.copyfile(Path(args.tdir) / 'qa.input', out / 'qa.input')
|
|
202
202
|
env = dict(os.environ, FORGE_SHADOW='1', FORGE_SHADOW_ATTEMPT=args.attempt,
|
|
203
203
|
FORGE_SHADOW_REVIEWED=args.reviewed, FORGE_SHADOW_FROM=args.qa)
|
|
@@ -211,7 +211,7 @@ def run(args) -> int:
|
|
|
211
211
|
STATE['child'] = subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT,
|
|
212
212
|
env=env, close_fds=True)
|
|
213
213
|
status = watch(STATE['child'], parent)
|
|
214
|
-
after = bash('forge_fingerprint', str(review)).stdout.strip()
|
|
214
|
+
after = bash('forge_fingerprint', str(review), '--tracked').stdout.strip()
|
|
215
215
|
if status == 'done' and (not before or after != before):
|
|
216
216
|
status = 'invalid' # the reviewer changed its snapshot: its verdict counts for nothing
|
|
217
217
|
except Stopped:
|
package/scripts/forge-solo.sh
CHANGED
|
@@ -19,14 +19,16 @@
|
|
|
19
19
|
# forge-solo.sh <run-dir> --repo <dir> --dwarf <spec> [--qa <spec>]
|
|
20
20
|
# [--approach <file>] [--yolo-dwarf] [--yolo-qa]
|
|
21
21
|
# [--native-review] [--no-memory] [--timeout <s>] [--dry-run] [--ui]
|
|
22
|
-
# [--fail-first]
|
|
22
|
+
# [--fail-first] [--qa-threshold P0|P1|P2|P3|none]
|
|
23
23
|
#
|
|
24
24
|
# Reads <run-dir>/prompt.md the implementation instruction (required)
|
|
25
25
|
# <run-dir>/goal.txt one line, what the user asked for (optional)
|
|
26
26
|
# Writes <run-dir>/dwarf.{input,last,log,resolved}
|
|
27
27
|
# <run-dir>/changes.diff
|
|
28
28
|
# <run-dir>/qa.{input,last,log,resolved}
|
|
29
|
-
# <run-dir>/verdict PASS | FAIL | UNKNOWN, when qa emitted one
|
|
29
|
+
# <run-dir>/verdict PASS | FAIL | UNKNOWN, when qa emitted one (after the severity gate)
|
|
30
|
+
# <run-dir>/qa.gate, known_issues.md the gate's decision and the tolerated findings
|
|
31
|
+
# <run-dir>/qa_threshold with --qa-threshold: the blocking level (default P2)
|
|
30
32
|
# <run-dir>/failfirst.json with --fail-first: do the change's tests fail without it?
|
|
31
33
|
# <run-dir>/status RUNNING, then this invocation's outcome
|
|
32
34
|
# <run-dir>/dwarf.spec, qa.spec and attempts.tsv
|
|
@@ -93,7 +95,7 @@ forge_metric_on_exit() {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
if [ "${1:-}" = --help ] || [ "${1:-}" = -h ]; then
|
|
96
|
-
sed -n '18,
|
|
98
|
+
sed -n '18,39s/^# *//p' "$0"
|
|
97
99
|
forge_fractal_help
|
|
98
100
|
echo 'Explicit Fractal retry: repeat the original command with --retry.'
|
|
99
101
|
exit 0
|
|
@@ -103,7 +105,7 @@ case "$RUN" in -*) die "first argument must be the run directory, got '$RUN'" ;;
|
|
|
103
105
|
shift
|
|
104
106
|
|
|
105
107
|
OUTPUT=summary
|
|
106
|
-
REPO="$PWD"; DWARF=""; QA="opus"; APPROACH=""; YD=""; YQ=""; NATIVE=""; TIMEOUT=""; DRY=0; FAIL_FIRST=0
|
|
108
|
+
REPO="$PWD"; DWARF=""; QA="opus"; APPROACH=""; YD=""; YQ=""; NATIVE=""; TIMEOUT=""; DRY=0; FAIL_FIRST=0; QA_THR=
|
|
107
109
|
while [ $# -gt 0 ]; do
|
|
108
110
|
case "$1" in
|
|
109
111
|
--fractal) forge_fractal_flag on || exit $?; shift ;;
|
|
@@ -124,11 +126,15 @@ while [ $# -gt 0 ]; do
|
|
|
124
126
|
--timeout) TIMEOUT="${2:?--timeout needs seconds}"; shift 2 ;;
|
|
125
127
|
--dry-run) DRY=1; shift ;;
|
|
126
128
|
--fail-first) FAIL_FIRST=1; shift ;;
|
|
129
|
+
--qa-threshold)
|
|
130
|
+
QA_THR="$(printf '%s' "${2:?--qa-threshold needs P0, P1, P2, P3 or none}" | tr 'a-z' 'A-Z')"
|
|
131
|
+
case "$QA_THR" in P0|P1|P2|P3) ;; NONE) QA_THR=none ;; *) die "--qa-threshold must be P0, P1, P2, P3 or none, got '$2'" 2 ;; esac
|
|
132
|
+
shift 2 ;;
|
|
127
133
|
--ui|--no-ui) forge_ui_flag "$1"; shift ;;
|
|
128
134
|
*)
|
|
129
135
|
# `case` is not a loop, so `continue` here belongs to the enclosing while.
|
|
130
136
|
if [ "$JEV_OPTS" = 1 ]; then
|
|
131
|
-
forge_jev_flag "
|
|
137
|
+
forge_jev_flag "$@"; jev_rc=$?
|
|
132
138
|
case "$jev_rc" in
|
|
133
139
|
0) shift "$JEV_SHIFT"; continue ;;
|
|
134
140
|
2) exit 2 ;;
|
|
@@ -163,6 +169,8 @@ RUN="$(cd "$RUN" && pwd)"
|
|
|
163
169
|
# same run dir restores it rather than re-reading whatever flags are passed then.
|
|
164
170
|
[ "$JEV_OPTS" = 1 ] && { forge_jev_restore "$RUN" || true; forge_jev_record "$RUN"; }
|
|
165
171
|
REPO="$(cd "$REPO" && pwd)"
|
|
172
|
+
# Before any decision-model step: the privacy floor and the run budget read these.
|
|
173
|
+
[ "$JEV_OPTS" = 1 ] && forge_decide_env "$REPO" "$RUN"
|
|
166
174
|
if [ "$DRY" != 1 ] && [ "${FORGE_SOLO_LOCK:-}" != "$RUN" ]; then
|
|
167
175
|
exec python3 "$SKILL_DIR/scripts/forge-fractal.py" _lock "$RUN" "$0" "${ORIGINAL_ARGS[@]}"
|
|
168
176
|
fi
|
|
@@ -281,11 +289,18 @@ REVIEW="$RUN/review-$(date +%s)-$$"
|
|
|
281
289
|
forge_review_snapshot "$REPO" "$START" "$END" "$REVIEW" || die "cannot create review snapshot" 3
|
|
282
290
|
SOURCE_FP="$(forge_fingerprint "$REPO")" || exit 3
|
|
283
291
|
[ "$(forge_tree "$REPO")" = "$END" ] || { echo INVALIDATED > "$RUN/verdict"; die "source changed while preparing QA" 5; }
|
|
284
|
-
|
|
292
|
+
# The review snapshot is a commit; the reviewer's untracked leftovers there do not count (#95).
|
|
293
|
+
# The source keeps them: in a solo run the implementer's new files are untracked.
|
|
294
|
+
REVIEW_FP="$(forge_fingerprint "$REVIEW" --tracked)" || exit 3
|
|
285
295
|
printf '%s\n' "$SOURCE_FP" > "$RUN/source.fingerprint"
|
|
286
296
|
printf '%s\n' "$REVIEW_FP" > "$RUN/review.fingerprint"
|
|
287
297
|
forge_metric_phase preparation
|
|
288
298
|
# --- qa -----------------------------------------------------------------------
|
|
299
|
+
# The blocking threshold: this invocation's flag (kept in the run dir), else the file, else P2.
|
|
300
|
+
[ -z "$QA_THR" ] || printf '%s\n' "$QA_THR" > "$RUN/qa_threshold"
|
|
301
|
+
THR="$(head -1 "$RUN/qa_threshold" 2>/dev/null | tr -d ' \r' | tr 'a-z' 'A-Z')"
|
|
302
|
+
case "$THR" in P0|P1|P2|P3) ;; NONE) THR=P3 ;; *) THR="$FORGE_QA_THRESHOLD_DEFAULT" ;; esac
|
|
303
|
+
rm -f "$RUN/qa.gate" "$RUN/known_issues.md"
|
|
289
304
|
rm -f "$RUN/failfirst.json" "$RUN/failfirst.txt"
|
|
290
305
|
if [ "$FAIL_FIRST" = 1 ]; then
|
|
291
306
|
# Opt-in and advisory: the reviewer reads the evidence; nothing here changes a verdict.
|
|
@@ -298,9 +313,11 @@ fi
|
|
|
298
313
|
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part head --kind solo
|
|
299
314
|
echo
|
|
300
315
|
if [ -s "$RUN/failfirst.txt" ]; then cat "$RUN/failfirst.txt"; echo; fi
|
|
301
|
-
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind solo
|
|
316
|
+
python3 "$SKILL_DIR/scripts/forge-contract.py" qa --part tail --kind solo --threshold "$THR"
|
|
302
317
|
echo
|
|
303
|
-
|
|
318
|
+
# --irreversible-delete: a deleted file shows as a header, not every line it had (one deleted
|
|
319
|
+
# data directory once made a 7.1M-character prompt that the reviewer's CLI refused).
|
|
320
|
+
echo '```diff'; git -C "$REPO" diff --binary --irreversible-delete "$START" "$END" -- . ':(exclude).forge'; echo '```'
|
|
304
321
|
echo; /bin/bash "$MEMORY" note qa
|
|
305
322
|
echo "Place any learning notes before the final FORGE_VERDICT: PASS or FORGE_VERDICT: FAIL line."
|
|
306
323
|
} > "$RUN/qa.input"
|
|
@@ -313,7 +330,7 @@ rc=$?
|
|
|
313
330
|
forge_metric_phase verification
|
|
314
331
|
verdict="$(forge_verdict "$RUN/qa.last")"
|
|
315
332
|
[ -n "$NATIVE" ] && verdict=UNKNOWN
|
|
316
|
-
if [ "$(forge_fingerprint "$REPO")" != "$SOURCE_FP" ] || [ "$(forge_fingerprint "$REVIEW")" != "$REVIEW_FP" ]; then
|
|
333
|
+
if [ "$(forge_fingerprint "$REPO")" != "$SOURCE_FP" ] || [ "$(forge_fingerprint "$REVIEW" --tracked)" != "$REVIEW_FP" ]; then
|
|
317
334
|
echo INVALIDATED > "$RUN/verdict"
|
|
318
335
|
die "source or review artifact changed during QA; review invalidated" 5
|
|
319
336
|
fi
|
|
@@ -327,11 +344,25 @@ dur_qa="$(sed -n 's/^duration_s=//p' "$RUN/qa.resolved" 2>/dev/null | tail -1)"
|
|
|
327
344
|
|
|
328
345
|
# --native-review is codex's own reviewer, which refuses a custom prompt alongside
|
|
329
346
|
# its scope flags — so it never sees the verdict instruction and cannot emit one.
|
|
347
|
+
# Otherwise forge enforces the severity rule itself, as a decomposed task's gate does; a gate
|
|
348
|
+
# that cannot run (no output) keeps the reviewer's verdict.
|
|
349
|
+
gate_note=""
|
|
350
|
+
if [ -z "$NATIVE" ]; then
|
|
351
|
+
gate_line="$(python3 "$SKILL_DIR/scripts/forge-contract.py" gate --verdict "${verdict:-UNKNOWN}" \
|
|
352
|
+
--qa-last "$RUN/qa.last" --threshold "$THR" --known-issues "$RUN/known_issues.md" 2>/dev/null)" || gate_line=""
|
|
353
|
+
if [ -n "$gate_line" ]; then
|
|
354
|
+
printf '%s\t%s\n' "$THR" "$gate_line" > "$RUN/qa.gate"
|
|
355
|
+
case "$(printf '%s' "$gate_line" | awk -F'\t' '{print $1}')" in
|
|
356
|
+
accept) verdict=PASS; gate_note=" (accepted with known issues: $RUN/known_issues.md)" ;;
|
|
357
|
+
fail) verdict=FAIL; gate_note=" (the reviewer said PASS, but listed a CONFIRMED finding at or above the $THR threshold — forge made it FAIL)" ;;
|
|
358
|
+
esac
|
|
359
|
+
fi
|
|
360
|
+
fi
|
|
330
361
|
echo "${verdict:-UNKNOWN}" > "$RUN/verdict"
|
|
331
362
|
|
|
332
363
|
echo
|
|
333
364
|
echo "dwarf: $DWARF ${dur_dwarf:-?}s"
|
|
334
|
-
echo "qa: $QA ${dur_qa:-?}s verdict: ${verdict:-UNKNOWN}"
|
|
365
|
+
echo "qa: $QA ${dur_qa:-?}s verdict: ${verdict:-UNKNOWN}$gate_note"
|
|
335
366
|
echo "diff: $RUN/changes.diff"
|
|
336
367
|
echo "read: $RUN/dwarf.last and $RUN/qa.last"
|
|
337
368
|
echo
|