From 6dfefed77b9e53e4ea12dd3285fc7620beb8c59d Mon Sep 17 00:00:00 2001 From: lex00 <121451605+lex00@users.noreply.github.com> Date: Fri, 16 Oct 2026 19:31:59 -0600 Subject: [PATCH 1/2] chant floors: one registry, a degraded why pane below WHY_CHANT_FLOOR, and a doctor line per read (#691) --- AGENTS.md | 21 ++++++++++ src/carve-manifest.ts | 5 ++- src/chant-floors.ts | 84 +++++++++++++++++++++++++++++++++++++++ src/chant.ts | 7 ++-- src/doctor.test.ts | 39 +++++++++++++++++- src/doctor.ts | 21 +++++++++- src/estate.ts | 9 ++--- src/operator.ts | 3 +- src/server.ts | 10 ++++- src/workspace-reader.ts | 5 ++- src/workspace-why.test.ts | 64 ++++++++++++++++++++++++++++- src/workspace-why.ts | 5 ++- 12 files changed, 251 insertions(+), 22 deletions(-) create mode 100644 src/chant-floors.ts diff --git a/AGENTS.md b/AGENTS.md index 5218e64e..e8275110 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -59,6 +59,27 @@ a scheduled read: it holds a slot in the read budget, has the read deadline, and stops when the request does. `serve --hud ` (or `BEHOLD_HUD_URL`) links a proposed decision to its review in hud. +## Chant version floors (behold#691) + +behold shells each project's own chant, so a read can reach a chant that +predates it. Every read has one floor, and every floor lives in +`src/chant-floors.ts`: + +- one constant per read, named after the read (`WHY_CHANT_FLOOR`) and set to the + chant release that adds it; +- one entry in `CHANT_FLOORS` (the read in words, the floor, what adds it in + chant), which is what `behold doctor` lists with the project's chant version + and whether the floor is met; +- the code that makes the read checks the project's chant first (`floorMet`, + `floorRefusal`) and never sends the read to a chant that would reject it. + +On an older chant the pane that needs the read shows `floorRefusal`'s words +(the read, the chant that adds it, the project's version) and the rest of +behold works. The why route does this: `GET /api/workspace/why` refuses before +spawning the read. A new read adds its constant and entry in the issue that +adds the read, once the chant release is known, and reads through the read +contract (`src/workspace-reader.ts`), never chant's library. + ## A pipeline's numbers, from Prometheus (behold#571) `behold serve --prometheus ` (or `BEHOLD_PROMETHEUS_URL`) adds `GET diff --git a/src/carve-manifest.ts b/src/carve-manifest.ts index ba4ed221..b736ae5a 100644 --- a/src/carve-manifest.ts +++ b/src/carve-manifest.ts @@ -347,8 +347,9 @@ function mergeCarveStates(byTarget: Map, paths: readonly str // ── Discovery through chant (chant#2038, chant ≥ 0.54.0) ───────────────────── -/** The chant that first answers `chant carve status`. */ -export const CARVE_STATUS_FLOOR = "0.54.0"; +/** The chant that first answers `chant carve status`; see src/chant-floors.ts. */ +import { CARVE_STATUS_FLOOR } from "./chant-floors.ts"; +export { CARVE_STATUS_FLOOR }; /** One row of `chant carve status --from --json` — chant's own * `CarveStatusRow` (cli/commands/carve-status.ts), reproduced rather than diff --git a/src/chant-floors.ts b/src/chant-floors.ts new file mode 100644 index 00000000..cf576159 --- /dev/null +++ b/src/chant-floors.ts @@ -0,0 +1,84 @@ +/** + * The registry of chant version floors (#691). + * + * behold shells each project's own chant, so a read can be asked of a chant + * that predates it. Every such read has one floor here: the first chant + * release that answers it. The convention: + * + * - One constant per read, named after the read (`WHY_CHANT_FLOOR`), set to + * the chant release that adds the read, and defined in this file. + * - One entry in {@link CHANT_FLOORS} naming the read in words a person + * recognises, the floor, and the chant issue or release that adds it. + * - The code that makes the read checks the project's chant with + * {@link floorRefusal} (or `meetsFloor`) before spawning anything, and a + * pane that needs the read shows that refusal while the rest of behold + * works. A read is never sent to a chant that would reject it. + * - `behold doctor` lists every entry with the project's chant version, so + * a new entry shows up there without further work. + * + * New reads go through the read contract (src/workspace-reader.ts), never + * through chant's library. Pure: imports only src/floor.ts, so any module may + * import it. + */ +import { meetsFloor } from "./floor.ts"; + +/** The first chant whose `graph` takes `--traffic` (chant#2377). An older one + * rejects an unknown flag outright (chant#1127), so the flag is never sent + * hopefully. */ +export const TRAFFIC_FLOOR = "0.75.0"; +/** The chant that ships `graph --live --namespace ` (chant#1629). Below + * this the flag is not merely ignored: chant#1127 made an unrecognised `--` + * flag a hard error, so a member on an older chant is left unjoined rather + * than sent an invocation its own CLI will refuse, which would turn today's + * "pending, with the note" into "unobserved", a strictly worse picture. */ +export const NAMESPACE_JOIN_FLOOR = "0.44.5"; +/** The first chant that writes contract 1. An older one has no `workspace` command at all. */ +export const WORKSPACE_CHANT_FLOOR = "0.81.0"; +/** The first chant whose intent document carries `why` (INTENTIUS/chant#3312). */ +export const WHY_CHANT_FLOOR = "0.102.0"; +/** The chant that ships `chant operator log` (chant#2029). */ +export const OPERATOR_LOG_FLOOR = "0.53.1"; +/** The chant that first answers `chant carve status` (chant#2038). */ +export const CARVE_STATUS_FLOOR = "0.54.0"; + +export interface ChantFloor { + /** The read, in words: `the why of a member or a card`. */ + read: string; + /** The floor constant's value: the first chant release that adds the read. */ + floor: string; + /** What adds it in chant, for the person reading doctor. */ + adds: string; +} + +/** Every read behold makes of chant that an older chant cannot answer. Add + * one entry per new read. */ +export const CHANT_FLOORS: readonly ChantFloor[] = [ + { read: "workspace read contract", floor: WORKSPACE_CHANT_FLOOR, adds: "chant workspace (contract 1)" }, + { read: "why", floor: WHY_CHANT_FLOOR, adds: "graph --intent writes a why (chant#3312)" }, + { read: "carve status", floor: CARVE_STATUS_FLOOR, adds: "chant carve status (chant#2038)" }, + { read: "operator log", floor: OPERATOR_LOG_FLOOR, adds: "chant operator log (chant#2029)" }, + { read: "graph traffic", floor: TRAFFIC_FLOOR, adds: "graph --traffic (chant#2377)" }, + { read: "namespace join", floor: NAMESPACE_JOIN_FLOOR, adds: "graph --live --namespace (chant#1629)" }, +]; + +/** One read's floor against one chant version. An unknown version meets it + * (an unknown version is not evidence of an old one). */ +export function floorMet(f: ChantFloor, version: string | undefined): boolean { + return meetsFloor(version, f.floor); +} + +/** The refusal a pane shows when the chant it would ask is older than the read's floor. */ +export function floorRefusal(f: ChantFloor, version: string | undefined): { error: string; code: string; remedy: string } { + return { + error: `${f.read[0].toUpperCase()}${f.read.slice(1)} needs chant ${f.floor} or newer. This project has chant ${version ?? "(unknown version)"}.`, + code: "chant-too-old", + remedy: `Upgrade @intentius/chant to ${f.floor} or newer in the project.`, + }; +} + +/** The registry's entry for a floor value. Throws on a floor not registered, so a typo fails a test. */ +export function floorFor(floor: string): ChantFloor { + const f = CHANT_FLOORS.find((x) => x.floor === floor); + if (!f) throw new Error(`no chant floor ${floor} in src/chant-floors.ts`); + return f; +} diff --git a/src/chant.ts b/src/chant.ts index 4bb31cef..66620235 100644 --- a/src/chant.ts +++ b/src/chant.ts @@ -151,10 +151,9 @@ export function envOverridesFor(opts: GraphOptions): Record | un return Object.keys(overrides).length ? overrides : undefined; } -/** The first chant whose `graph` takes `--traffic` (chant#2377). An older one - * rejects an unknown flag outright (chant#1127), so the flag is never sent - * hopefully. */ -export const TRAFFIC_FLOOR = "0.75.0"; +/** The first chant whose `graph` takes `--traffic` (chant#2377); see src/chant-floors.ts. */ +import { TRAFFIC_FLOOR } from "./chant-floors.ts"; +export { TRAFFIC_FLOOR }; /** Does this member's own read take `--traffic` (#402)? A chant member does * when its own chant has the flag; a terraform member is read by behold's diff --git a/src/doctor.test.ts b/src/doctor.test.ts index 9579fb53..293238c0 100644 --- a/src/doctor.test.ts +++ b/src/doctor.test.ts @@ -7,6 +7,8 @@ import type { Kubeconfig } from "./k8s-target.ts"; import type { Substrate } from "./substrates.ts"; import { discoverTerraformRoots as realRoots } from "./terraform-member.ts"; import { chantFloor } from "./chant.ts"; +import { CHANT_FLOORS } from "./chant-floors.ts"; +import { WHY_CHANT_FLOOR } from "./workspace-why.ts"; // Fixtures are built in the OS tmpdir rather than pointed at the bundled // examples: example-writes' node_modules is intentionally absent in a fresh @@ -89,7 +91,7 @@ describe("diagnose", () => { expect(report.ok).toBe(true); expect(report.kind).toBe("project"); - expect(report.checks.map((c) => c.status)).toEqual(["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]); + expect(report.checks.map((c) => c.status)).toEqual(Array(8 + CHANT_FLOORS.length).fill("pass")); expect(by(report, "chant").detail).toContain(`chant ${AT_FLOOR}`); expect(by(report, "lexicons").detail).toContain("aws 0.61.0"); expect(by(report, "envs").detail).toContain("prod"); @@ -119,6 +121,39 @@ describe("diagnose", () => { expect(chant.detail).toContain(`below behold's floor ${chantFloor()}`); }); + it("lists each chant read with the project's chant version and whether its floor is met (#691)", async () => { + const stale = fixture({ + "chant.config.ts": `export default { lexicons: ["aws"], environments: ["prod"], sourceDir: "src" };`, + "package.json": JSON.stringify({ name: "stale", dependencies: { "@intentius/chant": "^0.95.0" } }), + "src/main.ts": "", + ...installed("@intentius/chant", "0.95.0", "bin/chant"), + }); + const report = await diagnose(stale, probes({ detectSubstrates: async () => up })); + const floors = report.checks.filter((c) => c.name === "floor"); + expect(floors).toHaveLength(CHANT_FLOORS.length); + const why = floors.find((c) => c.detail.startsWith("why:"))!; + // 0.95.0 is below WHY_CHANT_FLOOR (0.102.0): named, with the project's version. + expect(why.status).toBe("warn"); + expect(why.detail).toContain(`needs chant ${WHY_CHANT_FLOOR}`); + expect(why.detail).toContain("chant 0.95.0"); + expect(why.detail).toContain("not met"); + expect(why.fix).toContain(WHY_CHANT_FLOOR); + // The workspace contract floor (0.81.0) is met by the same chant. + const contract = floors.find((c) => c.detail.startsWith("workspace read contract:"))!; + expect(contract.status).toBe("pass"); + expect(contract.detail).toMatch(/, met$/); + expect(formatReport(report)).toContain("why: needs chant"); + + const current = fixture({ + "chant.config.ts": `export default { lexicons: ["aws"], environments: ["prod"], sourceDir: "src" };`, + "package.json": JSON.stringify({ name: "fresh", dependencies: { "@intentius/chant": "^99.0.0" } }), + "src/main.ts": "", + ...installed("@intentius/chant", "99.0.0", "bin/chant"), + }); + const ok = await diagnose(current, probes({ detectSubstrates: async () => up })); + expect(ok.checks.filter((c) => c.name === "floor").every((c) => c.status === "pass")).toBe(true); + }); + it("fails with one line, and the fix, for a directory that is no project at all (#193's dead end)", async () => { const report = await diagnose(fixture({ "notes.txt": "hello" }), probes()); @@ -446,7 +481,7 @@ describe("--json", () => { expect(round.dir).toBe(dir); expect(round.kind).toBe("project"); expect(round.ok).toBe(true); - expect(round.checks.map((c) => c.name)).toEqual(["project", "chant", "lexicons", "targets", "envs", "kube", "substrates", "ops"]); + expect(round.checks.map((c) => c.name)).toEqual(["project", "chant", ...CHANT_FLOORS.map(() => "floor"), "lexicons", "targets", "envs", "kube", "substrates", "ops"]); for (const c of round.checks) { expect(Object.keys(c).filter((k) => k !== "fix")).toEqual(["name", "status", "detail"]); expect(["pass", "warn", "fail"]).toContain(c.status); diff --git a/src/doctor.ts b/src/doctor.ts index e18a57dc..7421e6ac 100644 --- a/src/doctor.ts +++ b/src/doctor.ts @@ -35,6 +35,7 @@ import { type ChantResolution, } from "./chant.ts"; import { registeredMemberKinds } from "./member-kind.ts"; +import { CHANT_FLOORS, floorMet } from "./chant-floors.ts"; import { CHOUDOUFU_FLOOR, choudoufuBinary, choudoufuMeetsFloor, choudoufuVersion, readLiveCheck, type ChoudoufuVersion, type LiveCheckParse } from "./choudoufu-member.ts"; import { detectProject, detectProjectShape, loadBeholdConfig, type ProjectKind } from "./project.ts"; import { terragucciConfig } from "./terragucci-repo.ts"; @@ -59,7 +60,7 @@ export type CheckStatus = "pass" | "warn" | "fail"; * on it); `detail` is what behold found; `fix` is the single next step, set * whenever the status isn't a pass. */ export interface DoctorCheck { - name: "project" | "chant" | "lexicons" | "targets" | "envs" | "kube" | "substrates" | "ops" | "choudoufu" | "terraform"; + name: "project" | "chant" | "lexicons" | "targets" | "envs" | "kube" | "substrates" | "floor" | "ops" | "choudoufu" | "terraform"; status: CheckStatus; detail: string; fix?: string; @@ -153,6 +154,23 @@ function chantCheck(root: string, targets: string[], estate: boolean): DoctorChe return { name: "chant", status: "pass", detail: `${versions}${floor ? ` (behold's floor ${floor})` : ""}` }; } +/** #691: one line per chant read behold makes (src/chant-floors.ts), each with + * the chant version of the project (every chant member of an estate) and + * whether the read's floor is met. An unmet floor is a warn: the pane that + * needs the read says so and the rest of behold works. */ +export function floorChecks(root: string, targets: string[], estate: boolean): DoctorCheck[] { + if (!targets.length) return []; + const resolutions = targets.map((t) => ({ target: t, res: resolveChant(t) })); + const have = list(resolutions.map(({ target, res }) => `${labelFor(root, target, estate)}chant ${res.version ?? "(unknown version)"}`)); + return CHANT_FLOORS.map((f): DoctorCheck => { + const behind = resolutions.filter(({ res }) => !floorMet(f, res.version)); + const head = `${f.read}: needs chant ${f.floor} (${f.adds}); ${have}`; + return behind.length + ? { name: "floor", status: "warn", detail: `${head}, not met`, fix: `Upgrade @intentius/chant to ${f.floor} or newer in ${list(behind.map(({ target }) => relative(root, target) || target))}; the pane that needs the ${f.read} stays off until then.` } + : { name: "floor", status: "pass", detail: `${head}, met` }; + }); +} + /** The lexicons line: what the config declares against what's installed. A * declared-but-missing lexicon is the same "not-installed" chant would raise * at graph time, said before a graph route has to. */ @@ -585,6 +603,7 @@ export async function diagnose(dir: string, probes: DoctorProbes = {}): Promise< const checks: DoctorCheck[] = [ projectCheck, chantCheck(root, chantTargets, estate), + ...floorChecks(root, chantTargets, estate), lexiconCheck(root, declared, estate), targetCheck(declared), // An estate root is not itself servable — the hint has to name its members diff --git a/src/estate.ts b/src/estate.ts index b3a7e984..f5fa60c5 100644 --- a/src/estate.ts +++ b/src/estate.ts @@ -332,12 +332,9 @@ export function namespaceRuntimeOwners(name: string, ir: GraphIR): GraphIR { // and an object naming its own namespace is untouched. // --------------------------------------------------------------------------- -/** The chant that ships `graph --live --namespace ` (chant#1629). Below - * this the flag is not merely ignored: chant#1127 made an unrecognised `--` - * flag a hard error, so a member on an older chant is left unjoined rather - * than sent an invocation its own CLI will refuse — which would turn today's - * "pending, with the note" into "unobserved", a strictly worse picture. */ -export const NAMESPACE_JOIN_FLOOR = "0.44.5"; +/** The chant that ships `graph --live --namespace ` (chant#1629); see src/chant-floors.ts. */ +import { NAMESPACE_JOIN_FLOOR } from "./chant-floors.ts"; +export { NAMESPACE_JOIN_FLOOR }; type Rec = Record; const rec = (v: unknown): Rec | undefined => (v && typeof v === "object" && !Array.isArray(v) ? (v as Rec) : undefined); diff --git a/src/operator.ts b/src/operator.ts index 2958c2f2..a39e8bd5 100644 --- a/src/operator.ts +++ b/src/operator.ts @@ -1138,7 +1138,8 @@ export function convergeGateCards(rows: readonly OpStatusLine[]): ConvergeGateCa * subcommand. That is a happy accident of flag ordering, not a guarantee, and it * is not what behold relies on.) */ -export const OPERATOR_LOG_FLOOR = "0.53.1"; +import { OPERATOR_LOG_FLOOR } from "./chant-floors.ts"; +export { OPERATOR_LOG_FLOOR }; /** How many timeline entries behold asks for when nothing says otherwise. */ export const OPERATOR_LOG_LIMIT = 50; diff --git a/src/server.ts b/src/server.ts index 20f112f1..369142a3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -153,7 +153,8 @@ import { readTerralith } from "./terralith-demo.ts"; import { discoverSplitPlans, moveMembers, moveReceipt, movesPayload, readSplitPlan, type MoveMorphMoveInput } from "./choudoufu-moves.ts"; import { servedWorkspace, setServedWorkspace, workspaceMemberOf, type Workspace } from "./workspace.ts"; import { approveArgs, isEnvName, isOverrideGate, localApprover, readWorkspaceGates } from "./workspace-gates.ts"; -import { readWhy, whyRegion } from "./workspace-why.ts"; +import { readWhy, whyRegion, WHY_CHANT_FLOOR } from "./workspace-why.ts"; +import { floorFor, floorMet, floorRefusal } from "./chant-floors.ts"; import { allowedHostsFrom, guardRequest } from "./request-guard.ts"; import { applyMemberPasses, memberKindOf, memberKindSpec, memberPassNote, servesAsEstate, type MemberPassRun } from "./member-kind.ts"; import { TerraformReadError, terraformMemberProject, terraformReaderState, terraformVia } from "./terraform-member.ts"; @@ -1548,6 +1549,13 @@ export function createApp( if (!ws) return c.json({ workspace: false, error: "behold isn't serving a declared chant workspace, so there is no why to read.", code: "no-workspace" }); const ask = whyRegion(ws, { member: c.req.query("member") || null, node: c.req.query("node") || null }); if (!ask.ok) return c.json({ workspace: true, ...ask.refusal }, 400); + // #691: a chant below the why floor is refused here, before the slow read + // is spawned; the pane says what is missing and the rest of behold works. + const whyFloor = floorFor(WHY_CHANT_FLOOR); + const whyChant = resolveChant(ws.root).version; + if (!floorMet(whyFloor, whyChant)) { + return c.json({ workspace: true, member: ask.member, region: ask.region, ms: 0, refusal: floorRefusal(whyFloor, whyChant) }); + } const started = Date.now(); let read: Awaited>; try { diff --git a/src/workspace-reader.ts b/src/workspace-reader.ts index 3ceee357..58a40f70 100644 --- a/src/workspace-reader.ts +++ b/src/workspace-reader.ts @@ -26,8 +26,9 @@ import { runChantRaw } from "./chant.ts"; /** The read contract version behold reads (chant's `reference/workspace-read-contract`). */ export const WORKSPACE_CONTRACT = 1; -/** The first chant that writes contract 1. An older one has no `workspace` command at all. */ -export const WORKSPACE_CHANT_FLOOR = "0.81.0"; +/** The first chant that writes contract 1 (see src/chant-floors.ts). */ +import { WORKSPACE_CHANT_FLOOR } from "./chant-floors.ts"; +export { WORKSPACE_CHANT_FLOOR }; /** The read-contract commands behold reads, named the way chant's conformance suite names them. */ export const BEHOLD_READS = ["ls", "graph", "status", "graph --intent"] as const; diff --git a/src/workspace-why.test.ts b/src/workspace-why.test.ts index d0832486..a3e937d2 100644 --- a/src/workspace-why.test.ts +++ b/src/workspace-why.test.ts @@ -1,10 +1,14 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; import { createApp } from "./server.ts"; import { Broadcaster } from "./events.ts"; import { FrameBuffer } from "./frames.ts"; import { OpRunner } from "./op-runner.ts"; import { readWorkspace, setServedWorkspace, type Workspace } from "./workspace.ts"; -import { hudAddress, hudReviewUrl, readWhy, whyFromIntent, whyRegion, WHY_COMMITS_SHOWN } from "./workspace-why.ts"; +import { CHANT_FLOORS, floorFor, floorMet, floorRefusal } from "./chant-floors.ts"; +import { hudAddress, hudReviewUrl, readWhy, whyFromIntent, whyRegion, WHY_CHANT_FLOOR, WHY_COMMITS_SHOWN } from "./workspace-why.ts"; import { createWhyFixture, type WhyFixture } from "./workspace-why-fixture.ts"; import { isScheduledRead } from "./chant.ts"; import { labelRead } from "./read-stats.ts"; @@ -220,3 +224,61 @@ describe("the why of a real workspace (#471)", () => { expect(bad.status).toBe(400); }, 120_000); }); + +describe("a chant below WHY_CHANT_FLOOR (#691)", () => { + const made: string[] = []; + afterAll(() => made.forEach((d) => rmSync(d, { recursive: true, force: true }))); + + /** A workspace root whose own chant install is `version`. No chant is spawned. */ + function rootWithChant(version: string): string { + const root = mkdtempSync(join(tmpdir(), "behold-why-floor-")); + made.push(root); + const pkg = join(root, "node_modules", "@intentius", "chant"); + mkdirSync(join(pkg, "bin"), { recursive: true }); + writeFileSync(join(pkg, "package.json"), JSON.stringify({ name: "@intentius/chant", version, main: "index.js", bin: { chant: "bin/chant" } })); + writeFileSync(join(pkg, "index.js"), ""); + writeFileSync(join(pkg, "bin", "chant"), "#!/usr/bin/env node\nprocess.exit(99);\n"); + return root; + } + + const serve = (root: string) => { + const w: Workspace = { ...ws([["delivery", "delivery"]]), root, chant: "0.95.0" }; + setServedWorkspace(w); + const broadcaster = new Broadcaster(); + return createApp( + { projectDir: root, workspace: w, port: 0 }, + broadcaster, + new FrameBuffer(), + new OpRunner({ projectDir: root, broadcaster, onDone: () => {} }), + ); + }; + afterAll(() => setServedWorkspace(undefined)); + + it("is registered, and the check names the read and the floor", () => { + expect(CHANT_FLOORS.map((f) => f.floor)).toContain(WHY_CHANT_FLOOR); + const f = floorFor(WHY_CHANT_FLOOR); + expect(floorMet(f, "0.95.0")).toBe(false); + expect(floorMet(f, WHY_CHANT_FLOOR)).toBe(true); + expect(floorMet(f, undefined)).toBe(true); + expect(floorRefusal(f, "0.95.0")).toEqual({ + error: "Why needs chant 0.102.0 or newer. This project has chant 0.95.0.", + code: "chant-too-old", + remedy: "Upgrade @intentius/chant to 0.102.0 or newer in the project.", + }); + }); + + it("the why pane shows what is missing without reading, and the rest of behold answers", async () => { + const app = serve(rootWithChant("0.95.0")); + const res = await app.request("/api/workspace/why?member=delivery"); + expect(res.status).toBe(200); + const body = (await res.json()) as Record; + expect(body.refusal).toEqual({ + error: "Why needs chant 0.102.0 or newer. This project has chant 0.95.0.", + code: "chant-too-old", + remedy: "Upgrade @intentius/chant to 0.102.0 or newer in the project.", + }); + expect(body.ms).toBe(0); + // Another route still answers. + expect((await app.request("/api/doctor")).status).toBe(200); + }); +}); diff --git a/src/workspace-why.ts b/src/workspace-why.ts index 4452d955..6d23190c 100644 --- a/src/workspace-why.ts +++ b/src/workspace-why.ts @@ -24,8 +24,9 @@ import { rootReader, WorkspaceReadError, type WorkspaceDocument, type WorkspaceR import type { Workspace } from "./workspace.ts"; export const INTENT_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/intent/v1/intent.schema.json"; -/** The first chant whose intent document carries `why` (INTENTIUS/chant#3312). */ -export const WHY_CHANT_FLOOR = "0.102.0"; +/** The first chant whose intent document carries `why` (see src/chant-floors.ts). */ +import { WHY_CHANT_FLOOR } from "./chant-floors.ts"; +export { WHY_CHANT_FLOOR }; /** How many commits the answer lists; the rest are counted. */ export const WHY_COMMITS_SHOWN = 8; From ec68b754d9652fe23a1ff3e906c8a2aa736416aa Mon Sep 17 00:00:00 2001 From: lex00 <121451605+lex00@users.noreply.github.com> Date: Fri, 16 Oct 2026 19:32:56 -0600 Subject: [PATCH 2/2] floors: look a read's floor up by its name, since reads can share a version (#691) --- src/chant-floors.ts | 9 +++++---- src/server.ts | 4 ++-- src/workspace-why.test.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/chant-floors.ts b/src/chant-floors.ts index cf576159..b4ea90ac 100644 --- a/src/chant-floors.ts +++ b/src/chant-floors.ts @@ -76,9 +76,10 @@ export function floorRefusal(f: ChantFloor, version: string | undefined): { erro }; } -/** The registry's entry for a floor value. Throws on a floor not registered, so a typo fails a test. */ -export function floorFor(floor: string): ChantFloor { - const f = CHANT_FLOORS.find((x) => x.floor === floor); - if (!f) throw new Error(`no chant floor ${floor} in src/chant-floors.ts`); +/** The registry's entry for a read, by its `read` name. Several reads can share one floor version, so the + * lookup is by name. Throws on a read not registered, so a typo fails a test. */ +export function floorFor(read: string): ChantFloor { + const f = CHANT_FLOORS.find((x) => x.read === read); + if (!f) throw new Error(`no chant floor for the read "${read}" in src/chant-floors.ts`); return f; } diff --git a/src/server.ts b/src/server.ts index 369142a3..013348f7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -153,7 +153,7 @@ import { readTerralith } from "./terralith-demo.ts"; import { discoverSplitPlans, moveMembers, moveReceipt, movesPayload, readSplitPlan, type MoveMorphMoveInput } from "./choudoufu-moves.ts"; import { servedWorkspace, setServedWorkspace, workspaceMemberOf, type Workspace } from "./workspace.ts"; import { approveArgs, isEnvName, isOverrideGate, localApprover, readWorkspaceGates } from "./workspace-gates.ts"; -import { readWhy, whyRegion, WHY_CHANT_FLOOR } from "./workspace-why.ts"; +import { readWhy, whyRegion } from "./workspace-why.ts"; import { floorFor, floorMet, floorRefusal } from "./chant-floors.ts"; import { allowedHostsFrom, guardRequest } from "./request-guard.ts"; import { applyMemberPasses, memberKindOf, memberKindSpec, memberPassNote, servesAsEstate, type MemberPassRun } from "./member-kind.ts"; @@ -1551,7 +1551,7 @@ export function createApp( if (!ask.ok) return c.json({ workspace: true, ...ask.refusal }, 400); // #691: a chant below the why floor is refused here, before the slow read // is spawned; the pane says what is missing and the rest of behold works. - const whyFloor = floorFor(WHY_CHANT_FLOOR); + const whyFloor = floorFor("why"); const whyChant = resolveChant(ws.root).version; if (!floorMet(whyFloor, whyChant)) { return c.json({ workspace: true, member: ask.member, region: ask.region, ms: 0, refusal: floorRefusal(whyFloor, whyChant) }); diff --git a/src/workspace-why.test.ts b/src/workspace-why.test.ts index a3e937d2..de14ed87 100644 --- a/src/workspace-why.test.ts +++ b/src/workspace-why.test.ts @@ -256,7 +256,7 @@ describe("a chant below WHY_CHANT_FLOOR (#691)", () => { it("is registered, and the check names the read and the floor", () => { expect(CHANT_FLOORS.map((f) => f.floor)).toContain(WHY_CHANT_FLOOR); - const f = floorFor(WHY_CHANT_FLOOR); + const f = floorFor("why"); expect(floorMet(f, "0.95.0")).toBe(false); expect(floorMet(f, WHY_CHANT_FLOOR)).toBe(true); expect(floorMet(f, undefined)).toBe(true);