answer-runs.ts
This file
Path
packages/project/src/answer-runs.ts
163 lines · 5.0 KiB · TypeScript
Last changed by
Merge observability into mainoscabrielbefore adoption1985111
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–10why, one step back1import { CheckLane } from "@repo/checks/check-runner";2import {3 HeldBackResult,4 LaneResult,5 Verdict,6} from "@repo/protocol/domain/answer";7import { Ask } from "@repo/protocol/domain/ask";8import { RatchetSpec } from "@repo/protocol/domain/check";9import { Choice } from "@repo/protocol/domain/decision";10import { AskKind } from "@repo/protocol/domain/kind";Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
line 11why, one step back11import type { LandingView } from "@repo/protocol/domain/landing";Merge observability into mainoscabrielbefore adoption1985111
line 12why, one step back12import { Outcome, 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 13–27why, one step back13import { RunBlock } from "@repo/protocol/domain/run";14import { Territory } from "@repo/protocol/domain/territory";15import {16 AskId,17 CommitSha,18 DecisionId,19 Handle,20 LandedSha,21 LaneName,22 RatchetName,23 RepoName,24 RepoPath,25 TreeSha,26} from "@repo/protocol/ids";27import type { RequestId } from "@repo/protocol/ids";Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
line 28why, one step back28import { MovedBy, Refusal, VerifierBlocked } 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 29–30why, one step back29import { Context, Effect, Option, Schema } from "effect";30Give checks the env as 611's job carries it, open values for landed runs, and parse env schemas in the Workeroscabrielbefore adoption234865c
line 31why, one step back31import { UnlandedRunEnv } from "./env-port.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 32–49why, one step back32import { Change, LandingState, PendingDecision } from "./landing.ts";33import type { LandingCommand, LandingEffect } from "./landing.ts";3435const Attempt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));3637export const ReportedCommand = Schema.TaggedUnion({38 Blocked: { attempt: Attempt },39 Busy: { attempt: Attempt },40 Checked: {41 decisions: Schema.Array(PendingDecision),42 finish: AskKind.fields.finish,43 refusals: Schema.Array(Refusal),44 tree: TreeSha,45 },46 Decided: { by: Handle, choice: Choice, decision: DecisionId },47 Finished: { by: Handle },48 LandedOk: { sha: LandedSha },49 MainMoved: { from: LandedSha, main: LandedSha },Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
lines 50–52why, one step back50 MergeConflict: {51 conflicts: Schema.Array(RepoPath),52 main: LandedSha,Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 53why, one step back53 // Absent from steps recorded before a merge named who moved a path.Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
lines 54–55why, one step back54 movedBy: Schema.optionalKey(Schema.NonEmptyArray(MovedBy)),55 },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 56–83why, one step back56 Merged: { changes: Schema.Array(Change), main: LandedSha, tree: TreeSha },57 Start: { main: LandedSha },58 Wait: { parent: AskId },59});6061export const NextStep = Schema.TaggedUnion({62 Land: { main: LandedSha, tree: TreeSha },63 Merge: { base: CommitSha, fork: RepoName, head: CommitSha, main: LandedSha },64 Retry: { at: Schema.DateTimeUtcFromString },65 RunChecks: { tree: TreeSha },66});6768export const Steps = Schema.Struct({69 effects: Schema.Array(NextStep),70 outcome: Outcome,71});7273export const MeasuredCount = Schema.Struct({74 count: Attempt,75 ratchet: RatchetName,76 territory: Schema.NonEmptyString,77});7879export type MeasuredCount = typeof MeasuredCount.Type;8081export const AnswerRun = Schema.Struct({82 admitted: Schema.Boolean,83 ask: Schema.optionalKey(Ask),Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 84why, one step back84 /** Red on main by design. */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 85–91why, one step back85 askLane: Schema.optionalKey(LaneName),86 counts: Schema.optionalKey(87 Schema.Struct({88 modules: Schema.Array(Territory),89 ratchets: Schema.Array(RatchetSpec),90 })91 ),Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 92why, one step back92 /** Placeholders and proxies, never a value. */Give checks the env as 611's job carries it, open values for landed runs, and parse env schemas in the Workeroscabrielbefore adoption234865c
line 93why, one step back93 env: Schema.optionalKey(UnlandedRunEnv),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–105why, one step back94 finish: AskKind.fields.finish,95 lanes: Schema.Array(CheckLane),96 message: Schema.optionalKey(Schema.String),97 repo: RepoName,98 run: Schema.optionalKey(RunBlock),99 sealed: Schema.optionalKey(Schema.Boolean),100 state: LandingState,101 verdict: Schema.optionalKey(Verdict),102});103104export type AnswerRun = typeof AnswerRun.Type;105Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 106why, one step back106/** `VerifierBlocked` without a run block: the Checker never guesses a project's setup. */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 107–120why, one step back107export const runBlockOf = (from: {108 readonly run?: RunBlock;109}): Effect.Effect<RunBlock, VerifierBlocked> =>110 Effect.fromOption(Option.fromUndefinedOr(from.run)).pipe(111 Effect.mapError(() => new VerifierBlocked({}))112 );113114export const AnswerReport = Schema.Struct({115 heldBack: Schema.optionalKey(Schema.Array(HeldBackResult)),116 lanes: Schema.optionalKey(Schema.Array(LaneResult)),117 pending: Schema.optionalKey(118 Schema.Array(Schema.Literals(["mirror", "notes"]))119 ),120 ratchets: Schema.optionalKey(Schema.Array(MeasuredCount)),Merge observability into mainoscabrielbefore adoption1985111
lines 121–122why, one step back121 /** The stage whose refusals a `Checked` report carries: absent when it carries none, or from a run that ran every lane at once. */122 stage: Schema.optionalKey(StageName),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 123–147why, one step back123});124125export type AnswerReport = typeof AnswerReport.Type;126127export type RunnableEffect = Extract<128 LandingEffect,129 { readonly _tag: NextStep["_tag"] }130>;131132type NextStep = typeof NextStep.Type;133134export interface Advanced {135 readonly effects: readonly RunnableEffect[];136 readonly outcome: Outcome;137}138139export interface AnswerQueue {140 readonly advanceAnswer: (141 requestId: RequestId,142 command: LandingCommand,143 report?: AnswerReport144 ) => Effect.Effect<Advanced>;145 readonly answer: (146 requestId: RequestId147 ) => Effect.Effect<Option.Option<AnswerRun>>;Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 148why, one step back148 /** A commit the platform did not land (imported history) has none. */Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
lines 149–151why, one step back149 readonly landings: (150 shas: readonly CommitSha[]151 ) => Effect.Effect<readonly LandingView[]>;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–153why, one step back152}153Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 154why, one step back154/** Idempotent by id. The Workflow adapter ignores `queue` and reaches it through the Durable Object. */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 155–163why, one step back155export class AnswerRuns extends Context.Service<156 AnswerRuns,157 {158 readonly start: (159 requestId: RequestId,160 queue: AnswerQueue161 ) => Effect.Effect<void>;162 }163>()("project/AnswerRuns") {}