Skip to content
Myr

gate.test.ts

This file

Path

packages/gate/test/gate.test.ts

140 lines · 3.8 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–6why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { RepoPath } from "@repo/protocol/ids";3import { NotClaimed, OutOfScope, TouchedJudge } from "@repo/protocol/refusal";4import type { Refusal } from "@repo/protocol/refusal";5import { Effect, Option } from "effect";6

Merge observability into mainoscabrielbefore adoption1985111

line 7why, one step back
7import { pushStages, refusingStage, runGate } from "../src/gate.ts";

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 8–89why, one step back
8import type { Stage } from "../src/stage.ts";
9import { ask, modified, testFacts, wire } from "./facts.ts";1011const wired = (answer: Option.Option<readonly Refusal[]>) =>12 Option.map(answer, wire);1314const always = (15 accumulate: boolean,16 refusals: readonly Refusal[]17): Stage<never> => ({18 accumulate,19 name: "cheap",20 run: () => Effect.succeed(refusals),21});2223const outside = new OutOfScope({ paths: [RepoPath.make("docs/guide.md")] });2425const judged = new TouchedJudge({26 paths: [RepoPath.make(".github/workflows/ci.yml")],27});2829describe(runGate, () => {30 it.effect("stops after parse when parse refuses, so shape is not heard", () =>31 Effect.gen(function* () {32 const answer = yield* runGate(33 pushStages,34 testFacts({35 changes: modified("docs/guide.md"),36 claim: Option.none(),37 })38 );3940 expect(wired(answer)).toStrictEqual(41 Option.some(wire([NotClaimed.of(ask.id)]))42 );43 })44 );4546 it.effect(47 "returns every shape refusal when parse lets the push through",48 () =>49 Effect.gen(function* () {50 const answer = yield* runGate(51 pushStages,52 testFacts({53 changes: modified("docs/guide.md", ".github/workflows/ci.yml"),54 })55 );5657 expect(wired(answer)).toStrictEqual(58 Option.some(wire([outside, judged]))59 );60 })61 );6263 it.effect("returns None when every stage lets the push through", () =>64 Effect.gen(function* () {65 const answer = yield* runGate(pushStages, testFacts());6667 expect(answer).toStrictEqual(Option.none());68 })69 );7071 it.effect("stops a stage that does not accumulate at its first refusal", () =>72 Effect.gen(function* () {73 const answer = yield* runGate(74 [always(false, [outside, judged]), always(true, [judged])],75 testFacts()76 );7778 expect(wired(answer)).toStrictEqual(Option.some(wire([outside])));79 })80 );8182 it.effect("keeps every refusal of a stage that accumulates", () =>83 Effect.gen(function* () {84 const answer = yield* runGate(85 [always(true, []), always(true, [outside, judged])],86 testFacts()87 );8889 expect(wired(answer)).toStrictEqual(Option.some(wire([outside, judged])));

Merge observability into mainoscabrielbefore adoption1985111

lines 90–137why, one step back
90 })
91 );92});9394describe(refusingStage, () => {95 it.effect("names parse when parse refuses the push", () =>96 Effect.gen(function* () {97 const refused = yield* refusingStage(98 pushStages,99 testFacts({100 changes: modified("docs/guide.md"),101 claim: Option.none(),102 })103 );104105 expect(Option.map(refused, ({ stage }) => stage)).toStrictEqual(106 Option.some("parse")107 );108 })109 );110111 it.effect(112 "names shape, with every refusal it gave, when parse lets the push through",113 () =>114 Effect.gen(function* () {115 const refused = yield* refusingStage(116 pushStages,117 testFacts({118 changes: modified("docs/guide.md", ".github/workflows/ci.yml"),119 })120 );121122 expect(123 Option.map(refused, ({ refusals, stage }) => ({124 refusals: wire(refusals),125 stage,126 }))127 ).toStrictEqual(128 Option.some({ refusals: wire([outside, judged]), stage: "shape" })129 );130 })131 );132133 it.effect("names no stage when every stage lets the push through", () =>134 Effect.gen(function* () {135 expect(yield* refusingStage(pushStages, testFacts())).toStrictEqual(136 Option.none()137 );

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 138–140why, one step back
138 })
139 );140});