Skip to content
Myr

Declare every W3 binding on the platform and sandbox Workers, decode the whole env once, and give group A its shared seams and final-named stubs

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

- Dependencies (spec §7.2, exact, all older than a day so bunfig.toml is unchanged): apps/platform gains @effect/sql-sqlite-do and @effect/sql-d1 4.0.1, @cloudflare/workers-oauth-provider 1.2.1, the six workspace packages, and dev @varlock/cloudflare-integration 1.6.0 (varlock-wrangler only; nothing imports it), @repo/testkit, @effect/sql-sqlite-node and @effect/platform-node 4.0.1. New apps/sandbox (@repo/sandbox) with @cloudflare/sandbox 1.0.0 and wrangler 4.147.0. packages/project gains @effect/sql-d1 and exports ./front-page, ./front-page/memory, ./lander/wire and ./projection-d1/* (a folder glob, not the issue's ./projection-d1: 309 builds packages/project/src/projection-d1/). - apps/platform/wrangler.jsonc: PROJECT (Project, sqlite migration v1), ANSWER and ON_PUSH Workflows, ARTIFACTS on projects-<s>, FRONT_PAGE D1, OAUTH_KV, EVIDENCE R2, LOADER, SANDBOX service, CLAIM_LIMIT and PROPOSAL_LIMIT (namespace ids 1001/1002, 1101/1102, 1201/1202), triggers.events cf.artifacts.repo.pushed -> on-push-<s>, vars OPERATOR_HANDLE, STAGE, LANDER_ADAPTER, nodejs_compat; top level is stage local (never deployed) and each env block (dev-oscabriel, demo) repeats every binding. D1 and KV ids are zero placeholders for 308's bootstrap. No ARTIFACTS_PRIVATE, MASTER_KEY or layers namespace (W6). - apps/sandbox/wrangler.jsonc: Checker and Lander Durable Objects (sqlite v1) with DO-managed containers (images check and land) per stage. Wrangler 4.147.0 refuses instance_type and max_instances on a DO-managed container, so the instance size moves to ctx.container.start. Both worker-configuration.d.ts files come from each package's types script; no `as` on env anywhere. - @cloudflare/sandbox 1.0 (read from its README and types) has no Sandbox class: the DO runs its container through ctx.container and the package adds Files, S3Mount and DirectoryBackup. So Checker and Lander extend DurableObject, src/box.ts is the Box port (exec, writeFile, destroy) and src/box/sdk.ts adapts it over the Container API and Files. Images copy sandbox-shim from docker.io/cloudflare/sandbox:1.0.0 and bun from oven/bun:1.4.2-slim (check: node:24-trixie-slim + git + corepack; land: debian:trixie-slim + git, built from the repo root through an allowlist land.Dockerfile.dockerignore so no env file reaches it). - platform.ts: PlatformEnv decodes every binding (presence-checked declares typed by Env["KEY"]), the vars (STAGE local|demo|dev-<user>, LANDER_ADAPTER defaulting to container) and the secrets, redacted: OPERATOR_TOKEN required; SESSION_TOKENS, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET and COOKIE_KEY optional, the last three all or none. InvalidEnv names top-level keys only, sorted, never a value or a session token. A Schema.Record with a refined key silently drops failing keys in v4, so the session table is checked whole. platform(env) is Vacant + MemorySessions(operator and SESSION_TOKENS) + workerPorts + Stage. - ports.ts: workerPorts(config) is every port 317 wires except RateLimits (312's), each unwired: building touches nothing, a call dies with NotWired{port}. EvidenceStore is already the memory store, since 304 writes lane logs through it. - surfaces.ts: GET /health answers {ok, stage}; git's smart-HTTP paths go to git.ts's serveGit (None until 303, so 404); both skip the 401 gate. Route handlers capture their services in HttpRouter.use, since a route's own requirements are per-request and Layer.provide cannot meet them. Services grows by GitServices and Stage; test/harness.ts fills in unwired Projects/Upstream and stage local for tests that leave them out. - Shared seams: workflows/step.ts (StepRunner, workflowSteps over a structural WorkflowSteps that a real WorkflowStep satisfies, memoSteps); answer-runs.ts (AnswerParams); repo-names.ts (RepoKind, repoKind, claimForkName = W2's forkName, workingForkName); credential.ts (credentialOf: Bearer, or the Basic password git sends); the FrontPage read port and its memory adapter; the EvidenceStore port (LogRef <project>/<requestId>/<lane>#<attempt>) and its memory adapter; @repo/checks/check-runner/wire (Remote, CheckWire, CheckExit) and @repo/project/lander/wire (job, result and wire schemas for merge, land, compose and bundleRules, each job schema `satisfies` W2 212's port type; outcomes are Schema.toCodecJson(Schema.Exit(...)) so they cross Workers RPC as JSON). - Stubs with final names: Project (DurableObject), Answer and OnPush (WorkflowEntrypoint; no run yet, since class-methods-use-this refuses a run that ignores `this` and wrangler types reads the params from run's first parameter), the sandbox entrypoint (check, merge, land, compose, bundleRules) delegating to runCheck/runMerge/runLand/runCompose/ runBundleRules, each VerifierBlocked with a `not built` log annotation through apps/sandbox/src/job.ts's answerJob and notBuilt. - Root: tsconfig.base.json overrides give apps/platform effect/sql, apps/sandbox/test effect/process, and packages/config/test and infra effect/http with effect/process (pre-approved); tsconfig.json includes infra/**/*.ts; package.json gains bootstrap, deploy and smoke scripts for 308's files; bytes:check measures apps/sandbox too. - Imports matrix (departure from spec §4.1, as the W3 index records): apps/sandbox may import @repo/project/lander/wire and @repo/rules/rules-evaluator only, so the sandbox decodes the Lander's jobs with the same schemas the platform encodes them with. - Debt 4 -> 5 (pre-approved for this build, spec §7.1): one oxlint-disable typescript/no-unsafe-argument in packages/testkit/src/untouchable.ts, the fake binding both apps' tests share. A Proxy whose every read throws has no members to type, so its target is Object.create(null); the alternative was a lying type guard or hand-written fakes of eleven binding types. - Tests added, red by assertion first where they cover new behaviour: platform.test.ts (missing ARTIFACTS -> InvalidEnv{keys:["ARTIFACTS"]}; two missing keys named at once; GitHub's id without its secret -> InvalidEnv{keys:["GITHUB_CLIENT_SECRET"]} with no value in its JSON; an unreadable session table named without its token; a session-table token calls as its person; LANDER_ADAPTER's default; GET /health -> 200 {ok:true, stage:"local"} with no credential; a git path -> 404, not 401), credential.test.ts, repo-names.test.ts (16 names: reserved ask ids, stray --, uppercase handles), step.test.ts (encode on the way out, replay without rerunning, retries handed to the engine, a typed failure surfacing, memoSteps), apps/sandbox smoke.test.ts (every entrypoint method answers a typed VerifierBlocked, not a defect) and box-sdk.test.ts (exec and start over a fake container), evidence-store-memory.test.ts, front-page-memory.test.ts, untouchable.test.ts. - Human step H5, for the user: set OPERATOR_TOKEN (required) and, optionally, SESSION_TOKENS, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET and COOKIE_KEY with NAME=varlock(prompt) in apps/platform/.env.local, then ./node_modules/.bin/varlock load --path apps/platform/ in their own terminal. For dev-oscabriel only, spec §8.3 O1 lets an agent generate them (GitHub's two stay the user's, H4). H6 is confirmed read-only: Workers Paid is on the account (spec §8.3 O2). - ASSUMPTION: Workers Paid includes Containers for this account (the subscription list shows workers_paid; no container has been deployed yet, 311 is the first). ASSUMPTION: BuildKit honours land.Dockerfile.dockerignore beside land.Dockerfile; the stub copies nothing from the context yet, so 306 confirms it when it copies the sdk. - bytes: platform entry 804 KB of 900 KB (770 KB before), sandbox 359 KB. verify green.

authored by oscabriel · committed by oscabriel · parent ec1d6f9 · Browse files · 60 files+3088 added−50 removed
This commit

State

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

Diff stats

60 files+3088 added−50 removed

  • tests:+1000 added−14 removed
  • other:+2088 added−36 removed

60 files+3088 added−50 removed

added:apps/platform/src/workflows/answer.ts+14 added
added:apps/platform/src/workflows/on-push.ts+38 added
added:apps/platform/src/workflows/step.ts+147 added
1/**2 * The seam between Effect programs and a Workflow's durable steps, shared by3 * the Answer (W3 304) and OnPush (313) Workflows. A program names each step4 * and gives the schema of its value; over a Workflow, the engine records the5 * value encoded as JSON and a replay decodes the record instead of running6 * the step again (principle 8).7 */8import { Context, Effect, Layer, Option, Ref, Schema } from "effect";910/** How the engine retries a step that failed: as `WorkflowStepConfig` spells it. */11export interface WorkflowStepRetries {12 readonly limit: number;13 readonly delay: number;14 readonly backoff: "constant" | "linear" | "exponential";15}1617/**18 * The part of a Workflow's `WorkflowStep` this seam uses: `do`, with a19 * config, recording what its body returns. A `WorkflowStep` is one.20 */21export interface WorkflowSteps {22 readonly do: (23 name: string,24 config: { readonly retries?: WorkflowStepRetries },25 body: () => Promise<Schema.Json>26 ) => Promise<Schema.Json>;27}2829/** How often, and how far apart, a failed step runs again before the run fails. */30export interface StepRetry {31 readonly limit: number;32 readonly delayMs: number;33 readonly backoff: "constant" | "linear" | "exponential";34}3536export class StepRunner extends Context.Service<37 StepRunner,38 {39 /**40 * Runs `effect` once per (instance, name); a replay returns the recorded41 * value, decoded with `schema`. A failure is retried per `retry` (the42 * engine's default without one), records nothing, and, once the retries43 * are spent, fails the step with the last failure.44 */45 readonly step: <A, I, E, R>(46 name: string,47 schema: Schema.Codec<A, I>,48 effect: Effect.Effect<A, E, R>,49 retry?: StepRetry50 ) => Effect.Effect<A, E, R>;51 }52>()("platform/StepRunner") {}5354/** The engine's spelling of a step's retries. */55const configOf = (retry: StepRetry | undefined) =>56 retry === undefined57 ? {}58 : {59 retries: {60 backoff: retry.backoff,61 delay: retry.delayMs,62 limit: retry.limit,63 },64 };6566/** One step over a Workflow's own steps. */67const durableStep =68 (steps: WorkflowSteps) =>69 <A, I, E, R>(70 name: string,71 schema: Schema.Codec<A, I>,72 effect: Effect.Effect<A, E, R>,73 retry?: StepRetry74 ): Effect.Effect<A, E, R> =>75 Effect.gen(function* () {76 const json = Schema.toCodecJson(schema);77 const context = yield* Effect.context<R>();78 const failed = yield* Ref.make(Option.none<E>());7980 const run = effect.pipe(81 Effect.tapError((failure) => Ref.set(failed, Option.some(failure))),82 Effect.flatMap((value) =>83 Effect.orDie(Schema.encodeEffect(json)(value))84 )85 );8687 const recorded = yield* Effect.tryPromise(() =>88 steps.do(name, configOf(retry), () =>89 Effect.runPromiseWith(context)(run)90 )91 ).pipe(92 // The engine gave up: the step's own last failure, if it had one.93 Effect.catch((error) =>94 Effect.flatMap(Ref.get(failed), (last) =>95 Option.match(last, {96 onNone: () => Effect.die(error),97 onSome: (failure) => Effect.fail(failure),98 })99 )100 )101 );102103 return yield* Effect.orDie(Schema.decodeEffect(json)(recorded));104 });105106/**107 * Steps over a Workflow's own: the value goes out encoded as JSON, and comes108 * back decoded, whether the step ran now or is a replay.109 */110export const workflowSteps = (steps: WorkflowSteps): Layer.Layer<StepRunner> =>111 Layer.succeed(StepRunner, StepRunner.of({ step: durableStep(steps) }));112113/** One step over an in-memory record of steps, keyed by name. */114const memoStep =115 (records: Ref.Ref<ReadonlyMap<string, Schema.Json>>) =>116 <A, I, E, R>(117 name: string,118 schema: Schema.Codec<A, I>,119 effect: Effect.Effect<A, E, R>,120 retry?: StepRetry121 ): Effect.Effect<A, E, R> =>122 Effect.gen(function* () {123 const json = Schema.toCodecJson(schema);124 const kept = (yield* Ref.get(records)).get(name);125126 if (kept !== undefined) {127 return yield* Effect.orDie(Schema.decodeEffect(json)(kept));128 }129130 const value = yield* Effect.retry(effect, { times: retry?.limit ?? 0 });131 const encoded = yield* Effect.orDie(Schema.encodeEffect(json)(value));132133 yield* Ref.update(records, (all) => new Map(all).set(name, encoded));134135 return yield* Effect.orDie(Schema.decodeEffect(json)(encoded));136 });137138/**139 * Steps in memory, for tests: the layer keeps one record per step name for140 * as long as the returned layer lives, so running a program twice over it141 * replays the second time. A failed step records nothing and is retried up142 * to its limit, without waiting.143 */144export const memoSteps = (): Effect.Effect<Layer.Layer<StepRunner>> =>145 Effect.map(Ref.make<ReadonlyMap<string, Schema.Json>>(new Map()), (records) =>146 Layer.succeed(StepRunner, StepRunner.of({ step: memoStep(records) }))147 );
added:apps/platform/src/answer-runs.ts+16 added
added:apps/platform/src/credential.ts+32 added
added:apps/platform/src/git.ts+23 added
modified:apps/platform/src/platform.ts+147 added-18 removed
added:apps/platform/src/ports.ts+131 added
1/**2 * The ports the Worker, the Project Durable Object and the Workflows run3 * on, built from the decoded env. Until W3 317 composes the real adapters4 * (the Artifacts binding, the sandbox, D1, the Loader, the Project DO), each5 * port is a stub whose every call dies with `NotWired`: a call made too soon6 * is a visible defect, never a silent success. `EvidenceStore` is already7 * real: the memory store, until W4 418 adds R2.8 *9 * `Alarms` and `AnswerRuns` are bound per project inside its Durable Object10 * (302); `RateLimits` joins when 312 makes its port.11 */12import { Fetch } from "@repo/artifacts/fetch";13import { RepoHost } from "@repo/artifacts/repo-host";14import { CheckRunner } from "@repo/checks/check-runner";15import type { EvidenceStore } from "@repo/checks/evidence-store";16import { EvidenceStoreMemory } from "@repo/checks/evidence-store/memory";17import { Upstream } from "@repo/git/upstream";18import { FrontPage } from "@repo/project/front-page";19import { Lander } from "@repo/project/lander";20import { Projection } from "@repo/project/projection";21import { Projects } from "@repo/project/projects";22import { RulesEvaluator } from "@repo/rules/rules-evaluator";23import { Data, Effect, Layer } from "effect";2425import type { PlatformConfig } from "./platform.ts";2627/** A port was called before W3 317 wired its adapter. */28export class NotWired extends Data.TaggedError("NotWired")<{29 readonly port: string;30}> {}3132/** A method of `port` that dies with `NotWired`, whatever it is asked. */33const notWired = (port: string) => () => Effect.die(new NotWired({ port }));3435/** Every port, unwired: building them touches nothing; calling one dies. */36export const Unwired = {37 CheckRunner: Layer.succeed(38 CheckRunner,39 CheckRunner.of({ run: notWired("CheckRunner") })40 ),41 Fetch: Layer.succeed(Fetch, Fetch.of({ fetch: notWired("Fetch") })),42 FrontPage: Layer.succeed(43 FrontPage,44 FrontPage.of({45 credits: notWired("FrontPage"),46 entries: notWired("FrontPage"),47 projects: notWired("FrontPage"),48 })49 ),50 Lander: Layer.succeed(51 Lander,52 Lander.of({53 bundleRules: notWired("Lander"),54 compose: notWired("Lander"),55 land: notWired("Lander"),56 merge: notWired("Lander"),57 })58 ),59 Projection: Layer.succeed(60 Projection,61 Projection.of({ apply: notWired("Projection") })62 ),63 Projects: Layer.succeed(64 Projects,65 Projects.of({ create: notWired("Projects"), get: notWired("Projects") })66 ),67 RepoHost: Layer.succeed(68 RepoHost,69 RepoHost.of({70 create: notWired("RepoHost"),71 fork: notWired("RepoHost"),72 importFrom: notWired("RepoHost"),73 log: notWired("RepoHost"),74 mintToken: notWired("RepoHost"),75 push: notWired("RepoHost"),76 readBlob: notWired("RepoHost"),77 readCommit: notWired("RepoHost"),78 readFile: notWired("RepoHost"),79 readTree: notWired("RepoHost"),80 refs: notWired("RepoHost"),81 remote: notWired("RepoHost"),82 remove: notWired("RepoHost"),83 revokeToken: notWired("RepoHost"),84 })85 ),86 RulesEvaluator: Layer.succeed(87 RulesEvaluator,88 RulesEvaluator.of({89 call: notWired("RulesEvaluator"),90 evaluate: notWired("RulesEvaluator"),91 })92 ),93 Upstream: Layer.succeed(94 Upstream,95 Upstream.of({ exchange: notWired("Upstream") })96 ),97};9899/** What the Worker's code runs on, besides sessions and the contracts' handlers. */100export type WorkerPorts =101 | CheckRunner102 | EvidenceStore103 | Fetch104 | FrontPage105 | Lander106 | Projection107 | Projects108 | RepoHost109 | RulesEvaluator110 | Upstream;111112/**113 * The ports for one stage's env. Today every one but `EvidenceStore` is114 * unwired; 317 builds each from `config` (its bindings and115 * `LANDER_ADAPTER`).116 */117export const workerPorts = (118 _config: PlatformConfig119): Layer.Layer<WorkerPorts> =>120 Layer.mergeAll(121 Unwired.CheckRunner,122 EvidenceStoreMemory,123 Unwired.Fetch,124 Unwired.FrontPage,125 Unwired.Lander,126 Unwired.Projection,127 Unwired.Projects,128 Unwired.RepoHost,129 Unwired.RulesEvaluator,130 Unwired.Upstream131 );
added:apps/platform/src/project-do.ts+9 added
added:apps/platform/src/repo-names.ts+86 added
1/**2 * What a repo's name says it is (spec §4.5): a project's canonical repo3 * `<project>`, a claim's fork `<project>--<ask>--<handle>`, or a person's4 * working fork `<project>--me--<handle>`, each handle in lowercase. `--`5 * occurs in no project or ask name, so a name splits back into its parts.6 * Pure: the gateway (303), the handlers (312) and OnPush (313) read names7 * with it.8 */9import { forkName } from "@repo/project/claim";10import { AskId, Handle, ProjectName, RepoName } from "@repo/protocol/ids";11import { Data, Option, Schema } from "effect";1213/** What a repo is, read from its name alone. */14export type RepoKind =15 | { readonly _tag: "Canonical"; readonly project: ProjectName }16 | {17 readonly _tag: "ClaimFork";18 readonly project: ProjectName;19 readonly ask: AskId;20 /** As the name spells it: in lowercase. */21 readonly handle: Handle;22 }23 | {24 readonly _tag: "WorkingFork";25 readonly project: ProjectName;26 /** As the name spells it: in lowercase. */27 readonly handle: Handle;28 }29 | { readonly _tag: "Unknown" };3031export const RepoKind = Data.taggedEnum<RepoKind>();3233const asProject = Schema.decodeOption(ProjectName);3435const asAsk = Schema.decodeOption(AskId);3637const asHandle = Schema.decodeOption(Handle);3839/** The word that names a working fork where a claim's fork names its ask. */40const WORKING = "me";4142/** What `name` says it is; `Unknown` for any name the platform never makes. */43export const repoKind = (name: RepoName): RepoKind => {44 const [first = "", second, third, ...rest] = name.split("--");4546 const kind = Option.flatMap(47 asProject(first),48 (project): Option.Option<RepoKind> => {49 if (second === undefined) {50 return Option.some(RepoKind.Canonical({ project }));51 }5253 if (third === undefined || rest.length > 0) {54 return Option.none();55 }5657 const handle = Option.filter(58 asHandle(third),59 (spelled) => spelled === spelled.toLowerCase()60 );6162 return second === WORKING63 ? Option.map(handle, (owner) =>64 RepoKind.WorkingFork({ handle: owner, project })65 )66 : Option.map(67 Option.all({ ask: asAsk(second), handle }),68 ({ ask, handle: claimant }) =>69 RepoKind.ClaimFork({ ask, handle: claimant, project })70 );71 }72 );7374 return Option.getOrElse(kind, () => RepoKind.Unknown());75};7677/** A claim's fork: `<project>--<ask>--<handle in lowercase>`. */78export const claimForkName: (79 project: ProjectName,80 ask: AskId,81 handle: Handle82) => RepoName = forkName;8384/** A person's working fork: `<project>--me--<handle in lowercase>`. */85export const workingForkName = (project: ProjectName, handle: Handle) =>86 RepoName.make(`${project}--${WORKING}--${handle.toLowerCase()}`);
modified:apps/platform/src/surfaces.ts+91 added-6 removed
1import { Brand } from "@repo/brand";2import { Upstream } from "@repo/git/upstream";3import { Projects } from "@repo/project/projects";4import { authenticated, bearerToken } from "@repo/protocol/authenticate";5import { Client, Contracts, surfaced } from "@repo/protocol/contracts";6import { toToolkit } from "@repo/protocol/mcp";7import { Authenticated } from "@repo/protocol/principal";6import { Effect, Layer, Option } from "effect";8import { Context, Effect, Layer, Option } from "effect";9import { McpProtocol, McpServer } from "effect/ai";10import {11 Headers,12 HttpRouter,
7 unmodified lines
20 RpcServer,21 RpcTest,22} from "effect/rpc";2324import { serveGit } from "./git.ts";25import type { GitServices } from "./git.ts";26import { Sessions } from "./sessions.ts";2724/** What the surfaces need from the platform: the contracts' handlers and sessions. */28/** Which stage this Worker serves: `/health` says so. */29export class Stage extends Context.Service<Stage, { readonly name: string }>()(30 "platform/Stage"31) {}3233/**34 * What the surfaces need from the platform: the contracts' handlers,35 * sessions, what git's paths need, and the stage.36 */37export type Services =38 | Rpc.ToHandler<RpcGroup.Rpcs<typeof Contracts>>27 | Sessions;39 | Sessions40 | GitServices41 | Stage;4243/** git's smart-HTTP paths: `/<repo>(.git)/info/refs` and the two services. */44const GIT_PATH =45 /^\/[A-Za-z0-9._-]+\/(?:info\/refs|git-upload-pack|git-receive-pack)$/u;4647/**48 * Paths no credential is asked for: `/health`, and git's, whose gateway49 * decides who may read and push.50 */51const isExempt = (url: string) => {52 const [path = url] = url.split("?");5354 return path === "/health" || GIT_PATH.test(path);55};5657/** The person an `Authorization` header names, if any. */58const principalOf = (sessions: Sessions["Service"], authorization?: string) =>59 Option.match(bearerToken(authorization), {60 onNone: () => Effect.succeedNone,61 onSome: (token) => sessions.verify(token),62 });6364/**37 * Every request needs a credential the platform knows; anything else gets a38 * 401 that asks for a bearer token, before any surface sees it.65 * Every request but `/health` and git's needs a credential the platform66 * knows; anything else gets a 401 that asks for a bearer token, before any67 * surface sees it.68 */69const requireCredential = HttpRouter.middleware(70 Effect.gen(function* () {71 const sessions = yield* Sessions;
1 unmodified line
73 return (httpEffect) =>74 Effect.gen(function* () {75 const request = yield* HttpServerRequest.HttpServerRequest;7677 if (isExempt(request.url)) {78 return yield* httpEffect;79 }8081 const principal = yield* principalOf(82 sessions,83 request.headers.authorization84 );
75 unmodified lines
160 path: "/rpc",161 protocol: "http",162}).pipe(Layer.provide([verifyCredential, RpcSerialization.layerJson]));163164/** `/health`: the Worker is up, and which stage it serves. */165const health = HttpRouter.use((router) =>166 Effect.gen(function* () {167 const { name } = yield* Stage;168169 yield* router.add(170 "GET",171 "/health",172 HttpServerResponse.jsonUnsafe({ ok: true, stage: name })173 );174 })175);176177/** A git request, as the gateway answers it; 404 for a path it does not serve. */178const toGateway = (request: HttpServerRequest.HttpServerRequest) =>179 HttpServerRequest.toWeb(request).pipe(180 Effect.flatMap((web) =>181 Option.match(serveGit(web), {182 onNone: () => Effect.succeed(HttpServerResponse.empty({ status: 404 })),183 onSome: Effect.map(HttpServerResponse.fromWeb),184 })185 ),186 Effect.orElseSucceed(() => HttpServerResponse.empty({ status: 400 }))187 );188189const GIT_ROUTES = [190 "/:repo/info/refs",191 "/:repo/git-upload-pack",192 "/:repo/git-receive-pack",193] as const;194195/**196 * git's smart-HTTP paths, each handed to the gateway with the services it197 * needs, taken once when the router is built.198 */199const git = HttpRouter.use((router) =>200 Effect.gen(function* () {201 const services = Context.make(Sessions, yield* Sessions).pipe(202 Context.add(Projects, yield* Projects),203 Context.add(Upstream, yield* Upstream)204 );205206 for (const path of GIT_ROUTES) {207 yield* router.add("*", path, (request) =>208 Effect.provide(toGateway(request), services)209 );210 }211 })212);213214/** The platform's fetch handler over `services`. */215export const serve = <E>(services: Layer.Layer<Services, E>) =>216 HttpRouter.toWebHandler(134 Layer.mergeAll(mcp, rpc, requireCredential).pipe(Layer.provide(services)),217 Layer.mergeAll(health, git, mcp, rpc, requireCredential).pipe(218 Layer.provide(services)219 ),220 { disableLogger: true }221 );
modified:apps/platform/src/worker.ts+6 added
1 unmodified line
23import { platform } from "./platform.ts";4import { serve } from "./surfaces.ts";56export { Project } from "./project-do.ts";78export { Answer } from "./workflows/answer.ts";910export { OnPush } from "./workflows/on-push.ts";1112// Built once per isolate, at module load: the env is decoded here and nowhere13// else.14const { handler } = serve(platform(env));15
3 unmodified lines
added:apps/platform/test/credential.test.ts+55 added
1import { describe, expect, it } from "@effect/vitest";2import { Option } from "effect";34import { credentialOf } from "../src/credential.ts";56const token = "alice-token-0123456789abcdef01234567";78const authorized = (authorization: string) => new Headers({ authorization });910/** What git sends for `https://<user>:<password>@host/…`: base64 of `user:password`. */11const basic = (user: string, password: string) =>12 `Basic ${btoa(`${user}:${password}`)}`;1314describe("the credential a request carries", () => {15 it("is a bearer token", () => {16 expect(credentialOf(authorized(`Bearer ${token}`))).toStrictEqual(17 Option.some(token)18 );19 });2021 it("is git's basic-auth password, whatever the user name", () => {22 expect(credentialOf(authorized(basic("alice", token)))).toStrictEqual(23 Option.some(token)24 );25 expect(26 credentialOf(authorized(basic("x-access-token", token)))27 ).toStrictEqual(Option.some(token));28 });2930 it("keeps a colon inside the password", () => {31 expect(credentialOf(authorized(basic("alice", "a:b")))).toStrictEqual(32 Option.some("a:b")33 );34 });3536 it("is none when the header is absent", () => {37 expect(credentialOf(new Headers())).toStrictEqual(Option.none());38 });3940 it("is none when the header is malformed", () => {41 expect(credentialOf(authorized("Bearer"))).toStrictEqual(Option.none());42 expect(credentialOf(authorized("Basic not*base64"))).toStrictEqual(43 Option.none()44 );45 expect(credentialOf(authorized(`Basic ${btoa("no-colon")}`))).toStrictEqual(46 Option.none()47 );48 expect(credentialOf(authorized(basic("alice", "")))).toStrictEqual(49 Option.none()50 );51 expect(credentialOf(authorized(`Token ${token}`))).toStrictEqual(52 Option.none()53 );54 });55});
added:apps/platform/test/fake-env.ts+37 added
1import { untouchable } from "@repo/testkit/untouchable";23/** The operator's token in every fake env: long enough to decode. */4export const operatorToken = "operator-token-0123456789abcdef0123";56/**7 * The platform Worker's env at stage `local`, as `wrangler.jsonc` declares8 * it: every var and the required secret set, every binding a fake that9 * throws if touched, so a test proves what building the platform touches.10 * The optional secrets are absent.11 */12export const fakeEnv = (): Env => ({13 ANSWER: untouchable("ANSWER"),14 ARTIFACTS: untouchable("ARTIFACTS"),15 CLAIM_LIMIT: untouchable("CLAIM_LIMIT"),16 EVIDENCE: untouchable("EVIDENCE"),17 FRONT_PAGE: untouchable("FRONT_PAGE"),18 LANDER_ADAPTER: "container",19 LOADER: untouchable("LOADER"),20 OAUTH_KV: untouchable("OAUTH_KV"),21 ON_PUSH: untouchable("ON_PUSH"),22 OPERATOR_HANDLE: "oscabriel",23 OPERATOR_TOKEN: operatorToken,24 PROJECT: untouchable("PROJECT"),25 PROPOSAL_LIMIT: untouchable("PROPOSAL_LIMIT"),26 SANDBOX: untouchable("SANDBOX"),27 STAGE: "local",28});2930/** `env` without `key`, as a Worker missing that binding, var or secret sees it. */31export const without = (env: Env, key: keyof Env): Env => {32 const rest = { ...env };3334 Reflect.deleteProperty(rest, key);3536 return rest;37};
modified:apps/platform/test/harness.ts+16 added-3 removed
1import type { Upstream } from "@repo/git/upstream";2import type { Projects } from "@repo/project/projects";3import { Contracts } from "@repo/protocol/contracts";4import { Effect, Layer, Schema } from "effect";5import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";6import { RpcClient, RpcSerialization } from "effect/rpc";78import { Unwired } from "../src/ports.ts";6import { serve } from "../src/surfaces.ts";9import { serve, Stage } from "../src/surfaces.ts";10import type { Services } from "../src/surfaces.ts";1112const origin = "http://localhost";13
104 unmodified lines
118 }))119 );120121/**122 * What a surfaces test may leave out: git's ports, unwired (no test here123 * pushes), and the stage, `local`.124 */125const defaults = Layer.mergeAll(126 Unwired.Projects,127 Unwired.Upstream,128 Layer.succeed(Stage, Stage.of({ name: "local" }))129);130131/**132 * The platform's fetch handler over `services`, disposed with the scope: as133 * an Effect, and as the plain function a fetch client calls.134 */135export const served = Effect.fnUntraced(function* <E>(123 services: Layer.Layer<Services, E>136 services: Layer.Layer<Exclude<Services, Projects | Upstream | Stage>, E>137) {125 const { dispose, handler } = serve(services);138 const { dispose, handler } = serve(Layer.merge(defaults, services));139140 yield* Effect.addFinalizer(() => Effect.promise(dispose));141142 return {
31 unmodified lines
modified:apps/platform/test/platform.test.ts+136 added-11 removed
1import { describe, expect, it } from "@effect/vitest";2import { ProjectName } from "@repo/protocol/ids";3import { Effect, Layer } from "effect";45import { InvalidEnv, platform } from "../src/platform.ts";5import { decodeEnv, InvalidEnv, platform } from "../src/platform.ts";6import { fakeEnv, operatorToken, without } from "./fake-env.ts";7import { rpcClient, served, toolCall } from "./harness.ts";88const token = "operator-token-0123456789abcdef0123";9const project = ProjectName.make("datekit");1010const env: Env = { OPERATOR_HANDLE: "oscabriel", OPERATOR_TOKEN: token };11const cookieKey = "cookie-key-0123456789abcdef0123456789";1212const project = ProjectName.make("datekit");13const clientId = "github-client-id-0123";1415/** What building the platform from `env` failed with. */16const failureOf = (env: Env) => Effect.flip(Layer.build(platform(env)));1718describe("the platform Worker's env", () => {19 it.effect("lets the operator's token call the contracts", () =>20 Effect.gen(function* () {17 const { handler } = yield* served(platform(env));21 const { handler } = yield* served(platform(fakeEnv()));2219 const operator = yield* rpcClient(handler, token);23 const operator = yield* rpcClient(handler, operatorToken);2425 expect(yield* operator.listProjects({})).toStrictEqual({26 projects: [],27 });
1 unmodified line
29 );3031 it.effect("turns away any other token", () =>32 Effect.gen(function* () {29 const { fetch } = yield* served(platform(env));33 const { fetch } = yield* served(platform(fakeEnv()));3435 const response = yield* fetch(32 toolCall("listAsks", { project }, `${token}-not`)36 toolCall("listAsks", { project }, `${operatorToken}-not`)37 );3839 expect(response.status).toBe(401);40 })41 );4243 it.effect("fails to start without a usable operator token", () =>44 Effect.gen(function* () {41 const failure = yield* Effect.flip(42 Layer.build(platform({ ...env, OPERATOR_TOKEN: "short" }))43 );45 const failure = yield* failureOf({46 ...fakeEnv(),47 OPERATOR_TOKEN: "short",48 });4950 expect(failure).toStrictEqual(51 new InvalidEnv({ keys: ["OPERATOR_TOKEN"] })52 );53 expect(JSON.stringify(failure)).not.toContain("short");54 })55 );5657 it.effect("fails to start without its Artifacts binding", () =>58 Effect.gen(function* () {59 const failure = yield* failureOf(without(fakeEnv(), "ARTIFACTS"));6061 expect(failure).toStrictEqual(new InvalidEnv({ keys: ["ARTIFACTS"] }));62 })63 );6465 it.effect("names every missing binding and var at once", () =>66 Effect.gen(function* () {67 const failure = yield* failureOf(68 without(without(fakeEnv(), "SANDBOX"), "STAGE")69 );7071 expect(failure).toStrictEqual(72 new InvalidEnv({ keys: ["SANDBOX", "STAGE"] })73 );74 })75 );7677 it.effect(78 "fails to start with GitHub's client id but not its secret, naming the key only",79 () =>80 Effect.gen(function* () {81 const env = {82 ...fakeEnv(),83 COOKIE_KEY: cookieKey,84 GITHUB_CLIENT_ID: clientId,85 };8687 const failure = yield* failureOf(env);8889 expect(failure).toStrictEqual(90 new InvalidEnv({ keys: ["GITHUB_CLIENT_SECRET"] })91 );92 expect(JSON.stringify(failure)).not.toContain(clientId);93 expect(JSON.stringify(failure)).not.toContain(cookieKey);94 })95 );9697 it.effect(98 "fails to start on a session table it cannot read, without printing it",99 () =>100 Effect.gen(function* () {101 const env = {102 ...fakeEnv(),103 SESSION_TOKENS: JSON.stringify({ "short-token": "alice" }),104 };105106 const failure = yield* failureOf(env);107108 expect(failure).toStrictEqual(109 new InvalidEnv({ keys: ["SESSION_TOKENS"] })110 );111 expect(JSON.stringify(failure)).not.toContain("short-token");112 })113 );114115 it.effect("lets a token from the session table call as its person", () =>116 Effect.gen(function* () {117 const token = "alice-token-0123456789abcdef01234567";118119 const env = {120 ...fakeEnv(),121 SESSION_TOKENS: JSON.stringify({ [token]: "alice" }),122 };123124 const { handler } = yield* served(platform(env));125126 const alice = yield* rpcClient(handler, token);127128 expect(yield* alice.listProjects({})).toStrictEqual({ projects: [] });129 })130 );131132 it.effect("lands with the container Lander unless the env says isogit", () =>133 Effect.gen(function* () {134 const unset = yield* decodeEnv(without(fakeEnv(), "LANDER_ADAPTER"));135136 const isogit = yield* decodeEnv({137 ...fakeEnv(),138 LANDER_ADAPTER: "isogit",139 });140141 expect([unset.LANDER_ADAPTER, isogit.LANDER_ADAPTER]).toStrictEqual([142 "container",143 "isogit",144 ]);145 })146 );147148 it.effect("answers /health with its stage, without a credential", () =>149 Effect.gen(function* () {150 const { fetch } = yield* served(platform(fakeEnv()));151152 const response = yield* fetch(new Request("http://localhost/health"));153154 expect(response.status).toBe(200);155 expect(yield* Effect.promise(() => response.json())).toStrictEqual({156 ok: true,157 stage: "local",158 });159 })160 );161162 it.effect("hands git's paths to the gateway, outside the 401 gate", () =>163 Effect.gen(function* () {164 const { fetch } = yield* served(platform(fakeEnv()));165166 const response = yield* fetch(167 new Request(168 "http://localhost/datekit.git/info/refs?service=git-upload-pack"169 )170 );171172 // No gateway yet (303): no repo answers, and nobody is asked to sign in.173 expect(response.status).toBe(404);174 })175 );176});
added:apps/platform/test/repo-names.test.ts+72 added
1import { describe, expect, it } from "@effect/vitest";2import { AskId, Handle, ProjectName, RepoName } from "@repo/protocol/ids";34import {5 claimForkName,6 RepoKind,7 repoKind,8 workingForkName,9} from "../src/repo-names.ts";1011const datekit = ProjectName.make("datekit");1213const parseIso = AskId.make("parse-iso");1415const kinds: readonly (readonly [string, RepoKind])[] = [16 ["datekit", RepoKind.Canonical({ project: datekit })],17 ["date-kit", RepoKind.Canonical({ project: ProjectName.make("date-kit") })],18 [19 "datekit--parse-iso--bob",20 RepoKind.ClaimFork({21 ask: parseIso,22 handle: Handle.make("bob"),23 project: datekit,24 }),25 ],26 [27 "datekit--me--alice",28 RepoKind.WorkingFork({ handle: Handle.make("alice"), project: datekit }),29 ],30 // `layer` is no ask's name; a layer's repo is W6's.31 ["datekit--layer--alice", RepoKind.Unknown()],32 ["datekit--maintainers", RepoKind.Unknown()],33 // A stray `--` splits a name into parts no repo has.34 ["datekit--parse-iso--bob--extra", RepoKind.Unknown()],35 ["datekit----bob", RepoKind.Unknown()],36 ["datekit---parse-iso--bob", RepoKind.Unknown()],37 ["datekit--parse-iso--", RepoKind.Unknown()],38 ["--datekit", RepoKind.Unknown()],39 // The platform spells every handle in a name in lowercase.40 ["datekit--parse-iso--Bob", RepoKind.Unknown()],41 // Not a project's name at all.42 ["Datekit", RepoKind.Unknown()],43 ["datekit.git", RepoKind.Unknown()],44];4546describe("what a repo's name says it is", () => {47 it.each(kinds)("%s", (name, kind) => {48 expect(repoKind(RepoName.make(name))).toStrictEqual(kind);49 });5051 it("names a claim's fork with its claimant's handle in lowercase, and reads it back", () => {52 const fork = claimForkName(datekit, parseIso, Handle.make("Bob"));5354 expect(fork).toBe("datekit--parse-iso--bob");55 expect(repoKind(fork)).toStrictEqual(56 RepoKind.ClaimFork({57 ask: parseIso,58 handle: Handle.make("bob"),59 project: datekit,60 })61 );62 });6364 it("names a person's working fork with their handle in lowercase, and reads it back", () => {65 const fork = workingForkName(datekit, Handle.make("Alice"));6667 expect(fork).toBe("datekit--me--alice");68 expect(repoKind(fork)).toStrictEqual(69 RepoKind.WorkingFork({ handle: Handle.make("alice"), project: datekit })70 );71 });72});
added:apps/platform/test/step.test.ts+172 added
1import { describe, expect, expectTypeOf, it } from "@effect/vitest";2import { LandedSha } from "@repo/protocol/ids";3import { StaleBase } from "@repo/protocol/refusal";4import type { WorkflowStep } from "cloudflare:workers";5import { DateTime, Effect, Option, Ref, Schema } from "effect";67import { memoSteps, StepRunner, workflowSteps } from "../src/workflows/step.ts";8import type {9 WorkflowStepRetries,10 WorkflowSteps,11} from "../src/workflows/step.ts";1213const sha = LandedSha.make("a".repeat(40));1415/** A value whose encoded form differs from it: a date and an option. */16const Landing = Schema.Struct({17 at: Schema.DateTimeUtcFromString,18 sha: Schema.OptionFromOptionalKey(LandedSha),19});2021const landing = {22 at: DateTime.makeUnsafe("2026-10-08T12:00:00Z"),23 sha: Option.some(sha),24};2526/**27 * A Workflow's steps as the engine runs them, in memory: a step's first run28 * records what its body returns under its name; a replay returns the29 * record without running it. It keeps every retry config it was given.30 */31const fakeWorkflowStep = () => {32 const recorded = new Map<string, Promise<Schema.Json>>();33 const retries: WorkflowStepRetries[] = [];3435 const steps: WorkflowSteps = {36 do: (name, config, body) => {37 if (config.retries !== undefined) {38 retries.push(config.retries);39 }4041 const kept = recorded.get(name) ?? body();4243 recorded.set(name, kept);4445 return kept;46 },47 };4849 /** What the engine recorded for `name`; `null` if it ran no such step. */50 const record = (name: string) =>51 Effect.promise(() => recorded.get(name) ?? Promise.resolve(null));5253 return { record, retries, steps };54};5556/** A step that counts its runs and lands. */57const counted = (runs: Ref.Ref<number>) =>58 Effect.as(59 Ref.update(runs, (n) => n + 1),60 landing61 );6263describe(StepRunner, () => {64 it("runs over a Workflow's own steps", () => {65 expectTypeOf<WorkflowStep>().toExtend<WorkflowSteps>();66 });6768 it.effect("records a step's value encoded, and decodes it back", () =>69 Effect.gen(function* () {70 const fake = fakeWorkflowStep();71 const runs = yield* Ref.make(0);7273 const value = yield* StepRunner.use(({ step }) =>74 step("land#1", Landing, counted(runs))75 ).pipe(Effect.provide(workflowSteps(fake.steps)));7677 expect(value).toStrictEqual(landing);78 expect(yield* fake.record("land#1")).toStrictEqual({79 at: "2026-10-08T12:00:00.000Z",80 sha,81 });82 })83 );8485 it.effect("returns a replayed step's record without running it again", () =>86 Effect.gen(function* () {87 const fake = fakeWorkflowStep();88 const runs = yield* Ref.make(0);8990 const run = StepRunner.use(({ step }) =>91 step("land#1", Landing, counted(runs))92 ).pipe(Effect.provide(workflowSteps(fake.steps)));9394 expect([yield* run, yield* run]).toStrictEqual([landing, landing]);95 expect(yield* Ref.get(runs)).toBe(1);96 })97 );9899 it.effect("hands the engine a step's retries", () =>100 Effect.gen(function* () {101 const fake = fakeWorkflowStep();102 const retry = { backoff: "exponential", delayMs: 500, limit: 3 } as const;103104 yield* StepRunner.use(({ step }) =>105 step("merge#1", Landing, Effect.succeed(landing), retry)106 ).pipe(Effect.provide(workflowSteps(fake.steps)));107108 expect(fake.retries).toStrictEqual([109 { backoff: "exponential", delay: 500, limit: 3 },110 ]);111 })112 );113114 it.effect("fails with a step's own refusal once the engine gives up", () =>115 Effect.gen(function* () {116 const fake = fakeWorkflowStep();117 const stale = new StaleBase({ base: sha, conflicts: [], main: sha });118119 const failure = yield* StepRunner.use(({ step }) =>120 step("land#1", Landing, Effect.fail(stale))121 ).pipe(Effect.provide(workflowSteps(fake.steps)), Effect.flip);122123 expect(failure).toStrictEqual(stale);124 })125 );126});127128describe(memoSteps, () => {129 it.effect("returns the recorded value on a second run", () =>130 Effect.gen(function* () {131 const steps = yield* memoSteps();132 const runs = yield* Ref.make(0);133134 const run = StepRunner.use(({ step }) =>135 step("land#1", Landing, counted(runs))136 ).pipe(Effect.provide(steps));137138 expect([yield* run, yield* run]).toStrictEqual([landing, landing]);139 expect(yield* Ref.get(runs)).toBe(1);140 })141 );142143 it.effect(144 "records nothing for a step that failed, so the next run tries again",145 () =>146 Effect.gen(function* () {147 const steps = yield* memoSteps();148 const runs = yield* Ref.make(0);149 const stale = new StaleBase({ base: sha, conflicts: [], main: sha });150151 const failing = StepRunner.use(({ step }) =>152 step(153 "land#1",154 Landing,155 Effect.andThen(156 Ref.update(runs, (n) => n + 1),157 Effect.fail(stale)158 )159 )160 ).pipe(Effect.provide(steps), Effect.flip);161162 expect(yield* failing).toStrictEqual(stale);163164 const landed = StepRunner.use(({ step }) =>165 step("land#1", Landing, counted(runs))166 ).pipe(Effect.provide(steps));167168 expect(yield* landed).toStrictEqual(landing);169 expect(yield* Ref.get(runs)).toBe(2);170 })171 );172});
added:apps/platform/test/workers-shim.ts+43 added
1/**2 * `cloudflare:workers` for tests in Node. `vitest.config.ts` aliases the3 * module here, so the Worker's modules load outside workerd: config4 * aliasing, not module mocking. Each class keeps what its constructor is5 * given and does nothing else; `env` is a fake whose bindings throw when6 * touched (`fake-env.ts`).7 */8import { fakeEnv } from "./fake-env.ts";910export class DurableObject<E = Env> {11 readonly ctx: DurableObjectState;1213 readonly env: E;1415 constructor(ctx: DurableObjectState, env: E) {16 this.ctx = ctx;17 this.env = env;18 }19}2021export class WorkflowEntrypoint<E = Env> {22 readonly ctx: ExecutionContext;2324 readonly env: E;2526 constructor(ctx: ExecutionContext, env: E) {27 this.ctx = ctx;28 this.env = env;29 }30}3132export class WorkerEntrypoint<E = Env> {33 readonly ctx: ExecutionContext;3435 readonly env: E;3637 constructor(ctx: ExecutionContext, env: E) {38 this.ctx = ctx;39 this.env = env;40 }41}4243export const env = fakeEnv();
modified:apps/platform/.env.schema+19 added
9 unmodified lines
10# The bearer token of the one operator session, until sign-in exists. Anyone11# holding it calls the contracts as `OPERATOR_HANDLE` (wrangler.jsonc).12# @required @sensitive @type=string(minLength=32)13OPERATOR_TOKEN=1415# Named sessions until GitHub sign-in exists (spec §8 D9): a JSON object from16# token to handle, `{"<token>":"alice"}`, for the demo's fictional people.17# Each token is at least 32 characters. The operator's token wins if both18# name one.19# @optional @sensitive20SESSION_TOKENS=2122# GitHub sign-in (H4): the OAuth app's client id and secret, and the key that23# seals the sign-in state cookie (at least 32 characters). Set all three or24# none: without them the stage runs on the operator and named sessions.25# @optional @sensitive26GITHUB_CLIENT_ID=2728# @optional @sensitive29GITHUB_CLIENT_SECRET=3031# @optional @sensitive @type=string(minLength=32)32COOKIE_KEY=
modified:apps/platform/package.json+13 added
6 unmodified lines
7 "typecheck": "tsc --noEmit -p tsconfig.json",8 "test": "vitest run"9 },10 "dependencies": {11 "@cloudflare/workers-oauth-provider": "1.2.1",12 "@effect/sql-d1": "4.0.1",13 "@effect/sql-sqlite-do": "4.0.1",14 "@repo/artifacts": "workspace:*",15 "@repo/brand": "workspace:*",16 "@repo/checks": "workspace:*",17 "@repo/gate": "workspace:*",18 "@repo/git": "workspace:*",19 "@repo/project": "workspace:*",20 "@repo/protocol": "workspace:*",21 "@repo/rules": "workspace:*",22 "effect": "catalog:"23 },24 "devDependencies": {25 "@cloudflare/workers-types": "5.20261006.1",26 "@effect/platform-node": "4.0.1",27 "@effect/sql-sqlite-node": "4.0.1",28 "@effect/vitest": "catalog:",29 "@repo/config": "workspace:*",30 "@repo/testkit": "workspace:*",31 "@varlock/cloudflare-integration": "1.6.0",32 "typescript": "catalog:",33 "vitest": "catalog:",34 "wrangler": "4.147.0"35 }
1 unmodified line
modified:apps/platform/vitest.config.ts+16 added-1 removed
1export { preset as default } from "@repo/config/vitest";1import { preset } from "@repo/config/vitest";2import { defineConfig, mergeConfig } from "vitest/config";34// Worker modules import `cloudflare:workers`, which only workerd serves; in5// Node it resolves to a shim. An alias resolves to a file, not a folder.6export default mergeConfig(7 preset,8 defineConfig({9 resolve: {10 alias: {11 "cloudflare:workers": new URL("test/workers-shim.ts", import.meta.url)12 .pathname,13 },14 },15 })16);
modified:apps/platform/worker-configuration.d.ts+50 added-2 removed
1/* eslint-disable */2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: 68d6818e21e9426b3b40f9ed8058a4bd)2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: b1749d7af308b3b61530326fe958bce2)3interface __BaseEnv_Env {4 OAUTH_KV: KVNamespace;5 EVIDENCE: R2Bucket;6 FRONT_PAGE: D1Database;7 ARTIFACTS: Artifacts;8 CLAIM_LIMIT: RateLimit;9 PROPOSAL_LIMIT: RateLimit;10 LOADER: WorkerLoader;11 OPERATOR_HANDLE: string;12 STAGE: string;13 LANDER_ADAPTER: string;14 OPERATOR_TOKEN: string;15 PROJECT: DurableObjectNamespace<import("./src/worker").Project>;16 SANDBOX: Fetcher /* sandbox-dev-oscabriel */ | Fetcher /* sandbox-demo */ | Fetcher /* sandbox */;17 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;18 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;19}20declare namespace Cloudflare {21 interface GlobalProps {22 mainModule: typeof import("./src/worker");23 durableNamespaces: "Project";24 }25 interface DevOscabrielEnv {26 OAUTH_KV: KVNamespace;27 EVIDENCE: R2Bucket;28 FRONT_PAGE: D1Database;29 ARTIFACTS: Artifacts;30 CLAIM_LIMIT: RateLimit;31 PROPOSAL_LIMIT: RateLimit;32 LOADER: WorkerLoader;33 OPERATOR_HANDLE: string;34 STAGE: string;35 LANDER_ADAPTER: string;36 OPERATOR_TOKEN: string;37 PROJECT: DurableObjectNamespace<import("./src/worker").Project>;38 SANDBOX: Fetcher /* sandbox-dev-oscabriel */;39 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;40 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;41 }42 interface DemoEnv {43 OAUTH_KV: KVNamespace;44 EVIDENCE: R2Bucket;45 FRONT_PAGE: D1Database;46 ARTIFACTS: Artifacts;47 CLAIM_LIMIT: RateLimit;48 PROPOSAL_LIMIT: RateLimit;49 LOADER: WorkerLoader;50 OPERATOR_HANDLE: string;51 STAGE: string;52 LANDER_ADAPTER: string;53 OPERATOR_TOKEN: string;54 PROJECT: DurableObjectNamespace<import("./src/worker").Project>;55 SANDBOX: Fetcher /* sandbox-demo */;56 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;57 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;58 }59 interface Env extends __BaseEnv_Env {}60}61interface Env extends __BaseEnv_Env {}62type StringifyValues<EnvType extends Record<string, unknown>> = {63 [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;64};65declare namespace NodeJS {18 interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "OPERATOR_HANDLE" | "OPERATOR_TOKEN">> {}66 interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "OPERATOR_HANDLE" | "STAGE" | "LANDER_ADAPTER" | "OPERATOR_TOKEN">> {}67}
modified:apps/platform/wrangler.jsonc+194 added-4 removed
1{2 // The platform Worker: the contracts over RPC at /rpc and MCP at /mcp.3 // Deploy only through infra/deploy.ts, to an explicit stage.2 // The platform Worker: the contracts over RPC at /rpc and MCP at /mcp, git3 // smart HTTP for every project's repos, the Project Durable Object and the4 // Answer and OnPush Workflows. Deploy only through infra/deploy.ts, to an5 // explicit stage.6 //7 // The top level is stage `local`: it builds and types the Worker and is8 // never deployed. Each stage under `env` repeats every binding, since9 // wrangler does not inherit bindings into an environment. Resource names10 // are jobs plus the stage (spec §4.4), never the brand. A `database_id` or11 // KV `id` of zeros is a placeholder that infra/bootstrap.ts replaces with12 // the id of the resource it made.13 "$schema": "node_modules/wrangler/config-schema.json",14 "name": "platform",15 "main": "src/worker.ts",16 "compatibility_date": "2026-10-05",17 // isomorphic-git needs `Buffer` (the /isogit Lander).18 "compatibility_flags": ["nodejs_compat"],19 // Rat Stack's byte limits are for a minified bundle (scripts/startup-budget.ts).20 "minify": true,21 "workers_dev": true,22 "preview_urls": false,23 "observability": { "enabled": true },24 "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Project"] }],25 "vars": {14 // Until sign-in exists, one operator holds the only session.26 // Until sign-in exists, one operator holds a session.27 "OPERATOR_HANDLE": "oscabriel",28 "STAGE": "local",29 // "container" (apps/sandbox) or "isogit" (in this Worker): spec §8 D6.30 "LANDER_ADAPTER": "container",31 },32 "secrets": {18 // Declared in .env.schema; the user sets the value.33 // Declared in .env.schema; the user sets the values. SESSION_TOKENS and34 // the GitHub and cookie keys are optional, so a stage deploys before H4.35 "required": ["OPERATOR_TOKEN"],36 },37 "durable_objects": {38 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],39 },40 "workflows": [41 { "name": "answer-local", "binding": "ANSWER", "class_name": "Answer" },42 { "name": "on-push-local", "binding": "ON_PUSH", "class_name": "OnPush" },43 ],44 "artifacts": [{ "binding": "ARTIFACTS", "namespace": "projects-local" }],45 "d1_databases": [46 {47 "binding": "FRONT_PAGE",48 "database_name": "front-page-local",49 "database_id": "00000000-0000-0000-0000-000000000000",50 "migrations_dir": "migrations",51 },52 ],53 // KV namespace `oauth-local`.54 "kv_namespaces": [55 { "binding": "OAUTH_KV", "id": "00000000000000000000000000000000" },56 ],57 "r2_buckets": [{ "binding": "EVIDENCE", "bucket_name": "evidence-local" }],58 "worker_loaders": [{ "binding": "LOADER" }],59 "services": [{ "binding": "SANDBOX", "service": "sandbox" }],60 // Namespace ids differ per stage, so one stage's counts never spend61 // another's.62 "ratelimits": [63 {64 "name": "CLAIM_LIMIT",65 "namespace_id": "1001",66 "simple": { "limit": 10, "period": 60 },67 },68 {69 "name": "PROPOSAL_LIMIT",70 "namespace_id": "1002",71 "simple": { "limit": 5, "period": 60 },72 },73 ],74 "triggers": {75 "events": [76 {77 "type": "cf.artifacts.repo.pushed",78 "filter": { "namespace": "projects-local" },79 "targets": [{ "type": "workflow", "workflow_name": "on-push-local" }],80 },81 ],82 },83 "env": {84 "dev-oscabriel": {85 "vars": {86 "OPERATOR_HANDLE": "oscabriel",87 "STAGE": "dev-oscabriel",88 "LANDER_ADAPTER": "container",89 },90 "secrets": { "required": ["OPERATOR_TOKEN"] },91 "durable_objects": {92 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],93 },94 "workflows": [95 {96 "name": "answer-dev-oscabriel",97 "binding": "ANSWER",98 "class_name": "Answer",99 },100 {101 "name": "on-push-dev-oscabriel",102 "binding": "ON_PUSH",103 "class_name": "OnPush",104 },105 ],106 "artifacts": [107 { "binding": "ARTIFACTS", "namespace": "projects-dev-oscabriel" },108 ],109 "d1_databases": [110 {111 "binding": "FRONT_PAGE",112 "database_name": "front-page-dev-oscabriel",113 "database_id": "00000000-0000-0000-0000-000000000000",114 "migrations_dir": "migrations",115 },116 ],117 // KV namespace `oauth-dev-oscabriel`.118 "kv_namespaces": [119 { "binding": "OAUTH_KV", "id": "00000000000000000000000000000000" },120 ],121 "r2_buckets": [122 { "binding": "EVIDENCE", "bucket_name": "evidence-dev-oscabriel" },123 ],124 "worker_loaders": [{ "binding": "LOADER" }],125 "services": [126 { "binding": "SANDBOX", "service": "sandbox-dev-oscabriel" },127 ],128 "ratelimits": [129 {130 "name": "CLAIM_LIMIT",131 "namespace_id": "1101",132 "simple": { "limit": 10, "period": 60 },133 },134 {135 "name": "PROPOSAL_LIMIT",136 "namespace_id": "1102",137 "simple": { "limit": 5, "period": 60 },138 },139 ],140 "triggers": {141 "events": [142 {143 "type": "cf.artifacts.repo.pushed",144 "filter": { "namespace": "projects-dev-oscabriel" },145 "targets": [146 { "type": "workflow", "workflow_name": "on-push-dev-oscabriel" },147 ],148 },149 ],150 },151 },152 "demo": {153 "vars": {154 "OPERATOR_HANDLE": "oscabriel",155 "STAGE": "demo",156 "LANDER_ADAPTER": "container",157 },158 "secrets": { "required": ["OPERATOR_TOKEN"] },159 "durable_objects": {160 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],161 },162 "workflows": [163 { "name": "answer-demo", "binding": "ANSWER", "class_name": "Answer" },164 {165 "name": "on-push-demo",166 "binding": "ON_PUSH",167 "class_name": "OnPush",168 },169 ],170 "artifacts": [{ "binding": "ARTIFACTS", "namespace": "projects-demo" }],171 "d1_databases": [172 {173 "binding": "FRONT_PAGE",174 "database_name": "front-page-demo",175 "database_id": "00000000-0000-0000-0000-000000000000",176 "migrations_dir": "migrations",177 },178 ],179 // KV namespace `oauth-demo`.180 "kv_namespaces": [181 { "binding": "OAUTH_KV", "id": "00000000000000000000000000000000" },182 ],183 "r2_buckets": [{ "binding": "EVIDENCE", "bucket_name": "evidence-demo" }],184 "worker_loaders": [{ "binding": "LOADER" }],185 "services": [{ "binding": "SANDBOX", "service": "sandbox-demo" }],186 "ratelimits": [187 {188 "name": "CLAIM_LIMIT",189 "namespace_id": "1201",190 "simple": { "limit": 10, "period": 60 },191 },192 {193 "name": "PROPOSAL_LIMIT",194 "namespace_id": "1202",195 "simple": { "limit": 5, "period": 60 },196 },197 ],198 "triggers": {199 "events": [200 {201 "type": "cf.artifacts.repo.pushed",202 "filter": { "namespace": "projects-demo" },203 "targets": [204 { "type": "workflow", "workflow_name": "on-push-demo" },205 ],206 },207 ],208 },209 },210 },211}
added:apps/sandbox/images/check.Dockerfile+17 added
1# The Checker's image: where an answer's checks run, with no credentials2# (spec §4.3). Debian trixie slim, Node 24, Bun 1.4.2, git and corepack, plus3# the Sandbox SDK's `sandbox-shim`, which `Files` runs. A stub until W3 3154# adds the phases' tools.5FROM docker.io/cloudflare/sandbox:1.0.0 AS shim6FROM docker.io/oven/bun:1.4.2-slim AS bun7FROM docker.io/library/node:24-trixie-slim89RUN apt-get update \10 && apt-get install -y --no-install-recommends ca-certificates git \11 && rm -rf /var/lib/apt/lists/* \12 && corepack enable1314COPY --from=shim /usr/local/bin/sandbox-shim /usr/local/bin/sandbox-shim15COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun1617WORKDIR /workspace
added:apps/sandbox/images/land.Dockerfile+17 added
1# The Lander's image: trusted, it runs git and Bun and never an answer's code2# (spec §4.3). Debian trixie slim, git, Bun 1.4.2 for `bundleRules`, plus the3# Sandbox SDK's `sandbox-shim`, which `Files` runs. Its build context is the4# repo root, so W3 306 can copy the sdk in for `bundleRules`; a stub until5# then.6FROM docker.io/cloudflare/sandbox:1.0.0 AS shim7FROM docker.io/oven/bun:1.4.2-slim AS bun8FROM docker.io/library/debian:trixie-slim910RUN apt-get update \11 && apt-get install -y --no-install-recommends ca-certificates git \12 && rm -rf /var/lib/apt/lists/*1314COPY --from=shim /usr/local/bin/sandbox-shim /usr/local/bin/sandbox-shim15COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun1617WORKDIR /workspace
added:apps/sandbox/images/land.Dockerfile.dockerignore+13 added
1# The Lander's build context is the repo root. Admit only what its image2# copies: the sdk and what it imports, for `bundleRules` (W3 306). Nothing3# else of the repo, no env file and no node_modules, reaches the build.4**5!packages/brand/package.json6!packages/brand/src/**7!packages/protocol/package.json8!packages/protocol/src/**9!packages/sdk/package.json10!packages/sdk/src/**11**/node_modules12**/.env13**/.env.*
added:apps/sandbox/src/box/sdk.ts+112 added
1/**2 * `Box` over a Durable Object's own container (`ctx.container`), as the3 * Sandbox SDK 1.0 runs one: the Durable Object starts the container and runs4 * commands through the Container API (`exec`, then `output`); the SDK's5 * `Files` writes files through the `sandbox-shim` every image carries.6 */7import { Files } from "@cloudflare/sandbox";8import { Duration, Effect, Layer } from "effect";910import { Box, BoxFailed } from "../box.ts";11import type { ExecOptions } from "../box.ts";1213/** Which image the container runs, and whether it may reach the internet. */14export interface ContainerStart {15 readonly image: string;16 readonly enableInternet: boolean;17}1819const text = new TextDecoder();2021/** The container, started on first use if it is not running yet. */22const started = (container: Container, start: ContainerStart) =>23 Effect.sync(() => {24 if (!container.running) {25 container.start({26 enableInternet: start.enableInternet,27 image: start.image,28 });29 }3031 return container;32 });3334/** The Container API's options for one command; `signal` stops it. */35const execOptions = (options: ExecOptions, signal: AbortSignal) => {36 const exec: ContainerExecOptions = { signal };3738 if (options.cwd !== undefined) {39 exec.cwd = options.cwd;40 }4142 if (options.env !== undefined) {43 exec.env = { ...options.env };44 }4546 return exec;47};4849const failed =50 (operation: BoxFailed["operation"]) =>51 (cause: unknown): BoxFailed =>52 new BoxFailed({ operation, reason: String(cause) });5354/** One command, run to its end, its output read as text. */55const run = (56 container: Container,57 argv: readonly string[],58 options: ExecOptions59) =>60 Effect.gen(function* () {61 const process = yield* Effect.tryPromise({62 catch: failed("exec"),63 try: (signal) => container.exec([...argv], execOptions(options, signal)),64 });6566 const output = yield* Effect.tryPromise({67 catch: failed("exec"),68 try: () => process.output(),69 });7071 return {72 exitCode: output.exitCode,73 stderr: text.decode(output.stderr),74 stdout: text.decode(output.stdout),75 };76 });7778export const SdkBox = {79 layer: (container: Container, start: ContainerStart): Layer.Layer<Box> =>80 Layer.succeed(81 Box,82 Box.of({83 destroy: () =>84 Effect.ignore(Effect.tryPromise(() => container.destroy())),85 exec: (argv, options = {}) =>86 Effect.flatMap(started(container, start), (running) => {87 const command = run(running, argv, options);8889 // Interrupting the command aborts its signal, which stops it.90 return options.timeoutMs === undefined91 ? command92 : Effect.timeoutOrElse(command, {93 duration: Duration.millis(options.timeoutMs),94 orElse: () =>95 Effect.fail(96 new BoxFailed({97 operation: "exec",98 reason: `timed out after ${options.timeoutMs} ms`,99 })100 ),101 });102 }),103 writeFile: (path, bytes) =>104 Effect.flatMap(started(container, start), (running) =>105 Effect.tryPromise({106 catch: failed("writeFile"),107 try: () => new Files(running).writeFile(path, bytes),108 })109 ),110 })111 ),112};
added:apps/sandbox/src/box.ts+45 added
1/**2 * The `Box` port: the one container a Checker or a Lander Durable Object3 * runs its commands in. Both run through it, so their scripts are tested in4 * Node over local processes (W3 306, 315) and run in a container in the5 * Worker (`box/sdk.ts`).6 */7import { Context, Schema } from "effect";8import type { Array, Effect } from "effect";910/** The container would not run a command, take a file or answer at all. */11export class BoxFailed extends Schema.TaggedError<BoxFailed>()("BoxFailed", {12 operation: Schema.Literals(["exec", "writeFile"]),13 reason: Schema.String,14}) {}1516/** How one command runs: where, with what env, and for how long at most. */17export interface ExecOptions {18 readonly cwd?: string;19 readonly env?: Readonly<Record<string, string>>;20 readonly timeoutMs?: number;21}2223/** What one command left: its exit code and its output, as text. */24export interface Executed {25 readonly exitCode: number;26 readonly stdout: string;27 readonly stderr: string;28}2930export class Box extends Context.Service<31 Box,32 {33 /** Runs `argv` and waits for it; a command that exits non-zero is still a success. */34 readonly exec: (35 argv: Array.NonEmptyReadonlyArray<string>,36 options?: ExecOptions37 ) => Effect.Effect<Executed, BoxFailed>;38 readonly writeFile: (39 path: string,40 bytes: Uint8Array41 ) => Effect.Effect<void, BoxFailed>;42 /** Stops the container and drops everything in it. */43 readonly destroy: () => Effect.Effect<void>;44 }45>()("sandbox/Box") {}
added:apps/sandbox/src/checker.ts+22 added
1/**2 * The Checker: one container per check, holding no credential, where an3 * answer's lanes run (spec §4.3). A stub until W3 315 builds its phases:4 * every check is `VerifierBlocked`. The class name is frozen.5 */6import { CheckExit, CheckWire } from "@repo/checks/check-runner/wire";7import { VerifierBlocked } from "@repo/protocol/refusal";8import { DurableObject } from "cloudflare:workers";910import { answerJob, notBuilt } from "./job.ts";1112/** The Checker's Durable Object, which owns its container. */13export class Checker extends DurableObject<Env> {}1415/** One check job from the platform, its outcome encoded. */16export const runCheck = (17 _env: Env,18 wire: typeof CheckWire.Encoded19): Promise<typeof CheckExit.Encoded> =>20 answerJob(CheckWire, CheckExit, () =>21 notBuilt("check", new VerifierBlocked({}))22 )(wire);
added:apps/sandbox/src/job.ts+38 added
1/**2 * How the sandbox answers one job from the platform: decode its wire, run3 * it, and send back its `Exit` encoded as JSON (principle 2: both sides of4 * the service binding decode with the same schemas). A wire that does not5 * decode, or an outcome that does not encode, is a defect: the platform6 * encoded the job with the same schema.7 */8import { Effect, Schema } from "effect";9import type { Exit } from "effect";1011export const answerJob =12 <W, WI, A, E, X>(13 wire: Schema.Codec<W, WI>,14 exit: Schema.Codec<Exit.Exit<A, E>, X>,15 run: (job: W) => Effect.Effect<A, E>16 ) =>17 (encoded: WI): Promise<X> =>18 Effect.runPromise(19 Schema.decodeEffect(wire)(encoded).pipe(20 Effect.orDie,21 Effect.flatMap(run),22 Effect.exit,23 Effect.flatMap((outcome) =>24 Effect.orDie(Schema.encodeEffect(exit)(outcome))25 )26 )27 );2829/**30 * A job whose side of the sandbox is not built yet: `VerifierBlocked`, the31 * gate's trouble and never the answer's, with `not built` in a log32 * annotation, since a refusal carries no free text (principle 3).33 */34export const notBuilt = <E>(job: string, blocked: E) =>35 Effect.logWarning("sandbox job not built").pipe(36 Effect.annotateLogs({ job, reason: "not built" }),37 Effect.andThen(Effect.fail(blocked))38 );
added:apps/sandbox/src/lander.ts+59 added
1/**2 * The Lander: the trusted container that merges answers, composes ask files,3 * lands checked trees on canonical `main` with a non-force push, and bundles4 * the config folder (spec §4.3). It runs no answer's code. A stub until W35 * 306 builds it: every job is `VerifierBlocked`. The class name is frozen.6 */7import {8 BundleExit,9 BundleWire,10 ComposeExit,11 ComposeWire,12 LandExit,13 LandWire,14 MergeExit,15 MergeWire,16} from "@repo/project/lander/wire";17import { VerifierBlocked } from "@repo/protocol/refusal";18import { DurableObject } from "cloudflare:workers";1920import { answerJob, notBuilt } from "./job.ts";2122/** The Lander's Durable Object, which owns its container. */23export class Lander extends DurableObject<Env> {}2425/** An answer's head merged onto canonical `main`. */26export const runMerge = (27 _env: Env,28 wire: typeof MergeWire.Encoded29): Promise<typeof MergeExit.Encoded> =>30 answerJob(MergeWire, MergeExit, () =>31 notBuilt("merge", new VerifierBlocked({}))32 )(wire);3334/** A checked tree landed on canonical `main`. */35export const runLand = (36 _env: Env,37 wire: typeof LandWire.Encoded38): Promise<typeof LandExit.Encoded> =>39 answerJob(LandWire, LandExit, () =>40 notBuilt("land", new VerifierBlocked({}))41 )(wire);4243/** A decider's files composed onto canonical `main`, on a compose ref. */44export const runCompose = (45 _env: Env,46 wire: typeof ComposeWire.Encoded47): Promise<typeof ComposeExit.Encoded> =>48 answerJob(ComposeWire, ComposeExit, () =>49 notBuilt("compose", new VerifierBlocked({}))50 )(wire);5152/** The config folder at a landed commit, bundled for the rules evaluator. */53export const runBundleRules = (54 _env: Env,55 wire: typeof BundleWire.Encoded56): Promise<typeof BundleExit.Encoded> =>57 answerJob(BundleWire, BundleExit, () =>58 notBuilt("bundleRules", new VerifierBlocked({}))59 )(wire);
added:apps/sandbox/src/worker.ts+52 added
1/**2 * The sandbox Worker. Its default entrypoint is reached only through the3 * platform's `SANDBOX` service binding: each method takes a job's wire,4 * encoded, and returns the job's `Exit`, encoded as JSON, so both sides5 * decode with the schemas in `@repo/checks/check-runner/wire` and6 * `@repo/project/lander/wire`.7 */8import type { CheckExit, CheckWire } from "@repo/checks/check-runner/wire";9import type {10 BundleExit,11 BundleWire,12 ComposeExit,13 ComposeWire,14 LandExit,15 LandWire,16 MergeExit,17 MergeWire,18} from "@repo/project/lander/wire";19import { WorkerEntrypoint } from "cloudflare:workers";2021import { runCheck } from "./checker.ts";22import { runBundleRules, runCompose, runLand, runMerge } from "./lander.ts";2324export { Checker } from "./checker.ts";2526export { Lander } from "./lander.ts";2728export default class Sandbox extends WorkerEntrypoint<Env> {29 check(wire: typeof CheckWire.Encoded): Promise<typeof CheckExit.Encoded> {30 return runCheck(this.env, wire);31 }3233 merge(wire: typeof MergeWire.Encoded): Promise<typeof MergeExit.Encoded> {34 return runMerge(this.env, wire);35 }3637 land(wire: typeof LandWire.Encoded): Promise<typeof LandExit.Encoded> {38 return runLand(this.env, wire);39 }4041 compose(42 wire: typeof ComposeWire.Encoded43 ): Promise<typeof ComposeExit.Encoded> {44 return runCompose(this.env, wire);45 }4647 bundleRules(48 wire: typeof BundleWire.Encoded49 ): Promise<typeof BundleExit.Encoded> {50 return runBundleRules(this.env, wire);51 }52}
added:apps/sandbox/test/box-sdk.test.ts+99 added
1import { describe, expect, it } from "@effect/vitest";2import { untouchable } from "@repo/testkit/untouchable";3import { Effect } from "effect";45import { Box } from "../src/box.ts";6import { SdkBox } from "../src/box/sdk.ts";78/** `text` as the Container API hands output back: a plain `ArrayBuffer`. */9const bytes = (text: string) => {10 const encoded = new TextEncoder().encode(text);11 const buffer = new ArrayBuffer(encoded.length);1213 new Uint8Array(buffer).set(encoded);1415 return buffer;16};1718/**19 * A Durable Object's container as the Container API shows it: it records20 * what starts it and each command it runs, and every command prints21 * `git version 2.47.3`.22 */23const fakeContainer = (running: boolean) => {24 const started: ContainerStartupOptions[] = [];25 const commands: { argv: string[]; options: ContainerExecOptions }[] = [];2627 const container = untouchable<Container>("container", {28 exec: (argv, options = {}) => {29 commands.push({ argv, options });3031 return Promise.resolve(32 untouchable<ExecProcess>("process", {33 output: () =>34 Promise.resolve({35 exitCode: 0,36 stderr: bytes(""),37 stdout: bytes("git version 2.47.3\n"),38 }),39 })40 );41 },42 running,43 start: (options) => {44 if (options !== undefined) {45 started.push(options);46 }47 },48 });4950 return { commands, container, started };51};5253const start = { enableInternet: false, image: "check" };5455describe("Box over the Sandbox SDK", () => {56 it.effect(57 "runs a command in the container and reads its output as text",58 () =>59 Effect.gen(function* () {60 const fake = fakeContainer(true);6162 const executed = yield* Box.use(({ exec }) =>63 exec(["git", "--version"], { cwd: "/workspace", env: { HOME: "/" } })64 ).pipe(Effect.provide(SdkBox.layer(fake.container, start)));6566 expect(executed).toStrictEqual({67 exitCode: 0,68 stderr: "",69 stdout: "git version 2.47.3\n",70 });71 expect(72 fake.commands.map(({ argv, options }) => ({73 argv,74 cwd: options.cwd,75 env: options.env,76 }))77 ).toStrictEqual([78 { argv: ["git", "--version"], cwd: "/workspace", env: { HOME: "/" } },79 ]);80 expect(fake.started).toStrictEqual([]);81 })82 );8384 it.effect(85 "starts a stopped container with its image, offline, before the first command",86 () =>87 Effect.gen(function* () {88 const fake = fakeContainer(false);8990 yield* Box.use(({ exec }) => exec(["true"])).pipe(91 Effect.provide(SdkBox.layer(fake.container, start))92 );9394 expect(fake.started).toStrictEqual([95 { enableInternet: false, image: "check" },96 ]);97 })98 );99});
added:apps/sandbox/test/fake-env.ts+10 added
1import { untouchable } from "@repo/testkit/untouchable";23/**4 * The sandbox Worker's env, as `wrangler.jsonc` declares it: each binding a5 * fake that throws if touched, so a test proves what a call touches.6 */7export const fakeEnv = (): Env => ({8 CHECKER: untouchable("CHECKER"),9 LANDER: untouchable("LANDER"),10});
added:apps/sandbox/test/smoke.test.ts+146 added
1import { describe, expect, it } from "@effect/vitest";2import { CheckAt } from "@repo/checks/check-runner";3import { CheckExit, CheckWire } from "@repo/checks/check-runner/wire";4import {5 BundleExit,6 BundleWire,7 ComposeExit,8 ComposeWire,9 LandExit,10 LandWire,11 MergeExit,12 MergeWire,13 Rebuild,14} from "@repo/project/lander/wire";15import {16 CommitSha,17 Handle,18 LandedSha,19 ProjectName,20 RepoName,21 RepoPath,22 RequestId,23 TreeSha,24} from "@repo/protocol/ids";25import { VerifierBlocked } from "@repo/protocol/refusal";26import { untouchable } from "@repo/testkit/untouchable";27import { Effect, Exit, Option, Redacted, Schema } from "effect";2829import Sandbox from "../src/worker.ts";30import { fakeEnv } from "./fake-env.ts";3132const repo = RepoName.make("datekit");3334const fork = RepoName.make("datekit--parse-iso--bob");3536const main = LandedSha.make("1".repeat(40));3738const head = CommitSha.make("2".repeat(40));3940const tree = TreeSha.make("3".repeat(40));4142const remote = (name: string) => ({43 token: Redacted.make(`token-for-${name}`),44 url: `https://artifacts.invalid/${name}.git`,45});4647/** The sandbox's entrypoint as the platform's service binding reaches it. */48const sandbox = new Sandbox(untouchable("ctx"), fakeEnv());4950/** A stub's outcome: a typed failure, not a defect. */51const failureOf = Exit.findErrorOption;5253describe("the sandbox Worker's entrypoint", () => {54 it.effect(55 "blocks a check with a typed refusal until the Checker is built",56 () =>57 Effect.gen(function* () {58 const wire = yield* Schema.encodeEffect(CheckWire)({59 clone: remote("datekit"),60 job: {61 at: CheckAt.cases.Tree.make({ tree }),62 lanes: [],63 placeholders: [],64 project: ProjectName.make("datekit"),65 proxies: [],66 repo,67 },68 });6970 const exit = yield* Schema.decodeEffect(CheckExit)(71 yield* Effect.promise(() => sandbox.check(wire))72 );7374 expect(failureOf(exit)).toStrictEqual(75 Option.some(new VerifierBlocked({}))76 );77 })78 );7980 it.effect(81 "blocks every Lander job with a typed refusal until the Lander is built",82 () =>83 Effect.gen(function* () {84 const merge = yield* Schema.encodeEffect(MergeWire)({85 fork: remote("fork"),86 job: { base: head, fork, head, main, repo },87 main: remote("main"),88 });8990 const land = yield* Schema.encodeEffect(LandWire)({91 job: {92 author: Handle.make("bob"),93 main,94 message: "Parse ISO weeks",95 rebuild: Rebuild.cases.Existing.make({ commit: head }),96 repo,97 requestId: RequestId.make("push-0123456789"),98 tree,99 verdict: Option.none(),100 },101 main: remote("main"),102 });103104 const compose = yield* Schema.encodeEffect(ComposeWire)({105 job: {106 files: [{ content: "export {}", path: RepoPath.make("a.ts") }],107 main,108 repo,109 },110 main: remote("main"),111 });112113 const bundle = yield* Schema.encodeEffect(BundleWire)({114 job: { at: main, repo },115 main: remote("main"),116 });117118 const outcomes = [119 failureOf(120 yield* Schema.decodeEffect(MergeExit)(121 yield* Effect.promise(() => sandbox.merge(merge))122 )123 ),124 failureOf(125 yield* Schema.decodeEffect(LandExit)(126 yield* Effect.promise(() => sandbox.land(land))127 )128 ),129 failureOf(130 yield* Schema.decodeEffect(ComposeExit)(131 yield* Effect.promise(() => sandbox.compose(compose))132 )133 ),134 failureOf(135 yield* Schema.decodeEffect(BundleExit)(136 yield* Effect.promise(() => sandbox.bundleRules(bundle))137 )138 ),139 ];140141 expect(outcomes).toStrictEqual(142 Array.from({ length: 4 }, () => Option.some(new VerifierBlocked({})))143 );144 })145 );146});
added:apps/sandbox/test/workers-shim.ts+32 added
1/**2 * `cloudflare:workers` for tests in Node. `vitest.config.ts` aliases the3 * module here, for this Worker's modules and the Sandbox SDK's: config4 * aliasing, not module mocking. Each class keeps what its constructor is5 * given and does nothing else; `env` is a fake whose bindings throw when6 * touched (`fake-env.ts`).7 */8import { fakeEnv } from "./fake-env.ts";910export class DurableObject<E = Env> {11 readonly ctx: DurableObjectState;1213 readonly env: E;1415 constructor(ctx: DurableObjectState, env: E) {16 this.ctx = ctx;17 this.env = env;18 }19}2021export class WorkerEntrypoint<E = Env> {22 readonly ctx: ExecutionContext;2324 readonly env: E;2526 constructor(ctx: ExecutionContext, env: E) {27 this.ctx = ctx;28 this.env = env;29 }30}3132export const env = fakeEnv();
added:apps/sandbox/package.json+30 added
1{2 "name": "@repo/sandbox",3 "private": true,4 "type": "module",5 "scripts": {6 "types": "wrangler types --include-runtime=false --strict-vars=false",7 "typecheck": "tsc --noEmit -p tsconfig.json",8 "test": "vitest run"9 },10 "dependencies": {11 "@cloudflare/sandbox": "1.0.0",12 "@repo/brand": "workspace:*",13 "@repo/checks": "workspace:*",14 "@repo/git": "workspace:*",15 "@repo/project": "workspace:*",16 "@repo/protocol": "workspace:*",17 "@repo/rules": "workspace:*",18 "effect": "catalog:"19 },20 "devDependencies": {21 "@cloudflare/workers-types": "5.20261006.1",22 "@effect/platform-node": "4.0.1",23 "@effect/vitest": "catalog:",24 "@repo/config": "workspace:*",25 "@repo/testkit": "workspace:*",26 "typescript": "catalog:",27 "vitest": "catalog:",28 "wrangler": "4.147.0"29 }30}
added:apps/sandbox/tsconfig.json+13 added
1{2 "extends": "../../tsconfig.base.json",3 "compilerOptions": {4 "allowImportingTsExtensions": true,5 "types": ["@cloudflare/workers-types"]6 },7 "include": [8 "src/**/*.ts",9 "test/**/*.ts",10 "*.config.ts",11 "worker-configuration.d.ts"12 ]13}
added:apps/sandbox/vitest.config.ts+19 added
1import { preset } from "@repo/config/vitest";2import { defineConfig, mergeConfig } from "vitest/config";34// Worker modules import `cloudflare:workers`, which only workerd serves; in5// Node it resolves to a shim. The Sandbox SDK imports it too, so vitest6// bundles the SDK (`inline`) for the alias to reach it. An alias resolves to7// a file, not a folder.8export default mergeConfig(9 preset,10 defineConfig({11 resolve: {12 alias: {13 "cloudflare:workers": new URL("test/workers-shim.ts", import.meta.url)14 .pathname,15 },16 },17 test: { server: { deps: { inline: ["@cloudflare/sandbox"] } } },18 })19);
added:apps/sandbox/worker-configuration.d.ts+22 added
1/* eslint-disable */2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: 834f9f6911d7397f08e3d315a4ba4497)3interface __BaseEnv_Env {4 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;5 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;6}7declare namespace Cloudflare {8 interface GlobalProps {9 mainModule: typeof import("./src/worker");10 durableNamespaces: "Checker" | "Lander";11 }12 interface DevOscabrielEnv {13 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;14 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;15 }16 interface DemoEnv {17 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;18 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;19 }20 interface Env extends __BaseEnv_Env {}21}22interface Env extends __BaseEnv_Env {}
added:apps/sandbox/wrangler.jsonc+106 added
1{2 // The sandbox Worker: the Checker and the Lander, each a Durable Object3 // with its own container, reached only through the platform's `SANDBOX`4 // service binding (its default entrypoint's RPC). It has no Artifacts5 // binding of any kind: tokens arrive in jobs, minted per job by the6 // platform. Deploy only through infra/deploy.ts, to an explicit stage.7 //8 // The top level is stage `local`: it builds and types the Worker and is9 // never deployed. Each stage under `env` repeats the containers and10 // Durable Objects, since wrangler does not inherit them.11 "$schema": "node_modules/wrangler/config-schema.json",12 "name": "sandbox",13 "main": "src/worker.ts",14 "compatibility_date": "2026-10-05",15 // The Sandbox SDK's `Files` needs it.16 "compatibility_flags": ["nodejs_compat"],17 "minify": true,18 "workers_dev": false,19 "preview_urls": false,20 "observability": { "enabled": true },21 "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Checker", "Lander"] }],22 "durable_objects": {23 "bindings": [24 { "name": "CHECKER", "class_name": "Checker" },25 { "name": "LANDER", "class_name": "Lander" },26 ],27 },28 // Untrusted answer code runs in a Checker; the Lander runs only git and29 // Bun. One container per Durable Object, which picks its instance size when30 // it starts it (`ctx.container.start`).31 "containers": [32 {33 "class_name": "Checker",34 "scheduling_policy": "durable_object",35 "images": { "check": { "dockerfile": "./images/check.Dockerfile" } },36 },37 {38 "class_name": "Lander",39 "scheduling_policy": "durable_object",40 // The repo root, so the image can carry the sdk for `bundleRules`41 // (land.Dockerfile.dockerignore admits only what it copies).42 "images": {43 "land": {44 "dockerfile": "./images/land.Dockerfile",45 "build_context": "../..",46 },47 },48 },49 ],50 "env": {51 "dev-oscabriel": {52 "durable_objects": {53 "bindings": [54 { "name": "CHECKER", "class_name": "Checker" },55 { "name": "LANDER", "class_name": "Lander" },56 ],57 },58 "containers": [59 {60 "class_name": "Checker",61 "scheduling_policy": "durable_object",62 "images": {63 "check": { "dockerfile": "./images/check.Dockerfile" },64 },65 },66 {67 "class_name": "Lander",68 "scheduling_policy": "durable_object",69 "images": {70 "land": {71 "dockerfile": "./images/land.Dockerfile",72 "build_context": "../..",73 },74 },75 },76 ],77 },78 "demo": {79 "durable_objects": {80 "bindings": [81 { "name": "CHECKER", "class_name": "Checker" },82 { "name": "LANDER", "class_name": "Lander" },83 ],84 },85 "containers": [86 {87 "class_name": "Checker",88 "scheduling_policy": "durable_object",89 "images": {90 "check": { "dockerfile": "./images/check.Dockerfile" },91 },92 },93 {94 "class_name": "Lander",95 "scheduling_policy": "durable_object",96 "images": {97 "land": {98 "dockerfile": "./images/land.Dockerfile",99 "build_context": "../..",100 },101 },102 },103 ],104 },105 },106}
added:packages/checks/src/check-runner/wire.ts+35 added
1/**2 * What crosses the service binding between the platform and the sandbox3 * Worker for a check: the job, with the one remote the Checker clones from,4 * and the run's outcome on the way back. Both sides decode with these5 * schemas (principle 2): the platform encodes the job and decodes the6 * outcome (W3 314); the sandbox does the reverse (W3 315).7 */8import { VerifierBlocked } from "@repo/protocol/refusal";9import { Schema } from "effect";1011import { CheckJob, CheckRun } from "../check-runner.ts";1213/**14 * Where a sandbox job reaches one repo: its git URL and a token the platform15 * minted for this job alone. The token is redacted wherever it is printed,16 * and a Checker's never enters its container: the outbound handler adds it17 * (W3 315).18 */19export const Remote = Schema.Struct({20 token: Schema.RedactedFromValue(Schema.String),21 url: Schema.NonEmptyString,22});2324export type Remote = typeof Remote.Type;2526/** A check job as the platform sends it: the job and a read token for its repo. */27export const CheckWire = Schema.Struct({ clone: Remote, job: CheckJob });2829/**30 * A check's outcome as it comes back: the run, `VerifierBlocked`, or a31 * defect, as JSON.32 */33export const CheckExit = Schema.toCodecJson(34 Schema.Exit(CheckRun, VerifierBlocked, Schema.Defect())35);
added:packages/checks/src/evidence-store/memory.ts+39 added
1/**2 * `EvidenceStore` in memory: it keeps each log under its name and records3 * every `put` in order, so a test can assert what a run kept.4 */5import { Context, Effect, Layer, Option, Ref } from "effect";67import { EvidenceStore, logRefOf } from "../evidence-store.ts";8import type { LaneLog } from "../evidence-store.ts";910/** Every log the memory store was given, in order, replays included. */11export class EvidenceKept extends Context.Service<12 EvidenceKept,13 { readonly puts: Effect.Effect<readonly LaneLog[]> }14>()("checks/EvidenceKept") {}1516/** A fresh, empty store each time the layer is built, and its record. */17export const EvidenceStoreMemory: Layer.Layer<EvidenceStore | EvidenceKept> =18 Layer.effectContext(19 Effect.gen(function* () {20 const puts = yield* Ref.make<readonly LaneLog[]>([]);2122 return Context.make(EvidenceStore, {23 get: (ref) =>24 Effect.map(Ref.get(puts), (kept) =>25 Option.map(26 Option.fromUndefinedOr(27 kept.findLast((log) => logRefOf(log) === ref)28 ),29 ({ text }) => text30 )31 ),32 put: (log) =>33 Effect.as(34 Ref.update(puts, (kept) => [...kept, log]),35 logRefOf(log)36 ),37 }).pipe(Context.add(EvidenceKept, { puts: Ref.get(puts) }));38 })39 );
added:packages/checks/src/evidence-store.ts+46 added
1/**2 * The `EvidenceStore` port: where a lane's raw log goes, so a3 * `LaneResult.logRef` (and a `ChecksFailed.logRef`) names something real and4 * the log itself never travels to an answerer (spec §2.3 `LaneResult`).5 *6 * Adapters: `/memory` here, for tests and the Worker until W4 418 adds the7 * R2 adapter over the `evidence-<stage>` bucket (spec §4.4).8 */9import type { LaneName, ProjectName, RequestId } from "@repo/protocol/ids";10import { Context, Schema } from "effect";11import type { Effect, Option } from "effect";1213/**14 * A kept log's name: `<project>/<requestId>/<lane>#<attempt>`. It is15 * deterministic, so a replayed step overwrites its log, never adds a second16 * one (principle 8).17 */18export const LogRef = Schema.NonEmptyString.pipe(Schema.brand("LogRef"));1920export type LogRef = typeof LogRef.Type;2122/** One lane's log from one attempt at one answer request. */23export interface LaneLog {24 readonly project: ProjectName;25 readonly requestId: RequestId;26 readonly lane: LaneName;27 readonly attempt: number;28 readonly text: string;29}3031/** The name a lane's log is kept under, whichever adapter keeps it. */32export const logRefOf = (log: Omit<LaneLog, "text">): LogRef =>33 LogRef.make(`${log.project}/${log.requestId}/${log.lane}#${log.attempt}`);3435export class EvidenceStore extends Context.Service<36 EvidenceStore,37 {38 /** Keeps the log, replacing any kept under the same name. */39 readonly put: (log: LaneLog) => Effect.Effect<LogRef>;40 /**41 * A kept log, for deciders only: callers check the audience; the port42 * does not.43 */44 readonly get: (ref: LogRef) => Effect.Effect<Option.Option<string>>;45 }46>()("checks/EvidenceStore") {}
added:packages/checks/test/evidence-store-memory.test.ts+60 added
1import { describe, expect, it } from "@effect/vitest";2import { LaneName, ProjectName, RequestId } from "@repo/protocol/ids";3import { Effect, Option } from "effect";45import { EvidenceStore, LogRef } from "../src/evidence-store.ts";6import {7 EvidenceKept,8 EvidenceStoreMemory,9} from "../src/evidence-store/memory.ts";1011const unitLog = {12 attempt: 1,13 lane: LaneName.make("unit"),14 project: ProjectName.make("datekit"),15 requestId: RequestId.make("push-0123456789"),16 text: "FAIL test/parse.test.ts > parses ISO weeks\nexpected 52 to be 53",17};1819describe("EvidenceStore in memory", () => {20 it.effect("names a lane's log by project, request, lane and attempt", () =>21 Effect.gen(function* () {22 const store = yield* EvidenceStore;2324 const ref = yield* store.put(unitLog);2526 expect(ref).toBe("datekit/push-0123456789/unit#1");27 expect(yield* store.get(ref)).toStrictEqual(Option.some(unitLog.text));28 }).pipe(Effect.provide(EvidenceStoreMemory))29 );3031 it.effect(32 "overwrites a replayed attempt's log under the same name, never a second one",33 () =>34 Effect.gen(function* () {35 const store = yield* EvidenceStore;3637 const first = yield* store.put(unitLog);38 const replayed = yield* store.put({ ...unitLog, text: "replayed" });39 const second = yield* store.put({ ...unitLog, attempt: 2 });4041 expect([first, replayed, second]).toStrictEqual([42 "datekit/push-0123456789/unit#1",43 "datekit/push-0123456789/unit#1",44 "datekit/push-0123456789/unit#2",45 ]);46 expect(yield* store.get(first)).toStrictEqual(Option.some("replayed"));47 expect(yield* (yield* EvidenceKept).puts).toHaveLength(3);48 }).pipe(Effect.provide(EvidenceStoreMemory))49 );5051 it.effect("has nothing under a name it never kept", () =>52 Effect.gen(function* () {53 const store = yield* EvidenceStore;5455 expect(56 yield* store.get(LogRef.make("datekit/push-0123456789/lint#1"))57 ).toStrictEqual(Option.none());58 }).pipe(Effect.provide(EvidenceStoreMemory))59 );60});
added:packages/project/src/front-page/memory.ts+51 added
1/**2 * `FrontPage` in memory, seeded from data: what tests read the front page,3 * the project list and credits from (W3 312, 317). It filters as the D14 * adapter does and never changes.5 */6import type {7 FrontPageEntry,8 ProjectListing,9} from "@repo/protocol/domain/front-page";10import type { CreditSummary } from "@repo/protocol/domain/record";11import { sameHandle } from "@repo/protocol/ids";12import type { Handle } from "@repo/protocol/ids";13import { Effect, Layer } from "effect";1415import { FrontPage } from "../front-page.ts";16import type { FrontPageFilter } from "../front-page.ts";1718/** What the memory front page reads back. */19export interface FrontPageSeed {20 readonly projects: readonly ProjectListing[];21 readonly entries: readonly FrontPageEntry[];22 /** Each credit, with the person it credits. */23 readonly credits: readonly {24 readonly handle: Handle;25 readonly credit: CreditSummary;26 }[];27}2829const matches =30 (filter: FrontPageFilter) =>31 ({ ask }: FrontPageEntry) =>32 (filter.kind === undefined || ask.kind === filter.kind) &&33 (filter.reserved === undefined || ask.reserve === filter.reserved);3435export const FrontPageMemory = {36 layer: (seed: FrontPageSeed): Layer.Layer<FrontPage> =>37 Layer.succeed(38 FrontPage,39 FrontPage.of({40 credits: (handle) =>41 Effect.succeed(42 seed.credits.flatMap((kept) =>43 sameHandle(kept.handle, handle) ? [kept.credit] : []44 )45 ),46 entries: (filter) =>47 Effect.succeed(seed.entries.filter(matches(filter))),48 projects: () => Effect.succeed(seed.projects),49 })50 ),51};
added:packages/project/src/lander/wire.ts+150 added
1/**2 * What crosses the service binding between the platform and the sandbox3 * Worker for each `Lander` job (`merge`, `land`, `compose`, `bundleRules`):4 * the job as the port takes it, the remotes the platform mints tokens for,5 * and the job's outcome on the way back. Both sides decode with these6 * schemas (principle 2): the platform encodes jobs and decodes outcomes7 * (W3 314); the sandbox's Lander does the reverse (W3 306).8 *9 * Each job schema decodes to the port's own argument type (`satisfies`10 * below), so the wire and the port cannot drift apart.11 */12import { Remote } from "@repo/checks/check-runner/wire";13import { Verdict } from "@repo/protocol/domain/answer";14import {15 CommitSha,16 Handle,17 LandedSha,18 RepoName,19 RepoPath,20 RequestId,21 TreeSha,22} from "@repo/protocol/ids";23import { RepoBusy, StaleBase, VerifierBlocked } from "@repo/protocol/refusal";24import { ConfigBundle } from "@repo/rules/rules-evaluator";25import { Schema } from "effect";2627import type {28 BundleJob as BundleJobArgs,29 ComposeJob as ComposeJobArgs,30 Composed as ComposedResult,31 LandJob as LandJobArgs,32 Landed as LandedResult,33 Merged as MergedResult,34 MergeJob as MergeJobArgs,35} from "../lander.ts";36import { Change } from "../landing.ts";3738export { Remote } from "@repo/checks/check-runner/wire";3940export { ConfigBundle } from "@repo/rules/rules-evaluator";4142/** One file a decider adds at its path. */43export const ComposedFile = Schema.Struct({44 content: Schema.String,45 path: RepoPath,46});4748export const MergeJob = Schema.Struct({49 base: CommitSha,50 fork: RepoName,51 head: CommitSha,52 main: LandedSha,53 repo: RepoName,54}) satisfies Schema.Codec<MergeJobArgs, unknown, unknown, unknown>;5556export const Merged = Schema.Struct({57 changes: Schema.Array(Change),58 tree: TreeSha,59}) satisfies Schema.Codec<MergedResult, unknown, unknown, unknown>;6061/** How a stateless Lander rebuilds the tree it lands (the port's `Rebuild`). */62export const Rebuild = Schema.TaggedUnion({63 Compose: { files: Schema.NonEmptyArray(ComposedFile) },64 Existing: { commit: CommitSha },65 Merge: { base: CommitSha, fork: RepoName, head: CommitSha },66});6768export const LandJob = Schema.Struct({69 author: Handle,70 main: LandedSha,71 message: Schema.String,72 rebuild: Rebuild,73 repo: RepoName,74 requestId: RequestId,75 tree: TreeSha,76 verdict: Schema.OptionFromOptionalKey(Verdict),77}) satisfies Schema.Codec<LandJobArgs, unknown, unknown, unknown>;7879export const Landed = Schema.Struct({80 pending: Schema.Array(Schema.Literals(["mirror", "notes"])),81 sha: LandedSha,82}) satisfies Schema.Codec<LandedResult, unknown, unknown, unknown>;8384export const ComposeJob = Schema.Struct({85 files: Schema.NonEmptyArray(ComposedFile),86 main: LandedSha,87 repo: RepoName,88}) satisfies Schema.Codec<ComposeJobArgs, unknown, unknown, unknown>;8990export const Composed = Schema.Struct({91 commit: CommitSha,92 tree: TreeSha,93}) satisfies Schema.Codec<ComposedResult, unknown, unknown, unknown>;9495export const BundleJob = Schema.Struct({96 at: LandedSha,97 repo: RepoName,98}) satisfies Schema.Codec<BundleJobArgs, unknown, unknown, unknown>;99100/** A merge: read tokens on canonical and on the answer's fork. */101export const MergeWire = Schema.Struct({102 fork: Remote,103 job: MergeJob,104 main: Remote,105});106107/**108 * A land: a write token on canonical, which goes only to the trusted Lander,109 * never to a Checker or outside the platform's Workers (S1 change 2); a read110 * token on the fork when the rebuild is a merge.111 */112export const LandWire = Schema.Struct({113 fork: Schema.optionalKey(Remote),114 job: LandJob,115 main: Remote,116});117118/** A compose: a write token on canonical, used only for a compose ref, never `main`. */119export const ComposeWire = Schema.Struct({ job: ComposeJob, main: Remote });120121/** A bundle of the config folder: a read token on canonical. */122export const BundleWire = Schema.Struct({ job: BundleJob, main: Remote });123124/** A merge's outcome as it comes back: the merged tree, a refusal, or a defect, as JSON. */125export const MergeExit = Schema.toCodecJson(126 Schema.Exit(127 Merged,128 Schema.Union([StaleBase, VerifierBlocked]),129 Schema.Defect()130 )131);132133/** A land's outcome as it comes back, as JSON. */134export const LandExit = Schema.toCodecJson(135 Schema.Exit(136 Landed,137 Schema.Union([StaleBase, RepoBusy, VerifierBlocked]),138 Schema.Defect()139 )140);141142/** A compose's outcome as it comes back, as JSON. */143export const ComposeExit = Schema.toCodecJson(144 Schema.Exit(Composed, VerifierBlocked, Schema.Defect())145);146147/** A bundle's outcome as it comes back, as JSON. */148export const BundleExit = Schema.toCodecJson(149 Schema.Exit(ConfigBundle, VerifierBlocked, Schema.Defect())150);
added:packages/project/src/front-page.ts+40 added
1/**2 * The `FrontPage` port: the read side of the projection every project feeds3 * (the write side is `Projection`, whose rows come from each project's4 * outbox). The front page, the project list and a person's credits read from5 * here without waking any project.6 *7 * Adapters: `/memory` here, seeded from data, for tests; `projection-d1`8 * (W3 309, W5 514) over D1 in the Worker.9 */10import type { Reserve } from "@repo/protocol/domain/ask";11import type {12 FrontPageEntry,13 ProjectListing,14} from "@repo/protocol/domain/front-page";15import type { CreditSummary } from "@repo/protocol/domain/record";16import type { Handle, KindName } from "@repo/protocol/ids";17import { Context } from "effect";18import type { Effect } from "effect";1920/** Which open asks to list: one kind, or the ones held for newcomers or for people. */21export interface FrontPageFilter {22 readonly kind?: KindName;23 readonly reserved?: Reserve;24}2526export class FrontPage extends Context.Service<27 FrontPage,28 {29 /** Every project, with its posture and how many asks it has open. */30 readonly projects: () => Effect.Effect<readonly ProjectListing[]>;31 /** The open asks across every project, as the anonymous viewer sees them. */32 readonly entries: (33 filter: FrontPageFilter34 ) => Effect.Effect<readonly FrontPageEntry[]>;35 /** A person's credits across every project, by project, area and role. */36 readonly credits: (37 handle: Handle38 ) => Effect.Effect<readonly CreditSummary[]>;39 }40>()("project/FrontPage") {}
added:packages/project/test/front-page-memory.test.ts+84 added
1import { describe, expect, it } from "@effect/vitest";2import type { FrontPageEntry } from "@repo/protocol/domain/front-page";3import { AskId, Handle, KindName, ProjectName } from "@repo/protocol/ids";4import { Effect } from "effect";56import { FrontPage } from "../src/front-page.ts";7import { FrontPageMemory } from "../src/front-page/memory.ts";89const datekit = ProjectName.make("datekit");1011const entry = (12 ask: string,13 kind: string,14 reserve?: "newcomers" | "people"15): FrontPageEntry => {16 const listing = {17 ask: AskId.make(ask),18 blockedBy: [],19 claimed: false,20 kind: KindName.make(kind),21 territory: "src/parse",22 want: `${ask} works`,23 };2425 return {26 ask: reserve === undefined ? listing : { ...listing, reserve },27 posture: "open",28 project: datekit,29 takeable: reserve === undefined,30 };31};3233const parseIso = entry("parse-iso", "fix");3435const weekStart = entry("week-start", "fix", "newcomers");3637const noAny = entry("no-any", "lintToZero", "people");3839const credit = {40 area: "src/parse",41 count: 2,42 project: datekit,43 role: "Signed-off-by" as const,44};4546const seeded = FrontPageMemory.layer({47 credits: [{ credit, handle: Handle.make("alice") }],48 entries: [parseIso, weekStart, noAny],49 projects: [{ openAsks: 3, posture: "open", project: datekit }],50});5152describe("FrontPage in memory", () => {53 it.effect("lists the open asks it was seeded with, by kind or reserve", () =>54 Effect.gen(function* () {55 const front = yield* FrontPage;5657 expect(yield* front.entries({})).toStrictEqual([58 parseIso,59 weekStart,60 noAny,61 ]);62 expect(63 yield* front.entries({ kind: KindName.make("lintToZero") })64 ).toStrictEqual([noAny]);65 expect(yield* front.entries({ reserved: "newcomers" })).toStrictEqual([66 weekStart,67 ]);68 }).pipe(Effect.provide(seeded))69 );7071 it.effect("reads a person's credits whatever case their handle is in", () =>72 Effect.gen(function* () {73 const front = yield* FrontPage;7475 expect(yield* front.credits(Handle.make("Alice"))).toStrictEqual([76 credit,77 ]);78 expect(yield* front.credits(Handle.make("bob"))).toStrictEqual([]);79 expect(yield* front.projects()).toStrictEqual([80 { openAsks: 3, posture: "open", project: datekit },81 ]);82 }).pipe(Effect.provide(seeded))83 );84});
modified:packages/project/package.json+5 added
19 unmodified lines
20 "./answer-runs": "./src/answer-runs.ts",21 "./answer-runs/inline": "./src/answer-runs/inline.ts",22 "./projection": "./src/projection.ts",23 "./projection/memory": "./src/projection/memory.ts",24 "./front-page": "./src/front-page.ts",25 "./front-page/memory": "./src/front-page/memory.ts",26 "./projection-d1/*": "./src/projection-d1/*.ts",27 "./lander/wire": "./src/lander/wire.ts",28 "./attention/*": "./src/attention/*.ts",29 "./*": "./src/*.ts"30 },31 "scripts": {32 "typecheck": "tsc --noEmit -p tsconfig.json",33 "test": "vitest run"34 },35 "dependencies": {36 "@effect/sql-d1": "4.0.1",37 "@repo/artifacts": "workspace:*",38 "@repo/brand": "workspace:*",39 "@repo/checks": "workspace:*",40 "@repo/gate": "workspace:*",
16 unmodified lines
added:packages/testkit/src/untouchable.ts+42 added
1/**2 * A stand-in for a Workers binding, or any runtime object, handed to code a3 * test expects not to use it: every read throws and names the member, so the4 * test proves what a call touches (a fake env's bindings, a Worker's5 * context). The members `known` gives read as given. Symbols and `then` read6 * as absent: printing a value or resolving a promise with it is not a use.7 *8 * Like everything in `@repo/testkit`, this module is for `test/` directories9 * only: no `src/` imports it (`imports:check` refuses one).10 */11import { Predicate } from "effect";1213/** What reading `name.member` hit: a member the test did not give. */14export class TouchedError extends Error {15 constructor(name: string, member: string) {16 super(`a test touched ${name}.${member}`);17 this.name = "TouchedError";18 }19}2021export const untouchable = <T extends object>(22 name: string,23 known: Partial<T> = {}24): T => {25 const members = new Map(Object.entries(known));2627 return new Proxy<T>(28 // oxlint-disable-next-line typescript/no-unsafe-argument -- a fake whose every read throws has no members to type, so its target is a bare object; `known` holds the only members a caller sees.29 Object.create(null),30 {31 get: (_target, key) => {32 const member = Predicate.isString(key) ? members.get(key) : undefined;3334 if (member !== undefined || Predicate.isSymbol(key) || key === "then") {35 return member;36 }3738 throw new TouchedError(name, key);39 },40 }41 );42};
added:packages/testkit/test/untouchable.test.ts+38 added
1import { describe, expect, it } from "@effect/vitest";2import { Effect } from "effect";34import { TouchedError, untouchable } from "../src/untouchable.ts";56interface Counter {7 readonly count: () => number;8 readonly reset: () => void;9}1011describe(untouchable, () => {12 it("throws on any member a test did not give, naming it", () => {13 const counter = untouchable<Counter>("COUNTER");1415 expect(() => {16 counter.reset();17 }).toThrow(new TouchedError("COUNTER", "reset"));18 });1920 it("reads the members a test gave", () => {21 const counter = untouchable<Counter>("COUNTER", { count: () => 3 });2223 expect(counter.count()).toBe(3);24 expect(() => {25 counter.reset();26 }).toThrow(TouchedError);27 });2829 it.effect("resolves a promise without a read", () =>30 Effect.gen(function* () {31 const counter = untouchable<Counter>("COUNTER");3233 expect(yield* Effect.promise(() => Promise.resolve(counter))).toBe(34 counter35 );36 })37 );38});
modified:scripts/lib/imports.ts+7 added
141 unmodified lines
142 "@repo/sandbox": [143 "@repo/brand",144 "@repo/checks",145 "@repo/git",146 "@repo/project",147 "@repo/protocol",148 "@repo/rules",149 "@repo/visibility",150 ],
30 unmodified lines
181 * importer, then imported package. `*` matches the rest of a subpath.182 */183export const OnlySubpaths = {184 "@repo/gate": { "@repo/checks": ChecksPureSubpaths },185 // Both sides of the platform's service binding decode the Lander's jobs186 // with one schema; the sandbox takes nothing else of the project.187 "@repo/sandbox": {188 "@repo/project": ["lander/wire"],189 "@repo/rules": ["rules-evaluator"],190 },191 "@repo/sdk": { "@repo/protocol": ["domain/*"] },192} as const satisfies Readonly<193 Record<string, Readonly<Record<string, readonly string[]>>>194>;
900 unmodified lines
modified:scripts/startup-budget.ts+4 added-1 removed
13 unmodified lines
1415const javascriptBudget = 2_500_000;1617/** Each Worker, and the file its `main` bundles to. */18const workers = [{ dir: "apps/platform", entry: "worker.js" }] as const;18const workers = [19 { dir: "apps/platform", entry: "worker.js" },20 { dir: "apps/sandbox", entry: "worker.js" },21] as const;2223class BuildFailed extends Data.TaggedError("BuildFailed")<{24 readonly worker: string;25 readonly exitCode: number;
79 unmodified lines
modified:bun.lock+53 added
37 unmodified lines
38 },39 "apps/platform": {40 "name": "@repo/platform",41 "dependencies": {42 "@cloudflare/workers-oauth-provider": "1.2.1",43 "@effect/sql-d1": "4.0.1",44 "@effect/sql-sqlite-do": "4.0.1",45 "@repo/artifacts": "workspace:*",46 "@repo/brand": "workspace:*",47 "@repo/checks": "workspace:*",48 "@repo/gate": "workspace:*",49 "@repo/git": "workspace:*",50 "@repo/project": "workspace:*",51 "@repo/protocol": "workspace:*",52 "@repo/rules": "workspace:*",53 "effect": "catalog:",54 },55 "devDependencies": {56 "@cloudflare/workers-types": "5.20261006.1",57 "@effect/platform-node": "4.0.1",58 "@effect/sql-sqlite-node": "4.0.1",59 "@effect/vitest": "catalog:",60 "@repo/config": "workspace:*",61 "@repo/testkit": "workspace:*",62 "@varlock/cloudflare-integration": "1.6.0",63 "typescript": "catalog:",64 "vitest": "catalog:",65 "wrangler": "4.147.0",66 },67 },68 "apps/sandbox": {69 "name": "@repo/sandbox",70 "dependencies": {71 "@cloudflare/sandbox": "1.0.0",72 "@repo/brand": "workspace:*",73 "@repo/checks": "workspace:*",74 "@repo/git": "workspace:*",75 "@repo/project": "workspace:*",76 "@repo/protocol": "workspace:*",77 "@repo/rules": "workspace:*",78 "effect": "catalog:",79 },80 "devDependencies": {81 "@cloudflare/workers-types": "5.20261006.1",82 "@effect/platform-node": "4.0.1",83 "@effect/vitest": "catalog:",84 "@repo/config": "workspace:*",85 "@repo/testkit": "workspace:*",86 "typescript": "catalog:",87 "vitest": "catalog:",88 "wrangler": "4.147.0",89 },90 },91 "packages/artifacts": {92 "name": "@repo/artifacts",93 "dependencies": {94 "@repo/protocol": "workspace:*",
84 unmodified lines
179 },180 "packages/project": {181 "name": "@repo/project",182 "dependencies": {183 "@effect/sql-d1": "4.0.1",184 "@repo/artifacts": "workspace:*",185 "@repo/brand": "workspace:*",186 "@repo/checks": "workspace:*",187 "@repo/gate": "workspace:*",
106 unmodified lines
294 "@cloudflare/kv-asset-handler": ["@cloudflare/kv-asset-handler@0.5.0", "", {}, "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg=="],295296 "@cloudflare/runtime-types": ["@cloudflare/runtime-types@0.1.7", "", { "dependencies": { "miniflare": "5.20261001.0-alpha", "workerd": "1.20261001.1" } }, "sha512-avgC1wfTunbVea8HOq4ygiQ0WFQVNxcUHOQvH9TM47+0NTdsVTqB8rPQg6Tb5BfVkcWh/a0RAjk+Elr/h35mtQ=="],297298 "@cloudflare/sandbox": ["@cloudflare/sandbox@1.0.0", "", { "dependencies": { "aws4fetch": "1.0.20", "zod": "4.5.4" } }, "sha512-+TZVuCey6OBDTvPLWisq4Ie7/R5Zy3zFyYOFCNRpdEIyQsKq3xwzpctonE43DfZ+wYZvvu6QYpR138PayDjF+A=="],299300 "@cloudflare/unenv-preset": ["@cloudflare/unenv-preset@2.16.2", "", { "peerDependencies": { "unenv": "2.0.0-rc.24", "workerd": ">1.20260305.0 <2.0.0-0" }, "optionalPeers": ["workerd"] }, "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ=="],301302 "@cloudflare/workerd-darwin-64": ["@cloudflare/workerd-darwin-64@1.20261001.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-4cgSgDf28JSw/P5Dj5GCS59hzVqS5XnmGAWNkvYHLI6ODU9idGaMMNEuhJXDkEG/lsABmlVlnCgsdh2VbKWepw=="],303
4 unmodified lines
308 "@cloudflare/workerd-linux-arm64": ["@cloudflare/workerd-linux-arm64@1.20261001.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-oOk3Zj6k/8oP0FJgZBWDn7+BqbsqIMEMaV95pulHPVbwVu4wYoLfQq2hp0vkbCNsCFLqZb7cqixXdrwD54ZIow=="],309310 "@cloudflare/workerd-windows-64": ["@cloudflare/workerd-windows-64@1.20261001.1", "", { "os": "win32", "cpu": "x64" }, "sha512-uRxm5W4VyBkoSaoP1BfOuH0873tE+vxsknF4sab6/5YIRvIAufChq3QDp+zlAn67PuGPGcn7W8QraA0t4ucmOQ=="],311312 "@cloudflare/workers-oauth-provider": ["@cloudflare/workers-oauth-provider@1.2.1", "", {}, "sha512-5bw7JJI9Nd4ArHfNnvTF8H2OpSbA2GbqTmX80ly47h7dR+atgjFsn9Wfz+biKlAKClTEUYE0KAr791RkED41VA=="],313314 "@cloudflare/workers-types": ["@cloudflare/workers-types@5.20261006.1", "", {}, "sha512-5OclwQK1d8f5LCPvOlyldC3ryKLUa4nLXegcgPZeUxAPudczQ9xujJDdpS2Tenp7JqbBLW3OgGciHJmuc7QShg=="],315316 "@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],317
2 unmodified lines
320 "@effect/platform-node": ["@effect/platform-node@4.0.1", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.1", "undici": "^8.11.2" }, "peerDependencies": { "effect": "^4.0.1", "redis": ">=5.0.0 <7.0.0" } }, "sha512-FT0Fu5LO0/XP9zBpj0HqrtJNLluK4StNKqf6TSulUsjp8FPBsDVXGJiDuyoN5J2yVMT7tgvhxSwaDcObWVRIaQ=="],321322 "@effect/platform-node-shared": ["@effect/platform-node-shared@4.0.1", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.22.0" }, "peerDependencies": { "effect": "^4.0.1" } }, "sha512-VanaejudEhKJ4mpmqnEzdncVUhN6sGSO9ZDND54mRxAlZxj+4dYAWjDTYAy9o4tJo9aALeP2U8cVcOFzEdSeLg=="],323324 "@effect/sql-d1": ["@effect/sql-d1@4.0.1", "", { "dependencies": { "@cloudflare/workers-types": "^5.20260926.1" }, "peerDependencies": { "effect": "^4.0.1" } }, "sha512-//VXATQFso9/y9JFDIfxxctMEwDlZq6RdlKA+q8nXE1N3q24FdBM9NF8BaBHT1G2NY+CB0U0PjqUASgsmcOvXw=="],325326 "@effect/sql-sqlite-do": ["@effect/sql-sqlite-do@4.0.1", "", { "peerDependencies": { "effect": "^4.0.1" } }, "sha512-tS+qQok3xKsycnnhvIDX+6nvlM4Y2ouvru3voOzxtDQqX96NSOMX2xReLf4Feb6GN3jnzgEEtVGDDWk3YLrpsg=="],327328 "@effect/sql-sqlite-node": ["@effect/sql-sqlite-node@4.0.1", "", { "peerDependencies": { "effect": "^4.0.1" } }, "sha512-VBlNvfFRxyyiu1viNygxA0ZVGZcpxBHA3+QLobaLQSXgAP0submgo98IzioWTHzdZUc9Xodi7ICci5ehhbD2fQ=="],329330 "@effect/tsgo": ["@effect/tsgo@0.48.1", "", { "optionalDependencies": { "@effect/tsgo-darwin-arm64": "0.48.1", "@effect/tsgo-darwin-x64": "0.48.1", "@effect/tsgo-linux-arm": "0.48.1", "@effect/tsgo-linux-arm64": "0.48.1", "@effect/tsgo-linux-x64": "0.48.1", "@effect/tsgo-win32-arm64": "0.48.1", "@effect/tsgo-win32-x64": "0.48.1" }, "bin": { "effect-tsgo": "dist/effect-tsgo.cjs" } }, "sha512-yLgXNwPaUWfGxcQw7FwLYwOF7me69r+tY4oHYV5hwMFE16qClXbIRnotNPp8pZ5pnbeLgPeRvCE7AWGQyYqQ2A=="],331
262 unmodified lines
594 "@repo/protocol": ["@repo/protocol@workspace:packages/protocol"],595596 "@repo/rules": ["@repo/rules@workspace:packages/rules"],597598 "@repo/sandbox": ["@repo/sandbox@workspace:apps/sandbox"],599600 "@repo/sdk": ["@repo/sdk@workspace:packages/sdk"],601602 "@repo/testkit": ["@repo/testkit@workspace:packages/testkit"],603
98 unmodified lines
702 "@typescript/typescript-win32-arm64": ["@typescript/typescript-win32-arm64@7.0.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="],703704 "@typescript/typescript-win32-x64": ["@typescript/typescript-win32-x64@7.0.2", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],705706 "@varlock/cloudflare-integration": ["@varlock/cloudflare-integration@1.6.0", "", { "peerDependencies": { "@cloudflare/vite-plugin": ">=1", "varlock": "^1.20.0", "vite": ">=5", "wrangler": ">=3" }, "optionalPeers": ["@cloudflare/vite-plugin", "vite", "wrangler"], "bin": { "varlock-wrangler": "bin/varlock-wrangler.js" } }, "sha512-HPtAQRVQ3AZRMzmnmHBZQaxZS/1tT0bmjbW+J4iALtuKXp8tI3X8EitlXlq4Kv23c2f8qpua4DSUUPxsylIRTw=="],707708 "@varlock/native-helper-darwin": ["@varlock/native-helper-darwin@1.21.1", "", { "os": "darwin" }, "sha512-hh7lB6cO/qEVJTgPY5ebVicwnbM7ROkIWjOkZ+k6PYWaoyj+UrUTymF5nHkqzg0TaZ+EA5z/eboFoZhrbsOHGw=="],709710 "@varlock/native-helper-linux-arm64": ["@varlock/native-helper-linux-arm64@1.21.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-ppN2UIrJKDVALBzZwVXzIokAch8j2eyeABEHZn5LkMS3auXBVdVVkqN9QPIe7/Ii91LIV5mwWMeVJrV1paTI5Q=="],711
20 unmodified lines
732 "async-lock": ["async-lock@1.4.1", "", {}, "sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ=="],733734 "available-typed-arrays": ["available-typed-arrays@1.0.7", "", { "dependencies": { "possible-typed-array-names": "^1.0.0" } }, "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ=="],735736 "aws4fetch": ["aws4fetch@1.0.20", "", {}, "sha512-/djoAN709iY65ETD6LKCtyyEI04XIBP5xVvfmNxsEP0uJB5tyaGBztSryRr4HqMStr9R06PisQE7m9zDTXKu6g=="],737738 "base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],739740 "blake3-wasm": ["blake3-wasm@2.1.5", "", {}, "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g=="],741
356 unmodified lines
1098 "@cloudflare/config/zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],10991100 "@cloudflare/runtime-types/miniflare": ["miniflare@5.20261001.0-alpha", "", { "dependencies": { "@cspotcode/source-map-support": "0.8.1", "sharp": "0.35.4", "undici": "7.29.1", "workerd": "1.20261001.1", "ws": "8.21.0", "youch": "4.1.0-beta.10" } }, "sha512-GaimS5mSIOMyvd16ga+e1/QkI8cmp3z35QPHFex0DktqNQf2RVZQwMPQXdyoUreUiFP/0Gpe2MoQInTyMAD5xA=="],11011102 "@cloudflare/sandbox/zod": ["zod@4.5.4", "", {}, "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA=="],11031104 "@cspotcode/source-map-support/@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.9", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" } }, "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ=="],11051106 "micromatch/picomatch": ["picomatch@2.3.2", "", {}, "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA=="],1107
27 unmodified lines
modified:debt.baseline.json+1 added-1 removed
1 unmodified line
2 "@effect-diagnostics": 0,3 "@ts-expect-error": 0,4 "@ts-ignore": 0,5 "@ts-nocheck": 0,6 "oxlint-disable": 46 "oxlint-disable": 57}
modified:package.json+3 added
29 unmodified lines
30 "brand:check": "bun scripts/brand.ts",31 "bytes:check": "bun scripts/startup-budget.ts",32 "env:check": "varlock load --agent --path infra/",33 "ops": "varlock run --path infra/ -- cf",34 "bootstrap": "varlock run --path infra/ -- bun infra/bootstrap.ts",35 "deploy": "bun infra/deploy.ts",36 "smoke": "bun scripts/smoke.ts",37 "verify": "bun run lockfile:check && bun run check && bun run typecheck && bun run test && bun run gen:check && bun run imports:check && bun run debt && bun run brand:check && bun run bytes:check"38 },39 "devDependencies": {40 "@effect/platform-bun": "catalog:",
16 unmodified lines
modified:tsconfig.base.json+14 added-3 removed
82 unmodified lines
83 ]84 }85 },86 {87 "include": ["packages/config/test/**/*.ts"],87 "include": ["packages/config/test/**/*.ts", "infra/**/*.ts"],88 "options": {89 "allowedUnstableApis": ["effect/process"]89 "allowedUnstableApis": ["effect/http", "effect/process"]90 }91 },92 {93 "include": ["apps/platform/**/*.ts"],94 "options": {95 "allowedUnstableApis": ["effect/ai", "effect/http", "effect/rpc"]95 "allowedUnstableApis": [96 "effect/ai",97 "effect/http",98 "effect/rpc",99 "effect/sql"100 ]101 }102 },103 {104 "include": ["apps/cli/**/*.ts"],
6 unmodified lines
111 ]112 }113 },114 {115 "include": ["apps/sandbox/test/**/*.ts"],116 "options": {117 "allowedUnstableApis": ["effect/process"]118 }119 },120 {121 "include": ["packages/protocol/src/**/*.ts"],122 "options": {123 "allowedUnstableApis": ["effect/ai", "effect/cli", "effect/rpc"]124 }
73 unmodified lines
modified:tsconfig.json+1 added
3 unmodified lines
4 "allowImportingTsExtensions": true5 },6 "include": [7 "*.config.ts",8 "infra/**/*.ts",9 "scripts/**/*.ts",10 "tools/oxlint/fence/**/*.ts",11 ".pi/extensions/**/*.ts"12 ],
8 unmodified lines