Skip to content
Myr

Make the people page's commands runnable and keep each source link in its section

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

- The "Changing these" lines now give every flag their contracts need: `ask open` takes --files, `land` takes --base, --head, --message and --requestId, and both take --yes (each needs approval); the old lines failed with MissingValue. - Limits and Agents render their `project.ts` link inside their own section; it sat between sections before. - The bans-only rule says a denounced person still may not claim, push or propose, as `mayClaim`, `mayPropose` and the gate's parse stage hold; it said a denouncement bars only proposing. - Tests: each command line is a real CLI command from `commandDocs`, with every payload flag and --yes when it needs approval; each section links its file inside it; the bans-only words; the agents test now tells "trailer" from "none" (it passed for either before). All three new tests failed by assertion first. - Checked at 360 px on `vite dev`: no horizontal scroll.

authored by oscabriel · committed by oscabriel · parent b6ca01c · Browse files · 2 files+128 added−10 removed
This commit

State

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

Diff stats

2 files+128 added−10 removed

  • tests:+105 added−1 removed
  • other:+23 added−9 removed

2 files+128 added−10 removed

modified:apps/web/src/features/project-people/people-view.tsx+23 added-9 removed
73 unmodified lines
74/** What a vouch gates, in words. */75const vouchModes = {76 all: "For everything: claiming an ask, offering a sealed answer and proposing an ask all need a vouch.",77 bansOnly:78 "Bans only: nobody needs a vouch; a denouncement still bars the person it names from proposing.",78 "Bans only: nobody needs a vouch, but a denounced person still may not claim, push or propose.",79 forCode:80 "For code: claiming an ask or offering a sealed answer needs a vouch; anyone not denounced may propose an ask.",81} as const satisfies Record<PublicPolicy["vouch"]["mode"], string>;82
178 unmodified lines
261 </p>262 </Region>263);264265const Limits = ({ policy }: { readonly policy: PublicPolicy }) => {265const Limits = ({266 policy,267 source,268}: {269 readonly policy: PublicPolicy;270 readonly source: ReactNode;271}) => {272 const { budget, caps, claims, record } = policy;273274 return (275 <Region id="limits" title="Limits">
19 unmodified lines
295 : `once it has stood ${plural(record.countsAfterDays, "day", "days")}`296 }, for ${plural(record.windowDays, "day", "days")}`}297 </Field>298 </Fields>299 {source}300 </Region>301 );302};303297const Agents = ({ policy }: { readonly policy: PublicPolicy }) => (304const Agents = ({305 policy,306 source,307}: {308 readonly policy: PublicPolicy;309 readonly source: ReactNode;310}) => (311 <Region id="agents" title="Agents">312 <p className="max-w-[70ch] text-sm">313 {policy.agents === "trailer" ? (314 <>
5 unmodified lines
320 Landings carry no <Code>Assisted-by:</Code> trailer.321 </>322 )}323 </p>324 {source}325 </Region>326);327328/** The page over an evaluated policy: its commit, then each section. */
36 unmodified lines
365 {projectFile}366 </Region>367 <Vouching policy={policy} project={project} />368 <Layers ledger={ledger} project={project} />355 <Limits policy={policy} />356 {projectFile}357 <Agents policy={policy} />358 {projectFile}369 <Limits policy={policy} source={projectFile} />370 <Agents policy={policy} source={projectFile} />371 </>372 );373};374
20 unmodified lines
395 <p className="max-w-[70ch] text-sm">396 {`Change these by landing a change to ${Brand.configDir}/: open an ask for it, or, as a decider, land your own change.`}397 </p>398 <CommandLine387 command={`${Brand.cli} ask open <ask> --project ${project}`}399 command={`${Brand.cli} ask open <ask> --project ${project} --files <files> --yes`}400 />389 <CommandLine command={`${Brand.cli} land --project ${project}`} />401 <CommandLine402 command={`${Brand.cli} land --project ${project} --base <base> --head $(git rev-parse HEAD) --message <message> --requestId land-$(git rev-parse HEAD) --yes`}403 />404 </Region>405 </PageShell>406);
modified:apps/web/test/project-people.test.tsx+105 added-1 removed
5 unmodified lines
6 * budget and timings, and where each comes from at the landed commit. The7 * page is read-only, and it shows nothing the two contracts don't carry.8 */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";14import { Ledger } from "@repo/protocol/domain/visibility";
107 unmodified lines
122 markup.indexOf(start),123 end === undefined ? undefined : markup.indexOf(end)124 );125126/** The markup of the section whose heading has the id `id`. */127const sectionOf = (markup: string, id: string) => {128 const heading = markup.indexOf(`id="${id}"`);129130 return markup.slice(131 markup.lastIndexOf("<section", heading),132 markup.indexOf("</section>", heading)133 );134};135136/** Each shell line the page offers to copy, as typed. */137const commandsOf = (markup: string) =>138 [139 ...markup.matchAll(/<code\b[^>]*select-all[^>]*>(?<line>.*?)<\/code>/gsu),140 ].map((found) => plainText(found.groups?.line ?? "").trim());141142/** The CLI command a line runs: the longest command path it starts with. */143const commandOf = (line: string) =>144 commandDocs(Contracts)145 .filter(({ path }) => line.startsWith(`${Brand.cli} ${path.join(" ")} `))146 .toSorted((one, other) => other.path.length - one.path.length)147 .at(0);148149/** Each `<tr>`'s text, in order. */150const rowsOf = (markup: string) =>151 [...markup.matchAll(/<tr\b[^>]*>(?<row>.*?)<\/tr>/gsu)].map((found) =>152 plainText(found.groups?.row ?? "").trim()
82 unmodified lines
235 }236 });237238 it("says whether landings disclose the agents people worked through", () => {215 expect(textOf(page)).toContain("Assisted-by:");239 const disclosed = plainText(sectionOf(markupOf(page), "agents"));240241 const undisclosed = plainText(242 sectionOf(243 markupOf(244 <PeopleView245 ledger={datekitLedger}246 policy={Option.some({ ...datekitPolicy, agents: "none" })}247 project={datekit}248 />249 ),250 "agents"251 )252 );253254 expect(disclosed).toContain(255 "Each landing names the agents its people worked through"256 );257 expect(undisclosed).toContain("Landings carry no Assisted-by: trailer");258 expect(undisclosed).not.toContain("names the agents");259 });260261 it("says a denouncement still bars a person when the vouch rule is bans only", () => {262 const vouching = plainText(263 sectionOf(264 markupOf(265 <PeopleView266 ledger={datekitLedger}267 policy={Option.some({268 ...datekitPolicy,269 vouch: { ...datekitPolicy.vouch, mode: "bansOnly" },270 })}271 project={datekit}272 />273 ),274 "vouching"275 )276 );277278 expect(vouching).toContain("Bans only: nobody needs a vouch");279 expect(vouching).toContain(280 "a denounced person still may not claim, push or propose"281 );282 });283284 it("links the file each section comes from, inside that section", () => {285 const markup = markupOf(page);286 const projectFile = `href="/datekit/blob/${sha}/${Brand.configDir}/project.ts"`;287288 for (const id of ["deciders", "limits", "agents"]) {289 expect(sectionOf(markup, id)).toContain(projectFile);290 }291292 expect(sectionOf(markup, "vouching")).toContain(293 `href="/datekit/blob/${sha}/${Brand.configDir}/vouched.td"`294 );295 expect(markup.split(projectFile)).toHaveLength(4);296 });297298 it("says which commit it is as of, and links each source file at that commit", () => {299 const markup = markupOf(page);300301 expect(textOf(page)).toContain(`As of ${sha.slice(0, 7)}`);
22 unmodified lines
324 expect(text).toContain(`${Brand.cli} ask open`);325 expect(text).toContain(`${Brand.cli} land`);326 });327328 it("shows each command whole: a real CLI command, with every flag its payload takes and --yes", () => {329 const lines = commandsOf(markupOf(page));330331 expect(lines.map((line) => commandOf(line)?.contract)).toStrictEqual([332 "openAsk",333 "land",334 ]);335336 for (const line of lines) {337 const doc = commandOf(line);338 const given = line.split(" ").filter((word) => word.startsWith("--"));339340 const payload = (doc?.flags ?? []).filter(341 (flag) => !["--dry-run", "--json", "--yes"].includes(flag)342 );343344 expect(345 given.filter((flag) => !(doc?.flags ?? []).includes(flag))346 ).toStrictEqual([]);347 expect(payload.filter((flag) => !given.includes(flag))).toStrictEqual([]);348 expect(given.includes("--yes")).toBe(doc?.needsApproval);349 }350 });351352 it("adds no sealed path, check name, salt or read log to what it was given", () => {353 const markup = markupOf(page);354355 for (const leak of [
181 unmodified lines