logicsrc/apps/logicsrc-web/contract/openstack.contract.test.ts
Anthony Ettinger 8e4ea2f997
docs: OpenStack.md 0.1, one Markdown file for what a project is built on (#191)
A new LogicSRC spec in the catalogs family. One heading, an identity block
(Kind, Web, Repo, Operator, License, Extends, Updated), one line, then eleven
layers: Languages, Runtimes, Interfaces (one ### per way in: web, api, cli,
tui, mcp, desktop, mobile, worker, extension, bot), Data, Services, Modules,
Tooling, Hosting, Auth, Conventions, Not. An item is one bullet: name,
version, an optional status word (trial, hold, leaving) and a role. Extends
inherits a parent file, sections replace, Conventions and Not accumulate.
Rule 8 is the reading rule for agents: use what is listed, prefer listed
over new, ask before adding a layer or a service, never add a Not, keep the
file true. Discovery at OpenStack.md in the repo, /.well-known/openstack.md,
rel=openstack, or a platform path. JSON is derived and never the source.

logicsrc.com serves its own at /.well-known/openstack.md: the route extracts
the worked example from docs/openstack.md, and a contract test holds the two
together and checks the file follows its own rules. rel=openstack in <head>
and in the Link header beside openprofile.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 02:21:12 -07:00

43 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { GET, openstackBody } from "../src/app/.well-known/openstack.md/route";
import { readDoc } from "../src/lib/docs";
// The site that publishes a spec serves its own file, and that file is the
// worked example inside the spec, so the two can never drift apart.
describe("OpenStack.md: the site's own file", () => {
it("serves the spec's worked example as text/markdown", async () => {
const res = GET();
expect(res.headers.get("content-type")).toBe("text/markdown; charset=utf-8");
const body = await res.text();
expect(body.startsWith("# LogicSRC\n")).toBe(true);
expect(readDoc("openstack")).toContain(body.trim());
});
it("follows its own rules: one name, an identity block, the fixed layers, a Not section", () => {
const body = openstackBody();
expect(body.match(/^# /gm)).toHaveLength(1);
expect(body).toMatch(/^- \*\*Kind\*\*: monorepo$/m);
expect(body).toMatch(/^- \*\*Web\*\*: https:\/\/logicsrc\.com$/m);
expect(body).toMatch(/^- \*\*Operator\*\*: https:\/\/logicsrc\.com\/\.well-known\/openprofile\.md$/m);
for (const layer of [
"Languages",
"Runtimes",
"Interfaces",
"Data",
"Services",
"Modules",
"Tooling",
"Hosting",
"Auth",
"Conventions",
"Not"
]) {
expect(body).toMatch(new RegExp(`^## ${layer}$`, "m"));
}
// every interface this monorepo ships is declared
for (const iface of ["Web", "CLI", "TUI", "MCP", "API"]) {
expect(body).toMatch(new RegExp(`^### ${iface}$`, "m"));
}
expect(body).not.toContain(String.fromCharCode(0x2014));
});
});