Skip to content
Myr

Review fixes for 1213

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- smoke skips the seeded example's two probes (its llms.txt and an ask's .md) with a warning when the platform refuses the example as unknown: deploy runs smoke before a new stage is seeded, so those probes failed every first deploy. Any other answer still runs them. - The fake platform in smoke's tests holds datekit; a new case runs smoke against a stage holding no project and asserts the two paths are never asked, the other probes pass, and each skip is a warning line. - commit.ts imports CommitDiff once, as both the schema and its type.

authored by oscabriel · committed by oscabriel · parent cf4c123 · Browse files · 3 files+156 added−69 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+156 added−69 removed

  • tests:+79 added−36 removed
  • other:+77 added−33 removed

3 files+156 added−69 removed

modified:infra/smoke.ts+74 added-30 removed
23 unmodified lines
24 * 11. `web-agent-skills`: the web's `/.well-known/agent-skills/index.json`25 * answers 200 with JSON.26 *27 * The web's probes run when smoke knows where the web lives: bootstrap's28 * workers.dev record, or `--web-url`. The agent surfaces among them28 * workers.dev record, or `--web-url`. 9 and 10 need the seeded example,29 * which a stage holds only once it is seeded, after its first deploy (and30 * that deploy's smoke): when the platform refuses the example as unknown,31 * each is skipped with a warning line. The agent surfaces among them32 * (`agentProbes`, 8 to 11) are what an agent reads first, so each is timed33 * against `AGENT_BUDGET_MS`: one over it is a warning line, never a failure,34 * since a cold isolate's first answer is slower than the rest.35 *
50 unmodified lines
8687/** An example every seeded stage holds, and one of its asks. */88const SEEDED = { ask: "format-ordinal", project: "datekit" } as const;8990/** The probes that read the seeded example, skipped on a stage that does not hold it. */91export const seededProbes: ReadonlySet<Probe> = new Set([92 "web-project-llms-txt",93 "web-ask-md",94]);9596/** The agent surfaces on the web smoke reads, each by its path and the media type it answers with. */97export const agentProbes = [98 { contentType: "text/markdown", path: "/llms.txt", probe: "web-llms-txt" },99 {
253 unmodified lines
353 Schema.Tuple([Schema.TaggedStruct("Defect", { defect: Schema.Unknown })])354 )355);356357/** An anonymous `/rpc` `listAsks` of `project`, as the platform answers it. */358const listAsks = (origin: string, project: string, label: string) =>359 send(360 label,361 HttpClientRequest.bodyJsonUnsafe(HttpClientRequest.post(`${origin}/rpc`), [362 RpcRequest.make({363 headers: [],364 id: "1",365 payload: { project },366 tag: "listAsks",367 }),368 ])369 );370371/** A read anyone may make, refused for a project that doesn't exist. */372const anonymousUnknownProject = (origin: string) =>373 Effect.gen(function* () {374 const label = "POST /rpc listAsks";375353 const call = RpcRequest.make({354 headers: [],355 id: "1",356 payload: { project: MISSING },357 tag: "listAsks",358 });376 const { text } = yield* listAsks(origin, MISSING, label).pipe(377 Effect.flatMap(statusIs(label, 200))378 );379360 const { text } = yield* send(361 label,362 HttpClientRequest.bodyJsonUnsafe(363 HttpClientRequest.post(`${origin}/rpc`),364 [call]365 )366 ).pipe(Effect.flatMap(statusIs(label, 200)));367380 const [reply] = yield* decodeRefused(text).pipe(381 Effect.mapError(() =>382 Option.isSome(decodeDefect(text))383 ? new Missed({
16 unmodified lines
400 })401 );402 });403404/**405 * Whether the platform at `origin` holds the seeded example: false only406 * when it refuses the example as an unknown project; any other answer407 * leaves the example's probes to say what is wrong.408 */409const holdsSeeded = (origin: string) =>410 listAsks(origin, SEEDED.project, `POST /rpc listAsks ${SEEDED.project}`).pipe(411 Effect.flatMap(({ text }) => Effect.option(decodeRefused(text))),412 Effect.map(413 Option.match({414 onNone: () => true,415 onSome: ([{ exit }]) => exit.cause[0].error.project !== SEEDED.project,416 })417 ),418 Effect.orElseSucceed(() => true)419 );420421/** git's discovery for a repo that doesn't exist. */422const missingRepo = (origin: string) => {423 const route = `/${MISSING}.git/info/refs`;424 const label = `GET ${route}`;
126 unmodified lines
551 );552553 const { web } = options;554555 const seeded = web === undefined ? true : yield* holdsSeeded(origin);556557 const skipped = seeded558 ? []559 : agentProbes.filter(({ probe }) => seededProbes.has(probe));560561 const rest = yield* Effect.forEach(562 [563 ["oauth-metadata", oauthMetadata(origin)],564 ["mcp-needs-credential", mcpNeedsCredential(origin)],
3 unmodified lines
568 ...(web === undefined569 ? []570 : ([571 ["web-front-page", webFrontPage(web)],572 ...agentProbes.flatMap((agent) =>573 skipped.includes(agent)537 ...agentProbes.map(538 (agent) =>539 [540 agent.probe,541 agent.probe === "web-llms-txt"542 ? webLlmsTxt(web, agent)543 : Effect.asVoid(agentSurface(web, agent)),544 ] as const574 ? []575 : [576 [577 agent.probe,578 agent.probe === "web-llms-txt"579 ? webLlmsTxt(web, agent)580 : Effect.asVoid(agentSurface(web, agent)),581 ] as const,582 ]583 ),584 ] as const)),585 ] as const,586 ([probe, run]) => timed(probe, run, settling)
27 unmodified lines
614 return {615 origin,616 probes: timings,617 stage: first.outcome.success,618 warnings: [619 ...skipped.map(620 ({ probe }) =>621 `${probe} was skipped: ${SEEDED.project} is not on this stage (bun run seed puts it there)`622 ),580 warnings: timings.flatMap(({ budgetMs, elapsedMs, probe }) =>581 budgetMs !== undefined && elapsedMs > budgetMs582 ? [583 `${probe} answered in ${elapsedMs} ms, over its ${budgetMs} ms budget`,584 ]585 : []586 ),623 ...timings.flatMap(({ budgetMs, elapsedMs, probe }) =>624 budgetMs !== undefined && elapsedMs > budgetMs625 ? [626 `${probe} answered in ${elapsedMs} ms, over its ${budgetMs} ms budget`,627 ]628 : []629 ),630 ],631 };632 });633634/** Neither `--url` nor bootstrap's record says where the stage lives. */
92 unmodified lines
modified:packages/config/test/smoke.test.ts+79 added-36 removed
47 unmodified lines
48 ])49);5051/**52 * The platform's `/rpc` reply to `body`: the bytes its server sent for an53 * anonymous `listAsks` of a project it doesn't hold (captured from52 * The platform's `/rpc` reply to `body`: for an anonymous `listAsks` of a53 * project in `held`, its open asks (none); of any other, the bytes its54 * server sent for a project it doesn't hold (captured from55 * `apps/platform`'s `serve` before any project existed, the refusal's55 * `next` aside), or a 400 for anything else.56 * `next` aside); a 400 for anything else.57 */57const rpcReply = (body: string): Reply =>58const rpcReply = (body: string, held: readonly string[]): Reply =>59 Option.match(Schema.decodeOption(ListAsksCall)(body), {60 onNone: () => ({ status: 400 }),61 onSome: ([{ id, payload }]) => ({62 body: held.includes(payload.project)63 ? `[{"_tag":"Exit","requestId":${JSON.stringify(id)},"exit":{"_tag":"Success","value":{"asks":[]}}}]`61 body: `[{"_tag":"Exit","requestId":${JSON.stringify(id)},"exit":{"_tag":"Failure","cause":[{"_tag":"Fail","error":{"_tag":"UnknownProject","next":"asks","retryable":false,"project":${JSON.stringify(payload.project)}}}]}}]`,64 : `[{"_tag":"Exit","requestId":${JSON.stringify(id)},"exit":{"_tag":"Failure","cause":[{"_tag":"Fail","error":{"_tag":"UnknownProject","next":"asks","retryable":false,"project":${JSON.stringify(payload.project)}}}]}}]`,65 status: 200,66 }),67 });6866/**67 * The platform as smoke expects to find it: healthy, OAuth's resource68 * metadata published, MCP closed to anyone without a credential, anonymous69 * reads open, no repo it doesn't hold, and a `/` that names MCP and the70 * CLI's installer.71 */72const healthy = ({ authorized, body, method, path }: Seen): Reply => {73 if (method === "GET" && path === "/") {74 return {75 body: "<!doctype html><p><code>http://127.0.0.1/mcp</code></p><pre>curl -fsSL http://127.0.0.1/install.sh | sh</pre>",76 contentType: "text/html; charset=utf-8",77 status: 200,78 };79 }69/** The platform as `healthy` below, holding only the projects `held` names: a stage not seeded holds none. */70const holding =71 (held: readonly string[]) =>72 ({ authorized, body, method, path }: Seen): Reply => {73 if (method === "GET" && path === "/") {74 return {75 body: "<!doctype html><p><code>http://127.0.0.1/mcp</code></p><pre>curl -fsSL http://127.0.0.1/install.sh | sh</pre>",76 contentType: "text/html; charset=utf-8",77 status: 200,78 };79 }8081 if (method === "GET" && path === "/health") {82 return { body: '{"ok":true,"stage":"dev-oscabriel"}', status: 200 };83 }81 if (method === "GET" && path === "/health") {82 return { body: '{"ok":true,"stage":"dev-oscabriel"}', status: 200 };83 }8485 if (method === "GET" && path === "/.well-known/oauth-protected-resource") {86 return {87 body: '{"resource":"https://platform-dev-oscabriel.example.workers.dev","authorization_servers":["https://platform-dev-oscabriel.example.workers.dev"]}',88 status: 200,89 };90 }85 if (method === "GET" && path === "/.well-known/oauth-protected-resource") {86 return {87 body: '{"resource":"https://platform-dev-oscabriel.example.workers.dev","authorization_servers":["https://platform-dev-oscabriel.example.workers.dev"]}',88 status: 200,89 };90 }9192 if (method === "POST" && path === "/mcp") {93 return authorized ? { body: "{}", status: 200 } : { status: 401 };94 }92 if (method === "POST" && path === "/mcp") {93 return authorized ? { body: "{}", status: 200 } : { status: 401 };94 }9596 if (method === "POST" && path === "/rpc" && !authorized) {97 return rpcReply(body);98 }96 if (method === "POST" && path === "/rpc" && !authorized) {97 return rpcReply(body, held);98 }99100 return { status: 404 };101};100 return { status: 404 };101 };102103/**104 * The platform as smoke expects to find it: healthy, OAuth's resource105 * metadata published, MCP closed to anyone without a credential, anonymous106 * reads open, the seeded example `datekit` held and no repo it doesn't107 * hold, and a `/` that names MCP and the CLI's installer.108 */109const healthy = holding(["datekit"]);110111/**112 * A platform whose 401 gate is gone and whose stage is down: `/health` and113 * `/rpc` break, MCP opens to anyone, git's paths answer 200, and `/` is114 * gone.115 */
297 unmodified lines
413 });414 });415416 it.live(417 "skips the seeded example's two probes, with a warning, on a stage that does not hold it",418 () =>419 Effect.gen(function* () {420 // A stage deployed before its examples are seeded: smoke runs after421 // every deploy, the seed only after the first.422 const origin = yield* fakePlatform(holding([]));423 const asked: string[] = [];424425 const web = yield* fakePlatform((seen) => {426 asked.push(seen.path);427428 return healthyWeb(seen);429 });430431 const report = yield* smoke(origin, { web });432433 expect({434 asked,435 probes: report.probes.map(({ probe }) => probe),436 warnings: report.warnings,437 }).toStrictEqual({438 asked: ["/", "/llms.txt", "/.well-known/agent-skills/index.json"],439 probes: probes.filter(440 (probe) =>441 probe !== "web-project-llms-txt" && probe !== "web-ask-md"442 ),443 warnings: [444 "web-project-llms-txt was skipped: datekit is not on this stage (bun run seed puts it there)",445 "web-ask-md was skipped: datekit is not on this stage (bun run seed puts it there)",446 ],447 });448 }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))449 );450451 it.live(452 "warns, and still passes, when an agent surface answers past its budget",453 () =>454 Effect.gen(function* () {455 const origin = yield* fakePlatform(healthy);
268 unmodified lines
modified:packages/project/src/code/commit.ts+3 added-3 removed
22 unmodified lines
23import { RepoHost } from "@repo/artifacts/repo-host";24import type { RepoNotFound, TreeEntry } from "@repo/artifacts/repo-host";25import { treeDiff } from "@repo/git/tree-diff";26import type { Change } from "@repo/git/tree-diff";27import type { ChangedFile, CommitDiff } from "@repo/protocol/domain/code";28import { CommitDiff as CommitDiffSchema } from "@repo/protocol/domain/code";27import { CommitDiff } from "@repo/protocol/domain/code";28import type { ChangedFile } from "@repo/protocol/domain/code";29import { BlobSha, TreeSha } from "@repo/protocol/ids";30import type { CommitSha, RepoName } from "@repo/protocol/ids";31import { UnknownCommit } from "@repo/protocol/refusal";32import { Array, Effect, Option, Order, Schema } from "effect";
193 unmodified lines
226 return { files, truncated };227 });228229/** A diff as the store keeps it: JSON, by the protocol's own schema. */230const Kept = Schema.fromJsonString(CommitDiffSchema);230const Kept = Schema.fromJsonString(CommitDiff);231232const decodeKept = Schema.decodeUnknownOption(Kept);233234const encodeKept = Schema.encodeEffect(Kept);
109 unmodified lines