@giamme/forge 0.15.0 → 0.17.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 +48 -0
- package/VERSION +1 -1
- package/docs/artifacts.md +1 -1
- package/docs/commands.md +14 -3
- package/docs/dataset.md +8 -0
- package/docs/forge-ui.md +14 -0
- package/docs/memory.md +22 -0
- package/docs/reviews.md +22 -1
- package/forge +11 -0
- package/package.json +1 -1
- package/references/dataset.md +129 -7
- package/references/decision-models.md +15 -2
- package/references/decompose.md +95 -13
- package/references/harnesses.md +4 -1
- package/references/planning.md +3 -2
- package/references/solo.md +5 -1
- package/references/ui.md +10 -1
- package/scripts/forge-artifact.sh +53 -0
- package/scripts/forge-contract.py +107 -9
- package/scripts/forge-control.py +0 -2
- package/scripts/forge-dispatch.sh +28 -12
- package/scripts/forge-fail-first.py +3 -1
- package/scripts/forge-guard.py +247 -8
- package/scripts/forge-issues.py +16 -3
- package/scripts/forge-ledger.py +3 -1
- package/scripts/forge-lib-adopt.sh +266 -0
- package/scripts/forge-lib-attribute.sh +10 -2
- package/scripts/forge-lib-plans.sh +16 -4
- package/scripts/forge-lib-review.sh +8 -2
- package/scripts/forge-lib-task.sh +19 -5
- package/scripts/forge-memory.sh +41 -4
- package/scripts/forge-metrics.sh +29 -0
- package/scripts/forge-parallel.sh +99 -14
- package/scripts/forge-plan-check.py +25 -2
- package/scripts/forge-planner.py +20 -6
- package/scripts/forge-route.py +16 -2
- package/scripts/forge-runs-rm.py +23 -7
- package/scripts/forge-runtime.py +25 -2
- package/scripts/forge-schedule.py +5 -2
- package/scripts/forge-shadow.py +30 -9
- package/scripts/forge-solo.sh +6 -0
- package/scripts/forge-sweep.py +25 -10
- package/scripts/forge_dataset/cli.py +99 -0
- package/scripts/forge_dataset/export.py +1 -0
- package/scripts/forge_dataset/facts.py +278 -0
- package/scripts/forge_dataset/harvest.py +27 -3
- package/scripts/forge_dataset/history.py +126 -0
- package/scripts/forge_dataset/outcomes.py +206 -58
- package/scripts/forge_dataset/pairs.py +174 -0
- package/scripts/forge_dataset/risk.py +108 -0
- package/scripts/forge_dataset/tiers.py +427 -0
- package/scripts/forge_dataset/worktrees.py +95 -0
- package/scripts/forge_decide/cli.py +23 -2
- package/scripts/forge_decide/labels.py +30 -6
- package/scripts/forge_decide/replay.py +10 -4
- 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 +92 -6
- package/ui/forge_ui/__init__.py +14 -1
- package/ui/forge_ui/__main__.py +1 -1
- package/ui/forge_ui/control.py +77 -0
- package/ui/forge_ui/export.py +9 -2
- package/ui/forge_ui/findings.py +11 -2
- package/ui/forge_ui/projects.py +571 -0
- package/ui/forge_ui/reader.py +96 -9
- package/ui/forge_ui/server.py +8 -0
- package/ui/forge_ui/static/app.js +105 -22
- 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 +9 -5
- package/ui/forge_ui/static/files.js +1 -1
- package/ui/forge_ui/static/index.html +5 -1
- package/ui/forge_ui/static/panel.js +69 -2
- package/ui/forge_ui/static/projectsview.js +372 -0
- package/ui/forge_ui/static/settings.js +136 -4
- package/ui/forge_ui/static/style.css +94 -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
|
@@ -96,7 +96,8 @@ def _newest_runs(events, n: int) -> set:
|
|
|
96
96
|
return set(sorted(first, key=lambda run: (first[run], str(run)), reverse=True)[:n])
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
def plan(site: str, provider: str, model: str, spec: dict, *, runs: int | None = None, store=None
|
|
99
|
+
def plan(site: str, provider: str, model: str, spec: dict, *, runs: int | None = None, store=None,
|
|
100
|
+
variant: str | None = None) -> Plan:
|
|
100
101
|
"""The labelled live requests of `site` (newest `runs` dataset runs only, when given), less
|
|
101
102
|
those whose own repo has the privacy floor, and which of them the replay file answers."""
|
|
102
103
|
store = store if store is not None else labels._open_store()
|
|
@@ -106,7 +107,7 @@ def plan(site: str, provider: str, model: str, spec: dict, *, runs: int | None =
|
|
|
106
107
|
usage = {event['d'].get('key'): event['d'].get('usage') for event, _body in stored}
|
|
107
108
|
keep = _newest_runs([event for event, _body in stored], runs) if runs else None
|
|
108
109
|
floors = {}
|
|
109
|
-
for row in labels.collect(site, store=store, runs=keep):
|
|
110
|
+
for row in labels.collect(site, store=store, runs=keep, variant=variant):
|
|
110
111
|
path = store.repo_paths.get(row['repo'])
|
|
111
112
|
# No recorded path, no floor: privacy_floor(None) would read the working directory's.
|
|
112
113
|
if path not in floors:
|
|
@@ -250,7 +251,7 @@ def evaluate(plan_: Plan, *, seed: int = 7, margin: float = 0.02) -> dict:
|
|
|
250
251
|
threshold = (forge_jev.threshold(record.threshold, site=plan_.site, model=plan_.model)
|
|
251
252
|
if record.threshold else None)
|
|
252
253
|
if threshold is not None and record.invert:
|
|
253
|
-
threshold = 1.0 - threshold
|
|
254
|
+
threshold = round(1.0 - threshold, 9) # 1 - 0.55 is 0.44999999999999996
|
|
254
255
|
answered_pairs = [(r['replay'], r['label']) for r in judged if r['replay'] is not None]
|
|
255
256
|
precision = (metrics.precision_at(answered_pairs, threshold) if threshold is not None
|
|
256
257
|
else dict(precision=None, recall=None, flagged=None))
|
|
@@ -343,7 +344,12 @@ def render(result: dict) -> str:
|
|
|
343
344
|
+ ('-' if ci is None else f'[{ci[0]:.3f}, {ci[1]:.3f}]') + f" (margin {result['margin']})",
|
|
344
345
|
]
|
|
345
346
|
if result['threshold'] is not None:
|
|
346
|
-
|
|
347
|
+
record = sites.site(result['site'])
|
|
348
|
+
cut = result['threshold']
|
|
349
|
+
# An inverted site's config value is on the other scale: show it as configured, and the cut.
|
|
350
|
+
at = (f"{result['threshold_name']} {round(1.0 - cut, 9):g} (inverted: a score at or above {cut:g})"
|
|
351
|
+
if record is not None and record.invert else f"{result['threshold_name']} {cut:g}")
|
|
352
|
+
lines.append(f" at {at}: precision "
|
|
347
353
|
f"{_number(result['precision'])}, recall {_number(result['recall'])}, "
|
|
348
354
|
f"{result['flagged']} flagged (floor {_number(result['floor'], 2)})")
|
|
349
355
|
lines += ['', ('PASSES: ' if result['passes'] else 'does not pass: ') + result['reason']]
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""`forge-memory.sh learnings <repo> --json`: every learning in a repo's ledger and its state (#126).
|
|
3
|
+
|
|
4
|
+
forge-memory.sh runs its own `rebuild` into a scratch dir first, with MEMORY_DROPS recording what it dropped
|
|
5
|
+
and why; this reads the ledger, that rebuilt memory and the drops, and says per learning what the rebuild did,
|
|
6
|
+
so the state shown is the one forge's bash decided, never a second implementation of it:
|
|
7
|
+
|
|
8
|
+
in_memory the rebuilt memory.md has it
|
|
9
|
+
waiting a finding seen in one run only: it needs a second run to be promoted
|
|
10
|
+
stale its [anchor] path no longer exists in the repo
|
|
11
|
+
capped trimmed by the memory cap (FORGE_MEMORY_MAX_LINES / MAX_BYTES)
|
|
12
|
+
muted every row of it was marked not injectable (Jev's curation)
|
|
13
|
+
|
|
14
|
+
A learning is a (category, key) group, as rebuild groups the ledger: `count` is the number of distinct runs
|
|
15
|
+
it appeared in, `text` the latest wording. `memory` is the repo's current .forge/memory.md by section, with
|
|
16
|
+
the roles each section reaches; `rebuilt_differs` says the current file is not what a rebuild makes now (an
|
|
17
|
+
older forge wrote it, or a `prune` asked Jev to drop facts). Stdlib only.
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import re
|
|
24
|
+
import sys
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
SECTIONS = (('verify', 'Verify', ('planner', 'dwarf')),
|
|
28
|
+
('trap', 'Known traps', ('planner', 'dwarf', 'qa')),
|
|
29
|
+
('finding', 'Recurring QA findings', ('planner', 'dwarf', 'qa')))
|
|
30
|
+
_TITLE = {'## ' + title: (cat, roles) for cat, title, roles in SECTIONS}
|
|
31
|
+
_FACT = re.compile(r'^- (?:([0-9]+)x: )?(.*)$')
|
|
32
|
+
_MAX_READ = 32 << 20
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _read(path):
|
|
36
|
+
try:
|
|
37
|
+
p = Path(path)
|
|
38
|
+
if not p.is_file() or p.stat().st_size > _MAX_READ:
|
|
39
|
+
return None
|
|
40
|
+
return p.read_text(encoding='utf-8', errors='replace')
|
|
41
|
+
except OSError:
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def parse_memory(text):
|
|
46
|
+
"""[{category, title, roles, lines: [{text, count}]}] of a memory.md, in file order."""
|
|
47
|
+
out, current = [], None
|
|
48
|
+
for line in (text or '').splitlines():
|
|
49
|
+
if line.startswith('## '):
|
|
50
|
+
found = _TITLE.get(line.strip())
|
|
51
|
+
current = None
|
|
52
|
+
if found:
|
|
53
|
+
current = dict(category=found[0], title=line[3:].strip(), roles=list(found[1]), lines=[])
|
|
54
|
+
out.append(current)
|
|
55
|
+
continue
|
|
56
|
+
fact = _FACT.match(line)
|
|
57
|
+
if fact and current is not None:
|
|
58
|
+
current['lines'].append(dict(text=fact.group(2), count=int(fact.group(1)) if fact.group(1) else None))
|
|
59
|
+
return out
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def ledger_groups(text):
|
|
63
|
+
"""{(category, key): group} as rebuild groups the ledger, plus every learning row."""
|
|
64
|
+
groups = {}
|
|
65
|
+
for line in (text or '').splitlines():
|
|
66
|
+
if not line or line.startswith('#'):
|
|
67
|
+
continue
|
|
68
|
+
cols = line.split('\t')
|
|
69
|
+
if len(cols) < 9:
|
|
70
|
+
continue
|
|
71
|
+
ts, run, task, role, model, verdict, cat, key, txt = cols[:9]
|
|
72
|
+
if cat == '-' or key == '-':
|
|
73
|
+
continue # a dispatch that emitted no learning
|
|
74
|
+
injectable = not (len(cols) >= 11 and cols[10] == '0')
|
|
75
|
+
g = groups.setdefault((cat, key), dict(category=cat, key=key, rows=[], runs=set(), last_ts=None, text=None,
|
|
76
|
+
any_injectable=False))
|
|
77
|
+
g['rows'].append(dict(ts=ts, run_id=run, task=task, role=role, model=model, verdict=verdict, text=txt,
|
|
78
|
+
injectable=injectable))
|
|
79
|
+
if injectable:
|
|
80
|
+
g['any_injectable'] = True
|
|
81
|
+
g['runs'].add(run)
|
|
82
|
+
# awk's `ts >= lastts[k]` on strings: the later row of two with the same time wins
|
|
83
|
+
if g['last_ts'] is None or ts >= g['last_ts']:
|
|
84
|
+
g['last_ts'], g['text'] = ts, txt
|
|
85
|
+
return groups
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def drops_of(text):
|
|
89
|
+
"""{(reason, category or '-', text)} of rebuild's MEMORY_DROPS rows; cap rows hold the whole '- ...' line."""
|
|
90
|
+
out = set()
|
|
91
|
+
for line in (text or '').splitlines():
|
|
92
|
+
reason, _, rest = line.partition('\t')
|
|
93
|
+
cat, _, fact = rest.partition('\t')
|
|
94
|
+
if reason == 'cap':
|
|
95
|
+
m = _FACT.match(fact)
|
|
96
|
+
fact = m.group(2) if m else fact
|
|
97
|
+
out.add((reason, cat, fact))
|
|
98
|
+
return out
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def classify(groups, rebuilt, drops):
|
|
102
|
+
kept = {(s['category'], line['text']) for s in rebuilt for line in s['lines']}
|
|
103
|
+
capped = {fact for reason, _cat, fact in drops if reason == 'cap'}
|
|
104
|
+
stale = {(cat, fact) for reason, cat, fact in drops if reason in ('anchor_missing', 'jev_stale')}
|
|
105
|
+
out = []
|
|
106
|
+
for (cat, key), g in groups.items():
|
|
107
|
+
if not g['any_injectable']:
|
|
108
|
+
state, text, count = 'muted', g['rows'][-1]['text'], 0
|
|
109
|
+
else:
|
|
110
|
+
text, count = g['text'], len(g['runs'])
|
|
111
|
+
if (cat, text) in kept:
|
|
112
|
+
state = 'in_memory'
|
|
113
|
+
elif (cat, text) in stale:
|
|
114
|
+
state = 'stale'
|
|
115
|
+
elif text in capped:
|
|
116
|
+
state = 'capped'
|
|
117
|
+
elif cat == 'finding' and count < 2:
|
|
118
|
+
state = 'waiting'
|
|
119
|
+
else:
|
|
120
|
+
state = 'dropped' # not reached by today's rebuild; kept honest if it changes
|
|
121
|
+
rows = g['rows']
|
|
122
|
+
out.append(dict(category=cat, key=key, text=text, count=count, state=state,
|
|
123
|
+
first=min(r['ts'] for r in rows), last=max(r['ts'] for r in rows), rows=rows))
|
|
124
|
+
out.sort(key=lambda r: (r['last'], r['category'], r['key']), reverse=True)
|
|
125
|
+
return out
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def build(repo, ledger, memory, rebuilt, drops, max_lines, max_bytes, memory_off):
|
|
129
|
+
ledger_text, current, made = _read(ledger), _read(memory), _read(rebuilt)
|
|
130
|
+
groups = ledger_groups(ledger_text)
|
|
131
|
+
rebuilt_sections = parse_memory(made)
|
|
132
|
+
return dict(repo=repo, ledger=ledger_text is not None, memory_off=memory_off, max_lines=max_lines,
|
|
133
|
+
max_bytes=max_bytes, memory=parse_memory(current) if current is not None else None,
|
|
134
|
+
rebuilt_differs=(current or '') != (made or ''),
|
|
135
|
+
learnings=classify(groups, rebuilt_sections, drops_of(_read(drops))))
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def main(argv=None):
|
|
139
|
+
p = argparse.ArgumentParser(prog='forge-memory.sh learnings')
|
|
140
|
+
for name in ('repo', 'ledger', 'memory', 'rebuilt', 'drops'):
|
|
141
|
+
p.add_argument('--' + name, required=True)
|
|
142
|
+
p.add_argument('--max-lines', type=int, required=True)
|
|
143
|
+
p.add_argument('--max-bytes', type=int, required=True)
|
|
144
|
+
p.add_argument('--memory-off', choices=('0', '1'), default='0')
|
|
145
|
+
a = p.parse_args(argv)
|
|
146
|
+
json.dump(build(a.repo, a.ledger, a.memory, a.rebuilt, a.drops, a.max_lines, a.max_bytes, a.memory_off == '1'),
|
|
147
|
+
sys.stdout, sort_keys=True)
|
|
148
|
+
sys.stdout.write('\n')
|
|
149
|
+
return 0
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == '__main__':
|
|
153
|
+
sys.exit(main())
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Which worktrees under `.forge-worktrees` are forge's, and what kind each is.
|
|
2
|
+
|
|
3
|
+
One rule for `forge runs rm` (what it may remove) and forge-ui's Worktrees screen (what it offers to
|
|
4
|
+
remove), so the two cannot disagree (#125).
|
|
5
|
+
|
|
6
|
+
forge-parallel.sh puts a run's worktrees in `<checkout>/../.forge-worktrees/<run id>/`, derived with a
|
|
7
|
+
logical `cd`, never read from the run's `wt_root` file. A worktree there is the run's when:
|
|
8
|
+
|
|
9
|
+
task it has the branch forge/<run id>/<task> checked out, for a task of the run
|
|
10
|
+
integration it has the branch forge/<run id>-integration checked out
|
|
11
|
+
candidate it is detached, directly in the run's folder, and named `_candidate-<n>` (integrate's
|
|
12
|
+
scratch worktree, left behind when integrate stopped)
|
|
13
|
+
attribute it is detached, directly in the run's folder, and named `_attribute` or
|
|
14
|
+
`_attribute-<n>` (the culprit search's scratch worktree), and no task has that name
|
|
15
|
+
|
|
16
|
+
Anything else there, and any worktree of the run's branches outside that folder, is not forge's.
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import os
|
|
21
|
+
import re
|
|
22
|
+
|
|
23
|
+
RUN_ID = re.compile(r'[A-Za-z0-9][A-Za-z0-9._-]{0,127}')
|
|
24
|
+
_SCRATCH = (('candidate', re.compile(r'_candidate-[0-9]+')), ('attribute', re.compile(r'_attribute(?:-[0-9]+)?')))
|
|
25
|
+
KINDS = ('task', 'integration', 'candidate', 'attribute')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def contains(parent, child):
|
|
29
|
+
"""True when `child` is `parent` or inside it (both real paths)."""
|
|
30
|
+
parent = parent.rstrip(os.sep) or os.sep
|
|
31
|
+
return child == parent or child.startswith(parent + os.sep)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def wt_root(repo, run_id):
|
|
35
|
+
"""The run's worktree folder, as forge-parallel.sh derives it: `$(cd "$REPO/.." && pwd)/.forge-worktrees/<run id>`."""
|
|
36
|
+
return os.path.realpath(os.path.join(os.path.normpath(os.path.join(repo, '..')), '.forge-worktrees', run_id))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def owner(path, branch, run_id, tasks, root):
|
|
40
|
+
"""The kind of forge worktree at `path` (one of KINDS), or None when it is not the run's.
|
|
41
|
+
|
|
42
|
+
`branch` is the full ref git lists (refs/heads/...), or None for a detached worktree; `tasks` the run's
|
|
43
|
+
task ids; `root` the run's worktree folder (`wt_root`).
|
|
44
|
+
"""
|
|
45
|
+
real = os.path.realpath(path)
|
|
46
|
+
if real == root or not contains(root, real):
|
|
47
|
+
return None
|
|
48
|
+
if branch == 'refs/heads/forge/%s-integration' % run_id:
|
|
49
|
+
return 'integration'
|
|
50
|
+
prefix = 'refs/heads/forge/%s/' % run_id
|
|
51
|
+
if isinstance(branch, str) and branch.startswith(prefix) and branch[len(prefix):] in set(tasks):
|
|
52
|
+
return 'task'
|
|
53
|
+
name = os.path.basename(real)
|
|
54
|
+
if branch is None and os.path.dirname(real) == root and name not in set(tasks):
|
|
55
|
+
for kind, pattern in _SCRATCH:
|
|
56
|
+
if pattern.fullmatch(name):
|
|
57
|
+
return kind
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def parse_porcelain(out, z=True):
|
|
62
|
+
"""`git worktree list --porcelain [-z]` output (text) as a list of dicts:
|
|
63
|
+
{path, head, branch (full ref or None), detached, bare, locked (reason or None), prunable (reason or None)}.
|
|
64
|
+
|
|
65
|
+
`locked` and `prunable` are '' when git gave no reason. With `z` a path may hold a newline; without it
|
|
66
|
+
such a path is split and its record is malformed, so that output is only for a git too old for -z.
|
|
67
|
+
"""
|
|
68
|
+
found, current = [], None
|
|
69
|
+
fields = out.split('\0') if z else out.split('\n')
|
|
70
|
+
for field in fields:
|
|
71
|
+
if not field:
|
|
72
|
+
current = None
|
|
73
|
+
continue
|
|
74
|
+
key, _, value = field.partition(' ')
|
|
75
|
+
if key == 'worktree':
|
|
76
|
+
current = dict(path=value, head=None, branch=None, detached=False, bare=False, locked=None, prunable=None)
|
|
77
|
+
found.append(current)
|
|
78
|
+
elif current is None:
|
|
79
|
+
continue
|
|
80
|
+
elif key == 'HEAD':
|
|
81
|
+
current['head'] = value
|
|
82
|
+
elif key == 'branch':
|
|
83
|
+
current['branch'] = value
|
|
84
|
+
elif key in ('detached', 'bare'):
|
|
85
|
+
current[key] = True
|
|
86
|
+
elif key in ('locked', 'prunable'):
|
|
87
|
+
current[key] = value
|
|
88
|
+
return found
|
package/ui/README.md
CHANGED
|
@@ -239,6 +239,37 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
239
239
|
run cloud filtered to its runs.
|
|
240
240
|
|
|
241
241
|
<img src="docs/media/models.png" width="760" alt="The implementers table: tasks, first-attempt pass rate with its 95% interval, retries, escalations, timeouts, accepts, median model time and tokens per model.">
|
|
242
|
+
- **Projects (`#/projects`, `#/projects/<id>[/runs|/findings|/memories]`):** one row per repository
|
|
243
|
+
(its root, as the run cloud groups runs, with the same id): runs, runs live now, last activity, open
|
|
244
|
+
findings and memory lines, sorted by latest activity; a repository whose folder is gone stays listed,
|
|
245
|
+
and runs tied to it only by their path are marked. A project's page has three tabs. *Runs*: its runs,
|
|
246
|
+
with the checkout and branch as a column to filter on. *Findings*: every finding of every review of
|
|
247
|
+
every run (each attempt and round, final reviews, shadow reviews behind a toggle), with severity,
|
|
248
|
+
confidence, location, run, task, attempt, reviewer, date and status: `open`, `filed`, `fixed`, `swept`,
|
|
249
|
+
`dismissed` (from `forge issues`, offline) or `superseded` (a later review of the same task passed,
|
|
250
|
+
which does not say the finding was fixed). A finding repeated across rounds is one row with a count,
|
|
251
|
+
by `forge issues`' fingerprint. A row opens the diff at that finding; filing and dismissing stay on the
|
|
252
|
+
run's Open findings page. *Memories*: what `memory.md` gives models, by section and role, and every
|
|
253
|
+
learning in the ledger with its state from `forge memory learnings` (in memory, waiting for a second
|
|
254
|
+
run, stale, trimmed by the cap, curated out), from the root and each checkout that still exists, and
|
|
255
|
+
from the dataset for checkouts that are gone; when checkouts' files differ the tab says so and lets you
|
|
256
|
+
pick one. Each tab reads its endpoint when it opens, never on the poll; *Read again* reads everything
|
|
257
|
+
again. A run's header (its repository name) and each map district's heading link to the project.
|
|
258
|
+
- **Worktrees (`#/worktrees`, `#/worktrees/repo/<root>`, `#/worktrees/runs/<key>`):** every worktree forge
|
|
259
|
+
created, in any repository forge-ui knows (the runs it lists and the repositories in the dataset),
|
|
260
|
+
with its run, task, branch, whether that branch is merged, its last commit, when forge created and
|
|
261
|
+
removed it, and its size. Each row has a status: *in use* (its run is active), *uncommitted
|
|
262
|
+
changes*, *locked*, *needed by the run* (the `_integration` of a run not yet integrated), *failed
|
|
263
|
+
task*, *finished*, *missing on disk*, *not forge's* (it fails the ownership rule `forge runs rm`
|
|
264
|
+
uses), *unknown to git* (a folder no repository lists) and *removed*. Rows with a safe next step
|
|
265
|
+
show the command to copy: `git -C <path> status`, `git -C <repo> worktree remove <path>` (plus
|
|
266
|
+
`git branch -d` for a merged branch), or `git worktree prune`; never `--force`, and the page runs
|
|
267
|
+
nothing, so it works with `--read-only`. *Whole runs* gives each finished run's
|
|
268
|
+
`forge runs rm <run-dir> --worktrees --branches --dry-run`, which also deletes the run directory
|
|
269
|
+
after archiving it. Removed worktrees are complete from the release that records them (dataset
|
|
270
|
+
events `worktree_created` and `worktree_removed`); older ones are derived from run dirs and the
|
|
271
|
+
dataset, without dates. The screen reads `/api/worktrees` when it opens and every minute, never on
|
|
272
|
+
the page's poll; sizes fill in as they are measured. A run's header links to its worktrees.
|
|
242
273
|
- **Diffs (`…/tasks/<id>/diff[/<source>][/file/<path> | /finding/<id>]`, `…/final-review/<name>/diff[/finding/<id>]`):** a task's
|
|
243
274
|
`changes.diff`, its previous or committed diff, or exactly the diff one reviewer read (the last
|
|
244
275
|
diff in that review's prompt), picked from a row of sources with each review's verdict; a final
|
package/ui/docs/api.md
CHANGED
|
@@ -90,7 +90,7 @@ written), and the reader must never raise because of one.
|
|
|
90
90
|
| `fractal-selection.json` | `{"enabled": true, "run": "run-<20 hex>"}` (or `enabled: false`): the run's Fractal choice, see Fractal below |
|
|
91
91
|
| `tasks/<id>/route.jsonl` | one JSON object per line, one per routing decision: `at` (epoch), `task`, `tier`, `epsilon`, `candidates` (list of specs), `default` (spec), `chosen` (spec), `explored` (bool), `propensity` (probability the chosen spec had), `inputs` (object), `decision` (a short hash identifying the decision). Keep unknown fields |
|
|
92
92
|
| `tasks/<id>/route.explored` | exists when the task's route was an exploratory pick |
|
|
93
|
-
| `shadow/<id>/<attempt>-<k>/shadow.json` | JSON: `task`, `attempt`, `reviewed`, `primary`, `spec`, `pick`, `started`. A second, never-read review of attempt `<attempt>` |
|
|
93
|
+
| `shadow/<id>/<attempt>-<k>/shadow.json` | JSON: `task`, `attempt`, `reviewed`, `primary`, `spec`, `pick` (`other_family`, `same_model`, `same_family` or `control`: identical to the primary), `started`. A second, never-read review of attempt `<attempt>` |
|
|
94
94
|
| `shadow/<id>/<attempt>-<k>/shadow.status` | one word |
|
|
95
95
|
| `shadow/<id>/<attempt>-<k>/qa.last` | the shadow reviewer's final message, verdict as above |
|
|
96
96
|
| `shadow/<id>/<attempt>-<k>/attempts/qa-<uuid>/` | the shadow review's execution |
|
|
@@ -248,6 +248,8 @@ its last 20,000 behind a leading `…`. Their `truncated` lists the field names
|
|
|
248
248
|
| `GET /api/runs/<key>/tasks/<id>/diff[/<which>]` | `200 DiffDetail`; `<which>` is `current` (the default: `changes.diff`), `prev`, `committed` (plan tasks), `existing` (solo) |
|
|
249
249
|
| `GET /api/runs/<key>/executions/<qa-or-dwarf>/diff` | `200 DiffDetail` of the diff that review read (a dwarf: its attempt's primary review) |
|
|
250
250
|
| `GET /api/runs/<key>/final-reviews/<name>/diff` | `200 DiffDetail` |
|
|
251
|
+
| `GET /api/runs/<key>/adoptions/<name>` | `200 AdoptionDetail`; `<name>` is the `adopt-<e>-<p>` an `adoptions.tsv` row names: `{name, adoption, verdict, threshold, gate, started, ended, duration_s, qa_input, qa_last, known_issues, findings, tests, diff}` (`adoption` is its row in `RunDetail.adoptions`; `diff` says the range's diff is there) |
|
|
252
|
+
| `GET /api/runs/<key>/adoptions/<name>/diff` | `200 DiffDetail` of the range (`range.diff`, else the prompt's fence), the review's findings pinned; unavailable with a reason past the 400 KB inline limit |
|
|
251
253
|
| `GET /api/runs/<key>/files` | `200 Files` |
|
|
252
254
|
| `GET /api/runs/<key>/findings` | `200 RunFindings` |
|
|
253
255
|
| `GET /api/runs/<key>/executions/<qa-or-dwarf>/transcript` | `200 ExecutionTranscript` |
|
|
@@ -259,7 +261,7 @@ its last 20,000 behind a leading `…`. Their `truncated` lists the field names
|
|
|
259
261
|
| `GET /api/runs/<key>/verification/lanes/<lane>/log[/lines/<n>]` | `200 VerificationLog` of `verification.lane.<lane>.log` |
|
|
260
262
|
| `GET /api/runs/<key>/verification/lanes/<lane>/runs/<k>/log[/lines/<n>]` | `200 VerificationLog` of `verification.lane.<lane>.run-<k>.log` |
|
|
261
263
|
| `GET /api/models` | `200 Models` |
|
|
262
|
-
| `GET /api/health` | `200 {"app": "forge-ui", "version", "build", "pid", "controls": true\|false}`; `controls` is `false` in read-only mode |
|
|
264
|
+
| `GET /api/health` | `200 {"app": "forge-ui", "version", "build", "pid", "controls": true\|false}`; `version` is forge's own (the root `VERSION` file, read when this server started), `null` when that file cannot be read; `controls` is `false` in read-only mode |
|
|
263
265
|
| `GET /api/runs/<key>/controls` | `200` the `forge control show --json` object of a plan run (see Controls); `404` for a solo or unknown run |
|
|
264
266
|
| `POST /api/runs/<key>/controls` | change one control or pin; authenticated, see Controls (write endpoints) |
|
|
265
267
|
| `GET /api/runs/<key>/issues?scope=run\|repo&offline=0\|1&plausible=0\|1&dismissed=0\|1&only=fp,fp` | `200` the `forge issues --json` listing, run fresh on every request (no cache); see Controls (write endpoints) |
|
|
@@ -267,6 +269,11 @@ its last 20,000 behind a leading `…`. Their `truncated` lists the field names
|
|
|
267
269
|
| `POST /api/runs/<key>/issues/dismiss` | dismiss or (`undo`) restore findings; authenticated |
|
|
268
270
|
| `POST /api/runs/<key>/delete` | dry-run or delete a run with `forge runs rm`; authenticated, 900 s timeout; later requests for the key answer `404` |
|
|
269
271
|
| `GET /api/models/reviewers` | `200` the `forge dataset reviewers --json` report (how each reviewer's PASSed work held up); no parameters |
|
|
272
|
+
| `GET /api/projects` | `200 {projects: [ProjectRow]}`: one row per repository (see Projects) |
|
|
273
|
+
| `GET /api/projects/<id>` | `200 Project`, `404` for an unknown id |
|
|
274
|
+
| `GET /api/projects/<id>/findings[?refresh=1]` | `200 ProjectFindings`: every review's findings with their status |
|
|
275
|
+
| `GET /api/projects/<id>/memories[?refresh=1]` | `200 ProjectMemories`: what each checkout's memory gives models and every learning's state |
|
|
276
|
+
| `GET /api/worktrees[?refresh=1]` | `200 Worktrees`: every worktree forge created, with its status and the commands to remove it; cached 60 s (see Worktrees) |
|
|
270
277
|
| `GET /api/config?run=<key>` | `200` the `forge config show --json` of that run's repository root (see Config) |
|
|
271
278
|
| `POST /api/config` | set or unset one allowed key (`repo.verify`, `repo.setup`, `repo.verify-subset`, `decide.gate.<gate>`, `decide.gate.<gate>.provider`, `decide.gate.<gate>.model`); `jev.enabled` is gone; authenticated |
|
|
272
279
|
| `GET /api/config/profiles?run=<key>` | `200` every profile of that run's repository, each with its level, shadowed levels, default flag and body (see Profiles) |
|
|
@@ -417,6 +424,9 @@ Every RunSummary field, plus:
|
|
|
417
424
|
"ended": 1760622300.0}]},
|
|
418
425
|
"final_review": FinalReviewSummary,
|
|
419
426
|
"final_reviews": [FinalReviewSummary, ...],
|
|
427
|
+
"adoptions": [{"at": 1760621000.0, "base": "...", "tip": "...", "verdict": "PASS", "approved": false,
|
|
428
|
+
"spec": "opus", "review": "adopt-1760621000-7", "reason": "...",
|
|
429
|
+
"findings": FindingsSummary, "diff": true}],
|
|
420
430
|
"scheduler": {"live": true, "drained": false, "stopping": null, "max_parallel": 3,
|
|
421
431
|
"pauses": [{"scope": "model:codex/gpt-6", "class": "rate_limit", "harness": "codex", "model": "gpt-6",
|
|
422
432
|
"tasks": ["perf"], "cycle": 1, "until": 1760622130.0, "exhausted": false}]},
|
|
@@ -759,12 +769,18 @@ FindingsSummary is `null` when there is no text or no contract module.
|
|
|
759
769
|
```json
|
|
760
770
|
{"severity": "P1", "status": "CONFIRMED", "location": "src/x.py:12", "line": 7,
|
|
761
771
|
"summary": "- [P1][CONFIRMED] src/x.py:12 — first line, at most 240 characters",
|
|
772
|
+
"facts": {"reach": "realistic", "origin": "new", "evidence": "traced"},
|
|
762
773
|
"text": "the whole finding block"}
|
|
763
774
|
```
|
|
764
775
|
|
|
765
776
|
`status` is `CONFIRMED`, `PLAUSIBLE` or `UNSTATED`; `severity` may be `null`; `location` is the
|
|
766
777
|
first match of the contract's `_LOCATION` in the first line, or `null`; `line` is the
|
|
767
|
-
block's 1-based line in the reply. Lists of Findings keep the first 200.
|
|
778
|
+
block's 1-based line in the reply. Lists of Findings keep the first 200. `facts` is the
|
|
779
|
+
reviewer's `{reach=… origin=… evidence=…}` suffix (#119), cut from `summary`: `null` when the
|
|
780
|
+
finding has none, and a fact whose value is not one of its words is `null`. `reach` is `main`,
|
|
781
|
+
`realistic` or `unusual`, `origin` `new` or `existing`, `evidence` `ran`, `traced` or
|
|
782
|
+
`suspected`. They are recorded in shadow: nothing in forge decides on them. A diff's and a
|
|
783
|
+
RunFindings' Findings carry `facts` too.
|
|
768
784
|
|
|
769
785
|
## FinalReviewSummary
|
|
770
786
|
|
|
@@ -818,7 +834,8 @@ TaskDetail:
|
|
|
818
834
|
"known_issues": null, "dwarf_input": "...", "qa_input": "..."},
|
|
819
835
|
"gate": {...},
|
|
820
836
|
"reviews": [{"kind": "primary", "execution": "qa-...", "attempt": 1, "spec": "opus",
|
|
821
|
-
"verdict": "FAIL", "state": "done", "findings": [Finding, ...]
|
|
837
|
+
"verdict": "FAIL", "state": "done", "findings": [Finding, ...],
|
|
838
|
+
"tests": {"status": "could_not_run", "reason": "..."}}],
|
|
822
839
|
"truncated": [], "warnings": []}
|
|
823
840
|
```
|
|
824
841
|
|
|
@@ -827,7 +844,9 @@ TaskDetail:
|
|
|
827
844
|
`dwarf.input`, `qa.input`; the others are `null`). `reviews` lists each non-shadow `qa`
|
|
828
845
|
execution with the findings of its own `qa.last` copy (`null` until it is done); then the
|
|
829
846
|
task's current `qa.last` as a `primary` review with `execution` `null`, only when no
|
|
830
|
-
execution's copy is identical to it; then one `shadow` review per shadow dir.
|
|
847
|
+
execution's copy is identical to it; then one `shadow` review per shadow dir. `tests` is the
|
|
848
|
+
reply's `FORGE_TESTS` line: `status` `ran`, `not_needed`, `could_not_run` or `unclear` (it says
|
|
849
|
+
something else), and `reason` or `null`; `null` when the reply has none.
|
|
831
850
|
|
|
832
851
|
ExecutionDetail: the Execution, plus `resolved` (every `key=value` of `<role>.resolved`, or
|
|
833
852
|
`null`), `dataset` (`{trigger, parent, attempt_start, resume}` or `null`), `prompt` (the
|
|
@@ -839,7 +858,8 @@ solo run), `<task>/<attempt>-<k>`, the review name, or `null`), `truncated` and
|
|
|
839
858
|
|
|
840
859
|
FinalReviewDetail: the FinalReviewSummary, plus `meta` (every `review.meta` key),
|
|
841
860
|
`tasks_summary`, `qa_input`, `qa_last`, `known_issues` (texts or `null`), `findings` (a list
|
|
842
|
-
of Findings, in place of the summary), `truncated` and
|
|
861
|
+
of Findings, in place of the summary), `tests` (as on a TaskDetail review), `truncated` and
|
|
862
|
+
`warnings`.
|
|
843
863
|
|
|
844
864
|
## DiffDetail (`forge_ui/diffs.py`)
|
|
845
865
|
|
|
@@ -1473,6 +1493,72 @@ Runs `dataset reviewers --json` and answers with its object: `horizon_days`, `mi
|
|
|
1473
1493
|
request runs the CLI, and the page asks once per change of `/api/models`. Advisory: it feeds the
|
|
1474
1494
|
Reviewers table's Did not hold column and nothing else. Timeout 60 s.
|
|
1475
1495
|
|
|
1496
|
+
### `GET /api/projects` and `/api/projects/<id>[/findings|/memories]`
|
|
1497
|
+
|
|
1498
|
+
The Projects screen (`forge_ui/projects.py`). Read-only, so they answer in `--read-only` mode too, and
|
|
1499
|
+
none of them calls `gh`. A project is one repository root as `repos.py` resolves it; `<id>` is the run
|
|
1500
|
+
cloud's (cloudmodel.js `hashId`: FNV-1a over the root's UTF-16 code units, 8 hex digits).
|
|
1501
|
+
|
|
1502
|
+
```
|
|
1503
|
+
ProjectRow = {id, name, root, exists, runs, live, last, path_only (runs tied by path only), checkouts,
|
|
1504
|
+
memory_lines (lines of <root>/.forge/memory.md, null when absent), open_findings (not superseded)}
|
|
1505
|
+
Project = {id, name, root, exists, live, last, path_only, memory_off_runs,
|
|
1506
|
+
checkouts: [{path, exists, branch, runs, root}], runs: [RunSummary + identity_source, dataset_uid, no_memory]}
|
|
1507
|
+
ProjectFindings = {id, rows: [Finding], notes: [text], runs, dataset_runs, computed, available}
|
|
1508
|
+
Finding = {source: run|dataset, run (key or null), run_id, task, final_review (its dir name, 'final' from the
|
|
1509
|
+
dataset), attempt, kind: primary|shadow|final, reviewer, verdict, at, id, severity, confidence, location,
|
|
1510
|
+
summary, text, fp (forge issues' key, null when it cannot parse the line), count, occurrences: [{run,
|
|
1511
|
+
run_id, task, attempt, kind, reviewer, at, href}], status, fileable, origin, href (the diff at the finding)}
|
|
1512
|
+
ProjectMemories = {id, sources: [{path, root, branch, ok, ledger, memory, rebuilt_differs, max_lines}], differs,
|
|
1513
|
+
learnings: [{category, key, text, count, states: {source path: state}, rows, last, dataset_only}],
|
|
1514
|
+
notes, memory_off_runs, runs, computed}
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1517
|
+
Findings come from every review of every run dir (parsed by forge-contract.py through `findings.py`), and
|
|
1518
|
+
from `dataset history --json` for runs whose dir is gone (their base commit ties a run whose checkout is
|
|
1519
|
+
gone to the project, as `repos.py` does). `status` comes from one `issues <run> --json --offline --all-runs
|
|
1520
|
+
--include-plausible --include-dismissed` listing per project, matched by `forge issues`' own key, else
|
|
1521
|
+
`superseded` when a later review of the same task (or a later final review) passed, else `open`. Repeats
|
|
1522
|
+
within a task collapse by that key; a line it cannot parse is its own row. Memories run `memory learnings
|
|
1523
|
+
<checkout> --json` for the root and each checkout a run started in that still exists. A run's findings
|
|
1524
|
+
are cached by its `updated` time, the CLI's answers for 300 s; `refresh=1` reads everything again; any
|
|
1525
|
+
other parameter is a `400`.
|
|
1526
|
+
|
|
1527
|
+
### `GET /api/worktrees`
|
|
1528
|
+
|
|
1529
|
+
The Worktrees screen (`forge_ui/worktrees.py`). Read-only, so it answers in `--read-only` mode too.
|
|
1530
|
+
It runs `git worktree list --porcelain -z` in every repository forge-ui knows (the roots of the runs
|
|
1531
|
+
it lists, and the repositories `forge dataset worktrees --json` names), `git status` in each forge
|
|
1532
|
+
worktree on disk, one `git show` per repository for the last commits and one `for-each-ref --merged
|
|
1533
|
+
HEAD` for merged branches; it lists the folders under each `.forge-worktrees` that no repository
|
|
1534
|
+
lists, and adds the dataset's history through `dataset worktrees --json`. Who owns a worktree is
|
|
1535
|
+
forge's rule (`scripts/forge_worktrees.py`, the one `forge runs rm` uses). The answer is cached
|
|
1536
|
+
for 60 s per server; `refresh=1` reads everything again, any other parameter is a `400`. Sizes are
|
|
1537
|
+
walked in a background thread and are `null` until measured (`sizes_pending` counts the rest).
|
|
1538
|
+
|
|
1539
|
+
```
|
|
1540
|
+
Worktrees = {
|
|
1541
|
+
rows: [Row], truncated, runs: [{key, run_id, path, repo, active, command}], repos: [root],
|
|
1542
|
+
notes: [text], dataset: {enabled, since} | null (the CLI failed), computed (unix time),
|
|
1543
|
+
totals: {count, on_disk, bytes, by_status: {status: n}}, sizes_pending
|
|
1544
|
+
}
|
|
1545
|
+
Row = {
|
|
1546
|
+
path, repo (the repository's main working tree, or null), git_dir, run (run key or null),
|
|
1547
|
+
run_id, run_path, task, branch (null when detached), kind (task | integration | candidate |
|
|
1548
|
+
attribute | null), status, merged (branch merged into the repository's HEAD; null unknown),
|
|
1549
|
+
head, commit: {sha, time, subject} | null, created, removed (unix times or null), derived
|
|
1550
|
+
(true: from a run dir or the dataset, no dates), locked (git's reason, '' for none, null when
|
|
1551
|
+
not locked), size (bytes or null), note, commands: [{label, command}]
|
|
1552
|
+
}
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
`status` is one of `in_use`, `dirty`, `locked`, `needed`, `failed`, `finished`, `missing`,
|
|
1556
|
+
`foreign`, `unknown`, `removed`. Commands: `dirty` gets `git -C <path> status`; `failed` gets
|
|
1557
|
+
`git -C <repo> worktree remove <path>`; `finished` gets the same plus `git -C <repo> branch -d
|
|
1558
|
+
<branch>` when the branch is merged; `missing` gets `git -C <repo> worktree prune`; every other
|
|
1559
|
+
status gets none. Paths are quoted for the shell and no command has `--force`. `runs[].command` is
|
|
1560
|
+
`forge runs rm <run-dir> --worktrees --branches --dry-run`, null while the run is active.
|
|
1561
|
+
|
|
1476
1562
|
### `GET /api/config?run=<key>` and `POST /api/config`
|
|
1477
1563
|
|
|
1478
1564
|
The repository is the run's `repo_root` (see RunSummary) when that is an existing absolute directory,
|
package/ui/forge_ui/__init__.py
CHANGED
|
@@ -4,7 +4,20 @@ from __future__ import annotations
|
|
|
4
4
|
import hashlib
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# forge's own version: this package ships inside forge, and two numbers could only disagree. What a
|
|
8
|
+
# running server reports is what it started with, which an upgrade underneath it does not change.
|
|
9
|
+
VERSION_FILE = Path(__file__).resolve().parents[2] / 'VERSION'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def read_version(path=VERSION_FILE):
|
|
13
|
+
"""The first line of forge's VERSION file, or None when it cannot be read."""
|
|
14
|
+
try:
|
|
15
|
+
return Path(path).read_text(encoding='utf-8').split('\n', 1)[0].strip() or None
|
|
16
|
+
except (OSError, ValueError):
|
|
17
|
+
return None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
__version__ = read_version()
|
|
8
21
|
|
|
9
22
|
|
|
10
23
|
def build_id():
|
package/ui/forge_ui/__main__.py
CHANGED
|
@@ -38,7 +38,7 @@ def _parser():
|
|
|
38
38
|
parser.add_argument('--read-only', action='store_true',
|
|
39
39
|
help='answer no write at all (also FORGE_UI_READONLY=1); the page shows no controls')
|
|
40
40
|
parser.add_argument('--open', action='store_true', help='open the page in the browser once started')
|
|
41
|
-
parser.add_argument('--version', action='version', version=f'forge-ui {__version__}')
|
|
41
|
+
parser.add_argument('--version', action='version', version=f'forge-ui {__version__ or "unknown"}')
|
|
42
42
|
return parser
|
|
43
43
|
|
|
44
44
|
|
package/ui/forge_ui/control.py
CHANGED
|
@@ -784,6 +784,78 @@ def _reviewer_outcomes(ctx):
|
|
|
784
784
|
return ctx.call('dataset', 'reviewers', '--json')
|
|
785
785
|
|
|
786
786
|
|
|
787
|
+
def _project_call(ctx, *args):
|
|
788
|
+
status, body = ctx.call(*args)
|
|
789
|
+
return body if status == 200 else None
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
def _projects(ctx):
|
|
793
|
+
# The Projects screen (#126): forge_ui/projects.py, which reads run dirs here and the rest through the CLI.
|
|
794
|
+
from forge_ui import projects
|
|
795
|
+
ctx.route = 'projects'
|
|
796
|
+
try:
|
|
797
|
+
_query_params(ctx.query, ())
|
|
798
|
+
except BadBody as exc:
|
|
799
|
+
return _invalid(str(exc))
|
|
800
|
+
return 200, projects.screen(ctx.server).listing(ctx.server.catalog)
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
def _project(ctx):
|
|
804
|
+
from forge_ui import projects
|
|
805
|
+
ctx.route = 'project'
|
|
806
|
+
try:
|
|
807
|
+
_query_params(ctx.query, ())
|
|
808
|
+
except BadBody as exc:
|
|
809
|
+
return _invalid(str(exc))
|
|
810
|
+
found = projects.screen(ctx.server).detail(ctx.server.catalog, ctx.key)
|
|
811
|
+
return (404, {'error': 'not found'}) if found is None else (200, found)
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
def _project_findings(ctx):
|
|
815
|
+
from forge_ui import projects
|
|
816
|
+
ctx.route = 'project findings'
|
|
817
|
+
try:
|
|
818
|
+
refresh = _bit(_query_params(ctx.query, ('refresh',)), 'refresh')
|
|
819
|
+
except BadBody as exc:
|
|
820
|
+
return _invalid(str(exc))
|
|
821
|
+
# --offline: no gh call; the listing says which findings are dismissed, filed (as recorded) or swept.
|
|
822
|
+
found = projects.screen(ctx.server).findings(
|
|
823
|
+
ctx.server.catalog, ctx.key, lambda: _project_call(ctx, 'dataset', 'history', '--json'),
|
|
824
|
+
lambda path: _project_call(ctx, 'issues', path, '--json', '--offline', '--all-runs', '--include-plausible',
|
|
825
|
+
'--include-dismissed'), refresh=refresh)
|
|
826
|
+
return (404, {'error': 'not found'}) if found is None else (200, found)
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
def _project_memories(ctx):
|
|
830
|
+
from forge_ui import projects
|
|
831
|
+
ctx.route = 'project memories'
|
|
832
|
+
try:
|
|
833
|
+
refresh = _bit(_query_params(ctx.query, ('refresh',)), 'refresh')
|
|
834
|
+
except BadBody as exc:
|
|
835
|
+
return _invalid(str(exc))
|
|
836
|
+
found = projects.screen(ctx.server).memories(
|
|
837
|
+
ctx.server.catalog, ctx.key, lambda path: _project_call(ctx, 'memory', 'learnings', path, '--json'),
|
|
838
|
+
lambda: _project_call(ctx, 'dataset', 'history', '--json'), refresh=refresh)
|
|
839
|
+
return (404, {'error': 'not found'}) if found is None else (200, found)
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
def _worktrees(ctx):
|
|
843
|
+
# The Worktrees screen (#125): git and the run dirs, read here, plus the history `forge dataset worktrees`
|
|
844
|
+
# keeps, read through the CLI. Cached per server (worktrees.CACHE_S); ?refresh=1 reads everything again.
|
|
845
|
+
from forge_ui import worktrees
|
|
846
|
+
ctx.route = 'worktrees'
|
|
847
|
+
try:
|
|
848
|
+
params = _query_params(ctx.query, ('refresh',))
|
|
849
|
+
refresh = _bit(params, 'refresh')
|
|
850
|
+
except BadBody as exc:
|
|
851
|
+
return _invalid(str(exc))
|
|
852
|
+
|
|
853
|
+
def history():
|
|
854
|
+
status, body = ctx.call('dataset', 'worktrees', '--json')
|
|
855
|
+
return body if status == 200 else None
|
|
856
|
+
return 200, worktrees.screen(ctx.server).answer(ctx.server.catalog, history, refresh=refresh)
|
|
857
|
+
|
|
858
|
+
|
|
787
859
|
ROUTES = [
|
|
788
860
|
('GET', re.compile(r'/api/runs/([0-9a-f]{12})/controls'), _show),
|
|
789
861
|
('POST', re.compile(r'/api/runs/([0-9a-f]{12})/controls'), _change),
|
|
@@ -796,6 +868,11 @@ ROUTES = [
|
|
|
796
868
|
('GET', re.compile(r'/api/config()'), _config_get),
|
|
797
869
|
('POST', re.compile(r'/api/config()'), _config_set),
|
|
798
870
|
('GET', re.compile(r'/api/models/reviewers()'), _reviewer_outcomes),
|
|
871
|
+
('GET', re.compile(r'/api/worktrees()'), _worktrees),
|
|
872
|
+
('GET', re.compile(r'/api/projects()'), _projects),
|
|
873
|
+
('GET', re.compile(r'/api/projects/([0-9a-f]{8})'), _project),
|
|
874
|
+
('GET', re.compile(r'/api/projects/([0-9a-f]{8})/findings'), _project_findings),
|
|
875
|
+
('GET', re.compile(r'/api/projects/([0-9a-f]{8})/memories'), _project_memories),
|
|
799
876
|
]
|
|
800
877
|
|
|
801
878
|
|