draft-runs.ts
This file
Path
packages/project/src/draft-runs.ts
95 lines · 2.2 KiB · TypeScript
Last changed by
Merge build/comments-project into mainoscabrielbefore adoption49efd2a
History of this fileTake it
Merge branch 'build/909-draft-rehearsal-and-settling'oscabrielbefore adoption9e6b61c
lines 1–17why, one step back1import { AtLeastOne, ConfigFile } from "@repo/protocol/domain/common";2import { PublicPolicy } from "@repo/protocol/domain/policy";3import {4 LandedSha,5 LaneName,6 ProjectName,7 ProposalId,8 RepoPath,9 TreeSha,10} from "@repo/protocol/ids";11import { Refusal } from "@repo/protocol/refusal";12import { Context, Effect, Schema } from "effect";1314export const DRAFT_ROUNDS = 3;1516export const EXCERPT_BYTES = 4 * 1024;17Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 18why, one step back18/** The note travels with the run, since a proposal keeps no note of its own. */Merge branch 'build/909-draft-rehearsal-and-settling'oscabrielbefore adoption9e6b61c
lines 19–28why, one step back19export const DraftParams = Schema.Struct({20 note: Schema.optionalKey(Schema.String),21 project: ProjectName,22 proposal: ProposalId,23 round: AtLeastOne,24});2526export type DraftParams = typeof DraftParams.Type;2728export interface DraftStarter {Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 29why, one step back29 /** Safe to call twice. */Merge branch 'build/909-draft-rehearsal-and-settling'oscabrielbefore adoption9e6b61c
lines 30–82why, one step back30 readonly start: (params: DraftParams) => Effect.Effect<void>;31}3233export const DraftRuns = Context.Reference<DraftStarter>("project/DraftRuns", {34 defaultValue: () => ({ start: () => Effect.void }),35});3637export const Diagnosis = Schema.Literals([38 "LoadError",39 "Passed",40 "NoTests",41 "Flaky",42 "Blocked",43 "Weak",44 "Brief",45 "Judge",46]);4748export type Diagnosis = typeof Diagnosis.Type;4950export const Rehearsal = Schema.TaggedUnion({51 Red: {52 lane: LaneName,53 signature: Schema.NonEmptyString,54 tree: TreeSha,55 },56 Refused: {57 diagnosis: Diagnosis,58 excerpt: Schema.String,59 refusal: Refusal,60 },61});6263export type Rehearsal = typeof Rehearsal.Type;6465const attempt = {66 attempts: AtLeastOne.check(Schema.isLessThanOrEqualTo(DRAFT_ROUNDS)),67 model: Schema.NonEmptyString,68};6970export const DraftResult = Schema.TaggedUnion({71 Failed: { ...attempt, refusal: Refusal },72 Red: {73 ...attempt,74 files: Schema.NonEmptyArray(ConfigFile),75 lane: LaneName,76 rationale: Schema.String,77 signature: Schema.NonEmptyString,78 },79});8081export type DraftResult = typeof DraftResult.Type;82Merge build/comments-project into mainoscabrielbefore adoption49efd2a
line 83why, one step back83/** Carries the public policy only, never `visibility`. */Merge branch 'build/909-draft-rehearsal-and-settling'oscabrielbefore adoption9e6b61c
lines 84–95why, one step back84export const DraftContextData = Schema.Struct({85 at: LandedSha,86 paths: Schema.Array(RepoPath),87 policy: PublicPolicy,88 project: ProjectName,89 proposal: ProposalId,90 round: AtLeastOne,91 territory: Schema.optionalKey(Schema.NonEmptyString),92 want: Schema.NonEmptyString,93});9495export type DraftContextData = typeof DraftContextData.Type;