Skip to content
Myr

guards.ts

This file

Path

packages/visibility/src/guards.ts

52 lines · 2.0 KiB · TypeScript

Last changed by

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

History of this file

Take it

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

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 1why, one step back
1import { layerPathRefusal } from "@repo/gate/stages/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 2–3why, one step back
2import type { Change } from "@repo/git/tree-diff";
3import type { BlobSha, RepoPath } from "@repo/protocol/ids";

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

lines 4–5why, one step back
4import { LayerContentInPublicTree } from "@repo/protocol/refusal";
5import type { PrivatePathInPublicTree } from "@repo/protocol/refusal";

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–17why, one step back
6import { Array, Option, Order } from "effect";
78const named = (paths: readonly RepoPath[]) =>9 Array.match(Array.dedupe(Array.sort(paths, Order.String)), {10 onEmpty: Option.none,11 onNonEmpty: Option.some,12 });1314const written = (changes: readonly Change[]) =>15 changes.filter((change) => change.status !== "deleted");1617/**

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

lines 18–22why, one step back
18 * The same rule as stage 1 (`@repo/gate/stages/shape`'s `layerPathRefusal`).
19 * The refusal is no oracle: to a pusher who cannot read the layer it names20 * every path they added or modified; only a reader hears which collide.21 * `pusherCanRead` must hold for every layer in `layerPaths`: call it once per22 * layer, or with the union and `false`, when they read some.

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 23why, one step back
23 */

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 24why, one step back
24export const privatePaths: (input: {

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 25–27why, one step back
25 readonly changes: readonly Change[];
26 readonly layerPaths: ReadonlySet<RepoPath>;27 readonly pusherCanRead: boolean;

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 28why, one step back
28}) => Option.Option<PrivatePathInPublicTree> = layerPathRefusal;

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/**

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

lines 31–34why, one step back
31 * It runs only for someone who can read the layer, the only people who could
32 * have copied from it; on anyone else it would be an oracle for the layer's33 * content. `layerBlobs` holds the blobs of layers the answerer reads, and only34 * those.

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 35–52why, one step back
35 */
36export const writeDown = (input: {37 readonly changes: readonly Change[];38 readonly layerBlobs: ReadonlySet<BlobSha>;39 readonly readerCanReadLayer: boolean;40}): Option.Option<LayerContentInPublicTree> =>41 input.readerCanReadLayer42 ? Option.map(43 named(44 written(input.changes)45 .filter(46 ({ after }) => after !== undefined && input.layerBlobs.has(after)47 )48 .map((change) => change.path)49 ),50 (paths) => new LayerContentInPublicTree({ paths })51 )52 : Option.none();