Skip to content
Myr

layers.ts

This file

Path

apps/platform/src/visibility/layers.ts

65 lines · 2.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/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–5why, one step back
1import type { Fetch } from "@repo/artifacts/fetch";
2import { RepoHost } from "@repo/artifacts/repo-host";3import { Upstream } from "@repo/git/upstream";4import { UpstreamRepoHost } from "@repo/git/upstream/repo-host";5import { Projects } from "@repo/project/projects";

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 6why, one step back
6import { LayerName, nameOfKey, ProjectKey } from "@repo/protocol/ids";

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 7–14why, one step back
7import { LayerRepos } from "@repo/visibility/layer-repos";
8import { Effect, Layer, Option, Schema } from "effect";910import { LayerGate } from "../layer-gate.ts";11import type { LayerTarget } from "../layer-gate.ts";12import type { PlatformConfig } from "../platform.ts";13import { layerRepos } from "./layer-repos.ts";14

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 15–17why, one step back
15const asKey = Schema.decodeOption(ProjectKey);
1617const asProject = (first: string) => Option.flatMap(asKey(first), nameOfKey);

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 18–28why, one step back
18
19const asLayer = Schema.decodeOption(LayerName);2021const spelled = (repo: string): Option.Option<LayerTarget> => {22 const [first = "", second = "", ...rest] = repo.split("--");2324 return rest.length > 025 ? Option.none()26 : Option.all({ layer: asLayer(second), project: asProject(first) });27};28

Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8

lines 29–30why, one step back
29// Fresh: a layer built twice in one memo map is shared, and the core ports build
30// `UpstreamRepoHost` over the public namespace.

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 31why, one step back
31const privateUpstream: Layer.Layer<Upstream, never, LayerRepos | Fetch> =

Close W6: give the layer gate its own upstream, prove the cartridge removable by deletion, and name its fences in AGENTS.mdoscabrielbefore adoption9a301f9

line 32why, one step back
32 Layer.fresh(UpstreamRepoHost).pipe(

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 33–65why, one step back
33 Layer.provide(Layer.effect(RepoHost, LayerRepos.useSync(RepoHost.of)))
34 );3536export const LayerGateLive: Layer.Layer<37 never,38 never,39 Projects | LayerRepos | Fetch40> = Layer.effect(41 LayerGate,42 Effect.gen(function* () {43 const projects = yield* Projects;44 const upstream = yield* Upstream;4546 return LayerGate.of({47 classify: (repo, who) =>48 Option.match(spelled(repo), {49 onNone: () => Effect.succeedNone,50 onSome: (target) =>51 projects.get(target.project).pipe(52 Effect.flatMap((api) => api.layerAccess(who, target.layer)),53 Effect.map(Option.map((access) => ({ access, target }))),54 Effect.catchTag("UnknownProject", () => Effect.succeedNone)55 ),56 }),57 upstream,58 });59 })60).pipe(Layer.provide(privateUpstream));6162export const layersLive = (63 config: PlatformConfig64): Layer.Layer<never, never, Projects | Fetch> =>65 LayerGateLive.pipe(Layer.provide(layerRepos(config)));