check-runner.ts
This file
Path
packages/checks/src/check-runner.ts
178 lines · 5.0 KiB · TypeScript
Last changed by
Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
History of this fileTake 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–33why, one step back1import { HeldBackResult, LaneResult } from "@repo/protocol/domain/answer";2import { RunBlock } from "@repo/protocol/domain/run";3import {4 AreaName,5 CommitSha,6 EnvKey,7 LaneName,8 ProjectName,9 RepoName,10 RepoPath,11 SuiteRoot,12 TreeSha,13} from "@repo/protocol/ids";14import type { VerifierBlocked } from "@repo/protocol/refusal";15import { Context, Option, Schema } from "effect";16import type { Effect } from "effect";1718import { diagnose, Diagnosis } from "./classify.ts";19import type { RunExit } from "./classify.ts";2021export const CheckAt = Schema.TaggedUnion({22 Commit: { commit: CommitSha },23 Tree: { tree: TreeSha },24});2526export type CheckAt = typeof CheckAt.Type;2728export const shaOf = (at: CheckAt): string =>29 CheckAt.match(at, {30 Commit: ({ commit }): string => commit,31 Tree: ({ tree }): string => tree,32 });33Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 34why, one step back34// A count lane's stdout goes back to the platform alone, never to an answerer.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–45why, one step back35export const CheckLane = Schema.Struct({36 command: Schema.NonEmptyString,37 lane: LaneName,38 output: Schema.optionalKey(Schema.Literal("stdout")),39 timeoutMs: Schema.optionalKey(40 Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0)))41 ),42});4344export type CheckLane = typeof CheckLane.Type;45Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 46why, one step back46// On the wire the bytes are base64 (`contentBase64`).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 47–62why, one step back47export const HeldBackFile = Schema.Struct({48 area: AreaName,49 content: Schema.Uint8ArrayFromBase64,50 path: RepoPath,51}).pipe(Schema.encodeKeys({ content: "contentBase64" }));5253export type HeldBackFile = typeof HeldBackFile.Type;5455export const HeldBackCheck = Schema.Struct({56 area: AreaName,57 command: Schema.NonEmptyString,58 path: RepoPath,59});6061export type HeldBackCheck = typeof HeldBackCheck.Type;62Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 63why, one step back63// Names no layer repo, route or token: the sandbox never reaches the layer.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 64–80why, one step back64export const HeldBackPart = Schema.Struct({65 areas: Schema.Array(AreaName),66 at: CommitSha,67 files: Schema.Array(HeldBackFile),68 runs: Schema.Array(HeldBackCheck),69 suite: SuiteRoot,70});7172export type HeldBackPart = typeof HeldBackPart.Type;7374export const EnvPlaceholder = Schema.Struct({75 key: EnvKey,76 placeholder: Schema.NonEmptyString,77});7879export type EnvPlaceholder = typeof EnvPlaceholder.Type;80Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 81why, one step back81// `placeholder` is swapped for the value of `key` only in a run of landed code.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 82–92why, one step back82export const EnvProxy = Schema.Struct({83 block: Schema.Boolean,84 host: Schema.NonEmptyString,85 key: EnvKey,86 method: Schema.optionalKey(Schema.NonEmptyString),87 path: Schema.optionalKey(Schema.NonEmptyString),88 placeholder: Schema.NonEmptyString,89});9091export type EnvProxy = typeof EnvProxy.Type;92Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 93why, one step back93// The sandbox hands it only to its env gateway, never to the container.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 94–100why, one step back94export const EnvValue = Schema.Struct({95 key: EnvKey,96 value: Schema.RedactedFromValue(Schema.NonEmptyString),97});9899export type EnvValue = typeof EnvValue.Type;100Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 101why, one step back101// A job that is not `landed` and carries values neither decodes nor encodes.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 102–150why, one step back102export const CheckJob = Schema.Struct({103 at: CheckAt,104 heldBack: Schema.optionalKey(HeldBackPart),105 landed: Schema.optionalKey(Schema.Boolean),106 lanes: Schema.Array(CheckLane),107 placeholders: Schema.Array(EnvPlaceholder),108 project: ProjectName,109 proxies: Schema.Array(EnvProxy),110 repo: RepoName,111 run: RunBlock,112 values: Schema.optionalKey(Schema.Array(EnvValue)),113}).check(114 Schema.makeFilter(({ landed, values }) =>115 values === undefined || landed === true116 ? true117 : "only a job of landed code carries values"118 )119);120121export type CheckJob = typeof CheckJob.Type;122123export const LaneEvidence = Schema.Struct({124 lane: LaneName,125 signature: Schema.optionalKey(Schema.NonEmptyString),126 weakness: Schema.optionalKey(Schema.Literal("no assertion")),127});128129export type LaneEvidence = typeof LaneEvidence.Type;130131export const evidenceFrom = (lane: LaneName, exit: RunExit): LaneEvidence =>132 Diagnosis.$match(diagnose(exit), {133 Blocked: () => ({ lane }),134 Failed: ({ signature }) =>135 Option.match(signature, {136 onNone: () => ({ lane }),137 onSome: (text) => ({ lane, signature: text }),138 }),139 LoadError: () => ({ lane }),140 NoTests: () => ({ lane, weakness: "no assertion" as const }),141 Passed: () => ({ lane }),142 });143144export const LaneOutput = Schema.Struct({145 lane: LaneName,146 stdout: Schema.String,147});148149export type LaneOutput = typeof LaneOutput.Type;150Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 151why, one step back151// Logs never travel here; a lane's `logRef` names where the platform keeps them.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 152–170why, one step back152export const CheckRun = Schema.Struct({153 durationMs: Schema.Int,154 evidence: Schema.Array(LaneEvidence),155 heldBack: Schema.Array(HeldBackResult),156 lanes: Schema.Array(LaneResult),157 outputs: Schema.optionalKey(Schema.Array(LaneOutput)),158});159160export type CheckRun = typeof CheckRun.Type;161162export const outputOf = (163 run: CheckRun,164 lane: LaneName165): Option.Option<string> =>166 Option.map(167 Option.fromUndefinedOr(run.outputs?.find((each) => each.lane === lane)),168 ({ stdout }) => stdout169 );170Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
lines 171–172why, one step back171// `VerifierBlocked` means the run could not happen at all: the gate's172// trouble, never the answer's.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 173–178why, one step back173export class CheckRunner extends Context.Service<174 CheckRunner,175 {176 readonly run: (job: CheckJob) => Effect.Effect<CheckRun, VerifierBlocked>;177 }178>()("checks/CheckRunner") {}