ledger.test.tsx
This file
Path
apps/web/test/ledger.test.tsx
814 lines · 24.7 KiB · TypeScript
Last changed by
Merge redesign into mainoscabrielbefore adoptioncaedd21
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 1why, one step back1import { describe, expect, it } from "@effect/vitest";Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 2why, one step back2import { Brand } from "@repo/brand";Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 3–4why, one step back3import { Client, Contracts, EnvSchemaOf } from "@repo/protocol/contracts";4import { EnvSchemaView } from "@repo/protocol/domain/env";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 5–24why, one step back5import { ProjectListing } from "@repo/protocol/domain/front-page";6import { Ledger, LedgerEntry } from "@repo/protocol/domain/visibility";7import {8 AreaName,9 DecisionId,10 EnvKey,11 Handle,12 LandedSha,13 LayerName,14 SuiteRoot,15} from "@repo/protocol/ids";16import { UnknownProject } from "@repo/protocol/refusal";17import { asTester, unanswered } from "@repo/protocol/testing";18import { isNotFound } from "@tanstack/react-router";19import { DateTime, Effect, Layer, Option, Ref, Schema } from "effect";20import { Atom, AtomRegistry, Reactivity } from "effect/reactivity";21import { RpcTest } from "effect/rpc";2223import { keys } from "../src/client/keys.ts";24import { ledgerAtom } from "../src/client/ledger.ts";Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 25why, one step back25import { areaSummaries } from "../src/features/ledger/areas.ts";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 26why, one step back26import { ProjectView } from "../src/features/project/project-page.tsx";Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 27–31why, one step back27import { VisibilityView } from "../src/features/visibility/visibility-page.tsx";28import {29 readVisibility,30 VisibilityPageData,31} from "../src/routes/$owner/$project/visibility.tsx";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 32–33why, one step back32import { ContractsClient, webContracts } from "../src/surfaces.ts";33import { inOrder, markupOf, plainText, textOf } from "./ask-fixtures.ts";Merge redesign into mainoscabrielbefore adoptioncaedd21
line 34why, one step back34import { fixturesClient } from "./dev-client.ts";Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 35why, one step back35import { textIn } from "./markup.ts";Merge redesign into mainoscabrielbefore adoptioncaedd21
line 36why, one step back36import { elementWith, factsOf, mainOf } from "./records.ts";Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 37why, one step back37import { renderAt } from "./render.tsx";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 38–132why, one step back3839const now = DateTime.makeUnsafe("2026-10-12T12:00:00Z");4041const root = SuiteRoot.make(`sha256:3f9a${"0b1c".repeat(15)}`);4243const earlierRoot = SuiteRoot.make(`sha256:${"9e8d".repeat(16)}`);4445const exportArea = AreaName.make("export");4647const maintainers = LayerName.make("maintainers");4849const decodeLedger = Schema.decodeSync(Ledger);5051const datekitRead = decodeLedger({52 entries: [],53 layers: [54 {55 audience: "maintainers",56 disclose: "sealed",57 holds: ["checks", "agent-config", "notes"],58 name: "maintainers",59 readers: "deciders",60 reason:61 "Held-back checks judge an answer by the ask's words, not by tests it could read.",62 repo: "datekit--maintainers",63 writers: "deciders",64 },65 ],66 posture: "openWithSealedEvidence",67 postureLabel: "Open with sealed evidence",68 project: "datekit",69});7071const entries: readonly LedgerEntry[] = [72 LedgerEntry.cases.LayerDeclared.make({73 at: DateTime.makeUnsafe("2026-10-09T10:00:00.000Z"),74 disclose: "sealed",75 kinds: ["checks", "agent-config", "notes"],76 layer: maintainers,77 seq: 1,78 }),79 LedgerEntry.cases.PostureChanged.make({80 at: DateTime.makeUnsafe("2026-10-09T10:05:00.000Z"),81 decision: DecisionId.make("dec-000003"),82 from: "open",83 seq: 2,84 to: "openWithSealedEvidence",85 }),86 LedgerEntry.cases.CountChanged.make({87 area: exportArea,88 at: DateTime.makeUnsafe("2026-10-10T09:00:00.000Z"),89 count: 5,90 layer: maintainers,91 seq: 3,92 }),93 LedgerEntry.cases.CommitmentPublished.make({94 area: exportArea,95 at: DateTime.makeUnsafe("2026-10-10T09:00:00.000Z"),96 authors: 2,97 checks: 5,98 seq: 4,99 suite: earlierRoot,100 }),101 LedgerEntry.cases.Admitted.make({102 area: exportArea,103 at: DateTime.makeUnsafe("2026-10-11T08:00:00.000Z"),104 knownBadCaught: 2,105 mainRuns: 3,106 seq: 5,107 suite: root,108 }),109 LedgerEntry.cases.CommitmentPublished.make({110 area: exportArea,111 at: DateTime.makeUnsafe("2026-10-11T08:00:00.000Z"),112 authors: 3,113 checks: 7,114 seq: 6,115 suite: root,116 }),117 LedgerEntry.cases.ValueSet.make({118 at: DateTime.makeUnsafe("2026-10-11T09:30:00.000Z"),119 by: Handle.make("ines-v"),120 key: EnvKey.make("SENTRY_AUTH_TOKEN"),121 seq: 7,122 }),123 LedgerEntry.cases.Released.make({124 at: DateTime.makeUnsafe("2026-10-12T08:00:00.000Z"),125 by: Handle.make("okonkwo"),126 landing: LandedSha.make("9b1c3e5d7f9a1b3c5d7e9f1a3b5c7d9e1f3a5b7c"),127 layer: maintainers,128 paths: 2,129 seq: 8,130 }),131];132Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 133why, one step back133const parserArea = AreaName.make("parser");Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 134why, one step back134Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 135–150why, one step back135const parserRoot = SuiteRoot.make(`sha256:7fbe4b${"2c3d".repeat(14)}a1`);136137const parserCommitment = LedgerEntry.cases.CommitmentPublished.make({138 area: parserArea,139 at: DateTime.makeUnsafe("2026-10-12T08:00:00.000Z"),140 authors: 3,141 checks: 4,142 seq: 9,143 suite: parserRoot,144});145146const datekit: Ledger = {147 ...datekitRead,148 entries: [...entries, parserCommitment],149};150Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 151–158why, one step back151const open = decodeLedger({152 entries: [],153 layers: [],154 posture: "open",155 postureLabel: "Open",156 project: "burrow",157});158Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 159–181why, one step back159const datekitEnv = Schema.decodeSync(EnvSchemaView)({160 at: "9b1c3e5d7f9a1b3c5d7e9f1a3b5c7d9e1f3a5b7c",161 file: ".env.schema",162 imports: [],163 items: [164 {165 key: "APP_ENV",166 required: true,167 sensitive: false,168 tags: [],169 type: "enum(development, test, production)",170 },171 {172 key: "SENTRY_AUTH_TOKEN",173 placeholder: "placeholder-sentry-auth-token",174 required: "depends",175 sensitive: true,176 tags: ["release"],177 value: { setAt: "2026-10-10T09:30:00.000Z", setBy: "ines-v" },178 },179 ],180 project: "datekit",181});Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 182why, one step back182Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 183–189why, one step back183/** The tab as a ledger test reads it: the environment unread, as before a first landing. */184const tabWith = (ledger: Ledger, at: DateTime.Utc = now) => (185 <VisibilityView env={undefined} ledger={ledger} now={at} />186);187188const page = tabWith(datekit);189Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 190–199why, one step back190const seqsOf = (markup: string) =>191 [...markup.matchAll(/data-seq="(?<seq>\d+)"/gu)].map((found) =>192 Number(found.groups?.seq)193 );194195const whenOf = (markup: string, marker: string) =>196 /<time\b[^>]*>(?<when>[^<]*)<\/time>/u.exec(197 markup.slice(markup.indexOf(marker))198 )?.groups?.when;199Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 200–212why, one step back200const historyRowsOf = (markup: string) =>201 [202 ...mainOf(markup).matchAll(/<li\b[^>]*data-entry="[^"]*"[\s\S]*?<\/li>/gu),203 ].map(([row]) => row);204205const wordsOf = (markup: string) =>206 historyRowsOf(markup).map((row) =>207 plainText(elementWith(row, "data-entry-word")).trim()208 );209210const toneOf = (row: string) =>211 /text-sealed/u.test(elementWith(row, "data-entry-word")) ? "sealed" : "ink";212Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 213why, one step back213describe("a project's ledger", () => {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 214why, one step back214 it("is titled Visibility, its status line saying the posture and every sealed area in one sentence, and its history titled Ledger", () => {Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 215–216why, one step back215 const markup = markupOf(page);216Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 217–218why, one step back217 expect(markup).toMatch(/<h1\b[^>]*>Visibility<\/h1>/u);218 expect(markup).toMatch(/<h2\b[^>]*id="ledger"[^>]*>Ledger<\/h2>/u);Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 219–230why, one step back219 expect(textIn(elementWith(markup, "data-ledger-head")).trim()).toBe(220 "Open with sealed evidence. export: 7 sealed checks by 3 people; parser: 4 sealed checks by 3 people."221 );222 });223224 it("leads with the posture alone when the platform's label names the areas the sentence counts", () => {225 const named: Ledger = {226 ...datekit,227 postureLabel:228 "Open with sealed evidence · sealed checks in export, parser",229 };230Merge redesign into mainoscabrielbefore adoptioncaedd21
line 231why, one step back231 const markup = markupOf(tabWith(named));Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 232–235why, one step back232233 expect(textIn(elementWith(markup, "data-ledger-head")).trim()).toBe(234 "Open with sealed evidence. export: 7 sealed checks by 3 people; parser: 4 sealed checks by 3 people."235 );Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 236–238why, one step back236 // The label itself is the platform's, whole, on the lead word.237 expect(elementWith(markup, "data-posture=")).toContain(238 'title="Open with sealed evidence · sealed checks in export, parser"'Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 239–249why, one step back239 );240 });241242 it("leads with any other label whole", () => {243 const core: Ledger = {244 ...datekit,245 posture: "openCore",246 postureLabel: "Open core · closed: maintainers",247 };248249 expect(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 250why, one step back250 textIn(elementWith(markupOf(tabWith(core)), "data-ledger-head")).trim()Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 251–255why, one step back251 ).toBe(252 "Open core · closed: maintainers. export: 7 sealed checks by 3 people; parser: 4 sealed checks by 3 people."253 );254 });255Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 256–262why, one step back256 it("shows the posture label the platform computed", () => {257 const markup = markupOf(page);258259 expect(markup).toContain('data-posture="openWithSealedEvidence"');260 expect(textOf(page)).toContain("Open with sealed evidence");261 });262Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 263–264why, one step back263 it("shows each declared layer, its name in mono, with its audience, kinds, disclosure, reason, readers and writers", () => {264 const markup = mainOf(markupOf(page));Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 265why, one step back265Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 266–267why, one step back266 const layer = markup.slice(267 markup.indexOf('data-layer="maintainers"'),Merge redesign into mainoscabrielbefore adoptioncaedd21
line 268why, one step back268 markup.indexOf('id="held-back"')Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 269–273why, one step back269 );270271 expect(elementWith(layer, "data-layer-name")).toMatch(272 /class="[^"]*font-mono[^"]*text-sealed|class="[^"]*text-sealed[^"]*font-mono/u273 );Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 274why, one step back274 expect(Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 275why, one step back275 inOrder(plainText(layer), [Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 276–284why, one step back276 "maintainers",277 "Audience",278 "maintainers",279 "Holds",280 "checks, agent-config, notes",281 "Disclosure",282 "sealed",283 "Reason",284 "Held-back checks judge an answer by the ask's words, not by tests it could read.",Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 285why, one step back285 "Readers",Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 286why, one step back286 "the maintainers",Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 287why, one step back287 "Writers",Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
line 288why, one step back288 "the maintainers",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 289–292why, one step back289 ])290 ).toBeTruthy();291 });292Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 293–294why, one step back293 it("titles each sealed area in sealed violet, its root shortened and whole in its title, with its admission and last change", () => {294 const markup = mainOf(markupOf(page));Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 295why, one step back295Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 296–298why, one step back296 const area = markup.slice(297 markup.indexOf('data-area="export"'),298 markup.indexOf('data-area="parser"')Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 299–300why, one step back299 );300Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 301why, one step back301 expect(elementWith(area, "data-area-title")).toMatch(/text-sealed/u);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 302why, one step back302 expect(Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 303why, one step back303 inOrder(plainText(area), [Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 304–305why, one step back304 "export: 7 sealed checks by 3 people",305 "Root",Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 306why, one step back306 "sha256:3f9a0b…",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 307–308why, one step back307 "Admission",308 "admitted Oct 11; passes main 3/3; catches 2 known-bad",Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 309–310why, one step back309 "Last changed",310 "1 d ago",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 311–312why, one step back311 ])312 ).toBeTruthy();Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 313–314why, one step back313 expect(area).toContain(`title="${root}"`);314 expect(markup).toContain(`title="${parserRoot}"`);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 315–316why, one step back315 });316Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 317–319why, one step back317 it("lists the history newest first, one line each, each with its typed word", () => {318 const markup = markupOf(page);319 const rows = historyRowsOf(markup);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 320why, one step back320Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 321–362why, one step back321 expect(seqsOf(mainOf(markup))).toStrictEqual([9, 8, 7, 6, 5, 4, 3, 2, 1]);322 expect(wordsOf(markup)).toStrictEqual([323 "Commitment changed",324 "Released",325 "Value set",326 "Commitment changed",327 "Admitted",328 "Commitment changed",329 "Count changed",330 "Posture changed",331 "Layer added",332 ]);333334 for (const row of rows) {335 // One line: inline parts, never a paragraph or a block under another.336 expect(row.slice(row.indexOf(">") + 1)).not.toMatch(337 /<(?:p|div|br|ul|ol)\b/u338 );339 }340 });341342 it("draws the sealed kinds' words in sealed violet, and the rest in ink", () => {343 const rows = historyRowsOf(markupOf(page));344345 expect(rows.map(toneOf)).toStrictEqual([346 "sealed",347 "ink",348 "sealed",349 "sealed",350 "sealed",351 "sealed",352 "sealed",353 "ink",354 "ink",355 ]);356 });357358 it("says each entry in the ledger's words, a root shortened and whole in its title", () => {359 const markup = markupOf(page);360 const text = plainText(mainOf(markup));361 const admitted = historyRowsOf(markup)[4] ?? "";362Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 363–369why, one step back363 expect(inOrder(text, ["ines-v", "set", "SENTRY_AUTH_TOKEN"])).toBeTruthy();364 expect(365 inOrder(text, ["okonkwo", "released 2 paths", "9b1c3e5"])366 ).toBeTruthy();367 expect(368 inOrder(text, ["Posture changed", "Open", "Open with sealed evidence"])369 ).toBeTruthy();Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 370–371why, one step back370 expect(plainText(admitted)).toContain("sha256:3f9a0b…");371 expect(admitted).toContain(`title="${root}"`);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 372–389why, one step back372 });373374 it("adds no path, check name or file name to what the ledger says", () => {375 const markup = markupOf(page);376377 for (const leak of [378 "held-back/",379 "layers/",380 ".test.ts",381 ".ts<",382 "/export/",383 ]) {384 expect(markup).not.toContain(leak);385 }386 });387388 it("never shows an entry as recorded in the future, though it arrived after the page was read", () => {389 // Served at 07:00; the release at 08:00 arrived while the page stayed open.Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 390why, one step back390 const markup = mainOf(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 391why, one step back391 markupOf(tabWith(datekit, DateTime.makeUnsafe("2026-10-12T07:00:00Z")))Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 392–398why, one step back392 );393394 expect(whenOf(markup, 'data-seq="8"')).toBe("now");395 expect(whenOf(markup, 'data-seq="7"')).toBe("22 h ago");396 expect(markup).not.toMatch(/>in \d+ (?:min|h|d)</u);397 });398Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 399–401why, one step back399 it("puts what is held back, the CLI line and what each disclosure means in its facts, and says the posture in its status line, not again there", () => {400 const markup = markupOf(page);401 const facts = factsOf(markup);Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 402–403why, one step back402 const text = plainText(facts);403Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 404–407why, one step back404 expect(elementWith(markup, "data-ledger-head")).toContain(405 'data-posture="openWithSealedEvidence"'406 );407 expect(facts).not.toContain("data-posture");Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 408–414why, one step back408 expect(409 inOrder(text, [410 "Held back",411 "export",412 "7 sealed checks",413 "parser",414 "4 sealed checks",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 415why, one step back415 `${Brand.cli} ledger --project oscabriel/datekit`,Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 416–419why, one step back416 "sealed: counts, authors and a salted root",417 "write-only: names, and who set each value and when",418 ])419 ).toBeTruthy();Finish the Control room: every page passes axe and a keyboard walk in both schemesoscabrielbefore adoption3fd50a5
lines 420–424why, one step back420 // The command is the text of the one code element a tap selects whole.421 expect(422 plainText(423 /<code\b[^>]*select-all[^>]*>.*?<\/code>/u.exec(facts)?.[0] ?? ""424 )Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 425why, one step back425 ).toContain("ledger --project oscabriel/datekit");Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 426–427why, one step back426 });427Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 428why, one step back428 it("shows a project without layers as Open, with nothing held back", () => {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 429why, one step back429 const view = tabWith(open);Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 430why, one step back430 const markup = markupOf(view);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 431why, one step back431Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 432–437why, one step back432 expect(markup).toMatch(/data-posture="open"[^>]*>Open</u);433 expect(textIn(elementWith(markup, "data-ledger-head")).trim()).toBe(434 "Open. Nothing is held back."435 );436 expect(textOf(view)).toContain("Nothing is held back");437 expect(textOf(view)).not.toContain("sealed checks by");Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 438why, one step back438 });Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 439why, one step back439Merge redesign into mainoscabrielbefore adoptioncaedd21
line 440why, one step back440 it.effect("sits under the project's crumbs: datekit, then Visibility", () =>Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 441why, one step back441 Effect.gen(function* () {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 442why, one step back442 const markup = yield* renderAt("/oscabriel/datekit/visibility", page);Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 443–444why, one step back443 const crumbs = elementWith(markup, 'aria-label="Breadcrumb"');444Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 445–447why, one step back445 expect(crumbs).toMatch(446 /<a\b[^>]*href="\/oscabriel\/datekit"[^>]*>oscabriel\/datekit<\/a>/u447 );Merge redesign into mainoscabrielbefore adoptioncaedd21
line 448why, one step back448 expect(plainText(crumbs)).toContain("Visibility");Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 449–450why, one step back449 })450 );Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 451–467why, one step back451});452453describe(areaSummaries, () => {454 it("folds each area's latest count, authors, root and the admission of that root", () => {455 expect(areaSummaries(datekit)).toStrictEqual([456 {457 admission: Option.some({458 at: DateTime.makeUnsafe("2026-10-11T08:00:00.000Z"),459 knownBadCaught: 2,460 mainRuns: 3,461 }),462 area: exportArea,463 authors: Option.some(3),464 changedAt: DateTime.makeUnsafe("2026-10-11T08:00:00.000Z"),465 checks: 7,466 root: Option.some(root),467 },Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
lines 468–475why, one step back468 {469 admission: Option.none(),470 area: parserArea,471 authors: Option.some(3),472 changedAt: DateTime.makeUnsafe("2026-10-12T08:00:00.000Z"),473 checks: 4,474 root: Option.some(parserRoot),475 },Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 476–488why, one step back476 ]);477 });478479 it("folds by sequence number, whatever order the entries arrive in", () => {480 const shuffled = { ...datekit, entries: datekit.entries.toReversed() };481482 expect(areaSummaries(shuffled)).toStrictEqual(areaSummaries(datekit));483 });484485 it("keeps no admission for a root that joined without one", () => {486 const later: Ledger = {487 ...datekit,488 entries: [Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 489why, one step back489 ...datekit.entries,Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 490–494why, one step back490 LedgerEntry.cases.CommitmentPublished.make({491 area: exportArea,492 at: DateTime.makeUnsafe("2026-10-12T09:00:00.000Z"),493 authors: 3,494 checks: 8,Merge build/1222-project-recordsoscabrielbefore adoption2e6b5a5
line 495why, one step back495 seq: 10,Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 496–512why, one step back496 suite: earlierRoot,497 }),498 ],499 };500501 const [summary] = areaSummaries(later);502503 expect(summary?.checks).toBe(8);504 expect(summary?.root).toStrictEqual(Option.some(earlierRoot));505 expect(summary?.admission).toStrictEqual(Option.none());506 });507508 it("has no area for a ledger with no sealed entries", () => {509 expect(areaSummaries(open)).toStrictEqual([]);510 });511});512Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 513–521why, one step back513interface Asked {514 readonly ledgers: number;515 readonly schemas: number;516}517518const nothingAsked: Asked = { ledgers: 0, schemas: 0 };519520// The env's schema is read from the landed main; before a first landing the platform answers `UnknownProject`.521const platformHandlers = (asked: Ref.Ref<Asked>, { landed = true } = {}) =>Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 522–525why, one step back522 Layer.mergeAll(523 unanswered,524 Contracts.toLayerHandler("ledger", ({ project }) =>525 Effect.gen(function* () {Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 526–529why, one step back526 yield* Ref.update(asked, (seen) => ({527 ...seen,528 ledgers: seen.ledgers + 1,529 }));Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 530–537why, one step back530531 if (project !== datekit.project) {532 return yield* new UnknownProject({ project });533 }534535 return datekit;536 })537 ),Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 538–551why, one step back538 Contracts.toLayerHandler(EnvSchemaOf._tag, ({ project }) =>539 Effect.gen(function* () {540 yield* Ref.update(asked, (seen) => ({541 ...seen,542 schemas: seen.schemas + 1,543 }));544545 if (!landed || project !== datekit.project) {546 return yield* new UnknownProject({ project });547 }548549 return datekitEnv;550 })551 ),Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 552–554why, one step back552 asTester553 );554Merge redesign into mainoscabrielbefore adoptioncaedd21
line 555why, one step back555const platformOf = (asked: Ref.Ref<Asked>, where = {}) =>Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 556why, one step back556 Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 557why, one step back557 Layer.provide(platformHandlers(asked, where))Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 558–559why, one step back558 );559Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 560–565why, one step back560describe(readVisibility, () => {561 it.effect(562 "reads the project's ledger, entries and all, and its environment, each once",563 () =>564 Effect.gen(function* () {565 const asked = yield* Ref.make(nothingAsked);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 566why, one step back566Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 567–569why, one step back567 const read = yield* readVisibility("datekit").pipe(568 Effect.provide(platformOf(asked))569 );Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 570why, one step back570Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 571–580why, one step back571 expect(read.ledger.postureLabel).toBe("Open with sealed evidence");572 expect(read.ledger.entries.map(({ seq }) => seq)).toStrictEqual([573 1, 2, 3, 4, 5, 6, 7, 8, 9,574 ]);575 expect(read.env?.items.map(({ key }) => key)).toStrictEqual([576 "APP_ENV",577 "SENTRY_AUTH_TOKEN",578 ]);579 expect(yield* Ref.get(asked)).toStrictEqual({ ledgers: 1, schemas: 1 });580 })Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 581–582why, one step back581 );582Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 583–597why, one step back583 it.effect(584 "reads no environment, and no 404, for a project whose main has not landed",585 () =>586 Effect.gen(function* () {587 const asked = yield* Ref.make(nothingAsked);588589 const read = yield* readVisibility("datekit").pipe(590 Effect.provide(platformOf(asked, { landed: false }))591 );592593 expect(read.ledger.project).toBe("oscabriel/datekit");594 expect(read.env).toBeUndefined();595 })596 );597Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 598–599why, one step back598 it.effect("is a not-found for a project the platform does not know", () =>599 Effect.gen(function* () {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 600why, one step back600 const asked = yield* Ref.make(nothingAsked);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 601–602why, one step back601602 const failed = yield* Effect.flip(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 603why, one step back603 readVisibility("oscabriel/no-such-project").pipe(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 604–605why, one step back604 Effect.provide(platformOf(asked))605 )Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 606–608why, one step back606 );607608 expect(isNotFound(failed)).toBeTruthy();Merge redesign into mainoscabrielbefore adoptioncaedd21
line 609why, one step back609 expect((yield* Ref.get(asked)).ledgers).toBe(1);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 610–616why, one step back610 })611 );612613 it.effect(614 "is a not-found, asking nothing, for an address that names no project",615 () =>616 Effect.gen(function* () {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 617why, one step back617 const asked = yield* Ref.make(nothingAsked);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 618–619why, one step back618619 const failed = yield* Effect.flip(Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 620–622why, one step back620 readVisibility("Not_A-Project").pipe(621 Effect.provide(platformOf(asked))622 )Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 623–625why, one step back623 );624625 expect(isNotFound(failed)).toBeTruthy();Merge redesign into mainoscabrielbefore adoptioncaedd21
line 626why, one step back626 expect(yield* Ref.get(asked)).toStrictEqual(nothingAsked);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 627–641why, one step back627 })628 );629});630631const runUntil = (done: Effect.Effect<boolean>) =>632 Effect.yieldNow.pipe(633 Effect.andThen(done),634 Effect.repeat({ times: 200, until: (held) => held })635 );636637describe(ledgerAtom, () => {638 it.effect(639 "reads the ledger again when the project's keys change, as the watch's poll changes them",640 () =>641 Effect.gen(function* () {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 642why, one step back642 const asked = yield* Ref.make(nothingAsked);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 643–684why, one step back643644 // One browser tab whose `ContractsClient` reaches the stub platform in process.645 const registry = yield* Effect.acquireRelease(646 Effect.sync(() =>647 AtomRegistry.make({648 initialValues: [649 Atom.initialValue(650 ContractsClient.runtime.layer,651 Layer.effect(652 ContractsClient,653 RpcTest.makeClient(webContracts, { flatten: true })654 ).pipe(655 Layer.provide(platformHandlers(asked)),656 Layer.provideMerge(Reactivity.layer)657 )658 ),659 ],660 })661 ),662 (made) =>663 Effect.sync(() => {664 made.dispose();665 })666 );667668 const atom = ledgerAtom(datekit.project);669670 registry.mount(atom);671 yield* AtomRegistry.getResult(registry, atom, {672 suspendOnWaiting: true,673 });674675 // What the watch's poll does every POLL_MS: the project's keys changed.676 yield* AtomRegistry.getResult(677 registry,678 ContractsClient.runtime.atom(679 Reactivity.invalidate(keys.project(datekit.project))680 ),681 { suspendOnWaiting: true }682 );683684 expect(Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 685–687why, one step back685 yield* runUntil(686 Ref.get(asked).pipe(Effect.map((seen) => seen.ledgers > 1))687 )Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 688–711why, one step back688 ).toBeTruthy();689 })690 );691});692693describe("the ledger's way in", () => {694 it("is linked from the project's page", () => {695 const listing = Schema.decodeSync(ProjectListing)({696 openAsks: 0,697 posture: "openWithSealedEvidence",698 project: "datekit",699 });700701 const markup = markupOf(702 <ProjectView703 asks={[]}704 landings={[]}705 listing={listing}706 now={now}707 platformUrl="https://platform-test.example.workers.dev"708 />709 );710711 expect(markup).toMatch(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 712why, one step back712 /<a\b[^>]*href="\/oscabriel\/datekit\/visibility#ledger"[^>]*>Ledger<\/a>/uMerge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 713–716why, one step back713 );714 });715});716Merge redesign into mainoscabrielbefore adoptioncaedd21
line 717why, one step back717describe("the Visibility tab's views", () => {Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 718–720why, one step back718 // Views only: props in, markup out, and outside the visibility cartridge,719 // so the web reads only what the public contracts return.720 const sources: Readonly<Record<string, string>> = import.meta.glob(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 721why, one step back721 "../src/features/{ledger,env,visibility}/**/*.{ts,tsx}",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 722–728why, one step back722 { eager: true, import: "default", query: "?raw" }723 );724725 const reaching =726 /from\s+["'](?:@repo\/visibility[^"']*|@repo\/protocol\/contracts|effect\/(?:rpc|http|reactivity)|#backend|[./]+\/(?:surfaces|client\/[^"']*|server\/[^"']*)(?:\.tsx?)?)["']/u;727728 it("import no transport and nothing from the visibility cartridge", () => {Merge redesign into mainoscabrielbefore adoptioncaedd21
line 729why, one step back729 expect(Object.keys(sources).length).toBeGreaterThanOrEqual(4);Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 730–736why, one step back730731 expect(732 Object.entries(sources).flatMap(([path, source]) =>733 reaching.test(source) ? [path] : []734 )735 ).toStrictEqual([]);736 });Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 737–813why, one step back737});738739const regionIdsOf = (markup: string) =>740 [...mainOf(markup).matchAll(/<h2\b[^>]*\bid="(?<id>[^"]+)"/gu)].map(741 (found) => found.groups?.id742 );743744const attributesOf = (markup: string, attribute: string) =>745 [746 ...mainOf(markup).matchAll(747 new RegExp(`${attribute}="(?<value>[^"]*)"`, "gu")748 ),749 ].map((found) => found.groups?.value);750751const tabOf = (markup: string) => ({752 areas: attributesOf(markup, "data-area"),753 entries: seqsOf(mainOf(markup)).length,754 keys: attributesOf(markup, "data-env-key"),755 layers: attributesOf(markup, "data-layer"),756});757758/** A fresh dev world seeds itself first, which a full test run can slow past 5 s. */759const seededWorld = { timeout: 30_000 };760761const decodeVisibility = Schema.decodeEffect(VisibilityPageData);762763describe("a project's Visibility tab", () => {764 it.effect(765 "shows, in one page, the layers, the held-back areas, the environment without a value, and the ledger",766 () =>767 Effect.gen(function* () {768 const markup = yield* renderAt(769 "/oscabriel/datekit/visibility",770 <VisibilityView env={datekitEnv} ledger={datekit} now={now} />771 );772773 expect(markup).toMatch(/<h1\b[^>]*>Visibility<\/h1>/u);774 expect(regionIdsOf(markup)).toStrictEqual([775 "layers",776 "held-back",777 "environment",778 "ledger",779 ]);780 expect(tabOf(markup)).toStrictEqual({781 areas: ["export", "parser"],782 entries: 9,783 keys: ["SENTRY_AUTH_TOKEN", "APP_ENV"],784 layers: ["maintainers"],785 });786 expect(markup).not.toContain("placeholder-sentry-auth-token");787 })788 );789790 it.effect(791 "reads the dev world's layered project whole: its maintainers layer, its export and parser areas, its env keys and its ledger",792 () =>793 Effect.gen(function* () {794 const read = yield* readVisibility("oscabriel/vellum").pipe(795 Effect.flatMap(decodeVisibility),796 Effect.provide(fixturesClient())797 );798799 const markup = yield* renderAt(800 "/oscabriel/vellum/visibility",801 <VisibilityView env={read.env} ledger={read.ledger} now={read.now} />802 );803804 const tab = tabOf(markup);805806 expect(tab.layers).toStrictEqual(["maintainers"]);807 expect(tab.areas).toStrictEqual(["export", "parser"]);808 expect(tab.keys).toContain("SENTRY_AUTH_TOKEN");809 expect(tab.entries).toBe(read.ledger.entries.length);810 expect(markup).not.toMatch(/<(?:input|textarea|form|select)\b/u);811 }),812 seededWorld813 );Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 814why, one step back814});