Skip to content
Myr

render.ts

This file

Path

packages/protocol/src/render.ts

209 lines · 9.7 KiB · TypeScript

Last changed by

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

History of this file

Take 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–6why, one step back
1import { Brand } from "@repo/brand";
2import { DateTime, Match, Result } from "effect";3import type { Array } from "effect";45import type { AnswerReceipt } from "./domain/answer.ts";6import { Outcome } from "./domain/outcome.ts";

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 7why, one step back
7import { ownerOf } from "./ids.ts";

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 8why, one step back
8import { ChecksFailed } from "./refusal.ts";

Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097

line 9why, one step back
9import type { CapReached, MovedBy, Refusal } from "./refusal.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 10–14why, one step back
10
11const short = (sha: string) => sha.slice(0, 7);1213const list = (items: readonly string[]) => items.join(", ");14

Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7

lines 15–45why, one step back
15const counted = (count: number, noun: string) =>
16 `${count} ${noun}${count === 1 ? "" : "s"}`;1718type CapLimit = NonNullable<CapReached["limit"]>;1920// A cap with no `retryAfter` is held: it lifts when a claim is released or21// landed, a proposal decided; a proposal's draft rounds never lift.22const held = {23 claims: (cap) =>24 `you already hold ${counted(cap, "claim")}, the most this project allows`,25 drafts: (cap) =>26 `this proposal was already drafted ${cap === 1 ? "once" : `${cap} times`}, the most one proposal takes`,27 proposals: (cap) =>28 `you already have ${counted(cap, "open proposal")} here, the most this project allows`,29} as const satisfies Record<CapLimit, (cap: number) => string>;3031const rated = {32 claims: { noun: "claim", verb: "made" },33 drafts: { noun: "draft", verb: "started" },34 proposals: { noun: "proposal", verb: "made" },35} as const satisfies Record<CapLimit, { noun: string; verb: string }>;3637const capReason = ({38 cap,39 limit = "claims",40 retryAfter,41}: CapReached): string =>42 retryAfter === undefined43 ? held[limit](cap)44 : `you ${rated[limit].verb} ${counted(cap, rated[limit].noun)} in the last minute, the most the platform allows; try again in ${retryAfter}s`;45

Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097

lines 46–59why, one step back
46const conflictIn = (path: string, movedBy: readonly MovedBy[]) => {
47 const mover = movedBy.find((moved) => moved.path === path);4849 if (mover === undefined) {50 return path;51 }5253 const { ask, author, landing } = mover;5455 return ask === undefined56 ? `${path} (last changed by ${author} in ${short(landing)})`57 : `${path} (last changed by ${author} in ${short(landing)}, for ${ask})`;58};59

Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7

lines 60–62why, one step back
60// A branch is what a person pushes; every other ref the platform writes.
61const BRANCH = "refs/heads/";62

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 63–71why, one step back
63// Reasons name only what the refusal's reader may see: held-back checks give
64// their area and suite, never a case or an input. A shape refusal's reason65// ends with how to repair it, after its first clause; `next` stays the command.66const reason = Match.typeTags<Refusal, string>()({67 AskBlocked: ({ ask, blockedBy }) =>68 `${ask} waits on ${list(blockedBy)} to land first`,69 AskFull: ({ ask }) => `someone else holds the claim on ${ask}`,70 AttemptsExhausted: ({ area, resetsAt }) =>71 `no attempts left on ${area} until ${DateTime.formatIso(resetsAt)}`,

Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7

line 72why, one step back
72 CapReached: capReason,

Merge build/1105 into mainoscabrielbefore adoption1fc92ed

lines 73–77why, one step back
73 ChecksFailed: ({ lane, logRef, next }) => {
74 if (logRef === ChecksFailed.withheld) {75 return `the ${lane} checks failed; their log was withheld`;76 }77

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 78why, one step back
78 // `evidence` lets in the answerer and the project's maintainers alone; the

Merge build/1105 into mainoscabrielbefore adoption1fc92ed

lines 79–81why, one step back
79 // local check keeps no log for it to read.
80 return ChecksFailed.isLocal(logRef)81 ? `the ${lane} checks failed on this commit; run ${next} to see the failure`

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 82why, one step back
82 : `the ${lane} checks failed on the answer; run ${next} in a clone of the fork to see the failure; the log is kept as ${logRef}, which the answerer and the project's maintainers read with ${Brand.cli} evidence`;

Merge build/1105 into mainoscabrielbefore adoption1fc92ed

line 83why, one step back
83 },

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 84–89why, one step back
84 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,
85 DecisionClosed: ({ decision }) =>86 `${decision} was already decided, or expired to its default`,87 Denounced: () =>88 "this project's vouch file denounces you, so it takes no claims or proposals from you",89 DirectPush: ({ ref }) =>

Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7

lines 90–92why, one step back
90 ref.startsWith(BRANCH)
91 ? `main moves only by a landing, so ${ref} takes no direct push; push your answer to your claim's fork`92 : `${ref} is written by the platform, not pushed; a fork takes branches only, so push your answer with git push ${Brand.slug} HEAD:main`,

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 93–94why, one step back
93 DraftInProgress: ({ proposal }) =>
94 `the platform is already drafting ${proposal}'s ask`,

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 95–104why, one step back
95 Flake: ({ lane }) =>
96 `the ${lane} checks failed, then passed on the same tree; the platform will run them again`,97 HeldBackFailed: ({ area, suite }) =>98 `a held-back check failed in ${area}, suite ${suite}`,99 ImportFailed: (refusal) => `the import failed: ${refusal.reason}`,100 IncompleteBrief: ({ missing }) => `the brief is missing ${list(missing)}`,101 LayerContentInPublicTree: ({ paths }) =>102 `a layer's files would enter a public tree: ${list(paths)}`,103 NoAsk: () => "this push names no open ask",104 NotClaimed: ({ ask }) => `you hold no claim on ${ask}`,

Merge build/1105 into mainoscabrielbefore adoption1fc92ed

lines 105–106why, one step back
105 // `today` across every project raises it too, so it names no project.
106 NotDecider: () =>

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 107why, one step back
107 "you are not a maintainer here: only the maintainers a project's config names may do this",

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 108–112why, one step back
108 NotRedFirst: () =>
109 "the ask's check must fail on main twice in the same way, by an assertion",110 NotSensitive: ({ key }) =>111 `${key} is not @sensitive, so it holds no write-only value`,112 NotVouched: () => "no member of this project has vouched for you",

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 113–114why, one step back
113 NotYourNamespace: ({ handle, project }) =>
114 `${ownerOf(project)} is not yours to make projects in: you are ${handle}`,

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 115–117why, one step back
115 OutOfScope: ({ paths }) =>
116 `changes paths outside the ask's territory: ${list(paths)}; put those files back, or flag the ask if the want needs them`,117 PostureChange: ({ from, to }) =>

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 118why, one step back
118 `landing would change the posture from ${from} to ${to}, which takes a maintainer`,

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 119–121why, one step back
119 PrivatePathInPublicTree: ({ paths }) =>
120 `would put held-back paths in a public tree: ${list(paths)}; those paths belong to a layer, so remove them from the answer`,121 ProjectExists: ({ project }) => `a project named ${project} already exists`,

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 122–123why, one step back
122 ProposalClosed: ({ proposal }) =>
123 `${proposal} was already accepted, declined or expired`,

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 124–128why, one step back
124 ReachedInternals: ({ from, to }) =>
125 `${from} reaches into ${to}, which its module does not export; import it through that module's public exports instead`,126 RepoBusy: () => "the repo was busy with another push",127 SecretInOutput: ({ item, where }) =>128 `the write-only value ${item} appeared in the ${where}`,

Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097

line 129why, one step back
129 StaleBase: ({ base, conflicts, main, movedBy = [] }) =>

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 130–131why, one step back
130 conflicts.length === 0
131 ? `main moved to ${short(main)}, past your base ${short(base)}`

Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097

line 132why, one step back
132 : `main moved to ${short(main)}, past your base ${short(base)}; conflicts in ${list(conflicts.map((path) => conflictIn(path, movedBy)))}`,

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 133–140why, one step back
133 StaleLayer: ({ layer }) =>
134 `the ${layer} layer moved since this answer was checked; it will be checked again`,135 TouchedJudge: ({ paths }) =>136 `changes files that decide what the checks do: ${list(paths)}; the checks are fixed for this ask, so put them back, or flag the ask if a check is wrong`,137 UnknownAsk: ({ ask }) => `this project has no ask named ${ask}`,138 UnknownCommit: ({ sha }) => `this project has no commit ${sha}`,139 UnknownDecision: ({ decision }) => `this project has no decision ${decision}`,140 UnknownEnvItem: ({ key }) => `the env shape has no item ${key}`,

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 141–142why, one step back
141 UnknownPath: ({ commit, path }) =>
142 `${short(commit)} has no file or folder at ${path}`,

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 143why, one step back
143 UnknownProject: ({ project }) => `no project is named ${project}`,

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 144–146why, one step back
144 UnknownProposal: ({ proposal }) => `this project has no proposal ${proposal}`,
145 UnknownRevision: ({ rev }) =>146 `${rev} is neither main, a commit this project holds, nor one of its tags`,

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 147–158why, one step back
147 UnstatedRequirement: ({ area }) =>
148 `a held-back check in ${area} enforces something no public clause states`,149 ValueTooShort: ({ key, minimum }) =>150 `the value for ${key} is shorter than the ${minimum} characters it needs`,151 VerifierBlocked: () =>152 "the platform could not run the checks; it will run them again",153 WeakCheck: ({ weakness }) => `the ask's check is weak: ${weakness}`,154 Weakened: ({ weakening }) => {155 if ("ratchet" in weakening) {156 return `raises the ${weakening.ratchet} ratchet in ${weakening.territory} from ${weakening.before} to ${weakening.after}`;157 }158

Merge build/1105 into mainoscabrielbefore adoption1fc92ed

line 159why, one step back
159 // A reasoned marker opens a decision, not a refusal: a refusal that

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 160why, one step back
160 // carries a reason is a waiver a maintainer declined.

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 161why, one step back
161 return weakening.reason === undefined

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

lines 162–163why, one step back
162 ? `adds ${weakening.marker} without a reason; remove it, or give a reason after " -- " for a maintainer to weigh`
163 : `adds ${weakening.marker} with the reason "${weakening.reason}"; a maintainer declined it, so take the marker out`;

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 164–199why, one step back
164 },
165});166167const block = (refusal: Refusal) => [168 `${refusal._tag}: ${reason(refusal)}`,169 ...(refusal.at === undefined170 ? []171 : [` at: ${refusal.at.path}:${refusal.at.line}`]),172 ` next: ${refusal.next}`,173 ` retryable: ${refusal.retryable ? "yes" : "no"}`,174];175176export const headline = (refusals: Array.NonEmptyReadonlyArray<Refusal>) => {177 const [first, ...rest] = refusals;178179 return rest.length === 0180 ? first._tag181 : `${first._tag} and ${rest.length} more`;182};183184export const explain = (refusals: Array.NonEmptyReadonlyArray<Refusal>) =>185 refusals.flatMap(block);186187export const receiptLine = (188 receipt: AnswerReceipt189): Result.Result<string, readonly Refusal[]> => {190 const at = `${receipt.ask} at ${short(receipt.head)}`;191 const follow = `follow with ${Brand.cli} status`;192193 return Outcome.match<Result.Result<string, readonly Refusal[]>>(194 receipt.outcome,195 {196 AwaitingDecision: ({ decision }) =>197 Result.succeed(`${at} waits on decision ${decision}; ${follow}`),198 AwaitingFinish: () =>199 Result.succeed(

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 200why, one step back
200 `${at} passed and waits for a maintainer's finish; ${follow}`

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 201–209why, one step back
201 ),
202 Checking: () => Result.succeed(`checking ${at}; ${follow}`),203 Landed: ({ sha }) => Result.succeed(`${at} landed as ${short(sha)}`),204 Refused: ({ refusals }) => Result.fail(refusals),205 WaitingOnParent: ({ ask }) =>206 Result.succeed(`${at} passed and waits for ${ask} to land; ${follow}`),207 }208 );209};