@giamme/forge 0.17.0 → 0.19.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 +57 -0
- package/README.md +1 -0
- package/SKILL.md +32 -5
- package/VERSION +1 -1
- package/docs/artifacts.md +33 -1
- package/docs/commands.md +147 -16
- package/docs/dataset.md +5 -0
- package/docs/decomposed-runs.md +122 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +98 -8
- package/docs/memory.md +27 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/docs/safety.md +8 -0
- package/forge +44 -4
- package/package.json +2 -1
- package/references/dataset.md +39 -1
- package/references/decompose.md +737 -16
- package/references/harnesses.md +18 -3
- package/references/planning.md +43 -14
- package/references/solo.md +2 -1
- package/references/ui.md +56 -6
- package/registry.tsv +8 -3
- package/scripts/forge-artifact.sh +14 -0
- package/scripts/forge-brief.py +217 -0
- package/scripts/forge-compare.py +13 -2
- package/scripts/forge-config.py +176 -9
- package/scripts/forge-contract.py +246 -28
- package/scripts/forge-control.py +200 -15
- package/scripts/forge-dispatch.sh +48 -15
- package/scripts/forge-du.py +167 -0
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-lib-adopt.sh +1 -0
- package/scripts/forge-lib-group.sh +641 -0
- package/scripts/forge-lib-plans.sh +343 -4
- package/scripts/forge-lib-review.sh +29 -1
- package/scripts/forge-lib-task.sh +197 -4
- package/scripts/forge-memory.sh +245 -3
- package/scripts/forge-metrics.sh +7 -3
- package/scripts/forge-parallel-options.sh +4 -0
- package/scripts/forge-parallel.sh +1216 -41
- package/scripts/forge-planner.py +104 -8
- package/scripts/forge-prompt.py +120 -0
- package/scripts/forge-retro.py +115 -0
- package/scripts/forge-route.py +190 -12
- package/scripts/forge-runs-compact.py +443 -0
- package/scripts/forge-runs-rm.py +2 -0
- package/scripts/forge-runs.py +27 -8
- package/scripts/forge-schedule.py +633 -49
- package/scripts/forge-shadow.py +7 -1
- package/scripts/forge-solo.sh +4 -0
- package/scripts/forge-summarize.py +698 -0
- package/scripts/forge-ui-options.sh +10 -0
- package/scripts/forge-worktrees.py +243 -0
- package/scripts/forge_brief/__init__.py +831 -0
- package/scripts/forge_brief/answers.py +506 -0
- package/scripts/forge_brief/proposals.py +1630 -0
- package/scripts/forge_dataset/__init__.py +10 -0
- package/scripts/forge_dataset/efforts.py +4 -3
- package/scripts/forge_dataset/export.py +36 -10
- package/scripts/forge_dataset/facts.py +8 -4
- package/scripts/forge_dataset/forecast.py +8 -18
- package/scripts/forge_dataset/harvest.py +241 -12
- package/scripts/forge_dataset/history.py +13 -6
- package/scripts/forge_dataset/importer.py +65 -1
- package/scripts/forge_dataset/names.py +66 -0
- package/scripts/forge_dataset/reviewers.py +5 -2
- package/scripts/forge_dataset/risk.py +6 -3
- package/scripts/forge_dataset/routing.py +6 -1
- package/scripts/forge_decide/__init__.py +11 -1
- package/scripts/forge_groups/__init__.py +308 -0
- package/scripts/forge_groups/attribute.py +289 -0
- package/scripts/forge_groups/review.py +286 -0
- package/scripts/forge_locations.py +366 -0
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_registry.py +19 -0
- package/scripts/forge_retro/__init__.py +417 -0
- package/scripts/forge_retro/issues.py +1193 -0
- package/scripts/forge_retro/report.py +671 -0
- package/scripts/forge_side/__init__.py +482 -0
- package/scripts/forge_storage.py +515 -0
- package/ui/README.md +68 -8
- package/ui/docs/api.md +375 -31
- package/ui/forge_ui/control.py +451 -11
- package/ui/forge_ui/executions.py +8 -1
- package/ui/forge_ui/export.py +53 -7
- package/ui/forge_ui/groups.py +264 -0
- package/ui/forge_ui/links.py +337 -0
- package/ui/forge_ui/models.py +125 -10
- package/ui/forge_ui/projects.py +4 -1
- package/ui/forge_ui/reader.py +919 -45
- package/ui/forge_ui/server.py +4 -0
- package/ui/forge_ui/static/app.js +173 -11
- package/ui/forge_ui/static/briefview.js +605 -0
- package/ui/forge_ui/static/checksview.js +6 -2
- package/ui/forge_ui/static/controls.js +5 -0
- package/ui/forge_ui/static/diffview.js +86 -1
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +4 -0
- package/ui/forge_ui/static/panel.js +394 -8
- package/ui/forge_ui/static/projectsview.js +189 -10
- package/ui/forge_ui/static/runmodel.js +27 -4
- package/ui/forge_ui/static/storageview.js +352 -0
- package/ui/forge_ui/static/style.css +176 -6
- package/ui/forge_ui/static/worktreesview.js +235 -14
- package/ui/forge_ui/storage.py +150 -0
- package/ui/forge_ui/transcripts.py +35 -10
- package/ui/forge_ui/worktrees.py +154 -13
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
"""What forge keeps on disk, what can go, and taking it back (#139).
|
|
2
|
+
|
|
3
|
+
One set of rules for `forge du` (what it reports), `forge runs compact` (what it removes or
|
|
4
|
+
gzips), forge-ui's Disk screen and the storage policy at run start, so they cannot disagree.
|
|
5
|
+
|
|
6
|
+
A run dir holds, by what this module calls them:
|
|
7
|
+
|
|
8
|
+
snapshots review snapshots: a directory named `review` or `review-*` that holds a `.git`
|
|
9
|
+
directory and sits beside a `review.base` file (forge_review_snapshot writes
|
|
10
|
+
both). Task reviews (`tasks/<id>/review-<n>-<pid>`), final reviews
|
|
11
|
+
(`final-review-*/review-<pid>`), shadow reviews (`shadow/<task>/<n>-<k>/review-snapshot`),
|
|
12
|
+
adopt (`<dir>/review`) and solo runs (`review-<time>-<pid>`). Nothing reads one after
|
|
13
|
+
its review ends; since 0.18 each is removed then, so these are leftovers of older runs
|
|
14
|
+
or of a review stopped by a signal.
|
|
15
|
+
logs `*.log`, `*.jsonl` and their `.gz`. `compressible` lists the ones `compact --logs`
|
|
16
|
+
gzips: a dwarf's or reviewer's own log in its execution record,
|
|
17
|
+
`attempts/<role>-<32 hex>/<role>.log` (role dwarf or qa), of at least LOG_MIN bytes,
|
|
18
|
+
outside a Fractal tree. Those copies are written once, when the execution ends; the
|
|
19
|
+
log a running agent writes, and every log a retry reads, is the one in the task dir,
|
|
20
|
+
which is never touched. forge-ui reads the copy, plain or gzipped.
|
|
21
|
+
strays what forge does not create: a dependency directory (DEP_DIRS) or a `.git` outside a
|
|
22
|
+
snapshot, such as a dependency install someone ran by hand inside a run dir. Reported
|
|
23
|
+
with its size, never removed.
|
|
24
|
+
fractal Fractal's own workspaces (`.../nodes/<id>/product`), opt-in and managed by Fractal.
|
|
25
|
+
other everything else: prompts, diffs, verdicts, metrics, the run's own records.
|
|
26
|
+
|
|
27
|
+
Sizes are disk usage (allocated blocks, as `du` counts them), and a file with several hard links
|
|
28
|
+
counts once. Nothing here follows a symbolic link: a snapshot links the attempt's dependency
|
|
29
|
+
directories into itself, and those are the worktree's, not the run's.
|
|
30
|
+
"""
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import gzip
|
|
34
|
+
import json
|
|
35
|
+
import os
|
|
36
|
+
import re
|
|
37
|
+
import shutil
|
|
38
|
+
import stat
|
|
39
|
+
import time
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
|
|
42
|
+
DEP_DIRS = frozenset('node_modules bower_components .venv venv vendor .bundle Pods deps _build .dart_tool elm-stuff .build'.split())
|
|
43
|
+
LOG_MIN = 64 << 10 # a smaller log gains next to nothing from gzip
|
|
44
|
+
LOG_ROLES = ('dwarf', 'qa')
|
|
45
|
+
ATTEMPT_DIR = re.compile(r'(dwarf|qa)-[0-9a-f]{32}')
|
|
46
|
+
PART = '.gz.part' # a gzip being written; one left by an interrupted compact is removed
|
|
47
|
+
GB = 1 << 30
|
|
48
|
+
DEFAULT_WARN_GB = 20.0
|
|
49
|
+
COMPACT_MODES = ('auto', 'off')
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def usage(info) -> int:
|
|
53
|
+
"""Bytes a file takes on disk: its allocated blocks, else its size."""
|
|
54
|
+
blocks = getattr(info, 'st_blocks', None)
|
|
55
|
+
return blocks * 512 if blocks is not None else info.st_size
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _lstat(path):
|
|
59
|
+
try:
|
|
60
|
+
return os.lstat(path)
|
|
61
|
+
except OSError:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def is_snapshot(path) -> bool:
|
|
66
|
+
"""Whether `path` is a review snapshot by the rule above (never a link)."""
|
|
67
|
+
path = os.fspath(path)
|
|
68
|
+
name = os.path.basename(path.rstrip('/'))
|
|
69
|
+
if name != 'review' and not name.startswith('review-'):
|
|
70
|
+
return False
|
|
71
|
+
info, git = _lstat(path), _lstat(os.path.join(path, '.git'))
|
|
72
|
+
base = _lstat(os.path.join(os.path.dirname(path.rstrip('/')), 'review.base'))
|
|
73
|
+
return (info is not None and stat.S_ISDIR(info.st_mode) and git is not None and stat.S_ISDIR(git.st_mode)
|
|
74
|
+
and base is not None and stat.S_ISREG(base.st_mode))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def is_compressible_log(path, info=None) -> bool:
|
|
78
|
+
"""Whether `compact --logs` gzips this file (the rule above); `info` is its lstat when known."""
|
|
79
|
+
path = os.fspath(path)
|
|
80
|
+
parent = os.path.dirname(path)
|
|
81
|
+
match = ATTEMPT_DIR.fullmatch(os.path.basename(parent))
|
|
82
|
+
if not match or os.path.basename(path) != match.group(1) + '.log':
|
|
83
|
+
return False
|
|
84
|
+
if os.path.basename(os.path.dirname(parent)) != 'attempts' or 'nodes' in Path(parent).parts:
|
|
85
|
+
return False
|
|
86
|
+
info = info if info is not None else _lstat(path)
|
|
87
|
+
return info is not None and stat.S_ISREG(info.st_mode) and info.st_size >= LOG_MIN
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class _Seen:
|
|
91
|
+
"""Hard-linked files count once across one scan."""
|
|
92
|
+
|
|
93
|
+
def __init__(self):
|
|
94
|
+
self.inodes = set()
|
|
95
|
+
|
|
96
|
+
def first(self, info) -> bool:
|
|
97
|
+
if info.st_nlink <= 1:
|
|
98
|
+
return True
|
|
99
|
+
key = (info.st_dev, info.st_ino)
|
|
100
|
+
if key in self.inodes:
|
|
101
|
+
return False
|
|
102
|
+
self.inodes.add(key)
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def tree_usage(path, seen=None, deadline=None) -> tuple[int, bool]:
|
|
107
|
+
"""(disk usage of everything under `path`, complete). Stops at `deadline` (time.monotonic) with a lower bound."""
|
|
108
|
+
seen = seen or _Seen()
|
|
109
|
+
total, stack = 0, [os.fspath(path)]
|
|
110
|
+
while stack:
|
|
111
|
+
if deadline is not None and time.monotonic() > deadline:
|
|
112
|
+
return total, False
|
|
113
|
+
directory = stack.pop()
|
|
114
|
+
try:
|
|
115
|
+
with os.scandir(directory) as listing:
|
|
116
|
+
entries = list(listing)
|
|
117
|
+
except OSError:
|
|
118
|
+
continue
|
|
119
|
+
for entry in entries:
|
|
120
|
+
try:
|
|
121
|
+
info = entry.stat(follow_symlinks=False)
|
|
122
|
+
except OSError:
|
|
123
|
+
continue
|
|
124
|
+
if stat.S_ISDIR(info.st_mode):
|
|
125
|
+
stack.append(entry.path)
|
|
126
|
+
elif seen.first(info):
|
|
127
|
+
total += usage(info)
|
|
128
|
+
return total, True
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def scan(run_dir, deadline=None) -> dict:
|
|
132
|
+
"""What one run dir holds, by kind (see the module docstring). Paths in the answer are absolute.
|
|
133
|
+
|
|
134
|
+
{path, total, snapshots: {bytes, count, items: [{path, bytes}]},
|
|
135
|
+
logs: {bytes, gz_bytes, compressible_bytes, compressible: [{path, bytes, size}]},
|
|
136
|
+
strays: [{path, bytes, kind}], fractal, other, parts: [path], complete}
|
|
137
|
+
"""
|
|
138
|
+
root = os.path.realpath(os.fspath(run_dir))
|
|
139
|
+
seen = _Seen()
|
|
140
|
+
out = dict(path=root, total=0, snapshots=dict(bytes=0, count=0, items=[]),
|
|
141
|
+
logs=dict(bytes=0, gz_bytes=0, compressible_bytes=0, compressible=[]),
|
|
142
|
+
strays=[], fractal=0, other=0, parts=[], complete=True)
|
|
143
|
+
stack = [root]
|
|
144
|
+
while stack:
|
|
145
|
+
if deadline is not None and time.monotonic() > deadline:
|
|
146
|
+
out['complete'] = False
|
|
147
|
+
break
|
|
148
|
+
directory = stack.pop()
|
|
149
|
+
try:
|
|
150
|
+
with os.scandir(directory) as listing:
|
|
151
|
+
entries = list(listing)
|
|
152
|
+
except OSError:
|
|
153
|
+
continue
|
|
154
|
+
for entry in entries:
|
|
155
|
+
try:
|
|
156
|
+
info = entry.stat(follow_symlinks=False)
|
|
157
|
+
except OSError:
|
|
158
|
+
continue
|
|
159
|
+
if stat.S_ISDIR(info.st_mode):
|
|
160
|
+
if is_snapshot(entry.path):
|
|
161
|
+
size, done = tree_usage(entry.path, seen, deadline)
|
|
162
|
+
out['snapshots']['items'].append(dict(path=entry.path, bytes=size))
|
|
163
|
+
out['snapshots']['bytes'] += size
|
|
164
|
+
out['snapshots']['count'] += 1
|
|
165
|
+
out['complete'] = out['complete'] and done
|
|
166
|
+
elif entry.name == 'product' and 'nodes' in Path(directory).parts:
|
|
167
|
+
size, done = tree_usage(entry.path, seen, deadline)
|
|
168
|
+
out['fractal'] += size
|
|
169
|
+
out['complete'] = out['complete'] and done
|
|
170
|
+
elif entry.name in DEP_DIRS or entry.name == '.git':
|
|
171
|
+
size, done = tree_usage(entry.path, seen, deadline)
|
|
172
|
+
out['strays'].append(dict(path=entry.path, bytes=size,
|
|
173
|
+
kind='git' if entry.name == '.git' else 'dependencies'))
|
|
174
|
+
out['complete'] = out['complete'] and done
|
|
175
|
+
else:
|
|
176
|
+
stack.append(entry.path)
|
|
177
|
+
continue
|
|
178
|
+
if not seen.first(info):
|
|
179
|
+
continue
|
|
180
|
+
size = usage(info)
|
|
181
|
+
name = entry.name
|
|
182
|
+
if name.endswith(PART):
|
|
183
|
+
out['parts'].append(entry.path)
|
|
184
|
+
if name.endswith(('.log', '.jsonl')):
|
|
185
|
+
out['logs']['bytes'] += size
|
|
186
|
+
if is_compressible_log(entry.path, info):
|
|
187
|
+
out['logs']['compressible'].append(dict(path=entry.path, bytes=size, size=info.st_size))
|
|
188
|
+
out['logs']['compressible_bytes'] += size
|
|
189
|
+
elif name.endswith(('.log.gz', '.jsonl.gz')):
|
|
190
|
+
out['logs']['gz_bytes'] += size
|
|
191
|
+
else:
|
|
192
|
+
out['other'] += size
|
|
193
|
+
stray = sum(s['bytes'] for s in out['strays'])
|
|
194
|
+
out['total'] = (out['snapshots']['bytes'] + out['logs']['bytes'] + out['logs']['gz_bytes'] + stray
|
|
195
|
+
+ out['fractal'] + out['other'])
|
|
196
|
+
out['snapshots']['items'].sort(key=lambda s: s['path'])
|
|
197
|
+
out['strays'].sort(key=lambda s: -s['bytes'])
|
|
198
|
+
return out
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
GZIP_RATIO = 0.25 # what a dwarf's or reviewer's log shrinks to, measured on real runs
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def reclaimable(found: dict, logs: bool = True) -> int:
|
|
205
|
+
"""Bytes `compact` would take back: every snapshot, and (logs) an estimate for the compressible logs."""
|
|
206
|
+
estimate = int(found['logs']['compressible_bytes'] * (1 - GZIP_RATIO)) if logs else 0
|
|
207
|
+
return found['snapshots']['bytes'] + estimate
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# ---------------------------------------------------------------------------------- changing things
|
|
211
|
+
|
|
212
|
+
def remove_snapshot(path, run_dir) -> str | None:
|
|
213
|
+
"""Removes one review snapshot under `run_dir`. Returns None, or why it was not removed."""
|
|
214
|
+
path, root = os.fspath(path), os.path.realpath(os.fspath(run_dir))
|
|
215
|
+
real = os.path.realpath(path)
|
|
216
|
+
if real == root or not real.startswith(root.rstrip('/') + '/'):
|
|
217
|
+
return 'outside the run dir'
|
|
218
|
+
if not is_snapshot(path):
|
|
219
|
+
return 'no longer a review snapshot'
|
|
220
|
+
errors = []
|
|
221
|
+
shutil.rmtree(path, onerror=lambda _f, p, e: errors.append('%s: %s' % (p, e[1]))) # never follows a link
|
|
222
|
+
return ('; '.join(errors[:3])) if errors else None
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def compress_log(path) -> tuple[int, str | None]:
|
|
226
|
+
"""Gzips one log into `<log>.gz` with the same mode and times, then removes the plain file.
|
|
227
|
+
|
|
228
|
+
Returns (bytes taken back, None) or (0, why not). The plain file goes only once the gzip is
|
|
229
|
+
complete on disk and the log did not change meanwhile; a `.gz` already there is never replaced.
|
|
230
|
+
"""
|
|
231
|
+
path = os.fspath(path)
|
|
232
|
+
target, part = path + '.gz', path + PART
|
|
233
|
+
before = _lstat(path)
|
|
234
|
+
if before is None or not stat.S_ISREG(before.st_mode):
|
|
235
|
+
return 0, 'not a regular file'
|
|
236
|
+
if os.path.lexists(target):
|
|
237
|
+
return 0, target + ' exists'
|
|
238
|
+
if os.path.lexists(part):
|
|
239
|
+
try:
|
|
240
|
+
os.unlink(part)
|
|
241
|
+
except OSError as error:
|
|
242
|
+
return 0, 'cannot remove %s: %s' % (part, error.strerror or error)
|
|
243
|
+
try:
|
|
244
|
+
fd = os.open(part, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, stat.S_IMODE(before.st_mode))
|
|
245
|
+
with os.fdopen(fd, 'wb') as raw, open(path, 'rb') as source:
|
|
246
|
+
with gzip.GzipFile(filename=os.path.basename(path), mode='wb', fileobj=raw, compresslevel=6,
|
|
247
|
+
mtime=int(before.st_mtime)) as packed:
|
|
248
|
+
shutil.copyfileobj(source, packed, 1 << 20)
|
|
249
|
+
raw.flush()
|
|
250
|
+
os.fsync(raw.fileno())
|
|
251
|
+
os.utime(part, ns=(before.st_atime_ns, before.st_mtime_ns))
|
|
252
|
+
after = _lstat(path)
|
|
253
|
+
if after is None or (after.st_size, after.st_mtime_ns, after.st_ino) != (before.st_size, before.st_mtime_ns, before.st_ino):
|
|
254
|
+
os.unlink(part)
|
|
255
|
+
return 0, 'changed while it was being compressed'
|
|
256
|
+
os.link(part, target) # fails when a .gz appeared meanwhile: nothing is replaced
|
|
257
|
+
os.unlink(part)
|
|
258
|
+
packed_info = os.lstat(target)
|
|
259
|
+
os.unlink(path)
|
|
260
|
+
except OSError as error:
|
|
261
|
+
try:
|
|
262
|
+
os.unlink(part)
|
|
263
|
+
except OSError:
|
|
264
|
+
pass
|
|
265
|
+
return 0, error.strerror or str(error)
|
|
266
|
+
return max(0, usage(before) - usage(packed_info)), None
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def read_log(path, cap=None) -> bytes | None:
|
|
270
|
+
"""The bytes of a log, plain or gzipped (`.gz`), the last `cap` of them when given; None when unreadable."""
|
|
271
|
+
path = os.fspath(path)
|
|
272
|
+
try:
|
|
273
|
+
if path.endswith('.gz'):
|
|
274
|
+
with gzip.open(path, 'rb') as stream:
|
|
275
|
+
data = stream.read()
|
|
276
|
+
else:
|
|
277
|
+
with open(path, 'rb') as stream:
|
|
278
|
+
data = stream.read()
|
|
279
|
+
except (OSError, EOFError, gzip.BadGzipFile):
|
|
280
|
+
return None
|
|
281
|
+
return data[-cap:] if cap is not None and len(data) > cap else data
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
# ---------------------------------------------------------------------------------- policy and footprint
|
|
285
|
+
|
|
286
|
+
def settings(features: dict | None) -> dict:
|
|
287
|
+
"""{compact: auto|off, warn_gb: float|None} from the user `features` object (decide.json).
|
|
288
|
+
|
|
289
|
+
FORGE_STORAGE_COMPACT=off and FORGE_STORAGE_WARN_GB=off turn either off for one process.
|
|
290
|
+
"""
|
|
291
|
+
storage = (features or {}).get('storage')
|
|
292
|
+
storage = storage if isinstance(storage, dict) else {}
|
|
293
|
+
compact = storage.get('compact') if storage.get('compact') in COMPACT_MODES else 'auto'
|
|
294
|
+
warn = parse_gb(storage.get('warn_gb'), DEFAULT_WARN_GB)
|
|
295
|
+
if os.environ.get('FORGE_STORAGE_COMPACT', '').strip().lower() == 'off':
|
|
296
|
+
compact = 'off'
|
|
297
|
+
env_warn = os.environ.get('FORGE_STORAGE_WARN_GB', '').strip()
|
|
298
|
+
if env_warn:
|
|
299
|
+
warn = parse_gb(env_warn, warn)
|
|
300
|
+
return dict(compact=compact, warn_gb=warn)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def parse_gb(value, default):
|
|
304
|
+
"""A positive number of gigabytes, None for `off`, else `default`."""
|
|
305
|
+
if isinstance(value, str) and value.strip().lower() == 'off':
|
|
306
|
+
return None
|
|
307
|
+
try:
|
|
308
|
+
number = float(value)
|
|
309
|
+
except (TypeError, ValueError):
|
|
310
|
+
return default
|
|
311
|
+
return number if number > 0 and number == number and number != float('inf') else default
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def footprint_path(home: Path) -> Path:
|
|
315
|
+
return Path(home) / 'storage' / 'footprint.json'
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def load_footprints(home: Path) -> dict:
|
|
319
|
+
"""{repo real path: {bytes, runs, at}} as the last scan left it; {} when there is none."""
|
|
320
|
+
try:
|
|
321
|
+
data = json.loads(footprint_path(home).read_text(encoding='utf-8'))
|
|
322
|
+
except (OSError, ValueError):
|
|
323
|
+
return {}
|
|
324
|
+
return data if isinstance(data, dict) else {}
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def save_footprints(home: Path, updates: dict) -> None:
|
|
328
|
+
"""Merges {repo: {bytes, runs}} into the footprint file, stamped now. Never raises."""
|
|
329
|
+
try:
|
|
330
|
+
path = footprint_path(home)
|
|
331
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
332
|
+
data = load_footprints(home)
|
|
333
|
+
now = time.time()
|
|
334
|
+
for repo, entry in updates.items():
|
|
335
|
+
data[str(repo)] = dict(entry, at=now)
|
|
336
|
+
tmp = path.with_name('.footprint.%d.tmp' % os.getpid())
|
|
337
|
+
tmp.write_text(json.dumps(data, indent=1, sort_keys=True) + '\n', encoding='utf-8')
|
|
338
|
+
os.replace(tmp, path)
|
|
339
|
+
except OSError:
|
|
340
|
+
pass
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def size_text(count) -> str:
|
|
344
|
+
value = float(count or 0)
|
|
345
|
+
for unit in ('B', 'KB', 'MB', 'GB'):
|
|
346
|
+
if value < 1024 or unit == 'TB':
|
|
347
|
+
return ('%d %s' % (value, unit)) if unit == 'B' else ('%.1f %s' % (value, unit))
|
|
348
|
+
value /= 1024
|
|
349
|
+
return '%.1f TB' % value
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
# ---------------------------------------------------------------------------------- the whole report
|
|
353
|
+
|
|
354
|
+
def _scripts():
|
|
355
|
+
import sys
|
|
356
|
+
here = str(Path(__file__).resolve().parent)
|
|
357
|
+
if here not in sys.path:
|
|
358
|
+
sys.path.insert(0, here)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def _first_line(path) -> str | None:
|
|
362
|
+
try:
|
|
363
|
+
with open(path, 'rb') as stream:
|
|
364
|
+
line = stream.read(64 * 1024).decode('utf-8', 'replace').split('\n', 1)[0].strip()
|
|
365
|
+
except OSError:
|
|
366
|
+
return None
|
|
367
|
+
return line or None
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _matches(entry, repo_real) -> bool:
|
|
371
|
+
"""Whether a location entry belongs to the repository at `repo_real`: as its checkout or its main working tree."""
|
|
372
|
+
return repo_real in (entry.get('checkout'), entry.get('root'))
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def run_dirs(repo=None) -> list[tuple[str, str | None]]:
|
|
376
|
+
"""[(run dir, repo the run names)] for `repo` (a path) or, None, for every repo: what the run registry lists,
|
|
377
|
+
then the run dirs forge's location list (forge_locations.py) knows and the registry does not."""
|
|
378
|
+
_scripts()
|
|
379
|
+
import forge_locations
|
|
380
|
+
import forge_registry
|
|
381
|
+
files = [forge_registry.runs_registry(repo)] if repo is not None else sorted(forge_registry.registry_dir().glob('*.txt'))
|
|
382
|
+
found, seen = [], set()
|
|
383
|
+
for path in files:
|
|
384
|
+
try:
|
|
385
|
+
lines = path.read_text(encoding='utf-8', errors='replace').splitlines()
|
|
386
|
+
except OSError:
|
|
387
|
+
continue
|
|
388
|
+
for line in lines:
|
|
389
|
+
line = line.strip()
|
|
390
|
+
if not line or line.startswith('#') or not os.path.isabs(line) or not os.path.isdir(line):
|
|
391
|
+
continue
|
|
392
|
+
real = os.path.realpath(line)
|
|
393
|
+
if real in seen:
|
|
394
|
+
continue
|
|
395
|
+
seen.add(real)
|
|
396
|
+
named = _first_line(os.path.join(real, 'repo'))
|
|
397
|
+
found.append((real, os.path.realpath(named) if named and os.path.isabs(named) else None))
|
|
398
|
+
repo_real = os.path.realpath(repo) if repo is not None else None
|
|
399
|
+
for entry in forge_locations.entries('run'):
|
|
400
|
+
real = entry['path']
|
|
401
|
+
if real in seen or not os.path.isdir(real) or (repo_real and not _matches(entry, repo_real)):
|
|
402
|
+
continue
|
|
403
|
+
seen.add(real)
|
|
404
|
+
found.append((real, entry.get('checkout')))
|
|
405
|
+
return found
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def data_home_parts(home: Path, deadline=None) -> dict:
|
|
409
|
+
"""{path, bytes, parts: {dataset, blobs, archive, exports, legacy, storage, other}} of forge's data home."""
|
|
410
|
+
home = Path(home)
|
|
411
|
+
parts = dict(dataset=0, blobs=0, archive=0, exports=0, legacy=0, storage=0, other=0)
|
|
412
|
+
seen = _Seen()
|
|
413
|
+
try:
|
|
414
|
+
entries = list(os.scandir(home))
|
|
415
|
+
except OSError:
|
|
416
|
+
entries = []
|
|
417
|
+
for entry in entries:
|
|
418
|
+
try:
|
|
419
|
+
info = entry.stat(follow_symlinks=False)
|
|
420
|
+
except OSError:
|
|
421
|
+
continue
|
|
422
|
+
if entry.name == 'dataset' and stat.S_ISDIR(info.st_mode):
|
|
423
|
+
for inner in os.scandir(entry.path):
|
|
424
|
+
try:
|
|
425
|
+
inner_info = inner.stat(follow_symlinks=False)
|
|
426
|
+
except OSError:
|
|
427
|
+
continue
|
|
428
|
+
if stat.S_ISDIR(inner_info.st_mode):
|
|
429
|
+
parts['blobs' if inner.name == 'blobs' else 'dataset'] += tree_usage(inner.path, seen, deadline)[0]
|
|
430
|
+
elif seen.first(inner_info):
|
|
431
|
+
parts['dataset'] += usage(inner_info)
|
|
432
|
+
elif stat.S_ISDIR(info.st_mode):
|
|
433
|
+
key = entry.name if entry.name in parts else 'other'
|
|
434
|
+
parts[key] += tree_usage(entry.path, seen, deadline)[0]
|
|
435
|
+
elif seen.first(info):
|
|
436
|
+
parts['other'] += usage(info)
|
|
437
|
+
return dict(path=str(home), bytes=sum(parts.values()), parts=parts)
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def report(repo=None, home=None, budget_s: float = 600.0, progress=None) -> dict:
|
|
441
|
+
"""What forge takes on disk, for one repository (a path) or, None, every one (`forge du`, forge-ui's Disk screen).
|
|
442
|
+
|
|
443
|
+
{repo, computed, complete, runs: [{path, run_id, repo, updated, total, snapshots, snapshot_count, logs, gz,
|
|
444
|
+
compressible, strays, fractal, other, reclaimable, complete}],
|
|
445
|
+
strays: [{path, bytes, kind, run}], worktrees: [{repo, run_id, path, bytes, complete}],
|
|
446
|
+
data_home: {path, bytes, parts} | None, totals: {runs, worktrees, data_home, reclaimable, snapshots, logs}}
|
|
447
|
+
"""
|
|
448
|
+
_scripts()
|
|
449
|
+
import forge_locations
|
|
450
|
+
import forge_worktrees
|
|
451
|
+
deadline = time.monotonic() + budget_s
|
|
452
|
+
found = run_dirs(repo)
|
|
453
|
+
runs, strays, worktrees, seen_roots = [], [], [], set()
|
|
454
|
+
complete = True
|
|
455
|
+
for index, (path, named) in enumerate(found):
|
|
456
|
+
if progress:
|
|
457
|
+
progress(index, len(found), path)
|
|
458
|
+
scanned = scan(path, deadline=deadline)
|
|
459
|
+
complete = complete and scanned['complete']
|
|
460
|
+
run_id = _first_line(os.path.join(path, 'run_id')) or os.path.basename(path)
|
|
461
|
+
try:
|
|
462
|
+
updated = max((e.stat(follow_symlinks=False).st_mtime for e in os.scandir(path)), default=None)
|
|
463
|
+
except OSError:
|
|
464
|
+
updated = None
|
|
465
|
+
runs.append(dict(path=path, run_id=run_id, repo=named, updated=updated, total=scanned['total'],
|
|
466
|
+
snapshots=scanned['snapshots']['bytes'], snapshot_count=scanned['snapshots']['count'],
|
|
467
|
+
logs=scanned['logs']['bytes'], gz=scanned['logs']['gz_bytes'],
|
|
468
|
+
compressible=scanned['logs']['compressible_bytes'], fractal=scanned['fractal'],
|
|
469
|
+
strays=sum(s['bytes'] for s in scanned['strays']), other=scanned['other'],
|
|
470
|
+
reclaimable=reclaimable(scanned), complete=scanned['complete']))
|
|
471
|
+
strays.extend(dict(s, run=path) for s in scanned['strays'])
|
|
472
|
+
if named and forge_worktrees.RUN_ID.fullmatch(run_id):
|
|
473
|
+
root = forge_worktrees.wt_root(named, run_id)
|
|
474
|
+
if root not in seen_roots and os.path.isdir(root) and not os.path.islink(root):
|
|
475
|
+
seen_roots.add(root)
|
|
476
|
+
size, done = tree_usage(root, deadline=deadline)
|
|
477
|
+
complete = complete and done
|
|
478
|
+
worktrees.append(dict(repo=named, run_id=run_id, path=root, bytes=size, complete=done))
|
|
479
|
+
# worktree folders the location list knows that no registered run led to (a run dir deleted, a checkout gone)
|
|
480
|
+
repo_real = os.path.realpath(repo) if repo is not None else None
|
|
481
|
+
for entry in forge_locations.entries('worktree'):
|
|
482
|
+
root = os.path.dirname(entry['path'])
|
|
483
|
+
if os.path.basename(os.path.dirname(root)) != '.forge-worktrees' or root in seen_roots or not os.path.isdir(root) \
|
|
484
|
+
or os.path.islink(root) or (repo_real and not _matches(entry, repo_real)):
|
|
485
|
+
continue
|
|
486
|
+
seen_roots.add(root)
|
|
487
|
+
size, done = tree_usage(root, deadline=deadline)
|
|
488
|
+
complete = complete and done
|
|
489
|
+
worktrees.append(dict(repo=entry.get('checkout'), run_id=entry.get('run_id') or os.path.basename(root), path=root,
|
|
490
|
+
bytes=size, complete=done))
|
|
491
|
+
home_parts = data_home_parts(home, deadline) if home is not None else None
|
|
492
|
+
runs.sort(key=lambda r: -r['total'])
|
|
493
|
+
worktrees.sort(key=lambda w: -w['bytes'])
|
|
494
|
+
totals = dict(runs=sum(r['total'] for r in runs), worktrees=sum(w['bytes'] for w in worktrees),
|
|
495
|
+
data_home=home_parts['bytes'] if home_parts else 0, reclaimable=sum(r['reclaimable'] for r in runs),
|
|
496
|
+
snapshots=sum(r['snapshots'] for r in runs), logs=sum(r['logs'] + r['gz'] for r in runs),
|
|
497
|
+
strays=sum(s['bytes'] for s in strays))
|
|
498
|
+
return dict(repo=str(repo) if repo is not None else None, computed=time.time(), complete=complete, runs=runs,
|
|
499
|
+
strays=sorted(strays, key=lambda s: -s['bytes']), worktrees=worktrees, data_home=home_parts, totals=totals)
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def footprints_of(result: dict) -> dict:
|
|
503
|
+
"""{repo: {bytes, runs, worktrees, count}} from a report, for save_footprints."""
|
|
504
|
+
out: dict = {}
|
|
505
|
+
for run in result['runs']:
|
|
506
|
+
if run['repo']:
|
|
507
|
+
entry = out.setdefault(run['repo'], dict(bytes=0, runs=0, worktrees=0, count=0))
|
|
508
|
+
entry['runs'] += run['total']
|
|
509
|
+
entry['bytes'] += run['total']
|
|
510
|
+
entry['count'] += 1
|
|
511
|
+
for wt in result['worktrees']:
|
|
512
|
+
entry = out.setdefault(wt['repo'], dict(bytes=0, runs=0, worktrees=0, count=0))
|
|
513
|
+
entry['worktrees'] += wt['bytes']
|
|
514
|
+
entry['bytes'] += wt['bytes']
|
|
515
|
+
return out
|
package/ui/README.md
CHANGED
|
@@ -110,6 +110,11 @@ Sources are checked in this order:
|
|
|
110
110
|
supplies absolute paths, one per line; blank lines and `#` comments are ignored.
|
|
111
111
|
`--registry-dir` replaces this location; `--no-registry` disables it.
|
|
112
112
|
|
|
113
|
+
Beside the registry, forge keeps a location list, `forge/locations.jsonl` in the same config home
|
|
114
|
+
(`scripts/forge_locations.py`): every run dir and worktree forge created, each with its repository's git dir
|
|
115
|
+
and main working tree, and when forge saw it go. The Worktrees and Disk screens use it as the index of where
|
|
116
|
+
to look; what is there is still read from the disk and git each time. forge-ui only reads it.
|
|
117
|
+
|
|
113
118
|
Plan directories (containing a `tasks.tsv` file) and solo run directories (a `prompt.md`
|
|
114
119
|
and a `repo` file) appear through `--plan` and the registry; `--root` finds plan directories
|
|
115
120
|
only. Stale or invalid paths are skipped. Duplicate real paths appear once,
|
|
@@ -158,7 +163,9 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
158
163
|
task table. The stage frames the run in the part of the window the modules leave free. The
|
|
159
164
|
inspector opens when you choose a task, an attempt or a finish node; with
|
|
160
165
|
nothing chosen it shows the run's timeline, finish and record (*Run details* in the header:
|
|
161
|
-
settings, request, waves, verification output).
|
|
166
|
+
settings, request, retro, waves, verification output). Above the task table, a plan run lists its
|
|
167
|
+
open brief questions (flagged first, then by projected start) and has the *Summaries* switch, which
|
|
168
|
+
shows the model when on. While summaries are on, the table has a Summary column.
|
|
162
169
|
- **Stage (3D):** each review finding stands over its task's block as a mark shaped by its
|
|
163
170
|
severity (P0 spike, P1 diamond, P2 cone, P3 pin, a ring when it has none; a plausible one smaller
|
|
164
171
|
and paler); on an opened task it moves onto the review that raised it, and the final review's sit
|
|
@@ -185,13 +192,41 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
185
192
|
<img src="docs/media/run.png" width="49%" alt="Planned waves: a run's tasks on a 3D plate with dependency cables, finding marks and the finish nodes, between the runs list and the run's inspector."> <img src="docs/media/execution.png" width="49%" alt="Execution: one block per attempt on wall-clock time, failed attempts in red, with the timeline and critical path in the inspector.">
|
|
186
193
|
- **Inspector:** for the run, its timeline, critical path, peak concurrency, what its scheduler
|
|
187
194
|
is doing (dispatching, drained or stopping, how many tasks wait and on what, each pause with its
|
|
188
|
-
countdown) and finish line, with what the finding sweep fixed and left; for a task, *Now* (below), its models and routing, escalations,
|
|
195
|
+
countdown) and finish line, with what the finding sweep fixed and left; for a task, first its header, its attempt trail, its Summary and its Questions (each below), then *Now* (below), its models and routing, escalations,
|
|
189
196
|
timings (busy, model time, overhead, queue wait after its dependencies merged), attempts and
|
|
190
197
|
their executions with the checks each ran, review findings with the gate decision, what the
|
|
191
198
|
finding sweep did with its findings (or, for a fix task, each finding it took and whether its
|
|
192
199
|
review found it fixed), and its prompts; for one execution, its model, phases, tokens,
|
|
193
200
|
checks, exact prompt and final message; for the final review, its verdict, findings, report,
|
|
194
201
|
prompt and history.
|
|
202
|
+
- **Task header and attempt trail:** a task's inspector opens on its title and goal, its links, and
|
|
203
|
+
the **Prompt**, **Approach** and **Acceptance criteria** buttons, each opening its text below them
|
|
204
|
+
(a button is disabled when the task has no such text). Links are `#N` and GitHub issue and pull
|
|
205
|
+
request URLs. A `#N` links to the GitHub origin of the run's repo, and is plain text when that
|
|
206
|
+
origin is not GitHub; nothing is fetched. Then comes one line per attempt: its dwarf, its verdict,
|
|
207
|
+
its findings with the worst severity, and why it ran (*first attempt*, *after review findings*,
|
|
208
|
+
*after failing tests before review*, *after unaddressed findings*, *after an unfinished message*,
|
|
209
|
+
*after your answer*, *escalated to a stronger model*, *manual retry*, or *reason not recorded*).
|
|
210
|
+
Each line opens that attempt's executions. A solo run has the header and the trail, but no Summary
|
|
211
|
+
and no Questions.
|
|
212
|
+
- **Summary:** a plan task's generated summary: its text, then *Generated by* its model and the time
|
|
213
|
+
it was made (a relative time, with the full time on hover). *Out of date* marks a summary made before
|
|
214
|
+
the task's attempts, status, merge or last review changed. Its sources link to the attempt's
|
|
215
|
+
executions or to the task's findings. A failed try shows its error and keeps the summary before it.
|
|
216
|
+
A task with no summary says *No summary yet.* Beside the text is the task's own switch: *Inherit*,
|
|
217
|
+
*On* or *Off*. Without write access the switch is not shown, and a task with no summary then has
|
|
218
|
+
no Summary section.
|
|
219
|
+
- **Questions:** a plan task's brief questions. Each shows its question, why, options, default (*if
|
|
220
|
+
unanswered*), its *must answer* and *possibly stale* flags, and its answer once recorded, with an
|
|
221
|
+
answer box where the page can write. Parked questions, which are wider than the task, sit under
|
|
222
|
+
*Parked (wider scope)*, collapsed, with their scope and no answer box. At the `gated` brief level a
|
|
223
|
+
task waits for its unanswered must-answer questions: its *Now* says *waits for your answer to* those
|
|
224
|
+
ids, and the run's scheduler counts them under *for your answer*.
|
|
225
|
+
- **Retro:** a run with a retro report or retro notes has a Retro section in *Run details*: its note
|
|
226
|
+
counts on one line (for example *5 notes: 3 you can fix, 2 for forge · 4 verified, 1 claimed · 1
|
|
227
|
+
blocking*), then the report, collapsed.
|
|
228
|
+
- **Read-only:** a server started with `--read-only` shows all of this, without the switches or the
|
|
229
|
+
answer boxes.
|
|
195
230
|
- **Now and checks:** a running task's *Now* names the agent at work and its attempt, the phase
|
|
196
231
|
and for how long, the command it is running (its first line, and whether it is a test, type
|
|
197
232
|
check, lint or build) and for how long, when its log last moved, and *quiet N min* once that is
|
|
@@ -255,16 +290,31 @@ keep one meaning everywhere (amber running, green merged or passed, red failed,
|
|
|
255
290
|
from the dataset for checkouts that are gone; when checkouts' files differ the tab says so and lets you
|
|
256
291
|
pick one. Each tab reads its endpoint when it opens, never on the poll; *Read again* reads everything
|
|
257
292
|
again. A run's header (its repository name) and each map district's heading link to the project.
|
|
293
|
+
- **Disk (`#/disk`):** what forge takes on disk in every repository it has runs for: each registered run dir
|
|
294
|
+
(total, review snapshots, logs, anything forge does not create, what can go), each run's worktree folder,
|
|
295
|
+
and forge's data home, with the command that takes each part back (`forge runs compact`, `forge runs rm
|
|
296
|
+
--dry-run`), to copy. The same report as `forge du --all` (`scripts/forge_storage.py`). Measuring visits
|
|
297
|
+
every file, so it runs once in the background when the screen opens and again on *Measure again*. A
|
|
298
|
+
chart shows where the space goes, by kind (review snapshots, logs, other run files, what is not
|
|
299
|
+
forge's, worktrees, the data home) and by repository, with each part's size and share on hover; the
|
|
300
|
+
answer is kept for 10 minutes, and the page polls only while a measurement runs. A finished execution's
|
|
301
|
+
conversation reads the same from a log copy that `forge runs compact --logs` gzipped.
|
|
258
302
|
- **Worktrees (`#/worktrees`, `#/worktrees/repo/<root>`, `#/worktrees/runs/<key>`):** every worktree forge
|
|
259
303
|
created, in any repository forge-ui knows (the runs it lists and the repositories in the dataset),
|
|
260
304
|
with its run, task, branch, whether that branch is merged, its last commit, when forge created and
|
|
261
305
|
removed it, and its size. Each row has a status: *in use* (its run is active), *uncommitted
|
|
262
306
|
changes*, *locked*, *needed by the run* (the `_integration` of a run not yet integrated), *failed
|
|
263
307
|
task*, *finished*, *missing on disk*, *not forge's* (it fails the ownership rule `forge runs rm`
|
|
264
|
-
uses
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
308
|
+
uses; a worktree whose folder and branch carry forge's names for the run, `<run id>/<name>` on
|
|
309
|
+
`forge/<run id>/<name>`, is the run's even when its task was split or dropped since), *unknown to git*
|
|
310
|
+
(a folder no repository lists) and *removed*. A repository is found through any of its worktrees on
|
|
311
|
+
disk, through symlinks too, so a checkout deleted by hand hides none of them; a worktree on disk is
|
|
312
|
+
never called removed, and a repository git cannot list (a timeout, git's `safe.directory` refusal)
|
|
313
|
+
is named at the top. The screen opens on the worktrees *on disk*; the status filter shows the rest.
|
|
314
|
+
Rows with a safe next step show the command to copy: `git -C <path> status`, `git -C <repo> worktree
|
|
315
|
+
remove <path>` (plus `git branch -d` for a merged branch), `git worktree prune`, or, for a folder left
|
|
316
|
+
where a worktree was and that git no longer knows, `rm -rf -- <path>`; never `--force`, and the page
|
|
317
|
+
runs nothing, so it works with `--read-only`. *Whole runs* gives each finished run's
|
|
268
318
|
`forge runs rm <run-dir> --worktrees --branches --dry-run`, which also deletes the run directory
|
|
269
319
|
after archiving it. Removed worktrees are complete from the release that records them (dataset
|
|
270
320
|
events `worktree_created` and `worktree_removed`); older ones are derived from run dirs and the
|
|
@@ -333,7 +383,7 @@ notifications on. Failed requests keep the last good data and show a banner.
|
|
|
333
383
|
The page can change a run, and every change is one call of a forge CLI; the server writes
|
|
334
384
|
nothing itself, so a change is validated, locked and logged exactly as if typed in a terminal
|
|
335
385
|
(`control.log` records `ui` as the actor). Each change is confirmed first and says when it
|
|
336
|
-
takes effect
|
|
386
|
+
takes effect, except a brief answer, which is sent when you press *Send*. The routes are in [docs/api.md](docs/api.md).
|
|
337
387
|
|
|
338
388
|
- **Run and task controls (`forge control`):** in a plan's inspector, the QA threshold,
|
|
339
389
|
timeout, escalate-after and verify retries, and while a scheduler is live the retry and
|
|
@@ -351,12 +401,20 @@ takes effect. The routes are in [docs/api.md](docs/api.md).
|
|
|
351
401
|
- **Settings (`forge config`):** the registry, Jev, the repository's `.forge` files, the
|
|
352
402
|
dataset and `FORGE_*` variables (secrets shown as `<set>`), with edits for `repo.verify`,
|
|
353
403
|
`repo.setup`, `repo.verify-subset` and `jev.enabled`.
|
|
404
|
+
- **Summaries (`forge control set summaries`):** the switch above a plan's task table turns summaries on or
|
|
405
|
+
off for the run. A task's own switch, in its Summary section, sets that task to *On*, *Off* or *Inherit*
|
|
406
|
+
(the run's setting). Each change is confirmed first. On a finished run, turning them on starts
|
|
407
|
+
`forge summarize` in the background; on a live run, the scheduler starts them at each task's next change.
|
|
408
|
+
- **Brief answers (`forge brief answer`):** each brief question in a task's inspector has an answer box, and
|
|
409
|
+
*Send* records the answer, logged as `ui` in `control.log`. An answer given after the task started is late:
|
|
410
|
+
the CLI's notice shows under the question, with the follow-up row and the `forge control add` line that
|
|
411
|
+
queues it. Answers are sent at once, not confirmed first.
|
|
354
412
|
|
|
355
413
|
**Protection.** Each server start makes a random token and serves it in the page; every change
|
|
356
414
|
must send it, from a `Host` of `127.0.0.1` or `localhost`, with an `Origin` equal to the host
|
|
357
415
|
when one is sent, as JSON of at most 64 KiB, or it is refused before any CLI runs. There are no
|
|
358
416
|
CORS headers. One write per run at a time (`409 busy`). `--read-only` or `FORGE_UI_READONLY=1`
|
|
359
|
-
turns all of it off: no token is issued, every change is a 405, and the controls say the page cannot change the run.
|
|
417
|
+
turns all of it off: no token is issued, every change is a 405, and the controls say the page cannot change the run. The summaries switches and the answer boxes are not shown either.
|
|
360
418
|
`forge ui open` never reuses a server running in the other mode.
|
|
361
419
|
|
|
362
420
|
## Layout of the code
|
|
@@ -384,6 +442,8 @@ turns all of it off: no token is issued, every change is a 405, and the controls
|
|
|
384
442
|
- `forge_ui/static/checksview.js`, `forge_ui/checks.py`: where each task stands and the checks its
|
|
385
443
|
agents ran (the Now column and section, each attempt's checks, the environment banner), and
|
|
386
444
|
the reading of checks, counts, acceptance criteria and environment problems from a transcript.
|
|
445
|
+
- `forge_ui/static/briefview.js`: a task's brief questions and answer boxes in the inspector, and the run's
|
|
446
|
+
open questions above its task table (its ordering and start line are pure, node-tested).
|
|
387
447
|
- `forge_ui/static/files.js`: the files heatmap (`matrix()` is pure and node-tested).
|
|
388
448
|
- `forge_ui/export.py`: a run as one HTML file (the page's scripts and styles inlined, the API
|
|
389
449
|
responses it reads, the 3D stage's modules as one module text, a hash-based policy).
|