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.
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
Provenance
- Commit
d1bcd43- Tree
f7f6903- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
42ea9b7
8 files changed+246 added−14 removed
modified:apps/cli/src/render.ts+7 added-3 removed
417 unmodified lines418 )419 );420 };421 422-/** 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+ */427 const pendingText = ({ at, reason }: PolicyPending) => {428 const notEvaluated = `The config at the landed commit ${short(at)} has not been evaluated`;429 430 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 linesmodified:apps/cli/test/policy-view.test.ts+16 added-3 removed
134 unmodified lines135 expect(lines).toContain(line);136 }137 });138 139+ // 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));143 144 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 });149 150+ it("names init with --project in the Markdown form too, without the page's clone sentence", () => {151+ const view = Option.getOrThrow(views.projectPolicy(noConfig));152+153+ 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+ });160+161 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 linesmodified:apps/web/src/features/ask/ask-page.tsx+9 added-2 removed
220 unmodified lines221 · 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 linesmodified:apps/web/test/ask.test.tsx+25 added
5 unmodified lines6 */7 import { describe, expect, it } from "@effect/vitest";8 import { Brand } from "@repo/brand";9 import { Client, Contracts } from "@repo/protocol/contracts";10+import { Glob } from "@repo/protocol/domain/common";11 import { AskId, Handle } from "@repo/protocol/ids";12 import { UnknownAsk } from "@repo/protocol/refusal";13 import { explain } from "@repo/protocol/render";14 import { asTester, unanswered } from "@repo/protocol/testing";82 unmodified lines97 ).toBeTruthy();98 expect(markupOf(page())).toContain('href="/people/ines-v"');99 });100 101+ // 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+ );113+114+ const field = text.slice(115+ text.indexOf("Territory"),116+ text.indexOf("Check", text.indexOf("Territory"))117+ );118+119+ 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+ });124+125 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 linesmodified:packages/project/src/project.ts+7 added-1 removed
1618 unmodified lines1619 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 linesadded:packages/project/test/brief.test.ts+128 added
1+import { describe, expect, it } from "@effect/vitest";2+import { RefName, RepoHost } from "@repo/artifacts/repo-host";3+import type { Ask } from "@repo/protocol/domain/ask";4+import { CheckSpec } from "@repo/protocol/domain/check";5+import { Glob } from "@repo/protocol/domain/common";6+import { AskId, LandedSha, LaneName, RepoName } from "@repo/protocol/ids";7+import { Anonymous, Person } from "@repo/protocol/principal";8+import { advanceTo } from "@repo/testkit/clock";9+import type { Files } from "@repo/testkit/git-client";10+import { aProject, withAsk } from "@repo/testkit/scenarios";11+import { Array, Effect, Option } from "effect";12+13+import type { ProjectApi } from "../src/project.ts";14+import { projectService } from "../src/project.ts";15+import { CheckScript, composedAt, Pusher, worldOf } from "./world.ts";16+17+/**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+ */22+const scenario = aProject().pipe(23+ withAsk({ id: "parse-iso", territory: "packages/parser" }),24+ withAsk({ id: "trim-input", territory: "." })25+);26+27+const 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;37+38+const policy = {39+ ...scenario.policy,40+ asks: scenario.policy.asks.map(byPaths),41+};42+43+const repo = RepoName.make(scenario.project);44+45+const mainRef = RefName.make("refs/heads/main");46+47+const alice = Person.make({ handle: scenario.initializer });48+49+const anyone = Anonymous.make({});50+51+const askOf = (id: string): Ask =>52+ Option.getOrThrow(Array.findFirst(policy.asks, (ask) => ask.id === id));53+54+const 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+];59+60+/** alice opens `id`: its file and its check, scripted red twice on main. */61+const openRed = (api: ProjectApi, id: string) =>62+ Effect.gen(function* () {63+ const { check, file } = askOf(id);64+65+ if (!CheckSpec.guards.RedThenGreen(check)) {66+ return yield* Effect.die(`${id}'s check is not red-then-green`);67+ }68+69+ const files = Array.make(70+ { content: `export default "${id}";\n`, path: file },71+ { content: `it("${id}", () => {});\n`, path: check.path }72+ );73+74+ const refs = yield* (yield* RepoHost).refs(repo).pipe(Effect.orDie);75+76+ const tip = LandedSha.make(77+ Option.getOrThrow(Option.fromNullishOr(refs.get(mainRef)))78+ );79+80+ 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+ );89+90+ return yield* api.openAsk(alice, { ask: AskId.make(id), files });91+ });92+93+/** The brief's Territory section, its one line. */94+const territoryLine = (brief: string) =>95+ brief.split("## Territory\n\n")[1]?.split("\n")[0];96+97+describe("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");103+104+ const api = yield* projectService(scenario.project);105+106+ yield* api.initProject(alice, {});107+108+ const first = yield* Pusher.use((pusher) =>109+ pusher.push(repo, Option.none(), start, "Start")110+ );111+112+ yield* api.recordFirstPush(alice, first);113+ yield* openRed(api, "parse-iso");114+ yield* openRed(api, "trim-input");115+116+ const paths = yield* api.showAsk(anyone, AskId.make("trim-input"));117+ const module = yield* api.showAsk(anyone, AskId.make("parse-iso"));118+119+ 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
57 unmodified lines5859606162626364656613 unmodified lines80818283848485868788899041 unmodified lines13213313413513613713813913614014114214314454 unmodified lines57 unmodified lines CapReached: capReason, ChecksFailed: ({ lane, logRef }) => logRef === ChecksFailed.withheld ? `the ${lane} checks failed; their log was withheld` : `the ${lane} checks failed; the log is at ${logRef}`, : `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}, for the answer's claimant and the project's deciders to read with ${Brand.cli} evidence`, ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`, DecisionClosed: ({ decision }) => `${decision} was already decided, or expired to its default`, Denounced: () =>13 unmodified lines LayerContentInPublicTree: ({ paths }) => `a layer's files would enter a public tree: ${list(paths)}`, NoAsk: () => "this push names no open ask", NotClaimed: ({ ask }) => `you hold no claim on ${ask}`, NotDecider: () => "only one of this project's deciders may do this", // `today` across every project raises it too, so it names no project. NotDecider: () => "you are not a decider here: only the deciders a project's config names may do this", NotRedFirst: () => "the ask's check must fail on main twice in the same way, by an assertion", NotSensitive: ({ key }) => `${key} is not @sensitive, so it holds no write-only value`,41 unmodified lines if ("ratchet" in weakening) { return `raises the ${weakening.ratchet} ratchet in ${weakening.territory} from ${weakening.before} to ${weakening.after}`; }
// A reasoned marker opens a decision, not a refusal: a refusal that // carries a reason is a waiver a decider declined. return weakening.reason === undefined ? `adds ${weakening.marker} without a reason; remove it, or give a reason after " -- " for a decider to weigh` : `adds ${weakening.marker}, with the reason "${weakening.reason}"; it waits for a decider because it raises this territory's escapes`; : `adds ${weakening.marker} with the reason "${weakening.reason}"; a decider declined it, so take the marker out`; },});
const block = (refusal: Refusal) => [54 unmodified linesmodified:packages/protocol/test/render.test.ts+47 added-2 removed
17 unmodified lines18 CapReached,19 ChecksFailed,20 DirectPush,21 DraftInProgress,22+ NotDecider,23 OutOfScope,24 PrivatePathInPublicTree,25 ProposalClosed,26 ReachedInternals,89 unmodified lines116 }),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 lines190 " retryable: no",191 ]);192 });193 194+ // 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+ ]);203+204+ 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+ });212+213 it("leaves a raised ratchet's reason as it was", () => {214 expect(215 explain([216 new Weakened({182 unmodified lines399 " retryable: no",400 ]);401 });402 403+ // 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";408+409+ 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+ });417+418+ // `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({})]);421+422+ 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+ });427+428 // 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