Merge build/1002
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents 51f046c, 0f7c1c9 · Browse files · 8 files·+377 added−85 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+377 added−85 removed
- tests:+213 added−1 removed
- other:+164 added−84 removed
Provenance
- Commit
1a364b9- Tree
b12b05a- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
51f046c- Parent 2
0f7c1c9
8 files changed+377 added−85 removed
modified:apps/cli/src/local/why.ts+19 added-7 removed
1 /**2 * `<cli> why <path>:<line>`: which landing put a line there, and why. git3- * blame names the commit; the platform's landing record names the ask, the4- * accountable author, every credit and the verdict. A commit the platform5- * did not land is said to be none of its landings, with the trailers its6- * author wrote. A verdict note fetched from the platform rides along, but3+ * blame names the commit; the platform's landing record names the ask (the4+ * one it answers, or the one an ask's opening opened), the accountable5+ * author, every credit and the verdict. A commit the platform did not land6+ * is said to be none of its landings, with the trailers its author wrote. A verdict note fetched from the platform rides along, but7 * the landing record is the source.8 */9 import { notesRef } from "@repo/git/notes";10 import { parseTrailers } from "@repo/git/trailers";249 unmodified lines260 ...verdict.lanes.map(({ lane, result }) => `${lane} ${result}`),261 ].join(", "),262 });263 264-const landingRows = (landing: LandingView): readonly Row[] => [265- landing.ask === undefined264+/**265+ * The ask a landing links: the one it answers ("Ask"), else the one it266+ * opened ("Opened": an opening answers nothing), else none.267+ */268+const askRow = (landing: LandingView): Row => {269+ if (landing.ask !== undefined) {270+ return { code: true, label: "Ask", value: landing.ask };271+ }272+273+ return landing.opened === undefined274 ? { label: "Ask", value: "none (a decider's own landing)" }267- : { code: true, label: "Ask", value: landing.ask },275+ : { code: true, label: "Opened", value: landing.opened };276+};277+278+const landingRows = (landing: LandingView): readonly Row[] => [279+ askRow(landing),280 { label: "Author", value: landing.author },281 ...landing.credits.map(({ handle, role }) => ({282 label: role,283 value: handle,140 unmodified linesmodified:apps/cli/test/local/why.test.ts+42 added
33 unmodified lines34 Path,35 Ref,36 Runtime,37 Schema,38+ Struct,39 } from "effect";40 import { CliOutput } from "effect/cli";41 import { RpcTest } from "effect/rpc";42 import { TestConsole } from "effect/testing";265 unmodified lines308 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))309 );310 311 it.live(312+ 'names the ask a line\'s landing opened in an "Opened" row, and no ask it answers',313+ () =>314+ Effect.gen(function* () {315+ const { dir } = yield* aRepo;316+317+ const opening = platform(({ sha }) =>318+ Effect.succeed({319+ landing: {320+ ...Struct.omit(landingOf(sha), ["ask"]),321+ opened: AskId.make("format-ordinal"),322+ },323+ })324+ );325+326+ const agent = yield* run(327+ dir,328+ ["src/week.ts:3", "--project", "datekit"],329+ opening,330+ OutputForAgent331+ );332+333+ expect(agent.code).toBe(0);334+ expect(agent.out.split("\n")).toStrictEqual(335+ expect.arrayContaining(["- Opened: `format-ordinal`"])336+ );337+ expect(agent.out).not.toContain("- Ask:");338+339+ const person = yield* run(340+ dir,341+ ["src/week.ts:3", "--project", "datekit"],342+ opening343+ );344+345+ expect(person.code).toBe(0);346+ expect(person.out.split("\n").map((line) => line.trim())).toStrictEqual(347+ expect.arrayContaining(["Opened: format-ordinal"])348+ );349+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))350+ );351+352+ it.live(353 "says a commit the platform did not land is none of its landings, and lists the trailers it carries",354 () =>355 Effect.gen(function* () {356 const { dir, second } = yield* aRepo;211 unmodified linesmodified:apps/web/e2e/why.e2e.ts+9 added-5 removed
123434567891011912131415161728 unmodified lines464748494650515253545 unmodified lines6061626360646566676812 unmodified lines/** * The deployed "why" page, as a browser shows it: a file a landing changed, * with at least one row naming the landing's ask, saved as * `e2e/out/why.png` for the shot list. * with at least one row linking an ask, saved as `e2e/out/why.png` for the * shot list. The ask a landing answers counts, and so does the ask an * opening opened ("Open ask <id>"), so a project whose landings are only * openings (burrow, or demo's datekit, where nothing is answered) passes on * an opening's file. * * It runs only against `WEB_URL` (a stage's web origin) and is skipped * without it. `WEB_PROJECT` picks the project (datekit, which the seed puts * on every stage, unless given) and `WEB_WHY_PATH` the file (datekit's * `src/format.ts` unless given). It only reads. * `src/format.ts` unless given; per stage, an opening's file such as * the config folder's `asks/format-ordinal.ask.ts`). It only reads. */import { expect, test } from "@playwright/test";import { Config, Effect, Option } from "effect";
28 unmodified lines Option.isNone(settings.web), "WEB_URL is not set: point it at a deployed web's origin to run this check" );
test(`${project}'s ${path} names the landing behind its lines, with its ask`, ({ test(`${project}'s ${path} names the landing behind its lines, with the ask it links`, ({ page: browser, }) => Effect.runPromise( Effect.gen(function* () {5 unmodified lines
expect(response?.status()).toBe(200);
// A range's row, in the server's table or above the drawn lines, // linking the ask its landing answered. // linking the ask its landing answered or opened. yield* Effect.promise(() => expect( browser.locator(`[data-range] a[href^="/${project}/asks/"]`).first() ).toBeVisible()12 unmodified linesmodified:apps/web/src/features/project/landings.tsx+56 added-50 removed
3 unmodified lines456789101112131415161718171819192021222122232423242526272829302627282930313233343536373839404139404142434445464748495051525354555657585960616242434445464748495051525354555657585960616263646566676869707172736465666768697071727374757677747576777879808182838485868710 unmodified lines3 unmodified lines * carries them (`CreditTrailers`: credit, then `Held-back:`, then the agents * used, apart, since they are never credit). */import type { LandingView } from "@repo/protocol/domain/landing";import { Option } from "effect";import type { DateTime } from "effect";
import { CreditTrailers } from "../shared/credits.tsx";import { HandleLink } from "../shared/handle.tsx";import { When } from "../shared/time.tsx";import { askOf } from "../why/rows.ts";import { ID, askPath } from "./asks.tsx";
/** * A landing's subject line. The platform writes `Answer <ask>` on a landing * that answers an ask; `LandingView` carries no subject for the rest (an * ask's opening, a decider's own landing, the first adoption), so those read * by what they are. * that answers an ask; `LandingView` carries no subject for the rest, so * those read by what they are: an ask's opening as `Open ask <ask>`, then a * decider's own landing and the first adoption. */export const landingSubject = (landing: LandingView) => { if (landing.ask !== undefined) { return `Answer ${landing.ask}`; }export const landingSubject = (landing: LandingView) => Option.match(askOf(landing), { onNone: () => landing.parent === undefined ? "First landing" : "Landed without an ask", onSome: ({ ask, kind }) => kind === "opened" ? `Open ask ${ask}` : `Answer ${ask}`, });
return landing.parent === undefined ? "First landing" : "Landed without an ask";};
const short = (sha: string) => sha.slice(0, 7);
const Landing = ({ landing, now,}: { readonly landing: LandingView; readonly now: DateTime.Utc;}) => { const linked = Option.getOrUndefined(askOf(landing));
}) => ( <li className="border-rule flex flex-col gap-3 border-t py-4" data-landing={landing.sha} > <div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1"> <h3 className="text-base font-semibold [overflow-wrap:anywhere]"> {landing.ask === undefined ? ( landingSubject(landing) ) : ( <a className="decoration-rule underline hover:decoration-current" href={askPath(landing.project, landing.ask)} > {landingSubject(landing)} </a> )} </h3> <p className="text-muted-foreground flex items-baseline gap-2 text-sm"> <code className={ID} title={landing.sha}> {short(landing.sha)} </code> <span aria-hidden="true">·</span> <When at={landing.landedAt} now={now} /> return ( <li className="border-rule flex flex-col gap-3 border-t py-4" data-landing={landing.sha} > <div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1"> <h3 className="text-base font-semibold [overflow-wrap:anywhere]"> {linked === undefined ? ( landingSubject(landing) ) : ( <a className="decoration-rule underline hover:decoration-current" href={askPath(landing.project, linked.ask)} > {landingSubject(landing)} </a> )} </h3> <p className="text-muted-foreground flex items-baseline gap-2 text-sm"> <code className={ID} title={landing.sha}> {short(landing.sha)} </code> <span aria-hidden="true">·</span> <When at={landing.landedAt} now={now} /> </p> </div> <p className="text-sm"> <span className="text-muted-foreground text-xs font-medium"> Author </span>{" "} <HandleLink handle={landing.author} /> </p> </div> <p className="text-sm"> <span className="text-muted-foreground text-xs font-medium">Author</span>{" "} <HandleLink handle={landing.author} /> </p> <CreditTrailers assisted={landing.assisted} credits={landing.credits} {...(landing.heldBackTrailer === undefined ? {} : { heldBack: landing.heldBackTrailer })} /> </li>); <CreditTrailers assisted={landing.assisted} credits={landing.credits} {...(landing.heldBackTrailer === undefined ? {} : { heldBack: landing.heldBackTrailer })} /> </li> );};
export const LandingList = ({ landings, now,10 unmodified linesmodified:apps/web/src/features/why/range-summary.tsx+58 added-21 removed
1 /**2 * One range's line of "why", shared by the server's table and the3- * browser's annotation rows: for a landing, "<subject> · <author> · <n>4- * credits · <verdict>", linking the commit, the ask, its answer and the5- * author; for a commit the project adopted, "<subject> · <author> · before6- * adoption". Then where to go from here: the file before this commit, and3+ * browser's annotation rows: for a landing, "<subject> · <ask> answer ·4+ * <author> · <n> credits · <verdict>", linking the commit, the ask, its5+ * answer and the author (an ask's opening reads "Open ask <ask>" instead,6+ * linking the ask alone: it answers nothing); for a commit the project7+ * adopted, "<subject> · <author> · before adoption". Then where to go from here: the file before this commit, and8 * the propose form about the range's first line. `LandingDetails` is the9 * whole landing, for the line dialog.10 */11 import type { WhyView } from "@repo/protocol/domain/code";4 unmodified lines16 import { answerPath, askPath } from "../ask/ask-page.tsx";17 import { commitHref, shortSha } from "../code/paths.ts";18 import { CreditTrailers } from "../shared/credits.tsx";19 import { HandleLink } from "../shared/handle.tsx";19-import { creditWords, priorHref, proposeHref, verdictWords } from "./rows.ts";20-import type { WhyRow } from "./rows.ts";20+import {21+ askOf,22+ creditWords,23+ priorHref,24+ proposeHref,25+ verdictWords,26+} from "./rows.ts";27+import type { LandingAsk, WhyRow } from "./rows.ts";28 29 const LINK = "decoration-rule underline hover:decoration-current";30 31 const ID = "font-mono text-[0.8125rem]";3 unmodified lines35 ·36 </span>37 );38 32-/** The ask a landing answers, with its answer's page. */39+/** The ask a landing links, as its id linking the ask's page. */40+const AskLink = ({41+ linked,42+ project,43+}: {44+ readonly linked: LandingAsk;45+ readonly project: ProjectName;46+}) => (47+ <a className={`${ID} ${LINK}`} href={askPath(project, linked.ask)}>48+ {linked.ask}49+ </a>50+);51+52+/**53+ * The ask a landing links: "<ask> answer" for the one it answers, with its54+ * answer's page; "Open ask <ask>" for the one it opened, which has none.55+ */56 const AskLinks = ({34- landing,57+ linked,58 project,59 }: {37- readonly landing: LandingView;60+ readonly linked: LandingAsk;61 readonly project: ProjectName;39-}) =>40- landing.ask === undefined ? null : (62+}) => {63+ const ask = <AskLink linked={linked} project={project} />;64+65+ return linked.kind === "opened" ? (66+ <span>Open ask {ask}</span>67+ ) : (68 <>42- <a className={`${ID} ${LINK}`} href={askPath(project, landing.ask)}>43- {landing.ask}44- </a>45- <a className={LINK} href={answerPath(project, landing.ask)}>69+ {ask}70+ <a className={LINK} href={answerPath(project, linked.ask)}>71 answer72 </a>73 </>74 );75+};76 77 /** "· <author> · before adoption", for a commit the project adopted. */78 const Adopted = ({ author }: { readonly author: string }) => (79 <>3 unmodified lines83 <span className="text-muted-foreground">before adoption</span>84 </>85 );86 61-/** "· <ask> answer · <author> · <n> credits · <verdict>", for a landing. */87+/**88+ * "· <ask> answer · <author> · <n> credits · <verdict>" for a landing, or89+ * "· Open ask <ask> · …" for an ask's opening.90+ */91 const Landed = ({92 landing,93 project,94 }: {95 readonly landing: LandingView;96 readonly project: ProjectName;97 }) => {98 const verdict = Option.getOrUndefined(verdictWords(landing));99+ const linked = Option.getOrUndefined(askOf(landing));100 101 return (102 <>73- {landing.ask === undefined ? null : (103+ {linked === undefined ? null : (104 <>105 {DOT}76- <AskLinks landing={landing} project={project} />106+ <AskLinks linked={linked} project={project} />107 </>108 )}109 {DOT}110 <HandleLink handle={landing.author} />85 unmodified lines196 readonly landing: LandingView;197 readonly project: ProjectName;198 }) => {199 const verdict = verdictWords(landing);200+ const linked = Option.getOrUndefined(askOf(landing));201 202 return (203 <div className="flex flex-col gap-3 text-sm">204 <dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1">174- {landing.ask === undefined ? null : (205+ {linked === undefined ? null : (206 <>176- <dt className={LABEL}>Ask</dt>207+ <dt className={LABEL}>208+ {linked.kind === "opened" ? "Opened ask" : "Ask"}209+ </dt>210 <dd className="flex gap-2">211+ {linked.kind === "opened" ? (212+ <AskLink linked={linked} project={project} />213+ ) : (178- <AskLinks landing={landing} project={project} />214+ <AskLinks linked={linked} project={project} />215+ )}216 </dd>217 </>218 )}219 <dt className={LABEL}>Author</dt>30 unmodified linesmodified:apps/web/src/features/why/rows.ts+22 added-1 removed
4 unmodified lines5 */6 import type { CommitView, WhyRange, WhyView } from "@repo/protocol/domain/code";7 import type { LandingView } from "@repo/protocol/domain/landing";8 import { Outcome } from "@repo/protocol/domain/outcome";9-import type { ProjectName } from "@repo/protocol/ids";9+import type { AskId, ProjectName } from "@repo/protocol/ids";10 import { Option } from "effect";11 12 import { whyHref } from "../code/paths.ts";13 30 unmodified lines44 /** A range as a reader says it: "line 4", or "lines 1–3". */45 export const linesWords = ({ end, start }: WhyRange) =>46 start === end ? `line ${start}` : `lines ${start}–${end}`;47 48+/**49+ * The ask a landing links, and how: the one it answers, or the one it50+ * opened (a migrate family's parent). An opening answers nothing, so it51+ * has no answer page and its link never reads as an answer.52+ */53+export type LandingAsk =54+ | { readonly kind: "answers"; readonly ask: AskId }55+ | { readonly kind: "opened"; readonly ask: AskId };56+57+/** Which ask `landing` links and how; none for a decider's own landing or an adoption. */58+export const askOf = (landing: LandingView): Option.Option<LandingAsk> => {59+ if (landing.ask !== undefined) {60+ return Option.some({ ask: landing.ask, kind: "answers" });61+ }62+63+ return Option.map(64+ Option.fromUndefinedOr(landing.opened),65+ (ask): LandingAsk => ({ ask, kind: "opened" })66+ );67+};68+69 /** A count of credit as a reader says it. */70 export const creditWords = (count: number) =>71 `${count} ${count === 1 ? "credit" : "credits"}`;72 31 unmodified linesadded:apps/web/test/landings.test.tsx+67 added
1+/**2+ * A project's landings list, rendered to HTML: each landing's subject says3+ * what it is and links the ask it answers or the ask it opened; one that4+ * did neither reads as what it is.5+ */6+import { describe, expect, it } from "@effect/vitest";7+import type { LandingView } from "@repo/protocol/domain/landing";8+import { AskId, LandedSha } from "@repo/protocol/ids";9+import { Struct } from "effect";10+11+import { LandingList } from "../src/features/project/landings.tsx";12+import { landing, markupOf, now, plainText } from "./ask-fixtures.ts";13+14+/** Every `href` in `markup`, in order. */15+const hrefsOf = (markup: string) =>16+ [...markup.matchAll(/href="(?<href>[^"]*)"/gu)].map(17+ (match) => match.groups?.href ?? ""18+ );19+20+/** The markup of the list item for the landing `sha`. */21+const itemOf = (markup: string, sha: string) =>22+ new RegExp(`<li\\b[^>]*data-landing="${sha}"[^>]*>[\\s\\S]*?</li>`, "u").exec(23+ markup24+ )?.[0] ?? "";25+26+/** `landing` without the ask it answers: a decider's own landing. */27+const unasked: LandingView = {28+ ...Struct.omit(landing, ["ask"]),29+ sha: LandedSha.make("e".repeat(40)),30+};31+32+/** An ask's opening: it opened `format-ordinal` and answers nothing. */33+const opening: LandingView = {34+ ...unasked,35+ opened: AskId.make("format-ordinal"),36+ sha: LandedSha.make("f".repeat(40)),37+};38+39+const markup = markupOf(40+ <LandingList landings={[landing, opening, unasked]} now={now} />41+);42+43+describe("a project's landings list", () => {44+ it('reads an opening as "Open ask <id>", linking the ask it opened', () => {45+ const item = itemOf(markup, opening.sha);46+47+ expect(plainText(item)).toContain("Open ask format-ordinal");48+ expect(plainText(item)).not.toContain("Landed without an ask");49+ expect(hrefsOf(item)).toContain("/datekit/asks/format-ordinal");50+ });51+52+ it("reads a landing that answers an ask as its answer, linking the ask", () => {53+ const item = itemOf(markup, landing.sha);54+55+ expect(plainText(item)).toContain("Answer parse-iso-week");56+ expect(hrefsOf(item)).toContain("/datekit/asks/parse-iso-week");57+ });58+59+ it("still reads a landing with neither as landed without an ask, linking none", () => {60+ const item = itemOf(markup, unasked.sha);61+62+ expect(plainText(item)).toContain("Landed without an ask");63+ expect(64+ hrefsOf(item).filter((href) => href.includes("/asks/"))65+ ).toStrictEqual([]);66+ });67+});modified:apps/web/test/why.test.tsx+104 added-1 removed
5 unmodified lines6 * answer, its commit and its people; the browser's drawing is Pierre's7 * (`<diffs-container>`), loaded only there.8 */9 import { describe, expect, it } from "@effect/vitest";10-import { WhyView } from "@repo/protocol/domain/code";10+import { CommitView, WhyView } from "@repo/protocol/domain/code";11+import { LandingView } from "@repo/protocol/domain/landing";12 import { Outcome } from "@repo/protocol/domain/outcome";13 import { LandedSha, ProjectName } from "@repo/protocol/ids";14 import { Schema } from "effect";15 import type { ReactElement } from "react";16 import { renderToStaticMarkup } from "react-dom/server";17 18+import { LandingDetails } from "../src/features/why/range-summary.tsx";19 import { WhyCode } from "../src/features/why/why-code.tsx";20 import { WhyLines } from "../src/features/why/why-view.tsx";21 22 const markupOf = (element: ReactElement) => renderToStaticMarkup(element);172 unmodified lines195 ).toContain("binary or too large");196 });197 });198 199+const OPENED = "6".repeat(40);200+201+/**202+ * `src/format.ts` where lines 1–2 came from an ask's opening: a landing203+ * with `opened` and no `ask`, so it answers nothing.204+ */205+const opening = Schema.decodeSync(WhyView)({206+ at: AT,207+ commits: [208+ {209+ author: signature("Ines", "2026-10-07T10:00:00.000Z"),210+ body: "",211+ committer: signature("platform", "2026-10-07T10:00:00.000Z"),212+ parents: [LANDED],213+ sha: OPENED,214+ subject: "Open format-ordinal",215+ trailers: [],216+ tree: "9".repeat(40),217+ },218+ ...view.commits.map((commit) => Schema.encodeSync(CommitView)(commit)),219+ ],220+ landings: [221+ ...view.landings.map((landing) => Schema.encodeSync(LandingView)(landing)),222+ {223+ assisted: [],224+ author: "ines-v",225+ credits: [{ handle: "ines-v", role: "Signed-off-by" }],226+ landedAt: "2026-10-07T10:00:00.000Z",227+ opened: "format-ordinal",228+ parent: LANDED,229+ project: "datekit",230+ sha: OPENED,231+ },232+ ],233+ path: "src/format.ts",234+ ranges: [235+ { end: 1, sha: LANDED, start: 1 },236+ { end: 3, sha: OPENED, start: 2 },237+ { end: 4, sha: IMPORTED, start: 4 },238+ ],239+});240+241+const opened = (242+ <WhyLines project={datekit} rev="main" text={TEXT} view={opening} />243+);244+245+describe("the why page's row for an ask's opening", () => {246+ it('links the ask it opened and reads "Open ask", with no answer link', () => {247+ const row = rowOf(markupOf(opened), "2-3");248+249+ expect(textOf(row)).toContain("Open ask format-ordinal");250+ expect(textOf(row)).toContain("ines-v");251+ expect(textOf(row)).toContain("1 credit");252+ expect(hrefsOf(row)).toContain("/datekit/asks/format-ordinal");253+ expect(254+ hrefsOf(row).filter((href) => href.includes("/answers/"))255+ ).toStrictEqual([]);256+ });257+258+ it("keeps an answering landing's ask and answer links, and an adopted commit's words", () => {259+ const markup = markupOf(opened);260+261+ expect(hrefsOf(rowOf(markup, "1-1"))).toStrictEqual(262+ expect.arrayContaining([263+ "/datekit/asks/parse-iso-week",264+ "/datekit/answers/parse-iso-week",265+ ])266+ );267+ expect(textOf(rowOf(markup, "1-1"))).not.toContain("Open ask");268+ expect(textOf(rowOf(markup, "4-4"))).toContain("before adoption");269+ });270+});271+272+/** The line dialog's landing, rendered; nothing for no landing. */273+const detailsOf = (landing: LandingView | undefined) =>274+ landing === undefined275+ ? ""276+ : markupOf(<LandingDetails landing={landing} project={datekit} />);277+278+describe("a line's landing, in the line dialog", () => {279+ it("names the ask an opening opened, linking it, and no answer", () => {280+ const markup = detailsOf(281+ opening.landings.find(({ sha }) => sha === OPENED)282+ );283+284+ expect(textOf(markup)).toContain("Opened ask format-ordinal");285+ expect(hrefsOf(markup)).toContain("/datekit/asks/format-ordinal");286+ expect(287+ hrefsOf(markup).filter((href) => href.includes("/answers/"))288+ ).toStrictEqual([]);289+ });290+291+ it("names the ask an answering landing answers, with its answer", () => {292+ const markup = detailsOf(view.landings[0]);293+294+ expect(textOf(markup)).toContain("Ask parse-iso-week");295+ expect(textOf(markup)).not.toContain("Opened ask");296+ expect(hrefsOf(markup)).toContain("/datekit/answers/parse-iso-week");297+ });298+});299+300 describe("the why page's drawing", () => {301 it("draws the file with @pierre/diffs", () => {302 expect(303 markupOf(<WhyCode project={datekit} text={TEXT} view={view} />)3 unmodified lines