Skip to content
Myr

Read four refusals, a paths territory and the CLI's policy view right

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

- Weakened with a reason says a decider declined it and to take the marker out: that refusal comes only from a declined waiver (a reasoned marker opens a decision instead). The no-reason and ratchet texts stay. - ChecksFailed says the checks failed on the answer, that running next in a clone of the fork shows the failure, and that the log is kept as its logRef for the answer's claimant and the project's deciders to read with evidence (who evidence lets in, read from its handler). The withheld case and next are unchanged. - NotDecider names no project: today across every project raises it too. - A paths territory (module ".") reads as "The paths ..." in the brief and on the ask page; a named module reads as before. - The CLI policy view's noConfig lines are a terminal's: short, imperative, naming `init --project <project> --dry-run` (the view sees only the success, so the project is a placeholder), without the page's clone sentence. configFailed and the evaluated view stay. - No field, tag, retryable or next changed. - Tests: render.test.ts (Weakened declined, ChecksFailed's next and log, NotDecider), brief.test.ts (new: showAsk over the memory world, paths and module territories), ask.test.tsx (a paths territory's field), policy-view.test.ts (noConfig in text and Markdown). - ASSUMPTION: a refused Weakened with a reason is always a declined waiver, as packages/project/src/landing.ts' declined is its one source.

authored by oscabriel · committed by oscabriel · parent 42ea9b7 · Browse files · 8 files+246 added−14 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+246 added−14 removed

  • tests:+216 added−5 removed
  • other:+30 added−9 removed

8 files+246 added−14 removed

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/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/render.ts+7 added-3 removed
modified:packages/protocol/test/render.test.ts+47 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 answer's claimant and the405 // project's deciders alone.406 it("says the checks failed on the answer, how to see 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 next in a clone of the fork to see the failure; the log is kept as ${logRef}, for the answer's claimant and the project's deciders to read with ${Brand.cli} evidence`,413 " next: bun test",414 " retryable: no",415 ]);416 });417418 // `today` across every project raises it too, so it names no project.419 it("tells a caller they are not a decider without naming a project", () => {420 const [line] = explain([new NotDecider({})]);421422 expect(line).toBe(423 "NotDecider: you are not a decider here: only the deciders a project's config names may do this"424 );425 expect(line).not.toContain("this project's");426 });427428 // Below the floor no acknowledgement helps, so the next step is another value.429 it("says a value below the floor needs another value, not an acknowledgement", () => {430 expect(431 explain([ValueTooShort.belowFloor(EnvKey.make("PAYMENTS_KEY"), 3)])
55 unmodified lines