Skip to content
Myr

lander-sandbox.ts

This file

Path

apps/platform/src/adapters/lander-sandbox.ts

95 lines · 3.3 KiB · TypeScript

Last changed by

Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8

line 1why, one step back
1// A write token on canonical goes only to `land` (a non-force compare-and-swap) and `compose`, never to a Checker.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 2–78why, one step back
2import { RepoHost } from "@repo/artifacts/repo-host";
3import type { RepoName } from "@repo/artifacts/repo-host";4import { Lander, Rebuild } from "@repo/project/lander";5import {6 BundleExit,7 BundleWire,8 ComposeExit,9 ComposeWire,10 LandExit,11 LandWire,12 MergeExit,13 MergeWire,14} from "@repo/project/lander/wire";15import { Effect, Layer } from "effect";1617import type { SandboxBinding } from "./check-runner-sandbox.ts";18import { sandboxJob, withRemote } from "./sandbox-credentials.ts";19import type { RemoteNeed } from "./sandbox-credentials.ts";2021const read = (repo: RepoName): RemoteNeed => ({ repo, scope: "read" });2223const write = (repo: RepoName): RemoteNeed => ({ repo, scope: "write" });2425const landing = (sandbox: SandboxBinding, wire: typeof LandWire.Type) =>26 sandboxJob({27 exit: LandExit,28 job: wire,29 method: "land",30 remotes: wire.fork === undefined ? [wire.main] : [wire.main, wire.fork],31 send: (encoded) => sandbox.land(encoded),32 wire: LandWire,33 });3435export const LanderSandbox = (36 sandbox: SandboxBinding37): Layer.Layer<Lander, never, RepoHost> =>38 Layer.effect(39 Lander,40 Effect.gen(function* () {41 const host = yield* RepoHost;4243 return Lander.of({44 bundleRules: (job) =>45 withRemote("bundleRules", read(job.repo), (main) =>46 sandboxJob({47 exit: BundleExit,48 job: { job, main },49 method: "bundleRules",50 remotes: [main],51 send: (wire) => sandbox.bundleRules(wire),52 wire: BundleWire,53 })54 ).pipe(Effect.provideService(RepoHost, host)),55 compose: (job) =>56 withRemote("compose", write(job.repo), (main) =>57 sandboxJob({58 exit: ComposeExit,59 job: { job, main },60 method: "compose",61 remotes: [main],62 send: (wire) => sandbox.compose(wire),63 wire: ComposeWire,64 })65 ).pipe(Effect.provideService(RepoHost, host)),66 land: (job) =>67 withRemote("land", write(job.repo), (main) =>68 Rebuild.$match(job.rebuild, {69 Compose: () => landing(sandbox, { job, main }),70 Existing: () => landing(sandbox, { job, main }),71 // Only a merge reads the answer's commits, from its fork.72 Merge: ({ fork }) =>73 withRemote("land", read(fork), (forkRemote) =>74 landing(sandbox, { fork: forkRemote, job, main })75 ),76 })77 ).pipe(Effect.provideService(RepoHost, host)),78 // The merged commit goes to the fork, for the Checker: a write token

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

line 79why, one step back
79 // there, never on canonical.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 80–95why, one step back
80 merge: (job) =>
81 withRemote("merge", read(job.repo), (main) =>82 withRemote("merge", write(job.fork), (fork) =>83 sandboxJob({84 exit: MergeExit,85 job: { fork, job, main },86 method: "merge",87 remotes: [main, fork],88 send: (wire) => sandbox.merge(wire),89 wire: MergeWire,90 })91 )92 ).pipe(Effect.provideService(RepoHost, host)),93 });94 })95 );