Skip to content
Myr

gate.ts

This file

Path

packages/gate/src/gate.ts

56 lines · 1.5 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

line 1why, one step back
1/**

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

lines 2–3why, one step back
2 * Stops after the first stage that refuses, so a push never pays for a stage
3 * past its cheapest problem.

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

line 4why, one step back
4 */

Merge observability into mainoscabrielbefore adoption1985111

line 5why, one step back
5import type { StageName } from "@repo/protocol/domain/outcome";

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 6–13why, one step back
6import type { Refusal } from "@repo/protocol/refusal";
7import { Array, Effect, Option } from "effect";89import type { PushFacts } from "./facts.ts";10import type { Stage } from "./stage.ts";11import { parse } from "./stages/parse.ts";12import { scan } from "./stages/shape.ts";13

Merge observability into mainoscabrielbefore adoption1985111

lines 14–20why, one step back
14/** What the first stage that refused a push refused it for. */
15export interface StageRefusal {16 readonly refusals: Array.NonEmptyReadonlyArray<Refusal>;17 readonly stage: StageName;18}1920export const refusingStage = <R>(

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 21–22why, one step back
21 stages: readonly Stage<R>[],
22 facts: PushFacts

Merge observability into mainoscabrielbefore adoption1985111

line 23why, one step back
23): Effect.Effect<Option.Option<StageRefusal>, never, R> =>

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 24–25why, one step back
24 Effect.gen(function* () {
25 for (const stage of stages) {

Merge observability into mainoscabrielbefore adoption1985111

lines 26–28why, one step back
26 const refusals = yield* stage
27 .run(facts)28 .pipe(Effect.withSpan(`Gate.${stage.name}`));

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 29–30why, one step back
29
30 if (Array.isReadonlyArrayNonEmpty(refusals)) {

Merge observability into mainoscabrielbefore adoption1985111

lines 31–36why, one step back
31 return Option.some({
32 refusals: stage.accumulate33 ? refusals34 : Array.of(Array.headNonEmpty(refusals)),35 stage: stage.name,36 });

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 37–41why, one step back
37 }
38 }3940 return Option.none();41 });

Merge observability into mainoscabrielbefore adoption1985111

lines 42–54why, one step back
42
43export const runGate = <R>(44 stages: readonly Stage<R>[],45 facts: PushFacts46): Effect.Effect<47 Option.Option<Array.NonEmptyReadonlyArray<Refusal>>,48 never,49 R50> =>51 Effect.map(52 refusingStage(stages, facts),53 Option.map(({ refusals }) => refusals)54 );

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 55–56why, one step back
55
56export const pushStages: readonly Stage<never>[] = [parse, scan];