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

A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time #6291

Closed opened this in answer to
Closed without merging

scout/forge:scout/6286-a-weekly-design-wave-a-designer-role-pas → main 4 commits fork 4 threads · 4 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
12 files changed +459 −3
docs/CREW.md +6
@@ -75,6 +75,12 @@ is one, and its review brief holds the change to `docs/DESIGN.md`. A security
7575 change still goes to the security reviewer; a change only under `src/core/` is
7676 not a design matter.
7777
78 **The weekly design wave.** Set a crew member's role to "designs" (Settings →
79 Crew; the terminal and the MCP set no roles). Every Monday 08:00Z the autonomy
80 tick opens one `Design wave <week>` issue for it, creates the `design-ask`
81 label if missing, and the assignment starts its run. Rubric, scores and report:
82 `docs/design/areas/wave.md`.
83
7884 **How a reviewer is chosen.** Reviews go to the least-busy reviewer: the one
7985 with the fewest review runs in flight (queued or running). A tie goes to the
8086 experience reviewer. A pull about security goes only to a security reviewer
docs/design/areas/wave.md added +26
@@ -0,0 +1,26 @@
1 # The weekly design wave
2
3 A crew member whose role is **designer** (Settings → Crew, "designs") is given
4 one issue each week, `Design wave 2026-W44`, on Monday 08:00Z or the first
5 autonomy tick after it. The tick (`crew/wave.ts`) opens it once per ISO week,
6 found by its title, and assigns it to the designer. Builders never take it:
7 the held filter keeps it with the designer.
8
9 The issue body is the whole task (`design/wave.ts`): look at every top page and
10 every gallery component at 390 and 1440 px, light and dark, in and out;
11 score each surface on the rubric (clarity, hierarchy, density, consistency,
12 touch targets, contrast, motion, states; 1–5) into
13 `docs/design/waves/<week>.json`; fix small things as one pull per component or
14 page, shared component first; file bigger ideas as `design-ask` issues; end
15 with the wave report, scores this week against last (`trendLine`).
16
17 The wave opens the `design-ask` label if the repository lacks it. The
18 assignment is what starts the run (the same event as any agent's), and the run
19 carries `role: designer`. The role is set where every role is: Settings → Crew
20 (`POST /:owner/:name/settings/crew/:agent/role`, which takes any `CREW_ROLES`
21 member); the terminal and the MCP set no role, so there is nothing to add there.
22
23 Nothing here restyles anything by itself, and a design that makes a page harder
24 to read in one glance does not land. Not built yet: the report on the home
25 feed, a screenshot diff in the check, and the first wave's targets (tabs, repo
26 header, home feed, Migrate, app template shell), which the first wave does.
docs/design/waves/README.md added +4
@@ -0,0 +1,4 @@
1 One file per wave week, `2026-W44.json`, written by the designer's pull:
2 `{"week":"2026-W44","scores":{"/":{"clarity":4,...}}}`, every surface scored 1–5
3 on the eight criteria of `src/design/wave.ts`. `test/wave.test.ts` refuses a
4 file that is not whole. The first wave writes the first file.
src/core/agents.ts +4 −2
@@ -276,14 +276,16 @@ export function deleteAgent(db: Database, userId: string): boolean {
276276 /**
277277 * What a crew member is for on one repository: a builder takes what is
278278 * ready, a planner turns a direction into a map, a reviewer looks at what
279 * landed. Per repository, because the same agent may plan one and build
279 * landed, a designer looks at every page each week and fixes what it
280 * finds. Per repository, because the same agent may plan one and build
280281 * another.
281282 */
282 export type CrewRole = "builder" | "planner" | "reviewer";
283 export type CrewRole = "builder" | "planner" | "reviewer" | "designer";
283284 export const CREW_ROLES: readonly CrewRole[] = [
284285 "builder",
285286 "planner",
286287 "reviewer",
288 "designer",
287289 ];
288290 export const isCrewRole = (value: unknown): value is CrewRole =>
289291 (CREW_ROLES as readonly unknown[]).includes(value);
src/crew/autonomy.ts +17
@@ -123,6 +123,8 @@ import {
123123 markReaders,
124124 } from "./direct.ts";
125125 import { crewOffInPreview } from "./preview.ts";
126 import { driveWave } from "./wave.ts";
127 import { isWaveTitle } from "../design/wave.ts";
126128 import { approvedOnHead, finishApproved, finishFields } from "./finishing.ts";
127129 import { readVitals, vitalsMisses, vitalsWords } from "../flow/vitals.ts";
128130 import { moveRequested, tallyRequested, tallyWords } from "./requested.ts";
@@ -459,6 +461,8 @@ export async function driveRepo(
459461 export function freeParked(app: App, repo: Repo, by: User, held: Held): number {
460462 let freed = 0;
461463 for (const issue of held.by.planner) {
464 // The week's design wave is the designer's, never a builder's.
465 if (isWaveTitle(issue.title)) continue;
462466 const cleared = assignIssue(app, by, repo, issue, null);
463467 if (!cleared.ok) {
464468 log.warn("could not free an issue parked on a non-builder", {
@@ -1224,6 +1228,19 @@ export async function autonomyTick(
12241228 const requested = await moveRequested(app, current, freeSlots(app, current, now), now);
12251229 const unstuck = unstickNow(app, current, now);
12261230 const did = await driveRepo(app, current, now);
1231 // The weekly design wave: one issue for the designer, when due.

Adds work to the autonomy tick while flow is the only priority. Even guarded, it widens the hot path the flow fixes depend on.

1232 // Guarded: a failure here must never stall the tick for other repos.
1233 if (did !== "off" && did !== "paused" && current.autonomyBy !== null) {
1234 try {
1235 const by = getUserById(app.db, current.autonomyBy);
1236 if (by) driveWave(app, current, by, listCrewRoles(app.db, current.id), now);
1237 } catch (error) {
1238 log.error("design wave failed", {
1239 repo: `${repo.ownerName}/${repo.name}`,
1240 error: String(error),
1241 });
1242 }
1243 }
12271244 // Rules only, no run: an issue noted already done on the base closes.
12281245 const triaged = await liveTriage(app, current, now).catch((error) => {
12291246 log.error("live triage failed", {
src/crew/brief.ts +2
@@ -10,6 +10,7 @@
1010 import type { OwnApp } from "./app_hosts.ts";
1111 import type { Owed } from "./team_share.ts";
1212 import type { Agent, CrewRole } from "../core/agents.ts";
13 import { DESIGNER_LINES } from "../design/wave.ts";
1314 import type { Comment, Issue } from "../core/issues.ts";
1415 import type { Pull } from "../core/pulls.ts";
1516 import { saysFromApp } from "../actions/app_notes.ts";
@@ -148,6 +149,7 @@ export function systemPrompt(input: BriefInput): string {
148149 "- Finish with a short message that lists what you opened, in order, and what is ready now.",
149150 );
150151 }
152 if (input.role === "designer") lines.push("", ...DESIGNER_LINES);
151153 if (input.isApp) {
152154 lines.push(
153155 "",
src/crew/held.ts +4
@@ -28,6 +28,7 @@
2828 */
2929
3030 import type { App } from "../app.ts";
31 import { isWaveTitle } from "../design/wave.ts";
3132 import { listCrewRoles, type Agent, type CrewRole } from "../core/agents.ts";
3233 import { readyNow, repoGraph, type Ranked } from "../core/dependencies.ts";
3334 import { alreadyDone, BY_CREW, DONE_LIKE } from "../core/done_on_main.ts";
@@ -123,12 +124,15 @@ export function heldBy(
123124 const planners = new Set(
124125 crew.filter((c) => c.role !== "builder").map((c) => c.agent.user.id),
125126 );
127 // A wave issue is the designer's only while a designer is on the crew.
128 const hasDesigner = crew.some((c) => c.role === "designer");
126129 const handed = withPlanner(app.db, repo);
127130 const hot = hotFiles(repo.id);
128131 const holdOf = (issue: Issue): HoldName | null => {
129132 if (busyIssues.has(issue.id)) return "running";
130133 if (proposed.has(issue.number)) return "open_pull";
outdated

Held as "planner" for every wave title, whether or not a designer exists. Check that a designer is on the crew first, or an orphaned wave issue is stuck.

131134 if (issue.assigneeId !== null && planners.has(issue.assigneeId)) return "planner";
135 if (hasDesigner && isWaveTitle(issue.title)) return "planner";
132136 if (handed.has(issue.id)) return "with_planner";
133137 if (alreadyDone(app.db, [issue.id]).has(issue.id)) return "done_on_main";
134138 if (stalled(app, repo, issue)) return "stalled";
src/crew/wave.ts added +77
@@ -0,0 +1,77 @@
1 /**

New feature module during FLOW ONLY. Park until the #5930 alarms are clear.

2 * The weekly design wave, as the autonomy tick sees it: on Monday 08:00Z
3 * (or the first tick after) a repository with a designer on its crew gets
4 * one issue for the week, assigned to the designer, whose run does the wave
5 * (`design/wave.ts` says what it is). One issue per week, found by its
6 * title, so a restart or a second tick opens nothing twice.
7 */
8
9 import type { App } from "../app.ts";
10 import { assignIssue, openIssue } from "../actions/issues.ts";
11 import type { Agent, CrewRole } from "../core/agents.ts";
12 import type { Repo } from "../core/repos.ts";
13 import type { User } from "../core/users.ts";
14 import { createLabel, getLabel } from "../core/issues.ts";
15 import {
16 ASK_LABEL,
17 WAVE_PREFIX,
18 isWaveTitle,
19 waveBody,
20 waveStarted,
21 waveTitle,
22 weekOf,
23 } from "../design/wave.ts";
24 import { createLog } from "../kernel/log.ts";
25
26 const log = createLog("wave");
27
28 /** The week before, as the files name it, from the wave issues that exist. */
29 function previousWeek(titles: readonly string[], week: string): string | undefined {
30 return titles
31 .filter(isWaveTitle)
32 .map((t) => t.slice(WAVE_PREFIX.length))
33 .filter((w) => w < week)
outdated

This opens and assigns the issue, but nothing downstream starts a designer run on it. Wire the dispatch in autonomy and test it.

34 .sort()
35 .pop();
36 }
37
38 /** Opens this week's wave when it is due; true when it did. */
39 export function driveWave(
40 app: App,
41 repo: Repo,
42 by: User,
43 crew: readonly { agent: Agent; role: CrewRole }[],
44 now: Date,
45 ): boolean {
46 const designer = crew.find((c) => c.role === "designer")?.agent;
47 if (designer === undefined || !waveStarted(now)) return false;
48 const week = weekOf(now);
49 const titles = app.db
50 .query<{ title: string }, [string, string]>(
51 "SELECT title FROM issue WHERE repo_id = ?1 AND title LIKE ?2",
52 )
53 .all(repo.id, `${WAVE_PREFIX}%`)
54 .map((r) => r.title);
55 if (titles.includes(waveTitle(week))) return false;
56 // The label the brief tells the designer to file asks under.
57 if (!getLabel(app.db, repo.id, ASK_LABEL.name))
58 createLabel(app.db, repo.id, ASK_LABEL.name, ASK_LABEL.color);
59 const opened = openIssue(app, by, repo, {
60 title: waveTitle(week),
61 body: waveBody(week, previousWeek(titles, week)),
62 });
63 if (!opened.ok) {
64 log.warn("could not open the design wave", {
65 repo: `${repo.ownerName}/${repo.name}`,
66 error: opened.error,
67 });
68 return false;
69 }
70 const assigned = assignIssue(app, by, repo, opened.value, designer.user);
71 if (!assigned.ok)
72 log.warn("could not assign the design wave", {
73 repo: `${repo.ownerName}/${repo.name}`,
74 error: assigned.error,
75 });
76 return assigned.ok;
77 }
src/design/wave.ts added +147
@@ -0,0 +1,147 @@
1 /**
2 * The weekly design wave: the fixed rubric, the week it belongs to, when it
3 * is due, the brief the designer is handed and the shape of the scores it
4 * keeps (`docs/design/waves/<year>-W<week>.json`, one file per week, in git
5 * like everything else). Pure data: `crew/wave.ts` opens the issue.
6 */
7
8 /** Scored 1–5 for every surface, in this order. */
9 export const RUBRIC = [
10 "clarity",
11 "hierarchy",
12 "density",
13 "consistency",
14 "touch",
15 "contrast",
16 "motion",
17 "states",
18 ] as const;
19 export type Criterion = (typeof RUBRIC)[number];
20
21 export const RUBRIC_WORDS: Record<Criterion, string> = {
22 clarity: "clarity: one glance says what this is and what to do",
23 hierarchy: "hierarchy: the eye lands on the right thing first",
24 density: "density: neither cramped nor empty",
25 consistency: "consistency: made of the gallery's components, no one-offs",
26 touch: "touch targets: 44 px reachable, no mis-taps at 390 px",
27 contrast: "contrast: readable in light and dark",
28 motion: "motion: feedback is instant, nothing jumps or shifts",
29 states: "states: empty, loading and error are designed, not blank",
30 };
31
32 /** Looked at every week, at 390 and 1440 px, light and dark, in and out. */
33 export const VIEWPORTS = [390, 1440] as const;
34
35 /** Monday 08:00 UTC. */
36 export const WAVE_DAY = 1;
37 export const WAVE_HOUR = 8;
38
39 export const WAVE_PREFIX = "Design wave ";
40
41 /** The week a moment falls in, ISO 8601, as `2026-W44`. */
42 export function weekOf(now: Date): string {
43 const d = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
44 const day = d.getUTCDay() || 7;
45 d.setUTCDate(d.getUTCDate() + 4 - day);
46 const year = d.getUTCFullYear();
47 const first = Date.UTC(year, 0, 1);
48 const week = Math.ceil(((d.getTime() - first) / 86_400_000 + 1) / 7);
49 return `${year}-W${String(week).padStart(2, "0")}`;
50 }
51
52 /** This week's wave has started: Monday 08:00Z or later, in the ISO week. */
53 export function waveStarted(now: Date): boolean {
54 const day = now.getUTCDay() || 7;
55 return day > WAVE_DAY || (day === WAVE_DAY && now.getUTCHours() >= WAVE_HOUR);
56 }
57
58 export const waveTitle = (week: string): string => `${WAVE_PREFIX}${week}`;
59 const WAVE_TITLE = new RegExp(`^${WAVE_PREFIX}\\d{4}-W\\d{2}$`);
60 export const isWaveTitle = (title: string): boolean => WAVE_TITLE.test(title);
61
62 /** The label the designer files its bigger ideas under. */
63 export const ASK_LABEL = { name: "design-ask", color: "7c3aed" } as const;
64
65 export type Scores = Record<string, Record<Criterion, number>>;
66
67 export interface WaveFile {
68 readonly week: string;
69 readonly scores: Scores;
70 }
71
72 /** What is wrong with a week's score file, or undefined when it is whole. */
73 export function scoreProblem(value: unknown): string | undefined {
74 if (typeof value !== "object" || value === null) return "not an object";
75 const file = value as Record<string, unknown>;
76 if (typeof file.week !== "string" || !/^\d{4}-W\d{2}$/.test(file.week))
77 return "week must look like 2026-W44";
78 const scores = file.scores;
79 if (typeof scores !== "object" || scores === null || Array.isArray(scores))
80 return "scores must map a surface to its marks";
81 for (const [surface, marks] of Object.entries(scores)) {
82 if (!/^\/[\w\-./]*$/.test(surface))
83 return `surface ${JSON.stringify(surface).slice(0, 40)} must be a path`;
84 if (typeof marks !== "object" || marks === null)
85 return `${surface}: marks must be an object`;
86 const given = marks as Record<string, unknown>;
87 for (const c of RUBRIC) {
88 const n = given[c];
89 if (!Number.isInteger(n) || (n as number) < 1 || (n as number) > 5)
90 return `${surface}: ${c} must be a whole number 1–5`;
91 }
92 if (Object.keys(given).length !== RUBRIC.length)
93 return `${surface}: only ${RUBRIC.join(", ")}`;
94 }
95 return undefined;
96 }
97
98 /** The mean of every mark of every surface, to one decimal; 0 with none. */
99 export function average(scores: Scores): number {
100 const all = Object.values(scores).flatMap((m) => RUBRIC.map((c) => m[c]));
101 if (all.length === 0) return 0;
102 return Math.round((all.reduce((a, b) => a + b, 0) / all.length) * 10) / 10;
103 }
104
105 /** One line for the wave report: this week against last. */
106 export function trendLine(now: Scores, before: Scores | undefined): string {
107 const mean = average(now);
108 if (before === undefined || Object.keys(before).length === 0)
109 return `Rubric average ${mean} (first wave scored).`;
110 const last = average(before);
111 const delta = Math.round((mean - last) * 10) / 10;
112 const word = delta > 0 ? "up" : delta < 0 ? "down" : "level";
113 return `Rubric average ${mean}, ${word}${delta === 0 ? "" : ` ${Math.abs(delta)}`} from ${last}.`;
114 }
115
116 /** The first wave's targets, named by the owner; later waves read the asks. */
117 export const FIRST_TARGETS = [
118 "the horizontal tabs: one component, a clear active state, good hit targets, overflow on phones, arrow keys",
119 "the repo header",
120 "the home feed",
121 "Migrate",
122 "the app template shell",
123 ] as const;
124
125 /** The issue body: the whole task, so the run needs nothing else. */
126 export function waveBody(week: string, previous: string | undefined): string {
127 return [
128 `The weekly design wave for ${week}. You are the designer: taste, hierarchy, spacing, motion and accessibility, with the forge's design system (docs/DESIGN.md, the gallery at /design/components) as the source of truth. Never hand-roll a one-off.`,
129 "",
130 "1. **Look**, in a real browser: every top page and every component in /design/components, at 390 px and 1440 px, light and dark, signed in and anonymous. Attach the screenshots.",
131 `2. **Score** each surface 1–5 on: ${RUBRIC.map((c) => RUBRIC_WORDS[c]).join("; ")}. Commit them as docs/design/waves/${week}.json: {"week":"${week}","scores":{"/path":{${RUBRIC.map((c) => `"${c}":n`).join(",")}}}}.${previous === undefined ? "" : ` Last week's are in docs/design/waves/${previous}.json: compare.`}`,
132 "3. **Fix** small, self-contained things; prefer the shared component to a per-page patch; one component or page per pull, with before and after screenshots. Never a big-bang restyle, and nothing that makes a page harder to read in one glance (the cold-read targets).",
133 "4. **Ask**: file the bigger ideas as issues labelled `design-ask`, each with the problem, a sketch or reference, and why it matters.",
134 "5. **Report**: your last message is the wave report: scores this week against last, what changed, the top asks.",
135 "",
136 `First targets: ${FIRST_TARGETS.join("; ")}.`,
137 ].join("\n");
138 }
139
140 /** The lines the designer's brief adds to the shared one. */
141 export const DESIGNER_LINES: readonly string[] = [
142 "You are this repository's designer, and your run is a design wave or a design fix:",
143 "- Taste, hierarchy, spacing, motion and accessibility, with docs/DESIGN.md and the gallery at /design/components as the source of truth. Use the shared components; a new one is named in docs/design/areas/<area>.md.",
144 "- Run `bun scripts/design-lint.ts` before you push; the one-offs outside the components must fall, never rise.",
145 "- Small pulls, one component or page each, never a restyle of everything; a page must not get harder to read in one glance.",
146 "- Look at the previews of the open pulls and the production app with the screenshots the forge's looks give you; say what you saw.",
147 ];
src/web/studio/app.ts +3 −1
@@ -388,7 +388,9 @@ export async function studioApp(
388388 ? "builds"
389389 : c.role === "planner"
390390 ? "plans"
391 : "reviews"}`,
391 : c.role === "designer"
392 ? "designs"
393 : "reviews"}`,
392394 }),
393395 ),
394396 {
src/web/studio/crew.ts +1
@@ -55,6 +55,7 @@ const ROLE_WORD: Record<CrewRole, string> = {
5555 builder: "builds",
5656 reviewer: "reviews",
5757 planner: "plans",
58 designer: "designs",
5859 };
5960
6061 /**
test/wave.test.ts added +168
@@ -0,0 +1,168 @@
1 import { describe, expect, test } from "bun:test";
2 import { readdirSync, readFileSync } from "node:fs";
3 import {
4 RUBRIC,
5 average,
6 isWaveTitle,
7 scoreProblem,
8 trendLine,
9 waveBody,
10 waveStarted,
11 waveTitle,
12 weekOf,
13 } from "../src/design/wave.ts";
14 import { mkdtemp, rm } from "node:fs/promises";
15 import { tmpdir } from "node:os";
16 import { join } from "node:path";
17 import { createApp } from "../src/app.ts";
18 import { addToCrew, createAgent } from "../src/actions/crew.ts";
19 import { createRepo } from "../src/actions/repos.ts";
20 import { isCrewRole, listCrewRoles, setCrewRole } from "../src/core/agents.ts";
21 import { getIssue, getLabel } from "../src/core/issues.ts";
22 import { createUser, getUserByName } from "../src/core/users.ts";
23 import { heldBy } from "../src/crew/held.ts";
24 import { driveWave } from "../src/crew/wave.ts";
25 import { startCrew } from "../src/crew/dispatch.ts";
26 import { listRuns } from "../src/core/runs.ts";
27 import { serve } from "../src/http/server.ts";
28 import { systemPrompt } from "../src/crew/brief.ts";
29
30 const marks = (n: number): Record<(typeof RUBRIC)[number], number> =>
31 Object.fromEntries(RUBRIC.map((c) => [c, n])) as Record<(typeof RUBRIC)[number], number>;
32
33 describe("the design wave's calendar", () => {
34 test("the ISO week, across a year's edge", () => {
35 expect(weekOf(new Date("2026-10-26T08:00:00Z"))).toBe("2026-W44");
36 expect(weekOf(new Date("2026-12-31T12:00:00Z"))).toBe("2026-W53");
37 expect(weekOf(new Date("2027-01-03T12:00:00Z"))).toBe("2026-W53");
38 expect(weekOf(new Date("2027-01-04T00:00:00Z"))).toBe("2027-W01");
39 });
40 test("it starts Monday 08:00Z and stays due all week", () => {
41 expect(waveStarted(new Date("2026-10-26T07:59:00Z"))).toBe(false);
42 expect(waveStarted(new Date("2026-10-26T08:00:00Z"))).toBe(true);
43 expect(waveStarted(new Date("2026-10-29T03:00:00Z"))).toBe(true);
44 expect(waveStarted(new Date("2026-11-01T23:00:00Z"))).toBe(true);
45 });
46 test("the title names the week and nothing else counts as one", () => {
47 expect(isWaveTitle(waveTitle("2026-W44"))).toBe(true);
48 expect(isWaveTitle("Design wave 2026-W44 please")).toBe(false);
49 expect(isWaveTitle("Fix the tabs")).toBe(false);
50 });
51 });
52
53 describe("the scores", () => {
54 test("a whole file passes, a bad mark names itself", () => {
55 expect(scoreProblem({ week: "2026-W44", scores: { "/": marks(3) } })).toBeUndefined();
56 expect(scoreProblem({ week: "2026-W44", scores: { "/": { ...marks(3), motion: 6 } } })).toContain("motion");
57 expect(scoreProblem({ week: "2026-W44", scores: { "/": { ...marks(3), extra: 1 } } })).toContain("only");
58 expect(scoreProblem({ week: "week 44", scores: {} })).toContain("week");
59 expect(scoreProblem({ week: "2026-W44", scores: { "<b>": marks(3) } })).toContain("path");
60 });
61 test("every kept week's file is whole", () => {
62 for (const f of readdirSync("docs/design/waves").filter((n) => n.endsWith(".json")))
63 expect(scoreProblem(JSON.parse(readFileSync(`docs/design/waves/${f}`, "utf8")))).toBeUndefined();
64 });
65 test("the trend says up, down or first", () => {
66 expect(average({ "/": marks(4), "/a": marks(2) })).toBe(3);
67 expect(trendLine({ "/": marks(4) }, { "/": marks(3) })).toBe("Rubric average 4, up 1 from 3.");
68 expect(trendLine({ "/": marks(2) }, { "/": marks(3) })).toContain("down 1");
69 expect(trendLine({ "/": marks(3) }, undefined)).toContain("first wave");
70 });
71 });
72
73 describe("the designer", () => {
74 test("is a crew role, and its brief and the wave's issue carry the task", () => {
75 expect(isCrewRole("designer")).toBe(true);
76 const body = waveBody("2026-W44", "2026-W43");
77 for (const c of RUBRIC) expect(body).toContain(c);
78 expect(body).toContain("design-ask");
79 expect(body).toContain("2026-W43.json");
80 expect(body).toContain("horizontal tabs");
81 });
82 test("its system prompt is the designer's, and a builder's is not", () => {
83 const base = {
84 agent: { user: { username: "pixel", displayName: "Pixel" }, brief: "" },
85 repo: { ownerName: "o", name: "r", defaultBranch: "main" },
86 issue: { number: 1, title: "t", body: "" },
87 branch: "b",
88 forgeUrl: "https://f",
89 resuming: false,
90 isApp: true,
91 } as unknown as Parameters<typeof systemPrompt>[0];
92 expect(systemPrompt({ ...base, role: "designer" })).toContain("repository's designer");
93 expect(systemPrompt({ ...base, role: "builder" })).not.toContain("repository's designer");
94 });
95 });
96
97 describe("opening the wave", () => {
98 test("one issue a week, for the designer, once Monday 08:00Z has come", async () => {
99 const dir = await mkdtemp(join(tmpdir(), "forge-wave-"));
100 const app = createApp({ dataDir: dir, port: 0 });
101 const servers = await serve(app);
102 const crewUp = await startCrew(app, {
103 forgeUrl: servers.url,
104 localUrl: servers.url,
105 binary: "/nonexistent/claude",
106 concurrency: 1,
107 budgetUsd: 1,
108 runTimeoutMs: 60_000,
109 });
110 try {
111 const made = await createUser(app.db, { origin: "seed", trusted: true,
112 username: "alice",
113 email: "[email protected]",
114 password: "a-good-passphrase",
115 adminIfFirst: true,
116 });
117 if (!made.ok) throw new Error(made.error);
118 const alice = made.value;
119 const r = await createRepo(app, alice, { name: "ui", visibility: "private" });
120 if (!r.ok) throw new Error(String(r.error));
121 const repo = r.value;
122 for (const name of ["pixel", "mason"])
123 await createAgent(app, alice, { username: name });
124 expect(addToCrew(app, alice, repo, "pixel").ok).toBe(true);
125 expect(addToCrew(app, alice, repo, "mason").ok).toBe(true);
126 const crew = () => listCrewRoles(app.db, repo.id);
127 const wave = (at: string) => driveWave(app, repo, alice, crew(), new Date(at));
128 const count = () =>
129 app.db.query<{ n: number }, [string]>("SELECT count(*) n FROM issue WHERE repo_id = ?1 AND title LIKE 'Design wave %'").get(repo.id)!.n;
130
131 // No designer on the crew: no wave.
132 expect(wave("2026-10-26T09:00:00Z")).toBe(false);
133 setCrewRole(app.db, repo.id, getUserByName(app.db, "pixel")!.id, "designer");
134 expect(wave("2026-10-26T07:00:00Z")).toBe(false);
135 expect(wave("2026-10-26T09:00:00Z")).toBe(true);
136 expect(wave("2026-10-27T09:00:00Z")).toBe(false);
137 expect(count()).toBe(1);
138 expect(getLabel(app.db, repo.id, "design-ask")).toBeDefined();
139 // The assignment is what starts the designer's run, once; the tick
140 // that finds the week's issue already open starts no second.
141 await Bun.sleep(300);
142 const pixel = getUserByName(app.db, "pixel")!;
143 const runsOf = () =>
144 listRuns(app.db, repo.id).filter((x) => x.actorId === pixel.id);
145 expect(runsOf()).toHaveLength(1);
146 expect(wave("2026-10-28T09:00:00Z")).toBe(false);
147 await Bun.sleep(100);
148 expect(runsOf()).toHaveLength(1);
149 const opened = getIssue(app.db, repo.id, 1)!;
150 expect(opened.title).toBe("Design wave 2026-W44");
151 expect(opened.assigneeId).toBe(getUserByName(app.db, "pixel")!.id);
152 // The next week gets its own, naming last week's scores.
153 expect(wave("2026-11-02T08:00:00Z")).toBe(true);
154 expect(getIssue(app.db, repo.id, 2)!.body).toContain("2026-W44.json");
155 expect(count()).toBe(2);
156 // Held for the designer while one is on the crew; free once the role goes.
157 const ready = [getIssue(app.db, repo.id, 1)!].map((issue) => ({ issue, holdsUp: 0, waitsFor: 0 }));
158 expect(heldBy(app, repo, ready, crew(), []).by.planner).toHaveLength(1);
159 setCrewRole(app.db, repo.id, pixel.id, "builder");
160 expect(heldBy(app, repo, ready, crew(), []).by.planner).toHaveLength(0);
161 } finally {
162 await crewUp.stop();
163 servers.stop();
164 app.close();
165 await rm(dir, { recursive: true, force: true });
166 }
167 });
168 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs