Skip to content
Myr

Merge build/1004

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

authored by oscabriel · committed by oscabriel · parents e8561dc, 30e38d8 · Browse files · 6 files+577 added−29 removed
This commit

State

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

Diff stats

6 files+577 added−29 removed

  • tests:+322 added−14 removed
  • other:+255 added−15 removed

6 files+577 added−29 removed

modified:apps/cli/src/render.ts+136 added
11 unmodified lines
12 FrontPage,13 LedgerOf,14 ListAsks,15 ListProjects,16 PolicyOf,17 ShowAsk,18 Status,19 SubmitAnswer,20 TodayOf,
3 unmodified lines
24import { LandReceipt } from "@repo/protocol/domain/answer";25import type { AnswerReceipt } from "@repo/protocol/domain/answer";26import { DecisionSubject } from "@repo/protocol/domain/decision";27import { Outcome } from "@repo/protocol/domain/outcome";28import type { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";29import { LedgerEntry } from "@repo/protocol/domain/visibility";30import type { Refusal } from "@repo/protocol/refusal";31import { receiptLine } from "@repo/protocol/render";32import { DateTime, Option, Result, Schema } from "effect";
44 unmodified lines
77 ].join("\n"),78 };79};8081/** Labelled values, one a line: a Markdown list, and padded for a person. */82const fields = (rows: readonly (readonly [string, string])[]): View => {83 const width = Math.max(0, ...rows.map(([label]) => label.length));8485 return {86 markdown: rows.map(([label, value]) => `- ${label}: ${value}`).join("\n"),87 text: rows88 .map(([label, value]) => `${label.padEnd(width)} ${value}`)89 .join("\n"),90 };91};9293/** Views one after another, as sections. */94const joined = (...parts: readonly View[]): View => ({95 markdown: parts.map(({ markdown }) => markdown).join("\n\n"),96 text: parts.map(({ markdown, text }) => text ?? markdown).join("\n\n"),
207 unmodified lines
304 ])305 )306);307308const plural = (count: number, one: string, many: string) =>309 `${count} ${count === 1 ? one : many}`;310311/** How many a vouch file names, as the people page says none: "nobody". */312const countOf = (count: number) => (count === 0 ? "nobody" : `${count}`);313314const HOUR_MS = 3_600_000;315316/** A claim timing as the people page says it: whole hours up to two days, then days. */317const spanOf = (ms: number) => {318 if (ms % HOUR_MS !== 0) {319 return plural(Math.round(ms / 60_000), "minute", "minutes");320 }321322 const hours = ms / HOUR_MS;323324 return hours > 48 && hours % 24 === 0325 ? plural(hours / 24, "day", "days")326 : plural(hours, "hour", "hours");327};328329/** The config folder's `project.ts`. */330const PROJECT_FILE = `${Brand.configDir}/project.ts`;331332/** What a vouch gates, in the people page's words. */333const vouchModes = {334 all: "For everything: claiming an ask, offering a sealed answer and proposing an ask all need a vouch.",335 bansOnly:336 "Bans only: nobody needs a vouch, but a denounced person still may not claim, push or propose.",337 forCode:338 "For code: claiming an ask or offering a sealed answer needs a vouch; anyone not denounced may propose an ask.",339} as const satisfies Record<PublicPolicy["vouch"]["mode"], string>;340341/** A policy at its landed commit, section by section, as the people page shows it. */342const evaluated = (policy: PublicPolicy) => {343 const { agents, budget, caps, claims, record, vouch, vouches } = policy;344 const denounced = vouches.filter((line) => line.denounced).length;345346 return joined(347 prose(348 policy.source === "config"349 ? `As of ${short(policy.at)}, the landed commit, from ${PROJECT_FILE}.`350 : `As of ${short(policy.at)}, the landed commit. This project has no ${PROJECT_FILE}: the person who set it up decides everything, under the platform's defaults.`351 ),352 prose("Deciders by path:"),353 table(354 ["paths", "deciders"],355 policy.deciders.map(({ handles, paths }) => [paths, handles.join(", ")]),356 "Nobody decides."357 ),358 prose(359 `Vouching: ${vouchModes[vouch.mode]} ${vouch.file} vouches for ${countOf(vouches.length - denounced)} and denounces ${countOf(denounced)}.`360 ),361 prose("Limits:"),362 fields([363 [364 "Claims",365 `${plural(caps.claimsPerPerson, "claim", "claims")} per person at once`,366 ],367 [368 "Proposals",369 caps.proposalsPerPerson === 0370 ? "Proposals are off"371 : `${plural(caps.proposalsPerPerson, "proposal", "proposals")} per person at once`,372 ],373 [374 "Budget",375 `${plural(budget.decisionsPerDay, "decision", "decisions")} a day per decider; an undecided one takes its default after ${plural(budget.expireDays, "day", "days")}`,376 ],377 [378 "Claim timing",379 `warned after ${spanOf(claims.warnAfterMs)} without a push; lapses after ${spanOf(claims.lapseAfterMs)}`,380 ],381 [382 "Record",383 `a landing counts ${384 record.countsAfterDays === 0385 ? "from the day it lands"386 : `once it has stood ${plural(record.countsAfterDays, "day", "days")}`387 }, for ${plural(record.windowDays, "day", "days")}`,388 ],389 ]),390 prose(391 agents === "trailer"392 ? "Agents: each landing names the agents its people worked through, in an Assisted-by: trailer."393 : "Agents: landings carry no Assisted-by: trailer."394 )395 );396};397398/** Why the config at the landed commit has not evaluated, and what makes it, in the people page's words. */399const pendingText = ({ at, reason }: PolicyPending) => {400 const notEvaluated = `The config at the landed commit ${short(at)} has not been evaluated`;401402 return reason === "noConfig"403 ? [404 `${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.`,405 `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.`,406 ]407 : [408 `${notEvaluated}: ${Brand.configDir}/ at ${short(at)} did not evaluate.`,409 `Fix it by landing a change to ${Brand.configDir}/; it is evaluated again at every landing.`,410 ];411};412413const policy = viewOf(PolicyOf.successSchema, (read) => {414 if (read.policy !== undefined) {415 return evaluated(read.policy);416 }417418 if (read.unevaluated === undefined) {419 return prose(420 "Nothing has landed yet. The config is evaluated at every landing."421 );422 }423424 const lines = pendingText(read.unevaluated);425426 return { markdown: lines.join("\n\n"), text: lines.join("\n") };427});428429const ledger = viewOf(LedgerOf.successSchema, (book) =>430 joined(431 prose(`${book.project}: ${book.postureLabel}.`),432 table(
86 unmodified lines
519 frontPage: front,520 ledger,521 listAsks: asks,522 listProjects: projects,523 projectPolicy: policy,524 showAsk: ask,525 status,526 submitAnswer: submitted,527 today,
9 unmodified lines
added:apps/cli/test/policy-view.test.ts+190 added
1/**2 * `policy` as a person reads it: datekit's evaluated config folder at the3 * landed commit in the people page's words (deciders by path, the vouch4 * rule and its counts, the caps, budget, claim timing and record window),5 * or, with no policy there, why it has not evaluated and what makes it.6 * The view is a pure function of `projectPolicy`'s decoded success; under7 * `--json` the success prints as JSON whatever the view says.8 */9import { describe, expect, it } from "@effect/vitest";10import { Brand } from "@repo/brand";11import { Contracts, PolicyOf } from "@repo/protocol/contracts";12import type { PublicPolicy } from "@repo/protocol/domain/policy";13import { Envelope } from "@repo/protocol/envelope";14import { unanswered } from "@repo/protocol/testing";15import { Effect, Layer, Option, Schema } from "effect";1617import { views } from "../src/render.ts";18import { runProgram } from "./remote-server.ts";1920const sha = "4c2e6a8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c";2122const decodeSuccess = Schema.decodeSync(PolicyOf.successSchema);2324/** datekit's evaluated config folder at `sha`, encoded. */25const datekitPolicy = {26 agents: "trailer",27 at: sha,28 budget: { decisionsPerDay: 5, expireDays: 14 },29 caps: { claimsPerPerson: 3, proposalsPerPerson: 2 },30 claims: { lapseAfterMs: 86_400_000, warnAfterMs: 7_200_000 },31 deciders: [32 { handles: ["ines-v"], paths: "**" },33 { handles: ["okonkwo", "bram"], paths: "src/tz.ts" },34 ],35 judge: { paths: [`${Brand.configDir}/**`], pointers: [] },36 kinds: [],37 modules: [],38 ratchets: [],39 record: { countsAfterDays: 30, windowDays: 365 },40 run: { checks: { unit: "bun test" }, test: "bun test {path}" },41 source: "config",42 vouch: { file: `${Brand.configDir}/vouched.td`, mode: "forCode" },43 vouches: [44 { denounced: false, handle: "bram", note: "first answer landed" },45 { denounced: false, handle: "ines-v" },46 { denounced: true, handle: "spam-bot" },47 ],48 weakening: { markers: [] },49} as const satisfies typeof PublicPolicy.Encoded;5051/** datekit's policy as `projectPolicy` returns it. */52const datekit = decodeSuccess({ policy: datekitPolicy });5354const noConfig = decodeSuccess({55 unevaluated: { at: sha, reason: "noConfig" },56});5758const configFailed = decodeSuccess({59 unevaluated: { at: sha, reason: "configFailed" },60});6162/** What a person reads: the view's text, or its Markdown when it has none. */63const textOf = (success: typeof PolicyOf.successSchema.Type) =>64 Option.match(views.projectPolicy(success), {65 onNone: () => "",66 onSome: ({ markdown, text }) => text ?? markdown,67 });6869/** Each non-empty line, its runs of spaces made one. */70const linesOf = (text: string) =>71 text72 .split("\n")73 .map((line) => line.replaceAll(/\s+/gu, " ").trim())74 .filter((line) => line !== "");7576describe("policy's text view", () => {77 it("lists each decider glob with its handles, in the policy's order", () => {78 const lines = linesOf(textOf(datekit));7980 expect(lines).toContain("** ines-v");81 expect(lines).toContain("src/tz.ts okonkwo, bram");82 expect(lines.indexOf("** ines-v")).toBeLessThan(83 lines.indexOf("src/tz.ts okonkwo, bram")84 );85 });8687 it("says which commit it is as of, and where it comes from", () => {88 const text = textOf(datekit);8990 expect(text).toContain(`As of ${sha.slice(0, 7)}, the landed commit`);91 expect(text).toContain(`${Brand.configDir}/project.ts`);92 });9394 it("states the vouch rule in words, with how many are vouched for and denounced", () => {95 const text = textOf(datekit);9697 expect(text).toContain(98 "For code: claiming an ask or offering a sealed answer needs a vouch"99 );100 expect(text).toContain(101 `${Brand.configDir}/vouched.td vouches for 2 and denounces 1`102 );103 });104105 it("says a vouch file that names nobody vouches for nobody and denounces nobody, as the people page does", () => {106 const text = textOf(107 decodeSuccess({ policy: { ...datekitPolicy, vouches: [] } })108 );109110 expect(text).toContain(111 `${Brand.configDir}/vouched.td vouches for nobody and denounces nobody`112 );113 });114115 it("shows the caps, the budget, the claim timing and the record window", () => {116 const lines = linesOf(textOf(datekit));117118 for (const line of [119 "Claims 3 claims per person at once",120 "Proposals 2 proposals per person at once",121 "Budget 5 decisions a day per decider; an undecided one takes its default after 14 days",122 "Claim timing warned after 2 hours without a push; lapses after 24 hours",123 "Record a landing counts once it has stood 30 days, for 365 days",124 ]) {125 expect(lines).toContain(line);126 }127 });128129 it("says a project with no config folder has not been evaluated, why, and what makes it evaluate", () => {130 const lines = linesOf(textOf(noConfig));131132 expect(lines).toStrictEqual([133 `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.`,134 `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.`,135 ]);136 });137138 it("says a config folder that did not evaluate has not been evaluated, and to land a fix", () => {139 expect(linesOf(textOf(configFailed))).toStrictEqual([140 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated: ${Brand.configDir}/ at ${sha.slice(0, 7)} did not evaluate.`,141 `Fix it by landing a change to ${Brand.configDir}/; it is evaluated again at every landing.`,142 ]);143 });144145 it("says nothing has landed yet when there is neither a policy nor a reason", () => {146 expect(textOf(decodeSuccess({}))).toContain("Nothing has landed yet");147 });148});149150const decodeEnvelope = Schema.decodeEffect(151 Schema.fromJsonString(Envelope(Schema.Unknown))152);153154/** A platform whose `projectPolicy` answers `success`. */155const answering = (success: typeof PolicyOf.successSchema.Type) =>156 Layer.mergeAll(157 unanswered,158 Contracts.toLayerHandler("projectPolicy", () => Effect.succeed(success))159 );160161describe("policy on the command line", () => {162 it.effect("prints the text view for a person", () =>163 Effect.gen(function* () {164 const run = yield* runProgram(["policy", "--project", "datekit"], {165 handlers: answering(noConfig),166 });167168 expect(run.code).toBe(0);169 expect(run.out.join("\n")).toContain("has not been evaluated");170 })171 );172173 it.effect("prints the success as JSON under --json", () =>174 Effect.gen(function* () {175 const run = yield* runProgram(176 ["policy", "--project", "datekit", "--json"],177 { handlers: answering(noConfig) }178 );179180 expect(run.code).toBe(0);181 expect(run.out).toHaveLength(1);182 expect(yield* decodeEnvelope(run.out[0] ?? "")).toStrictEqual({183 command: "policy",184 data: { unevaluated: { at: sha, reason: "noConfig" } },185 ok: true,186 v: 1,187 });188 })189 );190});
modified:apps/web/e2e/imports.e2e.ts+7 added-1 removed
15 unmodified lines
16 * for a run while the imports go in one at a time. It only reads.17 */18import { expect, test } from "@playwright/test";19import type { Page } from "@playwright/test";20import { Brand } from "@repo/brand";21import { Config, Console, Effect, Option } from "effect";2223/** One imported project: where its pages look, and what they must show. */24interface Imported {
335 unmodified lines
360 `/${project}/people`,361 "people",362 evaluated363 ? { selectors: ['tr[data-paths="**"]'] }363 : { texts: ["has not been evaluated"] }364 : {365 texts: [366 "has not been evaluated",367 `the project has no ${Brand.configDir}/ folder`,368 ],369 }370 )371 ));372373 test(`${project}'s ${file} says why each line is there`, ({
233 unmodified lines
modified:apps/web/src/features/project-people/people-view.tsx+99 added-3 removed
5 unmodified lines
6 * budget and timings, and whether landings disclose agents. Each section7 * links the file it comes from at that commit.8 *9 * Props in, markup out: the route reads `projectPolicy` and `ledger`10 * (`src/client/{policy,ledger}.ts`) and hands them here. The page is10 * (`src/client/{policy,ledger}.ts`) and hands them here. With no policy at11 * the landed commit, the page says why (`unevaluated`: no config folder, or12 * one that did not evaluate), names the commit and says what makes it13 * evaluate; with no reason either, nothing has landed yet. The page is14 * read-only: the one way to change any of it is to land a change to the15 * config folder, and it says so with the commands.16 */17import { Brand } from "@repo/brand";15import type { PublicPolicy } from "@repo/protocol/domain/policy";18import type { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";19import type { Layer, Ledger, Members } from "@repo/protocol/domain/visibility";20import type { Handle, ProjectName } from "@repo/protocol/ids";21import { Option } from "effect";22import { Fragment } from "react";
46 unmodified lines
69/** A file at a commit, on the code browser. */70const blobPath = (project: ProjectName, at: string, path: string) =>71 `/${project}/blob/${at}/${path}`;7273/** A folder at a commit, on the code browser. */74const treePath = (project: ProjectName, at: string, path: string) =>75 `/${project}/tree/${at}/${path}`;7677/** The config folder as a reader writes it: `<configDir>/`. */78const CONFIG_DIR = `${Brand.configDir}/`;7980/** What a vouch gates, in words. */81const vouchModes = {82 all: "For everything: claiming an ask, offering a sealed answer and proposing an ask all need a vouch.",83 bansOnly:
283 unmodified lines
367 </>368 );369};370371/** The landed commit, short and linked: "The config at the landed commit <sha> has not been evaluated". */372const NotEvaluated = ({373 at,374 project,375}: {376 readonly at: string;377 readonly project: ProjectName;378}) => (379 <>380 {"The config at the landed commit "}381 <a className={`${LINK} ${CODE}`} href={`/${project}/commit/${at}`}>382 {short(at)}383 </a>384 {" has not been evaluated"}385 </>386);387388/**389 * Why the config at the landed commit has not been evaluated, and what390 * makes it evaluate: a `project.ts` naming the test command, or a fix to391 * the folder that did not evaluate. Either way, it evaluates again at392 * every landing.393 */394const Pending = ({395 pending,396 project,397}: {398 readonly pending: PolicyPending;399 readonly project: ProjectName;400}) => (401 <div402 className="border-rule flex flex-col gap-3 border border-dashed px-4 py-5"403 data-unevaluated={pending.reason}404 >405 {pending.reason === "noConfig" ? (406 <>407 <p className="max-w-[70ch] text-sm font-medium">408 <NotEvaluated at={pending.at} project={project} />409 {": the project has no "}410 <Code>{CONFIG_DIR}</Code>411 {412 " folder, and the defaults need a test command that the platform could not find in its CI or package files."413 }414 </p>415 <p className="max-w-[70ch] text-sm">416 {"To make it evaluate, a decider lands a "}417 <Code>{PROJECT_FILE}</Code>418 {419 " that names the test command. In a clone, this prints the file the CLI proposes from the repo's own files; add the test command to it, commit it, and land it with the commands below."420 }421 </p>422 <CommandLine423 command={`${Brand.cli} init --project ${project} --dry-run`}424 />425 </>426 ) : (427 <>428 <p className="max-w-[70ch] text-sm font-medium">429 <NotEvaluated at={pending.at} project={project} />430 {": "}431 <a432 className={`${LINK} ${CODE}`}433 href={treePath(project, pending.at, Brand.configDir)}434 >435 {CONFIG_DIR}436 </a>437 {` at ${short(pending.at)} did not evaluate.`}438 </p>439 <p className="max-w-[70ch] text-sm">440 {`Fix it by landing a change to ${CONFIG_DIR}.`}441 </p>442 </>443 )}444 <p className="text-muted-foreground text-sm">445 It is evaluated again at every landing.446 </p>447 </div>448);449450export const PeopleView = ({451 ledger,452 policy,453 project,454 unevaluated,455}: {456 readonly ledger: Ledger;457 readonly policy: Option.Option<PublicPolicy>;458 readonly project: ProjectName;459 /** Why there is no policy at the landed commit; none before the first landing. */460 readonly unevaluated: Option.Option<PolicyPending>;461}): ReactNode => (462 <PageShell title={`${project}: people`}>463 <ProjectNav current="people" project={project} />464 {Option.isSome(policy) ? (465 <Evaluated ledger={ledger} policy={policy.value} project={project} />466 ) : (467 <>376 <EmptyState title="The config at the landed commit has not been evaluated yet. It is evaluated once per landing; this page shows it once that is done." />468 {Option.isSome(unevaluated) ? (469 <Pending pending={unevaluated.value} project={project} />470 ) : (471 <EmptyState title="Nothing has landed yet. The config is evaluated at every landing; this page shows it once the first one lands." />472 )}473 <Layers ledger={ledger} project={project} />474 </>475 )}476 <Region id="editing" title="Changing these">
12 unmodified lines
modified:apps/web/src/routes/$project/people.tsx+13 added-11 removed
modified:apps/web/test/project-people.test.tsx+132 added-14 removed
8 unmodified lines
9import { describe, expect, it } from "@effect/vitest";10import { commandDocs } from "@repo/agent-kit/command-doc";11import { Brand } from "@repo/brand";12import { Client, Contracts } from "@repo/protocol/contracts";13import { PublicPolicy } from "@repo/protocol/domain/policy";13import { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";14import { Ledger } from "@repo/protocol/domain/visibility";15import { ProjectName } from "@repo/protocol/ids";16import { UnknownProject } from "@repo/protocol/refusal";17import { asTester, unanswered } from "@repo/protocol/testing";
81 unmodified lines
99 vouch: { file: `${Brand.configDir}/vouched.td`, mode: "forCode" },100 vouches: [],101});102103/** Why an import with no config folder, whose defaults found no test command, has no policy at `sha`. */104const noConfig = Schema.decodeSync(PolicyPending)({105 at: sha,106 reason: "noConfig",107});108109const burrowLedger = decodeLedger({110 entries: [],111 layers: [],112 posture: "open",
5 unmodified lines
118 <PeopleView119 ledger={datekitLedger}120 policy={Option.some(datekitPolicy)}121 project={datekit}122 unevaluated={Option.none()}123 />124);125126/** The markup from `start` up to `end` (or to the end): one section of the page. */
134 unmodified lines
261 <PeopleView262 ledger={datekitLedger}263 policy={Option.some({ ...datekitPolicy, agents: "none" })}264 project={datekit}265 unevaluated={Option.none()}266 />267 ),268 "agents"269 )
16 unmodified lines
286 ...datekitPolicy,287 vouch: { ...datekitPolicy.vouch, mode: "bansOnly" },288 })}289 project={datekit}290 unevaluated={Option.none()}291 />292 ),293 "vouching"294 )
92 unmodified lines
387 <PeopleView388 ledger={burrowLedger}389 policy={Option.some(burrowPolicy)}390 project={ProjectName.make("burrow")}391 unevaluated={Option.none()}392 />393 );394395 const markup = markupOf(view);
8 unmodified lines
404 expect(markup).not.toContain(`/${Brand.configDir}/project.ts"`);405 expect(textOf(view)).toContain("vouches for nobody");406 });407398 it("says the config has not been evaluated yet, and shows no tables, when there is no policy", () => {408 it("says nothing has landed yet, and shows no tables, when there is no policy and no reason", () => {409 const view = (410 <PeopleView411 ledger={datekitLedger}412 policy={Option.none()}413 project={datekit}414 unevaluated={Option.none()}415 />416 );417418 const markup = markupOf(view);419409 expect(textOf(view)).toContain("has not been evaluated yet");420 expect(textOf(view)).toContain("Nothing has landed yet");421 expect(markup).not.toContain("<table");422 expect(markup).not.toContain('id="vouching"');423 });424425 it("says a config with no config folder has not been evaluated, at which commit, and why", () => {426 const view = (427 <PeopleView428 ledger={burrowLedger}429 policy={Option.none()}430 project={ProjectName.make("burrow")}431 unevaluated={Option.some(noConfig)}432 />433 );434435 const text = textOf(view);436 const markup = markupOf(view);437438 expect(439 inOrder(text, [440 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated`,441 `the project has no ${Brand.configDir}/ folder`,442 "the defaults need a test command",443 "could not find in its CI or package files",444 ])445 ).toBeTruthy();446 expect(markup).toMatch(447 new RegExp(448 `<a\\b[^>]*href="/burrow/commit/${sha}"[^>]*>${sha.slice(0, 7)}</a>`,449 "u"450 )451 );452 expect(text).toContain(`${Brand.configDir}/project.ts`);453 expect(text).toContain("It is evaluated again at every landing.");454 expect(markup).not.toContain("<table");455 });456457 it("offers the CLI lines that make a config with no config folder evaluate, each a real command", () => {458 const lines = commandsOf(459 markupOf(460 <PeopleView461 ledger={burrowLedger}462 policy={Option.none()}463 project={ProjectName.make("burrow")}464 unevaluated={Option.some(noConfig)}465 />466 )467 );468469 expect(lines.map((line) => commandOf(line)?.path.join(" "))).toStrictEqual([470 "init",471 "ask open",472 "land",473 ]);474 expect(lines[0]).toContain("--dry-run");475476 for (const line of lines) {477 const flags = commandOf(line)?.flags ?? [];478479 expect(480 line481 .split(" ")482 .filter((word) => word.startsWith("--"))483 .filter((flag) => !flags.includes(flag))484 ).toStrictEqual([]);485 }486 });487488 it("says a config folder that did not evaluate has not been evaluated, linking the folder at that commit", () => {489 const view = (490 <PeopleView491 ledger={burrowLedger}492 policy={Option.none()}493 project={ProjectName.make("burrow")}494 unevaluated={Option.some({ ...noConfig, reason: "configFailed" })}495 />496 );497498 const text = textOf(view);499500 expect(text).toContain(501 `The config at the landed commit ${sha.slice(0, 7)} has not been evaluated: ${Brand.configDir}/ at ${sha.slice(0, 7)} did not evaluate`502 );503 expect(text).toContain(504 `Fix it by landing a change to ${Brand.configDir}/.`505 );506 expect(markupOf(view)).toMatch(507 new RegExp(508 `<a\\b[^>]*href="/burrow/tree/${sha}/${Brand.configDir}"[^>]*>${Brand.configDir}/</a>`,509 "u"510 )511 );512 expect(text).not.toContain("test command");513 });514515 it("shows a project without layers as open, with nothing held back", () => {516 const view = (517 <PeopleView518 ledger={burrowLedger}519 policy={Option.some(burrowPolicy)}520 project={ProjectName.make("burrow")}521 unevaluated={Option.none()}522 />523 );524525 expect(textOf(view)).toContain("Open: nothing is held back");
2 unmodified lines
528529/** A platform that knows only datekit, counting the reads it is asked for. */530const platformOf = (531 asked: Ref.Ref<number>,430 policy: Option.Option<PublicPolicy>532 read: {533 readonly policy?: PublicPolicy;534 readonly unevaluated?: PolicyPending;535 }536) =>537 Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(538 Layer.provide(539 Layer.mergeAll(
5 unmodified lines
545 if (project !== datekit) {546 return yield* new UnknownProject({ project });547 }548444 return Option.match(policy, {445 onNone: () => ({}),446 onSome: (evaluated) => ({ policy: evaluated }),447 });549 return read;550 })551 ),552 Contracts.toLayerHandler("ledger", ({ project }) =>553 Effect.gen(function* () {
16 unmodified lines
570 Effect.gen(function* () {571 const asked = yield* Ref.make(0);572573 const read = yield* readPeople("datekit").pipe(472 Effect.provide(platformOf(asked, Option.some(datekitPolicy)))574 Effect.provide(platformOf(asked, { policy: datekitPolicy }))575 );576577 expect(read.policy?.at).toBe(sha);578 expect(read.ledger.layers.map(({ name }) => name)).toStrictEqual([
2 unmodified lines
581 expect(yield* Ref.get(asked)).toBe(2);582 })583 );584483 it.effect("carries no policy while the config has not evaluated", () =>585 it.effect(586 "carries no policy, and why, while the config has not evaluated",587 () =>588 Effect.gen(function* () {589 const asked = yield* Ref.make(0);590591 const read = yield* readPeople("datekit").pipe(592 Effect.provide(platformOf(asked, { unevaluated: noConfig }))593 );594595 expect(read.policy).toBeUndefined();596 expect(read.unevaluated).toStrictEqual({ at: sha, reason: "noConfig" });597 })598 );599600 it.effect("carries neither before the first landing", () =>601 Effect.gen(function* () {602 const asked = yield* Ref.make(0);603604 const read = yield* readPeople("datekit").pipe(488 Effect.provide(platformOf(asked, Option.none()))605 Effect.provide(platformOf(asked, {}))606 );607491 expect(read.policy).toBeUndefined();608 expect(read).not.toHaveProperty("policy");609 expect(read).not.toHaveProperty("unevaluated");610 })611 );612613 it.effect("is a not-found for a project the platform does not know", () =>
1 unmodified line
615 const asked = yield* Ref.make(0);616617 const failed = yield* Effect.flip(618 readPeople("no-such-project").pipe(501 Effect.provide(platformOf(asked, Option.some(datekitPolicy)))619 Effect.provide(platformOf(asked, { policy: datekitPolicy }))620 )621 );622623 expect(isNotFound(failed)).toBeTruthy();
7 unmodified lines
631 const asked = yield* Ref.make(0);632633 const failed = yield* Effect.flip(634 readPeople("Not_A-Project").pipe(517 Effect.provide(platformOf(asked, Option.some(datekitPolicy)))635 Effect.provide(platformOf(asked, { policy: datekitPolicy }))636 )637 );638639 expect(isNotFound(failed)).toBeTruthy();
25 unmodified lines