From d035fd316558416808ace5b6d4768c642fcd9d80 Mon Sep 17 00:00:00 2001 From: mnovak Date: Mon, 9 Nov 2026 17:42:05 +0100 Subject: [PATCH 1/5] [docs] Release: notes and screenshots of the web UI on the Gitea release of a v* tag, under the signed SHA256SUMS (docs/release.md) --- docs/release.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 docs/release.md diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 0000000..e2cb434 --- /dev/null +++ b/docs/release.md @@ -0,0 +1,109 @@ +# Releases: notes and screenshots on the Gitea release + +Ianitor is server-only: what runs is built by Nix on the server and switched in by the `deploy` pipeline +(`.fabrica/artifex/deploy.yaml`, `fabrica-deploy@ianitor`). A release adds what a deploy does not leave behind: a +Gitea release for the `vX.Y.Z` tag with the release notes and screenshots of the web UI, under a `SHA256SUMS` +signed by `domi-release`. It ships no binary; the deploy stays the deploy. + +The release kit is Fabrica's (Fabrica `docs/12_release_kit.md`, core `docs/FORMATS.md`, "Fabrica: release notes" +and "Fabrica: the Aula page"). Ianitor uses it as it is, with one difference: Fabrica's `fabrica aula shots` +drives a built Windows WebView2 exe, which Ianitor does not have, so a repo script takes the same files from the +web UI in a headless browser. + +## The pipeline: `.fabrica/artifex/release.yaml` + +`on: tag "v*"` and `manual: true`, on the Windows runner (the Fabrica app on Mark's PC: `fabrica`, node and pnpm +are on every step's PATH). + +| Step | Does | Produces | +| :-- | :-- | :-- | +| `version` | `node scripts/check-version.mjs `: the tag's version must be the workspace `Cargo.toml`'s and both `package.json`s' | | +| `install` | `pnpm install --frozen-lockfile` | | +| `check`, `test` | `svelte-check` and the vitest click smoke test of the web UI the shots show | | +| `notes` | `fabrica notes` (the range since the previous `v*` tag; the first release covers the whole history) | `target/notes/release-notes.md`, `release-notes.json` | +| `shots` | `node apps/web/scripts/shots.mjs` (below) | `target/aula/aula-.png`, `aula.json` | +| `approve` | the run's Custos approval, before anything is published | | +| `publish` | the Gitea release of the tag: the notes, the shots and `aula.json`; `sums: domi-release` adds `SHA256SUMS` and `SHA256SUMS.minisig`; `release-notes.md` becomes the release's text | | + +The Rust tests are not in it: the edge, diff and ACME tests are Linux-only (ROADMAP §8.3) and the release builds +nothing. They run in WSL2 and in the Nix build. + +**No landing page.** `fabrica aula page` and `aula-page.json` are left out while `.fabrica/app.yaml` has no +`aula: true`. Turning Aula on later is two lines: `aula: true` in `app.yaml` and a `page` step (`fabrica aula +page`, after `notes` and `shots`) whose `aula-page.json` is published; a brief (`.fabrica/aula/brief.md`) is +optional, its caption names are the shot names below. + +**app.yaml stays as it is.** Its parts are `desktop` (a release pipeline started by the tag the card's Deploy +bumps and pushes, with installers) and `server` (a deploy pipeline). Ianitor has no installer and no version bump to +make, so it keeps its one `server` part; the release is started by its tag. + +## Release notes + +`fabrica notes` writes them from the first-parent commit subjects, the Pensum tickets done (Ianitor has none) and +`.fabrica/notes/.md`, the highlights a person writes. The merges of PR 3 to 5 predate the +`[repo] Merge: (, PR #n)` form and come out as bare "PR #n" lines; history is not rewritten, so +`.fabrica/notes/0.1.0.md` says in a few sentences what 0.1.0 is, and goes first. + +## Screenshots: `apps/web/scripts/shots.mjs` + +`node apps/web/scripts/shots.mjs [--out <dir>]` (default `target/aula` at the repo root): + +1. empties the output folder of `aula-*.png` and `aula.json`; +2. builds the web UI (Vite, production) into a fresh temporary folder; +3. serves it on `127.0.0.1` (a free port), with `/api/v1` answered by the demo control plane + (`apps/web/tests/demo.ts`), and every other path falling back to `index.html` as in production; +4. starts headless Microsoft Edge (or Chrome; `IANITOR_SHOTS_BROWSER` names another) with a fresh profile in the + temporary folder, its DevTools port on loopback only, and a cleared environment (the system variables and the + temporary folder, nothing of the runner's: no `GITEA_TOKEN`, no hub token); a browser whose DevTools do not + answer within 20 s is stopped and started again, at most three times; +5. for each shot: sets the viewport (1440 × 900, scale 1), loads its page, clicks its selectors, waits for its + selector, the fonts, two frames and 400 ms, and saves `aula-<name>.png`; a wait that runs out (20 s) saves + `aula-<name>-failed.png` and fails; +6. writes `aula.json` in the format of core `docs/FORMATS.md` ("Fabrica: the Aula page"): `{"v":1,"shots":[…]}`, + each shot's `name`, `title`, `file`, `width` and `height` read from the PNG, and `sha256`; +7. on every way out kills the browser's process tree and, on Windows, any process left with a profile in the + temporary folder (Edge can start its browser again as a new process, outside the tree), stops the server, and + removes the temporary folder. + +| Name | Page | Shows | +| :-- | :-- | :-- | +| `hosts` | `/` | the host list: health, chips, where each sends traffic, the last change | +| `host` | `/hosts/wiki.home.test/edit` | editing a host: upstreams, certificate, sign-in, health check | +| `engine` | `/`, then the engine chip | Pingora serving and the Caddy fallback ready, with its differences | +| `history` | `/history/<change>` | the history with a version picked and what restoring it changes | +| `certificates` | `/certificates` | the Domi intermediate and the device certificates | + +**The demo control plane** (`apps/web/tests/demo.ts`) answers like control (docs/api.md), built on the click smoke +test's stand-in (`apps/web/tests/mockApi.ts`: the same host and apply shapes and every call the demo does not +replace). Its data is invented: hostnames under `.test`, upstream addresses in the documentation ranges +(192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24), people *ada* and *felix*, made-up commits, match codes and +fingerprints. A vitest test (`apps/web/tests/demo.test.ts`) asks every page's calls and fails on any other +hostname or address, so a real name cannot slip in through a later fixture. + +## Risks + +| Risk | Answer | +| :-- | :-- | +| A screenshot shows Mark's network | The UI talks only to the demo control plane; the demo data test refuses names outside `.test` and addresses outside the documentation ranges; the PNGs are looked at in the review. | +| The browser reaches out | It loads only `127.0.0.1`; the UI's own CSP allows no outside requests; background networking, sync and component updates are off; its profile is thrown away. | +| A secret reaches the browser | Its environment is cleared to the system variables. The demo serves no token, key or certificate. | +| A forged screenshot or note | They are release assets under `SHA256SUMS`, signed by `domi-release` through Custos; the Gitea text is not signed, the asset is. | +| The browser outlives the run | Its process tree is killed on every way out (`taskkill /T` on Windows). | +| A shot of a half-drawn screen | Each `wait` selector exists only once the screen's data is there; fonts and two frames are awaited. | + +## Gaps + +- Windows and Edge or Chrome only as tested; the script is plain Node and DevTools, so Linux with Chromium should + work, untested. +- One size (desktop); no phone layout shot. +- The release does not run the Rust tests (see above). +- No `[repo] Release:` bump: the version in `Cargo.toml` and the `package.json`s is changed by hand before tagging. + +## Handover: releasing 0.1.0 + +1. On main: `git tag v0.1.0 && git push origin v0.1.0`. +2. Start the `release` pipeline at `v0.1.0` from Fabrica (no Gitea webhook to the hub yet: the hub's + `POST /api/runs`, ref `v0.1.0`). Approve on the Custos card, then sign `SHA256SUMS` on Custos (`domi-release`). +3. The Gitea release `v0.1.0` has the notes as its text and `release-notes.md`, `release-notes.json`, five + `aula-*.png`, `aula.json`, `SHA256SUMS` and `SHA256SUMS.minisig`. +4. Deploy as before: Fabrica's *Apps* → Ianitor → *Deploy*, then deploy/test-access.sh from a LAN machine. From c2c64543028b0107deeafbcdd25abdd7d731cae4 Mon Sep 17 00:00:00 2001 From: mnovak <giteatruenasadminacc.from729@passmail.net> Date: Mon, 9 Nov 2026 17:42:05 +0100 Subject: [PATCH 2/5] [tests] Release screenshots, tests first: the demo control plane draws every shot from invented data only (.test names, documentation addresses) --- apps/web/tests/demo.test.ts | 97 +++++++++++++++ apps/web/tests/demo.ts | 236 ++++++++++++++++++++++++++++++++++++ apps/web/tests/mockApi.ts | 47 ++++--- 3 files changed, 365 insertions(+), 15 deletions(-) create mode 100644 apps/web/tests/demo.test.ts create mode 100644 apps/web/tests/demo.ts diff --git a/apps/web/tests/demo.test.ts b/apps/web/tests/demo.test.ts new file mode 100644 index 0000000..2abed14 --- /dev/null +++ b/apps/web/tests/demo.test.ts @@ -0,0 +1,97 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// The release's screenshots (docs/release.md): every shot's screen is drawn from the demo control +// plane alone (each click and wait selector found, no call unanswered), and nothing the demo +// serves or the page shows names a real host, address or person. + +import { cleanup, render, waitFor } from "@testing-library/svelte"; +import { afterEach, describe, expect, it } from "vitest"; +import App from "../src/App.svelte"; +import { app } from "../src/lib/app.svelte"; +import { SHOTS, demoApi } from "./demo"; + +const ALLOWED_TLDS = new Set(["test", "example", "invalid"]); +const DOC_NETS = ["192.0.2.", "198.51.100.", "203.0.113."]; +const FORBIDDEN = ["mark", "marek", "novak", "flowers", "esp32", "hyperv"]; + +/** What in a text could be real: addresses outside the documentation ranges, names outside .test. */ +function realLooking(text: string): string[] { + const found: string[] = []; + for (const m of text.matchAll(/(?<![\w.])\d{1,3}(?:\.\d{1,3}){3}(?![\w.])/g)) { + if (m[0] !== "127.0.0.1" && !DOC_NETS.some((n) => m[0].startsWith(n))) found.push(m[0]); + } + for (const m of text.matchAll(/(?<![\w.-])(?:[a-z0-9-]+\.)+([a-z][a-z0-9-]*)(?![\w-])/gi)) { + if (!ALLOWED_TLDS.has(m[1].toLowerCase())) found.push(m[0]); + } + for (const w of FORBIDDEN) if (new RegExp(`\\b${w}\\b`, "i").test(text)) found.push(w); + return found; +} + +let served: { status: number; path: string; text: string | null }[] = []; + +function start(path: string) { + history.replaceState({}, "", path); + app.path = path; + app.panel = null; + app.overview = null; + app.etag = null; + app.signedOut = false; + app.switchResult = null; + app.renewedUntil = null; + app.dismissed = []; + served = []; + const api = demoApi(); + globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { + const url = typeof input === "string" ? input : input instanceof URL ? input.pathname + input.search : input.url; + const path = url.replace(/^.*\/api\/v1/, ""); + const a = api(init?.method ?? "GET", path, init?.body ? JSON.parse(String(init.body)) : {}); + served.push({ status: a.status, path, text: a.text }); + return new Response(a.text, { status: a.status, headers: { "Content-Type": "application/json" } }); + }) as typeof fetch; + render(App); +} + +function pageText(): string[] { + const out: string[] = []; + const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); + for (let n = walk.nextNode(); n; n = walk.nextNode()) if (n.textContent?.trim()) out.push(n.textContent); + document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>("input, textarea").forEach((i) => out.push(i.value)); + document.querySelectorAll("[href]").forEach((a) => out.push(a.getAttribute("href") ?? "")); + return out; +} + +afterEach(() => cleanup()); + +describe("realLooking", () => { + it("passes invented names and refuses real-looking ones", () => { + expect(realLooking("wiki.home.test http://192.0.2.10:3000 on 127.0.0.1 for ada")).toEqual([]); + expect(realLooking("http://10.0.0.2:3000")).toEqual(["10.0.0.2"]); + expect(realLooking("gitea.example.cz and Mark's phone")).toEqual(["gitea.example.cz", "mark"]); + expect(realLooking("flowers.stage")).toEqual(["flowers.stage", "flowers"]); + }); +}); + +describe("the release's screenshots from the demo control plane", () => { + for (const shot of SHOTS) { + it(`${shot.name}: drawn from invented data only`, async () => { + start(shot.path); + for (const sel of shot.click ?? []) { + const el = await waitFor(() => { + const e = document.querySelector<HTMLElement>(sel); + expect(e, `click ${sel}`).not.toBeNull(); + return e as HTMLElement; + }, { timeout: 5000 }); + el.click(); + } + await waitFor(() => expect(document.querySelector(shot.wait), `wait ${shot.wait}`).not.toBeNull(), { timeout: 5000 }); + + expect(served.filter((s) => s.status === 404).map((s) => s.path)).toEqual([]); + // Control's codes (apply.kept, pki.renew_due) are dotted words, not names. + const json = served.map((s) => (s.text ?? "").replace(/"(?:code|message_code|error_code)":"[^"]*"/g, "")); + const seen = [...json, ...pageText()]; + expect(seen.flatMap(realLooking)).toEqual([]); + }); + } +}); diff --git a/apps/web/tests/demo.ts b/apps/web/tests/demo.ts new file mode 100644 index 0000000..2dfe3cb --- /dev/null +++ b/apps/web/tests/demo.ts @@ -0,0 +1,236 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// The demo control plane for the release's screenshots (docs/release.md): control's answers +// (docs/api.md) for a small invented home server, built on the click smoke test's stand-in +// (mockApi.ts), whose routes answer every call the demo does not replace. Everything here is +// invented: hostnames under .test, addresses in the documentation ranges (RFC 5737), people ada +// and felix, made-up commits and fingerprints. demo.test.ts renders every shot from it and fails +// on any other name or address. + +import { apply, host, mockRoutes, newMock, respond, type Route } from "./mockApi"; + +/** One screenshot: the page, the selectors clicked in order, and the selector that means "drawn". */ +export interface Shot { + name: string; + title: string; + path: string; + click?: string[]; + wait: string; +} + +/** The viewport in CSS pixels; the PNGs are this size. */ +export const SIZE = { width: 1440, height: 900 } as const; + +export const SHOTS: Shot[] = [ + { name: "hosts", title: "Every host, its health and where it sends traffic", path: "/", wait: "[aria-label=Hosts] .ia-row:nth-child(8) .ia-host" }, + { name: "host", title: "Editing a host", path: "/hosts/wiki.home.test/edit", wait: "#host-form input[readonly]" }, + { name: "engine", title: "Pingora serving, Caddy ready as the fallback", path: "/", click: ["[data-engine-chip]"], wait: "dialog.ia-popover[open] .ia-card" }, + { name: "history", title: "History: going back to a kept version", path: "/history/ch_0006", wait: "section.detail ul li:nth-child(2)" }, + { name: "certificates", title: "The Domi CA and the device certificates", path: "/certificates", wait: "ul.devices li:nth-child(5)" }, +]; + +type Json = Record<string, unknown>; + +const DAY = 86_400; +const at = (s: number) => new Date(Date.now() + s * 1000).toISOString(); + +interface Health { + state: string; + latency?: number | null; + upstreams?: Json[]; + failure?: Json | null; +} + +function demoHost(hostname: string, upstreams: string[], h: Health, over: Json = {}): Json { + const base = host(hostname, false); + return { + ...base, + upstreams, + health: { + state: h.state, + last_check_at: h.state === "unknown" ? null : at(-4), + latency_ms: h.latency ?? null, + since: at(-6 * DAY), + failure: h.failure ?? null, + upstreams: h.upstreams ?? [], + }, + ...over, + }; +} + +const MUSIC = ["http://192.0.2.20:4533", "http://192.0.2.21:4533"]; + +function hosts(): Json[] { + return [ + demoHost("wiki.home.test", ["http://192.0.2.10:3000"], { state: "healthy", latency: 9 }, { share_links: true }), + demoHost("photos.home.test", ["http://192.0.2.11:2342"], { state: "healthy", latency: 23 }), + demoHost("recipes.home.test", ["http://192.0.2.12:9000"], { state: "healthy", latency: 14 }, { added_at: at(-2 * 3600) }), + demoHost("music.home.test", MUSIC, { + state: "degraded", + latency: 18, + failure: { kind: "refused", upstream: MUSIC[1], count: 3, of: 3 }, + upstreams: [ + { url: MUSIC[0], state: "healthy", last_check_at: at(-4), latency_ms: 18, failure_kind: null }, + { url: MUSIC[1], state: "down", last_check_at: at(-4), latency_ms: null, failure_kind: "refused" }, + ], + }), + demoHost("cameras.home.test", ["https://192.0.2.30:7443"], { state: "healthy", latency: 31 }, { device_certs: true }), + demoHost("status.home.test", ["http://192.0.2.40:3001"], { state: "healthy", latency: 6 }, { tls: "letsencrypt", auth: "none" }), + demoHost("printer.home.test", ["http://192.0.2.50:631"], { state: "unknown" }, { websockets: false }), + ]; +} + +function lastApply(): Json { + return { + ...apply("ch_0008", "kept", "Added recipes.home.test", ["recipes.home.test"]), + created_at: at(-2 * 3600 - 70), + finished_at: at(-2 * 3600), + reason: { code: "apply.kept", message: "recipes.home.test is live. Health checks passed for 60 s." }, + commit_short: "c41d7e2", + push: { state: "pushed", at: at(-2 * 3600), error_code: null, next_try_at: null }, + }; +} + +function intermediate(): Json { + return { state: "ok", subject: "Demo Intermediate CA", not_after: at(212 * DAY), days_left: 212, renewal: null, banner: null }; +} + +function overview(): Json { + const list = hosts(); + const count = (s: string) => list.filter((h) => (h.health as Json).state === s).length; + return { + counts: { hosts: list.length, healthy: count("healthy"), degraded: count("degraded"), down: count("down"), unknown: count("unknown") }, + hosts: list, + engine: { + running: "pingora", + state: "running", + since: at(-6 * DAY), + target: null, + switchable: true, + fallback_ready: { + built_at: at(-2 * 3600), + current: true, + compared: list.length, + matched: list.length, + differences: ["Every host: Caddy adds its own Server and Via headers to answers, and a Content-Type when your service sends none."], + }, + last_error: null, + notes: [], + }, + last_apply: lastApply(), + undo: { + available: true, + target: { change_id: "ch_0008", summary: "Added recipes.home.test", kept_at: at(-2 * 3600), commit_short: "c41d7e2" }, + effect: "Removes recipes.home.test", + blocked: null, + }, + active_apply: null, + repo: { name: "home-routes", last_push_at: at(-2 * 3600), unpushed: 0, push_error_code: null }, + intermediate: intermediate(), + site: { forward_auth_configured: true, acme_configured: true, secrets: ["photos_api_key"], watch_seconds: 60, share_links_available: true, auth_logout_url: "https://auth.home.test/logout" }, + paused: null, + paused_reason: null, + health_error: null, + rev: "rev-demo-8", + viewer: { name: "ada", via: "authelia" }, + }; +} + +function spec(hostname: string): Json | null { + const row = hosts().find((h) => h.hostname === hostname); + if (!row) return null; + const wiki = hostname === "wiki.home.test"; + return { + hostname, + upstreams: row.upstreams, + tls: row.tls, + auth: row.auth, + websockets: row.websockets, + share_links: row.share_links, + device_certs: row.device_certs, + access_log: wiki ? "truncated" : "off", + health_check: (row.health as Json).state === "unknown" ? null : { path: wiki ? "/healthz" : "/", interval_secs: 30 }, + request_headers: [], + response_headers: wiki ? [{ action: "set", name: "X-Frame-Options", value: "SAMEORIGIN" }] : [], + }; +} + +const HISTORY = [ + { change_id: "ch_0008", summary: "Added recipes.home.test", kind: "add", state: "kept", ago: 2 * 3600, commit_short: "c41d7e2", hosts: ["recipes.home.test"], reason_short: null }, + { change_id: "ch_0007", summary: "Changed music.home.test", kind: "edit", state: "kept", ago: 1 * DAY, commit_short: "8e03b5a", hosts: ["music.home.test"], reason_short: null }, + { change_id: "ch_0006", summary: "Turned share links on for wiki.home.test", kind: "share_links", state: "kept", ago: 2 * DAY, commit_short: "5a9f210", hosts: ["wiki.home.test"], reason_short: null }, + { change_id: "ch_0005", summary: "Changed photos.home.test", kind: "edit", state: "reverted", ago: 3 * DAY, commit_short: null, hosts: ["photos.home.test"], reason_short: "photos.home.test answered 502 during the watch" }, + { change_id: "ch_0004", summary: "Added cameras.home.test", kind: "add", state: "kept", ago: 5 * DAY, commit_short: "0b7c4e9", hosts: ["cameras.home.test"], reason_short: null }, + { change_id: "ch_0003", summary: "Added printer.home.test", kind: "add", state: "kept", ago: 9 * DAY, commit_short: "e2d81f6", hosts: ["printer.home.test"], reason_short: null }, + { change_id: "ch_0002", summary: "Added status.home.test", kind: "add", state: "kept", ago: 12 * DAY, commit_short: "73a6c05", hosts: ["status.home.test"], reason_short: null }, + { change_id: "ch_0001", summary: "Added wiki.home.test", kind: "add", state: "kept", ago: 20 * DAY, commit_short: "1f4b9a3", hosts: ["wiki.home.test"], reason_short: null }, +]; + +function history(): Json { + return { entries: HISTORY.map(({ ago, ...e }) => ({ ...e, at: at(-ago) })), next_before: null }; +} + +function restorePreview(id: string): Json { + if (id === "ch_0008") return { restorable: false, same_as_current: true, changes: [], blocked: { code: "restore.same", message: "This version is the same as the current one." } }; + return { + restorable: true, + same_as_current: false, + changes: [ + { hostname: "recipes.home.test", effect: "removed", fields: [] }, + { hostname: "music.home.test", effect: "changed", fields: [{ field: "upstreams", from: MUSIC.join(", "), to: MUSIC[0] }] }, + ], + blocked: null, + }; +} + +function certs(): Json { + const device = (id: string, name: string, kind: string, made: number, until: number, revoked: number | null = null) => ({ + id, + name, + kind, + created_at: at(-made * DAY), + not_after: at(until * DAY), + state: revoked === null ? "valid" : "revoked", + revoked_at: revoked === null ? null : at(-revoked * DAY), + }); + return { + intermediate: intermediate(), + root: { offline: true, subject: "Demo Root CA", not_after: at(3000 * DAY), sha256: "5c0f9e2a71d84b36a8e1f40c2d9b7e6315a2c8d04f9b1e7a6c3d5f8e0b2a4c61" }, + devices: [ + device("dv_1", "ada's phone", "phone", 40, 325), + device("dv_2", "felix's laptop", "computer", 61, 304), + device("dv_3", "Kitchen tablet", "phone", 345, 20), + device("dv_4", "Notes app on the desk PC", "app", 12, 353), + device("dv_5", "Old phone", "phone", 200, 165, 30), + ], + device_lifetime_days: 365, + device_valid_until: null, + server_lifetime_days: 90, + approval: "manual", + requests: [], + }; +} + +/** The demo's own answers, first; the smoke test's stand-in answers the rest. */ +export function demoRoutes(): Route[] { + return [ + ["GET", /^\/overview$/, () => [200, overview()]], + ["GET", /^\/hosts\/([^/?]+)$/, (mm) => { + const s = spec(decodeURIComponent(mm[1])); + return s ? [200, { host: s, rev: "rev-demo-8" }] : [404, { error: { code: "host.not_found", message: "There is no such host.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "demo" }]; + }], + ["GET", /^\/history(\?.*)?$/, () => [200, history()]], + ["GET", /^\/history\/([^/]+)\/restore-preview$/, (mm) => [200, restorePreview(decodeURIComponent(mm[1]))]], + ["GET", /^\/certs$/, () => [200, certs()]], + ["GET", /^\/settings$/, () => [200, { repo: { name: "home-routes", last_push_at: at(-2 * 3600) }, watch_seconds: 60 }]], + ...mockRoutes(newMock()), + ]; +} + +/** Control's API for the demo: `path` is what follows /api/v1 (with its query). */ +export function demoApi(): (method: string, path: string, body: Json) => { status: number; text: string | null } { + const routes = demoRoutes(); + return (method, path, body) => respond(routes, method.toUpperCase(), path, body); +} diff --git a/apps/web/tests/mockApi.ts b/apps/web/tests/mockApi.ts index 1c1228e..d849ccc 100644 --- a/apps/web/tests/mockApi.ts +++ b/apps/web/tests/mockApi.ts @@ -3,7 +3,8 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. // A stateful stand-in for control's API, shaped like the real answers (docs/api.md), so the -// smoke tests can walk every §4 flow and count its clicks. +// smoke tests can walk every §4 flow and count its clicks. Its builders and routes are also the +// base of the screenshots' demo control plane (demo.ts, docs/release.md). type Json = Record<string, unknown>; @@ -22,7 +23,7 @@ export interface Mock { const now = () => new Date().toISOString(); const later = (s: number) => new Date(Date.now() + s * 1000).toISOString(); -function host(hostname: string, share: boolean) { +export function host(hostname: string, share: boolean) { return { hostname, upstreams: ["http://10.0.0.2:3000"], @@ -37,7 +38,7 @@ function host(hostname: string, share: boolean) { }; } -function apply(id: string, state: string, summary: string, hosts: string[]) { +export function apply(id: string, state: string, summary: string, hosts: string[]) { return { id, change_id: id, @@ -58,12 +59,30 @@ function apply(id: string, state: string, summary: string, hosts: string[]) { }; } -export function installMock(): Mock { - const m: Mock = { +/** One API call: method, the path after /api/v1, and its answer as [status, body]. */ +export type Route = [string, RegExp, (mm: RegExpMatchArray, body: Json) => [number, unknown]]; + +export function newMock(): Mock { + return { calls: [], state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [] }, }; +} +/** The first route that matches answers, with server_time added as control does; else control's 404. */ +export function respond(routes: Route[], method: string, path: string, body: Json): { status: number; text: string | null } { + for (const [mm, re, f] of routes) { + const match = path.match(re); + if (mm === method && match) { + const [status, data] = f(match, body); + const withTime = data && typeof data === "object" ? { ...(data as Json), server_time: now() } : data; + return { status, text: status === 204 ? null : JSON.stringify(withTime) }; + } + } + return { status: 404, text: JSON.stringify({ error: { code: "request.not_found", message: "There is no such API call.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "x" }) }; +} + +export function mockRoutes(m: Mock): Route[] { const overview = (): Json => ({ counts: { hosts: 2 + m.state.hostsAdded.length, healthy: 2, degraded: 0, down: 0, unknown: 0 }, hosts: [host("wiki.home.test", true), host("photos.home.test", false), ...m.state.hostsAdded.map((h) => host(h, false))], @@ -108,7 +127,7 @@ export function installMock(): Mock { server_time: now(), }); - const routes: [string, RegExp, (mm: RegExpMatchArray, body: Json) => [number, unknown]][] = [ + return [ ["GET", /^\/overview$/, () => [200, overview()]], ["POST", /^\/hosts\/validate/, () => [200, { message: "This host can be applied." }]], ["POST", /^\/hosts$/, (_, b) => { @@ -152,6 +171,11 @@ export function installMock(): Mock { ["POST", /^\/tokens$/, (_, b) => [201, { id: "tk_1", name: b.name, token: "ian_tk1_secretvalue", expires_at: later(365 * 86400) }]], ["GET", /^\/share-links$/, () => [200, { items: [], epoch: 0 }]], ]; +} + +export function installMock(): Mock { + const m = newMock(); + const routes = mockRoutes(m); globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { const url = typeof input === "string" ? input : input instanceof URL ? input.pathname + input.search : input.url; @@ -159,15 +183,8 @@ export function installMock(): Mock { const method = (init?.method ?? "GET").toUpperCase(); const body = init?.body ? JSON.parse(String(init.body)) : {}; m.calls.push({ method, path, body }); - for (const [mm, re, f] of routes) { - const match = path.match(re); - if (mm === method && match) { - const [status, data] = f(match, body); - const withTime = data && typeof data === "object" ? { ...(data as Json), server_time: now() } : data; - return new Response(status === 204 ? null : JSON.stringify(withTime), { status, headers: { "Content-Type": "application/json" } }); - } - } - return new Response(JSON.stringify({ error: { code: "request.not_found", message: "There is no such API call.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "x" }), { status: 404, headers: { "Content-Type": "application/json" } }); + const a = respond(routes, method, path, body); + return new Response(a.text, { status: a.status, headers: { "Content-Type": "application/json" } }); }) as typeof fetch; return m; From 7a32eeb411d186df74c6f969b38bf31011fe119e Mon Sep 17 00:00:00 2001 From: mnovak <giteatruenasadminacc.from729@passmail.net> Date: Mon, 9 Nov 2026 17:42:06 +0100 Subject: [PATCH 3/5] [web] Shots: the release's screenshots of the built UI against the demo control plane, in headless Edge over DevTools (aula-*.png, aula.json) --- apps/web/package.json | 3 +- apps/web/scripts/shots.mjs | 418 +++++++++++++++++++++++++++++++++++++ 2 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 apps/web/scripts/shots.mjs diff --git a/apps/web/package.json b/apps/web/package.json index 77afe14..c5adebc 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -9,7 +9,8 @@ "dev": "vite", "build": "vite build", "check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings", - "test": "vitest run" + "test": "vitest run", + "shots": "node scripts/shots.mjs" }, "dependencies": { "@ianitor/ui": "workspace:*" diff --git a/apps/web/scripts/shots.mjs b/apps/web/scripts/shots.mjs new file mode 100644 index 0000000..e5f0a07 --- /dev/null +++ b/apps/web/scripts/shots.mjs @@ -0,0 +1,418 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// The release's screenshots of the web UI (docs/release.md): +// node apps/web/scripts/shots.mjs [--out <dir>] (default: <repo>/target/aula) +// Builds the UI, serves it on 127.0.0.1 with /api/v1 answered by the demo control plane +// (tests/demo.ts: invented data only), photographs each shot of demo.ts's SHOTS in headless Edge +// or Chrome over DevTools, and writes aula-<name>.png and aula.json in the format of Fabrica's +// core docs/FORMATS.md ("Fabrica: the Aula page"). On every way out the browser's process tree +// and the server are stopped and the temporary folder is removed. +// Exit codes: 0 done, 1 a problem, 130 cancelled. + +import { spawn, spawnSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; +import { createServer as createHttpServer } from "node:http"; +import { tmpdir } from "node:os"; +import { basename, delimiter, dirname, extname, join, normalize, resolve, sep } from "node:path"; +import { fileURLToPath } from "node:url"; +import { build, createServer as createViteServer } from "vite"; + +const web = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const repo = resolve(web, "../.."); +const WAIT_MS = 20_000; + +function usage(msg) { + console.error(`shots: ${msg}\nusage: node apps/web/scripts/shots.mjs [--out <dir>]`); + process.exit(1); +} + +let out = join(repo, "target", "aula"); +for (let i = 2; i < process.argv.length; i++) { + const a = process.argv[i]; + if (a === "--out" && process.argv[i + 1]) out = resolve(process.argv[++i]); + else usage(`unknown argument ${a}`); +} + +const log = (m) => console.log(`shots: ${m}`); +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); + +// ---------- cleanup on every way out ---------- + +const cleanups = []; +let cleaning = false; +async function cleanup() { + if (cleaning) return; + cleaning = true; + for (const f of cleanups.reverse()) { + try { + await f(); + } catch (e) { + console.error(`shots: cleanup: ${e?.message ?? e}`); + } + } +} +process.on("SIGINT", () => void cleanup().then(() => process.exit(130))); +process.on("SIGTERM", () => void cleanup().then(() => process.exit(130))); + +// ---------- the output folder ---------- + +function clearOutput() { + mkdirSync(out, { recursive: true }); + for (const n of readdirSync(out)) { + if (n === "aula.json" || (n.startsWith("aula-") && n.endsWith(".png"))) rmSync(join(out, n), { force: true }); + } +} + +/** Width and height from the PNG's IHDR, not assumed. */ +function pngSize(png) { + const sig = "89504e470d0a1a0a"; + if (png.length < 24 || png.subarray(0, 8).toString("hex") !== sig || png.subarray(12, 16).toString("latin1") !== "IHDR") { + throw new Error("the browser's capture is not a PNG"); + } + return { width: png.readUInt32BE(16), height: png.readUInt32BE(20) }; +} + +// ---------- the demo control plane and the built UI on 127.0.0.1 ---------- + +const TYPES = { + ".html": "text/html; charset=utf-8", + ".js": "text/javascript; charset=utf-8", + ".css": "text/css; charset=utf-8", + ".json": "application/json", + ".svg": "image/svg+xml", + ".png": "image/png", + ".ico": "image/x-icon", + ".woff": "font/woff", + ".woff2": "font/woff2", + ".txt": "text/plain; charset=utf-8", +}; + +function serve(dist, api) { + const index = readFileSync(join(dist, "index.html")); + const server = createHttpServer((req, res) => { + const url = new URL(req.url ?? "/", "http://127.0.0.1"); + if (url.pathname.startsWith("/api/v1/") || url.pathname === "/api/v1") { + const chunks = []; + req.on("data", (c) => chunks.push(c)); + req.on("end", () => { + let body = {}; + try { + body = chunks.length ? JSON.parse(Buffer.concat(chunks).toString("utf8")) : {}; + } catch { + body = {}; + } + const a = api(req.method ?? "GET", url.pathname.slice("/api/v1".length) + url.search, body); + res.writeHead(a.status, { "Content-Type": "application/json", "Cache-Control": "no-store" }); + res.end(a.text ?? undefined); + }); + return; + } + // The built files; any other path is the app's own route, answered with index.html. + const file = normalize(join(dist, decodeURIComponent(url.pathname))); + if (file.startsWith(dist + sep) && existsSync(file) && statSync(file).isFile()) { + res.writeHead(200, { "Content-Type": TYPES[extname(file)] ?? "application/octet-stream" }); + res.end(readFileSync(file)); + return; + } + res.writeHead(200, { "Content-Type": TYPES[".html"], "Cache-Control": "no-store" }); + res.end(index); + }); + return new Promise((ok, fail) => { + server.once("error", fail); + server.listen(0, "127.0.0.1", () => ok(server)); + }); +} + +// ---------- the browser ---------- + +function findBrowser() { + const named = process.env.IANITOR_SHOTS_BROWSER; + if (named) { + if (!existsSync(named)) throw new Error(`IANITOR_SHOTS_BROWSER: ${named} does not exist`); + return named; + } + const candidates = []; + if (process.platform === "win32") { + for (const base of [process.env["ProgramFiles(x86)"], process.env.ProgramFiles, process.env.LOCALAPPDATA].filter(Boolean)) { + candidates.push(join(base, "Microsoft", "Edge", "Application", "msedge.exe"), join(base, "Google", "Chrome", "Application", "chrome.exe")); + } + } else { + for (const dir of (process.env.PATH ?? "").split(delimiter).filter(Boolean)) { + for (const n of ["chromium", "chromium-browser", "google-chrome", "google-chrome-stable", "microsoft-edge"]) candidates.push(join(dir, n)); + } + candidates.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"); + } + const found = candidates.find((c) => existsSync(c)); + if (!found) throw new Error("no Microsoft Edge or Chrome found; set IANITOR_SHOTS_BROWSER to a Chromium browser"); + return found; +} + +/** Only what a program needs to run, the user folders in the temporary folder, nothing of the runner's. */ +function cleanEnv(home) { + const keep = /^(SystemRoot|SystemDrive|windir|ComSpec|PATH|PATHEXT|OS|PROCESSOR_.*|NUMBER_OF_PROCESSORS|ProgramFiles.*|ProgramW6432|CommonProgramFiles.*|CommonProgramW6432|ProgramData|ALLUSERSPROFILE|PUBLIC|LANG|TZ)$/i; + const env = {}; + for (const [k, v] of Object.entries(process.env)) if (keep.test(k) && v !== undefined) env[k] = v; + for (const d of ["home", "appdata", "local", "temp"]) mkdirSync(join(home, d), { recursive: true }); + Object.assign(env, { + HOME: join(home, "home"), + USERPROFILE: join(home, "home"), + APPDATA: join(home, "appdata"), + LOCALAPPDATA: join(home, "local"), + TEMP: join(home, "temp"), + TMP: join(home, "temp"), + TMPDIR: join(home, "temp"), + }); + return env; +} + +/** Edge may start its browser again as a new process, outside the tree: on Windows, anything still + * running with a profile in the temporary folder is stopped by its command line. */ +function sweep(exe, tmp) { + if (process.platform !== "win32") return; + const script = "Get-CimInstance Win32_Process -Filter \"Name='$env:SHOTS_EXE'\" | Where-Object { $_.CommandLine -and $_.CommandLine.Contains($env:SHOTS_TMP) } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"; + spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { + stdio: "ignore", + windowsHide: true, + env: { ...cleanEnv(join(tmp, "sweep")), SHOTS_EXE: basename(exe), SHOTS_TMP: tmp }, + }); +} + +function killTree(child) { + if (!child.pid || child.exitCode !== null) return; + if (process.platform === "win32") { + spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }); + } else { + try { + process.kill(-child.pid, "SIGKILL"); + } catch { + child.kill("SIGKILL"); + } + } +} + +/** Starts the browser; one that has not opened DevTools after 20 s is killed and started again, twice. */ +async function startBrowser(exe, tmp, size) { + for (let attempt = 1; ; attempt++) { + try { + return await launch(exe, join(tmp, `profile-${attempt}`), join(tmp, `user-${attempt}`), size); + } catch (e) { + if (attempt === 3 || e.fatal) throw e; + log(`${e.message}; starting it again`); + } + } +} + +async function launch(exe, profile, user, size) { + mkdirSync(profile, { recursive: true }); + const args = [ + "--headless=new", + "--remote-debugging-port=0", + "--remote-debugging-address=127.0.0.1", + `--user-data-dir=${profile}`, + "--no-first-run", + "--no-default-browser-check", + "--disable-extensions", + "--disable-sync", + "--disable-background-networking", + "--disable-component-update", + "--disable-default-apps", + "--disable-features=Translate,OptimizationHints,MediaRouter,msSmartScreenProtection", + "--hide-scrollbars", + "--mute-audio", + "--force-color-profile=srgb", + "--force-device-scale-factor=1", + `--window-size=${size.width},${size.height}`, + "about:blank", + ]; + const child = spawn(exe, args, { env: cleanEnv(user), stdio: ["ignore", "ignore", "pipe"], windowsHide: true, detached: process.platform !== "win32" }); + const stop = async () => { + killTree(child); + for (let i = 0; i < 50 && child.exitCode === null && child.signalCode === null; i++) await sleep(100); + }; + cleanups.push(stop); + let stderr = ""; + child.stderr.on("data", (d) => (stderr = (stderr + d).slice(-2000))); + const fail = async (msg, fatal = false) => { + await stop(); + const tail = stderr.trim().split(/\r?\n/).slice(-3).join(" | "); + throw Object.assign(new Error(`${msg}${tail ? `; it said: ${tail}` : ""}`), { fatal }); + }; + let exited = null; + child.on("exit", (code) => (exited = code ?? -1)); + child.on("error", (e) => (exited = e.message)); + + const portFile = join(profile, "DevToolsActivePort"); + const deadline = Date.now() + 20_000; + let seen = "no DevToolsActivePort yet"; + for (;;) { + if (exited !== null) await fail(`the browser exited before it was ready (${exited})`, typeof exited === "string"); + if (existsSync(portFile)) { + const port = Number(readFileSync(portFile, "utf8").split(/\r?\n/)[0]); + if (port > 0) { + try { + const list = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json(); + const page = list.find((t) => t.type === "page" && t.webSocketDebuggerUrl); + if (page) return page.webSocketDebuggerUrl; + seen = `no page among ${list.length} targets on port ${port}`; + await fetch(`http://127.0.0.1:${port}/json/new?about:blank`, { method: "PUT" }).catch(() => {}); + } catch (e) { + seen = `port ${port}: ${e.cause?.message ?? e.message}`; + } + } + } + if (Date.now() > deadline) await fail(`the browser's DevTools did not answer within 20 s (${seen})`); + await sleep(200); + } +} + +/** A minimal DevTools client over Node's WebSocket. */ +async function devtools(url) { + const ws = new WebSocket(url); + await new Promise((ok, fail) => { + ws.onopen = ok; + ws.onerror = () => fail(new Error("cannot open the browser's DevTools socket")); + }); + let id = 0; + const pending = new Map(); + ws.onmessage = (m) => { + const msg = JSON.parse(String(m.data)); + const p = msg.id !== undefined && pending.get(msg.id); + if (!p) return; + pending.delete(msg.id); + if (msg.error) p.fail(new Error(`${p.method}: ${msg.error.message}`)); + else p.ok(msg.result); + }; + ws.onclose = () => { + for (const p of pending.values()) p.fail(new Error("the browser closed its DevTools socket")); + pending.clear(); + }; + cleanups.push(() => ws.close()); + const send = (method, params = {}) => + new Promise((ok, fail) => { + const n = ++id; + pending.set(n, { ok, fail, method }); + ws.send(JSON.stringify({ id: n, method, params })); + }); + /** The value of an expression in the page; a page being replaced answers again later. */ + const evaluate = async (expression) => { + const r = await send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true }); + if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description ?? r.exceptionDetails.text); + return r.result.value; + }; + return { send, evaluate }; +} + +async function until(what, test) { + const deadline = Date.now() + WAIT_MS; + let last = null; + while (Date.now() < deadline) { + try { + if (await test()) return; + } catch (e) { + last = e; + } + await sleep(100); + } + throw new Error(`waited ${WAIT_MS / 1000} s for ${what}${last ? ` (${last.message})` : ""}`); +} + +// ---------- the shots ---------- + +async function main() { + clearOutput(); + const tmp = mkdtempSync(join(tmpdir(), "ianitor-shots-")); + cleanups.push(async () => { + for (let i = 0; i < 20; i++) { + try { + rmSync(tmp, { recursive: true, force: true }); + return; + } catch { + await sleep(250); + } + } + console.error(`shots: could not remove ${tmp}`); + }); + + // The demo's shots and answers, from the TypeScript the tests use. + const loader = await createViteServer({ + root: web, + configFile: false, + logLevel: "error", + appType: "custom", + server: { middlewareMode: true, hmr: false, ws: false }, + optimizeDeps: { noDiscovery: true, include: [] }, + }); + let demo; + try { + demo = await loader.ssrLoadModule("/tests/demo.ts"); + } finally { + await loader.close(); + } + const { SHOTS, SIZE, demoApi } = demo; + + log("building the web UI"); + const dist = join(tmp, "dist"); + await build({ root: web, logLevel: "warn", build: { outDir: dist, emptyOutDir: true } }); + + const server = await serve(dist, demoApi()); + cleanups.push(() => new Promise((r) => server.close(() => r()))); + server.closeAllConnections && cleanups.push(() => server.closeAllConnections()); + const base = `http://127.0.0.1:${server.address().port}`; + log(`demo control plane and UI on ${base}`); + + const exe = findBrowser(); + log(`browser: ${exe}`); + cleanups.push(() => sweep(exe, tmp)); + const page = await devtools(await startBrowser(exe, tmp, SIZE)); + await page.send("Page.enable"); + await page.send("Emulation.setDeviceMetricsOverride", { width: SIZE.width, height: SIZE.height, deviceScaleFactor: 1, mobile: false }); + + const taken = []; + for (const shot of SHOTS) { + const url = base + shot.path; + try { + // A fresh load per shot: mark the old page, so a page that has not been replaced yet does not count. + await page.evaluate("window.__ianitorShotsOld = true").catch(() => {}); + await page.send("Page.navigate", { url }); + await until(`${url} to load`, () => page.evaluate("!window.__ianitorShotsOld && document.readyState === 'complete'")); + for (const sel of shot.click ?? []) { + const q = JSON.stringify(sel); + await until(`${sel} to click`, () => page.evaluate(`(() => { const e = document.querySelector(${q}); if (!e) return false; e.click(); return true; })()`)); + } + const w = JSON.stringify(shot.wait); + await until(shot.wait, () => page.evaluate(`!!document.querySelector(${w})`)); + await page.evaluate("document.fonts.ready.then(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r(true)))))"); + await sleep(400); + } catch (e) { + try { + const failed = await page.send("Page.captureScreenshot", { format: "png" }); + writeFileSync(join(out, `aula-${shot.name}-failed.png`), Buffer.from(failed.data, "base64")); + } catch { + /* nothing to save */ + } + throw new Error(`shot ${shot.name}: ${e.message}; the page was ${url}; what it showed is aula-${shot.name}-failed.png`); + } + const png = Buffer.from((await page.send("Page.captureScreenshot", { format: "png" })).data, "base64"); + const { width, height } = pngSize(png); + const file = `aula-${shot.name}.png`; + writeFileSync(join(out, file), png); + taken.push({ name: shot.name, title: shot.title, file, width, height, sha256: createHash("sha256").update(png).digest("hex") }); + log(`${file} ${width}x${height}`); + } + writeFileSync(join(out, "aula.json"), `${JSON.stringify({ v: 1, shots: taken })}\n`); + log(`${taken.length} shots and aula.json in ${out}`); +} + +let code = 0; +try { + await main(); +} catch (e) { + console.error(`shots: ${e?.message ?? e}`); + code = 1; +} finally { + await cleanup(); +} +process.exit(code); From b9ab5006a8ed424875a9f5b8f98181dd25836e30 Mon Sep 17 00:00:00 2001 From: mnovak <giteatruenasadminacc.from729@passmail.net> Date: Mon, 9 Nov 2026 17:42:29 +0100 Subject: [PATCH 4/5] [fabrica] Release: the release pipeline on a v* tag (version check, web tests, fabrica notes, the shots, approval, publish under SHA256SUMS signed by domi-release) and the highlights of 0.1.0 --- .fabrica/artifex/release.yaml | 44 +++++++++++++++++++++++++++++++++++ .fabrica/notes/0.1.0.md | 18 ++++++++++++++ CLAUDE.md | 3 +++ scripts/check-version.mjs | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 .fabrica/artifex/release.yaml create mode 100644 .fabrica/notes/0.1.0.md create mode 100644 scripts/check-version.mjs diff --git a/.fabrica/artifex/release.yaml b/.fabrica/artifex/release.yaml new file mode 100644 index 0000000..e05263b --- /dev/null +++ b/.fabrica/artifex/release.yaml @@ -0,0 +1,44 @@ +# Ianitor Domi: the Gitea release of a v* tag (docs/release.md). Ianitor ships no binary (the server builds it with +# Nix and the deploy pipeline switches it in), so a release is its notes and screenshots of the web UI, published under +# a SHA256SUMS signed by domi-release through Custos; release-notes.md is also the release's text on Gitea. +# The Windows runner (the Fabrica app on Mark's PC) runs it: `fabrica`, node and pnpm are on every step's PATH. +# No Gitea webhook to the hub yet: a pushed tag is started on demand (the hub's POST /api/runs, ref v<version>). +# `notes` is Fabrica's release notes since the previous v* tag (Fabrica docs/12_release_kit.md); `shots` takes the +# same files as `fabrica aula shots` (core docs/FORMATS.md, "Fabrica: the Aula page") from the built web UI against +# the demo control plane with invented data, in headless Edge. No landing page while app.yaml has no `aula: true`. +name: release +on: + tag: "v*" + manual: true +runner: windows +steps: + - id: version + run: node scripts/check-version.mjs ${{ version }} + - id: install + run: pnpm install --frozen-lockfile + - id: check + needs: [install] + run: pnpm --filter web check + - id: test + needs: [install] + run: pnpm --filter web test + - id: notes + run: fabrica notes + artifacts: ["target/notes/release-notes.md", "target/notes/release-notes.json"] + - id: shots + needs: [check, test] + run: node apps/web/scripts/shots.mjs + artifacts: ["target/aula/aula-*.png", "target/aula/aula.json"] + - id: approve + needs: [version, notes, shots] + approve: "Publish Ianitor ${{ tag }}: its notes and screenshots?" + - id: publish + needs: [approve] + publish: + gitea-release: true + files: + - "**/release-notes.md" + - "**/release-notes.json" + - "**/aula-*.png" + - "**/aula.json" + sums: domi-release diff --git a/.fabrica/notes/0.1.0.md b/.fabrica/notes/0.1.0.md new file mode 100644 index 0000000..054f10c --- /dev/null +++ b/.fabrica/notes/0.1.0.md @@ -0,0 +1,18 @@ +The first release of Ianitor Domi: a reverse proxy for a home server, built on Cloudflare's Pingora, with Caddy as a +tested fallback, a small Domi certificate authority, and a web UI where every change takes three clicks or fewer. + +- **Hosts in plain words.** Add a host, say where its traffic goes, pick a Domi or Let's Encrypt certificate and + whether visitors sign in first (Authelia forward-auth). Each host is checked for health and shows healthy, + degraded or down. +- **Changes that undo themselves.** Every change is compiled, tried, and watched for 60 seconds; if a host stops + answering, it is reverted on its own. Routes live in a git repository, one file per host, with Undo and a + history you can restore any kept version from. +- **Two engines.** Pingora serves; Caddy is built from the same routes, compared host by host, and can take over at + runtime in about two seconds. +- **The Domi CA.** Certificates for hosts reached only from home, and device certificates (mTLS) for phones, + computers and Domi apps, from an intermediate whose root stays offline. +- **Share links**, signed and time-limited, for a single host. +- **NixOS-native.** A flake with the module and VM tests; deployed through Fabrica. + +The changes below are the merges since the first commit; PR 3 to 5 are the control plane (phase 2), the decisions +on the open points, and the web UI, the Domi CA and the NixOS module (phase 3). diff --git a/CLAUDE.md b/CLAUDE.md index d0d0b84..245643a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,11 +13,14 @@ tests/diff same requests against Ianitor and Caddy, responses compared. tests/support shared test fixtures (test CA, upstreams, mock Authelia, clients); test-only. tests/fuzz cargo-fuzz targets. deploy/nixos NixOS module + VM tests. +scripts the release's version check. Releases (notes, screenshots): docs/release.md. ## Commands cargo test --workspace # quote test counts per crate; an exit code alone is not green cargo run -p ianitor-control -- --dev pnpm --filter web dev # 127.0.0.1 only, never --host +node apps/web/scripts/shots.mjs # the release's screenshots (demo data, headless Edge) -> target/aula (docs/release.md) +node scripts/check-version.mjs X.Y.Z # Cargo.toml and both package.json carry the version nix build .#ianitor nix flake check # includes NixOS VM tests (Linux + KVM) diff --git a/scripts/check-version.mjs b/scripts/check-version.mjs new file mode 100644 index 0000000..142ef63 --- /dev/null +++ b/scripts/check-version.mjs @@ -0,0 +1,43 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// The release's version check (docs/release.md): every place that carries Ianitor's version agrees, +// and, given a version (the tag's, e.g. 0.1.0 for v0.1.0), is that version. +// node scripts/check-version.mjs [X.Y.Z] +// Exit codes: 0 they agree, 1 they do not, 2 usage. + +import { readFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const repo = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const want = process.argv[2]; +if (process.argv.length > 3 || (want !== undefined && !/^\d+\.\d+\.\d+$/.test(want))) { + console.error("usage: node scripts/check-version.mjs [X.Y.Z]"); + process.exit(2); +} + +function cargo() { + const text = readFileSync(join(repo, "Cargo.toml"), "utf8"); + const section = /^\[workspace\.package\]\s*$([\s\S]*?)(?=^\[|(?![\s\S]))/m.exec(text); + const v = section && /^version\s*=\s*"([^"]*)"\s*$/m.exec(section[1]); + return v ? v[1] : null; +} + +const pkg = (p) => JSON.parse(readFileSync(join(repo, p), "utf8")).version ?? null; + +const found = [ + ["Cargo.toml [workspace.package]", cargo()], + ["apps/web/package.json", pkg("apps/web/package.json")], + ["packages/ui/package.json", pkg("packages/ui/package.json")], +]; + +const expected = want ?? found[0][1]; +const wrong = found.filter(([, v]) => v !== expected); +for (const [where, v] of found) console.log(`${where}: ${v ?? "(none)"}`); +if (wrong.length) { + console.error(`version: expected ${expected} everywhere; ${wrong.map(([w, v]) => `${w} has ${v ?? "none"}`).join(", ")}`); + process.exit(1); +} +console.log(`version: ${expected} everywhere`); From dcdff4d414d42ba4751a271a50d4c4577a84c29e Mon Sep 17 00:00:00 2001 From: mnovak <giteatruenasadminacc.from729@passmail.net> Date: Mon, 9 Nov 2026 17:46:34 +0100 Subject: [PATCH 5/5] [docs] Roadmap: phase 4 started with the release kit; handover --- docs/ROADMAP.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 667039e..86972e6 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -145,11 +145,28 @@ Identity gate, tunnel, Domi templates, ACME server, HTTP/3, migrating public sit | 1 Core and engine | Done | Merged to main 2026-11-07. Tests run in WSL2; ACME checked only against Pebble. The Let's Encrypt staging check moved to phase 3 (Mark, 2026-11-07). | | 2 Control plane | Done | Merged to main 2026-11-07 (PR 3): routes repo, journaled apply with trial/watch/revert, undo, restore, share links, API tokens, REST API + OpenAPI, `--dev`. Four QC rounds; every finding fixed or listed in Handover. Real Gitea, systemd credentials and Authelia not exercised. | | 3 Web UI, PKI, NixOS | Built and merged; Done criteria pending Mark | Merged to main 2026-11-08 (PR 5): web UI (murex palette), Domi CA and device mTLS, UI sign-in behind Authelia, runtime engine switch with changes under Caddy, NixOS flake, module and VM tests. Click smoke test green. Not yet done: VM tests run on a KVM host, Mark's nixos-rebuild on the staging mirror, deploy/test-access.sh there, the LE staging check. | -| 4 Hardening and release | Not started | Known gaps carried here: see Handover. | +| 4 Hardening and release | Started: the release kit | A `v*` tag's Gitea release carries the notes and screenshots of the web UI under a signed SHA256SUMS (docs/release.md, 2026-11-09). The rest of phase 4 is not started; known gaps carried here: see Handover. | ## 10. Handover (Rewritten at the end of every session: what changed, what was not verified, which build is deployed, the next step.) +**2026-11-09: Release notes and screenshots for Fabrica.** +- **Changed:** `.fabrica/artifex/release.yaml` (on a `v*` tag, Windows runner: version check, web check and tests, + `fabrica notes`, the screenshots, Custos approval, publish to the tag's Gitea release with `sums: domi-release`); + `apps/web/scripts/shots.mjs` (the built UI against the demo control plane `apps/web/tests/demo.ts`, invented data, + headless Edge over DevTools: `aula-hosts`, `-host`, `-engine`, `-history`, `-certificates`.png and `aula.json`); + `apps/web/tests/demo.test.ts` (each shot drawn from the demo alone, and nothing in it outside `.test` and the + documentation address ranges); `mockApi.ts` exports its builders and routes for the demo; `scripts/check-version.mjs`; + `.fabrica/notes/0.1.0.md` (the first release's highlights). docs/release.md says how. app.yaml is unchanged (no + `aula: true`, so no landing page; no desktop part: Ianitor has no installer). +- **Verified:** `fabrica artifex check` 0 problems; `fabrica notes` (whole history; PR 3 to 5 come out as bare + "PR #n", hence the highlights); the shots script 9 runs (one browser start timed out, before the retry was added), + each PNG looked at; vitest 21 (smoke 15, demo 6), svelte-check clean. Rust on Windows only (WSL2 Debian would not + start: HCS_E_CONNECTION_TIMEOUT): core 103, control 21, edge 31 and diff 2 (the Linux-only targets are skip stubs + there), testkit 1; no Rust file changed. +- **Deployed:** nothing; no tag, no run. +- **Next step:** Mark tags `v0.1.0`, starts `release` at it, then Deploy as before. + **2026-11-08: Ianitor declared to Fabrica.** - **Changed:** `.fabrica/app.yaml` (a server part, flake input `ianitor`) and `.fabrica/artifex/deploy.yaml` (approve, then `deploy: ianitor`), so Fabrica's Apps screen shows an Ianitor card with Deploy. `fabrica artifex check`: 0 problems.