answer-runs.ts
This file
Path
apps/platform/src/answer-runs.ts
78 lines · 1.8 KiB · TypeScript
Last changed by
Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
line 1why, one step back1import { DraftParams as DraftRun } from "@repo/project/draft-runs";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 back2import {3 CommitSha,Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 4why, one step back4 keyOf,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 5–25why, one step back5 LayerName,6 ProjectName,7 RequestId,8} from "@repo/protocol/ids";9import { Schema } from "effect";1011export const AnswerParams = Schema.Struct({12 project: ProjectName,13 requestId: RequestId,14});1516export type AnswerParams = typeof AnswerParams.Type;1718export const AdmissionParams = Schema.TaggedStruct("Admission", {19 head: CommitSha,20 layer: LayerName,21 project: ProjectName,22});2324export type AdmissionParams = typeof AdmissionParams.Type;25Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
line 26why, one step back26export const DraftParams = Schema.TaggedStruct("Draft", DraftRun.fields);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 27why, one step back27Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
lines 28–35why, one step back28export type DraftParams = typeof DraftParams.Type;2930export const WorkflowParams = Schema.Union([31 AdmissionParams,32 DraftParams,33 AnswerParams,34]);35Merge 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 36–39why, one step back36export type WorkflowParams = typeof WorkflowParams.Type;3738const ID_LENGTH = 100;39Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
line 40why, one step back40// 2^31 - 1, so every step stays a safe integer.Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
lines 41–52why, one step back41const TAG_MODULUS = 2_147_483_647;4243const tagOf = (text: string) => {44 let hash = 0;4546 for (const unit of text) {47 hash = (hash * 31 + (unit.codePointAt(0) ?? 0)) % TAG_MODULUS;48 }4950 return hash.toString(36);51};52Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
line 53why, one step back53// A name too long is cut and tagged with a hash of the whole name, so no two runs share an instance.Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c
lines 54–55why, one step back54const instanceId = (named: string, suffix: string) => {55 const whole = `${named}${suffix}`;Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
lines 56–60why, one step back5657 if (whole.length <= ID_LENGTH) {58 return whole;59 }60Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c
line 61why, one step back61 const tag = `-${tagOf(named)}`;Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
line 62why, one step back62Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c
line 63why, one step back63 return `${named.slice(0, ID_LENGTH - tag.length - suffix.length)}${tag}${suffix}`;Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
line 64why, one step back64};Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c
lines 65–66why, one step back6566export const admissionId = (params: AdmissionParams) =>Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 67–70why, one step back67 instanceId(68 `admit-${keyOf(params.project)}-${params.layer}`,69 `-${params.head}`70 );Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c
lines 71–74why, one step back7172export const draftId = (73 params: Pick<DraftParams, "project" | "proposal" | "round">74) =>Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 75–78why, one step back75 instanceId(76 `draft-${keyOf(params.project)}`,77 `-${params.proposal}-r${params.round}`78 );