render.ts
This file
Path
packages/protocol/src/render.ts
211 lines · 10.3 KiB · TypeScript
Last changed by
Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
History of this fileTake it
The walk stopped after 200 commits: lines older than 1e46e9a point at it.
Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 1–6why, one step back1import { 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 back7import { ownerOf } from "./ids.ts";Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 8why, one step back8import { ChecksFailed } from "./refusal.ts";Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
line 9why, one step back9import type { CapReached, MovedBy, Refusal } from "./refusal.ts";Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 10–14why, one step back1011const short = (sha: string) => sha.slice(0, 7);1213const list = (items: readonly string[]) => items.join(", ");14Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
lines 15–20why, one step back15const 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 orMerge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 21why, one step back21// landed, or a discussion closed.Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
lines 22–24why, one step back22const held = {23 claims: (cap) =>24 `you already hold ${counted(cap, "claim")}, the most this project allows`,Merge project/discussions into mainoscabrielbefore adoption29b0353
lines 25–26why, one step back25 discussions: (cap) =>26 `you already have ${counted(cap, "open discussion")} here, the most this project allows`,Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
lines 27–30why, one step back27} as const satisfies Record<CapLimit, (cap: number) => string>;2829const rated = {30 claims: { noun: "claim", verb: "made" },Merge project/discussions into mainoscabrielbefore adoption29b0353
line 31why, one step back31 discussions: { noun: "post", verb: "made" },Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
lines 32–42why, one step back32} as const satisfies Record<CapLimit, { noun: string; verb: string }>;3334const capReason = ({35 cap,36 limit = "claims",37 retryAfter,38}: CapReached): string =>39 retryAfter === undefined40 ? held[limit](cap)41 : `you ${rated[limit].verb} ${counted(cap, rated[limit].noun)} in the last minute, the most the platform allows; try again in ${retryAfter}s`;42Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
lines 43–56why, one step back43const conflictIn = (path: string, movedBy: readonly MovedBy[]) => {44 const mover = movedBy.find((moved) => moved.path === path);4546 if (mover === undefined) {47 return path;48 }4950 const { ask, author, landing } = mover;5152 return ask === undefined53 ? `${path} (last changed by ${author} in ${short(landing)})`54 : `${path} (last changed by ${author} in ${short(landing)}, for ${ask})`;55};56Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
lines 57–59why, one step back57// A branch is what a person pushes; every other ref the platform writes.58const BRANCH = "refs/heads/";59Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 60–68why, one step back60// Reasons name only what the refusal's reader may see: held-back checks give61// their area and suite, never a case or an input. A shape refusal's reason62// ends with how to repair it, after its first clause; `next` stays the command.63const reason = Match.typeTags<Refusal, string>()({64 AskBlocked: ({ ask, blockedBy }) =>65 `${ask} waits on ${list(blockedBy)} to land first`,66 AskFull: ({ ask }) => `someone else holds the claim on ${ask}`,67 AttemptsExhausted: ({ area, resetsAt }) =>68 `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 69why, one step back69 CapReached: capReason,Merge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 70–74why, one step back70 ChecksFailed: ({ lane, logRef, next }) => {71 if (logRef === ChecksFailed.withheld) {72 return `the ${lane} checks failed; their log was withheld`;73 }74Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 75why, one step back75 // `evidence` lets in the answerer and the project's maintainers alone; theMerge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 76–78why, one step back76 // local check keeps no log for it to read.77 return ChecksFailed.isLocal(logRef)78 ? `the ${lane} checks failed on this commit; run ${next} to see the failure`Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
line 79why, one step back79 : `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 ${logRef} --project <owner>/<name>`;Merge build/1105 into mainoscabrielbefore adoption1fc92ed
line 80why, one step back80 },Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 81–84why, one step back81 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,82 DecisionClosed: ({ decision }) =>83 `${decision} was already decided, or expired to its default`,84 Denounced: () =>Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 85why, one step back85 "this project's vouch file denounces you, so it takes no claims or posts from you",Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 86why, one step back86 DirectPush: ({ ref }) =>Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
line 87why, one step back87 ref.startsWith(BRANCH)Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
line 88why, one step back88 ? `main moves only by a landing, so ${ref} takes no direct push; a contributor pushes the answer to the claim's fork, and a maintainer makes a working fork with ${Brand.cli} fork and lands it with ${Brand.cli} land`Say which limit a CapReached reached and when to try again, and that a fork takes branches onlyoscabrielbefore adoption42ea9b7
line 89why, one step back89 : `${ref} is written by the platform, not pushed; a fork takes branches only, so push your answer with git push ${Brand.slug} HEAD:main`,Merge project/discussions into mainoscabrielbefore adoption29b0353
line 90why, one step back90 DiscussionClosed: ({ discussion }) =>Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 91why, one step back91 `${discussion} is closed, or became an ask, so it takes no more posts`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 92–101why, one step back92 Flake: ({ lane }) =>93 `the ${lane} checks failed, then passed on the same tree; the platform will run them again`,94 HeldBackFailed: ({ area, suite }) =>95 `a held-back check failed in ${area}, suite ${suite}`,96 ImportFailed: (refusal) => `the import failed: ${refusal.reason}`,97 IncompleteBrief: ({ missing }) => `the brief is missing ${list(missing)}`,98 LayerContentInPublicTree: ({ paths }) =>99 `a layer's files would enter a public tree: ${list(paths)}`,100 NoAsk: () => "this push names no open ask",101 NotClaimed: ({ ask }) => `you hold no claim on ${ask}`,Merge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 102–103why, one step back102 // `today` across every project raises it too, so it names no project.103 NotDecider: () =>Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 104why, one step back104 "you are not a maintainer here: only the maintainers a project's config names may do this",Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
lines 105–106why, one step back105 // The ask is not on main until it opens, so the local check cannot judge it:106 // the lane's own command, run on main, shows what it does.Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 107why, one step back107 NotRedFirst: () =>Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
line 108why, one step back108 "the ask's check must fail on main twice the same way, with a failing assertion, not a load or syntax error, on two runs; run the lane's command on it yourself, then open the ask again",Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 109–111why, one step back109 NotSensitive: ({ key }) =>110 `${key} is not @sensitive, so it holds no write-only value`,111 NotVouched: () => "no member of this project has vouched for you",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 112–113why, one step back112 NotYourNamespace: ({ handle, project }) =>113 `${ownerOf(project)} is not yours to make projects in: you are ${handle}`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 114why, one step back114 OutOfScope: ({ paths }) =>Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 115why, one step back115 `changes paths outside the ask's territory: ${list(paths)}; put those files back, or say why the want needs them in a discussion`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 116why, one step back116 PostureChange: ({ from, to }) =>Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 117why, one step back117 `landing would change the posture from ${from} to ${to}, which takes a maintainer`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 118–125why, one step back118 PrivatePathInPublicTree: ({ paths }) =>119 `would put held-back paths in a public tree: ${list(paths)}; those paths belong to a layer, so remove them from the answer`,120 ProjectExists: ({ project }) => `a project named ${project} already exists`,121 ReachedInternals: ({ from, to }) =>122 `${from} reaches into ${to}, which its module does not export; import it through that module's public exports instead`,123 RepoBusy: () => "the repo was busy with another push",124 SecretInOutput: ({ item, where }) =>125 `the write-only value ${item} appeared in the ${where}`,Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
lines 126–129why, one step back126 // With no conflict, main only kept moving while the answer was merged onto127 // it, and the platform merges again on the next push. A conflict is merged128 // by hand: the answer is judged from the newest landing it contains, so a129 // rebased answer carries every sibling's file as its own.Merge refusal/stale-base-movers into mainoscabrielbefore adoptiona23e097
line 130why, one step back130 StaleBase: ({ base, conflicts, main, movedBy = [] }) =>Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 131why, one step back131 conflicts.length === 0Merge protocol/next-commands into main, dropping the never-rebase clause now that an answer is judged from the newest landing it containsoscabrielbefore adoptionbf24bbf
lines 132–133why, one step back132 ? `main moved to ${short(main)}, past your base ${short(base)}, while this answer was checked; push again and the platform merges it onto the moved main`133 : `main moved to ${short(main)}, past your base ${short(base)}, at ${list(conflicts.map((path) => conflictIn(path, movedBy)))}; merge main into your answer: git fetch <platform>/<owner>/<name>.git main && git merge FETCH_HEAD, then push again`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 134–136why, one step back134 StaleLayer: ({ layer }) =>135 `the ${layer} layer moved since this answer was checked; it will be checked again`,136 TouchedJudge: ({ paths }) =>Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 137why, one step back137 `changes files that decide what the checks do: ${list(paths)}; the checks are fixed for this ask, so put them back, or say why a check is wrong in a discussion`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 138–140why, one step back138 UnknownAsk: ({ ask }) => `this project has no ask named ${ask}`,139 UnknownCommit: ({ sha }) => `this project has no commit ${sha}`,140 UnknownDecision: ({ decision }) => `this project has no decision ${decision}`,Merge project/discussions into mainoscabrielbefore adoption29b0353
lines 141–142why, one step back141 UnknownDiscussion: ({ discussion }) =>142 `this project has no discussion ${discussion}`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 143why, one step back143 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 144–145why, one step back144 UnknownPath: ({ commit, path }) =>145 `${short(commit)} has no file or folder at ${path}`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 146why, one step back146 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 147–148why, one step back147 UnknownRevision: ({ rev }) =>148 `${rev} is neither main, a commit this project holds, nor one of its tags`,Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 149–160why, one step back149 UnstatedRequirement: ({ area }) =>150 `a held-back check in ${area} enforces something no public clause states`,151 ValueTooShort: ({ key, minimum }) =>152 `the value for ${key} is shorter than the ${minimum} characters it needs`,153 VerifierBlocked: () =>154 "the platform could not run the checks; it will run them again",155 WeakCheck: ({ weakness }) => `the ask's check is weak: ${weakness}`,156 Weakened: ({ weakening }) => {157 if ("ratchet" in weakening) {158 return `raises the ${weakening.ratchet} ratchet in ${weakening.territory} from ${weakening.before} to ${weakening.after}`;159 }160Merge build/1105 into mainoscabrielbefore adoption1fc92ed
line 161why, one step back161 // A reasoned marker opens a decision, not a refusal: a refusal thatMerge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 162why, one step back162 // carries a reason is a waiver a maintainer declined.Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
line 163why, one step back163 return weakening.reason === undefinedMerge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
lines 164–165why, one step back164 ? `adds ${weakening.marker} without a reason; remove it, or give a reason after " -- " for a maintainer to weigh`165 : `adds ${weakening.marker} with the reason "${weakening.reason}"; a maintainer declined it, so take the marker out`;Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 166–201why, one step back166 },167});168169const block = (refusal: Refusal) => [170 `${refusal._tag}: ${reason(refusal)}`,171 ...(refusal.at === undefined172 ? []173 : [` at: ${refusal.at.path}:${refusal.at.line}`]),174 ` next: ${refusal.next}`,175 ` retryable: ${refusal.retryable ? "yes" : "no"}`,176];177178export const headline = (refusals: Array.NonEmptyReadonlyArray<Refusal>) => {179 const [first, ...rest] = refusals;180181 return rest.length === 0182 ? first._tag183 : `${first._tag} and ${rest.length} more`;184};185186export const explain = (refusals: Array.NonEmptyReadonlyArray<Refusal>) =>187 refusals.flatMap(block);188189export const receiptLine = (190 receipt: AnswerReceipt191): Result.Result<string, readonly Refusal[]> => {192 const at = `${receipt.ask} at ${short(receipt.head)}`;193 const follow = `follow with ${Brand.cli} status`;194195 return Outcome.match<Result.Result<string, readonly Refusal[]>>(196 receipt.outcome,197 {198 AwaitingDecision: ({ decision }) =>199 Result.succeed(`${at} waits on decision ${decision}; ${follow}`),200 AwaitingFinish: () =>201 Result.succeed(Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 202why, one step back202 `${at} passed and waits for a maintainer's finish; ${follow}`Fill the README's numbers from the live swarm and core-loop runs on dev-oscabriel, and record their throwawaysoscabrielbefore adoption1e46e9a
lines 203–211why, one step back203 ),204 Checking: () => Result.succeed(`checking ${at}; ${follow}`),205 Landed: ({ sha }) => Result.succeed(`${at} landed as ${short(sha)}`),206 Refused: ({ refusals }) => Result.fail(refusals),207 WaitingOnParent: ({ ask }) =>208 Result.succeed(`${at} passed and waits for ${ask} to land; ${follow}`),209 }210 );211};