Skip to content
Myr

held-back.test.ts

This file

Path

apps/platform/test/visibility/held-back.test.ts

953 lines · 28.2 KiB · TypeScript

Last changed by

Merge observability into mainoscabrielbefore adoption1985111

History of this file

Take it

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

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 1–65why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { ObjectId, RepoHost, RepoNotFound } from "@repo/artifacts/repo-host";3import { RepoHostMemory } from "@repo/artifacts/repo-host/memory";4import { CheckAt, CheckRunner, shaOf } from "@repo/checks/check-runner";5import type { CheckJob } from "@repo/checks/check-runner";6import { CheckExit } from "@repo/checks/check-runner/wire";7import type { CheckWire } from "@repo/checks/check-runner/wire";8import { EvidenceKept } from "@repo/checks/evidence-store/memory";9import { parseTrailers } from "@repo/git/trailers";10import { AnswerView, Verdict } from "@repo/protocol/domain/answer";11import type { HeldBackResult } from "@repo/protocol/domain/answer";12import { Command } from "@repo/protocol/domain/common";13import { ProjectEvent } from "@repo/protocol/domain/event";14import { Outcome } from "@repo/protocol/domain/outcome";15import {16 EnvKey,17 LandedSha,18 LaneName,19 RepoName,20 RepoPath,21 RequestId,22 SuiteRoot,23 TreeSha,24} from "@repo/protocol/ids";25import type { CommitSha } from "@repo/protocol/ids";26import {27 AttemptsExhausted,28 ChecksFailed,29 HeldBackFailed,30 LayerContentInPublicTree,31 PrivatePathInPublicTree,32 VerifierBlocked,33} from "@repo/protocol/refusal";34import type { Files } from "@repo/testkit/git-client";35import { untouchable } from "@repo/testkit/untouchable";36import {37 Array,38 Effect,39 Exit,40 Layer,41 Option,42 Redacted,43 Ref,44 Schema,45 Struct,46} from "effect";4748import { CheckRunnerSandbox } from "../../src/adapters/check-runner-sandbox.ts";49import type { SandboxBinding } from "../../src/adapters/check-runner-sandbox.ts";50import { decodeEnv } from "../../src/platform.ts";51import { workerPorts } from "../../src/ports.ts";52import { LandingGuards } from "../../src/workflows/answer/guards.ts";53import { withheld } from "../../src/workflows/answer/lanes.ts";54import { runAnswer } from "../../src/workflows/answer/program.ts";55import { notesRef } from "../../src/workflows/notes.ts";56import { memoSteps } from "../../src/workflows/step.ts";57import type { StepRunner } from "../../src/workflows/step.ts";58import { fakeEnv } from "../fake-env.ts";59import {60 admitted,61 alice,62 askLane,63 bob,64 bobFork,65 changed,

Merge observability into mainoscabrielbefore adoption1985111

line 66why, one step back
66 checkedStages,

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 67–210why, one step back
67 Checker,
68 finishRequired,69 fixed,70 LanderCalls,71 lexPath,72 logged,73 mainMoved,74 mainTip,75 openedFiles,76 parseIso,77 parsePath,78 policy,79 project,80 Pusher,81 repo,82 scriptProjectLanes,83 Started,84 verdictOf,85} from "../workflows/answer.fixtures.ts";86import type { Admitted } from "../workflows/answer.fixtures.ts";87import {88 exportArea,89 heldBackJob,90 maintainers,91 parserArea,92 resetsAt,93 sealedFiles,94 Sealed,95 sealedWorld,96 suiteRoot,97} from "./held-back.fixtures.ts";9899const run = (answer: Admitted) =>100 Effect.flatMap(memoSteps(), (steps) =>101 runAnswer({ project, requestId: answer.requestId }).pipe(102 Effect.provide(steps)103 )104 );105106const allGreen = (at: CheckAt) =>107 Effect.andThen(108 scriptProjectLanes(at, { result: "passed" }),109 Checker.use((script) => script.script(at, askLane, [{ result: "passed" }]))110 );111112const failing = (...areas: readonly (typeof exportArea)[]) =>113 Sealed.use(({ failing: next }) => Ref.set(next, new Set(areas)));114115const decodeVerdict = Schema.decodeUnknownEffect(116 Schema.fromJsonString(Verdict)117);118119const noteIn = (at: RepoName, commit: CommitSha) =>120 Effect.gen(function* () {121 const host = yield* RepoHost;122 const tip = (yield* host.refs(at).pipe(Effect.orDie)).get(notesRef);123124 if (tip === undefined) {125 return Option.none();126 }127128 const notes = Option.getOrThrow(129 yield* host.readCommit(at, tip).pipe(Effect.orDie)130 );131132 const entries = Option.getOrThrow(133 yield* host.readTree(at, notes.tree).pipe(Effect.orDie)134 );135136 const entry = entries.find(({ name }) => name === commit);137138 if (entry === undefined) {139 return Option.none();140 }141142 const blob = Option.getOrThrow(143 yield* host.readBlob(at, ObjectId.make(entry.sha)).pipe(Effect.orDie)144 );145146 return Option.some(147 yield* decodeVerdict(new TextDecoder().decode(blob)).pipe(Effect.orDie)148 );149 });150151const noteOn = (head: CommitSha) => noteIn(bobFork, head);152153const answerAgain = (answer: Admitted, files: Files) =>154 Effect.gen(function* () {155 const head = yield* Pusher.use((each) =>156 each.push(bobFork, Option.some(answer.head), files)157 );158159 const merged = yield* LanderCalls.use((calls) =>160 calls.preview({161 base: answer.opened,162 fork: bobFork,163 head,164 main: answer.opened,165 repo,166 })167 );168169 const receipt = yield* answer.api.submitAnswer(bob, {170 ask: parseIso,171 base: answer.opened,172 head,173 requestId: RequestId.make(`push-${head}`),174 });175176 yield* allGreen(merged);177178 return { ...answer, head, merged, requestId: receipt.requestId };179 }).pipe(Effect.orDie);180181describe("the held-back step", () => {182 it.effect(183 "refuses an answer whose public checks pass and whose export check fails, in its verdict, its note and status, and lands nothing",184 () =>185 Effect.gen(function* () {186 const answer = yield* admitted();187188 yield* allGreen(answer.merged);189 yield* failing(exportArea);190191 const outcome = yield* run(answer);192 const { answers } = yield* answer.api.status(bob);193194 const refused = Outcome.cases.Refused.make({195 refusals: [196 new HeldBackFailed({ area: exportArea, suite: suiteRoot }),197 ],198 });199200 expect(outcome).toStrictEqual(refused);201 expect(202 Option.map(203 yield* verdictOf(answer.api),204 ({ outcome: judged }) => judged205 )206 ).toStrictEqual(Option.some(refused));207 expect(208 Option.map(yield* noteOn(answer.head), ({ outcome: noted }) => noted)209 ).toStrictEqual(Option.some(refused));210 expect(answers.map((each) => each.outcome)).toStrictEqual([refused]);

Merge observability into mainoscabrielbefore adoption1985111

lines 211–214why, one step back
211 expect({
212 main: yield* mainTip,213 stages: yield* checkedStages,214 }).toStrictEqual({ main: answer.opened, stages: ["heldBack"] });

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 215–315why, one step back
215 }).pipe(Effect.provide(sealedWorld(policy)))
216 );217218 it.effect(219 "counts one attempt per held-back run, however often the Workflow is replayed or its steps run twice",220 () =>221 Effect.gen(function* () {222 const answer = yield* admitted();223224 yield* allGreen(answer.merged);225 yield* failing(exportArea);226227 const steps = yield* memoSteps();228229 const over = (record: Layer.Layer<StepRunner>) =>230 runAnswer({ project, requestId: answer.requestId }).pipe(231 Effect.provide(record)232 );233234 const twice = Layer.unwrap(235 Effect.map(memoSteps(), (memo) => logged(memo, { twice: true }))236 );237238 const outcomes = [239 yield* over(twice),240 yield* over(steps),241 yield* over(steps),242 ];243244 const second = yield* answerAgain(245 answer,246 changed(247 fixed,248 parsePath,249 "export const parse = (s) => ({ year: 2026, s });\n"250 )251 );252253 expect(outcomes).toStrictEqual([outcomes[0], outcomes[0], outcomes[0]]);254 expect(yield* Sealed.use(({ judged }) => judged)).toBe(1);255 expect(yield* run(second)).toStrictEqual(256 Outcome.cases.Refused.make({257 refusals: [258 new HeldBackFailed({ area: exportArea, suite: suiteRoot }),259 ],260 })261 );262 }).pipe(Effect.provide(sealedWorld(policy)))263 );264265 it.effect(266 "carries a passing held-back result over a moved main to the re-merged tree, whose public lanes run again",267 () =>268 Effect.gen(function* () {269 const answer = yield* admitted();270271 yield* allGreen(answer.merged);272273 const moved = yield* mainMoved(274 answer.opened,275 changed(276 openedFiles,277 lexPath,278 "export const lex = (s) => s.split(/ +/);\n"279 )280 );281282 const remerged = yield* LanderCalls.use(({ preview }) =>283 preview({284 base: answer.opened,285 fork: bobFork,286 head: answer.head,287 main: moved,288 repo,289 })290 );291292 yield* allGreen(remerged);293294 const outcome = yield* run(answer);295 const tip = yield* mainTip;296 const sealedJobs = yield* Sealed.use(({ jobs }) => Ref.get(jobs));297 const { landing } = yield* answer.api.landing(bob, tip);298299 const publicTrees = yield* Checker.use(({ jobs }) =>300 Effect.map(jobs, (all) =>301 Array.dedupe(302 all303 .filter(({ at }) => CheckAt.guards.Tree(at))304 .map(({ at }) => shaOf(at))305 )306 )307 );308309 expect(outcome).toStrictEqual(Outcome.cases.Landed.make({ sha: tip }));310 expect(publicTrees).toStrictEqual([311 shaOf(answer.merged),312 shaOf(remerged),313 ]);314 expect(sealedJobs.map(({ at }) => at)).toStrictEqual([answer.merged]);315 expect(landing.heldBackTrailer).toBe(

Tell stage 1 a pusher reads the layers only when they read every one, and give the no-oracle path rule one owner in the gateoscabrielbefore adoptionf9808ff

line 316why, one step back
316 `export 2/2 @ ${suiteRoot}; parser 1/1 @ ${suiteRoot}`

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 317–418why, one step back
317 );
318 }).pipe(Effect.provide(sealedWorld(policy)))319 );320321 it.effect(322 "waits, counting nothing, when the Checker cannot run the suite",323 () =>324 Effect.gen(function* () {325 const answer = yield* admitted();326327 yield* allGreen(answer.merged);328 yield* Sealed.use(({ blocked }) => Ref.set(blocked, true));329330 const outcome = yield* run(answer);331332 expect(outcome).toStrictEqual(333 Outcome.cases.Checking.make({ stage: "checks" })334 );335 expect(yield* Sealed.use(({ judged }) => judged)).toBe(0);336 expect(yield* mainTip).toBe(answer.opened);337 }).pipe(Effect.provide(sealedWorld(policy)))338 );339340 it.effect(341 "spends the area on the claim's third failed run: AttemptsExhausted",342 () =>343 Effect.gen(function* () {344 const first = yield* admitted();345346 yield* allGreen(first.merged);347 yield* failing(exportArea);348349 const outcomes = [yield* run(first)];350351 const second = yield* answerAgain(352 first,353 changed(354 fixed,355 parsePath,356 "export const parse = (s) => ({ year: 2026, s });\n"357 )358 );359360 outcomes.push(yield* run(second));361362 const third = yield* answerAgain(363 second,364 changed(365 fixed,366 parsePath,367 "export const parse = (s) => ({ year: 2026, t: s });\n"368 )369 );370371 outcomes.push(yield* run(third));372373 expect(374 outcomes.map((outcome) =>375 Outcome.guards.Refused(outcome)376 ? outcome.refusals.map(({ _tag }) => _tag)377 : outcome._tag378 )379 ).toStrictEqual([380 ["HeldBackFailed"],381 ["HeldBackFailed"],382 ["AttemptsExhausted"],383 ]);384 expect(outcomes[2]).toStrictEqual(385 Outcome.cases.Refused.make({386 refusals: [new AttemptsExhausted({ area: exportArea, resetsAt })],387 })388 );389 expect(yield* mainTip).toBe(first.opened);390 }).pipe(Effect.provide(sealedWorld(policy)))391 );392393 it.effect(394 "lands an answer that passes every area with the Held-back trailer, from a job that carried the suite and nothing of the layer's",395 () =>396 Effect.gen(function* () {397 const answer = yield* admitted();398399 yield* allGreen(answer.merged);400401 const outcome = yield* run(answer);402 const tip = yield* mainTip;403 const host = yield* RepoHost;404405 const commit = Option.getOrThrow(406 yield* host.readCommit(repo, tip).pipe(Effect.orDie)407 );408409 const { landing } = yield* answer.api.landing(bob, LandedSha.make(tip));410 const jobs = yield* Sealed.use(({ jobs: given }) => Ref.get(given));411 const value = `export 2/2 @ ${suiteRoot}; parser 1/1 @ ${suiteRoot}`;412413 expect(outcome).toStrictEqual(414 Outcome.cases.Landed.make({ sha: LandedSha.make(tip) })415 );416 expect(417 parseTrailers(commit.message).filter(({ key }) => key === "Held-back")418 ).toStrictEqual([{ key: "Held-back", value }]);

Tell stage 1 a pusher reads the layers only when they read every one, and give the no-oracle path rule one owner in the gateoscabrielbefore adoptionf9808ff

line 419why, one step back
419 expect(landing.heldBackTrailer).toBe(value);

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 420–559why, one step back
420 expect(
421 jobs.map((job) => ({422 at: job.at,423 files: job.heldBack?.files.map(({ area, path }) => [area, path]),424 lanes: job.lanes,425 repo: job.repo,426 suite: job.heldBack?.suite,427 }))428 ).toStrictEqual([429 {430 at: answer.merged,431 files: sealedFiles.map(({ area, path }) => [area, path]),432 lanes: [],433 repo: bobFork,434 suite: suiteRoot,435 },436 ]);437 expect(JSON.stringify(jobs)).not.toContain(maintainers);438 }).pipe(Effect.provide(sealedWorld(policy)))439 );440});441442const copied = RepoPath.make("packages/parser/src/copied.ts");443444const copiedContent = sealedFiles[0]?.content ?? "";445446const jobsOn = (at: CheckAt) =>447 Checker.use(({ jobs }) =>448 Effect.map(jobs, (all) => all.filter((job) => shaOf(job.at) === shaOf(at)))449 );450451const encoder = new TextEncoder();452453const blobIdOf = (text: string) =>454 Effect.map(455 Effect.promise(() =>456 crypto.subtle.digest(457 "SHA-1",458 encoder.encode(`blob ${encoder.encode(text).length}\0${text}`)459 )460 ),461 (digest) =>462 ObjectId.make(463 [...new Uint8Array(digest)]464 .map((byte) => byte.toString(16).padStart(2, "0"))465 .join("")466 )467 );468469const forkReads = (470 read: (471 id: ObjectId,472 given: Effect.Effect<Option.Option<Uint8Array>, RepoNotFound>473 ) => Effect.Effect<Option.Option<Uint8Array>, RepoNotFound>474) =>475 Effect.map(Effect.service(RepoHost), (host) =>476 RepoHost.of({477 ...host,478 readBlob: (name, id) =>479 name === bobFork480 ? read(id, host.readBlob(name, id))481 : host.readBlob(name, id),482 })483 );484485describe("the landing guards", () => {486 it.effect(487 "are plugged into the Worker's ports with the cartridge, and nowhere without it",488 () =>489 Effect.gen(function* () {490 const config = yield* decodeEnv(fakeEnv()).pipe(Effect.orDie);491492 const plugged = yield* Effect.scoped(493 Effect.flatMap(Layer.build(workerPorts(config)), (ports) =>494 Effect.provideContext(Effect.service(LandingGuards), ports)495 )496 );497498 expect(Option.isSome(plugged)).toBeTruthy();499 expect(Option.isSome(yield* Effect.service(LandingGuards))).toBeFalsy();500 })501 );502503 it.effect(504 "refuse a push that adds a layer's path at stage 1, before any check runs",505 () =>506 Effect.gen(function* () {507 const answer = yield* admitted();508 const escape = "checks/held-back/export/escape.test.ts";509510 const head = yield* Pusher.use((each) =>511 each.push(512 bobFork,513 Option.some(answer.head),514 changed(fixed, escape, 'it("escapes", () => {});\n')515 )516 );517518 const refusals = yield* answer.api.recordPush({519 after: head,520 before: Option.some(answer.head),521 eventId: "push-escape",522 pusher: bob,523 ref: "refs/heads/main",524 repo: bobFork,525 });526527 expect(refusals.map(({ _tag }) => _tag)).toContain(528 "PrivatePathInPublicTree"529 );530 expect(yield* Started.use(({ ids }) => ids)).toStrictEqual([531 answer.requestId,532 ]);533 }).pipe(Effect.provide(sealedWorld(policy)))534 );535536 it.effect(537 "refuse an admitted answer whose path a layer took since, before any check runs, naming all the answerer's paths to one who cannot read it",538 () =>539 Effect.gen(function* () {540 const taken = RepoPath.make("packages/parser/src/sealed.ts");541542 const answer = yield* admitted(543 changed(fixed, taken, "export const sealed = 1;\n")544 );545546 yield* allGreen(answer.merged);547 yield* Sealed.use(({ layerPaths }) =>548 Ref.update(layerPaths, (paths) => new Set([...paths, taken]))549 );550551 expect(yield* run(answer)).toStrictEqual(552 Outcome.cases.Refused.make({553 refusals: [554 new PrivatePathInPublicTree({ paths: [parsePath, taken] }),555 ],556 })557 );558 expect(yield* jobsOn(answer.merged)).toStrictEqual([]);559 expect(yield* mainTip).toBe(answer.opened);

Merge observability into mainoscabrielbefore adoption1985111

line 560why, one step back
560 expect(yield* checkedStages).toStrictEqual(["shape"]);

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 561–814why, one step back
561 }).pipe(Effect.provide(sealedWorld(policy)))
562 );563564 it.effect(565 "refuse a finish whose finisher reads the layer and adds a file holding a layer's blob: LayerContentInPublicTree",566 () =>567 Effect.gen(function* () {568 const answer = yield* admitted();569570 yield* allGreen(answer.merged);571572 expect(yield* run(answer)).toStrictEqual(573 Outcome.cases.AwaitingFinish.make({})574 );575576 const finished = yield* Pusher.use((each) =>577 each.push(578 bobFork,579 Option.some(answer.head),580 changed(fixed, copied, copiedContent)581 )582 );583584 const receipt = yield* answer.api585 .finish(alice, {586 ask: parseIso,587 base: answer.opened,588 head: finished,589 requestId: RequestId.make(`finish-${finished}`),590 })591 .pipe(Effect.orDie);592593 expect(594 yield* runAnswer({ project, requestId: receipt.requestId }).pipe(595 Effect.provide(yield* memoSteps())596 )597 ).toStrictEqual(598 Outcome.cases.Refused.make({599 refusals: [new LayerContentInPublicTree({ paths: [copied] })],600 })601 );602 }).pipe(Effect.provide(sealedWorld(finishRequired)))603 );604605 it.effect(606 "say nothing of a layer's content to an answerer who cannot read it: the same file lands",607 () =>608 Effect.gen(function* () {609 const answer = yield* admitted(changed(fixed, copied, copiedContent));610611 yield* allGreen(answer.merged);612613 const outcome = yield* run(answer);614615 expect(outcome).toStrictEqual(616 Outcome.cases.Landed.make({ sha: yield* mainTip })617 );618 }).pipe(Effect.provide(sealedWorld(policy)))619 );620621 it.effect(622 "wait, running no check and counting nothing, when the answer's fork cannot be read for the files it writes",623 () =>624 Effect.gen(function* () {625 const answer = yield* admitted();626627 yield* allGreen(answer.merged);628629 const host = yield* forkReads(() =>630 Effect.fail(new RepoNotFound({ name: bobFork }))631 );632633 const outcome = yield* run(answer).pipe(634 Effect.provideService(RepoHost, host)635 );636637 expect(outcome).toStrictEqual(638 Outcome.cases.Checking.make({ stage: "checks" })639 );640 expect(yield* jobsOn(answer.merged)).toStrictEqual([]);641 expect(yield* mainTip).toBe(answer.opened);642 }).pipe(Effect.provide(sealedWorld(policy)))643 );644645 it.effect(646 "scan nothing for a change no blob in the fork holds, a submodule's pointer, and let the answer on",647 () =>648 Effect.gen(function* () {649 const content = "a pointer to a commit in another repo\n";650651 const answer = yield* admitted(652 changed(fixed, "packages/parser/src/tz", content)653 );654655 yield* allGreen(answer.merged);656657 const pointer = yield* blobIdOf(content);658659 const host = yield* forkReads((id, given) =>660 id === pointer ? Effect.succeedNone : given661 );662663 const outcome = yield* run(answer).pipe(664 Effect.provideService(RepoHost, host)665 );666667 expect(outcome).toStrictEqual(668 Outcome.cases.Landed.make({ sha: yield* mainTip })669 );670 }).pipe(Effect.provide(sealedWorld(policy)))671 );672});673674const sentry = EnvKey.make("SENTRY_AUTH_TOKEN");675676const token = "sntrys_0a1b2c3d4e5f6a7b8c9d";677678const stored = (answer: Admitted) =>679 answer.api680 .setEnv(alice, { key: sentry, value: Redacted.make(token) })681 .pipe(Effect.orDie);682683const answererReads = (answer: Admitted) =>684 Effect.gen(function* () {685 const status = yield* answer.api.status(bob);686 const verdict = yield* verdictOf(answer.api);687 const note = yield* noteOn(answer.head);688 const events = yield* answer.api.events(0, 1000);689690 return JSON.stringify([691 yield* Schema.encodeEffect(Schema.toCodecJson(Schema.Array(AnswerView)))(692 status.answers693 ),694 yield* Schema.encodeEffect(Schema.toCodecJson(Schema.Option(Verdict)))(695 verdict696 ),697 yield* Schema.encodeEffect(Schema.toCodecJson(Schema.Option(Verdict)))(698 note699 ),700 yield* Schema.encodeEffect(701 Schema.toCodecJson(Schema.Array(ProjectEvent))702 )(events.map(({ event }) => event)),703 ]);704 }).pipe(Effect.orDie);705706describe("a stored value where it must not be", () => {707 it.effect(708 "quarantines an answer that adds a file holding a stored value: no check runs, it never lands, and nothing its answerer reads names the item",709 () =>710 Effect.gen(function* () {711 const answer = yield* admitted(712 changed(713 fixed,714 "packages/parser/src/report.ts",715 `export const dsn = "https://${token}@sentry.io/1";\n`716 )717 );718719 yield* stored(answer);720 yield* allGreen(answer.merged);721722 const outcome = yield* run(answer);723 const read = yield* answererReads(answer);724725 expect(outcome).toStrictEqual(726 Outcome.cases.Refused.make({ refusals: [new VerifierBlocked({})] })727 );728 expect(yield* jobsOn(answer.merged)).toStrictEqual([]);729 expect(yield* mainTip).toBe(answer.opened);730 expect(read).not.toContain(sentry);731 expect(read).not.toContain(token);732 }).pipe(Effect.provide(sealedWorld(policy)))733 );734735 it.effect(736 "keeps a lane log holding a stored value out of the evidence: its lane still refuses, under a withheld log, and nothing its answerer reads names the item",737 () =>738 Effect.gen(function* () {739 const answer = yield* admitted();740 const unit = LaneName.make("unit");741742 yield* stored(answer);743 yield* allGreen(answer.merged);744 yield* Checker.use((script) =>745 Effect.andThen(746 script.script(answer.merged, unit, [747 {748 result: "failed",749 signature: `reports: AssertionError: expected "${token}" to be redacted`,750 },751 ]),752 script.script(753 CheckAt.cases.Commit.make({ commit: answer.opened }),754 unit,755 [{ result: "passed" }]756 )757 )758 );759760 const outcome = yield* run(answer);761 const puts = yield* EvidenceKept.use((kept) => kept.puts);762 const read = yield* answererReads(answer);763764 expect(outcome).toStrictEqual(765 Outcome.cases.Refused.make({766 refusals: [767 new ChecksFailed({768 lane: unit,769 logRef: withheld,770 next: "bun run test",771 }),772 ],773 })774 );775 expect(puts).toStrictEqual([]);776 expect(read).not.toContain(sentry);777 expect(read).not.toContain(token);778 }).pipe(Effect.provide(sealedWorld(policy)))779 );780781 it.effect(782 "writes no verdict note that would carry a stored value, on the fork or on the landed commit, and the answer lands as it would",783 () =>784 Effect.gen(function* () {785 const answer = yield* admitted();786787 yield* stored(answer);788 yield* allGreen(answer.merged);789790 const outcome = yield* run(answer);791 const tip = yield* mainTip;792793 expect(outcome).toStrictEqual(Outcome.cases.Landed.make({ sha: tip }));794 expect(yield* noteOn(answer.head)).toStrictEqual(Option.none());795 expect(yield* noteIn(repo, tip)).toStrictEqual(Option.none());796 }).pipe(797 Effect.provide(798 sealedWorld({799 ...policy,800 run: {801 ...policy.run,802 checks: {803 ...policy.run.checks,804 [LaneName.make("unit")]: Command.make(805 `SENTRY_AUTH_TOKEN=${token} bun run test`806 ),807 },808 },809 })810 )811 )812 );813});814

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 815why, one step back
815const sandboxFork = RepoName.make("alice__datekit--parse-iso--bob");

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 816–953why, one step back
816
817const sealedJob: CheckJob = {818 at: CheckAt.cases.Tree.make({ tree: TreeSha.make("5".repeat(40)) }),819 heldBack: heldBackJob,820 lanes: [],821 placeholders: [],822 project,823 proxies: [],824 repo: sandboxFork,825 run: policy.run,826};827828const allPassed: readonly HeldBackResult[] = [829 { area: exportArea, passed: 2, suite: suiteRoot, total: 2 },830 { area: parserArea, passed: 1, suite: suiteRoot, total: 1 },831];832833const overSandbox = (heldBack: readonly HeldBackResult[]) =>834 Effect.gen(function* () {835 const sent: (typeof CheckWire.Encoded)[] = [];836837 const exit = yield* Schema.encodeEffect(CheckExit)(838 Exit.succeed({ durationMs: 9, evidence: [], heldBack, lanes: [] })839 ).pipe(Effect.orDie);840841 const sandbox = untouchable<SandboxBinding>("SANDBOX", {842 check: (wire) => {843 sent.push(wire);844845 return Promise.resolve(exit);846 },847 });848849 yield* RepoHost.use((host) => host.create(sandboxFork)).pipe(Effect.orDie);850851 const runner = yield* Effect.service(CheckRunner).pipe(852 Effect.provide(CheckRunnerSandbox(sandbox))853 );854855 return { runner, sent };856 });857858describe("a held-back job through the sandbox", () => {859 it.effect(860 "sends the suite's files as base64 beside one read token on the answer's fork, and hands back its area bits",861 () =>862 Effect.gen(function* () {863 const { runner, sent } = yield* overSandbox(allPassed);864 const ran = yield* runner.run(sealedJob).pipe(Effect.orDie);865 const remote = yield* RepoHost.use((host) => host.remote(sandboxFork));866867 expect(ran.heldBack).toStrictEqual(allPassed);868 expect(869 sent.map(({ clone, job }) => ({870 files: job.heldBack?.files.map(({ contentBase64, path }) => ({871 contentBase64,872 path,873 })),874 url: clone.url,875 }))876 ).toStrictEqual([877 {878 files: sealedFiles.map(({ content, path }) => ({879 contentBase64: btoa(content),880 path,881 })),882 url: remote,883 },884 ]);885 expect(JSON.stringify(sent)).not.toContain(maintainers);886 }).pipe(Effect.provide(Layer.fresh(RepoHostMemory)))887 );888889 it.effect(890 "takes one bit per area from a suite that names an area twice, as the Checker counts them",891 () =>892 Effect.gen(function* () {893 const { runner } = yield* overSandbox(allPassed);894895 const ran = yield* Effect.exit(896 runner.run({897 ...sealedJob,898 heldBack: {899 ...heldBackJob,900 areas: [exportArea, parserArea, exportArea],901 },902 })903 );904905 expect(Exit.map(ran, ({ heldBack }) => heldBack)).toStrictEqual(906 Exit.succeed(allPassed)907 );908 }).pipe(Effect.provide(Layer.fresh(RepoHostMemory)))909 );910911 it.effect(912 "refuses area bits that do not answer the job it sent: VerifierBlocked, never a bit an answer earned",913 () =>914 Effect.gen(function* () {915 const otherSuite = SuiteRoot.make(`sha256:${"0".repeat(64)}`);916917 const wrong: readonly {918 readonly job: CheckJob;919 readonly bits: readonly HeldBackResult[];920 }[] = [921 { bits: allPassed.slice(0, 1), job: sealedJob },922 {923 bits: allPassed.map((each) => ({ ...each, suite: otherSuite })),924 job: sealedJob,925 },926 {927 bits: allPassed.map((each) => ({928 ...each,929 passed: each.total + 1,930 })),931 job: sealedJob,932 },933 {934 bits: allPassed.map((each) => ({ ...each, total: each.total + 1 })),935 job: sealedJob,936 },937 { bits: allPassed, job: Struct.omit(sealedJob, ["heldBack"]) },938 ];939940 const outcomes = yield* Effect.forEach(wrong, ({ bits, job }) =>941 Effect.gen(function* () {942 const { runner } = yield* overSandbox(bits);943944 return yield* Effect.exit(runner.run(job));945 }).pipe(Effect.provide(Layer.fresh(RepoHostMemory)))946 );947948 expect(outcomes).toStrictEqual(949 wrong.map(() => Exit.fail(new VerifierBlocked({})))950 );951 })952 );953});