@giamme/forge 0.11.1 → 0.12.1
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 +56 -0
- package/SKILL.md +7 -3
- package/VERSION +1 -1
- package/docs/artifacts.md +50 -11
- package/docs/commands.md +56 -8
- package/docs/decomposed-runs.md +43 -2
- package/docs/forge-ui.md +55 -8
- package/docs/reviews.md +64 -6
- package/package.json +1 -1
- package/references/dataset.md +4 -2
- package/references/decompose.md +191 -17
- package/references/harnesses.md +13 -1
- package/references/ui.md +25 -4
- package/scripts/forge-contract.py +37 -7
- package/scripts/forge-control.py +268 -25
- package/scripts/forge-dispatch.sh +90 -3
- package/scripts/forge-guard.py +156 -15
- package/scripts/forge-issues.py +47 -3
- package/scripts/forge-lib-plans.sh +9 -3
- package/scripts/forge-lib-review.sh +24 -5
- package/scripts/forge-lib-task.sh +53 -5
- package/scripts/forge-lib-verify.sh +137 -6
- package/scripts/forge-parallel-options.sh +85 -0
- package/scripts/forge-parallel.sh +262 -31
- package/scripts/forge-ripwire.py +1 -1
- package/scripts/forge-route.py +157 -5
- package/scripts/forge-runtime.py +49 -1
- package/scripts/forge-schedule.py +735 -53
- package/scripts/forge-solo.sh +3 -1
- package/scripts/forge-sweep.py +542 -0
- package/scripts/forge-verify.py +878 -0
- package/scripts/forge_dataset/forecast.py +33 -5
- package/scripts/forge_dataset/harvest.py +10 -4
- package/scripts/forge_verify_reports.py +225 -0
- package/ui/README.md +58 -12
- package/ui/docs/api.md +277 -28
- package/ui/forge_ui/checks.py +331 -0
- package/ui/forge_ui/control.py +12 -2
- package/ui/forge_ui/export.py +25 -8
- package/ui/forge_ui/reader.py +657 -24
- package/ui/forge_ui/server.py +29 -0
- package/ui/forge_ui/static/app.js +15 -7
- package/ui/forge_ui/static/checksview.js +449 -0
- package/ui/forge_ui/static/controls.js +217 -33
- package/ui/forge_ui/static/convo.js +11 -2
- package/ui/forge_ui/static/findingsview.js +6 -4
- package/ui/forge_ui/static/gantt.js +14 -9
- package/ui/forge_ui/static/index.html +2 -0
- package/ui/forge_ui/static/panel.js +44 -1
- package/ui/forge_ui/static/runmodel.js +109 -12
- package/ui/forge_ui/static/scene3d.js +9 -5
- package/ui/forge_ui/static/style.css +113 -0
- package/ui/forge_ui/static/verifyview.js +324 -0
- package/ui/forge_ui/transcripts.py +225 -54
package/ui/forge_ui/server.py
CHANGED
|
@@ -41,11 +41,16 @@ _REVIEW_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/final-reviews/((?:final-rev
|
|
|
41
41
|
_TASK_DIFF_PATH = re.compile(_TASK_PATH.pattern + r'/diff(?:/(current|prev|committed|existing))?')
|
|
42
42
|
_EXEC_DIFF_PATH = re.compile(_EXEC_PATH.pattern + '/diff')
|
|
43
43
|
_TRANSCRIPT_PATH = re.compile(_EXEC_PATH.pattern + '/transcript')
|
|
44
|
+
_EXEC_CHECKS_PATH = re.compile(_EXEC_PATH.pattern + '/checks')
|
|
45
|
+
_TASK_CHECKS_PATH = re.compile(_TASK_PATH.pattern + '/checks')
|
|
46
|
+
_ENVIRONMENT_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/environment')
|
|
44
47
|
_REVIEW_DIFF_PATH = re.compile(_REVIEW_PATH.pattern + '/diff')
|
|
45
48
|
_FILES_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/files')
|
|
46
49
|
_FINDINGS_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/findings')
|
|
47
50
|
_EXPORT_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/export')
|
|
48
51
|
_FRACTAL_PATH = re.compile(_TASK_PATH.pattern + r'/fractal(?:/nodes/([A-Za-z0-9][A-Za-z0-9_-]{0,100})(/diff)?)?')
|
|
52
|
+
_VERIFY_LOG_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/verification(?:/(retry)|/lanes/([^/]+)(?:/runs/([^/]+))?)?/log'
|
|
53
|
+
r'(?:/lines/([^/]+))?')
|
|
49
54
|
_STATIC_PATH = re.compile(r'/([A-Za-z0-9_.-]+\.(?:html|js|css|svg|woff2))')
|
|
50
55
|
_TYPES = {
|
|
51
56
|
'html': 'text/html; charset=utf-8',
|
|
@@ -88,6 +93,13 @@ def with_token(body, token):
|
|
|
88
93
|
return body[:end] + meta + body[end:]
|
|
89
94
|
|
|
90
95
|
|
|
96
|
+
def _count(segment):
|
|
97
|
+
"""None for a missing segment, its value for a positive decimal one, False for anything else."""
|
|
98
|
+
if segment is None:
|
|
99
|
+
return None
|
|
100
|
+
return int(segment) if re.fullmatch(r'[1-9][0-9]{0,9}', segment) else False
|
|
101
|
+
|
|
102
|
+
|
|
91
103
|
def _task_id(segment):
|
|
92
104
|
"""A task id from its URL segment, or None when it cannot name a task dir."""
|
|
93
105
|
try:
|
|
@@ -135,12 +147,29 @@ def api_get(catalog, path):
|
|
|
135
147
|
match = _TRANSCRIPT_PATH.fullmatch(path)
|
|
136
148
|
if match:
|
|
137
149
|
return catalog.transcript(*match.groups())
|
|
150
|
+
match = _EXEC_CHECKS_PATH.fullmatch(path)
|
|
151
|
+
if match:
|
|
152
|
+
return catalog.execution_checks(*match.groups())
|
|
153
|
+
match = _TASK_CHECKS_PATH.fullmatch(path)
|
|
154
|
+
if match:
|
|
155
|
+
task_id = _task_id(match.group(2))
|
|
156
|
+
return None if task_id is None else catalog.task_checks(match.group(1), task_id)
|
|
157
|
+
match = _ENVIRONMENT_PATH.fullmatch(path)
|
|
158
|
+
if match:
|
|
159
|
+
return catalog.environment(match.group(1))
|
|
138
160
|
match = _FILES_PATH.fullmatch(path)
|
|
139
161
|
if match:
|
|
140
162
|
return catalog.files(match.group(1))
|
|
141
163
|
match = _FINDINGS_PATH.fullmatch(path)
|
|
142
164
|
if match:
|
|
143
165
|
return catalog.findings(match.group(1))
|
|
166
|
+
match = _VERIFY_LOG_PATH.fullmatch(path)
|
|
167
|
+
if match:
|
|
168
|
+
key, retry, lane, k, first = match.groups()
|
|
169
|
+
k, first = _count(k), _count(first)
|
|
170
|
+
if k is False or first is False:
|
|
171
|
+
return None
|
|
172
|
+
return catalog.verification_log(key, lane, k, first, retry=bool(retry))
|
|
144
173
|
match = _FRACTAL_PATH.fullmatch(path)
|
|
145
174
|
if match:
|
|
146
175
|
key, task_id, node, diff = match.group(1), _task_id(match.group(2)), match.group(3), match.group(4)
|
|
@@ -64,8 +64,8 @@ window.ForgeApp = (() => {
|
|
|
64
64
|
if (spec.kind === 'fractal') return `${base}/tasks/${e(spec.task)}/fractal/${e(spec.node)}/diff${file}`;
|
|
65
65
|
return `${base}/tasks/${e(spec.task)}/diff${spec.source && spec.source !== 'current' ? '/' + e(spec.source) : ''}${file}`;
|
|
66
66
|
}
|
|
67
|
-
// an execution's conversation, in the stage's place like a diff
|
|
68
|
-
const convoHash = (key, sel) => hashFor(key, sel) + '/conversation';
|
|
67
|
+
// an execution's conversation, in the stage's place like a diff; opened at one of its events when given
|
|
68
|
+
const convoHash = (key, sel, event) => hashFor(key, sel) + '/conversation' + (Number.isInteger(event) && event >= 0 ? '/event/' + event : '');
|
|
69
69
|
function cloudHash(sel, focus) {
|
|
70
70
|
if (sel) return '#/cloud/runs/' + encodeURIComponent(sel);
|
|
71
71
|
return focus ? '#/cloud/projects/' + encodeURIComponent(focus) : '#/cloud';
|
|
@@ -83,11 +83,11 @@ window.ForgeApp = (() => {
|
|
|
83
83
|
if ((r = rest.match(/^\/tasks\/([^/]+)\/diff(?:\/(?!file\/|finding\/)([^/]+))?(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'task', task: d(r[1]), source: r[2] ? d(r[2]) : 'current', finding: r[3] ? d(r[3]) : null, file: r[4] ? d(r[4]) : null } };
|
|
84
84
|
if ((r = rest.match(/^\/tasks\/([^/]+)\/fractal\/([^/]+)\/diff(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'fractal', task: d(r[1]), node: d(r[2]), file: r[3] ? d(r[3]) : null } };
|
|
85
85
|
if ((r = rest.match(/^\/final-review\/([^/]+)\/diff(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'final', name: d(r[1]) }, diff: { kind: 'final', name: d(r[1]), finding: r[2] ? d(r[2]) : null, file: r[3] ? d(r[3]) : null } };
|
|
86
|
-
if ((r = rest.match(/^\/(?:tasks\/([^/]+)\/)?executions\/([^/]+)\/conversation
|
|
86
|
+
if ((r = rest.match(/^\/(?:tasks\/([^/]+)\/)?executions\/([^/]+)\/conversation(?:\/event\/(\d{1,7}))?\/?$/))) {
|
|
87
87
|
const s = r[1] ? { kind: 'execution', task: d(r[1]), id: d(r[1]), exec: d(r[2]) } : { kind: 'execution', task: null, exec: d(r[2]) };
|
|
88
88
|
const run = s.task && state.cache.get(d(m[1]))?.data, t = run && list(run.tasks).find(x => x.id === s.task);
|
|
89
89
|
if (t && list(t.shadow).some(x => x.execution === s.exec)) s.shadow = true;
|
|
90
|
-
return { key: d(m[1]), sel: s, convo: { task: s.task, exec: s.exec } };
|
|
90
|
+
return { key: d(m[1]), sel: s, convo: { task: s.task, exec: s.exec, event: r[3] ? Number(r[3]) : null } };
|
|
91
91
|
}
|
|
92
92
|
if ((r = rest.match(/^\/tasks\/([^/]+)\/executions\/([^/]+)\/?$/))) sel = { kind: 'execution', task: d(r[1]), id: d(r[1]), exec: d(r[2]) };
|
|
93
93
|
if (sel && sel.kind === 'execution' && sel.task) {
|
|
@@ -740,6 +740,10 @@ window.ForgeApp = (() => {
|
|
|
740
740
|
if (run.updated != null) { upd.dataset.epoch = run.updated; upd.dataset.short = ''; }
|
|
741
741
|
desc.append(upd);
|
|
742
742
|
row.append(lamp, title, where, desc); head.append(row);
|
|
743
|
+
// an environment problem several tasks met, read lazily
|
|
744
|
+
if (window.ForgeChecks && !solo) window.ForgeChecks.banner(head, { run, fetchJSON: path => fetchJSON(path).then(r => r.data),
|
|
745
|
+
rerender: () => { const cur = state.cache.get(state.key)?.data; if (cur && cur.key === run.key) renderHeader(cur); },
|
|
746
|
+
hash: s => hashFor(run.key, s), convoHash: (s, event) => convoHash(run.key, s, event) });
|
|
743
747
|
if (list(run.warnings).length) details(head, `Reader warnings (${run.warnings.length})`, run.warnings.join('\n'), 'warnings');
|
|
744
748
|
if (list(run.truncated).length) details(head, 'Truncated fields', run.truncated.join('\n'), 'truncated');
|
|
745
749
|
scoped(head, run.key + ':');
|
|
@@ -756,6 +760,8 @@ window.ForgeApp = (() => {
|
|
|
756
760
|
{ id: 'difficulty', label: 'Difficulty', value: t => DIFF_RANK[t.difficulty] ?? null, cell: t => display(t.difficulty) },
|
|
757
761
|
{ id: 'wave', label: 'Wave', value: t => Number.isFinite(Number(t.wave)) && t.wave !== null && t.wave !== '' ? Number(t.wave) : null, cell: t => display(t.wave) },
|
|
758
762
|
{ id: 'status', label: 'Status', value: t => RM.taskStatus(t), cell: t => chip(RM.taskStatus(t)) },
|
|
763
|
+
...(window.ForgeChecks ? [{ id: 'now', label: 'Now', title: 'What a running task is doing, or why one that is not running waits',
|
|
764
|
+
value: t => window.ForgeChecks.nowRank(t), cell: t => window.ForgeChecks.cell(t, now(), { hash: s => hashFor(run.key, s) }) }] : []),
|
|
759
765
|
{ id: 'dwarf', label: 'Dwarf', value: t => t.dwarf, cell: t => window.ForgeIcons.modelPlate(t.dwarf) },
|
|
760
766
|
{ id: 'qa', label: 'QA', value: t => t.qa, cell: t => window.ForgeIcons.modelPlate(t.qa) },
|
|
761
767
|
{ id: 'attempt', label: 'Attempt', value: t => Number(t.attempt) || null, cell: t => display(t.attempt) },
|
|
@@ -802,7 +808,7 @@ window.ForgeApp = (() => {
|
|
|
802
808
|
fetchJSON: path => fetchJSON(path).then(r => r.data),
|
|
803
809
|
rerender: () => { const r = state.cache.get(state.key)?.data; if (r) renderInspector(r); },
|
|
804
810
|
hash: s => hashFor(run.key, s), onSelect: s => select(s), diffHash: spec => diffHash(run.key, spec),
|
|
805
|
-
convoHash: s => convoHash(run.key, s),
|
|
811
|
+
convoHash: (s, event) => convoHash(run.key, s, event),
|
|
806
812
|
onFractal: (id, data) => { if (state.stage && state.stage.setFractal) state.stage.setFractal(id, data); },
|
|
807
813
|
});
|
|
808
814
|
scoped(host, run.key + ':');
|
|
@@ -874,7 +880,7 @@ window.ForgeApp = (() => {
|
|
|
874
880
|
if (kind === 'convo') {
|
|
875
881
|
const sel = state.sel, task = sel.task ? list(run.tasks).find(t => t.id === sel.task) : run.kind === 'solo' ? list(run.tasks)[0] : null;
|
|
876
882
|
const brief = list(task && task.executions).find(e => e.id === state.convo.exec) || null;
|
|
877
|
-
window.ForgeConvo.render(host, { run, spec: { task: task ? task.id : null, exec: state.convo.exec }, brief, live: !SNAP,
|
|
883
|
+
window.ForgeConvo.render(host, { run, spec: { task: task ? task.id : null, exec: state.convo.exec }, brief, live: !SNAP, focus: state.convo.event,
|
|
878
884
|
fetchJSON: path => fetchJSON(path).then(r => r.data), rerender, diffHash: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) });
|
|
879
885
|
return;
|
|
880
886
|
}
|
|
@@ -1062,7 +1068,8 @@ window.ForgeApp = (() => {
|
|
|
1062
1068
|
function busy() {
|
|
1063
1069
|
if (state.key) {
|
|
1064
1070
|
const run = state.cache.get(state.key)?.data;
|
|
1065
|
-
return !!run && (list(run.tasks).some(t => t.status === 'RUNNING') || (run.final_review && run.final_review.state === 'running')
|
|
1071
|
+
return !!run && (list(run.tasks).some(t => t.status === 'RUNNING') || (run.final_review && run.final_review.state === 'running')
|
|
1072
|
+
|| (run.verification && run.verification.state === 'running'));
|
|
1066
1073
|
}
|
|
1067
1074
|
return state.runs.some(r => r.counts && r.counts.RUNNING);
|
|
1068
1075
|
}
|
|
@@ -1075,6 +1082,7 @@ window.ForgeApp = (() => {
|
|
|
1075
1082
|
if (state.models) loadModels();
|
|
1076
1083
|
if (state.settings) state.settingsView?.poll();
|
|
1077
1084
|
for (const node of document.querySelectorAll('[data-epoch]')) { const t = relative(node.dataset.epoch); node.textContent = node.dataset.short !== undefined ? t.replace(/^updated /, '') : t; }
|
|
1085
|
+
if (window.ForgeChecks) window.ForgeChecks.tick(document, now());
|
|
1078
1086
|
}
|
|
1079
1087
|
// Poll faster while something runs, slower otherwise; never with refresh off, and a hidden tab only to notify.
|
|
1080
1088
|
function schedule() {
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/* forge-ui checks and where each task stands (window.ForgeChecks, and a CommonJS module under node:test).
|
|
2
|
+
- Now: what a running task does (the agent at work, the call it is making and since when, how long its log has been
|
|
3
|
+
quiet), or why a task that is not running waits (RunDetail task.now, task.waiting and run.scheduler in
|
|
4
|
+
ui/docs/api.md): a cell of the task table, a section of the task inspector, the run inspector's scheduler fields.
|
|
5
|
+
- Checks: the tests, type checks, lints and builds each dwarf and reviewer ran, attempt by attempt, against the
|
|
6
|
+
commands the brief's acceptance criteria name (/tasks/<id>/checks, /executions/<name>/checks).
|
|
7
|
+
- Environment: a banner in the run header for each environment problem (Docker, a sandbox's EPERM, a port in use…)
|
|
8
|
+
that several tasks met (/environment).
|
|
9
|
+
Times that move between polls (an elapsed time, a countdown, a quiet log) are elements with data-since, data-until
|
|
10
|
+
or data-quiet; tick(root, now) brings them up to date, and app.js calls it on every refresh.
|
|
11
|
+
The pure helpers are tested in ui/tests/js/checksview.test.js. Commands, output lines and task ids are untrusted:
|
|
12
|
+
they only ever enter the page as text.
|
|
13
|
+
ctx = { run, now (epoch seconds), fetchJSON(path), rerender(), hash(sel), onSelect(sel), convoHash(sel, event) } */
|
|
14
|
+
(function (root, factory) {
|
|
15
|
+
'use strict';
|
|
16
|
+
const api = factory(root);
|
|
17
|
+
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
18
|
+
else root.ForgeChecks = api;
|
|
19
|
+
})(typeof self !== 'undefined' ? self : this, function (root) {
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
const QUIET_WARN_S = 300; // a log quiet past this is flagged, as the verification view flags its own
|
|
23
|
+
const ENV_EVERY_S = 15; // a running run's environment problems are read again at most this often
|
|
24
|
+
const list = v => Array.isArray(v) ? v : [];
|
|
25
|
+
const num = v => typeof v === 'number' && Number.isFinite(v) ? v : null;
|
|
26
|
+
const ROLE = { dwarf: 'dwarf', qa: 'reviewer', task: 'task', solo: 'run' };
|
|
27
|
+
const KIND = { test: 'tests', typecheck: 'type check', lint: 'lint', build: 'build' };
|
|
28
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
29
|
+
|
|
30
|
+
/* ---------- pure ---------- */
|
|
31
|
+
function dur(s) {
|
|
32
|
+
s = num(s); if (s === null) return '—';
|
|
33
|
+
s = Math.max(0, Math.round(s));
|
|
34
|
+
if (s < 60) return s + 's';
|
|
35
|
+
if (s < 3600) return Math.floor(s / 60) + 'm' + String(s % 60).padStart(2, '0') + 's';
|
|
36
|
+
return Math.floor(s / 3600) + 'h' + String(Math.floor(s % 3600 / 60)).padStart(2, '0') + 'm';
|
|
37
|
+
}
|
|
38
|
+
const since = (start, now) => num(start) !== null && num(now) !== null ? Math.max(0, now - start) : null;
|
|
39
|
+
const firstLine = text => (String(text || '').split('\n').find(line => line.trim()) || '').trim();
|
|
40
|
+
// "quiet 12 min" once a log has said nothing for over five minutes, else null
|
|
41
|
+
function quietText(lastOutput, now) {
|
|
42
|
+
const q = since(lastOutput, now);
|
|
43
|
+
return q !== null && q > QUIET_WARN_S ? `quiet ${Math.floor(q / 60)} min` : null;
|
|
44
|
+
}
|
|
45
|
+
// "resumes in 2m10s", "resuming" once its time has come, or null without a time
|
|
46
|
+
function untilText(until, now) {
|
|
47
|
+
if (num(until) === null || num(now) === null) return null;
|
|
48
|
+
return until > now ? 'resumes in ' + dur(until - now) : 'resuming';
|
|
49
|
+
}
|
|
50
|
+
// What a running task does now: {who, role, execution, attempt, phase, phaseSince, call, quietSince}; call is
|
|
51
|
+
// {text (its first line, or the tool), command, check, since} or null while the agent thinks or writes.
|
|
52
|
+
function nowModel(task) {
|
|
53
|
+
const n = task && task.now;
|
|
54
|
+
if (!n || typeof n !== 'object') return null;
|
|
55
|
+
const call = n.call && typeof n.call === 'object' ? n.call : null;
|
|
56
|
+
return {
|
|
57
|
+
who: ROLE[n.role] || String(n.role || 'task'), role: n.role || null, execution: n.execution || null, attempt: num(n.attempt),
|
|
58
|
+
phase: n.phase || null, phaseSince: num(n.phase_started),
|
|
59
|
+
call: call ? { text: firstLine(call.command) || call.tool || call.kind || 'a call', command: call.command || null,
|
|
60
|
+
tool: call.tool || null, check: call.check || null, since: num(call.started) } : null,
|
|
61
|
+
quietSince: num(n.last_output_at),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function scopeText(w) {
|
|
65
|
+
const scope = String(w.scope || '');
|
|
66
|
+
if (scope === 'all') return 'every model';
|
|
67
|
+
if (scope.startsWith('model:')) return `model ${w.model || scope.slice(6)}${w.harness ? ' on ' + w.harness : ''}`;
|
|
68
|
+
if (scope.startsWith('harness:')) return `harness ${w.harness || scope.slice(8)}`;
|
|
69
|
+
return scope || 'its model';
|
|
70
|
+
}
|
|
71
|
+
// Why a task waits: {kind, text, tasks: [{id, stopped}], until, exhausted, split}, or null
|
|
72
|
+
function waitingModel(w) {
|
|
73
|
+
if (!w || typeof w !== 'object') return null;
|
|
74
|
+
const ids = v => list(v).map(String);
|
|
75
|
+
const out = { kind: w.kind, tasks: [], until: null, exhausted: false, split: null };
|
|
76
|
+
if (w.kind === 'deps') {
|
|
77
|
+
const stopped = new Set(ids(w.stopped));
|
|
78
|
+
return { ...out, text: 'waits on', tasks: ids(w.on).map(id => ({ id, stopped: stopped.has(id) })) };
|
|
79
|
+
}
|
|
80
|
+
if (w.kind === 'overlap') return { ...out, text: 'shares files with', tasks: ids(w.on).map(id => ({ id, stopped: false })) };
|
|
81
|
+
if (w.kind === 'slot') return { ...out, text: `no free slot: ${num(w.running) ?? '?'} of ${num(w.max_parallel) ?? '?'} running` };
|
|
82
|
+
if (w.kind === 'drained') return { ...out, text: 'drained: nothing new starts until the run resumes' };
|
|
83
|
+
if (w.kind === 'stopping') return { ...out, text: w.mode === 'now' ? 'the run is stopping now' : 'the run stops once its running tasks end' };
|
|
84
|
+
if (w.kind === 'next') return { ...out, text: "starts at the scheduler's next turn" };
|
|
85
|
+
if (w.kind === 'infra') {
|
|
86
|
+
return { ...out, text: `paused: ${scopeText(w)}${w.class ? ' · ' + String(w.class).replace(/_/g, ' ') : ''}`,
|
|
87
|
+
until: w.exhausted === true ? null : num(w.until), exhausted: w.exhausted === true };
|
|
88
|
+
}
|
|
89
|
+
if (w.kind === 'escalation') {
|
|
90
|
+
return { ...out, text: `stopped by the retry policy${num(w.attempts) !== null ? ` after ${plural(w.attempts, 'attempt')}` : ''}${w.model ? ' on ' + w.model : ''}`,
|
|
91
|
+
split: w.split || null };
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
// The Now column's order: running, then what starts soonest, then what waits on others, then what is held
|
|
96
|
+
const RANK = { running: 0, next: 1, slot: 2, overlap: 2, deps: 3, infra: 4, drained: 5, stopping: 5, escalation: 6 };
|
|
97
|
+
function nowRank(task) {
|
|
98
|
+
if (task && task.now) return RANK.running;
|
|
99
|
+
const w = task && task.waiting;
|
|
100
|
+
return w && RANK[w.kind] !== undefined ? RANK[w.kind] : null;
|
|
101
|
+
}
|
|
102
|
+
function countsText(c) {
|
|
103
|
+
if (!c || typeof c !== 'object') return null;
|
|
104
|
+
if ('errors' in c || 'warnings' in c) {
|
|
105
|
+
const parts = [plural(num(c.errors) || 0, 'error')];
|
|
106
|
+
if (num(c.warnings)) parts.push(plural(c.warnings, 'warning'));
|
|
107
|
+
return parts.join(' · ');
|
|
108
|
+
}
|
|
109
|
+
const parts = [`${num(c.passed) || 0} passed`];
|
|
110
|
+
if (num(c.failed)) parts.push(`${c.failed} failed`);
|
|
111
|
+
if (num(c.skipped)) parts.push(`${c.skipped} skipped`);
|
|
112
|
+
return parts.join(' · ');
|
|
113
|
+
}
|
|
114
|
+
// One check as a row: {index, state (pass, fail, running, unknown), kind, command, full, exit, time, since, counts, tail}
|
|
115
|
+
function checkRow(c, now) {
|
|
116
|
+
const running = c.running === true;
|
|
117
|
+
const state = running ? 'running' : c.failed === true ? 'fail' : c.exit === 0 ? 'pass' : num(c.exit) !== null ? 'fail' : 'unknown';
|
|
118
|
+
const took = running ? since(c.started, now) : num(c.duration_s);
|
|
119
|
+
return { index: num(c.index), state, kind: KIND[c.kind] || String(c.kind || 'check'), command: firstLine(c.command),
|
|
120
|
+
full: String(c.command || ''), exit: !running && num(c.exit) !== null ? 'exit ' + c.exit : null,
|
|
121
|
+
time: took === null ? null : dur(took), since: running ? num(c.started) : null, counts: countsText(c.counts), tail: c.tail || null };
|
|
122
|
+
}
|
|
123
|
+
// Which acceptance-criteria checks an attempt's agents ran: {total, ran, similar: [cmd], missing: [cmd], text}, or null
|
|
124
|
+
function coverageModel(criteria) {
|
|
125
|
+
const items = list(criteria).filter(c => c && typeof c === 'object');
|
|
126
|
+
if (!items.length) return null;
|
|
127
|
+
const of = status => items.filter(c => c.status === status).map(c => String(c.command));
|
|
128
|
+
const ran = of('ran').length;
|
|
129
|
+
return { total: items.length, ran, similar: of('similar'), missing: of('missing'),
|
|
130
|
+
text: `${ran} of ${items.length} acceptance-criteria check${items.length === 1 ? '' : 's'} ran as written` };
|
|
131
|
+
}
|
|
132
|
+
// The environment problems that several tasks met, for the run header's banner
|
|
133
|
+
const bannerProblems = (env, least = 2) => list(env && env.problems).filter(p => p && list(p.tasks).length >= least);
|
|
134
|
+
// The run inspector's scheduler fields: [[label, text]], or null when no scheduler runs the plan
|
|
135
|
+
function schedulerModel(run) {
|
|
136
|
+
const s = run && run.scheduler;
|
|
137
|
+
if (!s || s.live !== true) return null;
|
|
138
|
+
const tasks = list(run.tasks), count = kind => tasks.filter(t => t.waiting && t.waiting.kind === kind).length;
|
|
139
|
+
const state = s.stopping ? (s.stopping === 'now' ? 'stopping now' : 'stopping once its running tasks end') : s.drained ? 'drained: nothing new starts' : 'dispatching';
|
|
140
|
+
const waiting = [['deps', 'on dependencies'], ['overlap', 'on shared files'], ['slot', 'for a free slot'], ['infra', 'paused'],
|
|
141
|
+
['next', 'next'], ['escalation', 'stopped by the retry policy']]
|
|
142
|
+
.map(([kind, label]) => [count(kind), label]).filter(([n]) => n).map(([n, label]) => `${n} ${label}`);
|
|
143
|
+
const rows = [['Scheduler', state], ['Running', String(tasks.filter(t => t.status === 'RUNNING').length) + (num(s.max_parallel) !== null ? ` of ${s.max_parallel} slots` : '')]];
|
|
144
|
+
if (waiting.length) rows.push(['Waiting', waiting.join(' · ')]);
|
|
145
|
+
return rows;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ---------- DOM ---------- */
|
|
149
|
+
const cache = new Map(); // path → { data, error, pending, fresh, at }
|
|
150
|
+
function el(tag, text, className) {
|
|
151
|
+
const node = document.createElement(tag);
|
|
152
|
+
if (text !== undefined && text !== null) node.textContent = String(text);
|
|
153
|
+
if (className) node.className = className;
|
|
154
|
+
return node;
|
|
155
|
+
}
|
|
156
|
+
function section(parent, title, cls) {
|
|
157
|
+
const s = el('section', undefined, 'insp-section' + (cls ? ' ' + cls : ''));
|
|
158
|
+
s.append(el('h3', title)); parent.append(s); return s;
|
|
159
|
+
}
|
|
160
|
+
function load(ctx, path, fresh) {
|
|
161
|
+
const c = cache.get(path);
|
|
162
|
+
if (c && (c.fresh === fresh || c.pending)) return c;
|
|
163
|
+
const entry = { pending: true, fresh, data: c ? c.data : null, error: null, at: Date.now() };
|
|
164
|
+
cache.set(path, entry);
|
|
165
|
+
for (const old of cache.keys()) if (cache.size > 40 && old !== path) cache.delete(old);
|
|
166
|
+
ctx.fetchJSON(path).then(data => { entry.data = data; entry.error = null; }, err => { entry.error = err; })
|
|
167
|
+
.finally(() => { entry.pending = false; ctx.rerender(); });
|
|
168
|
+
return entry;
|
|
169
|
+
}
|
|
170
|
+
const enc = encodeURIComponent;
|
|
171
|
+
const taskPath = (run, id) => `/api/runs/${enc(run.key)}/tasks/${enc(id)}/checks`;
|
|
172
|
+
const execPath = (run, name) => `/api/runs/${enc(run.key)}/executions/${enc(name)}/checks`;
|
|
173
|
+
// a finished task's checks never change; a running one's are read again when the run moved
|
|
174
|
+
const freshness = (run, task) => task && task.status === 'RUNNING' ? 'live:' + run.updated : `done:${task && task.status}:${task && task.attempt}`;
|
|
175
|
+
function timeNode(start, now, cls) {
|
|
176
|
+
const n = el('span', dur(since(start, now)), 'vfy-num ' + (cls || 'now-time'));
|
|
177
|
+
if (num(start) !== null) n.dataset.since = String(start);
|
|
178
|
+
return n;
|
|
179
|
+
}
|
|
180
|
+
function quietNode(lastOutput, now) {
|
|
181
|
+
const t = quietText(lastOutput, now), n = el('span', t || '', 'warn now-quiet');
|
|
182
|
+
n.hidden = !t;
|
|
183
|
+
if (num(lastOutput) !== null) n.dataset.quiet = String(lastOutput);
|
|
184
|
+
return n;
|
|
185
|
+
}
|
|
186
|
+
function untilNode(until, now) {
|
|
187
|
+
const n = el('span', untilText(until, now), 'vfy-num now-until');
|
|
188
|
+
n.dataset.until = String(until);
|
|
189
|
+
return n;
|
|
190
|
+
}
|
|
191
|
+
function taskLinks(parent, ctx, tasks) {
|
|
192
|
+
tasks.forEach((t, i) => {
|
|
193
|
+
if (i) parent.append(document.createTextNode(', '));
|
|
194
|
+
const a = el('a', t.id, 'mono'); a.href = ctx.hash({ kind: 'task', id: t.id });
|
|
195
|
+
parent.append(a);
|
|
196
|
+
if (t.stopped) parent.append(el('span', ' (stopped)', 'warn'));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// Brings the times under `root` up to `now` (epoch seconds) between redraws.
|
|
200
|
+
function tick(rootNode, now) {
|
|
201
|
+
if (!rootNode || !rootNode.querySelectorAll || num(now) === null) return;
|
|
202
|
+
for (const n of rootNode.querySelectorAll('[data-since]')) n.textContent = dur(since(Number(n.dataset.since), now));
|
|
203
|
+
for (const n of rootNode.querySelectorAll('[data-until]')) n.textContent = untilText(Number(n.dataset.until), now) || '';
|
|
204
|
+
for (const n of rootNode.querySelectorAll('[data-quiet]')) { const t = quietText(Number(n.dataset.quiet), now); n.textContent = t || ''; n.hidden = !t; }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// The task table's Now cell
|
|
208
|
+
function cell(task, now, ctx) {
|
|
209
|
+
const box = el('span', undefined, 'now-cell');
|
|
210
|
+
const m = nowModel(task);
|
|
211
|
+
if (m) {
|
|
212
|
+
if (m.call) {
|
|
213
|
+
const code = el('code', m.call.text, 'now-call'); code.title = m.call.command || m.call.text;
|
|
214
|
+
box.append(code, timeNode(m.call.since, now));
|
|
215
|
+
} else box.append(el('span', `${m.who}${m.phase ? ' · ' + m.phase : ''}`, 'now-who'), timeNode(m.phaseSince, now));
|
|
216
|
+
box.append(quietNode(m.quietSince, now));
|
|
217
|
+
return box;
|
|
218
|
+
}
|
|
219
|
+
const w = waitingModel(task && task.waiting);
|
|
220
|
+
if (!w) { box.append(el('span', '—', 'muted')); return box; }
|
|
221
|
+
box.classList.add('now-waiting');
|
|
222
|
+
box.append(el('span', w.text + (w.tasks.length ? ' ' : ''), 'now-why'));
|
|
223
|
+
taskLinks(box, ctx, w.tasks);
|
|
224
|
+
if (w.until !== null) box.append(untilNode(w.until, now));
|
|
225
|
+
if (w.exhausted) box.append(el('span', 'waits used up', 'warn'));
|
|
226
|
+
return box;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// The task inspector's Now section: what it does, or why it waits
|
|
230
|
+
function nowSection(host, ctx, task) {
|
|
231
|
+
const m = nowModel(task), w = m ? null : waitingModel(task.waiting);
|
|
232
|
+
if (!m && !w) return;
|
|
233
|
+
const s = section(host, 'Now', 'now-section');
|
|
234
|
+
const box = el('div', undefined, 'vfy-live now-live');
|
|
235
|
+
if (m) {
|
|
236
|
+
const exec = list(task.executions).find(e => e.id === m.execution);
|
|
237
|
+
const who = el('p', undefined, 'vfy-now');
|
|
238
|
+
who.append(el('span', m.who, 'now-role'));
|
|
239
|
+
const spec = exec && exec.model && exec.model.spec;
|
|
240
|
+
if (spec && root.ForgeIcons) who.append(document.createTextNode(' '), root.ForgeIcons.modelPlate(spec));
|
|
241
|
+
if (m.attempt !== null) who.append(el('span', ` · attempt ${m.attempt}`, 'muted'));
|
|
242
|
+
if (m.phase) who.append(el('span', ` · ${m.phase} for `, 'muted'), timeNode(m.phaseSince, ctx.now));
|
|
243
|
+
box.append(who);
|
|
244
|
+
const call = el('p', undefined, 'vfy-now now-doing');
|
|
245
|
+
if (m.call) {
|
|
246
|
+
call.append(el('span', m.call.command ? 'runs ' : 'calls ', 'muted'));
|
|
247
|
+
const code = el('code', m.call.text, 'now-call'); code.title = m.call.command || m.call.text;
|
|
248
|
+
call.append(code);
|
|
249
|
+
if (m.call.check) call.append(el('span', KIND[m.call.check] || m.call.check, 'tag'));
|
|
250
|
+
call.append(el('span', ' for ', 'muted'), timeNode(m.call.since, ctx.now));
|
|
251
|
+
} else if (m.role === 'dwarf' || m.role === 'qa') call.append(el('span', 'no call running: the model is thinking or writing', 'muted'));
|
|
252
|
+
if (call.childNodes.length) box.append(call);
|
|
253
|
+
if (m.quietSince !== null) {
|
|
254
|
+
const last = el('p', undefined, 'vfy-now muted');
|
|
255
|
+
last.append(document.createTextNode('last output '), timeNode(m.quietSince, ctx.now), document.createTextNode(' ago'));
|
|
256
|
+
box.append(last);
|
|
257
|
+
}
|
|
258
|
+
const quiet = quietNode(m.quietSince, ctx.now); quiet.classList.add('vfy-idle');
|
|
259
|
+
box.append(quiet);
|
|
260
|
+
if (m.execution && (m.role === 'dwarf' || m.role === 'qa') && ctx.convoHash) {
|
|
261
|
+
const a = el('a', 'Follow it in its conversation →', 'diff-link small');
|
|
262
|
+
a.href = ctx.convoHash({ kind: 'execution', task: task.id === 'solo' ? null : task.id, id: task.id, exec: m.execution });
|
|
263
|
+
box.append(a);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
const p = el('p', undefined, 'vfy-now');
|
|
267
|
+
p.append(el('span', w.text + (w.tasks.length ? ' ' : '')));
|
|
268
|
+
taskLinks(p, ctx, w.tasks);
|
|
269
|
+
if (w.until !== null) p.append(document.createTextNode(' · '), untilNode(w.until, ctx.now));
|
|
270
|
+
if (w.exhausted) p.append(el('span', ' · its waits are used up', 'warn'));
|
|
271
|
+
box.append(p);
|
|
272
|
+
if (w.split) {
|
|
273
|
+
const d = el('details', undefined, 'now-split'); d.dataset.keep = `now-split-${task.id}`;
|
|
274
|
+
d.append(el('summary', 'The split it suggests'), el('pre', w.split));
|
|
275
|
+
box.append(d);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
s.append(box);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// One execution's checks, its environment problems and, while it runs, its call
|
|
282
|
+
function execChecks(parent, ctx, task, data) {
|
|
283
|
+
const rows = list(data && data.checks).map(c => checkRow(c, ctx.now));
|
|
284
|
+
const target = { kind: 'execution', task: task && task.id !== 'solo' ? task.id : null, id: task ? task.id : null, exec: data.execution };
|
|
285
|
+
if (rows.length) {
|
|
286
|
+
const ul = el('ul', undefined, 'plain checks');
|
|
287
|
+
for (const r of rows) {
|
|
288
|
+
const li = el('li', undefined, 'check check-' + r.state);
|
|
289
|
+
const head = el('div', undefined, 'check-head');
|
|
290
|
+
head.append(el('i', undefined, 'lamp st-' + (r.state === 'unknown' ? 'unknown' : r.state)), el('span', r.kind, 'tag'));
|
|
291
|
+
const cmd = r.index !== null && ctx.convoHash ? el('a', r.command, 'mono check-cmd') : el('span', r.command, 'mono check-cmd');
|
|
292
|
+
if (cmd.tagName === 'A') cmd.href = ctx.convoHash(target, r.index);
|
|
293
|
+
cmd.title = r.full;
|
|
294
|
+
head.append(cmd);
|
|
295
|
+
const meta = el('span', undefined, 'check-meta vfy-num');
|
|
296
|
+
if (r.exit) meta.append(el('span', r.exit, r.state === 'fail' ? 'check-exit warn' : 'check-exit'));
|
|
297
|
+
if (r.since !== null) meta.append(timeNode(r.since, ctx.now));
|
|
298
|
+
else if (r.time) meta.append(el('span', r.time));
|
|
299
|
+
if (r.counts) meta.append(el('span', r.counts, 'check-counts'));
|
|
300
|
+
if (meta.childNodes.length) head.append(meta);
|
|
301
|
+
li.append(head);
|
|
302
|
+
if (r.tail) {
|
|
303
|
+
const d = el('details', undefined, 'check-tail'); d.dataset.keep = `check-${data.execution}-${r.index}`;
|
|
304
|
+
d.append(el('summary', 'last lines'), el('pre', r.tail));
|
|
305
|
+
li.append(d);
|
|
306
|
+
}
|
|
307
|
+
ul.append(li);
|
|
308
|
+
}
|
|
309
|
+
parent.append(ul);
|
|
310
|
+
} else if (data.state === 'done') parent.append(el('p', 'ran no tests, type checks or lints', 'muted checks-none'));
|
|
311
|
+
for (const hit of list(data.environment)) {
|
|
312
|
+
const p = el('p', undefined, 'check-env');
|
|
313
|
+
p.append(el('span', hit.label || hit.problem, 'check-env-what'));
|
|
314
|
+
const cmd = ctx.convoHash ? el('a', firstLine(hit.command), 'mono') : el('span', firstLine(hit.command), 'mono');
|
|
315
|
+
if (ctx.convoHash) cmd.href = ctx.convoHash(target, hit.index);
|
|
316
|
+
p.append(cmd);
|
|
317
|
+
if (hit.line) p.title = hit.line;
|
|
318
|
+
parent.append(p);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function coverageBlock(parent, cov, running) {
|
|
323
|
+
if (!cov) return;
|
|
324
|
+
const box = el('div', undefined, 'checks-criteria');
|
|
325
|
+
box.append(el('p', cov.text, cov.missing.length && !running ? 'warn checks-cov' : 'muted checks-cov'));
|
|
326
|
+
const items = [...cov.missing.map(c => [c, running ? 'not run yet' : 'not run']), ...cov.similar.map(c => [c, 'run another way'])];
|
|
327
|
+
if (items.length) {
|
|
328
|
+
const ul = el('ul', undefined, 'plain checks-missing');
|
|
329
|
+
for (const [command, why] of items) {
|
|
330
|
+
const li = el('li');
|
|
331
|
+
li.append(el('span', why + ': ', why === 'not run' ? 'warn' : 'muted'), el('code', command, 'mono'));
|
|
332
|
+
ul.append(li);
|
|
333
|
+
}
|
|
334
|
+
box.append(ul);
|
|
335
|
+
}
|
|
336
|
+
parent.append(box);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// The task inspector's attempts get their checks: one lazy read for the whole task.
|
|
340
|
+
function taskChecks(ctx, task) {
|
|
341
|
+
if (!ctx.fetchJSON || !task) return null;
|
|
342
|
+
return load(ctx, taskPath(ctx.run, task.id), freshness(ctx.run, task));
|
|
343
|
+
}
|
|
344
|
+
// under an attempt's dwarf or reviewer line
|
|
345
|
+
function underExecution(parent, ctx, task, entry, attempt, exec) {
|
|
346
|
+
const a = entry && entry.data && list(entry.data.attempts).find(x => x.attempt === attempt);
|
|
347
|
+
const data = a && list(a.executions).find(x => x.execution === exec);
|
|
348
|
+
if (!data) return;
|
|
349
|
+
const box = el('div', undefined, 'checks-of');
|
|
350
|
+
execChecks(box, ctx, task, data);
|
|
351
|
+
if (box.childNodes.length) parent.append(box);
|
|
352
|
+
}
|
|
353
|
+
// at the foot of an attempt's box
|
|
354
|
+
function attemptCriteria(parent, entry, attempt) {
|
|
355
|
+
const a = entry && entry.data && list(entry.data.attempts).find(x => x.attempt === attempt);
|
|
356
|
+
if (a) coverageBlock(parent, coverageModel(a.criteria), a.running === true);
|
|
357
|
+
}
|
|
358
|
+
function loadingLine(parent, entry) {
|
|
359
|
+
if (!entry) return;
|
|
360
|
+
if (entry.error && !entry.data) {
|
|
361
|
+
parent.append(el('p', entry.error.snapshot ? 'The checks are not in this export: it was made without prompts and texts.'
|
|
362
|
+
: `Could not read the checks${entry.error.status === 404 ? ': this server predates them (forge ui open restarts it)' : ''}.`, 'muted'));
|
|
363
|
+
} else if (!entry.data) parent.append(el('p', 'Reading the checks each agent ran…', 'muted'));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// The execution inspector's Checks section
|
|
367
|
+
function execSection(host, ctx, task, sel, brief) {
|
|
368
|
+
const role = brief ? brief.role : String(sel.exec).split('-')[0];
|
|
369
|
+
if (role !== 'dwarf' && role !== 'qa') return;
|
|
370
|
+
const s = section(host, 'Checks', 'checks-section');
|
|
371
|
+
const fresh = brief && brief.state === 'done' ? 'done' : 'live:' + ctx.run.updated;
|
|
372
|
+
const entry = load(ctx, execPath(ctx.run, sel.exec), fresh);
|
|
373
|
+
loadingLine(s, entry);
|
|
374
|
+
const d = entry.data;
|
|
375
|
+
if (!d) return;
|
|
376
|
+
if (d.call && d.state === 'running') {
|
|
377
|
+
const p = el('p', undefined, 'vfy-now now-doing');
|
|
378
|
+
p.append(el('span', d.call.command ? 'runs ' : 'calls ', 'muted'), el('code', firstLine(d.call.command) || d.call.tool || 'a call', 'now-call'),
|
|
379
|
+
el('span', ' for ', 'muted'), timeNode(d.call.started, ctx.now));
|
|
380
|
+
s.append(p);
|
|
381
|
+
}
|
|
382
|
+
execChecks(s, ctx, task, d);
|
|
383
|
+
coverageBlock(s, coverageModel(d.criteria), d.state === 'running');
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// The run inspector's scheduler fields, under its timeline
|
|
387
|
+
function schedulerFields(parent, run, now) {
|
|
388
|
+
const rows = schedulerModel(run);
|
|
389
|
+
if (!rows) return;
|
|
390
|
+
const dl = el('dl', undefined, 'fields');
|
|
391
|
+
for (const [label, value] of rows) { dl.append(el('dt', label), el('dd', value)); }
|
|
392
|
+
for (const p of list(run.scheduler.pauses)) {
|
|
393
|
+
const w = waitingModel({ ...p, kind: 'infra' });
|
|
394
|
+
const dd = el('dd', w.text);
|
|
395
|
+
if (w.until !== null) dd.append(document.createTextNode(' · '), untilNode(w.until, now));
|
|
396
|
+
if (w.exhausted) dd.append(el('span', ' · its waits are used up', 'warn'));
|
|
397
|
+
dl.append(el('dt', 'Paused'), dd);
|
|
398
|
+
}
|
|
399
|
+
parent.append(dl);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// The run header's banner: environment problems more than one task met
|
|
403
|
+
const banners = new Map(); // run key → { entry, updated, at }
|
|
404
|
+
function banner(head, ctx) {
|
|
405
|
+
const run = ctx.run, path = `/api/runs/${enc(run.key)}/environment`;
|
|
406
|
+
const running = list(run.tasks).some(t => t.status === 'RUNNING');
|
|
407
|
+
const c = cache.get(path);
|
|
408
|
+
// once per change of the run, and while it runs at most every fifteen seconds
|
|
409
|
+
const due = !c || (c.fresh !== run.updated && (!running || Date.now() - c.at > ENV_EVERY_S * 1000));
|
|
410
|
+
const entry = due ? load(ctx, path, run.updated) : c;
|
|
411
|
+
const problems = bannerProblems(entry && entry.data);
|
|
412
|
+
if (!problems.length) return;
|
|
413
|
+
const box = el('div', undefined, 'env-banner'); box.setAttribute('role', 'note');
|
|
414
|
+
box.append(el('span', 'Environment', 'plate'));
|
|
415
|
+
const ul = el('ul', undefined, 'plain env-list');
|
|
416
|
+
for (const p of problems) {
|
|
417
|
+
const li = el('li', undefined, 'env-problem');
|
|
418
|
+
const head2 = el('span', undefined, 'env-head');
|
|
419
|
+
head2.append(el('strong', p.label || p.problem), el('span', ` in ${plural(list(p.tasks).length, 'task')}: `, 'muted'));
|
|
420
|
+
list(p.tasks).forEach((id, i) => {
|
|
421
|
+
if (i) head2.append(document.createTextNode(', '));
|
|
422
|
+
const a = el('a', id, 'mono'); a.href = ctx.hash({ kind: 'task', id });
|
|
423
|
+
head2.append(a);
|
|
424
|
+
});
|
|
425
|
+
li.append(head2);
|
|
426
|
+
const d = el('details', undefined, 'env-hits'); d.dataset.keep = `env-${p.problem}`;
|
|
427
|
+
d.append(el('summary', `${plural(num(p.count) || list(p.hits).length, 'failed command')}, what they said`));
|
|
428
|
+
const hits = el('ul', undefined, 'plain env-hit-list');
|
|
429
|
+
for (const h of list(p.hits)) {
|
|
430
|
+
const item = el('li');
|
|
431
|
+
const where = el('span', `${h.task} · attempt ${h.attempt ?? '?'} · ${ROLE[h.role] || h.role}: `, 'muted');
|
|
432
|
+
const cmd = ctx.convoHash ? el('a', firstLine(h.command), 'mono') : el('span', firstLine(h.command), 'mono');
|
|
433
|
+
if (ctx.convoHash) cmd.href = ctx.convoHash({ kind: 'execution', task: h.task === 'solo' ? null : h.task, id: h.task, exec: h.execution }, h.index);
|
|
434
|
+
item.append(where, cmd);
|
|
435
|
+
if (h.line) item.append(el('div', h.line, 'mono env-line'));
|
|
436
|
+
hits.append(item);
|
|
437
|
+
}
|
|
438
|
+
d.append(hits);
|
|
439
|
+
li.append(d);
|
|
440
|
+
ul.append(li);
|
|
441
|
+
}
|
|
442
|
+
box.append(ul);
|
|
443
|
+
head.append(box);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return { dur, quietText, untilText, nowModel, waitingModel, nowRank, countsText, checkRow, coverageModel, bannerProblems,
|
|
447
|
+
schedulerModel, tick, cell, nowSection, taskChecks, underExecution, attemptCriteria, loadingLine, execSection,
|
|
448
|
+
schedulerFields, banner, QUIET_WARN_S, cache };
|
|
449
|
+
});
|