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

Full suite red: test/stranger-first-ask-journey.test.ts #12675

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/12654-full-suite-red-test-stranger-first-ask-j → main 6 commits fork

  • Merged. scout/12654-full-suite-red-test-stranger-first-ask-j was merged into main as dafc023.

Review

Sign in to review this change.
1 file changed +29 −15
test/stranger-first-ask-journey.test.ts +29 −15
@@ -24,7 +24,7 @@ import { listAgents } from "../src/core/agents.ts";
2424 import { startCrew, type CrewHandle } from "../src/crew/dispatch.ts";
2525 import { useProbe } from "../src/spawn/door.ts";
2626 import { firstBoot } from "../src/spawn/first-boot.ts";
27 import { writeStandInClaude } from "./helpers/crew-standin.ts";
27 import { STAND_IN_TICK_MS, writeStandInClaude } from "./helpers/crew-standin.ts";
2828 import { quietLogs } from "./helpers/globals.ts";
2929
3030 quietLogs();
@@ -125,18 +125,25 @@ const since = (t0: number) => Math.ceil((performance.now() - t0) / 1000);
125125 let ask = "";
126126 let homeHtml = "";
127127
128 test("the walk: link, first screen, one sentence, the crew at work", async () => {
128 const record = async (name: string, res: Response, counted: boolean) => {
129 const html = res.headers.get("content-type")?.includes("html") ? await res.text() : "";
130 screens.push({ name, status: res.status, html, counted });
131 return html;
132 };
133 let t0 = 0;
134 let t1 = 0;
135 let cookie = "";
136 let homeUrl = "";
137
138 // The walk is two tests, each inside the 2 s test budget: the stranger's path
139 // to the ask, then the crew's answer. The second says so when the first failed.
140 test("the walk: link, first screen, one sentence, the crew standing by", async () => {
129141 up = true;
130 const record = async (name: string, res: Response, counted: boolean) => {
131 const html = res.headers.get("content-type")?.includes("html") ? await res.text() : "";
132 screens.push({ name, status: res.status, html, counted });
133 return html;
134 };
135142
136143 // Screen 1: the home page, no cookies; the name goes in the form it carries.
137144 const home = await fetch(`${parentServers.url}/`);
138145 expect(await record("home", home, true)).toContain('id="start-forge"');
139 const t0 = performance.now();
146 t0 = performance.now();
140147 const started = await fetch(`${parentServers.url}/forges/start`, {
141148 method: "POST",
142149 headers: { "content-type": "application/x-www-form-urlencoded" },
@@ -171,7 +178,7 @@ test("the walk: link, first screen, one sentence, the crew at work", async () =>
171178 redirect: "manual",
172179 });
173180 expect(claimed.status).toBe(303);
174 const cookie = (claimed.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
181 cookie = (claimed.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
175182 expect(cookie).not.toBe("");
176183
177184 // Screen 3: the forge's first screen. One sentence through its own form.
@@ -179,7 +186,7 @@ test("the walk: link, first screen, one sentence, the crew at work", async () =>
179186 const landing = await fetch(landed, { headers: { cookie } });
180187 expect(landing.status).toBe(200);
181188 const first = await record("forge", landing, true);
182 const t1 = performance.now();
189 t1 = performance.now();
183190 const formTag = /<form[^>]*action="\/tell"[^>]*>([\s\S]*?)<\/form>/.exec(first);
184191 expect(formTag).not.toBeNull();
185192 const fields = new URLSearchParams();
@@ -204,15 +211,16 @@ test("the walk: link, first screen, one sentence, the crew at work", async () =>
204211 // row on the forge's home, polled until it shows and timed from the post.
205212 // The row's "Waiting for the crew." is the forge's echo of the ask, drawn by
206213 // the same request that stores it, so it is not counted.
207 const homeUrl = `${childServers.url}${posted.headers.get("location") ?? "/"}`;
214 homeUrl = `${childServers.url}${posted.headers.get("location") ?? "/"}`;
208215 // The page the post lands on, before any crew run: the forge's echo of the
209216 // ask, checked like every screen.
210217 const echoed = await fetch(homeUrl, { headers: { cookie } });
211218 const echoHtml = await record("forge after the ask", echoed, false);
212219 expect(echoHtml).toContain("Waiting for the crew.");
213220 expect(crewRow(echoHtml)).toBe(false);
214 // Then the child's crew, as `main.ts` starts it, with the stand-in for
215 // Claude Code: started after the post, so its timing only grows stricter.
221 // The child's crew, as `main.ts` starts it, with the stand-in for Claude Code,
222 // started after the echo is checked (it would answer the echo away) and
223 // inside the first test, so its start is not spent in the answer's own test.
216224 crew = await startCrew(child, {
217225 forgeUrl: childServers.url,
218226 localUrl: childServers.url,
@@ -221,13 +229,19 @@ test("the walk: link, first screen, one sentence, the crew at work", async () =>
221229 budgetUsd: 1,
222230 runTimeoutMs: 60_000,
223231 networkRetryScale: 0,
224 tickMs: 200,
232 tickMs: STAND_IN_TICK_MS,
225233 });
234 });
235
236 test("the walk: the crew answers", async () => {
237 if (child === undefined || homeUrl === "") {
238 throw new Error("the walk above did not reach the ask; fix that failure first");
239 }
226240 const deadline = performance.now() + FIRST_FIVE_MINUTES.firstCrewActivitySeconds * 1000;
227241 let back = await fetch(homeUrl, { headers: { cookie } });
228242 homeHtml = await back.text();
229243 while (!crewRow(homeHtml) && performance.now() < deadline) {
230 await Bun.sleep(100);
244 await Bun.sleep(25); // real-timer: polls a real crew run in a child process
231245 back = await fetch(homeUrl, { headers: { cookie } });
232246 homeHtml = await back.text();
233247 }

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs