From 2525ad620034e3132e5855f78cc10895be6b6df4 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 01:58:22 +0000 Subject: [PATCH 01/19] fix(goals): the built-in kind goal hires onto one copy of agent (FIX-1824) The harness built hireWorkforce(workers), which since FIX-1788 P4 takes an installation. It now builds createWorkerInstallation({ standardWorkers }) with no worker flows, registers the copies hireWorkforce returns, and asks each worker in a session on the agent copy that names it. Leg 0's scan moves to the installation: it holds the roster and nothing else. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../goal.md | 16 ++- .../harness.mts | 96 +++++++++----- .../run.mts | 119 ++++++++++++------ 3 files changed, 157 insertions(+), 74 deletions(-) diff --git a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/goal.md b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/goal.md index f2a15d7a52..744e7a29cb 100644 --- a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/goal.md +++ b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/goal.md @@ -4,21 +4,21 @@ **Outcome:** Someone describes two workers in Markdown — a description and some instructions, nothing else, no `flow:` and no `model:` — points the app at the folder, and has two working workers. Each answers a question in the voice its own file gave it, and neither answers in its neighbour's. A worker file naming a kind nobody registered takes the whole roster down with it rather than hiring around the problem. -No flow is written, no kind is registered, and `hireWorkforce` is called with **no `kinds` argument at all** — so the only thing that could have answered is the built-in `agent` kind. +No flow is written, no kind is registered, and the installation `hireWorkforce` takes is built from the workers alone, with **no worker flows at all** — so the only thing that could have answered is the built-in `agent` kind, whose one copy runs both workers. **Input:** `fixtures/workforce/` — two teams, one worker each, whose bodies carry the held-out tokens `HALYARD-6182` and `KESTREL-3390`. `fixtures/mixed-roster/` — one valid worker beside one naming `flow: reviewer`. `fixtures/input.json` holds the expected ids, descriptions, bodies and tokens, plus the one question both seats are asked. Held out: every id, body and token is read from the fixture and graded against what the seats actually replied; swapping them for another valid set must still pass a correct implementation. Each token appears in exactly one file on disk and nowhere in the question, so a reply can only carry the right one if that worker's file reached the model. **Signal:** four legs, run against the real HTTP route over a real `createFlowState` host with a real model. -(0) **Fixture integrity, before a model call is spent.** Every `WORKER.md` is compared against `input.json` body-for-body and description-for-description, whole values rather than `includes`; each file is checked for its sibling's token and the question for either; and `mixed-roster/`'s two workers are checked to still declare the flow kinds `input.json` says, since a roster that is no longer mixed makes leg (c) green for some other reason. Separately, `harness.mts`'s source is read and every `hireWorkforce(` call site asserted to take exactly one argument — read statically, because a runtime report could only say what the harness chose to say, and anything beyond the roster can carry a kind under any name. A refactor of `harness.mts` must keep that call site readable by the scan — moving the hire behind a wrapper would leave leg 0 asserting nothing. +(0) **Fixture integrity, before a model call is spent.** Every `WORKER.md` is compared against `input.json` body-for-body and description-for-description, whole values rather than `includes`; each file is checked for its sibling's token and the question for either; and `mixed-roster/`'s two workers are checked to still declare the flow kinds `input.json` says, since a roster that is no longer mixed makes leg (c) green for some other reason. Separately, `harness.mts`'s source is read and every `createWorkerInstallation(` call site asserted to pass an object literal holding `standardWorkers` and nothing else, and every `hireWorkforce(` call site to take only the installation — read statically, because a runtime report could only say what the harness chose to say, and anything beyond the roster can carry a worker flow under any name. A refactor of `harness.mts` must keep those call sites readable by the scan — moving the installation behind a wrapper would leave leg 0 asserting nothing. -(a) **C1 — it hires from files alone.** `readWorkforce` over the tree, `hireWorkforce(workers)` with one argument, two seats back in id order, each addressable by its own worker id, both registered through the real registry. +(a) **C1 — it hires from files alone.** `readWorkforce` over the tree, `createWorkerInstallation({ standardWorkers })`, then `hireWorkforce(installation)`: both workers on the installation, each running on the built-in `agent`, and the copies registered through the real registry are exactly `agent` and the roster flow. Each worker is then asked in a session on that one copy, created naming it (`state.workerId`). (b) **C2 — the answer is steered by the file's body.** Both seats are asked the same question. Each reply must carry **its own** file's token and must **not** carry its sibling's. Graded on the assistant's reply text, never on `ctx.flow.config` — a sibling goal already proves the setting arrives, and that stays true even if the model never sees it. -(c) **C3 — an unregistered kind refuses, and nothing on the roster hires.** A **mixed** roster: one valid worker plus one naming `flow: reviewer`. Graded in order — the call threw *rather than returned* (the load-bearing assertion), the message names the worker, `reviewer` and `agent`, and the valid worker's address 404s on a host built from what came back. +(c) **C3 — an unregistered kind refuses, and nothing on the roster hires.** A **mixed** roster: one valid worker plus one naming `flow: reviewer`. Graded in order — the call threw *rather than returned* (the load-bearing assertion), the message names the worker, `reviewer` and `agent`, and a session with the valid worker on `agent` 404s on a host built from what came back. -**Anti-game:** A hollow pass would assert that two seats hired and two non-empty replies came back — true even when the body never reaches the model at all, which is exactly what the first control produces. So the check MUST grade the **reply text**, not the settings bag; MUST grade the two seats as a **pair**, each carrying its own token and not its sibling's, because one shared prompt is always right for somebody; MUST use tokens that live in exactly one file each and nowhere in the question, so the only route to a token is that file; MUST assert the hire passes **no `kinds`**, since hiring a flow the test supplied proves nothing about the built-in; and MUST grade the refusal on a **mixed** roster, asserting the call threw rather than returned — on a single-bad-record roster "nothing hired" is true for reasons unrelated to atomicity, and the 404 merely restates the throw. +**Anti-game:** A hollow pass would assert that two seats hired and two non-empty replies came back — true even when the body never reaches the model at all, which is exactly what the first control produces. So the check MUST grade the **reply text**, not the settings bag; MUST grade the two seats as a **pair**, each carrying its own token and not its sibling's, because one shared prompt is always right for somebody; MUST use tokens that live in exactly one file each and nowhere in the question, so the only route to a token is that file; MUST assert the installation is given **no worker flows**, since hiring onto a flow the test supplied proves nothing about the built-in; and MUST grade the refusal on a **mixed** roster, asserting the call threw rather than returned — on a single-bad-record roster "nothing hired" is true for reasons unrelated to atomicity, and the 404 merely restates the throw. The controls below are the other half of this. A control has to fail **at the leg it controls**: editing the fixture bodies would die at leg 0's integrity check and prove only that the checksum works, so every control perturbs the **harness** instead and leaves the fixture tree untouched. @@ -40,3 +40,9 @@ The controls below are the other half of this. A control has to fail **at the le | 2026-09-16 | fix/FIX-1365-thin-proof-hire (control: `withhold-instructions`) | openai/gpt-5.4-mini | FAIL (expected) | Named **leg (b)**, not leg 0: *"engineering.desk did not carry its own token HALYARD-6182"*. With the body withheld at the mint both seats answered as a generic assistant — *"I'm ChatGPT, an AI assistant from OpenAI… I don't actually have a physical desk"* — and neither token appeared. This is the control that proves the tokens come from the worker file rather than from the question, the default prompt or the harness. | | 2026-09-16 | fix/FIX-1365-thin-proof-hire (control: `cross-wire`) | openai/gpt-5.4-mini | FAIL (expected) | Named **leg (b)**: *"engineering.desk carried marketing.desk's token KESTREL-3390"*, and the mirror for the other seat. With each seat handed its sibling's body, `engineering.desk` answered *"I'm your marketing desk assistant… KESTREL-3390"*. Proves the pair grading is sensitive to which body reached which seat — the failure one shared prompt would otherwise satisfy. | | 2026-09-16 | fix/FIX-1365-thin-proof-hire (control: `partial-hire`) | n/a (model-free leg) | FAIL (expected) | Named **leg (c)** on both assertions: *"the hire returned ["engineering.desk"] instead of refusing"* and *"the valid worker engineering.desk answered 202 on a host built from what came back — a seat was registered anyway"*. Admitting the valid record from the mixed roster turns the leg red, which is what makes it a test of all-or-nothing admission rather than of the throw. It also shows the 404 assertion is load-bearing **because** the roster is mixed: with a valid record in play it moved to 202. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | — | FAIL | Red on `main` since FIX-1788 P4, before any leg: the harness called `hireWorkforce(workers)`, which now takes an installation, and died with *"TypeError: installation.workerFlows is not a function"*. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | vercel/openai/gpt-5.4-mini | PASS | The harness builds `createWorkerInstallation({ standardWorkers })` with no worker flows and registers what `hireWorkforce(installation)` returns: `agent` and `workforce-roster`. Both workers run on `agent` and are asked in a session on that copy naming them. Attempt 1 of 1: `engineering.desk` *"I'm the engineering desk at a small software company… HALYARD-6182"*, `marketing.desk` *"…this is the marketing desk. KESTREL-3390"*. The mixed roster refused naming `engineering.scribe`, `reviewer` and `agent`, and a session with `engineering.desk` on `agent` 404'd on the host built from nothing. | +| 2026-10-09 | same (control: `withhold-instructions`) | vercel/openai/gpt-5.4-mini | FAIL (expected) | **Leg (b)** only, on all 3 attempts: both workers answered *"I'm ChatGPT, an AI assistant"* and neither carried its token. | +| 2026-10-09 | same (control: `cross-wire`) | vercel/openai/gpt-5.4-mini | FAIL (expected) | **Leg (b)** only: `engineering.desk` answered as the marketing desk with `KESTREL-3390`, and the mirror for `marketing.desk`. | +| 2026-10-09 | same (control: `partial-hire`) | n/a (model-free leg) | FAIL (expected) | **Leg (c)** on both assertions: *"the hire returned ["agent","workforce-roster"] instead of refusing"* and *"a session with the valid worker engineering.desk on "agent" answered 201 on a host built from what came back"*. | +| 2026-10-09 | same, one hand mutation, reverted | — | FAIL (expected) | Leg 0's new scan: `workerFlows: {}` added to the harness's installation stopped the run at leg 0 with no model call: *"the harness builds an installation from more than its workers ({ standardWorkers: workers, workerFlows: {} })"*. | diff --git a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/harness.mts b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/harness.mts index 18668d8363..a4ad6900f5 100644 --- a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/harness.mts +++ b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/harness.mts @@ -6,9 +6,10 @@ * kitchen-sink; it is the working directory, not the subject. * * Drives the path a team adopting the framework would: read worker Markdown - * files from disk, hire them with NO `kinds` argument so only the built-in - * `agent` kind can answer, register the seats, and ask each one a question over - * the real HTTP route. + * files from disk, build the installation over them with NO worker flows so + * only the built-in `agent` flow can answer, register the copies `hireWorkforce` + * returns, and ask each worker a question over the real HTTP route, in a + * session on the one `agent` copy that names it. * * OBSERVES ONLY — every assertion lives in run.mts. This file must not decide * whether anything passed; it reports what happened on one `__GOAL__` line. @@ -30,7 +31,13 @@ import { createGateway } from "@ai-sdk/gateway"; import { createModelResolver } from "@flow-state-dev/core"; import { createFlowState, inMemoryStores } from "@flow-state-dev/engine"; -import { hireWorkforce } from "@flow-state-dev/workforce"; +import { + AGENT_KIND, + WORKER_ID_STATE_KEY, + createWorkerInstallation, + hireWorkforce, + inventorySeats, +} from "@flow-state-dev/workforce"; import { readWorkforce } from "@flow-state-dev/workforce/loader"; const MODEL = process.env.GOAL_MODEL ?? "vercel/openai/gpt-5.4-mini"; @@ -124,25 +131,56 @@ async function main(): Promise { out.rosterIds = workers.map((w) => w.id); out.rosterBodies = Object.fromEntries(workers.map((w) => [w.id, w.body])); - // THE call under test: no `kinds` argument, so only the built-in can answer. - const seats = hireWorkforce(workers); - out.seatIds = seats.map((s) => s.id); + // THE calls under test: an installation over the files' workers that names + // no worker flow, so only the built-in `agent` can answer, and the copies it + // registers. + const installation = createWorkerInstallation({ standardWorkers: workers }); + const copies = hireWorkforce(installation); + // Each worker, and the flow it runs on. + const seats = inventorySeats(installation).map((seat) => ({ id: seat.id, kind: seat.kind })); + out.seats = seats; // ---- register and ask, over the real route ------------------------------ // `createFlowState` is the path a real app uses: it builds the flow registry // AND registers each flow's declared resources (the built-in kind declares a // skills collection), then resolves the same HTTP router. const flowState = createFlowState({ - flows: Object.fromEntries(seats.map((seat) => [seat.id, seat])), + flows: Object.fromEntries(copies.map((copy) => [copy.id, copy])), stores: { dev: { primary: inMemoryStores() } }, modelResolver, } as never); const router = await flowState.getRouter(); const stores = (await flowState.getRuntime()).stores; - out.registered = seats.map((s) => s.id); + out.registered = copies.map((copy) => copy.id); - async function ask(address: string, sessionId: string): Promise { - const path = [address, sessionId, "actions", "run"]; + /** Create a session on `flow` naming `worker`, as an app opens one: the route's status and body. */ + async function openSession( + on: { POST(request: Request, context: never): Promise }, + flow: string, + worker: string, + sessionId: string, + ): Promise<{ status: number; text: string }> { + const path = [flow, "sessions"]; + const res = await on.POST( + new Request(`http://goal/api/flows/${path.join("/")}`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ userId: USER_ID, sessionId, state: { [WORKER_ID_STATE_KEY]: worker } }), + }), + { params: { path } } as never, + ); + return { status: res.status, text: await res.text() }; + } + + async function ask(seat: { id: string; kind: string }, sessionId: string): Promise { + // A worker has no flow address of its own: it answers in a session of the + // flow it runs on, created naming it. + const opened = await openSession(router as never, seat.kind, seat.id, sessionId); + if (opened.status !== 201) { + throw new Error(`${seat.id}: a session on "${seat.kind}" naming it answered ${opened.status}: ${opened.text}`); + } + const address = seat.id; + const path = [seat.kind, sessionId, "actions", "run"]; const res = await router.POST( new Request(`http://goal/api/flows/${path.join("/")}`, { method: "POST", @@ -195,7 +233,7 @@ async function main(): Promise { for (let attempt = 1; attempt <= ATTEMPTS; attempt += 1) { const replies: Record = {}; for (const seat of seats) { - replies[seat.id] = await ask(seat.id, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); + replies[seat.id] = await ask(seat, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); } attempts.push(replies); if (everySeatOnItsOwnToken(replies)) break; @@ -209,41 +247,31 @@ async function main(): Promise { let threw = false; let refusal = ""; - let hiredSeats: Array<{ id: string }> = []; - let returned: string[] | null = null; + let returned: Array<{ id: string }> = []; try { - hiredSeats = - CONTROL === "partial-hire" - ? // The failure mode the leg exists to catch: admit the good record and - // report the bad one, instead of refusing the whole call. - hireWorkforce(mixedRecords.filter((w) => w.id === MIXED_VALID_ID)) - : hireWorkforce(mixedRecords); - returned = hiredSeats.map((s) => s.id); + // The failure mode the leg exists to catch: admit the good record and + // report the bad one, instead of refusing the whole call. + const admitted = CONTROL === "partial-hire" ? mixedRecords.filter((w) => w.id === MIXED_VALID_ID) : mixedRecords; + const mixedInstallation = createWorkerInstallation({ standardWorkers: admitted }); + returned = hireWorkforce(mixedInstallation); } catch (error) { threw = true; refusal = error instanceof Error ? error.message : String(error); } - out.refusal = { threw, message: refusal, returnedSeatIds: returned }; + out.refusal = { threw, message: refusal, returnedCopyIds: threw ? null : returned.map((copy) => copy.id) }; - // A host built from exactly what came back. Meaningful only because the - // roster is mixed: with a valid record in play, a seat reaching the registry + // A host built from exactly what came back, asked for a session with the + // valid worker on the built-in flow it runs on. Meaningful only because the + // roster is mixed: with a valid record in play, a copy reaching the registry // is a real failure mode rather than an impossibility. { const afterState = createFlowState({ - flows: Object.fromEntries(hiredSeats.map((seat) => [seat.id, seat])), + flows: Object.fromEntries(returned.map((copy) => [copy.id, copy])), stores: { dev: { primary: inMemoryStores() } }, modelResolver, } as never); const afterRouter = await afterState.getRouter(); - const path = [MIXED_VALID_ID, "s_after_refusal", "actions", "run"]; - const res = await afterRouter.POST( - new Request(`http://goal/api/flows/${path.join("/")}`, { - method: "POST", - body: JSON.stringify({ userId: USER_ID, input: { message: QUESTION } }), - }), - { params: { path } } as never, - ); - out.validWorkerStatusAfterRefusal = res.status; + out.validWorkerStatusAfterRefusal = (await openSession(afterRouter as never, AGENT_KIND, MIXED_VALID_ID, "s_after_refusal")).status; } out.ok = true; diff --git a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/run.mts b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/run.mts index f0d95c9a57..537167bac9 100644 --- a/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/run.mts +++ b/goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/run.mts @@ -10,7 +10,7 @@ * (`docs/architecture/workforce-default-worker-kind.md`): * * 0 fixture integrity — the tree and input.json agree, before any model call - * a C1: two worker files hire with NO `kinds` argument, and register + * a C1: two worker files hire onto the built-in, from an installation given no worker flow * b C2: each seat's reply is steered by ITS OWN body, not its neighbour's * c C3: a mixed roster with one unregistered kind refuses, and nothing hires * @@ -20,6 +20,7 @@ * Run: pnpm tsx goals/workforce-seats/the-built-in-kind-answers-from-a-file-alone/run.mts */ import { readFileSync } from "node:fs"; +import { ROSTER_FLOW_KIND } from "@flow-state-dev/workforce/browser"; import { KITCHEN_SINK, fixturePath, @@ -53,11 +54,13 @@ interface Observation { skillErrors: unknown[]; rosterIds: string[]; rosterBodies: Record; - seatIds: string[]; + /** Each worker the installation holds, and the flow it runs on. */ + seats: Array<{ id: string; kind: string }>; + /** The copies `hireWorkforce` returned, by id, all registered. */ registered: string[]; attempts: Array>; mixedRosterIds: string[]; - refusal: { threw: boolean; message: string; returnedSeatIds: string[] | null }; + refusal: { threw: boolean; message: string; returnedCopyIds: string[] | null }; validWorkerStatusAfterRefusal: number; } @@ -172,30 +175,70 @@ function mixedRosterDrift(): string[] { } /** - * Leg 0, half two — the hire call itself passes no `kinds`. + * Leg 0, half two — the installation names no worker flow, and the hire adds + * nothing to it. * * Read statically off the harness source, because a runtime report could only - * say what the harness chose to say. Passing a `kinds` map would prove nothing - * about the built-in, which is the whole subject. + * say what the harness chose to say. An installation handed a worker flow + * would prove nothing about the built-in, which is the whole subject. */ -function hireCallPassesNoKinds(): string[] { +function installationNamesNoFlows(): string[] { const source = readFileSync(new URL("./harness.mts", import.meta.url), "utf8"); - const calls = [...source.matchAll(/hireWorkforce\s*\(([\s\S]{0,200}?)\)\s*[;:\n]/g)].map((m) => - m[1].replace(/\s+/g, " ").trim(), - ); - if (calls.length === 0) { - return ["the harness contains no hireWorkforce call — the check is not driving the subject"]; + const installs = callArguments(source, "createWorkerInstallation"); + const hires = callArguments(source, "hireWorkforce"); + if (installs.length === 0 || hires.length === 0) { + return ["the harness builds no installation or calls no hireWorkforce — the check is not driving the subject"]; + } + const problems: string[] = []; + // Only the roster, as a literal: any other key, a spread or a variable can + // carry `workerFlows` without the name appearing at the call. + const carrying = installs.filter((args) => JSON.stringify(literalKeys(args)) !== JSON.stringify(["standardWorkers"])); + if (carrying.length > 0) { + problems.push( + `the harness builds an installation from more than its workers (${carrying.join(" | ")}) — ` + + `anything beyond the roster can carry a worker flow, which proves nothing about the built-in`, + ); + } + // The installation is the hire's one argument. + const withArgs = hires.filter((args) => hasSecondArgument(args)); + if (withArgs.length > 0) { + problems.push(`the harness passes a second argument to hireWorkforce (${withArgs.join(" | ")}) — the installation is all it takes`); + } + return problems; +} + +/** The source inside each `name(...)` call, up to its matching parenthesis, whitespace collapsed. */ +function callArguments(source: string, name: string): string[] { + const found: string[] = []; + for (const match of source.matchAll(new RegExp(`\\b${name}\\s*\\(`, "g"))) { + const start = match.index! + match[0].length; + let depth = 1; + let at = start; + for (; at < source.length && depth > 0; at += 1) { + if ("([{".includes(source[at]!)) depth += 1; + else if (")]}".includes(source[at]!)) depth -= 1; + } + found.push(source.slice(start, at - 1).replace(/\s+/g, " ").trim()); } - // Any second argument, not just one spelled `kinds` — `hireWorkforce(workers, - // options)` carries a kinds map the name never mentions, and goal.md's own - // criterion is `hireWorkforce(workers)` with one argument. - const withArgs = calls.filter((args) => hasSecondArgument(args)); - return withArgs.length > 0 - ? [ - `the harness passes a second argument to hireWorkforce (${withArgs.join(" | ")}) — ` + - `anything beyond the roster can carry a kind, which proves nothing about the built-in`, - ] - : []; + return found; +} + +/** An object literal's top-level keys (a spread reads as `...`), or `undefined` when the source isn't one. */ +function literalKeys(args: string): string[] | undefined { + if (!args.startsWith("{") || !args.endsWith("}")) return undefined; + const keys: string[] = []; + let depth = 0; + let entry = ""; + for (const ch of `${args.slice(1, -1)},`) { + if ("([{".includes(ch)) depth += 1; + else if (")]}".includes(ch)) depth -= 1; + if (ch === "," && depth === 0) { + const text = entry.trim(); + if (text !== "") keys.push(text.startsWith("...") ? "..." : text.split(":")[0]!.trim()); + entry = ""; + } else entry += ch; + } + return keys; } /** A comma outside every bracket in a captured argument list. */ @@ -220,12 +263,12 @@ await runGoal(() => { const evidence: string[] = []; // ---- leg 0 ------------------------------------------------------------- - failures.push(...fixtureDrift(), ...mixedRosterDrift(), ...hireCallPassesNoKinds()); + failures.push(...fixtureDrift(), ...mixedRosterDrift(), ...installationNamesNoFlows()); if (failures.length > 0) { return { failures, evidence: "stopped at leg 0 — no model call was spent" }; } evidence.push( - "leg 0: both fixture trees match input.json and the hire passes no `kinds`", + "leg 0: both fixture trees match input.json, and the installation names no worker flow", ); const o = runHarness({ @@ -260,18 +303,24 @@ await runGoal(() => { const expected = fixture.workers.map((w) => w.id).sort(); - // ---- leg (a): C1 — hires from files alone, with no kinds --------------- + // ---- leg (a): C1 — hires from files alone, on the built-in -------------- { - const seats = [...o.seatIds].sort(); + const { builtInKind } = fixture.mixedRoster; + const seats = o.seats.map((s) => s.id).sort(); if (JSON.stringify(seats) !== JSON.stringify(expected)) { failures.push(`hired ${JSON.stringify(seats)}, wanted ${JSON.stringify(expected)}`); } + for (const seat of o.seats) { + if (seat.kind !== builtInKind) failures.push(`${seat.id} runs on "${seat.kind}", not the built-in "${builtInKind}"`); + } + // One copy of the built-in beside the roster flow: no worker flow of the harness's own was registered. const registered = [...o.registered].sort(); - if (JSON.stringify(registered) !== JSON.stringify(expected)) { - failures.push(`registered ${JSON.stringify(registered)}, wanted ${JSON.stringify(expected)}`); + const wanted = [builtInKind, ROSTER_FLOW_KIND].sort(); + if (JSON.stringify(registered) !== JSON.stringify(wanted)) { + failures.push(`registered ${JSON.stringify(registered)}, wanted ${JSON.stringify(wanted)}`); } if (failures.length === 0) { - evidence.push(`leg (a): ${seats.join(", ")} hired from files alone with no \`kinds\`, and registered`); + evidence.push(`leg (a): ${seats.join(", ")} hired from files alone onto one registered copy of "${builtInKind}"`); } } @@ -330,11 +379,11 @@ await runGoal(() => { ); } - // THE load-bearing assertion. A partial hire returns an array containing - // the valid seat instead of throwing, and turns this red. + // THE load-bearing assertion. A partial hire returns the copies the valid + // worker runs on instead of throwing, and turns this red. if (!o.refusal.threw) { failures.push( - `leg (c): the hire returned ${JSON.stringify(o.refusal.returnedSeatIds)} instead of refusing — ` + + `leg (c): the hire returned ${JSON.stringify(o.refusal.returnedCopyIds)} instead of refusing — ` + `a refusal after a partial hire is not a refusal`, ); } else { @@ -357,15 +406,15 @@ await runGoal(() => { // Secondary, and meaningful only because the roster is mixed. if (o.validWorkerStatusAfterRefusal !== 404) { failures.push( - `leg (c): the valid worker ${validId} answered ${o.validWorkerStatusAfterRefusal} on a host built ` + - `from what came back — a seat was registered anyway`, + `leg (c): a session with the valid worker ${validId} on "${builtInKind}" answered ` + + `${o.validWorkerStatusAfterRefusal} on a host built from what came back — a copy was registered anyway`, ); } if (o.refusal.threw && failures.length === 0) { evidence.push( `leg (c): a mixed roster (${validId} valid, ${invalidId} naming "${invalidKind}") refused by name, ` + - `listing "${builtInKind}", returning nothing — the valid worker's address 404s`, + `listing "${builtInKind}", returning nothing — a session with the valid worker 404s`, ); } } From aed8ce45e83f39a70b8df24029cbbbc8929998a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:00:19 +0000 Subject: [PATCH 02/19] fix(goals): the held-package goal runs its seats on one agent copy (FIX-1824) The harness hired with hireWorkforce(workers, { workerFlows, packageBlocks }). It now builds the installation with the generated packageBlocks and no worker flow, registers its copies, and asks each seat in a session on agent that names it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../a-held-package-reaches-one-worker/goal.md | 4 ++ .../harness.mts | 48 ++++++++++++++----- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/goals/workforce-packages/a-held-package-reaches-one-worker/goal.md b/goals/workforce-packages/a-held-package-reaches-one-worker/goal.md index 9fba9baca9..ba6eae2198 100644 --- a/goals/workforce-packages/a-held-package-reaches-one-worker/goal.md +++ b/goals/workforce-packages/a-held-package-reaches-one-worker/goal.md @@ -35,3 +35,7 @@ | 2026-09-25 | fix/fix-1459-pr-b @ 581dec56c + goal | vercel/openai/gpt-5.4-mini | PASS | Attempt 1 of 1. `iris`: 1 call, "MARIGOLD-4417 Ticket 58 has been logged; receipt: QUILL-7730." `otto`: 0 calls, "I can help draft it, but I don't have access to actually create the ticket…". `tess`: 0 calls, "MARIGOLD-4417 Ticket 58 could not be stamped." Leg 0 and leg (a) green. | | 2026-09-25 | same | vercel/openai/gpt-5.4-mini | FAIL (expected) | `move-to-sibling`: leg (a) showed `iris` holding [] and `otto` holding the moved package. In leg (b), on all 3 attempts, `otto` said MARIGOLD-4417, made 1 call and gave QUILL-7730, while `iris` did neither. The legs swapped. The scratch copy was removed. | | 2026-09-25 | same | vercel/openai/gpt-5.4-mini | FAIL (expected) | `drop-tools-line`: on all 3 attempts, only `tess` failed, for 1 call and giving QUILL-7730. `iris` and `otto` graded green. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | — | FAIL | Red on `main` since FIX-1788 P4, before any leg: the harness called `hireWorkforce(workers, { workerFlows, packageBlocks })`, which now takes an installation, and died with *"TypeError: installation.workerFlows is not a function"*. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | vercel/openai/gpt-5.4-mini | PASS | The harness builds `createWorkerInstallation({ standardWorkers, packageBlocks })` with no worker flow, so all three seats run on the one bound `agent` copy, and asks each in a session on it naming the seat. Attempt 1 of 1. `iris`: 1 call, "MARIGOLD-4417 Ticket 58 has been logged; receipt: QUILL-7730." `otto`: 0 calls, "I can help, but I don't have access to the support desk system…". `tess`: 0 calls, "MARIGOLD-4417 I can't stamp that ticket because no `stamp-ticket` tool is available here." | +| 2026-10-09 | same | vercel/openai/gpt-5.4-mini | FAIL (expected) | `move-to-sibling`: leg (a) showed `iris` holding [] and `otto` holding the moved package; in leg (b) `otto` said MARIGOLD-4417, made 1 call and gave QUILL-7730 while `iris` did neither. The legs swapped. | +| 2026-10-09 | same | vercel/openai/gpt-5.4-mini | FAIL (expected) | `drop-tools-line`: on all 3 attempts, only `tess` failed, for 1 call and giving QUILL-7730. | diff --git a/goals/workforce-packages/a-held-package-reaches-one-worker/harness.mts b/goals/workforce-packages/a-held-package-reaches-one-worker/harness.mts index e731baf155..f6eb54b12b 100644 --- a/goals/workforce-packages/a-held-package-reaches-one-worker/harness.mts +++ b/goals/workforce-packages/a-held-package-reaches-one-worker/harness.mts @@ -6,9 +6,11 @@ * directory, not the subject. * * Drives what a team adopting packages would do: read the tree with the real - * loader, import the module `fsdev gen` wrote from it, hire every seat onto the - * built-in agent kind with the generated `packageBlocks`, and ask each seat the - * same question over the real HTTP route. + * loader, import the module `fsdev gen` wrote from it, build the installation + * over every seat with the generated `packageBlocks`, register the copies + * `hireWorkforce` returns (every seat runs on the one built-in `agent` copy), + * and ask each seat the same question over the real HTTP route, in a session + * on that copy that names it. * * OBSERVES ONLY. Every assertion lives in run.mts; this file reports what * happened on one `__GOAL__` line. The tool calls are observed as a real side @@ -24,7 +26,12 @@ import { createGateway } from "@ai-sdk/gateway"; import { createModelResolver } from "@flow-state-dev/core"; import { createFlowState, inMemoryStores } from "@flow-state-dev/engine"; -import { defineAgentWorkerFlow, hireWorkforce } from "@flow-state-dev/workforce"; +import { + WORKER_ID_STATE_KEY, + createWorkerInstallation, + hireWorkforce, + inventorySeats, +} from "@flow-state-dev/workforce"; import { readWorkforce } from "@flow-state-dev/workforce/loader"; const MODEL = process.env.GOAL_MODEL ?? "vercel/openai/gpt-5.4-mini"; @@ -107,23 +114,42 @@ async function main(): Promise { Object.entries(generated.packageBlocks).map(([address, blocks]) => [address, Object.keys(blocks)]), ); - const agent = defineAgentWorkerFlow(); - const seats = hireWorkforce(loaded.workers, { - workerFlows: { agent }, + // No worker flow is given, so every seat runs on the built-in `agent`, bound + // to this installation. + const installation = createWorkerInstallation({ + standardWorkers: loaded.workers, packageBlocks: generated.packageBlocks, }); + const copies = hireWorkforce(installation); + // Each seat, and the flow it runs on. + const seats = inventorySeats(installation); out.seatIds = seats.map((s) => s.id); const flowState = createFlowState({ - flows: Object.fromEntries(seats.map((seat) => [seat.id, seat])), + flows: Object.fromEntries(copies.map((copy) => [copy.id, copy])), stores: { dev: { primary: inMemoryStores() } }, modelResolver, } as never); const router = await flowState.getRouter(); const stores = (await flowState.getRuntime()).stores; - async function ask(address: string, sessionId: string): Promise { - const path = [address, sessionId, "actions", "run"]; + async function ask(seat: { id: string; kind: string }, sessionId: string): Promise { + const address = seat.id; + // A seat has no flow address of its own: it answers in a session of the + // flow it runs on, created naming it. + const sessionPath = [seat.kind, "sessions"]; + const opened = await router.POST( + new Request(`http://goal/api/flows/${sessionPath.join("/")}`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ userId: USER_ID, sessionId, state: { [WORKER_ID_STATE_KEY]: seat.id } }), + }), + { params: { path: sessionPath } } as never, + ); + if (opened.status !== 201) { + throw new Error(`${address}: a session on "${seat.kind}" naming it answered ${opened.status}: ${await opened.text()}`); + } + const path = [seat.kind, sessionId, "actions", "run"]; const res = await router.POST( new Request(`http://goal/api/flows/${path.join("/")}`, { method: "POST", @@ -161,7 +187,7 @@ async function main(): Promise { const turns: Record = {}; for (const seat of seats) { counter.__goalStampCalls = 0; - const reply = await ask(seat.id, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); + const reply = await ask(seat, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); turns[seat.id] = { reply, calls: counter.__goalStampCalls ?? 0 }; } attempts.push(turns); From 55634c00be9b090b5931a8a5c8876f47cbc80611 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:01:55 +0000 Subject: [PATCH 03/19] fix(goals): the capabilities goal builds its kind on the installation (FIX-1824) The harness hired with hireWorkforce(workers, { workerFlows: { agent } }). The agent carrying the team's capabilities is now a workerFlow builder on createWorkerInstallation, and each seat is asked in a session on the one agent copy that names it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../goal.md | 3 ++ .../harness.mts | 42 +++++++++++++++---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/goals/workforce-conventions/capabilities-come-from-files-alone/goal.md b/goals/workforce-conventions/capabilities-come-from-files-alone/goal.md index 87319424a6..0c269ec69b 100644 --- a/goals/workforce-conventions/capabilities-come-from-files-alone/goal.md +++ b/goals/workforce-conventions/capabilities-come-from-files-alone/goal.md @@ -21,3 +21,6 @@ |------|--------|-------|---------|-------| | 2026-09-17 | fix/FIX-1388-P3 | — | BLOCKED | Run attempted; it reached the model call and stopped there: `No API key found for gateway "vercel". Set AI_GATEWAY_API_KEY environment variable.` Everything before the provider ran on the real path — leg 0 passed, the generated module was imported, the capability landed on the kind through `uses`, both seats hired carrying their own selections, registered, and each turn reached the answering generator. Leg (b) is unrun, so the model has not yet been shown answering from one seat's file and not the other's. That behaviour is covered mock-side by `packages/workforce/test/seat-capabilities.test.ts`, whose duplicate-preset and no-per-seat-resolution controls were both seen red first — a weaker bar than this goal, not a substitute for it. **Re-run this goal in an environment with an inference credential before treating the acceptance criterion as met.** | | 2026-09-24 | 49472de (main) | openai/gpt-5.4-mini | PASS | Re-run in the FSD cloud environment with `AI_GATEWAY_API_KEY` set; the `FSDEV_*` overrides did not need unsetting. All legs passed on attempt 1 of 1: `support.iris` (named `["briefing"]`) answered `LANTERN-2208`, `support.otto` (named nothing) answered "I do not know", neither carried `THISTLE-6194`. Both controls went red on the same path from reply grading: `install-everything` failed leg (b) on all 3 attempts because `support.otto` answered `LANTERN-2208`; `ignore-selection` failed because `support.iris` hired naming `[]` and answered "I do not know" on all 3 attempts. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | — | FAIL | Red on `main` since FIX-1788 P4, before any leg: the harness called `hireWorkforce(workers, { workerFlows: { agent } })`, which now takes an installation, and died with *"TypeError: installation.workerFlows is not a function"*. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | openai/gpt-5.4-mini | PASS | The kind carrying the capabilities is now a `workerFlow` builder on the installation (`defineAgentWorkerFlow({ installation, uses })`), registered as one `agent` copy that runs both seats, each asked in a session on it naming the seat. Attempt 1 of 1: `support.iris` (named `["briefing"]`) answered `LANTERN-2208`, `support.otto` (named nothing) answered "I do not know", neither carried `THISTLE-6194`. | +| 2026-10-09 | same (controls) | openai/gpt-5.4-mini | FAIL (expected) | `install-everything`: leg (b) on all 3 attempts, `support.otto` answered `LANTERN-2208`. `ignore-selection`: leg (a) `support.iris` reached the hire naming `[]`, and leg (b) on all 3 attempts it answered "I do not know". | diff --git a/goals/workforce-conventions/capabilities-come-from-files-alone/harness.mts b/goals/workforce-conventions/capabilities-come-from-files-alone/harness.mts index 81f9b68add..18f25c063e 100644 --- a/goals/workforce-conventions/capabilities-come-from-files-alone/harness.mts +++ b/goals/workforce-conventions/capabilities-come-from-files-alone/harness.mts @@ -32,9 +32,13 @@ import { createGateway } from "@ai-sdk/gateway"; import { createModelResolver } from "@flow-state-dev/core"; import { createFlowState, inMemoryStores } from "@flow-state-dev/engine"; import { + WORKER_ID_STATE_KEY, + createWorkerInstallation, defineAgentWorkerFlow, hireWorkforce, + inventorySeats, splitResourceModules, + workerFlow, } from "@flow-state-dev/workforce"; import { readWorkforce } from "@flow-state-dev/workforce/loader"; @@ -148,22 +152,44 @@ async function main(): Promise { ) : capabilities; - const agent = defineAgentWorkerFlow({ uses: installed as never }); - const seats = hireWorkforce(workers, { workerFlows: { agent } }); + // The kind, carrying the capabilities, built on the installation that runs + // both seats on its one copy. + const installation = createWorkerInstallation({ + standardWorkers: workers, + workerFlows: { agent: workerFlow((on) => defineAgentWorkerFlow({ installation: on, uses: installed as never })) }, + }); + const copies = hireWorkforce(installation); + // Each seat, and the flow it runs on. + const seats = inventorySeats(installation); out.seatIds = seats.map((s) => s.id); // ---- register and ask, over the real route ------------------------------ const flowState = createFlowState({ - flows: Object.fromEntries(seats.map((seat) => [seat.id, seat])), + flows: Object.fromEntries(copies.map((copy) => [copy.id, copy])), stores: { dev: { primary: inMemoryStores() } }, modelResolver, } as never); const router = await flowState.getRouter(); const stores = (await flowState.getRuntime()).stores; - out.registered = seats.map((s) => s.id); - - async function ask(address: string, sessionId: string): Promise { - const path = [address, sessionId, "actions", "run"]; + out.registered = copies.map((copy) => copy.id); + + async function ask(seat: { id: string; kind: string }, sessionId: string): Promise { + const address = seat.id; + // A seat has no flow address of its own: it answers in a session of the + // flow it runs on, created naming it. + const sessionPath = [seat.kind, "sessions"]; + const opened = await router.POST( + new Request(`http://goal/api/flows/${sessionPath.join("/")}`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ userId: USER_ID, sessionId, state: { [WORKER_ID_STATE_KEY]: seat.id } }), + }), + { params: { path: sessionPath } } as never, + ); + if (opened.status !== 201) { + throw new Error(`${address}: a session on "${seat.kind}" naming it answered ${opened.status}: ${await opened.text()}`); + } + const path = [seat.kind, sessionId, "actions", "run"]; const res = await router.POST( new Request(`http://goal/api/flows/${path.join("/")}`, { method: "POST", @@ -212,7 +238,7 @@ async function main(): Promise { for (let attempt = 1; attempt <= ATTEMPTS; attempt += 1) { const replies: Record = {}; for (const seat of seats) { - replies[seat.id] = await ask(seat.id, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); + replies[seat.id] = await ask(seat, `s_${attempt}_${seat.id.replace(/\W/g, "_")}`); } attempts.push(replies); if (eachSeatOnItsOwnFile(replies)) break; From 42214712391ae520c27563b626a04da1ba4e12ac Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:08:45 +0000 Subject: [PATCH 04/19] fix(goals): it-shows-who-is-on-shift on one copy per flow, asks by workerId (FIX-1824) The shift-lab hired with hireWorkforce(tree.workers, { workerFlows }). It now runs every worker on one copy of lead or seat through installWorkers; the drain and each ask open their session on that copy naming the worker, and a row's run session names the lead that drained it. The store oracle read a session's flowId as its seat. goals/lib/shift-manager gains pendingSeatAsks, which picks the person's pending asks as Shift Manager's reads.ts does (a session on a seat's kind that names that seat, or names none), and workerOf. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- goals/README.md | 2 +- goals/lib/shift-manager.mts | 56 ++++++++++++ .../it-shows-who-is-on-shift/goal.md | 4 + .../it-shows-who-is-on-shift/lab/lab.mts | 86 +++++++++++++------ .../it-shows-who-is-on-shift/run.mts | 23 ++--- 5 files changed, 128 insertions(+), 43 deletions(-) diff --git a/goals/README.md b/goals/README.md index 8e7d3ee39e..1fc54b2de9 100644 --- a/goals/README.md +++ b/goals/README.md @@ -99,7 +99,7 @@ Every goal repeats the same scaffolding around the part that is actually its own | `specs` | `runSpecs` — delegate to an app's mock-free vitest specs | | `server` | `refuseIfAnswering`, `stopProcessGroup` — for a goal that spawns its own server: refuse when anything already answers on the port, and stop the whole detached process group so no survivor is left for the next run to grade | | `playwright` | `launchChromium`, `preinstalledChromium` — Chromium for a goal that reads the shipped DevTool. **Not re-exported from `index.mts`**, so a goal that opens no browser does not load Playwright; import `../../lib/playwright.mts` directly | -| `shift-manager` | `buildShiftManagerCopy` (a patched scratch copy, built with Vite), `startShiftManager` (its command over a Lab, with `NODE_ENV` as it was before any in-process build; optional `root`, `tsx` and `timeoutMs` to serve another checkout, including an older one that has only `bin/start.mts`), `labApi` (the Lab's routes) — for the Shift Manager goals; and, for a goal that drives Shift Manager as a person in Playwright, `buildShiftManagerPages`, `labRoutes` (`labApi` read as one verified user) and `personPage` (a browser context as a given person). **Not re-exported from `index.mts`**; import `../../lib/shift-manager.mts` directly | +| `shift-manager` | `buildShiftManagerCopy` (a patched scratch copy, built with Vite), `startShiftManager` (its command over a Lab, with `NODE_ENV` as it was before any in-process build; optional `root`, `tsx` and `timeoutMs` to serve another checkout, including an older one that has only `bin/start.mts`), `labApi` (the Lab's routes), `pendingSeatAsks` (the person's pending asks on the seats' sessions, picked as Shift Manager picks them) and `workerOf` (the worker a listed session names) — for the Shift Manager goals; and, for a goal that drives Shift Manager as a person in Playwright, `buildShiftManagerPages`, `labRoutes` (`labApi` read as one verified user) and `personPage` (a browser context as a given person). **Not re-exported from `index.mts`**; import `../../lib/shift-manager.mts` directly | The library covers scaffolding only. **The grading logic is the goal** and belongs in `run.mts`. So does retry *policy* — the corpus has three, and they mean different things (retry-until-first-pass over model flakiness vs. require-k-of-k where the stability number is itself the published result). diff --git a/goals/lib/shift-manager.mts b/goals/lib/shift-manager.mts index 8c390447f8..5d7f9898e4 100644 --- a/goals/lib/shift-manager.mts +++ b/goals/lib/shift-manager.mts @@ -17,6 +17,9 @@ * itself. * - {@link labApi}: the Lab's HTTP routes, read with the goal's own requests, * so a goal's oracle is the store and never Shift Manager's state. + * - {@link pendingSeatAsks}: the person's pending asks on the seats' sessions, + * picked the way Shift Manager picks them, and {@link workerOf}, the worker + * a listed session names. * * `vite.build()` run in-process sets `process.env.NODE_ENV` to `production` * and never restores it. A Lab started after a build would inherit it, which @@ -36,6 +39,7 @@ import { createRequire } from "node:module"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; import type { Browser, BrowserContext, Page } from "playwright"; +import { WORKER_ID_STATE_KEY } from "@flow-state-dev/workforce/browser"; import { intentFreeEnv } from "./env.mts"; import { REPO_ROOT, repoPath } from "./paths.mts"; @@ -238,6 +242,58 @@ export function labApi(origin: string, bearer: string | undefined) { /** A Lab's routes, as {@link labApi} reads them. */ export type LabApi = ReturnType; +/** Suspension reasons that are a person being asked something. */ +const PERSON_REASONS = new Set(["human_approval", "human_input"]); + +/** The worker a listed session runs, as its state names it (`workerId`), or `null` when it names none. */ +export function workerOf(session: Readonly>): string | null { + const worker = session.state?.[WORKER_ID_STATE_KEY]; + return typeof worker === "string" ? worker : null; +} + +/** A person-ask still pending in a seat's session. */ +export type PendingAsk = { + suspensionId: string; + /** The session it waits in. */ + sessionId: string; + /** The seat that session names as its worker, or `null` when it names none. */ + seatId: string | null; +}; + +/** + * The person's pending asks, read from the seats' sessions as Shift Manager + * reads them (`packages/shift-manager/src/lib/reads.ts`): a session on a + * seat's kind that names that seat as its worker, or names no worker at all, + * whose asks are then the seat-less ones. An ask is a suspension asking a + * person that holds no resume. + * + * @param api Reads one session's items by type: {@link LabApi}'s `items`, or a goal's own. + * @param sessions The person's session listing, dispatch runs included: a seat + * a mailbox post woke asks from one. + * @param seats The inventory's seats, each with the kind it runs on. + */ +export async function pendingSeatAsks( + api: { items(sessionId: string, types: string[]): Promise>> }, + sessions: ReadonlyArray>>, + seats: ReadonlyArray<{ id: string; kind: string | null }>, +): Promise { + const ids = new Set(seats.map((s) => s.id)); + const kinds = new Set(seats.flatMap((s) => (s.kind === null ? [] : [s.kind]))); + const asks: PendingAsk[] = []; + for (const session of sessions) { + const seatId = workerOf(session); + if (!kinds.has(String(session.flowKind)) || (seatId !== null && !ids.has(seatId))) continue; + const found = await api.items(String(session.id), ["suspension", "suspension_resume"]); + const resumed = new Set(found.filter((i) => i.type === "suspension_resume").map((i) => String(i.suspensionId))); + for (const item of found) { + if (item.type === "suspension" && PERSON_REASONS.has(String(item.reason)) && !resumed.has(String(item.suspensionId))) { + asks.push({ suspensionId: String(item.suspensionId), sessionId: String(session.id), seatId }); + } + } + } + return asks; +} + /** * Build Shift Manager's pages into `outDir` with the Vite the checkout at * `root` carries. diff --git a/goals/shift-manager/it-shows-who-is-on-shift/goal.md b/goals/shift-manager/it-shows-who-is-on-shift/goal.md index 3cca6dace1..3e31edb0ca 100644 --- a/goals/shift-manager/it-shows-who-is-on-shift/goal.md +++ b/goals/shift-manager/it-shows-who-is-on-shift/goal.md @@ -38,3 +38,7 @@ | 2026-10-01 | feat/FIX-1723-roster (pre-PR) | n/a | PASS | Spread 1: 7 workers in [Staff, eng, ops]: eng.coder on shift (1 held), eng.reviewer on call (1 parked), ops.asker on call (1 ask), ops.waiter off shift (1 queued), eng.lead, eng.spare and chief-of-staff off shift. Spread 2: eng.reviewer on shift (2 held, 1 parked), ops.waiter on shift, eng.coder on call (1 parked, 1 queued), eng.spare on call (2 asks), ops.asker off shift (1 queued). | | 2026-10-01 | feat/FIX-1723-roster (pre-PR), `GOAL_CONTROL=ignore-asks` | n/a | FAIL (expected) | **status** on ops.asker (spread 1) and eng.spare (spread 2), drawn off shift where the store says on call, with the **summary**, **sidebar** and **TEAMS** counts that follow from it. slots, holding, waits, roster and filter pass. | | 2026-10-01 | feat/FIX-1723-roster (pre-PR), `GOAL_CONTROL=count-queued` | n/a | FAIL (expected) | **slots** and **holding** on ops.waiter (spread 1), eng.coder and ops.asker (spread 2): "1 in use" where the worker holds 0 rows and 1 queued. status, summary, sidebar, TEAMS and filter pass. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | n/a | FAIL | Red on `main` since FIX-1788 P4, before any leg: *"Shift Manager's command never served the shift-lab … Failed to load fsdev config …/lab/fsdev.config.mts: installation.workerFlows is not a function"* (`lab.mts` called `hireWorkforce(tree.workers, { workerFlows })`). | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | PASS | The lab runs every worker on one copy of `lead` or `seat` (`installWorkers`); the drain and each ask open their session on that copy naming the worker, and a row's run session names the lead that drained it. The **store** oracle reads asks through `goals/lib`'s `pendingSeatAsks`: a session on a seat's kind that names that seat, or names none. Spread 1: eng.coder on shift (1 held), eng.reviewer on call (1 parked), ops.asker on call (1 ask), ops.waiter off shift (1 queued), eng.lead, eng.spare and chief-of-staff off shift. Spread 2: eng.reviewer on shift (2 held, 1 parked), ops.waiter on shift, eng.coder on call (1 parked, 1 queued), eng.spare on call (2 asks), ops.asker off shift (1 queued). | +| 2026-10-09 | same, `GOAL_CONTROL=ignore-asks` | n/a | FAIL (expected) | **status** on ops.asker (spread 1) and eng.spare (spread 2), drawn off shift where the store says on call, with the **summary**, **sidebar** and **TEAMS** counts that follow. slots, holding, waits, roster and filter pass. The store saw each ask on its own seat, through the session's `workerId`. | +| 2026-10-09 | same, `GOAL_CONTROL=count-queued` | n/a | FAIL (expected) | **slots** and **holding** on ops.waiter (spread 1), eng.coder and ops.asker (spread 2). status, summary, sidebar, TEAMS and filter pass. | diff --git a/goals/shift-manager/it-shows-who-is-on-shift/lab/lab.mts b/goals/shift-manager/it-shows-who-is-on-shift/lab/lab.mts index 7578b2c7fa..119cbca196 100644 --- a/goals/shift-manager/it-shows-who-is-on-shift/lab/lab.mts +++ b/goals/shift-manager/it-shows-who-is-on-shift/lab/lab.mts @@ -17,7 +17,11 @@ * aborted; * - `parked`: a row its run parks for a person (`awaitReview`), then returns; * - `queued`: a row filed after the only drain, so nothing ever claims it; - * - `ask`: a pending approval in a session of its own, on its own flow. + * - `ask`: a pending approval in a session of its own, on the flow it runs on, + * naming it. + * + * Every worker runs on one copy of the flow its file names (`lead` or + * `seat`), and each of its sessions names it in its state (`workerId`). * * Every row is filed through the mailbox's own `fileTask`, assigned by the * worker's name. No model: the runs are scripted. @@ -30,11 +34,12 @@ import { taskBoard, taskWorkerInputSchema } from "@flow-state-dev/orchestration/ import { getOrCreateTaskCollection, type TaskWorkerInput } from "@flow-state-dev/orchestration/tasks"; import { MAILBOX_KIND, + WORKER_ID_STATE_KEY, mailboxBoard, mailboxBoardIds, mailboxInstances, defineMailboxFlow, - hireWorkforce, + inventorySeats, openMailboxes, openInventory, workerConfigSchema, @@ -46,6 +51,7 @@ import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import { z } from "zod"; import { workerDoor } from "../../../lib/worker-door.mts"; +import { installWorkers } from "../../../lib/workers.mts"; /** The tree this Lab reads. */ const SHIFT_LAB_TREE = join(dirname(fileURLToPath(import.meta.url)), "workforce"); @@ -159,37 +165,54 @@ export async function openShiftLab(spread: Spread = spreadFromEnv()) { }, }); + // A row runs on the lead's flow, in a session of its own that names the lead + // whose drain handed it over, as the session it was drained from does. const leadBoard = taskBoard({ name: "shift-lab-lead", boardId: `${ledger.id}-board`, collection: ledger, workers: Object.fromEntries( - seats.map((seat) => [seat.name, dispatcher({ name: `shift-lab-hand-${seat.name}`, action: ENTRY, session: "per-task" })]), + seats.map((seat) => [ + seat.name, + dispatcher({ + name: `shift-lab-hand-${seat.name}`, + action: ENTRY, + session: "per-task", + state: (_task, ctx) => ({ [WORKER_ID_STATE_KEY]: (ctx.session.state as Record)[WORKER_ID_STATE_KEY] }), + }), + ]), ), }); - const leadKind = defineFlow({ - kind: drainer.declared.flow as string, - cardinality: "collection", - configSchema: workerConfigSchema(), - resources: { [ledger.id]: ledger }, - actions: { drain: { block: leadBoard.drain }, ...workerDoor }, - task: { actions: { [ENTRY]: { block: scriptedRun } } }, - } as never); - const seatKind = defineFlow({ - kind: SEAT_KIND, - cardinality: "collection", - configSchema: workerConfigSchema().extend({ handoff: z.enum(["per-task", "per-worker"]).optional() }), - actions: { ...workerDoor, ask: { block: sequencer({ name: "shift-lab-ask", inputSchema: z.object({ what: z.string() }) }).step(gate), durable: true } }, - } as never); + const leadFlow = drainer.declared.flow as string; - const hired = hireWorkforce(tree.workers, { - workerFlows: { [drainer.declared.flow as string]: leadKind as never, [SEAT_KIND]: seatKind as never }, - mailboxBoards: mailboxBoardIds(tree.mailboxes), - }); + // One copy of each flow, which every worker that names it runs on. + const { installation, copies } = installWorkers( + tree.workers, + (installation) => ({ + [leadFlow]: defineFlow({ + kind: leadFlow, + cardinality: "collection", + configSchema: workerConfigSchema(), + session: installation.session(), + resources: { [ledger.id]: ledger, ...installation.resources }, + actions: { drain: { block: leadBoard.drain }, ...workerDoor }, + task: { actions: { [ENTRY]: { block: scriptedRun } } }, + } as never), + [SEAT_KIND]: defineFlow({ + kind: SEAT_KIND, + cardinality: "collection", + configSchema: workerConfigSchema().extend({ handoff: z.enum(["per-task", "per-worker"]).optional() }), + session: installation.session(), + resources: { ...installation.resources }, + actions: { ...workerDoor, ask: { block: sequencer({ name: "shift-lab-ask", inputSchema: z.object({ what: z.string() }) }).step(gate), durable: true } }, + } as never), + }), + { mailboxBoards: mailboxBoardIds(tree.mailboxes) }, + ); const instances = mailboxInstances(tree.mailboxes, { kinds: { [MAILBOX_KIND]: defineMailboxFlow({ inventory: true }) as never } }); const flows: Record = { ...Object.fromEntries(instances.map((i) => [i.kind, i])), - ...Object.fromEntries(hired.map((seat) => [seat.id, seat])), + ...Object.fromEntries(copies.map((copy) => [copy.id, copy])), }; const flowState = createFlowState({ flows, @@ -246,7 +269,7 @@ export async function openShiftLab(spread: Spread = spreadFromEnv()) { }; const inventory = await openInventory( - { seats: [...hired, ORG_SEAT], mailboxes: tree.mailboxes }, + { seats: [...inventorySeats(installation), ORG_SEAT], mailboxes: tree.mailboxes }, { run: (request: InventoryActionRequest) => act(flows[request.flowKind]!, request.sessionId, request.action, request.input, request.source), seatWriter: { flowKind: MAILBOX_KIND }, @@ -262,14 +285,27 @@ export async function openShiftLab(spread: Spread = spreadFromEnv()) { act(mailboxInstance, mailbox.id, "fileTask", { board: boardName, goal, assignee: name, input: script }); const states = (wanted: ShiftState) => Object.entries(spread).flatMap(([name, list]) => list.filter((s) => s === wanted).map(() => name)); + /** A session on `flow` with `worker`, created naming it: a worker has no flow address of its own. */ + const openWorkerSession = async (flow: string, worker: string, sessionId: string) => { + const opened = await call("POST", [flow, "sessions"], { + userId: SHIFT_LAB_USER_ID, + sessionId, + state: { [WORKER_ID_STATE_KEY]: worker }, + }); + if (opened.status !== 201) throw new Error(`a session with ${worker} on "${flow}": ${opened.status} ${JSON.stringify(opened.body)}`); + }; + for (const name of states("held")) await file(name, `${name}: hold until stopped`, {}); for (const name of states("parked")) await file(name, `${name}: park for a person`, { park: true }); - await act(hired.find((seat) => seat.id === drainer.id)! as FlowInstance, DRAIN_SESSION, "drain", {}); + await openWorkerSession(leadFlow, drainer.id, DRAIN_SESSION); + await act(flows[leadFlow]!, DRAIN_SESSION, "drain", {}); // Filed after the only drain, so nothing ever claims them. for (const name of states("queued")) await file(name, `${name}: filed after the drain`, {}); for (const [i, name] of states("ask").entries()) { const seat = seats.find((s) => s.name === name)!; - const posted = await call("POST", [seat.id, `s_shift_lab_ask_${name}_${i}`, "actions", "ask"], { + const sessionId = `s_shift_lab_ask_${name}_${i}`; + await openWorkerSession(SEAT_KIND, seat.id, sessionId); + const posted = await call("POST", [SEAT_KIND, sessionId, "actions", "ask"], { userId: SHIFT_LAB_USER_ID, input: { what: `${name} wants to go ahead` }, }); diff --git a/goals/shift-manager/it-shows-who-is-on-shift/run.mts b/goals/shift-manager/it-shows-who-is-on-shift/run.mts index 31b680fdec..7947a15441 100644 --- a/goals/shift-manager/it-shows-who-is-on-shift/run.mts +++ b/goals/shift-manager/it-shows-who-is-on-shift/run.mts @@ -46,7 +46,7 @@ import { join } from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import type { Browser, Page } from "playwright"; import { REPO_ROOT, goalTmpDir, intentFreeEnv, loadFixture, runGoal } from "../../lib/index.mts"; -import { SHIFT_MANAGER_COMMAND, servedAddresses } from "../../lib/shift-manager.mts"; +import { SHIFT_MANAGER_COMMAND, pendingSeatAsks, servedAddresses } from "../../lib/shift-manager.mts"; import { launchChromium } from "../../lib/playwright.mts"; const CONTROL = process.env.GOAL_CONTROL ?? ""; @@ -71,8 +71,6 @@ const CONFIG = join(HERE, "lab", "fsdev.config.mts"); /** The group a seat with no team sits in, as the design names it. */ const STAFF = "Staff"; -/** Suspension reasons that are a person being asked something. */ -const PERSON_REASONS = new Set(["human_approval", "human_input"]); const STATUSES = ["on shift", "on call", "off shift"] as const; type Status = (typeof STATUSES)[number]; @@ -213,14 +211,14 @@ async function readStore(api: LabApi, userId: string): Promise>; // The inventory, through a mailbox's session, by its published key patterns. const mailboxIds: string[] = []; - let seats: string[] = []; + let seatRows: Array<{ id: string; kind: string | null }> = []; for (const host of sessions.filter((s) => s.flowKind === "mailbox" && String(s.id).includes("."))) { const manifest = await api.get(`/sessions/${encodeURIComponent(host.id)}/manifest`); const refOf = (pattern: string) => (manifest.resources as Array<{ kind: string; ref: string; pattern: string }>).find((r) => r.kind === "collection" && r.pattern === pattern)?.ref; const seatsRef = refOf("inventory/seats/*"); const mailboxesRef = refOf("inventory/mailboxes/*"); if (seatsRef === undefined || mailboxesRef === undefined) continue; - seats = (await api.collection(host.id, seatsRef)).map((r) => String(r.id)); + seatRows = (await api.collection(host.id, seatsRef)).map((r) => ({ id: String(r.id), kind: r.kind == null ? null : String(r.kind) })); mailboxIds.push(...(await api.collection(host.id, mailboxesRef)).map((r) => String(r.id))); break; } @@ -237,18 +235,9 @@ async function readStore(api: LabApi, userId: string): Promise = []; - for (const session of sessions) { - if (!seats.includes(String(session.flowId))) continue; - const found = await api.items(String(session.id), ["suspension", "suspension_resume"]); - const resumed = new Set(found.filter((i) => i.type === "suspension_resume").map((i) => String(i.suspensionId))); - for (const item of found) { - if (item.type === "suspension" && PERSON_REASONS.has(String(item.reason)) && !resumed.has(String(item.suspensionId))) { - asks.push({ seat: String(session.flowId), id: String(item.suspensionId) }); - } - } - } + const seats = seatRows.map((s) => s.id); + // Pending person-asks on the seats' sessions, by the seat each session names. + const asks = (await pendingSeatAsks(api, sessions, seatRows)).map((a) => ({ seat: a.seatId, id: a.suspensionId })); const unmatched = rows.filter((r) => seatOf(seats, r.assignee) === undefined).map((r) => `${r.key} (${r.assignee})`); const workers = seats.map((id): Worker => { const mine = rows.filter((r) => seatOf(seats, r.assignee) === id); From 1fdfb1f9971cf121738e487e899c1160a2dce386 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:12:27 +0000 Subject: [PATCH 05/19] fix(goals): the chief-of-staff desk on one copy per flow (FIX-1824) open-desk.mts hired with hireWorkforce(tree.workers, { workerFlows }) and an asker flow built without its installation. It now goes through installWorkers and inventorySeats. The check raises its asks in sessions on the asker's flow created naming the asker, and finds the chief of staff's line in a session that names it as its worker rather than one whose flowId is the seat. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../goal.md | 4 ++++ .../lab/open-desk.mts | 15 ++++++++------- .../run.mts | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md index 45199fd7e2..f5769a9ac8 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md @@ -44,3 +44,7 @@ The seat, mailbox and board names are read from the tree at run time. Tokens are | 2026-10-01 | f2d2c7278+wip (main merged; review fixes) | openai/gpt-5.4-mini (vercel gateway) | FAIL (control `optimistic-reply`, expected) | Only `[desk] talk`, as before. | | 2026-10-01 | f2d2c7278+wip (main merged; review fixes) | openai/gpt-5.4-mini (vercel gateway) | FAIL (control `static-brief`, expected) | Only `[desk] inline`: 2 shown while the store holds 1, and the answered ask still listed. | | 2026-10-02 | a65594ee1+wip (FIX-1719 PR 2) | openai/gpt-5.4-mini (vercel gateway) | PASS | The no-CoS leg now runs on `lab-no-cos/` (the desk's `asker` alone), because DevTeam declares a chief of staff since FIX-1719. Summary 2 need you / 2 pending; Approve from the summary 2 → 1; line and reply drawn by id, again after a reload; the Lab with no chief of staff lands on the view with the summary and the no-chief-of-staff line. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | n/a | FAIL | Red on `main` since FIX-1788 P4, before any leg: *"Shift Manager's command never served desk … Failed to load fsdev config …/lab/fsdev.config.mts: Cannot read properties of undefined (reading 'session')"* (`open-desk.mts` called `hireWorkforce(tree.workers, { workerFlows })` and `defineAskerFlow()` with no installation). | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | openai/gpt-5.4-mini (vercel gateway) | PASS | The desk runs each seat on one copy of `asker` or `agent` (`installWorkers`). The check raises each ask in a session on `asker` created naming the asker, and finds the line in a direct session that names `desk.chief-of-staff` as its worker. Summary 2 need you / 2 pending, `desk.front` 0 running; Approve from the summary: store 2 → 1, summary 2 → 1, Inbox 1; the line was held in `conv_9d487fe8…` when *delivered* was drawn, the stored reply drawn by id, and again after a reload; the Lab with no chief of staff lands on the view with the summary and its no-coordinator line. | +| 2026-10-09 | same (control `static-brief`) | openai/gpt-5.4-mini (vercel gateway) | FAIL (expected) | Only `[desk] inline`: after Approve the summary says 2 need you while the store holds 1, and still lists the answered ask. | +| 2026-10-09 | same (control `optimistic-reply`) | n/a | FAIL (stale control) | Fails at the build, not at **talk**: *"the build never imported …/packages/shift-manager/src/lib/cos.ts, so nothing was swapped"*. `lib/cos.ts` was folded into `lib/conversation.ts` by 260690140 (2026-10-07), which is on `main`, so the control is red at setup with or without this change. Re-pointing it at the conversation hook is follow-up work; until then **talk** has no working control. | diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/lab/open-desk.mts b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/lab/open-desk.mts index a62370fd0a..30ba23dd9f 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/lab/open-desk.mts +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/lab/open-desk.mts @@ -2,8 +2,9 @@ * The goal's fixture Labs, opened the way Shift Manager's command loads * one: a tree with one team, `desk`, whose seats run the turn goal's `asker` * kind or the built-in `agent` kind with a real model, in one mailbox with one - * board. The organization's inventory is open, so each seat's row names its - * door. In-memory stores and no credential, so every start is fresh. The check + * board. Each kind is one registered copy that every seat naming it runs on, + * and a seat's sessions name it in their state. The organization's inventory + * is open, so each seat's row names its door. In-memory stores and no credential, so every start is fresh. The check * raises the asks itself, through the Lab's own action route, so the Lab * reopens them when they are answered. * @@ -22,13 +23,14 @@ import { mailboxBoardIds, mailboxInstances, defineMailboxFlow, - hireWorkforce, + inventorySeats, openMailboxes, openInventory, type InventoryActionRequest, type OpenMailboxesOptions, } from "@flow-state-dev/workforce"; import { readDeclaredRoster } from "@flow-state-dev/workforce/loader"; +import { installWorkers } from "../../../lib/workers.mts"; import { ASKER_KIND, defineAskerFlow } from "../../it-sends-a-turn-into-a-seat-session/lab/asker/asker.mts"; /** The one person this Lab runs as. */ @@ -44,14 +46,13 @@ export async function openDesk(root: string) { const tree = await readDeclaredRoster(root); if (tree.problems.length > 0) throw new Error(`the desk tree did not load: ${tree.problems.map((p) => p.error.message).join("; ")}`); - const seats = hireWorkforce(tree.workers, { - workerFlows: { [ASKER_KIND]: defineAskerFlow() as never }, + const { installation, copies } = installWorkers(tree.workers, (installation) => ({ [ASKER_KIND]: defineAskerFlow(installation) }), { mailboxBoards: mailboxBoardIds(tree.mailboxes), }); const mailboxKind = defineMailboxFlow({ inventory: true }); const flows: Record = { ...Object.fromEntries(mailboxInstances(tree.mailboxes, { kinds: { [MAILBOX_KIND]: mailboxKind as never } }).map((i) => [i.kind, i])), - ...Object.fromEntries(seats.map((seat) => [seat.id, seat])), + ...Object.fromEntries(copies.map((copy) => [copy.id, copy])), }; const flowState = createFlowState({ flows, @@ -93,7 +94,7 @@ export async function openDesk(root: string) { const runtime = await flowState.getRuntime(); const opened = await openInventory( - { seats, mailboxes: tree.mailboxes }, + { seats: inventorySeats(installation), mailboxes: tree.mailboxes }, { run: async (request: InventoryActionRequest) => { const result = (await runAction({ diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts index f39695e515..55319a6446 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts @@ -50,9 +50,10 @@ import { createRequire } from "node:module"; import { join } from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import type { Page } from "playwright"; +import { WORKER_ID_STATE_KEY } from "@flow-state-dev/workforce/browser"; import { readDeclaredRoster } from "@flow-state-dev/workforce/loader"; import { REPO_ROOT, goalTmpDir, intentFreeEnv, runGoal } from "../../lib/index.mts"; -import { SHIFT_MANAGER_COMMAND, servedAddresses } from "../../lib/shift-manager.mts"; +import { SHIFT_MANAGER_COMMAND, servedAddresses, workerOf } from "../../lib/shift-manager.mts"; import { launchChromium } from "../../lib/playwright.mts"; const CONTROL = process.env.GOAL_CONTROL ?? ""; @@ -188,7 +189,7 @@ function labApi(origin: string, bearer: string | undefined) { return out; }; /** The person's sessions, dispatch runs included. */ - const sessions = async (userId: string): Promise> => + const sessions = async (userId: string): Promise; parentSessionId?: string | null; createdAt: number }>> => (await get(`/sessions?userId=${enc(userId)}&include=dispatch-runs`)).sessions ?? []; /** The suspension ids still pending in `sessionIds`, asking a person. */ const pendingAsks = async (sessionIds: string[]): Promise => { @@ -288,10 +289,15 @@ await runGoal(async () => { if (userId === undefined) throw new Error("the page was handed no userId"); const api = labApi(served.desk.origin, config?.bearerToken); - // Two asks, raised by the person through the asker's own action route. + // Two asks, raised by the person through the asker's own action route: a + // worker has no flow address of its own, so each runs in a session of the + // flow its file names, created naming it. + const askerFlow = String(asker.declared.flow); const askSessions = [0, 1].map(() => `s_cos_goal_${randomBytes(3).toString("hex")}`); for (const [i, sessionId] of askSessions.entries()) { - const posted = await api.call("POST", `/${encodeURIComponent(asker.id)}/${encodeURIComponent(sessionId)}/actions/ask`, { + const opened = await api.call("POST", `/${encodeURIComponent(askerFlow)}/sessions`, { userId, sessionId, state: { [WORKER_ID_STATE_KEY]: asker.id } }); + if (opened.status !== 201) throw new Error(`a session with ${asker.id} on "${askerFlow}": ${opened.status} ${JSON.stringify(opened.body)}`); + const posted = await api.call("POST", `/${encodeURIComponent(askerFlow)}/${encodeURIComponent(sessionId)}/actions/ask`, { userId, input: { what: `ship part ${i + 1}` }, }); @@ -348,9 +354,9 @@ await runGoal(async () => { await input.waitFor(); const token = `cos-${randomBytes(4).toString("hex")}`; await input.fill(`Please repeat this code back to me exactly: ${token}`); - /** The person's direct sessions on the seat, and the one holding the token's user item. */ + /** The person's direct sessions with the seat (the ones naming it as their worker), and the one holding the token's user item. */ const findLine = async () => { - for (const session of (await api.sessions(userId)).filter((s) => s.flowId === cosSeat.id && s.parentSessionId == null)) { + for (const session of (await api.sessions(userId)).filter((s) => workerOf(s) === cosSeat.id && s.parentSessionId == null)) { const messages = await api.items(session.id, "message"); const at = messages.findIndex((m) => m.role === "user" && textOf(m).includes(token)); if (at >= 0) return { sessionId: session.id, messages, at }; From 190b89fe929577c7627898b73fd847f93d614dad Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:20:30 +0000 Subject: [PATCH 06/19] fix(goals): it-draws-v2s-look reads seat asks through the shared helper (FIX-1824) readStore's seat-scoped ask read is the same predicate as Shift Manager's reads.ts, so it now goes through goals/lib's pendingSeatAsks. The every-session read behind the DevTeam precondition is a different predicate and stays local. The desk Lab's header said the chief of staff was a seat on the built-in agent kind; it says now that it is a worker on the one agent copy, with no flow of its own. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- goals/shift-manager/it-draws-v2s-look/goal.md | 2 ++ .../it-draws-v2s-look/lab/fsdev.config.mts | 10 +++++---- goals/shift-manager/it-draws-v2s-look/run.mts | 22 +++++++++---------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/goals/shift-manager/it-draws-v2s-look/goal.md b/goals/shift-manager/it-draws-v2s-look/goal.md index 88d5406bab..dc0e2ef922 100644 --- a/goals/shift-manager/it-draws-v2s-look/goal.md +++ b/goals/shift-manager/it-draws-v2s-look/goal.md @@ -70,3 +70,5 @@ Which regions are graded whole grows with each slice's screens: Chief of Staff's | 2026-10-04 | merge of 4633c47fb (slice B) into feat/FIX-1737-d-inbox-tasks-roster | n/a | PASS | 117 rows and 14 exceptions: slice B's `rows/sidebar-and-cos.mts` and D's `screens-inbox-tasks-roster.mts` both spread in. devteam: 2 teams, 4 seats, 1 running, 1 ask pending; desk ends with the held-send sweep (`cos working`, both shifts), reopened on Chief of Staff after Roster. Drift (both slices' patches) FAILs only at **surface** (`button[team]`) and **type** (the Roster count, Tasks ID cells); unclassified only at **totality** (`p "A line no row covers"`); missing only at **totality** (Tasks ID 0 of 1). Run on a fresh DevTeam store: a store left from earlier runs holds an abandoned row, and the filed row never runs. | | 2026-10-04 | merge of main f8a24755d (slices B and C) into feat/FIX-1737-d-inbox-tasks-roster (pre-push) | n/a | PASS | B's, C's and D's rows together, each slice's spread, hooks and open() cases inside its own markers: 141 rows, 21 exceptions. Screens workstream, board, task, tasks, cos, inbox, roster, project on DevTeam (2 teams, 4 seats, 1 running, 1 ask pending, 88 to 133 painting elements per state); cos, inbox (empty), tasks and roster on the desk, then the held-send sweep reopened on Chief of Staff (`cos working`, both shifts, 73). Run with a fresh `DEVTEAM_STORE`. Controls drift (**surface** `button[team]` radius; **type** the Roster count and Tasks ID cells), unclassified (**totality** `p "A line no row covers"`) and missing (**totality** Tasks ID 0 of 1, on Tasks only) each FAIL only there. | | 2026-10-09 | fix/closure-children-one-copy (main 57d2c10e9) | n/a | PASS | On one copy per flow (FIX-1788 P4): the EM's drain runs in a session on `em` naming it, the desk Lab registers one copy per flow over an installation, and the ask oracles take a session's seat from the worker its state names. The themes are picked with the sidebar's theme mark, and the Shift Coordinator feed and column rows read the `conversation-*` hooks. The table is re-baselined on the shipped sidebar header (36bed1297 / #2825): v2's shift switch row (v2:113) gives way to rows for the header, the theme mark and its svg, the app's name and the theme name, each asserting the values the run reads and citing the shipped source. 144 rows, 21 exceptions. Controls: `drift` FAILs only at **surface** (`button[team]` radius) and **type** (the Roster count, Tasks ID); `missing` only at **totality** (Tasks ID 0 of 1); `unclassified` only at **totality** (`p "A line no row covers"`). Planted wrong values in the four new rows each FAIL at that row, and a stale citation fails setup. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | PASS | The seats' pending asks are now read through `goals/lib`'s `pendingSeatAsks`, the one helper the Shift Manager goals share (same predicate: a session on a seat's kind that names that seat, or names none); `pendingAsks`' precondition still reads every session. The desk Lab's header says what it runs: `chief-of-staff` on the one `agent` copy. 144 rows, 21 exceptions; devteam 2 teams, 4 seats, 1 running, 1 ask pending, chief of staff yes. | +| 2026-10-09 | same (controls) | n/a | FAIL (expected) | `drift` only at **surface** and **type** (the team row's radius; the Roster count and Tasks ID in the sans, both shifts and widths); `unclassified` only at **totality** (`p "A line no row covers"`); `missing` only at **totality** (Tasks ID 0 of 1). | diff --git a/goals/shift-manager/it-draws-v2s-look/lab/fsdev.config.mts b/goals/shift-manager/it-draws-v2s-look/lab/fsdev.config.mts index cbe51efdea..d31d084422 100644 --- a/goals/shift-manager/it-draws-v2s-look/lab/fsdev.config.mts +++ b/goals/shift-manager/it-draws-v2s-look/lab/fsdev.config.mts @@ -1,9 +1,11 @@ /** * The look check's desk Lab, as Shift Manager's command loads it: one - * team, `desk`, with a seat named `chief-of-staff` on the built-in `agent` - * kind, in one mailbox with one board, and the organization's inventory open - * so the seat's row names its door. In-memory stores and no credential, so - * every start is fresh. + * team, `desk`, whose one worker, `chief-of-staff`, runs on the one copy of + * the built-in `agent` flow the installation registers (its WORKER.md names + * `flow: agent`), with no flow of its own: its sessions are on that copy and + * name it in their state. One mailbox with one board, and the organization's + * inventory open so the seat's row names its door. In-memory stores and no + * credential, so every start is fresh. * * No model key: the seat's model is `@flow-state-dev/testing`'s mock resolver * with one scripted reply, read from the check's fixture. The check sends one diff --git a/goals/shift-manager/it-draws-v2s-look/run.mts b/goals/shift-manager/it-draws-v2s-look/run.mts index 29370d1593..efeef8cd71 100644 --- a/goals/shift-manager/it-draws-v2s-look/run.mts +++ b/goals/shift-manager/it-draws-v2s-look/run.mts @@ -65,7 +65,7 @@ import { RUN_STAMP, goalTmpDir, loadFixture, repoPath, runGoal } from "../../lib import { EM_KIND } from "../../../packages/shift-manager/teams/devteam/workforce/flows/workers/em.mts"; import { hex, parseColour, type Rgb } from "../../lib/colour.mts"; import { launchChromium } from "../../lib/playwright.mts"; -import { buildShiftManagerCopy, labApi, startShiftManager, type LabApi, type Patch } from "../../lib/shift-manager.mts"; +import { buildShiftManagerCopy, labApi, pendingSeatAsks, startShiftManager, type LabApi, type Patch } from "../../lib/shift-manager.mts"; // ---- slice D ---- import * as inboxTasksRoster from "./screens-inbox-tasks-roster.mts"; // ---- end slice D ---- @@ -659,7 +659,11 @@ async function readStore(api: LabApi, tree: string, userId: string): Promise(); + for (const ask of await pendingSeatAsks(api, listing.sessions ?? [], seats)) asks.set(ask.seatId ?? "", (asks.get(ask.seatId ?? "") ?? 0) + 1); const mailboxes: Store["mailboxes"] = {}; const allRows: Array> = []; let running = 0; @@ -710,26 +714,22 @@ async function mailboxKind(api: LabApi, mailbox: string): Promise { return String(kind); } -/** The person's pending asks, across the seats' sessions. */ +/** The person's pending asks, in every session they hold. */ async function pendingAsks(api: LabApi, userId: string): Promise { return [...(await pendingAsksBySeat(api, userId)).values()].reduce((a, b) => a + b, 0); } /** - * The person's pending asks, by the worker (the seat) whose session each waits in: the one - * its state names (`workerId`). Given the inventory's seats, only their sessions count, as - * Shift Manager reads asks: a session on a seat's kind that names that seat, or names no - * worker at all (`packages/shift-manager/src/lib/reads.ts`). + * The person's pending asks in every session they hold, by the worker (the seat) whose + * session each waits in: the one its state names (`workerId`). The seats' own read, as + * Shift Manager picks their sessions, is `pendingSeatAsks`. */ -async function pendingAsksBySeat(api: LabApi, userId: string, seats?: ReadonlyArray<{ id: string; kind: string | null }>): Promise> { +async function pendingAsksBySeat(api: LabApi, userId: string): Promise> { // Dispatch runs included: a seat woken by a mailbox post asks from one, and the app lists them. const listing = await api.get(`/sessions?userId=${encodeURIComponent(userId)}&include=dispatch-runs&limit=500`); - const ids = new Set(seats?.map((s) => s.id)); - const kinds = new Set(seats?.flatMap((s) => (s.kind === null ? [] : [s.kind]))); const bySeat = new Map(); for (const session of (listing.sessions ?? []) as Array>) { const worker = typeof session.state?.workerId === "string" ? session.state.workerId : null; - if (seats !== undefined && !(kinds.has(String(session.flowKind)) && (worker === null || ids.has(worker)))) continue; const found = await api.items(String(session.id), ["suspension", "suspension_resume"]); const resumed = new Set(found.filter((i) => i.type === "suspension_resume").map((i) => String(i.suspensionId))); const pending = found.filter((i) => i.type === "suspension" && PERSON_REASONS.has(String(i.reason)) && !resumed.has(String(i.suspensionId))).length; From e5b3f6ab829f933f1892717f813db9f52253d11e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:32:04 +0000 Subject: [PATCH 07/19] fix(goals): multi-seat-collab and its two DevTool siblings read a seat as its worker (FIX-1824) ChangeRecord carried the session's flowId, which V4 read as the seat; on one copy per flow that is 'worker' for both seats. It now carries the workerId the session's state names, and V4 grades a claim as a seat's when that worker is a seat and the session is its own. V3's drain over the parked row posted to the seat's id as a flow, and VB opened the seat as a navigator instance; both now go through the one copy of the flow the seat runs on. works-a-task-from-its-row and the-checklist-rows opened the seat as a navigator instance the same way; they open the worker copy now. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../the-checklist-rows/goal.md | 3 ++ .../the-checklist-rows/run.mts | 13 ++--- .../works-a-task-from-its-row/goal.md | 3 ++ .../works-a-task-from-its-row/run.mts | 3 +- .../goal.md | 8 ++- .../run.mts | 52 ++++++++++++------- goals/multi-seat-collab/run-scenario.mts | 15 +++--- 7 files changed, 63 insertions(+), 34 deletions(-) diff --git a/goals/devtool-workforce-visibility/the-checklist-rows/goal.md b/goals/devtool-workforce-visibility/the-checklist-rows/goal.md index 61584aaaf2..708b52279a 100644 --- a/goals/devtool-workforce-visibility/the-checklist-rows/goal.md +++ b/goals/devtool-workforce-visibility/the-checklist-rows/goal.md @@ -82,3 +82,6 @@ The view-side and server-side reds have no named control, because producing them | 2026-09-24 | `41eb55216` (control: `silent-park`) | n/a | FAIL (expected) | **Row 4 only**, at the positive record, as before. Row 5 PASS. | | 2026-09-24 | FIX-1502 working tree, seven hand mutations, each reverted | n/a | FAIL (expected) | Each produced once on the row-5 leg and reverted by restoring the file from a copy: **the browser read removed** from the three collections → *"[row 5] step 4: the mailbox's session eng.queue shows no Inventory tab"* plus step 6 naming each collection's missing 200. The plan expected the tab to name a 403 here; it cannot, because the manifest omits a collection with no browser read, so the tab never appears. So a second mutation left the seat and membership reads in place and declared the mailbox collection with a content read only: *"[row 5] step 4: the mailboxes section reads "failed" … The mailboxes read was refused (403): State read not permitted for "mailboxes". This is not an empty organization."* **The view pointed at the debug read**, debug off → steps 4 (each section refused 403 `debug_endpoints_disabled`) and 6 (*"the page asked the debug endpoint for the inventory"*); **the same with debug on** → step 4 passed on the debug rows, and step 6 alone failed (*"no 200 on the production collection read"*, *"a debug read was served with the debug endpoints off"*, *"the debug Resources surface does not report the debug endpoints disabled"*): the hollow pass step 6 exists for. **The tab pushed 3000px down its pane** → *"[row 5] step 5: the seats row eng.builder is out of view vertically: 0px of a 29px cell can be seen"*, one line per row. **The route made to read the foreign organization too** → *"the tab lists 4 seat(s); the store holds 3"* and *"another organization's "foreign-….seat" is on the page"*. **A mailbox that re-stamps its registration time every boot** → *"[row 5] step 3: a second boot over the same database changed the inventory"*. **A boot whose inventory reports a problem** (`seatWriter` naming a kind that is not served) → the server does not start: *"the lab's inventory did not register, so the lab will not serve: the seat rows could not be written — no flow is served under "no-such-kind""*. | | 2026-09-28 | `1f2bc1183` (FIX-1629: the Tasks tab is now rows that open in place, and the reason is a slot on the collapsed row) | n/a | **PASS: row 4 and row 5.** Row 6 not graded, as before | The row-4 read was re-pointed from the cell under the `Reason` heading to the collapsed row's reason slot, found by `data-task-id`, with open rows counted in place of open expanders. `eng.builder` parked the row, and its run showed `parked` with the ledger's reason in the slot, no row open. At 1440px 172px of the slot is visible, and at 1280px 92px is (FIX-1523; it was 20px and 0px). Controls were re-run on the tree committed as `25a363b4` (the same check, and a DevTool without the two later row fixes): `silent-park` FAIL (expected) at row 4 only, and `no-inventory` FAIL (expected) at row 5 step 3 only. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | n/a | FAIL | Red on `main` since FIX-1788 P4, at row 4: *"locator.getAttribute: Timeout 30000ms exceeded … waiting for locator('[data-instance-id="eng.builder"]')"*. The seat was opened as a navigator instance; it is now a worker on the one `worker` copy. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | **PASS: row 4 and row 5.** Row 6 not graded, as before | Row 4 opens the one `worker` copy, then the seat's own session on it, then its run: `eng.builder` parked its row and the run showed it `parked` with the question in the reason slot, nothing expanded. Row 5 as before: 3 seats, the mailbox `eng.queue` and 3 memberships, exactly as the store holds them, with the debug endpoints off. | +| 2026-10-09 | same (controls) | n/a | FAIL (expected) | `silent-park` at row 4 only (*"the hire parked row … with no reason on it"*), row 5 PASS. `no-inventory` at row 5 step 3 only, row 4 PASS. | diff --git a/goals/devtool-workforce-visibility/the-checklist-rows/run.mts b/goals/devtool-workforce-visibility/the-checklist-rows/run.mts index fdcab6d8d1..6dbb9cf667 100644 --- a/goals/devtool-workforce-visibility/the-checklist-rows/run.mts +++ b/goals/devtool-workforce-visibility/the-checklist-rows/run.mts @@ -92,14 +92,15 @@ async function waitForBadge(page: Page, sessionId: string): Promise { } /** - * Open a session the way a person does: the kind, then the seat, then the - * seat's own session, then the run it spawned. + * Open a session the way a person does: the kind, then its one copy (a seat + * has none of its own; a copy's id is its kind), then the seat's own session + * on it, then the run it spawned. */ -async function openRun(page: Page, seat: string, seatSession: string, run: string): Promise { +async function openRun(page: Page, seatSession: string, run: string): Promise { const kindRow = page.locator(`[data-kind="${WORKER_KIND}"]`); if ((await kindRow.getAttribute("aria-expanded")) !== "true") await kindRow.click(); - const seatRow = page.locator(`[data-instance-id="${seat}"]`); - if ((await seatRow.getAttribute("aria-expanded")) !== "true") await seatRow.click(); + const copyRow = page.locator(`[data-instance-id="${WORKER_KIND}"]`); + if ((await copyRow.getAttribute("aria-expanded")) !== "true") await copyRow.click(); await page.locator(`[data-session-id="${seatSession}"]`).click(); await waitForBadge(page, seatSession); await page.locator(`[data-session-id="${run}"]`).click(); @@ -290,7 +291,7 @@ async function main(): Promise<{ failures: string[]; evidence: string }> { // ---- the screen ------------------------------------------------------ const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } }); await page.goto(served.origin, { waitUntil: "networkidle" }); - await openRun(page, owner, lab.seatSession(owner), parkLine.session); + await openRun(page, lab.seatSession(owner), parkLine.session); const onScreen = await readTaskRow(page, parked.id, (cells) => cells.Status === "parked"); await page.screenshot({ path: join(SHOTS, "row4-parked.png") }); diff --git a/goals/devtool-workforce-visibility/works-a-task-from-its-row/goal.md b/goals/devtool-workforce-visibility/works-a-task-from-its-row/goal.md index ea2b20a141..ef11969a58 100644 --- a/goals/devtool-workforce-visibility/works-a-task-from-its-row/goal.md +++ b/goals/devtool-workforce-visibility/works-a-task-from-its-row/goal.md @@ -44,3 +44,6 @@ So the check never reads the store to decide what is on screen. The ledger is on | 2026-09-28 | `b8ad96ff` (control: `mailbox-actions-off`) | n/a | FAIL (expected) | **tool and refuse only**: *"the mailbox's row offers [], not the board's `cancelTask_eng_queue_work`"*. Read and answer stayed green. Today's-`main` control not re-run: this round changed nothing it depends on. | | 2026-09-28 | PR review round 6 (over `b3f74ea5d`: read grades every carried field; outcome skips lifecycle-hook roots) | n/a | **PASS** | Every leg green at 1280×800. **read:** all 16 ledger fields a client is sent were shown and matched, including `leaseDurationMs`, `writeLogTruncated` and `incarnationId` under their raw keys. `claimedBy` is server-only and noted. Answer, tool and refuse as before. Run twice. | | 2026-09-28 | same, with the row's catch-all for unlabelled fields removed (negative, not committed) | n/a | FAIL (expected) | **read only**: *"the open row does not show leaseDurationMs, writeLogTruncated, incarnationId, which the ledger holds"*. Restored and rebuilt. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | n/a | FAIL | Red on `main` since FIX-1788 P4, before any leg: *"locator.click: Timeout 30000ms exceeded … waiting for locator('[data-session-id="s_eng_builder"]')"*. The navigator was opened on an instance named for the seat, which no longer exists: the seat's session is on the one `worker` copy. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | **PASS** | The navigator opens the one `worker` copy (a copy's id is its kind) and the seat's session under it. Every leg green at 1280×800: the parked row collapsed shows `parked` and 92px of its reason; open, all 17 ledger fields a client is sent shown and matching; `answer` run from the row; `cancelTask_eng_queue_work` cancelled ledger and row; the second run refused as terminal with the ledger unchanged. | +| 2026-10-09 | same (control: `mailbox-actions-off`) | n/a | FAIL (expected) | **tool and refuse only**: *"the mailbox's row offers [], not the board's `cancelTask_eng_queue_work`"*, and the same for refuse. The today's-`main` control was not re-run: it compares against a DevTool from before FIX-1629, which this change does not touch. | diff --git a/goals/devtool-workforce-visibility/works-a-task-from-its-row/run.mts b/goals/devtool-workforce-visibility/works-a-task-from-its-row/run.mts index 0cb8474054..c153b868a8 100644 --- a/goals/devtool-workforce-visibility/works-a-task-from-its-row/run.mts +++ b/goals/devtool-workforce-visibility/works-a-task-from-its-row/run.mts @@ -415,7 +415,8 @@ async function main(): Promise<{ failures: string[]; evidence: string }> { await page.goto(served.origin, { waitUntil: "networkidle" }); // ---- read: collapsed, then open, in the run the row parked in ------------ - await openSession(page, WORKER_KIND, owner, lab.seatSession(owner)); + // A seat has no copy of its own: its session is on the one copy of the worker flow (a copy's id is its kind). + await openSession(page, WORKER_KIND, WORKER_KIND, lab.seatSession(owner)); await page.locator(`[data-session-id="${parkLine.session}"]`).click(); await waitForBadge(page, parkLine.session); await openTasksTab(page); diff --git a/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/goal.md b/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/goal.md index c33132db06..ab12eb454a 100644 --- a/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/goal.md +++ b/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/goal.md @@ -12,10 +12,10 @@ - **V1 · BR-2, BR-5.** Exactly one row lands for the one piece, carrying it verbatim, for a desk the tree declares — not one per mailbox member. A piece filed for nobody reaches the board, is taken at a drain, and settles `errored` carrying its own id, having run nowhere. - **V2 · BR-3, BR-4.** Every attempt that ran is graded against the `WORKER.md` of the seat that ran it: the row's desk is the desk that seat's own file answers for. Proved by a line the worker body appends to a file, never by the board's report. - **V3 · BR-6, BR-7, BR-7a, BR-10.** The owning seat parks the row. The seats hand rows off, so the drain that claimed it returns `handed-off` as soon as the row is running in its child session; the park happens there. A drain run afterwards over the parked row returns promptly with `parked-for-review` and the row is still `parked` when read back. The answer, through the owning seat's `answer` action, completes the row with the answer on it; the finishing attempt runs under a claim made by an `answer` request on the owning seat's own session, not by a later drain; the row parks once and finishes once. A second answer completes, having found the row, its action returns `declined` with reason `terminal` — read off the request's own recorded output, the value the DevTool's Trace tab shows, since the HTTP route returns none — and it changes nothing on the row and runs nothing. -- **V4 · BR-8, BR-9.** Every attempt ran under a claim made from a worker seat's own session, every visible `claimed` change was emitted from one by a `drain` or `answer` request as the one principal, and the row for nobody **has** a claim or refusal on record from a seat's own drain, as the one principal — an errored row with no seat record behind it fails. An answer sent to the owning seat as a second person, while the row is parked, leaves the row byte-for-byte unchanged; the delivery must first have reached the server as a `202` with a request id, or been refused explicitly: a `401`/`403`, or the engine's answer for another user's session, a `404 Unknown session` naming the owning seat's session, which counts only once the owner's own delivery to that same session is admitted (an unused id gets the same `404`, so the owner's admission is what tells them apart). Any other status, a missing request id or a transport error fails V4. +- **V4 · BR-8, BR-9.** Every attempt ran under a claim made from a worker seat's own session (the session whose state names that seat as its `workerId`; a seat has no flow of its own), every visible `claimed` change was emitted from one by a `drain` or `answer` request as the one principal, and the row for nobody **has** a claim or refusal on record from a seat's own drain, as the one principal — an errored row with no seat record behind it fails. An answer sent to the owning seat as a second person, while the row is parked, leaves the row byte-for-byte unchanged; the delivery must first have reached the server as a `202` with a request id, or been refused explicitly: a `401`/`403`, or the engine's answer for another user's session, a `404 Unknown session` naming the owning seat's session, which counts only once the owner's own delivery to that same session is admitted (an unused id gets the same `404`, so the owner's admission is what tells them apart). Any other status, a missing request id or a transport error fails V4. - **V5 · BR-12, BR-13, BR-14.** The seat that finished the first row filed a second row, for the other desk, naming the first; the other seat instance ran it in its own child session under its own session; moving the first row's assignee was declined `immutable-assignee` and the assignee never moved. Graded only when the first row finished — if it did not, that is V3's failure and the run says so. - **V6 · BR-20.** `TaskStatus` equals the written list of seven. -- **VB · BR-15, BR-16, BR-17.** In Chromium, on the DevTool's own navigation: (1) each seat is a navigator row by its exact id, and the owning seat's session's Tasks tab shows the row with its goal, assignee and a link to the session it ran in; (2) following that link opens the child session the row ran in, whose Tasks tab shows the row `parked` with the reason legible in the collapsed row's reason slot, read by task id, **and no row open** — a clamped reason must carry the whole text on its title — and, after the answer, the row in its current state with the answer in the same place; (3) the Resources panel's ledger collection lists every row, and each expanded row shows the status, assignee and running seat the ledger holds — a listed row whose body shows none of it fails. The body folds after 20 lines behind a "… (N more lines)" button; a row that names its run folds its output, where the seat is, below it, so the check clicks it, as a person would, before reading. Screen 3 grades what a person sees against the ledger; that the ledger holds two rows with two assignees is V5's to grade. +- **VB · BR-15, BR-16, BR-17.** In Chromium, on the DevTool's own navigation: (1) each seat's own session is a navigator row under the one copy of the flow it runs on (since FIX-1788 P4 a seat is a worker on that copy, not a copy of its own, so it has no row of its own), and the owning seat's session's Tasks tab shows the row with its goal, assignee and a link to the session it ran in; (2) following that link opens the child session the row ran in, whose Tasks tab shows the row `parked` with the reason legible in the collapsed row's reason slot, read by task id, **and no row open** — a clamped reason must carry the whole text on its title — and, after the answer, the row in its current state with the answer in the same place; (3) the Resources panel's ledger collection lists every row, and each expanded row shows the status, assignee and running seat the ledger holds — a listed row whose body shows none of it fails. The body folds after 20 lines behind a "… (N more lines)" button; a row that names its run folds its output, where the seat is, below it, so the check clicks it, as a person would, before reading. Screen 3 grades what a person sees against the ledger; that the ledger holds two rows with two assignees is V5's to grade. **Anti-game:** A hollow pass would file a row, drain it, answer it and read back `completed` — true when every row ran on one seat, true when the check read the routing map on both sides of its own comparison, true when the board reported a completion for work that never ran, and true when the "answer" was simply the next drain picking the row up. So the check MUST prove execution by a file the worker body writes, outside the board; MUST grade each attempt against the `WORKER.md` of the seat that ran it and never against the app's map; MUST read the finishing claim back to the `answer` request rather than accepting that the row got done somehow; MUST assert the second person's delivery reached the server as a request before judging that it did not land; MUST read the reason off the row on screen with nothing expanded, not off the store; and MUST NOT count "two rows exist" as a handoff unless two different seat instances ran them. A pass condition that is an absence is paired with a positive record every time: the second delivery *completed* (so it found the row) before "changed nothing" counts, and the row for nobody *reached the board* before its fate is judged. @@ -59,3 +59,7 @@ V0 and V6 have no named control. Their red states were produced once by hand, sn | 2026-10-01 | `f5f4d9342` | n/a | FAIL (expected) | All five controls, each red at exactly its named legs: `swapped-desks` V2, `ignore-the-answer` V3, `second-principal` V4, `silent-park` VB screen 2, `one-seat` V2 and V5. Before the VB fix, `swapped-desks`, `second-principal` and `silent-park` also went red at VB screen 3, so they failed their own isolation check. | | 2026-10-01 | `f5f4d9342`, one hand perturbation, reverted | n/a | FAIL (expected) | The second person's delivery pointed at the planner's session instead of the owning seat's: red at **V4** only, *came back 404 {"error":"Unknown session \"s_eng_planner\""} — neither an explicit refusal nor a request the fence was exercised on*. A 404 for a session other than the owning seat's does not count as the refusal. | | 2026-10-01 | `10acd61ea` (review fixes: V4's 404 rule in one helper, `error` parsed rather than string-matched) | n/a | **PASS** | Every leg green, and all five controls red at exactly their named legs. The planner-session perturbation is still red at **V4** only. One earlier run on this tree went red once at VB screen 1 (*the row carries no link to the session it ran in*), a leg this change does not touch; three clean re-runs followed. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the fix | n/a | FAIL | Red on `main` since FIX-1788 P4, at VB screen 1, which threw before V4 was graded: *"locator.getAttribute: Timeout 30000ms exceeded … waiting for locator('[data-instance-id="eng.builder"]')"*. A seat is no longer a copy, so the navigator has no row by its id. Three spots still read a seat as a flow: V3's drain over the parked row posted to `/eng.builder/…`, VB opened the seat as a navigator instance, and V4 read `ChangeRecord.flowId` (now `worker` for both seats) as the seat. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | **PASS** | `ChangeRecord` carries the `workerId` its session's state names, and V4 grades a claim as a seat's when that worker is a seat and the session is its own. V3's drain goes to the flow the seat runs on. VB (1) opens the one `worker` copy and finds each seat's own session under it. Every leg green; notes: the claiming drain on eng.builder ended `handed-off`; the second person's delivery was refused at admission (404 *Unknown session "s_eng_builder"*) and the owner's own delivery admitted. | +| 2026-10-09 | same (controls) | n/a | FAIL (expected) | All five red at exactly their named legs: `swapped-desks` V2; `ignore-the-answer` V3 (V5 reported ungraded); `second-principal` V4 (*"an answer sent as a second person moved the row"*); `silent-park` VB screen 2; `one-seat` V2 and V5. | +| 2026-10-09 | same, one hand mutation, reverted | n/a | FAIL (expected) | The bug put back: `changes()` reading the session's `flowId` as its worker. Red at **V4** only: *"row … was claimed from session s_eng_builder (worker worker), not from a seat's own session"*, the refusal of the row for nobody likewise, and *"the row for nobody … has no claim or refusal on record from a seat's own drain"*. | diff --git a/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/run.mts b/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/run.mts index 8bd4bef1a9..fc85214681 100644 --- a/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/run.mts +++ b/goals/multi-seat-collab/it-hands-a-row-between-two-seats-in-view/run.mts @@ -37,7 +37,7 @@ import { chromium, type Browser, type Page } from "playwright"; import { taskStatusSchema } from "@flow-state-dev/orchestration/tasks"; import { REPO_ROOT, goalTmpDir, loadFixture, runGoal } from "../../lib/index.mts"; import { LAB_USER_ID, readLabTree } from "../../../packages/shift-manager/test/fixtures/multi-seat-collab/host.mts"; -import { LAB_CONFIG, Scenario, actionOutputOf, serveLab, terminationReasonOf, type ActResult } from "../run-scenario.mts"; +import { LAB_CONFIG, Scenario, actionOutputOf, serveLab, terminationReasonOf, type ActResult, type ChangeRecord } from "../run-scenario.mts"; import { DRAIN_ENTRY, type WorkLine } from "../../../packages/shift-manager/test/fixtures/multi-seat-collab/workforce/flows/workers/worker.mts"; type Fixture = { @@ -139,12 +139,20 @@ function preinstalledChromium(): string | undefined { // The browser half: the DevTool's own navigation, nothing else // --------------------------------------------------------------------------- -/** Open one session from the navigator: kind, then instance, then the session row. */ -async function openSession(page: Page, kind: string, instance: string, sessionId: string): Promise { - const kindRow = page.locator(`[data-kind="${kind}"]`); +/** + * Open the one copy of `flow` in the navigator: its kind row, then the copy's + * own row (a copy's id is its kind), which lists the sessions on it. + */ +async function openCopy(page: Page, flow: string): Promise { + const kindRow = page.locator(`[data-kind="${flow}"]`); if ((await kindRow.getAttribute("aria-expanded")) !== "true") await kindRow.click(); - const instanceRow = page.locator(`[data-instance-id="${instance}"]`); - if ((await instanceRow.getAttribute("aria-expanded")) !== "true") await instanceRow.click(); + const copyRow = page.locator(`[data-instance-id="${flow}"]`); + if ((await copyRow.getAttribute("aria-expanded")) !== "true") await copyRow.click(); +} + +/** Open one session from the navigator: the copy of the flow it is on, then the session row. */ +async function openSession(page: Page, flow: string, sessionId: string): Promise { + await openCopy(page, flow); await page.locator(`[data-session-id="${sessionId}"]`).click(); await waitForBadge(page, sessionId); } @@ -303,7 +311,8 @@ async function main() { } const owner = parkedLine.seat; notes.push(`the claiming drain on ${owner} ended "${drain1.find((drain) => drain.seat === owner)?.terminationReason}"`); - const overParked = await lab.act(owner, lab.seatSession(owner), DRAIN_ENTRY, {}, LAB_USER_ID, 10_000); + const ownerFlow = tree.seatFlows[owner]!; + const overParked = await lab.act(ownerFlow, lab.seatSession(owner), DRAIN_ENTRY, {}, LAB_USER_ID, 10_000); const overParkedReason = terminationReasonOf(overParked.items); if (overParked.status !== "completed" || overParkedReason !== "parked-for-review") { fail("V3", `${owner}'s drain over the parked row ended ${overParked.status} / "${overParkedReason}", not completed / parked-for-review`); @@ -312,12 +321,17 @@ async function main() { if (stillParked?.status !== "parked") fail("V3", `after that drain returned the first row is "${stillParked?.status}", not parked`); // ---- VB (1). the seat's Tasks tab: the row, and its dispatch-run link -- - await page.locator('[data-kind="worker"]').click(); - const listed = await page.locator("[data-instance-id]").evaluateAll((els) => els.map((el) => el.getAttribute("data-instance-id"))); + // A seat has no flow of its own: the navigator lists the one copy of the + // flow it runs on, and each seat's own session under it. + for (const flow of new Set(seats.map((seat) => tree.seatFlows[seat]!))) await openCopy(page, flow); + await page.locator(`[data-session-id="${lab.seatSession(owner)}"]`).waitFor(); + const listed = await page.locator("[data-session-id]").evaluateAll((els) => els.map((el) => el.getAttribute("data-session-id"))); for (const seat of seats) { - if (!listed.includes(seat)) fail("VB", `the navigator has no row for seat ${seat} (listed: ${listed.join(", ")})`); + if (!listed.includes(lab.seatSession(seat))) { + fail("VB", `the navigator lists no session of seat ${seat} under the copy of "${tree.seatFlows[seat]}" (listed: ${listed.join(", ")})`); + } } - await openSession(page, "worker", owner, lab.seatSession(owner)); + await openSession(page, ownerFlow, lab.seatSession(owner)); const screen1 = await taskRow(page, firstId); await page.screenshot({ path: join(SHOTS, "1-seat-tasks.png") }); if (screen1 === undefined) { @@ -454,7 +468,7 @@ async function main() { const firstNow = ledgerNow.find((row) => row.id === firstId); if (childSession !== undefined) { // Re-selected through the navigator, the way a person comes back to it. - await openSession(page, "worker", owner, lab.seatSession(owner)); + await openSession(page, ownerFlow, lab.seatSession(owner)); await page.locator(`[data-session-id="${childSession}"]`).click(); await waitForBadge(page, childSession); const screen2b = await taskRow(page, firstId, (cells) => cells.Status === firstNow?.status); @@ -554,9 +568,12 @@ async function main() { for (const id of [...new Set(ran.map((line) => line.taskId))]) { if (!claims.some((claim) => claim.taskId === id)) fail("V4", `row ${id} ran with no claim on record`); } + // A seat is the worker its session's state names, not the flow it runs on. + const seatsOwn = (change: ChangeRecord) => + change.workerId !== null && seats.includes(change.workerId) && change.sessionId === lab.seatSession(change.workerId); for (const claim of claims) { - if (!seats.includes(claim.flowId) || claim.sessionId !== lab.seatSession(claim.flowId)) { - fail("V4", `row ${claim.taskId} was claimed from ${claim.flowId} session ${claim.sessionId}, not from a seat's own session`); + if (!seatsOwn(claim)) { + fail("V4", `row ${claim.taskId} was claimed from session ${claim.sessionId} (worker ${claim.workerId ?? "none"}), not from a seat's own session`); } if (claim.action !== "drain" && claim.action !== "answer") fail("V4", `row ${claim.taskId} was claimed by a "${claim.action}" request`); if (claim.userId !== LAB_USER_ID) fail("V4", `row ${claim.taskId} was claimed as ${claim.userId}`); @@ -572,8 +589,8 @@ async function main() { } } for (const settled of changes.filter((change) => change.kind === "errored")) { - if (!seats.includes(settled.flowId) || settled.sessionId !== lab.seatSession(settled.flowId)) { - fail("V4", `row ${settled.taskId} was taken and refused from ${settled.flowId} session ${settled.sessionId}`); + if (!seatsOwn(settled)) { + fail("V4", `row ${settled.taskId} was taken and refused from session ${settled.sessionId} (worker ${settled.workerId ?? "none"})`); } } // And the row for nobody must HAVE such a record: an errored row with no @@ -584,8 +601,7 @@ async function main() { (change) => change.taskId === orphan.id && (change.kind === "claimed" || change.kind === "errored") && - seats.includes(change.flowId) && - change.sessionId === lab.seatSession(change.flowId) && + seatsOwn(change) && (change.action === "drain" || change.action === "answer") && change.userId === LAB_USER_ID, ); diff --git a/goals/multi-seat-collab/run-scenario.mts b/goals/multi-seat-collab/run-scenario.mts index 348817cb21..1824c288fd 100644 --- a/goals/multi-seat-collab/run-scenario.mts +++ b/goals/multi-seat-collab/run-scenario.mts @@ -24,7 +24,7 @@ import { spawn, type ChildProcess } from "node:child_process"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -import { openMailboxes } from "@flow-state-dev/workforce"; +import { WORKER_ID_STATE_KEY, openMailboxes } from "@flow-state-dev/workforce"; import { REPO_ROOT, intentFreeEnv, refuseIfAnswering, stopProcessGroup } from "../lib/index.mts"; import { LAB_USER_ID, type LabTree } from "../../packages/shift-manager/test/fixtures/multi-seat-collab/host.mts"; import { FILE_ENTRY, type FileInput } from "../../packages/shift-manager/test/fixtures/multi-seat-collab/workforce/flows/workers/planner.mts"; @@ -173,8 +173,8 @@ export interface ChangeRecord { taskId: string; /** The session the emitting request ran in. */ sessionId: string; - /** The flow instance that owns that session. */ - flowId: string; + /** The worker that session names in its state (`workerId`), or `null` when it names none. */ + workerId: string | null; /** The principal the emitting request ran as. */ userId: string; /** The action the emitting request ran. */ @@ -262,7 +262,7 @@ export class Scenario { await openMailboxes([this.tree.mailbox], { client, userId: LAB_USER_ID }); // A seat has no flow of its own: its session is on the one copy of the flow it runs on, naming it. for (const seat of [this.tree.plannerId, ...this.tree.workerIds]) { - await client.createSession({ flowKind: this.tree.seatFlows[seat]!, userId: LAB_USER_ID, sessionId: this.seatSession(seat), state: { workerId: seat } }); + await client.createSession({ flowKind: this.tree.seatFlows[seat]!, userId: LAB_USER_ID, sessionId: this.seatSession(seat), state: { [WORKER_ID_STATE_KEY]: seat } }); } } @@ -373,21 +373,22 @@ export class Scenario { } /** - * Every task change the run emitted, anywhere, with the session, owner, - * principal and action of the request that emitted it. A change is emitted + * Every task change the run emitted, anywhere, with the session (and the + * worker it names), principal and action of the request that emitted it. A change is emitted * into the session that made it, so for a claim this is the claim's identity * as the server recorded it. */ async changes(): Promise { const out: ChangeRecord[] = []; for (const session of await this.sessions()) { + const worker = session.state?.[WORKER_ID_STATE_KEY]; for (const request of await this.requests(String(session.id))) { for (const change of taskChangesOf(request.items ?? [])) { out.push({ kind: change.kind, taskId: change.taskId, sessionId: String(session.id), - flowId: String(session.flowId ?? session.flowKind), + workerId: typeof worker === "string" ? worker : null, userId: String(request.userId), action: String(request.actionName), requestId: String(request.id), From d22d161e1ead042ad7bf0addf9523fe81f2378ae Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:43:15 +0000 Subject: [PATCH 08/19] fix(goals): the skinned-shell closure reads asks by the worker a session names (FIX-1824) readStore kept an ask only when its session's flowId was a seat, which no session has on one copy per flow, so the store held no ask while Inbox drew the EM's. It now reads asks through goals/lib's pendingSeatAsks, as Shift Manager's reads.ts picks them. StoredAsk.seat is null for a session on a seat's kind that names no worker. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../goal.md | 2 ++ .../legs.mts | 4 +-- .../shell.mts | 29 +++++++------------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md index fb5eda1212..db76735fed 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md @@ -57,3 +57,5 @@ | 2026-10-04 | 25d026528 | real model where each child names one | PASS (part 3) | 39 verdicts, all as expected: every child check passes (pentest a-seat-answers included) and every child control fails at its named signal; design-system, registry and static tests, `pnpm typecheck` and `pnpm test` PASS. | | 2026-10-04 | 25d026528 | none | PASS (part 4) | ER-15: the seat's door, the mailbox's post, the project room's read/post/join on the room kind (3 calls), the person's room session (2 `createSession` on `ROOM_KIND`), Interrupt's abort and the one resume. Negatives on 6e0201344's tree, each reverted: a `hire` talk action, `joinRoom(clients, "agent")` in Project.tsx, `createSession({ flowKind: "agent" })` in reads.ts, and a second `sendAction` in talk.ts each turned part 4 red at P4:ER-15 alone. Literal colours, pinned routes, one ask card, layer fence, final visuals and docs smoke PASS. | | 2026-10-04 | 01444863c (4b7d4d828: Codex's five review fixes; 01444863c: POC #2711's shared-helper fold) | Claude Code harness (a4), `claude` CLI (b0), real model where each child names one | **PASS** | One commit, fresh stores, each part its own process. **Negatives:** `GOAL_PART=bogus` and `GOAL_PART=` exit 1 naming the unknown part (on 49fd744e3 `bogus` printed PASS with 0 verdicts); `GOAL_CONTROLS=nope` exits 1; a part 3 selection matching nothing fails with "no verdict ran"; `GOAL_CONTROL_LEGS=c` on optimistic-post reads WRONG before building. **Legs:** a, b0 (the writer declared its guesses: none), b, c, d, J3, J4 PASS, 10 verdicts; b:org now checks DevForce inside leg b (store org devforce-lab, switcher devforce-lab) beside pentest and the no-resolver Lab. **Controls:** all six RIGHT: today's main FAIL as expected (c's static half green); hardcoded-accent at c:tool only (the patch printed as a unified diff through the shared copy build); static-names at b:teams only; optimistic-post at a4 + b:post only; worker-session at a2 only (c:sweep, as allowed); no-org at b:org only, red on pentest, no-resolver and DevForce. **Part 3:** 39 verdicts, all as expected, `pnpm typecheck` and `pnpm test` PASS. **Part 4** PASS. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the oracle fix | none (leg c) | FAIL (finding) | The store's asks were read from sessions whose `flowId` is a seat, which no session has since FIX-1788 P4 (a seat's session is on the flow it runs on and names it as its `workerId`), so the store held no ask while Inbox drew the EM's. **c FAIL (12):** *"DevForce raised no ask, so the ask card could not be swept"*, *"no ask is pending and Inbox's empty state is not named"*, *"no board holds a row, so the task level was never reached"* and the sweeps that follow (ask 0, devtool 0 elements), day and night, plus the Day / Night switch below. **b FAIL (1):** the Day / Night switch only; pentest holds no ask, so its Inbox check passes either way. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | Claude Code harness (a4) | FAIL (finding, not this change) | `readStore` reads asks through `goals/lib`'s `pendingSeatAsks`, as Shift Manager's `reads.ts` picks them: a session on a seat's kind that names that seat, or names none. **a FAIL at a3 only:** a1 the EM's approval ask from eng.em, Inbox names exactly the store's memberships [eng.feature, eng.triage, ops.oncall, ops.release], approved, resume stored, gone from Inbox; a4 delivered (held when drawn) and answered in the run session; a2 15 items drawn, all stored, from Tasks and Board, trace followed. **c FAIL at the switch only:** message 20, reasoning 16, tool 50, code block 32, ask 11, devtool 293/292 elements, 0 Shift Manager values; static fence 0 hits in 2705 files. **b FAIL at the switch only:** 3 seats, post held 1 when drawn, `packages/shift-manager` unchanged, org on all three Labs. **Finding:** a3, b:reach and c:reach look for the sidebar's Day / Night switch (`shift-switch`), which the theme mark replaced (36bed1297 / #2825); `it-draws-v2s-look` already grades the shipped header. Out of FIX-1824's scope, so every control would read WRONG at those three signals; controls, b0, d and parts 2 to 4 were not run. | diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts index 7ade2832d3..20ef5d840f 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts @@ -369,7 +369,7 @@ async function inboxJourney(page: Page, api: LabApi, store: Store, tree: Tree, s // the ask's session has one as its parent, otherwise every mailbox the store lists the seat in. const session = await api.get(`/sessions/${encodeURIComponent(ask.sessionId)}`); const parent = (session.session ?? session).parentSessionId as string | null | undefined; - const memberOf = store.mailboxes.filter((c) => c.members.includes(ask.seat)).map((c) => c.id); + const memberOf = store.mailboxes.filter((c) => ask.seat !== null && c.members.includes(ask.seat)).map((c) => c.id); const streams = parent != null && store.mailboxes.some((c) => c.id === parent) ? [parent] : memberOf; const workstream = streams[0]; await page.getByTestId("nav-inbox").click(); @@ -773,7 +773,7 @@ export async function legC(ctx: LegCtx): Promise { await page.locator(`[data-testid=inbox-item][data-suspension-id="${ask.suspensionId}"]`).click(); await page.locator("[data-testid=inbox-detail] [data-testid=ask-card]").waitFor(); await sweep(page, { ask: `[data-testid=inbox-detail] ${SWEPT.ask}` }, tally); - const workstream = tree.mailboxes.find((c) => c.members.includes(ask.seat))!.id; + const workstream = tree.mailboxes.find((c) => ask.seat !== null && c.members.includes(ask.seat))!.id; await page.getByTestId(`nav-workstream-${workstream}`).click(); await page.locator("[data-testid=feed-ask] [data-testid=ask-card]").waitFor().catch(() => undefined); await sweep(page, { ask: `[data-testid=feed-ask] ${SWEPT.ask}` }, tally); diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/shell.mts b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/shell.mts index 1913151342..deb8858458 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/shell.mts +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/shell.mts @@ -16,7 +16,7 @@ import { pathToFileURL } from "node:url"; import type { Page } from "playwright"; import { readDeclaredRoster } from "@flow-state-dev/workforce/loader"; import { REPO_ROOT, intentFreeEnv } from "../../lib/index.mts"; -import { SHIFT_MANAGER, SHIFT_MANAGER_COMMAND, buildShiftManagerCopy, labApi as labRoutes, servedAddresses, type Patch } from "../../lib/shift-manager.mts"; +import { SHIFT_MANAGER, SHIFT_MANAGER_COMMAND, buildShiftManagerCopy, labApi as labRoutes, pendingSeatAsks, servedAddresses, type Patch } from "../../lib/shift-manager.mts"; export { SHIFT_MANAGER, type Patch }; @@ -218,8 +218,11 @@ export async function readTree(root: string): Promise { /** A stored board row, as the store returns it. */ export type StoredRow = { ref: string; id: string; status: string; title: string; run: { sessionId: string; requestId: string } | null; raw: Record }; -/** A pending ask: a suspension with no resume, on a seat's session, asking a person. */ -export type StoredAsk = { suspensionId: string; sessionId: string; seat: string }; +/** + * A pending ask: a suspension with no resume, on a seat's session, asking a person. `seat` is the + * worker the session names, or `null` for a session on a seat's kind that names none. + */ +export type StoredAsk = { suspensionId: string; sessionId: string; seat: string | null }; /** What the store holds, read through the Lab's routes by this script. */ export type Store = { @@ -233,9 +236,6 @@ export type Store = { projects: Array<{ id: string; title: string; brief: string | null; workstreams: string[] }>; }; -/** Suspension reasons that are a person being asked something. */ -const PERSON_REASONS = new Set(["human_approval", "human_input"]); - export async function readStore(api: LabApi, tree: Tree, userId: string): Promise { // The inventory, through the first mailbox's session, by its published key patterns. const host = tree.mailboxes[0]!.id; @@ -244,7 +244,8 @@ export async function readStore(api: LabApi, tree: Tree, userId: string): Promis (manifest.resources as Array<{ kind: string; ref: string; pattern: string }>).find((r) => r.kind === "collection" && r.pattern === pattern)?.ref; const seatsRef = refOf("inventory/seats/*"); const mailboxesRef = refOf("inventory/mailboxes/*"); - const seats = seatsRef === undefined ? [] : (await api.collection(host, seatsRef)).map((r) => String(r.id)); + const seatRows = seatsRef === undefined ? [] : (await api.collection(host, seatsRef)).map((r) => ({ id: String(r.id), kind: r.kind == null ? null : String(r.kind) })); + const seats = seatRows.map((s) => s.id); const mailboxes = mailboxesRef === undefined ? [] @@ -281,18 +282,8 @@ export async function readStore(api: LabApi, tree: Tree, userId: string): Promis const listing = await api.get(`/sessions?userId=${encodeURIComponent(userId)}&include=dispatch-runs&limit=500`); const sessions = (listing.sessions ?? []) as Array>; const orgs = [...new Set(sessions.map((s) => s.orgId).filter((o): o is string => typeof o === "string" && o.length > 0))]; - const seatSet = new Set(seats); - const asks: StoredAsk[] = []; - for (const session of sessions) { - if (!seatSet.has(String(session.flowId))) continue; - const found = await api.items(String(session.id), ["suspension", "suspension_resume"]); - const resumed = new Set(found.filter((i) => i.type === "suspension_resume").map((i) => String(i.suspensionId))); - for (const item of found) { - if (item.type === "suspension" && PERSON_REASONS.has(String(item.reason)) && !resumed.has(String(item.suspensionId))) { - asks.push({ suspensionId: String(item.suspensionId), sessionId: String(session.id), seat: String(session.flowId) }); - } - } - } + // The seat an ask belongs to is the worker its session names, not the flow the session is on. + const asks: StoredAsk[] = (await pendingSeatAsks(api, sessions, seatRows)).map((a) => ({ suspensionId: a.suspensionId, sessionId: a.sessionId, seat: a.seatId })); return { seats, mailboxes, rows, asks, orgs, projects }; } From 22e135b8118309e78ec25973b72ed2dcb26b2aca Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:54:22 +0000 Subject: [PATCH 09/19] fix(goals): re-point the optimistic-reply control at the conversation hook (FIX-1824) The control swapped src/lib/cos.ts, which 260690140 folded into lib/conversation.ts, so the build failed before talk was graded. It now stands in for lib/conversation.ts and lib/send.ts, the two modules a conversation runs through: it opens no session, sends nothing, and draws the typed line with a canned reply. The build's swap takes one or more modules. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../controls/optimistic-reply.ts | 45 ++++++++++++++----- .../goal.md | 6 ++- .../run.mts | 21 +++++---- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/controls/optimistic-reply.ts b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/controls/optimistic-reply.ts index 40c10ed854..f173bca1fc 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/controls/optimistic-reply.ts +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/controls/optimistic-reply.ts @@ -2,17 +2,44 @@ * Control `optimistic-reply`: the conversation draws the person's line and a * canned reply without calling the door. * - * Built into the control page in place of `src/lib/cos.ts`. Sending resolves - * at once and sends nothing; reading the conversation hands back the lines - * typed here and a reply written here, so the screen shows *delivered* and a - * reply while the seat's session holds neither. The goal must fail at "talk". + * Built into the control page in place of both modules a conversation runs + * through: `src/lib/conversation.ts` (the hook that reads the seat's session) + * and `src/lib/send.ts` (the one send path its composer calls). One module + * stands in for both. + * + * - `openConversation` opens nothing, and `sendTurn` resolves at once and + * sends nothing, so the composer reads *delivered* while no session holds + * the line. + * - `useSeatConversation` hands back the lines typed here, each with a reply + * written here, in place of what the session stores. + * + * The goal must fail at "talk" ("delivered was drawn while no session … + * held a user item with the token"). */ +import type { SessionSummary } from "@flow-state-dev/client"; import type { OutputItem } from "@flow-state-dev/core/items"; -export { conversationSession, currentConversation, newConversationId } from "../../../../packages/shift-manager/src/lib/cos.ts"; +import { useSeatConversation as useStoredConversation, type SeatConversation } from "../../../../packages/shift-manager/src/lib/conversation.ts"; +import type { Seat } from "../../../../packages/shift-manager/src/lib/reads.ts"; +import type { sendTurn as realSendTurn } from "../../../../packages/shift-manager/src/lib/send.ts"; + +export * from "../../../../packages/shift-manager/src/lib/conversation.ts"; +export * from "../../../../packages/shift-manager/src/lib/send.ts"; const typed: string[] = []; -export async function readConversation(): Promise<{ items: OutputItem[]; truncated: boolean }> { +/** Opens nothing: the Lab is never asked. */ +export async function openConversation(): Promise {} + +/** Read the line as delivered; the seat's door is never called. */ +export const sendTurn: typeof realSendTurn = async (_clients, _target, message) => { + typed.push(message); + return { requestId: "never-sent", suspended: false, stopped: null }; +}; + +/** The real hook, with the session's items replaced by the lines typed here and a canned reply to each. */ +export function useSeatConversation(seat: Seat, sessions: readonly SessionSummary[]): SeatConversation { + const stored = useStoredConversation(seat, sessions); + if (typed.length === 0) return stored; const items = typed.flatMap((line, i) => [ { id: `local_user_${i}`, type: "message", role: "user", status: "completed", requestId: `local_${i}`, content: [{ type: "output_text", text: line }] }, { @@ -24,9 +51,5 @@ export async function readConversation(): Promise<{ items: OutputItem[]; truncat content: [{ type: "output_text", text: "Noted. I'll take care of it." }], }, ]); - return { items: items as unknown as OutputItem[], truncated: false }; -} - -export async function sendToChiefOfStaff(_clients: unknown, _target: unknown, message: string): Promise { - typed.push(message); + return { ...stored, read: { items: items as unknown as OutputItem[], truncated: false }, failure: undefined }; } diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md index f5769a9ac8..aaa5a7726d 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/goal.md @@ -27,9 +27,9 @@ The seat, mailbox and board names are read from the tree at run time. Tokens are **Run:** `PLAYWRIGHT_BROWSERS_PATH=/opt/pw-browsers pnpm tsx goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts` -**Controls:** each rebuilds Shift Manager with one source module swapped for a module under `controls/`. The build fails if the swap never fired. +**Controls:** each rebuilds Shift Manager with source modules swapped for one module under `controls/`. The build fails if a swap never fired. -- `GOAL_CONTROL=optimistic-reply`: `src/lib/cos.ts` is swapped; the composer draws the line and a canned reply without calling the door. Must fail at **talk** ("delivered was drawn while no session … held a user item with the token"). +- `GOAL_CONTROL=optimistic-reply`: `src/lib/conversation.ts` (the conversation hook) and `src/lib/send.ts` (the send path its composer calls) are swapped; the composer draws the line and a canned reply without calling the door. Must fail at **talk** ("delivered was drawn while no session … held a user item with the token"). - `GOAL_CONTROL=static-brief`: `src/lib/derive.ts` is swapped; the summary's asks are written in at the first read. Must fail at **inline**, where the store drops to one and the summary stays at two. **Before-state:** `GOAL_PAGES=` serves pages built elsewhere instead of building them. Pages built before the view existed fail **landing** and everything after it. @@ -48,3 +48,5 @@ The seat, mailbox and board names are read from the tree at run time. Tokens are | 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | openai/gpt-5.4-mini (vercel gateway) | PASS | The desk runs each seat on one copy of `asker` or `agent` (`installWorkers`). The check raises each ask in a session on `asker` created naming the asker, and finds the line in a direct session that names `desk.chief-of-staff` as its worker. Summary 2 need you / 2 pending, `desk.front` 0 running; Approve from the summary: store 2 → 1, summary 2 → 1, Inbox 1; the line was held in `conv_9d487fe8…` when *delivered* was drawn, the stored reply drawn by id, and again after a reload; the Lab with no chief of staff lands on the view with the summary and its no-coordinator line. | | 2026-10-09 | same (control `static-brief`) | openai/gpt-5.4-mini (vercel gateway) | FAIL (expected) | Only `[desk] inline`: after Approve the summary says 2 need you while the store holds 1, and still lists the answered ask. | | 2026-10-09 | same (control `optimistic-reply`) | n/a | FAIL (stale control) | Fails at the build, not at **talk**: *"the build never imported …/packages/shift-manager/src/lib/cos.ts, so nothing was swapped"*. `lib/cos.ts` was folded into `lib/conversation.ts` by 260690140 (2026-10-07), which is on `main`, so the control is red at setup with or without this change. Re-pointing it at the conversation hook is follow-up work; until then **talk** has no working control. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy, the control re-pointed | openai/gpt-5.4-mini (vercel gateway) | FAIL (control `optimistic-reply`, expected) | The control now stands in for `lib/conversation.ts` and `lib/send.ts`, the two modules a conversation runs through: it opens no session, sends nothing, and draws the typed line with a canned reply. Only `[desk] talk`: *"delivered was drawn while no session of desk.chief-of-staff held a user item with the token"*. | +| 2026-10-09 | same | openai/gpt-5.4-mini (vercel gateway) | PASS, and FAIL (control `static-brief`, expected) | The build's swap now takes one or more modules. Green path: summary 2 / 2 pending, Approve 2 → 1 in store, summary and Inbox; line held in `conv_c29a81ba…` when *delivered* was drawn, reply drawn by id, again after a reload; no-coordinator state. `static-brief` only at `[desk] inline`. | diff --git a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts index 55319a6446..092389cdf6 100644 --- a/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts +++ b/goals/shift-manager/it-briefs-and-talks-with-the-chief-of-staff/run.mts @@ -31,7 +31,9 @@ * * Controls: * - * optimistic-reply Shift Manager built with `src/lib/cos.ts` swapped for + * optimistic-reply Shift Manager built with `src/lib/conversation.ts` (the + * conversation hook) and `src/lib/send.ts` (the send path + * its composer calls) swapped for * `controls/optimistic-reply.ts`: the line and a canned * reply are drawn without calling the door. Must fail at * "talk". @@ -57,9 +59,11 @@ import { SHIFT_MANAGER_COMMAND, servedAddresses, workerOf } from "../../lib/shif import { launchChromium } from "../../lib/playwright.mts"; const CONTROL = process.env.GOAL_CONTROL ?? ""; +/** Each control's source modules, and the module under `controls/` that stands in for all of them. */ const SWAPS = { - "optimistic-reply": { module: join("src", "lib", "cos.ts"), with: "optimistic-reply.ts" }, - "static-brief": { module: join("src", "lib", "derive.ts"), with: "static-brief.ts" }, + // The conversation hook, and the send path its composer calls: both, so the reply is drawn and nothing is sent. + "optimistic-reply": { modules: [join("src", "lib", "conversation.ts"), join("src", "lib", "send.ts")], with: "optimistic-reply.ts" }, + "static-brief": { modules: [join("src", "lib", "derive.ts")], with: "static-brief.ts" }, } as const; type Control = keyof typeof SWAPS; if (CONTROL === "list") { @@ -96,8 +100,8 @@ async function buildShiftManager(control: string): Promise { const viteEntry = createRequire(join(SHIFT_MANAGER, "package.json")).resolve("vite"); const vite = (await import(pathToFileURL(viteEntry).href)) as { build(config: Record): Promise }; const spec = control === "" ? undefined : SWAPS[control as Control]; - const swap = spec === undefined ? undefined : { target: join(SHIFT_MANAGER, spec.module), with: join(HERE, "controls", spec.with) }; - let swapped = 0; + const swap = spec === undefined ? undefined : { targets: spec.modules.map((m) => join(SHIFT_MANAGER, m)), with: join(HERE, "controls", spec.with) }; + const swapped = new Set(); await vite.build({ root: SHIFT_MANAGER, configFile: join(SHIFT_MANAGER, "vite.config.ts"), @@ -114,14 +118,15 @@ async function buildShiftManager(control: string): Promise { async resolveId(this: any, source: string, importer: string | undefined, options: Record) { if (importer === undefined || importer === swap.with) return null; const resolved = await this.resolve(source, importer, { ...options, skipSelf: true }); - if (resolved?.id !== swap.target) return null; - swapped += 1; + if (resolved === null || !swap.targets.includes(resolved.id)) return null; + swapped.add(resolved.id); return swap.with; }, }, ], }); - if (swap !== undefined && swapped === 0) throw new Error(`control ${control}: the build never imported ${swap.target}, so nothing was swapped`); + const missed = swap?.targets.filter((target) => !swapped.has(target)) ?? []; + if (missed.length > 0) throw new Error(`control ${control}: the build never imported ${missed.join(", ")}, so nothing was swapped there`); return outDir; } From accb40cdd26a8fbb9d79be0458562590e29bbbba Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 02:55:02 +0000 Subject: [PATCH 10/19] fix(goals): the skinned shell grades the theme mark; pickShift moves to goals/lib (FIX-1824) The closure's reach walk looked for the sidebar's Day / Night switch, which the theme mark replaced (36bed1297 / #2825), so a3, b:reach and c:reach were red on every run. It now clicks the mark as a person does until it reaches night, day and the theme it started on, checking the page takes each. pickShift, which it-draws-v2s-look already used for this, moves to goals/lib/shift-manager.mts so both goals share it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- goals/README.md | 2 +- goals/lib/shift-manager.mts | 18 +++++++++++++ .../goal.md | 2 +- .../legs.mts | 25 ++++++++++++------- goals/shift-manager/it-draws-v2s-look/run.mts | 15 +---------- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/goals/README.md b/goals/README.md index 1fc54b2de9..b507260534 100644 --- a/goals/README.md +++ b/goals/README.md @@ -99,7 +99,7 @@ Every goal repeats the same scaffolding around the part that is actually its own | `specs` | `runSpecs` — delegate to an app's mock-free vitest specs | | `server` | `refuseIfAnswering`, `stopProcessGroup` — for a goal that spawns its own server: refuse when anything already answers on the port, and stop the whole detached process group so no survivor is left for the next run to grade | | `playwright` | `launchChromium`, `preinstalledChromium` — Chromium for a goal that reads the shipped DevTool. **Not re-exported from `index.mts`**, so a goal that opens no browser does not load Playwright; import `../../lib/playwright.mts` directly | -| `shift-manager` | `buildShiftManagerCopy` (a patched scratch copy, built with Vite), `startShiftManager` (its command over a Lab, with `NODE_ENV` as it was before any in-process build; optional `root`, `tsx` and `timeoutMs` to serve another checkout, including an older one that has only `bin/start.mts`), `labApi` (the Lab's routes), `pendingSeatAsks` (the person's pending asks on the seats' sessions, picked as Shift Manager picks them) and `workerOf` (the worker a listed session names) — for the Shift Manager goals; and, for a goal that drives Shift Manager as a person in Playwright, `buildShiftManagerPages`, `labRoutes` (`labApi` read as one verified user) and `personPage` (a browser context as a given person). **Not re-exported from `index.mts`**; import `../../lib/shift-manager.mts` directly | +| `shift-manager` | `buildShiftManagerCopy` (a patched scratch copy, built with Vite), `startShiftManager` (its command over a Lab, with `NODE_ENV` as it was before any in-process build; optional `root`, `tsx` and `timeoutMs` to serve another checkout, including an older one that has only `bin/start.mts`), `labApi` (the Lab's routes), `pendingSeatAsks` (the person's pending asks on the seats' sessions, picked as Shift Manager picks them), `workerOf` (the worker a listed session names) and `pickShift` (a theme picked with the sidebar's theme mark) — for the Shift Manager goals; and, for a goal that drives Shift Manager as a person in Playwright, `buildShiftManagerPages`, `labRoutes` (`labApi` read as one verified user) and `personPage` (a browser context as a given person). **Not re-exported from `index.mts`**; import `../../lib/shift-manager.mts` directly | The library covers scaffolding only. **The grading logic is the goal** and belongs in `run.mts`. So does retry *policy* — the corpus has three, and they mean different things (retry-until-first-pass over model flakiness vs. require-k-of-k where the stability number is itself the published result). diff --git a/goals/lib/shift-manager.mts b/goals/lib/shift-manager.mts index 5d7f9898e4..96b6b49136 100644 --- a/goals/lib/shift-manager.mts +++ b/goals/lib/shift-manager.mts @@ -20,6 +20,8 @@ * - {@link pendingSeatAsks}: the person's pending asks on the seats' sessions, * picked the way Shift Manager picks them, and {@link workerOf}, the worker * a listed session names. + * - {@link pickShift}: the page put in a theme with the sidebar's theme mark, + * as a person picks one. * * `vite.build()` run in-process sets `process.env.NODE_ENV` to `production` * and never restores it. A Lab started after a build would inherit it, which @@ -242,6 +244,22 @@ export function labApi(origin: string, bearer: string | undefined) { /** A Lab's routes, as {@link labApi} reads them. */ export type LabApi = ReturnType; +/** + * Put the page in `shift` with the sidebar's theme mark, clicking it as a person cycles the + * themes (day, evening, night), and let each click's fade (the root's `theme-fade` class) + * end before the next. The mark replaced v2's Day / Night switch (36bed1297 / #2825). + * + * @throws When three clicks never bring the mark to `shift`. + */ +export async function pickShift(page: Page, shift: "day" | "evening" | "night"): Promise { + const mark = page.getByTestId("theme-mark"); + for (let i = 0; i < 3 && (await mark.getAttribute("data-theme")) !== shift; i += 1) { + await mark.click(); + await page.waitForFunction(() => !document.documentElement.classList.contains("theme-fade"), undefined, { timeout: 10_000 }); + } + if ((await mark.getAttribute("data-theme")) !== shift) throw new Error(`the theme mark never reached "${shift}"`); +} + /** Suspension reasons that are a person being asked something. */ const PERSON_REASONS = new Set(["human_approval", "human_input"]); diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md index db76735fed..a2ec66ecd5 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md @@ -10,7 +10,7 @@ - **a1, the Inbox journey.** The EM seat's ask is in Inbox with its kind and its workstreams. An ask with no workstream session belongs to every mailbox the store lists its seat in, because FIX-1662's BR-18 draws its card on each of those Streams (decided for this closure, 2026-10-04); an ask a mailbox post started belongs to that mailbox. Inbox names exactly that set, and on each of those Streams the card says what the detail pane says (its question heading and its card). Approve leaves the resume stored and the ask gone from Inbox. - **a2, the task journey.** From Tasks, then from the workstream's Board: the task's Session tab draws only items the run session holds, the inspector's trace link is the in-process devtool's `?session=`, and following it opens that session. -- **a3, reach.** Chief of Staff, the org switcher, Jump to, Inbox against the store's asks, Tasks in its three groupings, Roster for all teams and for each team row in TEAMS, PROJECTS, the Day/Night switch, the project level's four tabs, each workstream's four tabs, panel and Board against the store's rows, and the task frame's four tabs and panel slot. Every empty one names what will be there. +- **a3, reach.** Chief of Staff, the org switcher, Jump to, Inbox against the store's asks, Tasks in its three groupings, Roster for all teams and for each team row in TEAMS, PROJECTS, the theme mark that replaced the Day/Night switch (36bed1297 / #2825: clicked, it reaches night and day and the page takes each), the project level's four tabs, each workstream's four tabs, panel and Board against the store's rows, and the task frame's four tabs and panel slot. Every empty one names what will be there. - **a4, the `@worker` turn** (the one step on the real model). While the coder's task runs, `@coder ` in the workstream composer is in the running task session as a person's turn before the composer reads delivered, and the next attempt answers in that session. Never retried. - **b0, the pentest config from the README.** An isolated writer that sees only Shift Manager's README and the pentest tree (minus its config) writes a config to scratch. Every step it had to guess is a failure, as is a reply that declares nothing (it must say `GUESSED: none` when it guessed nothing), and so is a semantic difference from the committed config (flows, org, seats, workstreams, the page's user and bearer), booted side by side. - **b, the pentest Lab.** The a3 reach on the pentest tree; the composer's post is in the mailbox's stored transcript when it is drawn, and drawn once after a reload; `packages/shift-manager` is unchanged and names no pentest seat, team or mailbox. A Lab with no resolver opens under `DEFAULT_ORG_ID`, and on both Labs the switcher names the store's org. diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts index 20ef5d840f..baffe9658f 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/legs.mts @@ -16,6 +16,7 @@ import type { Browser, Page } from "playwright"; import { DEFAULT_ORG_ID } from "@flow-state-dev/core"; import { hex, near, parseColour, readShiftManagerTheme, type Rgb } from "../../lib/colour.mts"; import { REPO_ROOT } from "../../lib/index.mts"; +import { pickShift } from "../../lib/shift-manager.mts"; import { findThemeValues, themeValues } from "../../../labs/design-system/test/theme.ts"; import { SHIFT_MANAGER, @@ -214,16 +215,22 @@ export async function walkSurfaces( ); if (!same(streams, store.mailboxes.map((c) => c.id))) reach(`PROJECTS lists ${diff(store.mailboxes.map((c) => c.id), streams)}`); - // The Day / Night switch: there, and each half marks itself when clicked. - if (!(await visible(page, "shift-switch", 3_000))) reach("the Day / Night switch is not in the sidebar"); + // The theme mark, which replaced v2's Day / Night switch (36bed1297 / #2825): there, and + // clicked as a person cycles it, it reaches night and day, the page taking each, then the + // theme it started on. + if (!(await visible(page, "theme-mark", 3_000))) reach("the theme mark is not in the sidebar"); else { - const day = (await page.getByTestId("shift-day").getAttribute("aria-pressed")) === "true"; - const other = day ? "shift-night" : "shift-day"; - const back = day ? "shift-day" : "shift-night"; - await page.getByTestId(other).click(); - if ((await page.getByTestId(other).getAttribute("aria-pressed")) !== "true") reach(`the switch does not mark ${other} once clicked`); - await page.getByTestId(back).click(); - if ((await page.getByTestId(back).getAttribute("aria-pressed")) !== "true") reach(`the switch does not mark ${back} once clicked back`); + const start = (await page.getByTestId("theme-mark").getAttribute("data-theme")) as "day" | "evening" | "night"; + for (const shift of ["night", "day", start] as const) { + try { + await pickShift(page, shift); + } catch (error) { + reach(String((error as Error).message)); + break; + } + const shown = await page.evaluate(() => document.documentElement.getAttribute("data-theme")); + if (shown !== shift) reach(`the theme mark reads ${shift}, and the page is in ${shown}`); + } } // The project level: No project, then each of the store's projects, in four diff --git a/goals/shift-manager/it-draws-v2s-look/run.mts b/goals/shift-manager/it-draws-v2s-look/run.mts index efeef8cd71..ac621420f9 100644 --- a/goals/shift-manager/it-draws-v2s-look/run.mts +++ b/goals/shift-manager/it-draws-v2s-look/run.mts @@ -65,7 +65,7 @@ import { RUN_STAMP, goalTmpDir, loadFixture, repoPath, runGoal } from "../../lib import { EM_KIND } from "../../../packages/shift-manager/teams/devteam/workforce/flows/workers/em.mts"; import { hex, parseColour, type Rgb } from "../../lib/colour.mts"; import { launchChromium } from "../../lib/playwright.mts"; -import { buildShiftManagerCopy, labApi, pendingSeatAsks, startShiftManager, type LabApi, type Patch } from "../../lib/shift-manager.mts"; +import { buildShiftManagerCopy, labApi, pendingSeatAsks, pickShift, startShiftManager, type LabApi, type Patch } from "../../lib/shift-manager.mts"; // ---- slice D ---- import * as inboxTasksRoster from "./screens-inbox-tasks-roster.mts"; // ---- end slice D ---- @@ -741,19 +741,6 @@ async function pendingAsksBySeat(api: LabApi, userId: string): Promise { - const mark = page.getByTestId("theme-mark"); - for (let i = 0; i < 3 && (await mark.getAttribute("data-theme")) !== shift; i += 1) { - await mark.click(); - await page.waitForFunction(() => !document.documentElement.classList.contains("theme-fade"), undefined, { timeout: 10_000 }); - } - if ((await mark.getAttribute("data-theme")) !== shift) throw new Error(`the theme mark never reached "${shift}"`); -} - /** Wait until the page shows `shift` and nothing is still moving or loading. */ async function settle(page: Page, shift: Shift): Promise { await page.waitForFunction( From f80e923612da59fc80bde665aa11909293fe5649 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 03:12:41 +0000 Subject: [PATCH 11/19] fix(goals): part 4 pins a conversation's session on the seat's flow (FIX-1824) FIX-1788 P4 has Shift Manager open the person's session with a seat on the flow the seat runs on, naming its worker, before the door runs in it (lib/conversation.ts). ER-15's seam list didn't name that write, so part 4 was red on every run. It is now allowed there and pinned: one createSession, on seat.kind, with state naming seat.id. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../parts.mts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/parts.mts b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/parts.mts index 6bc1dd8d0a..c1cee627b7 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/parts.mts +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/parts.mts @@ -359,7 +359,7 @@ export function part4(base: string, report: Report): void { "sendAction(": ["lib/send.ts", "lib/transcript.ts", "lib/talk.ts"], "abortRequest(": ["lib/run.ts"], "resumeSuspension(": ["lib/reads.ts"], - "createSession(": ["lib/reads.ts"], + "createSession(": ["lib/reads.ts", "lib/conversation.ts"], }; const writes: string[] = []; for (const file of own) { @@ -392,7 +392,15 @@ export function part4(base: string, report: Report): void { const creates = [...reads.matchAll(/\bcreateSession\(\s*\{([^}]*)\}/g)].map((m) => m[1]!); const createCount = reads.match(/\bcreateSession\(/g)?.length ?? 0; if (createCount !== creates.length || creates.some((args) => !/\bflowKind:\s*ROOM_KIND\b/.test(args))) report.fail("P4:ER-15", "lib/reads.ts creates a session on a kind other than the room kind"); - report.note(`P4 ER-15: Shift Manager's writes are [${writes.join("; ")}]: the seat's door (send.ts), the mailbox's post (transcript.ts), the project room's ${talkCalls.join("/")} on the room kind (talk.ts; ${roomCalls.length} call(s)), the person's room session (reads.ts; ${creates.length} createSession on ROOM_KIND), Interrupt's abort (run.ts) and the one resume (reads.ts); Inbox's reply is graded by FIX-1690's check in part 3`); + // A conversation's first line (FIX-1788 P4): a worker has no flow of its own, so the person's + // session with a seat is opened on the flow the seat runs on, naming it, before the door runs in it. + const conversation = stripComments(readFileSync(join(src, "lib", "conversation.ts"), "utf8")); + const opens = [...conversation.matchAll(/\bcreateSession\(\s*\{([^}]*\}[^}]*)\}/g)].map((m) => m[1]!); + const openCount = conversation.match(/\bcreateSession\(/g)?.length ?? 0; + if (openCount !== 1 || opens.length !== 1 || !/\bflowKind:\s*seat\.kind\b/.test(opens[0]!) || !/\bstate:\s*\{\s*\[WORKER_ID_STATE_KEY\]:\s*seat\.id\s*\}/.test(opens[0]!)) { + report.fail("P4:ER-15", "lib/conversation.ts opens a session other than the seat's own, on its flow and naming its worker"); + } + report.note(`P4 ER-15: Shift Manager's writes are [${writes.join("; ")}]: the seat's door (send.ts), a conversation's session opened on the seat's flow naming its worker (conversation.ts; ${opens.length} createSession), the mailbox's post (transcript.ts), the project room's ${talkCalls.join("/")} on the room kind (talk.ts; ${roomCalls.length} call(s)), the person's room session (reads.ts; ${creates.length} createSession on ROOM_KIND), Interrupt's abort (run.ts) and the one resume (reads.ts); Inbox's reply is graded by FIX-1690's check in part 3`); // One ask rendering: Inbox's detail and the stream's card draw through AskCard. for (const surface of ["Inbox.tsx", "Stream.tsx", "ChiefOfStaff.tsx"]) { From 55bbc65418e670d72d859f77d508413502b0af92 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 04:28:41 +0000 Subject: [PATCH 12/19] fix(goals): it-shows-and-stops-a-task-run compares a run's flow with the drainer's flow (FIX-1824) A run's owner is the flow its session is on. The check compared it with the drainer's worker id, which since FIX-1788 P4 is no flow, so the store precondition failed and every control read WRONG. The tree read now names the drainer's flow from its file, and the held rows and the board-flow control use it. Found by the FIX-1663 closure's part 3. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../it-shows-and-stops-a-task-run/goal.md | 3 +++ .../it-shows-and-stops-a-task-run/run.mts | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/goals/shift-manager/it-shows-and-stops-a-task-run/goal.md b/goals/shift-manager/it-shows-and-stops-a-task-run/goal.md index c48172d03a..eef61731b4 100644 --- a/goals/shift-manager/it-shows-and-stops-a-task-run/goal.md +++ b/goals/shift-manager/it-shows-and-stops-a-task-run/goal.md @@ -52,3 +52,6 @@ | 2026-10-01 | f46942359+wip (FIX-1691, same-process devtool) | n/a | PASS | No `--devtool`: the trace link is the devtool Shift Manager serves with `?session=` the run's session, and clicking it opens a page where that session is open, on all three run rows. With the devtool served over a second load of the config (its own store), the leg FAILs on every row with the devtool's own 404. `worker-session`, `optimistic-interrupt` and `board-flow` each FAIL at their named signal. | | 2026-10-01 | 829c2c2dd+wip (FIX-1690 lab) | n/a | PASS | Seats are now registered with their doors. No kind here declares one, so the composer is disabled and says the worker takes no message. Held on lab.lead: 7 items, then aborted. Held on lab.auditor: 11, then aborted. Finished: 6. | | 2026-10-01 | 475b3cd4b (feat/FIX-1649-shift-manager) | n/a | PASS | After the rename to Shift Manager. DevTeam served from `packages/shift-manager/teams/devteam`; the pages carry the boot-shift code, unset in this run. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy at f80e92361, before the fix (run by the FIX-1663 closure's part 3) | n/a | FAIL | Red since FIX-1788 P4 at the **store** precondition: *"the board does not hold the rows the goal reads: … in_progress lead; … in_progress audit; … completed lead; … pending no run"*. A run's owner is the flow its session is on (`lead`, `audit`), and the check compared it with the drainer's worker id (`lab.lead`), so no held row read as on the drainer's flow. The `board-flow` control's flow was the drainer's id too. Every control was WRONG for the same reason. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy | n/a | PASS | The tree read names the drainer's flow (`lead`, from its file), and the held rows and the `board-flow` control use it. Held on lab.lead's flow: 7 items drawn = stored, then aborted. Held on `audit`: 11, then aborted. Finished: 6. | +| 2026-10-09 | same (controls) | n/a | FAIL (expected) | `worker-session`: **items equal the run session's** on all three rows (nothing drawn) and **live** on both held rows. `optimistic-interrupt`: only **the request reads aborted first**, on both held rows. `board-flow`: only the `audit` row: the request 404s through `lead`, so its items, inspector, composer and Interrupt go with it; the other rows pass. | diff --git a/goals/shift-manager/it-shows-and-stops-a-task-run/run.mts b/goals/shift-manager/it-shows-and-stops-a-task-run/run.mts index a57e4c04db..63c27e3bc1 100644 --- a/goals/shift-manager/it-shows-and-stops-a-task-run/run.mts +++ b/goals/shift-manager/it-shows-and-stops-a-task-run/run.mts @@ -91,7 +91,8 @@ const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, // ---- the tree on disk ---------------------------------------------------------- -type Tree = { mailboxId: string; boardRef: string; drainerId: string; members: string[] }; +/** `drainerFlow` is the flow the drainer's file names: a worker has no flow of its own, so its runs are on that flow's one copy. */ +type Tree = { mailboxId: string; boardRef: string; drainerId: string; drainerFlow: string; members: string[] }; async function readTree(): Promise { const roster = await readDeclaredRoster(TREE); @@ -101,7 +102,7 @@ async function readTree(): Promise { const members = (mailbox.declared.members as string[] | undefined) ?? []; const drainer = roster.workers.find((w) => members.includes(w.id) && w.declared.flow !== undefined && w.declared.handoff === undefined); if (drainer === undefined) throw new Error("the tree's mailbox has no member that drains its board"); - return { mailboxId: mailbox.id, boardRef: `${mailbox.id}.${(mailbox.declared.boards as string[])[0]}`, drainerId: drainer.id, members }; + return { mailboxId: mailbox.id, boardRef: `${mailbox.id}.${(mailbox.declared.boards as string[])[0]}`, drainerId: drainer.id, drainerFlow: String(drainer.declared.flow), members }; } // ---- building Shift Manager -------------------------------------------------------- @@ -477,7 +478,7 @@ await runGoal(async () => { const tree = await readTree(); // GOAL_PAGES serves pages built elsewhere, e.g. from the commit before this // screen existed, to record the before-state. - const pages = process.env.GOAL_PAGES ?? (await buildShiftManager(CONTROL, tree.drainerId)); + const pages = process.env.GOAL_PAGES ?? (await buildShiftManager(CONTROL, tree.drainerFlow)); const failures: string[] = []; const evidence: string[] = []; const served = await startLab(pages); @@ -494,8 +495,9 @@ await runGoal(async () => { const owners = new Map(); for (const row of rows) if (row.run !== null) owners.set(row.id, await api.ownerOf(row.run.sessionId)); const held = rows.filter((r) => r.status === "in_progress" && r.run !== null); - const onDrainer = held.find((r) => owners.get(r.id) === tree.drainerId); - const ownFlow = held.find((r) => owners.get(r.id) !== tree.drainerId); + // A run's owner is the flow its session is on: the drainer's flow, or a seat's flow of its own. + const onDrainer = held.find((r) => owners.get(r.id) === tree.drainerFlow); + const ownFlow = held.find((r) => owners.get(r.id) !== tree.drainerFlow); const finished = rows.find((r) => r.status === "completed" && r.run !== null); const unclaimed = rows.find((r) => r.run === null && r.status !== "in_progress"); if (onDrainer === undefined || ownFlow === undefined || finished === undefined || unclaimed === undefined) { From 8d831cb04a44af3d22f024617d4df3ece88e3201 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 04:38:26 +0000 Subject: [PATCH 13/19] fix(goals): part 3 lets optimistic-turn redden the em door leg too (FIX-1824) FIX-1789 added an em door leg to it-sends-a-turn-into-a-seat-session: Inbox's reply to the EM's ask goes through send.ts, the module optimistic-turn swaps, so it goes red with delivered. The closure graded it as a stray. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../a-lab-is-worked-through-one-skinned-shell/run.mts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/run.mts b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/run.mts index 945f7f07af..d1473e1546 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/run.mts +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/run.mts @@ -410,7 +410,8 @@ const CHILDREN: Child[] = [ { id: "P3.2 FIX-1688/1689/1725 it-takes-its-look-from-the-design-system", run: SM("it-takes-its-look-from-the-design-system"), control: "hardcoded-accent", must: /\] neutral .*tool:/, allowed: /\] neutral .*tool:/ }, { id: "P3.2 FIX-1688/1689/1725 it-takes-its-look-from-the-design-system", run: SM("it-takes-its-look-from-the-design-system"), control: "switch-ignored", must: /\] switch /, allowed: /\] switch / }, { id: "P3.2 FIX-1690 it-sends-a-turn-into-a-seat-session", run: SM("it-sends-a-turn-into-a-seat-session") }, - { id: "P3.2 FIX-1690 it-sends-a-turn-into-a-seat-session", run: SM("it-sends-a-turn-into-a-seat-session"), control: "optimistic-turn", must: /\] delivered:/, allowed: /\] (delivered|stopped|continued|standing|heard):/ }, + // Inbox's reply to the EM's ask goes through the same send path (FIX-1789's em door leg), so it goes red with delivered. + { id: "P3.2 FIX-1690 it-sends-a-turn-into-a-seat-session", run: SM("it-sends-a-turn-into-a-seat-session"), control: "optimistic-turn", must: /\] delivered:/, allowed: /\] (delivered|stopped|continued|standing|heard|em door):/ }, { id: "P3.2 FIX-1690 it-sends-a-turn-into-a-seat-session", run: SM("it-sends-a-turn-into-a-seat-session"), control: "fresh-session", must: /\] continued:/, allowed: /\] continued:/ }, { id: "P3.2 FIX-1722 it-briefs-and-talks-with-the-chief-of-staff", run: SM("it-briefs-and-talks-with-the-chief-of-staff") }, { id: "P3.2 FIX-1722 it-briefs-and-talks-with-the-chief-of-staff", run: SM("it-briefs-and-talks-with-the-chief-of-staff"), control: "optimistic-reply", must: /\[desk\] talk/, allowed: /\[desk\] talk/ }, From 9f9351b6db392f181ff3d9c2929b035077d20061 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 05:03:31 +0000 Subject: [PATCH 14/19] docs(goals): the closure's verdict rows on the theme mark, every part and control (FIX-1824) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../a-lab-is-worked-through-one-skinned-shell/goal.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md index a2ec66ecd5..91be1eacb8 100644 --- a/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md +++ b/goals/shift-manager/a-lab-is-worked-through-one-skinned-shell/goal.md @@ -59,3 +59,7 @@ | 2026-10-04 | 01444863c (4b7d4d828: Codex's five review fixes; 01444863c: POC #2711's shared-helper fold) | Claude Code harness (a4), `claude` CLI (b0), real model where each child names one | **PASS** | One commit, fresh stores, each part its own process. **Negatives:** `GOAL_PART=bogus` and `GOAL_PART=` exit 1 naming the unknown part (on 49fd744e3 `bogus` printed PASS with 0 verdicts); `GOAL_CONTROLS=nope` exits 1; a part 3 selection matching nothing fails with "no verdict ran"; `GOAL_CONTROL_LEGS=c` on optimistic-post reads WRONG before building. **Legs:** a, b0 (the writer declared its guesses: none), b, c, d, J3, J4 PASS, 10 verdicts; b:org now checks DevForce inside leg b (store org devforce-lab, switcher devforce-lab) beside pentest and the no-resolver Lab. **Controls:** all six RIGHT: today's main FAIL as expected (c's static half green); hardcoded-accent at c:tool only (the patch printed as a unified diff through the shared copy build); static-names at b:teams only; optimistic-post at a4 + b:post only; worker-session at a2 only (c:sweep, as allowed); no-org at b:org only, red on pentest, no-resolver and DevForce. **Part 3:** 39 verdicts, all as expected, `pnpm typecheck` and `pnpm test` PASS. **Part 4** PASS. | | 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a, before the oracle fix | none (leg c) | FAIL (finding) | The store's asks were read from sessions whose `flowId` is a seat, which no session has since FIX-1788 P4 (a seat's session is on the flow it runs on and names it as its `workerId`), so the store held no ask while Inbox drew the EM's. **c FAIL (12):** *"DevForce raised no ask, so the ask card could not be swept"*, *"no ask is pending and Inbox's empty state is not named"*, *"no board holds a row, so the task level was never reached"* and the sweeps that follow (ask 0, devtool 0 elements), day and night, plus the Day / Night switch below. **b FAIL (1):** the Day / Night switch only; pentest holds no ask, so its Inbox check passes either way. | | 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | Claude Code harness (a4) | FAIL (finding, not this change) | `readStore` reads asks through `goals/lib`'s `pendingSeatAsks`, as Shift Manager's `reads.ts` picks them: a session on a seat's kind that names that seat, or names none. **a FAIL at a3 only:** a1 the EM's approval ask from eng.em, Inbox names exactly the store's memberships [eng.feature, eng.triage, ops.oncall, ops.release], approved, resume stored, gone from Inbox; a4 delivered (held when drawn) and answered in the run session; a2 15 items drawn, all stored, from Tasks and Board, trace followed. **c FAIL at the switch only:** message 20, reasoning 16, tool 50, code block 32, ask 11, devtool 293/292 elements, 0 Shift Manager values; static fence 0 hits in 2705 files. **b FAIL at the switch only:** 3 seats, post held 1 when drawn, `packages/shift-manager` unchanged, org on all three Labs. **Finding:** a3, b:reach and c:reach look for the sidebar's Day / Night switch (`shift-switch`), which the theme mark replaced (36bed1297 / #2825); `it-draws-v2s-look` already grades the shipped header. Out of FIX-1824's scope, so every control would read WRONG at those three signals; controls, b0, d and parts 2 to 4 were not run. | +| 2026-10-09 | accb40cdd to 8d831cb04 (fix/FIX-1824-goals-one-copy: the theme mark, part 4's conversation door, part 3's em door) | Claude Code harness (a4), `claude` CLI (b0), real model where each child names one | FAIL (findings, not FIX-1824) | Each part its own process, one at a time. a3, b:reach and c:reach now click the theme mark (`goals/lib`'s `pickShift`, shared with `it-draws-v2s-look`) to night, day and back, and check the page takes each. **a PASS:** a1 the EM's approval from Inbox, its four memberships, resume stored, gone; a4 delivered (held when drawn), answered in the run session; a2 16 items drawn, all stored, from Tasks and Board; a3 every surface. **b PASS:** 3 seats, post held 1 when drawn, `packages/shift-manager` unchanged, org on all three Labs. **c PASS:** message 20, reasoning 16, tool 50, code block 32, ask 11, devtool 292 elements, 0 Shift Manager values day and night; static fence 0 hits in 2705 files. **d PASS** (144 rows; drift at surface + type, unclassified and missing at totality). **J3, J4 PASS.** **b0 FAIL (finding):** both configs boot the same 4 flows, org, seats, workstream and user, but the writer declared 3 guesses (which store; whether `openLab` needs only stores, inventory and devtool; whether the host's `inventory` and `devtool` do the README's steps). **Part 4 FAIL (1, finding):** *"labs/README.md does not list Shift Manager"*: 652e41938 (FIX-1770 PR-C) moved it to a package and the README now links `../packages/shift-manager`. Part 4's ER-15 had also been red at *"lib/conversation.ts writes through createSession("*, the conversation's session FIX-1788 P4 opens naming its worker; it is now allowed and pinned to `seat.kind` with `state` naming `seat.id`, and a planted `flowKind: "agent"` turns it red. A planted dead theme mark (its click does nothing) turns b:reach red: *"the theme mark never reached "day""*. | +| 2026-10-09 | f80e92361 | as above | controls | today's main FAIL as expected (c's static half green). static-names at b:teams only; optimistic-post at a4 + b:post only; worker-session at a2 only; no-org at b:org only. **hardcoded-accent WRONG (finding):** *"stayed green at c:tool"*. Since 5910d4279 / 810765e5e (2026-10-07) Shift Manager draws a tool call as a quiet line (`ToolLine`), which doesn't render `tool.tsx`'s status icons, so the patched `CheckCircleIcon` never paints. | +| 2026-10-09 | f80e92361 to 8d831cb04 | real model where each child names one | FAIL (part 3, findings) | Every child check and control as expected except one goal. design-system and its control, it-opens-a-lab and its three, it-sends-a-turn (`fresh-session`; `optimistic-turn` once the closure lets FIX-1789's em door leg go red with delivered), it-briefs-and-talks and both controls (`optimistic-reply` re-pointed at `lib/conversation.ts`), it-shows-who-is-on-shift and both, it-hands-a-run and `drop-task`, both D1 children and controls, the three devforce labs, both pentest labs and multi-seat-collab PASS. it-shows-and-stops-a-task-run was red at its **store** precondition (it compared a run's flow with the drainer's worker id); fixed in FIX-1824, it passes and its three controls fail at their signals. **it-takes-its-look-from-the-design-system FAIL (finding):** *"page.waitForFunction: Timeout 10000ms exceeded"* in `readPass`, and its `switch-ignored` control can't build: *"src/surfaces/Sidebar.tsx has nothing to patch (looked for onClick={() => look.choose(scheme)})"*. The goal still drives the Day / Night switch the theme mark replaced (#2825). design-system static fence, registry drift and palette census, Shift Manager's copies unedited PASS; `pnpm typecheck`'s steps PASS with turbo held to `--concurrency=2` for the shared box (74 tasks). `pnpm test`: see the next row. | +| 2026-10-09 | 8d831cb04 | none | PASS (part 3, `pnpm test`) | The first run stopped at `@flow-state-dev/engine`: *"filesystem (session stream conformance) > keeps an unfinished run older than a page of runs listed (BR-23)"* timed out at 25 s; the file passes alone (46 passed). The second stopped at `@flow-state-dev/shift-manager`'s *"the pages are not built at …/packages/shift-manager/dist-client"*, because this checkout had never built them. After `pnpm --filter @flow-state-dev/shift-manager build`, 72 of 72 tasks pass, the earlier ones from turbo's cache of the runs before. | From 360f03c298c1a1efdd2732511758da9a19ecd479 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 05:03:41 +0000 Subject: [PATCH 15/19] docs(goals): it-draws-v2s-look's verdict row with pickShift shared (FIX-1824) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- goals/shift-manager/it-draws-v2s-look/goal.md | 1 + 1 file changed, 1 insertion(+) diff --git a/goals/shift-manager/it-draws-v2s-look/goal.md b/goals/shift-manager/it-draws-v2s-look/goal.md index dc0e2ef922..d3caccea67 100644 --- a/goals/shift-manager/it-draws-v2s-look/goal.md +++ b/goals/shift-manager/it-draws-v2s-look/goal.md @@ -72,3 +72,4 @@ Which regions are graded whole grows with each slice's screens: Chief of Staff's | 2026-10-09 | fix/closure-children-one-copy (main 57d2c10e9) | n/a | PASS | On one copy per flow (FIX-1788 P4): the EM's drain runs in a session on `em` naming it, the desk Lab registers one copy per flow over an installation, and the ask oracles take a session's seat from the worker its state names. The themes are picked with the sidebar's theme mark, and the Shift Coordinator feed and column rows read the `conversation-*` hooks. The table is re-baselined on the shipped sidebar header (36bed1297 / #2825): v2's shift switch row (v2:113) gives way to rows for the header, the theme mark and its svg, the app's name and the theme name, each asserting the values the run reads and citing the shipped source. 144 rows, 21 exceptions. Controls: `drift` FAILs only at **surface** (`button[team]` radius) and **type** (the Roster count, Tasks ID); `missing` only at **totality** (Tasks ID 0 of 1); `unclassified` only at **totality** (`p "A line no row covers"`). Planted wrong values in the four new rows each FAIL at that row, and a stale citation fails setup. | | 2026-10-09 | fix/FIX-1824-goals-one-copy on 9d136d21a | n/a | PASS | The seats' pending asks are now read through `goals/lib`'s `pendingSeatAsks`, the one helper the Shift Manager goals share (same predicate: a session on a seat's kind that names that seat, or names none); `pendingAsks`' precondition still reads every session. The desk Lab's header says what it runs: `chief-of-staff` on the one `agent` copy. 144 rows, 21 exceptions; devteam 2 teams, 4 seats, 1 running, 1 ask pending, chief of staff yes. | | 2026-10-09 | same (controls) | n/a | FAIL (expected) | `drift` only at **surface** and **type** (the team row's radius; the Roster count and Tasks ID in the sans, both shifts and widths); `unclassified` only at **totality** (`p "A line no row covers"`); `missing` only at **totality** (Tasks ID 0 of 1). | +| 2026-10-09 | accb40cdd (`pickShift` moved to `goals/lib/shift-manager.mts`, shared with the FIX-1663 closure), run as the closure's leg d | n/a | PASS, and the three controls FAIL (expected) | 144 rows, 21 exceptions; devteam 2 teams, 4 seats, 1 running, 1 ask pending, chief of staff yes. `drift` at surface + type only, `unclassified` and `missing` at totality only. | From 0ad8b70c71b2669ea72b08555f102488d164b22e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 05:21:55 +0000 Subject: [PATCH 16/19] fix(goals): it-takes-its-look-from-the-design-system on the theme mark (FIX-1824) The goal drove the Day / Night switch the theme mark replaced (36bed1297 / #2825), and its passes relied on Shift Manager following the OS setting, which it no longer does. Each pass now runs over a Lab started on its shift (SHIFT_MANAGER_SHIFT), the switch leg picks with the theme mark (goals/lib's pickShift) against the shift each Lab started on, and switch-ignored patches out the mark's click handler. Still red at themed: the mark's root svg leaves fill at the default black. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../goal.md | 13 +- .../run.mts | 133 ++++++++++-------- 2 files changed, 80 insertions(+), 66 deletions(-) diff --git a/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md b/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md index b09bc4268a..afceacc605 100644 --- a/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md +++ b/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md @@ -2,22 +2,22 @@ **Issue:** FIX-1688, FIX-1689, FIX-1725 and FIX-1736 (epic FIX-1649) -**Outcome:** Shift Manager's light and dark look, its two typefaces included, comes from the design-system package's one import. The FSD parts it reuses in a task's Session (message, reasoning, tool and code block cards) are its unedited registry copies, and they take that look with the rest of the shell. Remove the one import and no Shift Manager value is left on any of them: the shell and the cards show the registry's neutral defaults. The Day shift / Night shift switch in the sidebar changes the look on the spot, either way, whatever the OS prefers, and the pick holds through a reload. +**Outcome:** Shift Manager's light and dark look, its two typefaces included, comes from the design-system package's one import. The FSD parts it reuses in a task's Session (message, reasoning, tool and code block cards) are its unedited registry copies, and they take that look with the rest of the shell. Remove the one import and no Shift Manager value is left on any of them: the shell and the cards show the registry's neutral defaults. The theme mark in the sidebar (which replaced the Day shift / Night shift switch, 36bed1297 / #2825) changes the look on the spot, either way, whatever shift the Lab started on, and the pick holds through a reload. **Input:** Shift Manager as checked out, copied to a scratch directory and built twice: as written, and with the line `@import "@flow-state-dev/design-system/shift-manager.css";` removed from `src/styles.css`. Each build is served by Shift Manager's command over the run-lab (`packages/shift-manager/test/fixtures/run-lab/`), whose runs store a message, a reasoning item and a tool call with its result. Shift Manager's theme values and font families are read from `labs/design-system/shift-manager.css` at run time. -**Signal:** Chromium opens a running task from Tasks by clicking, opens its tool card and reasoning, and reads the computed colour, background, border, outline, svg stroke and fill, and font of every visible element on the shell and inside each swept card. Two passes per build: with the browser set to light, then to dark (Shift Manager follows that setting). Each failure is tagged ` [ ]`. +**Signal:** Chromium opens a running task from Tasks by clicking, opens its tool card and reasoning, and reads the computed colour, background, border, outline, svg stroke and fill, and font of every visible element on the shell and inside each swept card. Two passes per build, each over a Lab started on its shift (`SHIFT_MANAGER_SHIFT`, as `--shift` sets it), which a browser that has picked nothing opens on: light on day, then dark on night. Shift Manager no longer follows the OS setting; it takes a person's pick, then the shift it was started on, then the clock. Each failure is tagged ` [ ]`. - **reach**: the Session draws each swept registry part (message, reasoning, tool, code block) at least once. - **themed**: on the build as written, every painted colour is one of Shift Manager's values for that variant (to within 3 per channel), and every font is one of its families. For every family and weight the page's text is set in, `document.fonts` holds a face with status `loaded`. - **neutral** (the closure's leg c): on the build without the import, no painted colour is any Shift Manager value from either variant, no font is one of its families, and `document.fonts` holds no face of one. -- **switch**: on the build as written, in a fresh browser with nothing picked, opened on Tasks with the OS set to light. Clicking *Night shift* makes the page's computed background Shift Manager's dark `--background`; after a reload it still is. With the OS set to dark, clicking *Day shift* makes it the light `--background`; after a reload it still is. Each time the switch marks the shift the page is on (`aria-pressed`). +- **switch**: on the build as written, in a fresh browser with nothing picked, opened on Tasks. Over the Lab started on day, picking night with the theme mark (clicked as a person cycles it, `goals/lib`'s `pickShift`) makes the page's computed background Shift Manager's dark `--background`; after a reload it still is. Over the Lab started on night, picking day makes it the light `--background`; after a reload it still is. Each time the mark shows the theme the page is on (`data-theme`). **Anti-game:** - The no-theme build removes exactly one line. If that line isn't there, the setup fails: a build that "removed" an import that was never loaded proves nothing. - A font is graded by the face the browser loaded, not by the computed `font-family` string, which names the family whether or not it loaded. - Colours are graded by computed value, never by class name. Colours set by an inline literal (syntax highlighting) are content, not skin, and are skipped. -- Each switch click is made against the opposite OS setting, so a page that ignored the click and followed the OS fails. The two backgrounds are read from `labs/design-system/shift-manager.css`, and the setup fails if they're the same colour. +- Each pick is made against the shift the Lab started on, so a page that ignored the click and kept its start fails, and the reload is where the start would put it back. The two backgrounds are read from `labs/design-system/shift-manager.css`, and the setup fails if they're the same colour. - The copies being unedited is CI's job (`packages/shift-manager/test/static.test.ts`), checked against the install list in Shift Manager's `package.json`. **Model:** n/a (the run-lab's scripted runs). @@ -26,7 +26,7 @@ **Controls:** - `GOAL_CONTROL=hardcoded-accent`: Shift Manager's copy of the tool card paints its completed icon with Shift Manager's accent (`--attention`, light) as a literal class, in both builds. Must fail at **neutral** naming `tool`, light and dark, and nowhere else. -- `GOAL_CONTROL=switch-ignored`: the switch's buttons do nothing when clicked. Must fail at **switch**, on every step after the first click, and nowhere else. +- `GOAL_CONTROL=switch-ignored`: the theme mark does nothing when clicked (`ShiftManagerMark.tsx`'s `onClick={look.cycle}` patched out). Must fail at **switch**, on every step after the first click, and nowhere else. - `GOAL_CONTROL=fonts-not-loaded`: the build as written imports a copy of the design-system stylesheet with only its font imports blanked, so the families are named and no face is declared. Must fail at **themed** on the fonts, light and dark, and nowhere else. ## Verdict log @@ -49,3 +49,6 @@ | 2026-10-02 | fix/FIX-1736-fonts (pre-PR) | n/a | PASS | Faces loaded, light and dark: Space Grotesk 400, 500, 600, IBM Plex Mono 400. No-theme: none loaded or declared. Shell 123 elements; light 372 colours, dark 377. | | 2026-10-02 | fix/FIX-1736-fonts (pre-PR), `GOAL_CONTROL=fonts-not-loaded` | n/a | FAIL (expected) | Only **themed**, on the fonts, light and dark (`document.fonts`: none declared). Colours, neutral and switch pass. | | 2026-10-02 | fix/FIX-1736-fonts, review round (Latin subsets, IBM Plex Mono 700, weights compared as numbers) | n/a | PASS | Same faces loaded as above; no-theme none. `GOAL_CONTROL=fonts-not-loaded` (font imports blanked): FAIL (expected), only **themed** on the fonts, light and dark. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy at 8d831cb04, before (run by the FIX-1663 closure's part 3) | n/a | FAIL | Red since the theme mark replaced the shift switch (36bed1297 / #2825): *"page.waitForFunction: Timeout 10000ms exceeded"* in `readPass`. The page no longer follows the OS setting, so the light pass found it dark (the clock said night). `switch-ignored` could not build: *"src/surfaces/Sidebar.tsx has nothing to patch (looked for onClick={() => look.choose(scheme)})"*. | +| 2026-10-09 | fix/FIX-1824-goals-one-copy (the theme mark) | n/a | FAIL (finding, not FIX-1824) | Each pass is over a Lab started on its shift (`SHIFT_MANAGER_SHIFT`), and **switch** picks with the theme mark (`goals/lib`'s `pickShift`) against the shift each Lab started on. reach, neutral and switch pass: picking night over day paints `#1c1b15` and holds through a reload, and picking day over night paints `#f8f6f0` and holds. **themed FAIL**, light and dark, on one element: *"shell: svg.block.h-auto.w-[42px] fill → #000000 is not a Shift Manager light value"*. The mark's root `` (`ShiftManagerMark.tsx`) sets no `fill`, so its computed fill is the default black, though every child sets its own. The sidebar's `NavIcon` was red the same way on 2026-10-04 and was fixed in Shift Manager with `fill="none"` on its ``. | +| 2026-10-09 | same (controls) | n/a | FAIL | `switch-ignored` (the mark's `onClick={look.cycle}` patched out): **switch** on every step after the first pick, both halves (*"the theme mark never reached "night""*, the background kept, the mark unchanged, and the same after the reload), plus the mark's `fill` above. `fonts-not-loaded`: **themed** on the fonts, light and dark, plus the mark's `fill`. **`hardcoded-accent` WRONG**: only the mark's `fill`; **neutral** stays green, because since 5910d4279 / 810765e5e a tool call is a quiet line that doesn't render the patched status icon (the closure's `hardcoded-accent` reads WRONG the same way). | diff --git a/goals/shift-manager/it-takes-its-look-from-the-design-system/run.mts b/goals/shift-manager/it-takes-its-look-from-the-design-system/run.mts index 87d8b505fb..f5f5b8cd9e 100644 --- a/goals/shift-manager/it-takes-its-look-from-the-design-system/run.mts +++ b/goals/shift-manager/it-takes-its-look-from-the-design-system/run.mts @@ -2,7 +2,7 @@ * Goal check: Shift Manager takes its light and dark look from the design-system * package's one import, the FSD parts it reuses are the registry's copies, * with that import removed no Shift Manager value shows on any of them, and - * the sidebar's shift switch changes the look live, both ways. + * the sidebar's theme mark changes the look live, both ways. * * Real path, no model, out of CI. See goal.md for the contract. * @@ -11,7 +11,9 @@ * run-lab (`packages/shift-manager/test/fixtures/run-lab/`), whose runs store * a message, a reasoning item and a tool call through the Claude Code harness's * emit path. Chromium opens a task from Tasks by clicking, opens its tool card, - * and reads COMPUTED styles in a light pass and a dark pass, set through the browser's colour-scheme setting. + * and reads COMPUTED styles in a light pass and a dark pass, each over a Lab + * started on that shift (day, then night; `SHIFT_MANAGER_SHIFT`, as `--shift` + * sets it), which a browser that has picked nothing opens on. * * Builds: * themed Shift Manager as written @@ -31,20 +33,21 @@ * on a swept part is any Shift Manager value (either variant), no * font is one of its families, and the page declares no face of * one, so the fonts arrive with the import and only with it - * switch on the themed build, in a fresh browser: clicking Night shift - * while the OS prefers light paints the page's background with - * Shift Manager's dark value, clicking Day shift while the OS - * prefers dark paints its light value, the switch shows the shift - * it's on each time, and each pick survives a reload + * switch on the themed build, in a fresh browser, with the sidebar's theme + * mark (which replaced the Day / Night switch, 36bed1297 / #2825): + * over the Lab started on day, picking night paints the page's + * background with Shift Manager's dark value; over the one started + * on night, picking day paints its light value; the mark shows the + * theme the page is on each time, and each pick survives a reload * * Control: * GOAL_CONTROL=hardcoded-accent Shift Manager's copy of the tool card paints its * completed icon with Shift Manager's accent as a * literal, in both builds. `neutral` must FAIL * naming `tool`, and nothing else may fail. - * GOAL_CONTROL=switch-ignored the shift switch's buttons do nothing when - * clicked. `switch` must FAIL, and nothing - * else may fail. + * GOAL_CONTROL=switch-ignored the theme mark does nothing when clicked. + * `switch` must FAIL, and nothing else may + * fail. * GOAL_CONTROL=fonts-not-loaded the themed build imports the design-system * stylesheet with its font imports blanked, so * the families are named but no face is declared. @@ -62,7 +65,7 @@ import { declarations, hex, near, parseColour, readShiftManagerTheme, type Rgb } import { stripImportsAndComments } from "../../../labs/design-system/test/theme.ts"; import { REPO_ROOT, goalTmpDir, runGoal } from "../../lib/index.mts"; import { launchChromium } from "../../lib/playwright.mts"; -import { buildShiftManagerCopy, startShiftManager, type Patch, type ServedShiftManager } from "../../lib/shift-manager.mts"; +import { buildShiftManagerCopy, pickShift, startShiftManager, type Patch, type ServedShiftManager } from "../../lib/shift-manager.mts"; const CONTROL = process.env.GOAL_CONTROL ?? ""; const CONTROLS = ["hardcoded-accent", "switch-ignored", "fonts-not-loaded"] as const; @@ -106,8 +109,9 @@ const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, // ---- serving ----------------------------------------------------------------- -const startLab = (pages: string): Promise => - startShiftManager({ scratch: SCRATCH, label: "run-lab", config: join(RUN_LAB, "fsdev.config.mts"), pages }); +/** The run-lab served on `shift`: the theme a browser that has picked nothing opens on (`SHIFT_MANAGER_SHIFT`, as `--shift` sets it). */ +const startLab = (pages: string, shift: "day" | "night"): Promise => + startShiftManager({ scratch: SCRATCH, label: `run-lab-${shift}`, config: join(RUN_LAB, "fsdev.config.mts"), pages, env: { SHIFT_MANAGER_SHIFT: shift } }); /** A board row with a run, read through the Lab's own route. */ async function rowWithRun(origin: string): Promise { @@ -196,8 +200,7 @@ function readPage(args: { swept: Record; probeValues: string[] } /** Open the task from Tasks, open what its Session draws closed, and read one pass. */ async function readPass(page: Page, origin: string, taskId: string, dark: boolean): Promise { - // Shift Manager follows the OS setting, so the pass sets the setting, not the class. - await page.emulateMedia({ colorScheme: dark ? "dark" : "light" }); + // The Lab was started on the pass's shift, which a browser that has picked nothing opens on. await page.goto(`${origin}/tasks`); await page.getByTestId("tasks-table").waitFor({ timeout: 20_000 }); await page.locator(`[data-testid=task-row][data-task-id="${taskId}"]`).click(); @@ -223,46 +226,51 @@ async function readPass(page: Page, origin: string, taskId: string, dark: boolea return page.evaluate(readPage, { swept: SWEPT, probeValues: [...THEME.light, ...THEME.dark] }); } -// ---- the shift switch ---------------------------------------------------------- +// ---- the theme mark ----------------------------------------------------------- /** - * The switch leg: a fresh browser (nothing picked yet), each click made - * against the opposite OS setting so a page that ignored the click and - * followed the OS fails, and each pick read again after a reload. + * Half the switch leg, on the theme mark that replaced the Day / Night switch + * (36bed1297 / #2825), over a Lab started on `started`: a fresh browser + * (nothing picked yet) opens on that shift, the mark picks the other one, so + * a page that ignored the click and kept the start fails, and the pick is + * read again after a reload, where the start would put it back. Run once over + * a Lab started on day and once over one started on night, it covers both ways. */ -async function switchLeg(browser: Browser, origin: string): Promise<{ failures: string[]; evidence: string }> { +async function switchLeg(browser: Browser, origin: string, started: "day" | "night"): Promise<{ failures: string[]; evidence: string }> { const failures: string[] = []; const seen: string[] = []; const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } }); + const mark = page.getByTestId("theme-mark"); const ready = async () => { - await page.getByTestId("shift-switch").waitFor({ timeout: 20_000 }); + await mark.waitFor({ timeout: 20_000 }); await page.waitForFunction(() => document.getAnimations().every((a) => a.playState !== "running" || a.effect?.getTiming().iterations === Infinity)); }; - const expect = async (step: string, want: "light" | "dark") => { + const expect = async (step: string, want: "day" | "night") => { await ready(); + const variant = want === "night" ? "dark" : "light"; const got = parseColour(await page.evaluate(() => getComputedStyle(document.body).backgroundColor)); - const shown = want === "dark" ? "Night shift" : "Day shift"; - if (got === null || !near(got.rgb, BACKGROUND[want])) { - failures.push(`switch [${step}] the page background is ${got === null ? "transparent" : hex(got.rgb)}, not Shift Manager's ${want} ${hex(BACKGROUND[want])}`); - } - if ((await page.getByTestId(want === "dark" ? "shift-night" : "shift-day").getAttribute("aria-pressed")) !== "true") { - failures.push(`switch [${step}] the switch doesn't show ${shown}`); + if (got === null || !near(got.rgb, BACKGROUND[variant])) { + failures.push(`switch [${step}] the page background is ${got === null ? "transparent" : hex(got.rgb)}, not Shift Manager's ${variant} ${hex(BACKGROUND[variant])}`); } + const marked = await mark.getAttribute("data-theme"); + if (marked !== want) failures.push(`switch [${step}] the theme mark shows ${marked}, not ${want}`); seen.push(`${step}: ${got === null ? "transparent" : hex(got.rgb)}`); }; + const pick = async (step: string, want: "day" | "night") => { + try { + await pickShift(page, want); + } catch (error) { + failures.push(`switch [${step}] ${String((error as Error).message)}`); + } + await expect(step, want); + }; try { - await page.emulateMedia({ colorScheme: "light" }); + const want = started === "day" ? "night" : "day"; await page.goto(`${origin}/tasks`); - await expect("OS light, nothing picked", "light"); - await page.getByTestId("shift-night").click(); - await expect("Night shift clicked, OS light", "dark"); - await page.reload(); - await expect("reloaded after Night shift, OS light", "dark"); - await page.emulateMedia({ colorScheme: "dark" }); - await page.getByTestId("shift-day").click(); - await expect("Day shift clicked, OS dark", "light"); + await expect(`started on ${started}, nothing picked`, started); + await pick(`${want} picked, started on ${started}`, want); await page.reload(); - await expect("reloaded after Day shift, OS dark", "light"); + await expect(`reloaded after ${want}, started on ${started}`, want); } finally { await page.close(); } @@ -344,10 +352,10 @@ await runGoal(async () => { : CONTROL === "switch-ignored" ? [ { - file: "src/surfaces/Sidebar.tsx", - from: "onClick={() => look.choose(scheme)}", + file: "src/components/ShiftManagerMark.tsx", + from: "onClick={look.cycle}", to: "onClick={() => undefined}", - why: "the shift switch's buttons do nothing when clicked", + why: "the theme mark does nothing when clicked", }, ] : []; @@ -382,16 +390,18 @@ await runGoal(async () => { const browser = await launchChromium(); try { for (const { name, pages } of builds) { - const served = await startLab(pages); - try { - const taskId = await rowWithRun(served.origin); - const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } }); - const errors: string[] = []; - page.on("pageerror", (e) => errors.push(e.message)); - // tsx compiles this file with esbuild's keepNames, which wraps nested - // functions in readPage with a `__name` helper the page lacks. - await page.addInitScript("globalThis.__name = (fn) => fn;"); - for (const variant of ["light", "dark"] as const) { + // One Lab per pass, started on the pass's shift: the light pass on day, the dark pass on night. + for (const variant of ["light", "dark"] as const) { + const shift = variant === "dark" ? "night" : "day"; + const served = await startLab(pages, shift); + try { + const taskId = await rowWithRun(served.origin); + const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } }); + const errors: string[] = []; + page.on("pageerror", (e) => errors.push(e.message)); + // tsx compiles this file with esbuild's keepNames, which wraps nested + // functions in readPage with a `__name` helper the page lacks. + await page.addInitScript("globalThis.__name = (fn) => fn;"); const tag = `${name} ${variant}`; const read = await readPass(page, served.origin, taskId, variant === "dark"); if (name === "themed" && variant === "light") { @@ -404,17 +414,18 @@ await runGoal(async () => { `${tag}: ${Object.entries(read.counts).map(([p, n]) => `${p} ${n}`).join(", ")} elements; ${read.colours.length} colours, ${read.fonts.length} fonts; faces loaded: ${loadedFaces.length === 0 ? "none" : [...new Set(loadedFaces)].join(", ")}`, ); if (process.env.GOAL_KEEP === "1") await page.screenshot({ path: join(SCRATCH, `${name}-${variant}.png`), fullPage: true }); + if (errors.length > 0) failures.push(`reach [${tag}] the page threw: ${errors.join(" | ")}`); + await page.close(); + // Half the switch leg on each themed Lab, in a fresh browser: picked against the shift it started on. + if (name === "themed") { + const switched = await switchLeg(browser, served.origin, shift); + failures.push(...switched.failures); + evidence.push(switched.evidence); + } + } finally { + served.child.kill("SIGTERM"); + await served.exited; } - if (errors.length > 0) failures.push(`reach [${name}] the page threw: ${errors.join(" | ")}`); - await page.close(); - if (name === "themed") { - const switched = await switchLeg(browser, served.origin); - failures.push(...switched.failures); - evidence.push(switched.evidence); - } - } finally { - served.child.kill("SIGTERM"); - await served.exited; } } } finally { From d3b2098903692230a0bc3f809d5555d3ad07226c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 05:22:51 +0000 Subject: [PATCH 17/19] fix(shift-manager): the theme mark's svg paints no fill of its own Every shape in the mark sets its own fill, so the root svg's default black painted nothing, but the design-system look check grades every svg's computed fill and read it as a colour that isn't Shift Manager's. fill="none" on the root, as NavIcon does. Nothing changes on screen. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- packages/shift-manager/src/components/ShiftManagerMark.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shift-manager/src/components/ShiftManagerMark.tsx b/packages/shift-manager/src/components/ShiftManagerMark.tsx index 16e9cc2433..7ccc7aabbf 100644 --- a/packages/shift-manager/src/components/ShiftManagerMark.tsx +++ b/packages/shift-manager/src/components/ShiftManagerMark.tsx @@ -54,7 +54,7 @@ export function ShiftManagerMark({ look }: { look: ThemeLook }) { data-theme={theme} className="flex shrink-0 cursor-pointer py-0.5" > - + {PETALS.map((d, i) => ( From d468817e59844eb146b613ee236b5e5490d5f5cb Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 05:38:15 +0000 Subject: [PATCH 18/19] docs(goals): it-takes-its-look-from-the-design-system green on the theme mark (FIX-1824) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01XMg2dz8sMEdyzCQTRsaMTV --- .../it-takes-its-look-from-the-design-system/goal.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md b/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md index afceacc605..5659ddb15f 100644 --- a/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md +++ b/goals/shift-manager/it-takes-its-look-from-the-design-system/goal.md @@ -52,3 +52,5 @@ | 2026-10-09 | fix/FIX-1824-goals-one-copy at 8d831cb04, before (run by the FIX-1663 closure's part 3) | n/a | FAIL | Red since the theme mark replaced the shift switch (36bed1297 / #2825): *"page.waitForFunction: Timeout 10000ms exceeded"* in `readPass`. The page no longer follows the OS setting, so the light pass found it dark (the clock said night). `switch-ignored` could not build: *"src/surfaces/Sidebar.tsx has nothing to patch (looked for onClick={() => look.choose(scheme)})"*. | | 2026-10-09 | fix/FIX-1824-goals-one-copy (the theme mark) | n/a | FAIL (finding, not FIX-1824) | Each pass is over a Lab started on its shift (`SHIFT_MANAGER_SHIFT`), and **switch** picks with the theme mark (`goals/lib`'s `pickShift`) against the shift each Lab started on. reach, neutral and switch pass: picking night over day paints `#1c1b15` and holds through a reload, and picking day over night paints `#f8f6f0` and holds. **themed FAIL**, light and dark, on one element: *"shell: svg.block.h-auto.w-[42px] fill → #000000 is not a Shift Manager light value"*. The mark's root `` (`ShiftManagerMark.tsx`) sets no `fill`, so its computed fill is the default black, though every child sets its own. The sidebar's `NavIcon` was red the same way on 2026-10-04 and was fixed in Shift Manager with `fill="none"` on its ``. | | 2026-10-09 | same (controls) | n/a | FAIL | `switch-ignored` (the mark's `onClick={look.cycle}` patched out): **switch** on every step after the first pick, both halves (*"the theme mark never reached "night""*, the background kept, the mark unchanged, and the same after the reload), plus the mark's `fill` above. `fonts-not-loaded`: **themed** on the fonts, light and dark, plus the mark's `fill`. **`hardcoded-accent` WRONG**: only the mark's `fill`; **neutral** stays green, because since 5910d4279 / 810765e5e a tool call is a quiet line that doesn't render the patched status icon (the closure's `hardcoded-accent` reads WRONG the same way). | +| 2026-10-09 | d3b209890 (fix/FIX-1824-goals-one-copy: `fill="none"` on the theme mark's ``, as `NavIcon`) | n/a | **PASS** | Themed light and dark: shell 155, message 8, reasoning 16, tool 50, code block 32 elements; 422 colours; faces loaded Space Grotesk 400/500/600/700, IBM Plex Mono 400/500/600. No-theme light and dark: no Shift Manager value, no face. switch: started on day `#f8f6f0`, night picked `#1c1b15`, and after a reload; started on night `#1c1b15`, day picked `#f8f6f0`, and after a reload. `packages/shift-manager` tests: 37 files, 391 passed. | +| 2026-10-09 | d3b209890 (controls) | n/a | FAIL (expected), one WRONG | `switch-ignored` only at **switch**, every step after the first pick, both halves (*"the theme mark never reached "night""*). `fonts-not-loaded` only at **themed**, on the fonts, light and dark. **`hardcoded-accent` WRONG**: the run passes, because a tool call is a quiet line that doesn't render the patched status icon; tracked in FIX-1827 with the closure's. | From 9cc8f83ee0c81b637cffb034bb9b089467f0d62a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 9 Oct 2026 05:45:31 +0000 Subject: [PATCH 19/19] poc: count pending asks without grouping them by seat pendingAsksBySeat built a map the only caller immediately summed, after the seat-scoped read moved to pendingSeatAsks. Co-authored-by: Jake Hoffner --- goals/shift-manager/it-draws-v2s-look/run.mts | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/goals/shift-manager/it-draws-v2s-look/run.mts b/goals/shift-manager/it-draws-v2s-look/run.mts index ac621420f9..d50e01ec53 100644 --- a/goals/shift-manager/it-draws-v2s-look/run.mts +++ b/goals/shift-manager/it-draws-v2s-look/run.mts @@ -714,29 +714,20 @@ async function mailboxKind(api: LabApi, mailbox: string): Promise { return String(kind); } -/** The person's pending asks, in every session they hold. */ -async function pendingAsks(api: LabApi, userId: string): Promise { - return [...(await pendingAsksBySeat(api, userId)).values()].reduce((a, b) => a + b, 0); -} - /** - * The person's pending asks in every session they hold, by the worker (the seat) whose - * session each waits in: the one its state names (`workerId`). The seats' own read, as - * Shift Manager picks their sessions, is `pendingSeatAsks`. + * The person's pending asks in every session they hold. Not `pendingSeatAsks`: + * that one only counts a session on a seat's kind. Dispatch runs included: a seat + * a mailbox post woke asks from one, and the app lists them. */ -async function pendingAsksBySeat(api: LabApi, userId: string): Promise> { - // Dispatch runs included: a seat woken by a mailbox post asks from one, and the app lists them. +async function pendingAsks(api: LabApi, userId: string): Promise { const listing = await api.get(`/sessions?userId=${encodeURIComponent(userId)}&include=dispatch-runs&limit=500`); - const bySeat = new Map(); + let pending = 0; for (const session of (listing.sessions ?? []) as Array>) { - const worker = typeof session.state?.workerId === "string" ? session.state.workerId : null; const found = await api.items(String(session.id), ["suspension", "suspension_resume"]); const resumed = new Set(found.filter((i) => i.type === "suspension_resume").map((i) => String(i.suspensionId))); - const pending = found.filter((i) => i.type === "suspension" && PERSON_REASONS.has(String(i.reason)) && !resumed.has(String(i.suspensionId))).length; - const seat = worker ?? ""; - if (pending > 0) bySeat.set(seat, (bySeat.get(seat) ?? 0) + pending); + pending += found.filter((i) => i.type === "suspension" && PERSON_REASONS.has(String(i.reason)) && !resumed.has(String(i.suspensionId))).length; } - return bySeat; + return pending; } // ---- driving the page --------------------------------------------------------------