Public: anyone can read this; the crew can change it.

/flow redirects to /boards and the top bar drops its Flow button #2791

Parked opened this
Closed without merging

scout/forge:scout/2767-flow-redirects-to-boards-and-the-top-bar → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
11 files changed +37 −403
README.md +5 −5
@@ -875,7 +875,7 @@ code never blocks. If the verdict is on the current head and no run is in
875875 flight, one feedback run is queued to the pull's builder, and a builder is
876876 assigned when the pull has none. That run takes a builder slot like any
877877 other. The tick log names each pull it moved, or why it did not, and
878 `/flow`, the terminal's Flow dialog and the MCP `flow` tool list the pulls
878 `/boards`, the terminal's Flow dialog and the MCP `flow` tool list the pulls
879879 waiting on a builder and those waiting on a reviewer, oldest first.
880880
881881 **Already done.** A builder that finds its issue already built on the base
@@ -909,7 +909,7 @@ gated tree. Red bisects: the front half is gated by itself, a green half
909909 lands, and the red pull is handed back with the failing tests named. Pulls
910910 that turn green while a candidate is gating wait for the next one. Each
911911 queue's numbers — how many pulls are queued, how many are gating, and how
912 many landed in the last hour — show in three places: the /flow page, the
912 many landed in the last hour — show in three places: the /boards page, the
913913 terminal's Flow command, and the MCP `flow` tool's `queue` field.
914914
915915 An autonomous app's planner is **held** while nothing is landing or the plate
@@ -924,7 +924,7 @@ under the first filter that holds it (`crew/held.ts`): `held: running=1
924924 open_pull=10 stalled=12 run_cap=11` — a run on it, an open pull proposing it,
925925 the planner's, found done on main and waiting for a person to close it
926926 (`done_on_main`, never re-planned), stalled, at its run cap, parked twice, covered by a red-main
927 fix, or a setting's finding. `/flow` draws the same per autonomous app as one
927 fix, or a setting's finding. `/boards` draws the same per autonomous app as one
928928 bar, and the terminal's Flow command prints it as a line per app
929929 (`flow/held.ts`, kept 5 s). When nothing is startable while builder slots are free and some of the
930930 held are stalled, capped or parked twice, the planner is owed one pass with
@@ -972,13 +972,13 @@ from before this record say nothing).
972972 mechanical rather than advisory.
973973
974974 `docs/FLOW.md` is where every issue stands: `GET /api/v1/repos/:owner/:name/flow` returns each open issue's stage, since, stalled and unblock, plus what went live in the last 24 h.
975 Where the whole forge waits is a forge admin's: `/flow` shows each stage from ready to live with what waits, the oldest wait and its capacity, under one sentence naming the bottleneck, and beside each what it let out in the last hour with a 24-hour sparkline, under a line of landings and the median ask→live — every count links to the items it counts. A stalled step is a card on the home (Studio mode) for anyone who can write to the repository: an open pull whose check was never asked for, or is red, past its stage's allowance, with its stage, how long it has been stuck, and one button — Run check or Re-run — that asks for a check at the head and returns to the home. The terminal's **Stalled steps** command (palette) lists the same steps, live, and Enter or `r` does the same re-run; both read `flow/stalled.ts` and act through `flow/unblock.ts`, and neither shows anything to someone who cannot write. A conflicted pull never sits: every tick the crew's open pulls that no longer merge get one bring-up-to-date run each (one in flight per pull); after 2 failed tries in the same conflict, or 24 h since the first, the pull is closed with the conflicting files named and its issue goes back to ready, unassigned, with no strike against the builder. Conflicted pulls are listed oldest first on `/flow`. The terminal's Flow command and the MCP `flow` tool read the same: the sentence, the landings line, and each stage's count out in the last hour and in 24 h.
975 Where the whole forge waits is a forge admin's: `/boards` shows each stage from ready to live with what waits, the oldest wait and its capacity, under one sentence naming the bottleneck (`/flow` answers 301 to it, and the top bar has no Flow button); the landings line, the median ask→live and each stage's count out are the terminal's Flow command and the MCP `flow` tool. A stalled step is a card on the home (Studio mode) for anyone who can write to the repository: an open pull whose check was never asked for, or is red, past its stage's allowance, with its stage, how long it has been stuck, and one button — Run check or Re-run — that asks for a check at the head and returns to the home. The terminal's **Stalled steps** command (palette) lists the same steps, live, and Enter or `r` does the same re-run; both read `flow/stalled.ts` and act through `flow/unblock.ts`, and neither shows anything to someone who cannot write. A conflicted pull never sits: every tick the crew's open pulls that no longer merge get one bring-up-to-date run each (one in flight per pull); after 2 failed tries in the same conflict, or 24 h since the first, the pull is closed with the conflicting files named and its issue goes back to ready, unassigned, with no strike against the builder. Conflicted pulls are listed oldest first by the terminal's Flow command and the MCP `flow` tool.
976976
977977 `/resilience` is a forge admin's too (a guest is sent to sign in, anyone else gets 404): each protection in `docs/THREATS.md` as one line, green, red, untested or "no test yet", judged by the test file it cites in the last full gate of the forge's own repository (`FORGE_REPO`; other repositories' gates never touch it). The terminal's **Resilience** command (palette, admins) lists the same lines.
978978
979979 The terminal also has an Access command (`:` → Access), a site admin's: it reads the same last-day non-browser requests as Settings → Access and the `access` MCP tool, newest first, and filters them with `s` (since), `u` (user agent) and `p` (path), `c` to clear.
980980
981 `/system` is the machine, for the owner (#1789): per-core CPU, hwmon temperatures, load, memory, disk per mount, network, and every process grouped by what the forge launched it for (`check:<run>`, `app:<slug>/<env>`, the forge, the host) with CPU, memory and age. It reads `/proc` and `/sys` and updates in place over one event stream, `/system/stream` (`?pause` holds it still; no reload, no polling); the 2 s push timer runs only while someone is subscribed, so it costs nothing unwatched. Its history is the `machine` board source. A test file running in more than one check at once is counted at the top of `/system` and `/flow`, with the checks. Command lines are never kept — only `*.test.ts` arguments.
981 `/system` is the machine, for the owner (#1789): per-core CPU, hwmon temperatures, load, memory, disk per mount, network, and every process grouped by what the forge launched it for (`check:<run>`, `app:<slug>/<env>`, the forge, the host) with CPU, memory and age. It reads `/proc` and `/sys` and updates in place over one event stream, `/system/stream` (`?pause` holds it still; no reload, no polling); the 2 s push timer runs only while someone is subscribed, so it costs nothing unwatched. Its history is the `machine` board source. A test file running in more than one check at once is counted at the top of `/system`, with the checks. Command lines are never kept — only `*.test.ts` arguments.
982982 In the terminal, `:` → System shows the same view (the owner's only), and `:` → Telemetry lists the agents and flips `telemetry:read` for the one you press Enter on.
983983 An agent the owner grants `telemetry:read` (Settings → Telemetry, one switch per agent, revoked the same way) reads the same through `GET /api/v1/telemetry/{system,flow,sources,history}` and the MCP `flow` and `system` tools; private repositories' checks and apps are renamed `check:private-N` and lose their processes and test files, and `flow` (like `system`, an admin agent account needs the grant too: only a person who is an admin reads without it) names only public repositories' conflicted pulls, every read is listed on that page, and an agent without the grant is refused. `/contribute`, `GET /api/v1/contribute` and the MCP `contribute` tool are open to anyone: what the forge is, the bottleneck now, open issues labelled “help wanted” in public repositories, and how to propose (fork, pull, the same gate). The grant is a table, not a token scope, so no token has to be re-issued.
984984
src/http/server.ts +2 −3
@@ -14,7 +14,6 @@ import { unsealReleased } from "../actions/sealed.ts";
1414 import { parentCallback, parentStart } from "./rp.ts";
1515 import { accessPage } from "../web/pages/access.ts";
1616 import { capacityPage, capacitySet } from "../web/pages/capacity.ts";
17 import { flowPage } from "../web/pages/flow.ts";
1817 import { systemPage, systemStream } from "../web/pages/system.ts";
1918 import { telemetryPage, telemetrySet } from "../web/pages/telemetry.ts";
2019 import { contributePage } from "../web/pages/contribute.ts";
@@ -734,8 +733,8 @@ export function buildRouter(): Router<Handler> {
734733 router.add("GET", "/migrate/jobs/:job", migrationJobPage);
735734 // Every app on one canvas; a literal route, so it must sit above /:owner.
736735 router.add("GET", "/map", globalMapPage);
737 // The pipeline's stages and its bottleneck, for a forge admin (#1554); literal, above /:owner.
738 router.add("GET", "/flow", flowPage);
736 // /flow's pipeline and held counts are a /boards panel; literal, above /:owner.
737 router.add("GET", "/flow", () => new Response(null, { status: 301, headers: { location: "/boards" } }));
739738 router.add("GET", "/system", systemPage);
740739 router.add("GET", "/system/stream", systemStream);
741740 router.add("GET", "/contribute", contributePage);
src/web/layout.ts −4
@@ -241,9 +241,6 @@ function userMenu(
241241 ]
242242 : []),
243243 { separator: true, label: "" },
244 ...(user.isAdmin
245 ? [{ label: "Flow", href: "/flow", icon: "activity" as const }]
246 : []),
247244 helpItem,
248245 themeForm(theme),
249246 { separator: true, label: "" },
@@ -334,7 +331,6 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
334331 : []),
335332 ...(ctx.auth.user?.isAdmin
336333 ? [
337 { t: "Flow", h: "/flow", c: "Go to" },
338334 { t: "System", h: "/system", c: "Go to" },
339335 { t: "Forges you sent", h: "/forges", c: "Go to" },
340336 { t: "Family of forges", h: "/family", c: "Go to" },
src/web/pages/flow.ts deleted −264
@@ -1,264 +0,0 @@
1 /**
2 * /flow, for a forge admin: the pipeline from a ready issue to a live
3 * deploy as rows, one per stage, each with how much is in it now, how long
4 * its oldest waiting item has waited, and the capacity that limits it
5 * (#1554). One sentence above names the stage with the longest wait — the
6 * bottleneck. The numbers are `flow/pipeline.ts`'s; the knobs stay on
7 * Settings → Capacity, linked from here.
8 *
9 * Beside what each stage holds, what it let out (#1779): items out in the
10 * last hour and a 24-bar sparkline per stage, and a headline line of
11 * landings and the median ask→live — `flow/throughput.ts`'s numbers, the
12 * same ones the MCP `flow` tool and the terminal's Flow command read. Every
13 * count links back here with `?out=<what>[&hour=<0–23>]`, which lists the
14 * items it counted under the table.
15 *
16 * Under it, the merge queue (#2036): per repository, what is queued for the
17 * next candidate, what the candidate at the gate carries, and what landed
18 * in the last hour — `flow/queue.ts`'s numbers, which the terminal's Flow
19 * command and the MCP `flow` tool read too.
20 *
21 * Beside the conflicted pulls, the pulls with changes requested (#2172):
22 * those waiting on a builder apart from those waiting on a reviewer, by
23 * age — `flow/requested.ts`'s, the rows the tick moves.
24 *
25 * Under the pipeline, why ready issues cannot start (#2244): per autonomous
26 * repository, its ready list as one bar, startable beside each filter that
27 * holds the rest — `flow/held.ts`'s rows, the same the tick line says and
28 * the terminal's Flow command prints.
29 */
30
31 import { noteRead, telemetryReader } from "../../actions/telemetry.ts";
32 import { queuesFor, systemFor } from "../../system/telemetry.ts";
33 import { conflictedPulls, conflictedSays } from "../../flow/conflicted.ts";
34 import { requestedSays, requestedWaits } from "../../flow/requested.ts";
35 import {
36 bottleneck,
37 readPipeline,
38 span,
39 STAGE_HOLDS,
40 STAGE_LABEL,
41 verdict,
42 waited,
43 type PipelineKey,
44 } from "../../flow/pipeline.ts";
45 import {
46 hoursSpan,
47 HOURS,
48 itemsIn,
49 OUTFLOW,
50 readThroughput,
51 stageOf,
52 type StageThroughput,
53 } from "../../flow/throughput.ts";
54 import type { QueueRow } from "../../flow/queue.ts";
55 import { readHeld } from "../../flow/held.ts";
56 import type { Ctx } from "../../http/context.ts";
57 import { notFoundPage, signInFirst } from "../chrome.ts";
58 import { html, type Html } from "../html.ts";
59 import { page } from "../layout.ts";
60 import { heldCard, heldCss } from "./boards-held.ts";
61 import { badge, card } from "../ui.ts";
62
63 const css = /* css */ `
64 .flow-out { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
65 .flow-out svg { width: 72px; height: 16px; }
66 .flow-bar { fill: var(--muted-fg); }
67 .flow-bar[data-empty] { fill: var(--muted); }
68 `;
69
70 /** What `?out=` and `?hour=` ask to list, checked: an unknown stage or hour lists nothing. */
71 function asked(url: URL): { key: PipelineKey; hour: number | null } | null {
72 const key = stageOf(url.searchParams.get("out") ?? "");
73 if (key === undefined) return null;
74 const h = url.searchParams.get("hour");
75 if (h === null) return { key, hour: null };
76 if (!/^\d{1,2}$/.test(h) || Number(h) >= HOURS) return null;
77 return { key, hour: Number(h) };
78 }
79
80 const outHref = (key: PipelineKey, hour: number | null): string =>
81 `/flow?out=${OUTFLOW[key].out}${hour === null ? "" : `&hour=${hour}`}#out`;
82
83 const hourWords = (hour: number | null): string =>
84 hour === null ? "in the last 24 hours" : hour === 0 ? "in the last hour" : `${hour}–${hour + 1} hours ago`;
85
86 /**
87 * 24 bars, oldest on the left: a picture only, hidden from assistive tech and
88 * out of the tab order. The two counts beside it are the way in (#1786).
89 */
90 function sparkline(t: StageThroughput): Html {
91 const max = Math.max(1, ...t.hours);
92 const bars = t.hours.map((n, hour) => {
93 const x = (HOURS - 1 - hour) * 3;
94 const h = n === 0 ? 1 : Math.max(2, Math.round((n / max) * 16));
95 return html`<rect class="flow-bar" ${n === 0 ? html`data-empty` : null} x="${String(x)}" y="${String(16 - h)}" width="2" height="${String(h)}" />`;
96 });
97 return html`<svg viewBox="0 0 72 16" aria-hidden="true" focusable="false">${bars}</svg>`;
98 }
99
100 function outCell(t: StageThroughput): Html {
101 const day = t.items.length;
102 const passed = t.items.filter((i) => i.outcome === "passed").length;
103 return html`<span class="flow-out" data-out="${OUTFLOW[t.key].out}">
104 <a class="mono" href="${outHref(t.key, 0)}" data-hour="0">${String(t.hours[0] ?? 0)}</a>
105 ${sparkline(t)}
106 <a class="muted small" href="${outHref(t.key, null)}" data-day="${String(day)}">${String(day)} in 24 h</a>
107 </span>
108 <div class="muted small">
109 ${OUTFLOW[t.key].label}${t.key === "checking" && day > 0 ? ` · ${passed} passed · ${day - passed} failed` : ""}
110 </div>`;
111 }
112
113 // GET /flow
114 export function flowPage(ctx: Ctx): Response {
115 if (!ctx.auth.user) return signInFirst(ctx);
116 const reader = telemetryReader(ctx.app, ctx.auth.user);
117 if (!reader) return notFoundPage(ctx);
118 noteRead(ctx.app, ctx.auth.user, reader, "flow");
119 const now = Date.now();
120 const stages = readPipeline(ctx.app.db, new Date(now));
121 const worst = bottleneck(stages);
122 const flow = readThroughput(ctx.app.db, stages.map((s) => s.key), new Date(now));
123 const out = new Map(flow.stages.map((t) => [t.key, t]));
124 const landed = out.get("approved");
125 const dups = systemFor(ctx.app, reader).duplicates;
126 const conflicted = conflictedSays(conflictedPulls(ctx.app.db, reader.kind === "agent"), now);
127 const requested = requestedWaits(ctx.app.db, reader.kind === "agent");
128 const onBuilder = requestedSays(requested.builder, "builder", now);
129 const onReviewer = requestedSays(requested.reviewer, "reviewer", now);
130 const listed = asked(ctx.url);
131 const shown = listed === null ? undefined : out.get(listed.key);
132 const body = html`<div class="page-head">
133 <h1>Flow</h1>
134 <p class="muted">
135 From a ready issue to a live deploy: what is in each stage now, how
136 long its oldest has waited, and what limits it. The limits are set on
137 <a href="/settings/capacity">Capacity</a> and in each repository's
138 autonomy settings. How the forge stands against its threats is on
139 <a href="/resilience">Resilience</a>. Where an outside agent can
140 help is on <a href="/contribute">Contribute</a>.
141 </p>
142 </div>
143 <p id="bottleneck" data-stage="${worst?.key ?? ""}">
144 <strong>${verdict(stages, now)}</strong>
145 </p>
146 ${conflicted === null ? "" : html`<p id="conflicted">${conflicted}</p>`}
147 ${onBuilder === null ? "" : html`<p id="requested-builder">${onBuilder}</p>`}
148 ${onReviewer === null ? "" : html`<p id="requested-reviewer">${onReviewer}</p>`}
149 <p id="throughput">
150 landed
151 <a href="${outHref("approved", 0)}" data-landed-hour>${String(landed?.hours[0] ?? 0)}</a>
152 in the last hour ·
153 <a href="${outHref("approved", null)}" data-landed-day>${String(landed?.items.length ?? 0)}</a>
154 in 24 h · median ask→live
155 <span data-median>${flow.medianAskToLiveMs === null ? "—" : hoursSpan(flow.medianAskToLiveMs)}</span>
156 (24 h)
157 </p>
158 <p id="duplicate-work" data-count="${String(dups.length)}" class="${dups.length === 0 ? "muted" : ""}">
159 ${dups.length === 0
160 ? html`No test file is running in more than one check.`
161 : html`<strong>${String(dups.length)} test file${dups.length === 1 ? " is" : "s are"} running in more than one check:</strong>
162 ${dups.slice(0, 5).map((d) => html`<span class="mono small">${d.file} (${d.checks.join(", ")})</span> `)}`}
163 <a href="/system">System</a>
164 </p>
165 ${card(
166 html`<div class="table-scroll">
167 <table class="table" aria-label="Pipeline stages">
168 <thead>
169 <tr>
170 <th scope="col">Stage</th>
171 <th scope="col">Waiting</th>
172 <th scope="col">Active</th>
173 <th scope="col">Oldest wait</th>
174 <th scope="col">Capacity</th>
175 <th scope="col">Out, last hour · 24 h</th>
176 </tr>
177 </thead>
178 <tbody>
179 ${stages.map(
180 (s) =>
181 html`<tr
182 data-stage="${s.key}"
183 ${s === worst ? html`data-bottleneck="true"` : null}
184 >
185 <th scope="row">
186 ${STAGE_LABEL[s.key]}
187 ${s === worst ? badge("bottleneck", { tone: "danger" }) : null}
188 <div class="muted small">${STAGE_HOLDS[s.key]}</div>
189 </th>
190 <td class="mono">${String(s.waiting)}</td>
191 <td class="mono">${String(s.active)}</td>
192 <td class="mono">${waited(s, now) ?? "—"}</td>
193 <td class="small">${s.capacity ?? "—"}</td>
194 <td>${outCell(out.get(s.key)!)}</td>
195 </tr>`,
196 )}
197 </tbody>
198 </table>
199 </div>`,
200 { pad: false },
201 )}
202 ${heldCard(readHeld(ctx.app, reader.kind === "owner", now))}
203 ${queueCard(queuesFor(ctx.app, reader, new Date(now)))}
204 ${listed === null || shown === undefined ? null : outList(shown, listed.hour, now)}`;
205 return page({ ctx, title: "Flow", body, styleCss: css + heldCss });
206 }
207
208 /** The merge queue, one row per repository with something in it or landed. */
209 function queueCard(rows: readonly QueueRow[]): Html {
210 return card(
211 html`<h2>Merge queue</h2>
212 <p class="muted small">
213 Green, approved pulls join their repository's queue; each candidate
214 is gated once and lands whole, or is bisected to the red one.
215 </p>
216 ${rows.length === 0
217 ? html`<p class="muted">Nothing queued, gating or landed in the last hour.</p>`
218 : html`<div class="table-scroll">
219 <table class="table" aria-label="Merge queue">
220 <thead>
221 <tr>
222 <th scope="col">Repository</th>
223 <th scope="col">Queued</th>
224 <th scope="col">Gating</th>
225 <th scope="col">Landed, last hour</th>
226 </tr>
227 </thead>
228 <tbody>
229 ${rows.map(
230 (r) =>
231 html`<tr data-queue="${r.repo}">
232 <th scope="row"><a href="/${r.repo}/pulls">${r.repo}</a></th>
233 <td class="mono" data-queued>${String(r.queued)}</td>
234 <td class="mono" data-gating>${String(r.gating)}</td>
235 <td class="mono" data-landed>${String(r.landedHour)}</td>
236 </tr>`,
237 )}
238 </tbody>
239 </table>
240 </div>`}`,
241 { id: "queue" },
242 );
243 }
244
245 /** The items one count counted, newest first, each linked to where it lives. */
246 function outList(t: StageThroughput, hour: number | null, now: number): Html {
247 const items = itemsIn(t, hour, now);
248 return card(
249 html`<h2>${STAGE_LABEL[t.key]}: ${String(items.length)} ${OUTFLOW[t.key].label} ${hourWords(hour)}</h2>
250 ${items.length === 0
251 ? html`<p class="muted">None.</p>`
252 : html`<ul>
253 ${items.map(
254 (i) =>
255 html`<li>
256 <a href="${i.href}">${i.label}</a>
257 ${i.outcome === null ? null : badge(i.outcome, { tone: i.outcome === "passed" ? "success" : "danger" })}
258 <span class="muted small">${span(now - Date.parse(i.at))} ago</span>
259 </li>`,
260 )}
261 </ul>`}`,
262 { id: "out" },
263 );
264 }
test/conflict_sweep.test.ts +2 −16
@@ -31,19 +31,8 @@ let alice: User;
3131 let repo: Repo;
3232 const fresh = () => getRepoById(app.db, repo.id)!;
3333
34 /** /flow as the admin, and the MCP flow tool's `conflicted` field. */
34 /** The MCP flow tool's `conflicted` field. */
3535 async function flowDoors() {
36 const signin = await fetch(`${servers.url}/signin`, {
37 method: "POST",
38 redirect: "manual",
39 headers: {
40 "content-type": "application/x-www-form-urlencoded",
41 origin: servers.url,
42 },
43 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
44 });
45 const cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
46 const page = await (await fetch(`${servers.url}/flow`, { headers: { cookie } })).text();
4736 const res = await fetch(`${servers.url}/mcp`, {
4837 method: "POST",
4938 headers: {
@@ -62,7 +51,7 @@ async function flowDoors() {
6251 const read = JSON.parse(body.result.content[0]!.text) as {
6352 conflicted: { says: string | null; pulls: { number: number }[] };
6453 };
65 return { page, mcp: read.conflicted };
54 return { mcp: read.conflicted };
6655 }
6756
6857 beforeAll(async () => {
@@ -147,8 +136,6 @@ test("a pull a landing made conflicted is brought up to date within a tick; fail
147136 expect(conflictedSays(conflictedPulls(app.db))).toContain(`engine#${pull.number}`);
148137 expect(flowLines(app.db).join("\n")).toContain("1 conflicted pull");
149138 const doors = await flowDoors();
150 expect(doors.page).toContain('id="conflicted"');
151 expect(doors.page).toContain(`engine#${pull.number}`);
152139 expect(doors.mcp.pulls.map((p) => p.number)).toEqual([pull.number]);
153140 expect(doors.mcp.says).toContain(`engine#${pull.number}`);
154141
@@ -176,7 +163,6 @@ test("a pull a landing made conflicted is brought up to date within a tick; fail
176163 expect(parkedCount(app.db, fresh(), freed.id)).toBe(0);
177164 expect(conflictedPulls(app.db)).toEqual([]);
178165 const after = await flowDoors();
179 expect(after.page).not.toContain('id="conflicted"');
180166 expect(after.mcp).toEqual({ says: null, pulls: [] });
181167 });
182168
test/crew-held.test.ts +9 −6
@@ -2,7 +2,7 @@
22 * Why each ready issue cannot start (#2244): an issue held by each filter
33 * is counted under that filter's name, the tick's words say the counts,
44 * and a crew with free slots and nothing startable asks the planner once,
5 * with the breakdown — a full plate does not hold it. /flow and the
5 * with the breakdown — a full plate does not hold it. /boards and the
66 * terminal's Flow dialog show the same counts, private repositories to the
77 * owner only. Each test makes its own repository and crew.
88 */
@@ -330,7 +330,7 @@ describe("the tick says why each ready issue cannot start", () => {
330330 expect(getIssueById(app.db, direction.id)!.assigneeId).toBeNull();
331331 });
332332
333 test("three doors: /flow, /boards and the terminal's Flow dialog show the counts, private ones to the owner only", async () => {
333 test("two doors: /boards and the terminal's Flow dialog show the counts, private ones to the owner only", async () => {
334334 const open = await crewed(app, alice, "open-door", "public");
335335 const shut = await crewed(app, alice, "shut-door");
336336 for (const { repo, mason } of [open, shut]) {
@@ -348,7 +348,7 @@ describe("the tick says why each ready issue cannot start", () => {
348348 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
349349 });
350350 const cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
351 const res = await fetch(`${servers.url}/flow`, { headers: { cookie } });
351 const res = await fetch(`${servers.url}/boards`, { headers: { cookie } });
352352 expect(res.status).toBe(200);
353353 const page = await res.text();
354354 expect(page).toContain('id="held"');
@@ -363,9 +363,12 @@ describe("the tick says why each ready issue cannot start", () => {
363363 expect(row).toContain('<span class="mono">run_cap=1</span>');
364364 expect(page).toContain('data-held-repo="alice/shut-door"');
365365
366 // /boards is the owner's: the same counts, private ones included, and a
367 // stranger is not shown the page at all.
368 const boards = await (await fetch(`${servers.url}/boards`, { headers: { cookie } })).text();
366 // /boards is the owner's: private ones included, and a stranger is not
367 // shown the page at all. /flow, which used to show them, moves here.
368 const moved = await fetch(`${servers.url}/flow`, { headers: { cookie }, redirect: "manual" });
369 expect(moved.status).toBe(301);
370 expect(moved.headers.get("location")).toBe("/boards");
371 const boards = page;
369372 expect(boards).toContain('id="held"');
370373 expect(boards).toContain('id="pipeline"');
371374 expect(boards).toContain('data-held-repo="alice/open-door"');
test/flow-pipeline.test.ts +10 −9
@@ -239,37 +239,38 @@ describe("/flow: the forge shows its own bottleneck", () => {
239239
240240 test("an admin reads the stages as rows under the one sentence, linked from the header", async () => {
241241 const cookie = await login("alice");
242 const res = await get("/flow", cookie);
242 const moved = await get("/flow", cookie);
243 expect(moved.status).toBe(301);
244 expect(moved.headers.get("location")).toBe("/boards");
245 const res = await get("/boards", cookie);
243246 expect(res.status).toBe(200);
244247 const page = await res.text();
245 expect(page).toContain('id="bottleneck" data-stage="check-queue"');
248 expect(page).toContain('data-stage="check-queue"');
246249 expect(page).toContain("Check queue is the bottleneck");
247250 expect(page).toMatch(/data-stage="check-queue"\s+data-bottleneck="true"/);
248251 for (const key of ["ready", "building", "checking", "review", "approved", "landed", "live"])
249252 expect(page).toContain(`data-stage="${key}"`);
250 expect(page).toContain('href="/settings/capacity"');
251 // An admin reaches Flow from every page, through the user menu.
252 expect(await (await get("/", cookie)).text()).toContain('href="/flow"');
253 // No page carries a Flow link any more: Boards holds what it showed.
254 expect(await (await get("/", cookie)).text()).not.toContain('href="/flow"');
253255 });
254256
255257 test("nobody but a forge admin reads it", async () => {
256258 const bob = await login("bob");
257 expect((await get("/flow", bob)).status).toBe(404);
259 expect(await (await get("/boards", bob)).text()).not.toContain('data-stage="check-queue"');
258260 expect(await (await get("/", bob)).text()).not.toContain('href="/flow"');
259 expect((await get("/flow", "")).status).not.toBe(200);
260261 });
261262
262263 test("the top bar holds search, New and the user menu; Flow, help and theme live in menus", async () => {
263264 expect(alice.isAdmin).toBe(true);
264265 const page = await (await get("/", await login("alice"))).text();
265266 const bar = page.slice(page.indexOf('<header class="topbar"'), page.indexOf("</header>"));
266 // Nothing but menus and search sits in the bar: no bare Flow link, no help button.
267 // Nothing but menus and search sits in the bar: no Flow link, no help button.
267268 expect(bar).not.toContain("flow-link");
268269 expect(bar).not.toContain("theme-menu");
269270 expect(bar.match(/<details/g)?.length).toBe(2);
270271 // They are still one open away, in the user menu.
271272 const panel = bar.slice(bar.lastIndexOf('<details'));
272 expect(panel).toContain('href="/flow"');
273 expect(panel).not.toContain('href="/flow"');
273274 expect(panel).toContain("data-help");
274275 expect(panel).toContain('action="/theme"');
275276 });
test/flow-throughput.test.ts +3 −59
@@ -1,5 +1,5 @@
11 /**
2 * /flow shows what moves (#1779): from a seeded forge — six pulls landed
2 * The terminal and MCP show what moves (#1779): from a seeded forge — six pulls landed
33 * over three hours, each closing an issue asked at a known time, a
44 * production deploy that served them, checks that passed and failed, a
55 * builder started on an issue twice, a release preflighted — each stage
@@ -31,7 +31,7 @@ const MIN = 60_000;
3131 const NOW = Date.now();
3232 const ago = (ms: number) => new Date(NOW - ms).toISOString();
3333
34 describe("/flow: actual throughput per stage", () => {
34 describe("actual throughput per stage", () => {
3535 let dataDir: string;
3636 let app: App;
3737 let servers: Servers;
@@ -39,17 +39,6 @@ describe("/flow: actual throughput per stage", () => {
3939 let bob: User;
4040 let repo: Repo;
4141
42 const login = async (username: string): Promise<string> => {
43 const res = await fetch(`${servers.url}/signin`, {
44 method: "POST",
45 redirect: "manual",
46 headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url },
47 body: new URLSearchParams({ username, password: "a-good-passphrase" }),
48 });
49 return (res.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
50 };
51 const get = async (path: string) =>
52 fetch(`${servers.url}${path}`, { headers: { cookie: await login("alice") }, redirect: "manual" });
5342
5443 const newIssue = (title: string, createdAt: string, body = "") => {
5544 const issue = openIssue(app, alice, repo, { title, body });
@@ -175,42 +164,10 @@ describe("/flow: actual throughput per stage", () => {
175164 expect(stageOf("approved")).toBeUndefined();
176165 });
177166
178 test("the page says it in the headline and beside each stage, and every count links to its items", async () => {
179 const res = await get("/flow");
180 expect(res.status).toBe(200);
181 const page = await res.text();
182 const headline = page.match(/<p id="throughput">([\s\S]*?)<\/p>/)?.[1] ?? "";
183 expect(headline.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim()).toBe(
184 "landed 2 in the last hour · 6 in 24 h · median ask→live 3.5 h (24 h)",
185 );
167 test("the headline says landings, the last day and the median", () => {
186168 expect(throughputSays(readThroughput(app.db, PIPELINE, new Date(NOW)))).toBe(
187169 "landed 2 in the last hour · 6 in 24 h · median ask→live 3.5 h (24 h)",
188170 );
189 expect(headline).toContain('href="/flow?out=landed&amp;hour=0#out"');
190 expect(page).toMatch(/data-out="landed">\s*<a class="mono" href="\/flow\?out=landed&amp;hour=0#out" data-hour="0">2<\/a>/);
191 expect(page).toContain('data-day="6">6 in 24 h');
192 expect(page).toContain("2 passed · 1 failed");
193 expect((page.match(/class="flow-bar"/g) ?? []).length).toBe(PIPELINE.length * 24);
194 });
195
196 test("each sparkline is a picture only: hidden from assistive tech, no links or tab stops of its own", async () => {
197 const page = await (await get("/flow")).text();
198 const svgs = page.match(/<svg[\s\S]*?<\/svg>/g) ?? [];
199 const sparks = svgs.filter((s) => s.includes('class="flow-bar"'));
200 expect(sparks).toHaveLength(PIPELINE.length);
201 for (const svg of sparks) {
202 expect(svg).toContain('aria-hidden="true"');
203 expect(svg).toContain('focusable="false"');
204 expect(svg).not.toContain("role=");
205 expect(svg).not.toContain("<a");
206 }
207 // The way in is the two counts per stage: last hour and 24 h.
208 for (const key of PIPELINE) {
209 const out = { ready: "started", building: "opened", "check-queue": "check-started", checking: "checked",
210 review: "reviewed", approved: "landed", landed: "released", live: "live" }[key];
211 expect(page).toContain(`href="/flow?out=${out}&amp;hour=0#out" data-hour="0"`);
212 expect(page).toMatch(new RegExp(`href="/flow\\?out=${out}#out" data-day=`));
213 }
214171 });
215172
216173 const mcpFlow = async (user: User) => {
@@ -266,17 +223,4 @@ describe("/flow: actual throughput per stage", () => {
266223 expect(pushed.map((s) => s.title)).toEqual(["Flow"]);
267224 expect(command(bob)).toBeUndefined();
268225 });
269
270 test("following a count lists the items it counted; a bad ask lists nothing", async () => {
271 const hour = await (await get("/flow?out=landed&hour=0")).text();
272 expect(hour).toContain('id="out"');
273 expect(hour).toContain("2 landed in the last hour");
274 expect(hour).toContain('href="/alice/shop/pulls/2"');
275 expect(hour).toContain('href="/alice/shop/pulls/4"');
276 expect(hour).not.toContain('href="/alice/shop/pulls/6"');
277 const day = await (await get("/flow?out=landed")).text();
278 expect(day).toContain("6 landed in the last 24 hours");
279 for (const bad of ["?out=nope", "?out=landed&hour=24", "?out=landed&hour=-1", "?out=landed&hour=1e1"])
280 expect(await (await get(`/flow${bad}`)).text()).not.toContain('id="out"');
281 });
282226 });
test/merge-queue.test.ts +2 −20
@@ -125,15 +125,6 @@ describe("the merge queue", () => {
125125 return pull;
126126 }
127127
128 const login = async (): Promise<string> => {
129 const res = await fetch(`${servers.url}/signin`, {
130 method: "POST",
131 redirect: "manual",
132 headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url },
133 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
134 });
135 return (res.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
136 };
137128 /** The MCP `flow` tool's `queue` field, as alice reads it. */
138129 const mcpQueue = async () => {
139130 const res = await fetch(`${servers.url}/mcp`, {
@@ -288,7 +279,7 @@ describe("the merge queue", () => {
288279 expect(released).toEqual([{ pull: pulls[1]!.number, tip: `tip-${pulls[1]!.number}` }]);
289280 });
290281
291 test("the queue shows through every door: /flow, the terminal and MCP, while gating and after", async () => {
282 test("the queue shows through every door: the terminal and MCP, while gating and after", async () => {
292283 const repo = await autonomousRepo("on-flow");
293284 const first = await greenPull(repo, "first.ts");
294285 const second = await greenPull(repo, "second.ts");
@@ -302,16 +293,7 @@ describe("the merge queue", () => {
302293 while (!queueStatus().some((q) => q.repoId === repo.id && q.queued === 2)) await Bun.sleep(5);
303294 const row = readQueues(app.db, new Date()).find((r) => r.repo === `alice/${repo.name}`);
304295 expect(row).toMatchObject({ queued: 2, gating: 1 });
305 const res = await fetch(`${servers.url}/flow`, {
306 headers: { cookie: await login() },
307 redirect: "manual",
308 });
309 expect(res.status).toBe(200);
310 const page = await res.text();
311 expect(page).toMatch(
312 /data-queue="alice\/on-flow">[\s\S]*?data-queued>2<[\s\S]*?data-gating>1<[\s\S]*?data-landed>0</,
313 );
314 // The terminal's Flow dialog and the MCP tool say the same.
296 // The terminal's Flow dialog and the MCP tool read the same rows.
315297 expect(terminalLine(repo)?.split(/\s+/)).toEqual([`alice/${repo.name}`, "2", "1", "0"]);
316298 expect(await mcpQueue()).toContainEqual({ repo: `alice/${repo.name}`, queued: 2, gating: 1, landedHour: 0 });
317299 held = undefined;
test/requested.test.ts −11
@@ -252,17 +252,6 @@ describe("a pull with changes requested always moves", () => {
252252 `1 pull with changes requested waits on a builder, oldest first: alice/garden#${current.number} `,
253253 );
254254
255 const signin = await fetch(`${servers.url}/signin`, {
256 method: "POST",
257 redirect: "manual",
258 headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url },
259 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
260 });
261 const cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
262 const page = await (await fetch(`${servers.url}/flow`, { headers: { cookie } })).text();
263 expect(page).toContain(`id="requested-builder"`);
264 expect(page).toContain(`waits on a reviewer, oldest first: alice/garden#${stale.number} `);
265
266255 // The terminal's Flow dialog says the same; an agent's is cut to public.
267256 const dialog = flowLines(app.db).join(" ");
268257 expect(dialog).toContain("waits on a builder");
test/system-telemetry.test.ts +4 −6
@@ -307,8 +307,6 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
307307 expect(html).toMatch(/id="summary"[^>]*>\s*<span class="pill"/);
308308 expect(html).toContain('<li data-kind="check"><div class="row">');
309309 expect(html).not.toContain("<table");
310 const flowPage = await fetch(`${servers.url}/flow`, { headers: { cookie: await login("alice") } });
311 expect(await flowPage.text()).toContain('id="duplicate-work" data-count="1"');
312310
313311 const reads = recentReads(app.db).filter((r) => r.username === "muse");
314312 expect(reads.map((r) => r.what)).toContain("system");
@@ -373,7 +371,7 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
373371 }
374372 });
375373
376 test("an admin agent reads flow only with the grant, in the page and the terminal, and sees the agent view", async () => {
374 test("an admin agent reads flow only with the grant, in the API and the terminal, and sees the agent view", async () => {
377375 const made = await createAgent(app, alice, { username: "zadminbot" });
378376 if (!made.ok) throw new Error(String(made.error));
379377 app.db.query("UPDATE user SET is_admin = 1 WHERE id = ?1").run(made.value.user.id);
@@ -385,11 +383,11 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
385383 const session = new Session(app, { sshUsername: "zadminbot", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: adminbot });
386384 return forgeCommands(session)(ctx).find((c) => c.id === "flow");
387385 };
388 expect((await get(token, "/flow")).status).toBe(404);
386 expect((await get(token, "/api/v1/telemetry/flow")).status).toBe(403);
389387 expect(flowCommand()).toBeUndefined();
390388
391389 expect(setTelemetryGrant(app, alice, "zadminbot", true).ok).toBe(true);
392 const page = await get(token, "/flow");
390 const page = await get(token, "/api/v1/telemetry/flow");
393391 expect(page.status).toBe(200);
394392 const text = await page.text();
395393 // (the page's palette index lists every repo an admin can open; the telemetry body must not)
@@ -399,7 +397,7 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
399397 expect(recentReads(app.db).some((r) => r.username === "zadminbot" && r.what === "flow")).toBe(true);
400398 // Revoked, the door closes again.
401399 setTelemetryGrant(app, alice, "zadminbot", false);
402 expect((await get(token, "/flow")).status).toBe(404);
400 expect((await get(token, "/api/v1/telemetry/flow")).status).toBe(403);
403401 });
404402
405403 test("in the terminal, the owner is offered System and Telemetry; nobody else is", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs