Skip to content
Myr

Merge build/1105 into main

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by oscabriel · committed by oscabriel · parents 82cc398, 4825e07 · Browse files · 11 files+294 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+294 added−19 removed

  • tests:+236 added−6 removed
  • other:+58 added−13 removed

11 files+294 added−19 removed

modified:apps/cli/src/local/check.ts+7 added-1 removed
789 unmodified lines
790791 const failed = run.lanes.flatMap(({ command, lane, result }) =>792 result === "passed"793 ? []794 : [new ChecksFailed({ lane, logRef: `local:${lane}`, next: command })]794 : [795 new ChecksFailed({796 lane,797 logRef: ChecksFailed.localRef(lane),798 next: command,799 }),800 ]801 );802803 for (const evidence of run.evidence) {804 if (evidence.signature !== undefined) {
65 unmodified lines
modified:apps/cli/src/render.ts+7 added-3 removed
417 unmodified lines
418 )419 );420};421422/** Why the config at the landed commit has not evaluated, and what makes it, in the people page's words. */422/**423 * Why the config at the landed commit has not evaluated, and the step that424 * makes it, as a terminal's lines. The view sees only the success, which425 * names no project, so the command names it as `<project>`.426 */427const pendingText = ({ at, reason }: PolicyPending) => {428 const notEvaluated = `The config at the landed commit ${short(at)} has not been evaluated`;429430 return reason === "noConfig"431 ? [428 `${notEvaluated}: the project has no ${Brand.configDir}/ folder, and the defaults need a test command that the platform could not find in its CI or package files.`,429 `To make it evaluate, a decider lands a ${PROJECT_FILE} that names the test command (\`${Brand.cli} init --dry-run\` in a clone prints the one the CLI proposes); it is evaluated again at every landing.`,432 `${notEvaluated}: there is no ${Brand.configDir}/ folder, and no test command in the project's CI or package files.`,433 `Run \`${Brand.cli} init --project <project> --dry-run\` in the project's repo to see the ${PROJECT_FILE} it proposes, then have a decider land it.`,434 ]435 : [436 `${notEvaluated}: ${Brand.configDir}/ at ${short(at)} did not evaluate.`,437 `Fix it by landing a change to ${Brand.configDir}/; it is evaluated again at every landing.`,
127 unmodified lines
modified:apps/cli/test/local/check.test.ts+1 added-1 removed
475 unmodified lines
476 ok: false,477 refusals: [478 new ChecksFailed({479 lane: "bad",480 logRef: "local:bad",480 logRef: ChecksFailed.localRef("bad"),481 next: "false",482 }),483 ],484 v: 1,
379 unmodified lines
modified:apps/cli/test/policy-view.test.ts+16 added-3 removed
134 unmodified lines
135 expect(lines).toContain(line);136 }137 });138139 // The view sees only the success, which names no project: the next step140 // names it as a placeholder, in the terminal's own short lines.139 it("says a project with no config folder has not been evaluated, why, and what makes it evaluate", () => {141 it("says a project with no config folder has not been evaluated, why, and the command that makes it evaluate", () => {142 const lines = linesOf(textOf(noConfig));143144 expect(lines).toStrictEqual([143 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated: the project has no ${Brand.configDir}/ folder, and the defaults need a test command that the platform could not find in its CI or package files.`,144 `To make it evaluate, a decider lands a ${Brand.configDir}/project.ts that names the test command (\`${Brand.cli} init --dry-run\` in a clone prints the one the CLI proposes); it is evaluated again at every landing.`,145 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated: there is no ${Brand.configDir}/ folder, and no test command in the project's CI or package files.`,146 `Run \`${Brand.cli} init --project <project> --dry-run\` in the project's repo to see the ${Brand.configDir}/project.ts it proposes, then have a decider land it.`,147 ]);148 });149150 it("names init with --project in the Markdown form too, without the page's clone sentence", () => {151 const view = Option.getOrThrow(views.projectPolicy(noConfig));152153 for (const form of [view.markdown, view.text ?? ""]) {154 expect(form).toContain(155 `\`${Brand.cli} init --project <project> --dry-run\``156 );157 expect(form.toLowerCase()).not.toContain("in a clone");158 }159 });160161 it("says a config folder that did not evaluate has not been evaluated, and to land a fix", () => {162 expect(linesOf(textOf(configFailed))).toStrictEqual([163 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated: ${Brand.configDir}/ at ${sha.slice(0, 7)} did not evaluate.`,164 `Fix it by landing a change to ${Brand.configDir}/; it is evaluated again at every landing.`,
49 unmodified lines
modified:apps/web/src/features/ask/ask-page.tsx+9 added-2 removed
220 unmodified lines
221 · opened <When at={ask.openedAt} now={now} />222 </span>223 </Field>224 <Field label="Territory">225 {/* A paths territory (module `.`) reads as its paths alone. */}226 {ask.territory.module === "." ? (227 <span className="text-muted-foreground">The paths </span>228 ) : (229 <>225 <Code>{ask.territory.module}</Code>226 <span className="text-muted-foreground">: </span>230 <Code>{ask.territory.module}</Code>231 <span className="text-muted-foreground">: </span>232 </>233 )}234 {ask.territory.paths.map((path, index) => (235 <span key={path}>236 {index === 0 ? null : ", "}237 <Code>{path}</Code>
96 unmodified lines
modified:apps/web/test/ask.test.tsx+25 added
5 unmodified lines
6 */7import { describe, expect, it } from "@effect/vitest";8import { Brand } from "@repo/brand";9import { Client, Contracts } from "@repo/protocol/contracts";10import { Glob } from "@repo/protocol/domain/common";11import { AskId, Handle } from "@repo/protocol/ids";12import { UnknownAsk } from "@repo/protocol/refusal";13import { explain } from "@repo/protocol/render";14import { asTester, unanswered } from "@repo/protocol/testing";
82 unmodified lines
97 ).toBeTruthy();98 expect(markupOf(page())).toContain('href="/people/ines-v"');99 });100101 // A paths territory (`territory.paths(...)`) has module `.`, which names102 // nothing a reader knows: the field gives its paths alone.103 it("gives a paths territory as its paths, with no module `.`", () => {104 const text = textOf(105 page({106 ...ask,107 territory: {108 module: ".",109 paths: [Glob.make("src/parse.ts"), Glob.make("test/parse.test.ts")],110 },111 })112 );113114 const field = text.slice(115 text.indexOf("Territory"),116 text.indexOf("Check", text.indexOf("Territory"))117 );118119 expect(120 inOrder(field, ["The paths", "src/parse.ts", "test/parse.test.ts"])121 ).toBeTruthy();122 expect(field).not.toMatch(/\s\.\s|\s\.:/u);123 });124125 it("gives the lines that clone the project, claim the ask and check an answer, with the CLI's own name", () => {126 expect(127 inOrder(textOf(page()), [128 `git clone ${platformUrl}/datekit.git`,
179 unmodified lines
modified:packages/project/src/project.ts+7 added-1 removed
1618 unmodified lines
1619 return [1620 `# ${brief.want}`,1621 "",1622 `Ask \`${ask.id}\` in ${ask.project}, a \`${ask.kind}\` ask from ${ask.askedBy}.`,1623 ...section("Territory", [`The module \`${territory.module}\`: ${paths}.`]),1623 // A paths territory (module `.`) is no module a reader would know: it1624 // reads as its paths alone.1625 ...section("Territory", [1626 territory.module === "."1627 ? `The paths ${paths}.`1628 : `The module \`${territory.module}\`: ${paths}.`,1629 ]),1630 ...section(1631 "Current",1632 Option.toArray(Option.fromUndefinedOr(brief.current))1633 ),
4178 unmodified lines
added:packages/project/test/brief.test.ts+128 added
1import { describe, expect, it } from "@effect/vitest";2import { RefName, RepoHost } from "@repo/artifacts/repo-host";3import type { Ask } from "@repo/protocol/domain/ask";4import { CheckSpec } from "@repo/protocol/domain/check";5import { Glob } from "@repo/protocol/domain/common";6import { AskId, LandedSha, LaneName, RepoName } from "@repo/protocol/ids";7import { Anonymous, Person } from "@repo/protocol/principal";8import { advanceTo } from "@repo/testkit/clock";9import type { Files } from "@repo/testkit/git-client";10import { aProject, withAsk } from "@repo/testkit/scenarios";11import { Array, Effect, Option } from "effect";1213import type { ProjectApi } from "../src/project.ts";14import { projectService } from "../src/project.ts";15import { CheckScript, composedAt, Pusher, worldOf } from "./world.ts";1617/**18 * datekit with two asks: `parse-iso` in the module `parser`, and19 * `trim-input` over two paths alone, as `territory.paths(...)` makes it20 * (module `.`).21 */22const scenario = aProject().pipe(23 withAsk({ id: "parse-iso", territory: "packages/parser" }),24 withAsk({ id: "trim-input", territory: "." })25);2627const byPaths = (ask: Ask): Ask =>28 ask.id === "trim-input"29 ? {30 ...ask,31 territory: {32 module: ".",33 paths: [Glob.make("src/trim.ts"), Glob.make("test/trim.test.ts")],34 },35 }36 : ask;3738const policy = {39 ...scenario.policy,40 asks: scenario.policy.asks.map(byPaths),41};4243const repo = RepoName.make(scenario.project);4445const mainRef = RefName.make("refs/heads/main");4647const alice = Person.make({ handle: scenario.initializer });4849const anyone = Anonymous.make({});5051const askOf = (id: string): Ask =>52 Option.getOrThrow(Array.findFirst(policy.asks, (ask) => ask.id === id));5354const start: Files = [55 ["package.json", '{ "name": "datekit", "workspaces": ["packages/*"] }\n'],56 ["packages/parser/src/parse.ts", "export const parse = (s) => ({});\n"],57 ["src/trim.ts", "export const trim = (s) => s;\n"],58];5960/** alice opens `id`: its file and its check, scripted red twice on main. */61const openRed = (api: ProjectApi, id: string) =>62 Effect.gen(function* () {63 const { check, file } = askOf(id);6465 if (!CheckSpec.guards.RedThenGreen(check)) {66 return yield* Effect.die(`${id}'s check is not red-then-green`);67 }6869 const files = Array.make(70 { content: `export default "${id}";\n`, path: file },71 { content: `it("${id}", () => {});\n`, path: check.path }72 );7374 const refs = yield* (yield* RepoHost).refs(repo).pipe(Effect.orDie);7576 const tip = LandedSha.make(77 Option.getOrThrow(Option.fromNullishOr(refs.get(mainRef)))78 );7980 yield* CheckScript.use(81 Effect.fnUntraced(function* (checker) {82 yield* checker.script(83 yield* composedAt(repo, tip, files),84 LaneName.make("redThenGreen"),85 ["failed", "failed"]86 );87 })88 );8990 return yield* api.openAsk(alice, { ask: AskId.make(id), files });91 });9293/** The brief's Territory section, its one line. */94const territoryLine = (brief: string) =>95 brief.split("## Territory\n\n")[1]?.split("\n")[0];9697describe("an ask's brief", () => {98 it.effect(99 "reads a paths territory as its paths, and a module's as the module",100 () =>101 Effect.gen(function* () {102 yield* advanceTo("2026-10-07T12:00:00Z");103104 const api = yield* projectService(scenario.project);105106 yield* api.initProject(alice, {});107108 const first = yield* Pusher.use((pusher) =>109 pusher.push(repo, Option.none(), start, "Start")110 );111112 yield* api.recordFirstPush(alice, first);113 yield* openRed(api, "parse-iso");114 yield* openRed(api, "trim-input");115116 const paths = yield* api.showAsk(anyone, AskId.make("trim-input"));117 const module = yield* api.showAsk(anyone, AskId.make("parse-iso"));118119 expect(territoryLine(paths.brief)).toBe(120 "The paths `src/trim.ts`, `test/trim.test.ts`."121 );122 expect(paths.brief).not.toContain("module");123 expect(territoryLine(module.brief)).toBe(124 "The module `parser`: `packages/parser/**`."125 );126 }).pipe(Effect.provide(worldOf({ policy }, "memory")))127 );128});
modified:packages/protocol/src/refusal.ts+11 added
207 unmodified lines
208}) {}209210// Checks211212const LOCAL = "local:";213214/** A check failed; `next` is the command that reproduces it. */215export class ChecksFailed extends Schema.TaggedError<ChecksFailed>()(216 "ChecksFailed",217 {
6 unmodified lines
224 * The `logRef` of a lane whose log held a stored write-only value: the log225 * was never kept, and nothing names the item.226 */227 static readonly withheld = "withheld";228229 /**230 * The `logRef` of a lane the CLI's local check ran on the caller's machine:231 * its log was kept nowhere, so `evidence` has nothing to read.232 */233 static readonly localRef = (lane: string) => `${LOCAL}${lane}`;234235 /** Whether `logRef` names a lane the local check ran. */236 static readonly isLocal = (logRef: string) => logRef.startsWith(LOCAL);237}238239/** A held-back check failed; only its area and suite are disclosed. */240export class HeldBackFailed extends Schema.TaggedError<HeldBackFailed>()(
305 unmodified lines
modified:packages/protocol/src/render.ts+17 added-6 removed
54 unmodified lines
55 AskFull: ({ ask }) => `someone else holds the claim on ${ask}`,56 AttemptsExhausted: ({ area, resetsAt }) =>57 `no attempts left on ${area} until ${DateTime.formatIso(resetsAt)}`,58 CapReached: capReason,59 ChecksFailed: ({ lane, logRef }) =>60 logRef === ChecksFailed.withheld61 ? `the ${lane} checks failed; their log was withheld`62 : `the ${lane} checks failed; the log is at ${logRef}`,59 ChecksFailed: ({ lane, logRef, next }) => {60 if (logRef === ChecksFailed.withheld) {61 return `the ${lane} checks failed; their log was withheld`;62 }6364 // `evidence` lets in the answerer and the project's deciders alone; the65 // local check keeps no log for it to read.66 return ChecksFailed.isLocal(logRef)67 ? `the ${lane} checks failed on this commit; run ${next} to see the failure`68 : `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 deciders read with ${Brand.cli} evidence`;69 },70 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,71 DecisionClosed: ({ decision }) =>72 `${decision} was already decided, or expired to its default`,73 Denounced: () =>
13 unmodified lines
87 LayerContentInPublicTree: ({ paths }) =>88 `a layer's files would enter a public tree: ${list(paths)}`,89 NoAsk: () => "this push names no open ask",90 NotClaimed: ({ ask }) => `you hold no claim on ${ask}`,84 NotDecider: () => "only one of this project's deciders may do this",91 // `today` across every project raises it too, so it names no project.92 NotDecider: () =>93 "you are not a decider here: only the deciders a project's config names may do this",94 NotRedFirst: () =>95 "the ask's check must fail on main twice in the same way, by an assertion",96 NotSensitive: ({ key }) =>97 `${key} is not @sensitive, so it holds no write-only value`,
41 unmodified lines
139 if ("ratchet" in weakening) {140 return `raises the ${weakening.ratchet} ratchet in ${weakening.territory} from ${weakening.before} to ${weakening.after}`;141 }142143 // A reasoned marker opens a decision, not a refusal: a refusal that144 // carries a reason is a waiver a decider declined.145 return weakening.reason === undefined146 ? `adds ${weakening.marker} without a reason; remove it, or give a reason after " -- " for a decider to weigh`136 : `adds ${weakening.marker}, with the reason "${weakening.reason}"; it waits for a decider because it raises this territory's escapes`;147 : `adds ${weakening.marker} with the reason "${weakening.reason}"; a decider declined it, so take the marker out`;148 },149});150151const block = (refusal: Refusal) => [
54 unmodified lines
modified:packages/protocol/test/render.test.ts+66 added-2 removed
17 unmodified lines
18 CapReached,19 ChecksFailed,20 DirectPush,21 DraftInProgress,22 NotDecider,23 OutOfScope,24 PrivatePathInPublicTree,25 ProposalClosed,26 ReachedInternals,
89 unmodified lines
116 }),117 starts: "Weakened: adds .skip( without a reason",118 },119 {119 ends: "; it waits for a decider because it raises this territory's escapes",120 ends: "; a decider declined it, so take the marker out",121 refusal: new Weakened({122 at: { line: 3, path },123 weakening: { marker: "oxlint-disable", reason: "generated code" },124 }),124 starts: 'Weakened: adds oxlint-disable, with the reason "generated code"',125 starts: 'Weakened: adds oxlint-disable with the reason "generated code"',126 },127 {128 ends: "; import it through that module's public exports instead",129 refusal: new ReachedInternals({
60 unmodified lines
190 " retryable: no",191 ]);192 });193194 // A reasoned marker opens a decision instead of a refusal, so a refused one195 // was declined by a decider: no reason given now changes that.196 it("says a decider declined a reasoned marker, and to take it out", () => {197 const lines = explain([198 new Weakened({199 at: { line: 3, path },200 weakening: { marker: ".skip(", reason: "flaky" },201 }),202 ]);203204 expect(lines).toStrictEqual([205 'Weakened: adds .skip( with the reason "flaky"; a decider declined it, so take the marker out',206 " at: src/a.ts:3",207 ` next: ${Brand.cli} check`,208 " retryable: no",209 ]);210 expect(lines.join("\n")).not.toContain("waits for a decider");211 });212213 it("leaves a raised ratchet's reason as it was", () => {214 expect(215 explain([216 new Weakened({
182 unmodified lines
399 " retryable: no",400 ]);401 });402403 // The lane's command reproduces the failure in a clone of the fork; the log404 // is read through `evidence`, which lets in the answerer and the project's405 // deciders alone.406 it("says the checks failed on the answer, the command that shows it, and where the log is kept", () => {407 const logRef = "datekit/push-2222222/unit#1";408409 expect(410 explain([new ChecksFailed({ lane: "unit", logRef, next: "bun test" })])411 ).toStrictEqual([412 `ChecksFailed: the unit checks failed on the answer; run bun test in a clone of the fork to see the failure; the log is kept as ${logRef}, which the answerer and the project's deciders read with ${Brand.cli} evidence`,413 " next: bun test",414 " retryable: no",415 ]);416 });417418 // The CLI's local check ran the lane on this machine: no log was kept, so419 // nothing points at `evidence`.420 it("says a lane the local check ran failed here, with no kept log to read", () => {421 const lines = explain([422 new ChecksFailed({423 lane: "unit",424 logRef: ChecksFailed.localRef("unit"),425 next: "bun test",426 }),427 ]);428429 expect(lines).toStrictEqual([430 "ChecksFailed: the unit checks failed on this commit; run bun test to see the failure",431 " next: bun test",432 " retryable: no",433 ]);434 expect(lines.join("\n")).not.toContain("evidence");435 });436437 // `today` across every project raises it too, so it names no project.438 it("tells a caller they are not a decider without naming a project", () => {439 const [line] = explain([new NotDecider({})]);440441 expect(line).toBe(442 "NotDecider: you are not a decider here: only the deciders a project's config names may do this"443 );444 expect(line).not.toContain("this project's");445 });446447 // Below the floor no acknowledgement helps, so the next step is another value.448 it("says a value below the floor needs another value, not an acknowledgement", () => {449 expect(450 explain([ValueTooShort.belowFloor(EnvKey.make("PAYMENTS_KEY"), 3)])
55 unmodified lines