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 #16253
Check · Review · Land · Live — Its check is red.
scout/forge:scout/6286-a-weekly-design-wave-a-designer-role-pas → main 9 commits fork 3 threads · 3 unresolved
13 files
changed +378
−8
docs/CREW.md +2
| @@ -90,6 +90,8 @@ is one, and its review brief holds the change to `docs/DESIGN.md`. A security | ||
| 90 | 90 | change still goes to the security reviewer; a change only under `src/core/` is |
| 91 | 91 | not a design matter. |
| 92 | 92 | |
| 93 | **The weekly design wave.** A crew member set to "designs" gets one `Design wave <week>` issue every Monday: `docs/features/design-wave.md`. | |
| 94 | ||
| 93 | 95 | **How a reviewer is chosen.** Reviews go to the least-busy reviewer: the one |
| 94 | 96 | with the fewest review runs in flight (queued or running). A tie goes to the |
| 95 | 97 | experience reviewer. A pull about security goes only to a security reviewer |
docs/features/design-wave.md added +13
| @@ -0,0 +1,13 @@ | ||
| 1 | --- | |
| 2 | topic: The crew | |
| 3 | row: The weekly design wave | |
| 4 | --- | |
| 5 | # The weekly design wave | |
| 6 | ||
| 7 | A crew member whose role is **designer** (Settings → Crew, "designs") is given one issue each week, `Design wave 2026-W44`, on Monday 08:00Z or the first autonomy tick after it. The tick (`src/crew/wave.ts`) opens it once per ISO week, found by its title, and assigns it to the designer. The assignment starts the run (the same event as any agent's) and the run carries `role: designer`. Builders never take the issue: the held filter keeps it with the designer, and releases it once no designer is on the crew. The tick also creates the `design-ask` label if the repository lacks it. | |
| 8 | ||
| 9 | The issue body is the whole task (`src/design/wave.ts`): look at every top page and every gallery component at 390 and 1440 px, light and dark, signed in and out; score each surface 1–5 on clarity, hierarchy, density, consistency, touch targets, contrast, motion and states into `docs/design/waves/<week>.json` (`{"week":"2026-W44","scores":{"/":{"clarity":4,…}}}`); fix small things as one pull per component or page, shared component first; file bigger ideas as `design-ask` issues; end with a wave report, this week's scores against last. | |
| 10 | ||
| 11 | The role is set where every role is: `POST /:owner/:name/settings/crew/:agent/role`, which takes any `CREW_ROLES` member. The terminal and the MCP set no role, for any role, so the designer has no door of its own there. | |
| 12 | ||
| 13 | Not built: validating the score files, a trend line in the report, a screen in the terminal for the week's wave, and a report on the home feed. They wait for the pull that scores. |
src/core/agents.ts +9 −2
| @@ -303,15 +303,22 @@ export function deleteAgent(db: Database, userId: string): boolean { | ||
| 303 | 303 | /** |
| 304 | 304 | * What a crew member is for on one repository: a builder takes what is |
| 305 | 305 | * ready, a planner turns a direction into a map, a reviewer looks at what |
| 306 | * landed. Per repository, because the same agent may plan one and build | |
| 306 | * landed, a designer looks at every page each week and fixes what it | |
| 307 | * finds. Per repository, because the same agent may plan one and build | |
| 307 | 308 | * another. |
| 308 | 309 | */ |
| 309 | export type CrewRole = "builder" | "planner" | "reviewer" | "maintainer"; | |
| 310 | export type CrewRole = | |
| 311 | | "builder" | |
| 312 | | "planner" | |
| 313 | | "reviewer" | |
| 314 | | "maintainer" | |
| 315 | | "designer"; | |
| 310 | 316 | export const CREW_ROLES: readonly CrewRole[] = [ |
| 311 | 317 | "planner", |
| 312 | 318 | "builder", |
| 313 | 319 | "reviewer", |
| 314 | 320 | "maintainer", |
| 321 | "designer", | |
| 315 | 322 | ]; |
| 316 | 323 | export const isCrewRole = (value: unknown): value is CrewRole => |
| 317 | 324 | (CREW_ROLES as readonly unknown[]).includes(value); |
src/crew/autonomy.ts +17
| @@ -145,6 +145,8 @@ import { foldWall } from "./fold_walls.ts"; | ||
| 145 | 145 | import { guardedList } from "./stranger.ts"; |
| 146 | 146 | import { warnExpiring } from "./fold_in.ts"; |
| 147 | 147 | import { crewOffInPreview } from "./preview.ts"; |
| 148 | import { driveWave } from "./wave.ts"; | |
| 149 | import { isWaveTitle } from "../design/wave.ts"; | |
| 148 | 150 | import { approvedOnHead, finishApproved, finishFields } from "./finishing.ts"; |
| 149 | 151 | import { isFirstChange, reviewComing, sayFirstLanded } from "./first_change.ts"; |
| 150 | 152 | import { recheckRedApproved } from "./red_approved.ts"; |
| @@ -627,6 +629,8 @@ export function noteRedThrice(app: App, repo: Repo, by: User): number { | ||
| 627 | 629 | export function freeParked(app: App, repo: Repo, by: User, held: Held): number { |
| 628 | 630 | let freed = 0; |
| 629 | 631 | for (const issue of held.by.planner) { |
| 632 | // The week's design wave is the designer's, never a builder's. | |
| 633 | if (isWaveTitle(issue.title)) continue; | |
| 630 | 634 | const cleared = assignIssue(app, by, repo, issue, null); |
| 631 | 635 | if (!cleared.ok) { |
| 632 | 636 | log.warn("could not free an issue parked on a non-builder", { |
| @@ -1435,6 +1439,19 @@ export async function autonomyTick( | ||
| 1435 | 1439 | const unstuck = unstickNow(app, current, now); |
| 1436 | 1440 | const did = await driveOrBeat(app, current, now, picked, driveRepo); |
| 1437 | 1441 | await breathe(); |
| 1442 | // The weekly design wave: one issue for the designer, when due. | |
| 1443 | // Guarded: a failure here must never stall the tick for other repos. | |
| 1444 | if (did !== "off" && did !== "paused" && current.autonomyBy !== null) { | |
| 1445 | try { | |
| 1446 | const by = getUserById(app.db, current.autonomyBy); | |
| 1447 | if (by) driveWave(app, current, by, listCrewRoles(app.db, current.id), now); | |
| 1448 | } catch (error) { | |
| 1449 | log.error("design wave failed", { | |
| 1450 | repo: `${repo.ownerName}/${repo.name}`, | |
| 1451 | error: String(error), | |
| 1452 | }); | |
| 1453 | } | |
| 1454 | } | |
| 1438 | 1455 | // Rules only, no run: an issue noted already done on the base closes. |
| 1439 | 1456 | const triaged = await liveTriage(app, current, now).catch((error) => { |
| 1440 | 1457 | log.error("live triage failed", { |
src/crew/brief.ts +2
| @@ -11,6 +11,7 @@ import { machineNote, type Machine } from "./machines.ts"; | ||
| 11 | 11 | import type { OwnApp } from "./app_hosts.ts"; |
| 12 | 12 | import type { Owed } from "./team_share.ts"; |
| 13 | 13 | import type { Agent, CrewRole } from "../core/agents.ts"; |
| 14 | import { DESIGNER_LINES } from "../design/wave.ts"; | |
| 14 | 15 | import type { Comment, Issue } from "../core/issues.ts"; |
| 15 | 16 | import type { Pull } from "../core/pulls.ts"; |
| 16 | 17 | import { saysFromApp } from "../actions/app_notes.ts"; |
| @@ -220,6 +221,7 @@ export function systemPrompt(input: BriefInput): string { | ||
| 220 | 221 | "- Finish with a short message that lists what you opened, in order, and what is ready now.", |
| 221 | 222 | ); |
| 222 | 223 | } |
| 224 | if (input.role === "designer") lines.push("", ...DESIGNER_LINES); | |
| 223 | 225 | if (input.isApp) { |
| 224 | 226 | lines.push( |
| 225 | 227 | "", |
src/crew/dispatch.ts +2
| @@ -454,6 +454,8 @@ export function outsideSeat( | ||
| 454 | 454 | const own = held ?? agent.roles[0]; |
| 455 | 455 | return own === "planner" || own === "maintainer"; |
| 456 | 456 | } |
| 457 | // A designer takes the week's wave issue, which is design work, not building. | |
| 458 | if (held === "designer" && seat === "builder") return false; | |
| 457 | 459 | return held === undefined ? !agent.roles.includes(seat) : held !== seat; |
| 458 | 460 | } |
| 459 | 461 |
src/crew/held.ts +4
| @@ -52,6 +52,7 @@ | ||
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | 54 | import type { App } from "../app.ts"; |
| 55 | import { isWaveTitle } from "../design/wave.ts"; | |
| 55 | 56 | import { listCrewRoles, type Agent, type CrewRole } from "../core/agents.ts"; |
| 56 | 57 | import { readyNow, repoGraph, type Graph, type Ranked } from "../core/dependencies.ts"; |
| 57 | 58 | import { alreadyDone, BY_CREW, DONE_LIKE, unticked } from "../core/done_on_main.ts"; |
| @@ -218,6 +219,8 @@ export function heldBy( | ||
| 218 | 219 | const planners = new Set( |
| 219 | 220 | crew.filter((c) => c.role !== "builder").map((c) => c.agent.user.id), |
| 220 | 221 | ); |
| 222 | // A wave issue is the designer's only while a designer is on the crew. | |
| 223 | const hasDesigner = crew.some((c) => c.role === "designer"); | |
| 221 | 224 | const builders = crew.filter((c) => c.role === "builder").map((c) => c.agent.user.username); |
| 222 | 225 | // Read once for the whole pass, matched per issue in memory (#10445). |
| 223 | 226 | const fresh = builders.length === 0 ? [] : freshPulls(app.db, repo.id); |
| @@ -290,6 +293,7 @@ export function heldBy( | ||
| 290 | 293 | if (reds.has(issue.number)) return "red_thrice"; |
| 291 | 294 | if (proposed.has(issue.number)) return "open_pull"; |
| 292 | 295 | if (issue.assigneeId !== null && planners.has(issue.assigneeId)) return "planner"; |
| 296 | if (hasDesigner && isWaveTitle(issue.title)) return "planner"; | |
| 293 | 297 | if (handed.has(issue.id)) return "with_planner"; |
| 294 | 298 | // A landing that left boxes names what remains (#15289); its own done note waits behind it. |
| 295 | 299 | if (landedUnanswered(app.db, repo, issue) !== undefined) return "landed"; |
src/crew/seat_slots.ts +1
src/crew/wave.ts added +77
| @@ -0,0 +1,77 @@ | ||
| 1 | /** | |
| 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) | |
| 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 +93
| @@ -0,0 +1,93 @@ | ||
| 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 | * asks it to keep (`docs/design/waves/<week>.json`). Pure data: `crew/wave.ts` | |
| 5 | * 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 | /** Monday 08:00 UTC. */ | |
| 33 | export const WAVE_DAY = 1; | |
| 34 | export const WAVE_HOUR = 8; | |
| 35 | ||
| 36 | export const WAVE_PREFIX = "Design wave "; | |
| 37 | ||
| 38 | /** The week a moment falls in, ISO 8601, as `2026-W44`. */ | |
| 39 | export function weekOf(now: Date): string { | |
| 40 | const d = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())); | |
| 41 | const day = d.getUTCDay() || 7; | |
| 42 | d.setUTCDate(d.getUTCDate() + 4 - day); | |
| 43 | const year = d.getUTCFullYear(); | |
| 44 | const first = Date.UTC(year, 0, 1); | |
| 45 | const week = Math.ceil(((d.getTime() - first) / 86_400_000 + 1) / 7); | |
| 46 | return `${year}-W${String(week).padStart(2, "0")}`; | |
| 47 | } | |
| 48 | ||
| 49 | /** This week's wave has started: Monday 08:00Z or later, in the ISO week. */ | |
| 50 | export function waveStarted(now: Date): boolean { | |
| 51 | const day = now.getUTCDay() || 7; | |
| 52 | return day > WAVE_DAY || (day === WAVE_DAY && now.getUTCHours() >= WAVE_HOUR); | |
| 53 | } | |
| 54 | ||
| 55 | export const waveTitle = (week: string): string => `${WAVE_PREFIX}${week}`; | |
| 56 | const WAVE_TITLE = new RegExp(`^${WAVE_PREFIX}\\d{4}-W\\d{2}$`); | |
| 57 | export const isWaveTitle = (title: string): boolean => WAVE_TITLE.test(title); | |
| 58 | ||
| 59 | /** The label the designer files its bigger ideas under. */ | |
| 60 | export const ASK_LABEL = { name: "design-ask", color: "7c3aed" } as const; | |
| 61 | ||
| 62 | /** The first wave's targets, named by the owner; later waves read the asks. */ | |
| 63 | const FIRST_TARGETS = [ | |
| 64 | "the horizontal tabs: one component, a clear active state, good hit targets, overflow on phones, arrow keys", | |
| 65 | "the repo header", | |
| 66 | "the home feed", | |
| 67 | "Migrate", | |
| 68 | "the app template shell", | |
| 69 | ] as const; | |
| 70 | ||
| 71 | /** The issue body: the whole task, so the run needs nothing else. */ | |
| 72 | export function waveBody(week: string, previous: string | undefined): string { | |
| 73 | return [ | |
| 74 | `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.`, | |
| 75 | "", | |
| 76 | "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.", | |
| 77 | `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.`}`, | |
| 78 | "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).", | |
| 79 | "4. **Ask**: file the bigger ideas as issues labelled `design-ask`, each with the problem, a sketch or reference, and why it matters.", | |
| 80 | "5. **Report**: your last message is the wave report: scores this week against last, what changed, the top asks.", | |
| 81 | "", | |
| 82 | `First targets: ${FIRST_TARGETS.join("; ")}.`, | |
| 83 | ].join("\n"); | |
| 84 | } | |
| 85 | ||
| 86 | /** The lines the designer's brief adds to the shared one. */ | |
| 87 | export const DESIGNER_LINES: readonly string[] = [ | |
| 88 | "You are this repository's designer, and your run is a design wave or a design fix:", | |
| 89 | "- 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.", | |
| 90 | "- Run `bun scripts/design-lint.ts` before you push; the one-offs outside the components must fall, never rise.", | |
| 91 | "- Small pulls, one component or page each, never a restyle of everything; a page must not get harder to read in one glance.", | |
| 92 | "- 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.", | |
| 93 | ]; |
src/web/studio/app.ts +12 −6
| @@ -23,7 +23,8 @@ import { audit } from "../../contract/audit.ts"; | ||
| 23 | 23 | import { latestProbes } from "../../contract/probes.ts"; |
| 24 | 24 | import { appsRuntime, envsFor } from "../../apps/runtime.ts"; |
| 25 | 25 | import { TELL_LIMIT_WORDS, TELL_TEXT_MAX } from "../../actions/tell_from.ts"; |
| 26 | import { listCrewRoles } from "../../core/agents.ts"; | |
| 26 | import { listCrewRoles, type CrewRole } from "../../core/agents.ts"; | |
| 27 | ||
| 27 | 28 | import type { AppRecord } from "../../core/apps.ts"; |
| 28 | 29 | import type { DecisionStat } from "../../core/decisions.ts"; |
| 29 | 30 | import { growthPanel } from "../pages/growth_panel.ts"; |
| @@ -84,6 +85,15 @@ import { mayReadStatement } from "../../actions/statement.ts"; | ||
| 84 | 85 | import { appPicture } from "../../flow/pages.ts"; |
| 85 | 86 | import { moneyRows } from "./money_line.ts"; |
| 86 | 87 | |
| 88 | /** What a seat does, as the rail's Crew card says it. */ | |
| 89 | const CREW_VERB: Record<CrewRole, string> = { | |
| 90 | planner: "plans", | |
| 91 | builder: "builds", | |
| 92 | reviewer: "reviews", | |
| 93 | maintainer: "maintains", | |
| 94 | designer: "designs", | |
| 95 | }; | |
| 96 | ||
| 87 | 97 | /** |
| 88 | 98 | * What asks the viewer in this repository, muted or not: a mute quiets the |
| 89 | 99 | * home, the inbox and the phone, never the repository's own page. |
| @@ -376,11 +386,7 @@ export async function studioApp( | ||
| 376 | 386 | row({ |
| 377 | 387 | lead: avatar(c.agent.user.username), |
| 378 | 388 | title: c.agent.user.username, |
| 379 | meta: html`${c.role === "builder" | |
| 380 | ? "builds" | |
| 381 | : c.role === "planner" | |
| 382 | ? "plans" | |
| 383 | : "reviews"}`, | |
| 389 | meta: html`${CREW_VERB[c.role]}`, | |
| 384 | 390 | }), |
| 385 | 391 | ), |
| 386 | 392 | { |
src/web/studio/crew.ts +1
test/wave.test.ts added +145
| @@ -0,0 +1,145 @@ | ||
| 1 | import { describe, expect, test } from "bun:test"; | |
| 2 | import { | |
| 3 | RUBRIC, | |
| 4 | isWaveTitle, | |
| 5 | waveBody, | |
| 6 | waveStarted, | |
| 7 | waveTitle, | |
| 8 | weekOf, | |
| 9 | } from "../src/design/wave.ts"; | |
| 10 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 11 | import { tmpdir } from "node:os"; | |
| 12 | import { join } from "node:path"; | |
| 13 | import { createApp } from "../src/app.ts"; | |
| 14 | import { addToCrew, createAgent } from "../src/actions/crew.ts"; | |
| 15 | import { createRepo } from "../src/actions/repos.ts"; | |
| 16 | import { isCrewRole, listCrewRoles, setCrewRole, updateAgent } from "../src/core/agents.ts"; | |
| 17 | import { getIssue, getLabel } from "../src/core/issues.ts"; | |
| 18 | import { createUser, getUserByName } from "../src/core/users.ts"; | |
| 19 | import { heldBy } from "../src/crew/held.ts"; | |
| 20 | import { driveWave } from "../src/crew/wave.ts"; | |
| 21 | import { startCrew } from "../src/crew/dispatch.ts"; | |
| 22 | import { listRuns } from "../src/core/runs.ts"; | |
| 23 | import { serve } from "../src/http/server.ts"; | |
| 24 | import { pollUntil } from "./helpers/poll.ts"; | |
| 25 | import { systemPrompt } from "../src/crew/brief.ts"; | |
| 26 | ||
| 27 | describe("the design wave's calendar", () => { | |
| 28 | test("the ISO week, across a year's edge", () => { | |
| 29 | expect(weekOf(new Date("2026-10-26T08:00:00Z"))).toBe("2026-W44"); | |
| 30 | expect(weekOf(new Date("2026-12-31T12:00:00Z"))).toBe("2026-W53"); | |
| 31 | expect(weekOf(new Date("2027-01-03T12:00:00Z"))).toBe("2026-W53"); | |
| 32 | expect(weekOf(new Date("2027-01-04T00:00:00Z"))).toBe("2027-W01"); | |
| 33 | }); | |
| 34 | test("it starts Monday 08:00Z and stays due all week", () => { | |
| 35 | expect(waveStarted(new Date("2026-10-26T07:59:00Z"))).toBe(false); | |
| 36 | expect(waveStarted(new Date("2026-10-26T08:00:00Z"))).toBe(true); | |
| 37 | expect(waveStarted(new Date("2026-10-29T03:00:00Z"))).toBe(true); | |
| 38 | expect(waveStarted(new Date("2026-11-01T23:00:00Z"))).toBe(true); | |
| 39 | }); | |
| 40 | test("the title names the week and nothing else counts as one", () => { | |
| 41 | expect(isWaveTitle(waveTitle("2026-W44"))).toBe(true); | |
| 42 | expect(isWaveTitle("Design wave 2026-W44 please")).toBe(false); | |
| 43 | expect(isWaveTitle("Fix the tabs")).toBe(false); | |
| 44 | }); | |
| 45 | }); | |
| 46 | ||
| 47 | describe("the designer", () => { | |
| 48 | test("is a crew role, and its brief and the wave's issue carry the task", () => { | |
| 49 | expect(isCrewRole("designer")).toBe(true); | |
| 50 | const body = waveBody("2026-W44", "2026-W43"); | |
| 51 | for (const c of RUBRIC) expect(body).toContain(c); | |
| 52 | expect(body).toContain("design-ask"); | |
| 53 | expect(body).toContain("2026-W43.json"); | |
| 54 | expect(body).toContain("horizontal tabs"); | |
| 55 | }); | |
| 56 | test("its system prompt is the designer's, and a builder's is not", () => { | |
| 57 | const base = { | |
| 58 | agent: { user: { username: "pixel", displayName: "Pixel" }, brief: "" }, | |
| 59 | repo: { ownerName: "o", name: "r", defaultBranch: "main" }, | |
| 60 | issue: { number: 1, title: "t", body: "" }, | |
| 61 | branch: "b", | |
| 62 | forgeUrl: "https://f", | |
| 63 | resuming: false, | |
| 64 | isApp: true, | |
| 65 | } as unknown as Parameters<typeof systemPrompt>[0]; | |
| 66 | expect(systemPrompt({ ...base, role: "designer" })).toContain("repository's designer"); | |
| 67 | expect(systemPrompt({ ...base, role: "builder" })).not.toContain("repository's designer"); | |
| 68 | }); | |
| 69 | }); | |
| 70 | ||
| 71 | describe("opening the wave", () => { | |
| 72 | test("one issue a week, for the designer, once Monday 08:00Z has come", async () => { | |
| 73 | const dir = await mkdtemp(join(tmpdir(), "forge-wave-")); | |
| 74 | const app = createApp({ dataDir: dir, port: 0 }); | |
| 75 | const servers = await serve(app); | |
| 76 | const crewUp = await startCrew(app, { | |
| 77 | forgeUrl: servers.url, | |
| 78 | localUrl: servers.url, | |
| 79 | binary: "/nonexistent/claude", | |
| 80 | concurrency: 1, | |
| 81 | budgetUsd: 1, | |
| 82 | runTimeoutMs: 60_000, | |
| 83 | }); | |
| 84 | try { | |
| 85 | const made = await createUser(app.db, { origin: "seed", trusted: true, | |
| 86 | username: "alice", | |
| 87 | email: "[email protected]", | |
| 88 | password: "a-good-passphrase", | |
| 89 | adminIfFirst: true, | |
| 90 | }); | |
| 91 | if (!made.ok) throw new Error(made.error); | |
| 92 | const alice = made.value; | |
| 93 | const r = await createRepo(app, alice, { name: "ui", visibility: "private" }); | |
| 94 | if (!r.ok) throw new Error(String(r.error)); | |
| 95 | const repo = r.value; | |
| 96 | await createAgent(app, alice, { username: "pixel" }); | |
| 97 | await createAgent(app, alice, { username: "mason" }); | |
| 98 | expect(addToCrew(app, alice, repo, "pixel").ok).toBe(true); | |
| 99 | expect(addToCrew(app, alice, repo, "mason").ok).toBe(true); | |
| 100 | const crew = () => listCrewRoles(app.db, repo.id); | |
| 101 | const wave = (at: string) => driveWave(app, repo, alice, crew(), new Date(at)); | |
| 102 | const count = () => | |
| 103 | app.db.query<{ n: number }, [string]>("SELECT count(*) n FROM issue WHERE repo_id = ?1 AND title LIKE 'Design wave %'").get(repo.id)!.n; | |
| 104 | ||
| 105 | // No designer on the crew: no wave. | |
| 106 | expect(wave("2026-10-26T09:00:00Z")).toBe(false); | |
| 107 | updateAgent(app.db, getUserByName(app.db, "pixel")!.id, { roles: ["builder", "designer"] }); | |
| 108 | setCrewRole(app.db, repo.id, getUserByName(app.db, "pixel")!.id, "designer"); | |
| 109 | expect(wave("2026-10-26T07:00:00Z")).toBe(false); | |
| 110 | expect(wave("2026-10-26T09:00:00Z")).toBe(true); | |
| 111 | expect(wave("2026-10-27T09:00:00Z")).toBe(false); | |
| 112 | expect(count()).toBe(1); | |
| 113 | expect(getLabel(app.db, repo.id, "design-ask")).toBeDefined(); | |
| 114 | // The assignment is what starts the designer's run, once; the tick | |
| 115 | // that finds the week's issue already open starts no second. | |
| 116 | const pixel = getUserByName(app.db, "pixel")!; | |
| 117 | const runsOf = () => | |
| 118 | listRuns(app.db, repo.id).filter((x) => x.actorId === pixel.id); | |
| 119 | await pollUntil(() => runsOf().length > 0, "the designer run", 10_000); | |
| 120 | expect(runsOf()).toHaveLength(1); | |
| 121 | expect(wave("2026-10-28T09:00:00Z")).toBe(false); | |
| 122 | // A tick that finds the issue open opens nothing and queues nothing: | |
| 123 | // one issue, and the one run is still the only one on record. | |
| 124 | expect(count()).toBe(1); | |
| 125 | expect(runsOf()).toHaveLength(1); | |
| 126 | const opened = getIssue(app.db, repo.id, 1)!; | |
| 127 | expect(opened.title).toBe("Design wave 2026-W44"); | |
| 128 | expect(opened.assigneeId).toBe(getUserByName(app.db, "pixel")!.id); | |
| 129 | // The next week gets its own, naming last week's scores. | |
| 130 | expect(wave("2026-11-02T08:00:00Z")).toBe(true); | |
| 131 | expect(getIssue(app.db, repo.id, 2)!.body).toContain("2026-W44.json"); | |
| 132 | expect(count()).toBe(2); | |
| 133 | // Held for the designer while one is on the crew; free once the role goes. | |
| 134 | const ready = [getIssue(app.db, repo.id, 1)!].map((issue) => ({ issue, holdsUp: 0, waitsFor: 0 })); | |
| 135 | expect(heldBy(app, repo, ready, crew(), []).by.planner).toHaveLength(1); | |
| 136 | setCrewRole(app.db, repo.id, pixel.id, "builder"); | |
| 137 | expect(heldBy(app, repo, ready, crew(), []).by.planner).toHaveLength(0); | |
| 138 | } finally { | |
| 139 | await crewUp.stop(); | |
| 140 | servers.stop(); | |
| 141 | app.close(); | |
| 142 | await rm(dir, { recursive: true, force: true }); | |
| 143 | } | |
| 144 | }); | |
| 145 | }); |
new above
offline
Dead code (Clean):
scoreProblem,average,trendLineandFIRST_TARGETShave no caller outside tests. Wire them in or remove them. Allow-listingscoreProblemis not the fix.