@giamme/forge 0.22.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 +61 -0
- package/README.md +19 -12
- package/SKILL.md +137 -216
- package/VERSION +1 -1
- 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 +11 -9
- package/docs/forge-ui.md +33 -4
- package/docs/install.md +37 -5
- package/docs/memory.md +6 -1
- package/docs/models.md +36 -10
- package/docs/reviews.md +44 -25
- package/docs/safety.md +27 -2
- package/docs/troubleshooting.md +7 -10
- package/forge +25 -4
- package/package.json +2 -1
- 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 +143 -12
- 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 +777 -54
- package/scripts/forge-dispatch.sh +95 -12
- package/scripts/forge-du.py +13 -3
- package/scripts/forge-handoff.py +221 -39
- package/scripts/forge-install-ripwire.sh +100 -24
- package/scripts/forge-install.sh +18 -32
- 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 +21 -0
- package/scripts/forge-lib-group.sh +4 -1
- package/scripts/forge-lib-plans.sh +30 -18
- package/scripts/forge-lib-review.sh +28 -8
- package/scripts/forge-lib-task.sh +225 -56
- package/scripts/forge-lib-verify.sh +59 -10
- package/scripts/forge-memory.sh +81 -4
- package/scripts/forge-metrics.sh +4 -2
- package/scripts/forge-parallel-options.sh +23 -4
- package/scripts/forge-parallel.sh +447 -175
- 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 +37 -12
- package/scripts/forge-schedule.py +124 -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 +33 -56
- package/scripts/forge-sweep.py +2 -1
- package/scripts/forge-ui.py +8 -1
- package/scripts/forge-update.sh +2 -2
- package/scripts/forge-verify.py +16 -1
- package/scripts/forge-version.py +13 -1
- package/scripts/forge-watch.py +7 -2
- 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/profiles.py +11 -14
- package/scripts/forge_decompose.py +987 -0
- 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_prefs.py +138 -0
- package/scripts/forge_side/__init__.py +10 -0
- 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 +46 -14
- 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 +456 -59
- 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 +29 -29
- 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
|
@@ -24,6 +24,8 @@ import time
|
|
|
24
24
|
from pathlib import Path
|
|
25
25
|
|
|
26
26
|
from . import SCRIPTS, put_blob, put_file, sha256
|
|
27
|
+
import forge_decompose # noqa: E402 (scripts/ is on sys.path once the package is imported)
|
|
28
|
+
import forge_legacy # noqa: E402
|
|
27
29
|
|
|
28
30
|
DISPATCH_ROLES = ('dwarf', 'qa', 'planner', 'side')
|
|
29
31
|
# The file role stays `side`. Harvest records side_<kind> (see dispatch_event);
|
|
@@ -300,8 +302,9 @@ def locate(root: str | Path, role: str | None = None) -> dict:
|
|
|
300
302
|
"""Which run, mode and task a dispatch or pipeline root belongs to, from the path alone.
|
|
301
303
|
|
|
302
304
|
Env vars cannot carry this reliably (the orchestrator dispatches the planner by hand,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
and the importer has no env at all), so live capture and import both derive it from
|
|
306
|
+
where forge put the files. The steps/nodes shape is an old record: a run made with
|
|
307
|
+
Fractal, which forge 0.23 removed and the importer still reads.
|
|
305
308
|
"""
|
|
306
309
|
p = Path(root).resolve()
|
|
307
310
|
parts = p.parts
|
|
@@ -727,6 +730,26 @@ def requirement_blob(tdir: Path, stem: str):
|
|
|
727
730
|
return put_file(tdir / (stem + '.md'), 'prompt')
|
|
728
731
|
|
|
729
732
|
|
|
733
|
+
def steered_of(tdir: Path, attempt) -> tuple[list, str | None]:
|
|
734
|
+
"""The messages `forge control steer` gave this attempt (#134), as `{actor, at, sha256, chars, mode}`,
|
|
735
|
+
and their texts joined for the blob. An attempt nobody steered has `[]`. mode is `queued` (given with the
|
|
736
|
+
prompt) or `live` (sent while the implementer ran, #252)."""
|
|
737
|
+
if attempt is None:
|
|
738
|
+
return [], None
|
|
739
|
+
found, texts = [], []
|
|
740
|
+
for line in (text(tdir / ('steered.%d.jsonl' % attempt)) or '').splitlines():
|
|
741
|
+
try:
|
|
742
|
+
entry = json.loads(line)
|
|
743
|
+
except ValueError:
|
|
744
|
+
continue
|
|
745
|
+
if not isinstance(entry, dict) or not isinstance(entry.get('text'), str):
|
|
746
|
+
continue
|
|
747
|
+
found.append(dict(actor=entry.get('actor'), at=entry.get('at'), sha256=entry.get('sha256'),
|
|
748
|
+
chars=entry.get('chars'), mode='live' if entry.get('mode') == 'live' else 'queued'))
|
|
749
|
+
texts.append(entry['text'])
|
|
750
|
+
return found, ('\n\n---\n\n'.join(texts) if texts else None)
|
|
751
|
+
|
|
752
|
+
|
|
730
753
|
def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') -> dict:
|
|
731
754
|
before = prov.get('files')
|
|
732
755
|
made = lambda name: produced(tdir, before, name)
|
|
@@ -738,6 +761,7 @@ def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') ->
|
|
|
738
761
|
row = tasks_rows(plan / 'tasks.tsv').get(tdir.name, {})
|
|
739
762
|
diff = text(tdir / 'changes.diff') if made('changes.diff') else None
|
|
740
763
|
gate = first_line(tdir / 'qa.gate') if made('qa.gate') else None
|
|
764
|
+
steered, steer_text = steered_of(tdir, end)
|
|
741
765
|
data = dict(
|
|
742
766
|
status=status, exit=as_int(rc), attempt_start=prov.get('attempt_start'), attempt_end=end,
|
|
743
767
|
trigger=prov.get('trigger'), **flags,
|
|
@@ -752,6 +776,7 @@ def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') ->
|
|
|
752
776
|
retry_source=first_line(tdir / 'retry_findings.source'),
|
|
753
777
|
identical_retry=bool(diff) and made('changes.prev.diff') and diff == text(tdir / 'changes.prev.diff'),
|
|
754
778
|
prompt_changed=attempt_prompt_changed(status),
|
|
779
|
+
steered=steered,
|
|
755
780
|
produced=sorted(n for n in WATCHED if made(n)),
|
|
756
781
|
carried=sorted(n for n in WATCHED if (tdir / n).exists() and not made(n)),
|
|
757
782
|
children=children(tdir, attempt.name),
|
|
@@ -771,6 +796,7 @@ def task_event(attempt: Path, tdir: Path, rc, prov: dict, src: str = 'live') ->
|
|
|
771
796
|
review_triage_jev=put_file(tdir / 'qa.jev.json') if made('qa.jev.json') else None,
|
|
772
797
|
routing_jev=put_file(tdir / 'jev.json'),
|
|
773
798
|
prompt=requirement_blob(tdir, 'prompt'), approach=requirement_blob(tdir, 'approach'),
|
|
799
|
+
steer=put_blob(steer_text, 'message') if steer_text else None,
|
|
774
800
|
)
|
|
775
801
|
data['blobs'] = refs
|
|
776
802
|
return dict(rid=attempt.name, kind='attempt', ts=prov.get('wall_ended') or time.time(), src=src,
|
|
@@ -886,7 +912,7 @@ def run_end_event(attempt: Path, plan: Path, rc, prov: dict, src: str = 'live')
|
|
|
886
912
|
repo = first_line(plan / 'repo')
|
|
887
913
|
data = dict(exit=as_int(rc), results=results,
|
|
888
914
|
accepted_integration=first_line(plan / 'accepted.integration'),
|
|
889
|
-
blobs=blobs(memory=put_file(
|
|
915
|
+
blobs=blobs(memory=put_file(_memory_md(repo)) if repo else None))
|
|
890
916
|
return dict(rid=attempt.name, kind='run_end', ts=prov.get('wall_ended') or time.time(), src=src,
|
|
891
917
|
run=prov.get('run'), run_id=prov.get('run_id'), mode='parallel', parent=prov.get('parent'),
|
|
892
918
|
inv=prov.get('inv'), data=data)
|
|
@@ -928,6 +954,49 @@ def decision_snapshot(repo: str, rows: dict, head: str | None) -> dict | None:
|
|
|
928
954
|
return excerpts
|
|
929
955
|
|
|
930
956
|
|
|
957
|
+
def decomposition_of(plan: Path) -> tuple:
|
|
958
|
+
"""(parent, decomposition, chain) of a plan, each None when the plan has no such record (#153).
|
|
959
|
+
|
|
960
|
+
parent: for the sub-plan of a split task (`<plan>/tasks/<id>/sub`), the run and the task it holds the
|
|
961
|
+
subtasks of: {run, run_id, task, level, root, start, by, reason}. `level` is how deep its tasks are
|
|
962
|
+
(1 for the subtasks of a plan's own task), `root` the run at the top of the tree.
|
|
963
|
+
decomposition: {limits, frozen, nodes: {task: {decision, reason, by, children, limit}}}, the decision
|
|
964
|
+
recorded for each task of this plan: atomic, split or bounded.
|
|
965
|
+
chain: {stage, first, previous, later}: where a plan made by `next` stands in its goal, and how many
|
|
966
|
+
stages its planner proposed after it."""
|
|
967
|
+
plan = Path(plan)
|
|
968
|
+
parent = None
|
|
969
|
+
if plan.name == 'sub' and plan.parent.parent.name == 'tasks' and (plan.parents[2] / 'tasks.tsv').exists():
|
|
970
|
+
link = read_json(plan / 'parent.json')
|
|
971
|
+
if isinstance(link, dict):
|
|
972
|
+
above, level, root = plan.parents[2], 1, plan.parents[2]
|
|
973
|
+
while root.name == 'sub' and root.parent.parent.name == 'tasks' and (root.parents[2] / 'tasks.tsv').exists() \
|
|
974
|
+
and level < 16:
|
|
975
|
+
root, level = root.parents[2], level + 1
|
|
976
|
+
parent = dict(run=run_uid(above, create=False), run_id=first_line(above / 'run_id') or above.name,
|
|
977
|
+
task=plan.parent.name, level=level, root=run_uid(root, create=False),
|
|
978
|
+
start=link.get('start'), by=link.get('by'), reason=link.get('reason'))
|
|
979
|
+
decomposition = None
|
|
980
|
+
record = read_json(plan / 'decomposition.json')
|
|
981
|
+
if isinstance(record, dict):
|
|
982
|
+
nodes = {}
|
|
983
|
+
for task, node in (record.get('nodes') or {}).items() if isinstance(record.get('nodes'), dict) else ():
|
|
984
|
+
if isinstance(node, dict):
|
|
985
|
+
used = node.get('limits_used') if isinstance(node.get('limits_used'), dict) else {}
|
|
986
|
+
nodes[task] = dict(decision=node.get('decision'), reason=node.get('reason'), by=node.get('by'),
|
|
987
|
+
children=used.get('children'), limit=used.get('limit'))
|
|
988
|
+
# The limits in force are the root plan's, each default where it set none.
|
|
989
|
+
decomposition = dict(limits=forge_decompose.limits(plan), frozen=forge_decompose.is_frozen(plan), nodes=nodes)
|
|
990
|
+
chain = None
|
|
991
|
+
link, later = read_json(plan / 'chain.json'), read_json(plan / 'later.json')
|
|
992
|
+
stages = later.get('later') if isinstance(later, dict) and isinstance(later.get('later'), list) else []
|
|
993
|
+
if isinstance(link, dict) or stages:
|
|
994
|
+
link = link if isinstance(link, dict) else {}
|
|
995
|
+
chain = dict(stage=link.get('stage'), first=link.get('first'), previous=link.get('previous'),
|
|
996
|
+
later=[s.get('title') for s in stages if isinstance(s, dict)])
|
|
997
|
+
return parent, decomposition, chain
|
|
998
|
+
|
|
999
|
+
|
|
931
1000
|
def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True, head: str | None = None) -> dict:
|
|
932
1001
|
rows = tasks_rows(plan / 'tasks.tsv')
|
|
933
1002
|
declared_path = plan / 'tasks.declared.tsv'
|
|
@@ -986,6 +1055,15 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
986
1055
|
later['collapsed'] = collapsed_record
|
|
987
1056
|
if plan_gate is not None:
|
|
988
1057
|
later['plan_gate'] = plan_gate
|
|
1058
|
+
# The decisions about the plan's tasks (#153), hashed without their times: a task split after the
|
|
1059
|
+
# plan was first recorded is a new revision of the plan, and reading the same file again is not.
|
|
1060
|
+
parent, decomposition, chain = decomposition_of(plan)
|
|
1061
|
+
if parent is not None:
|
|
1062
|
+
later['parent'] = [parent['run'], parent['task']]
|
|
1063
|
+
if decomposition is not None:
|
|
1064
|
+
later['decomposition'] = [decomposition['limits'], decomposition['nodes']]
|
|
1065
|
+
if chain is not None:
|
|
1066
|
+
later['chain'] = chain
|
|
989
1067
|
inputs = json.dumps([text(plan / 'goal.txt'), text(plan / 'tasks.tsv'), text(declared_path),
|
|
990
1068
|
{t: [r['prompt'], r['approach']] for t, r in per_task.items()}] + ([later] if later else []),
|
|
991
1069
|
sort_keys=True, default=str)
|
|
@@ -997,8 +1075,7 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
997
1075
|
planner=first_line(plan / 'planner'), author='planner' if list(plan.glob('attempts/planner-*')) else 'orchestrator',
|
|
998
1076
|
planner_dispatches=sorted(p.name for p in plan.glob('attempts/planner-*')),
|
|
999
1077
|
head=head, tasks=per_task, waves=waves, deferrals=(text(plan / 'deferrals.txt') or '').splitlines(),
|
|
1000
|
-
pools=read_json(plan
|
|
1001
|
-
fractal_selection=read_json(plan / 'fractal-selection.json'),
|
|
1078
|
+
pools=read_json(forge_legacy.pools_path(plan)), jev_selection=read_json(plan / 'jev-selection.json'),
|
|
1002
1079
|
jev_coupling=read_json(plan / 'jev-coupling.json'),
|
|
1003
1080
|
options=dict({name: first_line(plan / name) for name in ('verify_retries', 'timeout', 'final_qa',
|
|
1004
1081
|
'shadow_qa', 'shadow_rate', 'explore', 'reviewer_session', 'reviewer_session_rate',
|
|
@@ -1012,8 +1089,13 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
1012
1089
|
jev_routing=put_file(plan / 'jev-routing.tsv'),
|
|
1013
1090
|
snapshot=put_blob(json.dumps(snapshot_excerpts, sort_keys=True), 'request') if snapshot_excerpts else None,
|
|
1014
1091
|
inventory=put_blob(listing, 'request') if listing else None,
|
|
1015
|
-
memory=put_file(
|
|
1092
|
+
memory=put_file(_memory_md(repo)) if repo else None),
|
|
1016
1093
|
)
|
|
1094
|
+
# An old record only: a plan made before forge 0.23 says whether it ran under Fractal, and the
|
|
1095
|
+
# routing analysis leaves such a run out. A plan without the file gets no such key.
|
|
1096
|
+
old_selection = read_json(plan / forge_legacy.OLD_SELECTION)
|
|
1097
|
+
if old_selection is not None:
|
|
1098
|
+
data['fractal_selection'] = old_selection
|
|
1017
1099
|
if plan_gates is not None:
|
|
1018
1100
|
data['plan_gates'] = plan_gates
|
|
1019
1101
|
if plan_shape is not None:
|
|
@@ -1032,6 +1114,13 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
1032
1114
|
data['collapsed_from'] = origin
|
|
1033
1115
|
if plan_gate is not None:
|
|
1034
1116
|
data['plan_gate'] = plan_gate
|
|
1117
|
+
# Recursive decomposition (#153). Absent on a plan with no such record, so an older plan keeps its shape.
|
|
1118
|
+
if parent is not None:
|
|
1119
|
+
data['parent'] = parent
|
|
1120
|
+
if decomposition is not None:
|
|
1121
|
+
data['decomposition'] = decomposition
|
|
1122
|
+
if chain is not None:
|
|
1123
|
+
data['chain'] = chain
|
|
1035
1124
|
# Who started the plan: `auto` for forge-parallel.sh auto. Absent for a plan built by hand.
|
|
1036
1125
|
orchestrator = first_line(plan / 'orchestrator')
|
|
1037
1126
|
if orchestrator:
|
|
@@ -1041,7 +1130,9 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
1041
1130
|
inv=prov.get('inv'), data=data)
|
|
1042
1131
|
|
|
1043
1132
|
|
|
1044
|
-
# --- Fractal
|
|
1133
|
+
# --- old records: runs made with Fractal ----------------------------------------------------
|
|
1134
|
+
# forge 0.23 removed Fractal (#154). Nothing writes these live any more; the importer still reads
|
|
1135
|
+
# what such a run left on disk, so its history is not lost when its state directory is deleted.
|
|
1045
1136
|
|
|
1046
1137
|
def fractal_context(task_dir: Path, create: bool) -> dict:
|
|
1047
1138
|
request = read_json(task_dir / 'request.json') or {}
|
|
@@ -1090,3 +1181,12 @@ def fractal_task_events(task_dir: Path, ctx: dict, src: str = 'live') -> list:
|
|
|
1090
1181
|
blobs=blobs(diff=put_file(task_dir / 'changes.diff', 'diff'),
|
|
1091
1182
|
qa=put_file(task_dir / 'qa.last', 'message')))))
|
|
1092
1183
|
return events
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
def _memory_md(repo) -> Path:
|
|
1187
|
+
"""repo's .forge/memory.md, in the main checkout when repo is a linked worktree (#159)."""
|
|
1188
|
+
try:
|
|
1189
|
+
import forge_memory_home
|
|
1190
|
+
except ImportError:
|
|
1191
|
+
return Path(repo) / '.forge' / 'memory.md'
|
|
1192
|
+
return forge_memory_home.memory_file(repo)
|
|
@@ -27,7 +27,7 @@ import time
|
|
|
27
27
|
from pathlib import Path
|
|
28
28
|
from types import SimpleNamespace
|
|
29
29
|
|
|
30
|
-
from . import (BUSY_TIMEOUT_S, DatasetError, config_runs_dir, connect,
|
|
30
|
+
from . import (BUSY_TIMEOUT_S, DatasetError, config_runs_dir, connect, dataset_dir, enabled,
|
|
31
31
|
location_refused, put_blob, put_file, record, record_strict, repo_id, sha256, watch_blob_failures)
|
|
32
32
|
from . import harvest as h
|
|
33
33
|
from . import capture
|
|
@@ -70,6 +70,7 @@ def walk_plans(top: Path, onerror=None) -> list[Path]:
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
def walk_fractal_tasks(top: Path, onerror=None) -> list[Path]:
|
|
73
|
+
"""Task dirs of a run made with Fractal (removed in forge 0.23): old records, still imported."""
|
|
73
74
|
found = []
|
|
74
75
|
for directory, subdirs, files in os.walk(top, onerror=onerror):
|
|
75
76
|
subdirs[:] = [d for d in subdirs if d not in SKIP_DIRS and not d.startswith('review-')
|
|
@@ -478,7 +479,7 @@ def _manifest(directory: Path) -> dict:
|
|
|
478
479
|
|
|
479
480
|
|
|
480
481
|
def _member(member, path):
|
|
481
|
-
# Links are never run data (Fractal
|
|
482
|
+
# Links are never run data (an old Fractal archive carries a venv full of absolute ones),
|
|
482
483
|
# and skipping them means nothing extracted can point outside the temp dir.
|
|
483
484
|
if member.issym() or member.islnk():
|
|
484
485
|
return None
|
|
@@ -134,13 +134,13 @@ def report(runs: Runs, repo: str = None) -> dict:
|
|
|
134
134
|
by_kind={k: sum(r['pairs'] for r in out if r['kind'] == k) for k in KINDS}, comparisons=out)
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def load(repo: str = None) -> dict:
|
|
137
|
+
def load(repo: str = None, include_steered: bool = False) -> dict:
|
|
138
138
|
# Reading must not create a store: a fresh machine gets an empty report.
|
|
139
139
|
if not (dataset_dir() / 'dataset.sqlite').exists():
|
|
140
140
|
return dict(min_pairs=MIN_PAIRS, line_window=LINE_WINDOW, pairs=0, by_kind={k: 0 for k in KINDS}, comparisons=[])
|
|
141
141
|
db = connect()
|
|
142
142
|
try:
|
|
143
|
-
runs = Runs(Store(db))
|
|
143
|
+
runs = Runs(Store(db), include_steered=include_steered)
|
|
144
144
|
finally:
|
|
145
145
|
db.close()
|
|
146
146
|
return report(runs, repo=repo)
|
|
@@ -151,7 +151,7 @@ HEADINGS = dict(effort='effort, within one model', model='another model, one fam
|
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
def main(args) -> int:
|
|
154
|
-
rep = load(os.path.realpath(args.repo) if args.repo else None)
|
|
154
|
+
rep = load(os.path.realpath(args.repo) if args.repo else None, include_steered=getattr(args, 'include_steered', False))
|
|
155
155
|
if args.json:
|
|
156
156
|
print(json.dumps(rep, indent=2, sort_keys=True))
|
|
157
157
|
return 0
|
|
@@ -100,13 +100,13 @@ def report(runs: Runs, *, horizon_days: int = HORIZON_DAYS, repo: str = None) ->
|
|
|
100
100
|
return out
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
def load(horizon_days: int = HORIZON_DAYS, repo: str = None) -> dict:
|
|
103
|
+
def load(horizon_days: int = HORIZON_DAYS, repo: str = None, include_steered: bool = False) -> dict:
|
|
104
104
|
# Reading must not create a store: a fresh machine (or forge-ui asking) gets an empty report.
|
|
105
105
|
if not (dataset_dir() / 'dataset.sqlite').exists():
|
|
106
106
|
return _empty(horizon_days)
|
|
107
107
|
db = connect()
|
|
108
108
|
try:
|
|
109
|
-
runs = Runs(Store(db))
|
|
109
|
+
runs = Runs(Store(db), include_steered=include_steered)
|
|
110
110
|
finally:
|
|
111
111
|
db.close()
|
|
112
112
|
return report(runs, horizon_days=horizon_days, repo=repo)
|
|
@@ -120,7 +120,8 @@ def main(args) -> int:
|
|
|
120
120
|
if args.horizon_days < 1:
|
|
121
121
|
print('forge dataset reviewers: --horizon-days must be at least 1', file=sys.stderr)
|
|
122
122
|
return 2
|
|
123
|
-
rep = load(args.horizon_days, os.path.realpath(args.repo) if args.repo else None
|
|
123
|
+
rep = load(args.horizon_days, os.path.realpath(args.repo) if args.repo else None,
|
|
124
|
+
include_steered=getattr(args, 'include_steered', False))
|
|
124
125
|
if args.json:
|
|
125
126
|
print(json.dumps(rep, indent=2, sort_keys=True))
|
|
126
127
|
return 0
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Two tables, kept apart because they answer different questions:
|
|
4
4
|
|
|
5
5
|
- **Observational**: every task's first attempt, by declared tier and the model and effort
|
|
6
|
-
that ran it (resolved, so `sol` and `gpt-6.
|
|
6
|
+
that ran it (resolved, so `sol` and `gpt-6.2-sol:medium:codex` are one row). First-pass rate
|
|
7
7
|
(Wilson 95%), the share that passed review at some attempt (or that a human accepted),
|
|
8
8
|
unfinished tasks, attempts per task and the implementer's runtime. Routing chose who ran what, so a model sent the hard tasks looks
|
|
9
|
-
worse here than it is. Fractal
|
|
9
|
+
worse here than it is. Runs made with Fractal (removed in forge 0.23) are left out: their dispatches have their own identities
|
|
10
10
|
and their runtime would be missing.
|
|
11
11
|
- **Randomized**: the `plan --explore` draws (forge-route.py), one row per (tier, default,
|
|
12
12
|
alternative) pair, since round-robin pools make the pair differ between rows and a spec has
|
|
@@ -93,6 +93,9 @@ def tasks(runs: Runs, *, repo=None, since=None) -> list:
|
|
|
93
93
|
rows[tid] = row
|
|
94
94
|
decisions[tid].extend(row.get('route') or [])
|
|
95
95
|
for tid, row in rows.items():
|
|
96
|
+
# A steered task (#134) is left out whole: its later attempts and its outcome carry a person's nudge.
|
|
97
|
+
if (run, tid) in runs.steered and not runs.include_steered:
|
|
98
|
+
continue
|
|
96
99
|
events = runs.attempts.get((run, tid), [])
|
|
97
100
|
attempts = _attempts(runs, run, tid, events)
|
|
98
101
|
first = attempts[0] if attempts else None
|
|
@@ -241,7 +244,7 @@ def _pct(x):
|
|
|
241
244
|
def main(args) -> int:
|
|
242
245
|
db = connect()
|
|
243
246
|
try:
|
|
244
|
-
runs = Runs(Store(db))
|
|
247
|
+
runs = Runs(Store(db), include_steered=getattr(args, 'include_steered', False))
|
|
245
248
|
finally:
|
|
246
249
|
db.close()
|
|
247
250
|
repo = os.path.realpath(args.repo) if args.repo else None
|
|
@@ -5,7 +5,7 @@ very differently. This report looks inside each tier with only what the dataset
|
|
|
5
5
|
nothing in a run.
|
|
6
6
|
|
|
7
7
|
Population: the tasks `forge dataset routing` counts, whose first attempt says something about the
|
|
8
|
-
implementer (
|
|
8
|
+
implementer (old Fractal runs left out). Each task is described by:
|
|
9
9
|
|
|
10
10
|
plan time known before dispatch, so a rule could route on it: declared files, dependencies, wave,
|
|
11
11
|
the size of the task's prompt (KB)
|
|
@@ -18,7 +18,7 @@ File schema, the same at both levels (unknown keys are kept and ignored):
|
|
|
18
18
|
"profiles": {"<name>": {
|
|
19
19
|
"routing": {"dwarf": {"any"|"low"|"medium"|"high": [spec, ...]},
|
|
20
20
|
"qa": {"any"|"low"|"medium"|"high": [spec, ...]},
|
|
21
|
-
"planner": spec, "
|
|
21
|
+
"planner": spec, "final_reviewer": spec,
|
|
22
22
|
"escalate_after": int >= 0, "escalate_effort": bool},
|
|
23
23
|
"policy": {"qa_threshold": "P0"|"P1"|"P2"|"P3"|"none", "retry_failed": int >= 0,
|
|
24
24
|
"infra_retries": int >= 0, "verify_retries": int >= 0, "timeout": int >= 0,
|
|
@@ -36,11 +36,14 @@ import tempfile
|
|
|
36
36
|
import unicodedata
|
|
37
37
|
|
|
38
38
|
from . import GATES, MODES, load_repo, load_user
|
|
39
|
+
import forge_legacy # noqa: E402 (scripts/ is on sys.path: this package is imported from it)
|
|
39
40
|
|
|
40
41
|
LEVELS = ('user', 'repo', 'builtin')
|
|
41
42
|
TIERS = ('any', 'low', 'medium', 'high')
|
|
42
43
|
POOLS = ('dwarf', 'qa')
|
|
43
|
-
ROUTING_SPECS = ('planner', '
|
|
44
|
+
ROUTING_SPECS = ('planner', 'final_reviewer')
|
|
45
|
+
# A key of profiles saved before forge 0.23 removed Fractal: still accepted, never applied or shown.
|
|
46
|
+
OLD_ROUTING_KEYS = ('fractal_planner',)
|
|
44
47
|
ROUTING_KEYS = POOLS + ROUTING_SPECS + ('escalate_after', 'escalate_effort')
|
|
45
48
|
THRESHOLDS = ('P0', 'P1', 'P2', 'P3', 'none')
|
|
46
49
|
FAST_ROLES = ('dwarf', 'qa', 'planner', 'review')
|
|
@@ -207,6 +210,8 @@ def _validate_routing(routing, out: list) -> None:
|
|
|
207
210
|
return
|
|
208
211
|
for key, value in routing.items():
|
|
209
212
|
path = f'routing.{key}'
|
|
213
|
+
if key in OLD_ROUTING_KEYS:
|
|
214
|
+
continue
|
|
210
215
|
if key not in ROUTING_KEYS:
|
|
211
216
|
out.append(f'{path}: unknown key (known: {", ".join(ROUTING_KEYS)})')
|
|
212
217
|
elif key in POOLS:
|
|
@@ -371,7 +376,7 @@ def from_plan(plan_dir) -> dict:
|
|
|
371
376
|
plan = Path(plan_dir)
|
|
372
377
|
routing: dict = {}
|
|
373
378
|
policy: dict = {}
|
|
374
|
-
for key, name in (('dwarf',
|
|
379
|
+
for key, name in (('dwarf', forge_legacy.pools_path(plan).name), ('qa', 'qa-routing.json')):
|
|
375
380
|
pool = _pool(plan, name)
|
|
376
381
|
if pool:
|
|
377
382
|
routing[key] = pool
|
|
@@ -466,6 +471,8 @@ def flat(body) -> dict:
|
|
|
466
471
|
return out
|
|
467
472
|
routing, policy = body.get('routing'), body.get('policy')
|
|
468
473
|
for key, value in (routing.items() if isinstance(routing, dict) else ()):
|
|
474
|
+
if key in OLD_ROUTING_KEYS:
|
|
475
|
+
continue
|
|
469
476
|
if key in POOLS and isinstance(value, dict):
|
|
470
477
|
for tier, specs in value.items():
|
|
471
478
|
out[f'routing.{key}.{tier}'] = specs
|
|
@@ -731,10 +738,7 @@ def freeze_plan(plan: Path, repo, name, none, given, check_only=False, validate_
|
|
|
731
738
|
|
|
732
739
|
|
|
733
740
|
SOLO_GIVEN = {'dwarf': None, 'qa': None, 'qa_threshold': 'policy.qa_threshold',
|
|
734
|
-
'timeout': 'policy.timeout', 'fast': 'policy.fast'
|
|
735
|
-
'fractal-planner': 'routing.fractal_planner',
|
|
736
|
-
'dwarf-low': 'routing.dwarf.low', 'dwarf-medium': 'routing.dwarf.medium',
|
|
737
|
-
'dwarf-high': 'routing.dwarf.high'}
|
|
741
|
+
'timeout': 'policy.timeout', 'fast': 'policy.fast'}
|
|
738
742
|
|
|
739
743
|
|
|
740
744
|
def _first(body, pool):
|
|
@@ -749,7 +753,7 @@ def _first(body, pool):
|
|
|
749
753
|
|
|
750
754
|
def solo_profile(run: Path, repo, name, none, given, use_frozen, write, validate_it=True) -> list:
|
|
751
755
|
"""The solo run's values from a profile, as `key<TAB>value` lines; writes the frozen copy
|
|
752
|
-
when `write`. Keys: dwarf, qa, qa_threshold, timeout, fast,
|
|
756
|
+
when `write`. Keys: dwarf, qa, qa_threshold, timeout, fast, line."""
|
|
753
757
|
frozen_path = run / FROZEN
|
|
754
758
|
action, chosen = _choose(repo, name, none, frozen_path, use_frozen, validate_it)
|
|
755
759
|
if action == 'remove':
|
|
@@ -785,13 +789,6 @@ def solo_profile(run: Path, repo, name, none, given, use_frozen, write, validate
|
|
|
785
789
|
out.append(f'timeout\t{keys["policy.timeout"]}')
|
|
786
790
|
if 'fast' not in given and isinstance(keys.get('policy.fast'), list):
|
|
787
791
|
out.append(f'fast\t{_fast_roles(keys["policy.fast"], SOLO_FAST_ROLES)}')
|
|
788
|
-
for tier in ('low', 'medium', 'high'):
|
|
789
|
-
specs = keys.get(f'routing.dwarf.{tier}')
|
|
790
|
-
if f'dwarf-{tier}' not in given and isinstance(specs, list) and specs:
|
|
791
|
-
out.append(f'pool.{tier}\t{_list(specs)}')
|
|
792
|
-
planner = keys.get('routing.fractal_planner')
|
|
793
|
-
if 'fractal-planner' not in given and isinstance(planner, str) and planner:
|
|
794
|
-
out.append(f'fractal_planner\t{planner}')
|
|
795
792
|
out.append(f'line\t{table_line(shown)}')
|
|
796
793
|
out.append(f'decide\t{frozen_decide(json.dumps(record)) or ""}')
|
|
797
794
|
if write and action == 'new':
|