Skip to main content

Decisions — tooling

Rendered from corpus/wiki/decisions-tooling.md · updated 2026-11-04

This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.

How the repo builds, checks and pins itself. These are the calls that decide whether a green command means anything.

Three of the four below exist because a tool was reporting success while reaching nothing — the pattern log.md calls green because nothing ran, which has now been hit seven times in this project. That is the thread to follow if you are tempted to relax one of them.

Runtime and library calls live in decisions-engineering.md, the security posture in decisions-security.md, product-shaping ones in decisions.md. Same rule: don't reopen one without an explicit revisit and a log.md entry.

The UI workspace is typechecked, not just bundled​

2026-08-31 — ui has a typecheck script (tsc --noEmit) alongside its bundler build, and the root build chain runs it. (The bundler was astro build when this was decided; the move to Vite + React (2026-08-31) made it vite build days later, and the typecheck step was the point either way.) Found because the editor work (2026-08-31) left a dangling import { EditorStep } from '../editor/EditorStep' in ui/src/components/wizard/Wizard.tsx and every gate stayed green. core and api both built with tsc --noEmit (they also emit dist/ since 2026-11-04); ui built with astro build alone, which bundles from the page entry points and tree-shakes — nothing imports Wizard, so the file was never reached, never typechecked, and never complained.

Two things had to be fixed before the script could pass at all, and both were hiding the same way: ui/tsconfig.json set the deprecated baseUrl, which raised a config-level error that aborted the run before any file was checked — so even running tsc -p ui by hand caught nothing; and types was unset, so the eight UI test files importing node:fs/node:url could not resolve them.

Same family as the .gitignore and vitest-include incidents: green because nothing ran. A tool that is not reaching a file cannot report on it, and a passing command is not evidence of coverage.

The formatter and the linter are enforced, and configured to do something​

2026-08-31 — Three tooling defects, found by running npm run fmt on a clean tree during a verify gate and watching it rewrite 106 files.

There was no Prettier config at all, so npm run fmt used Prettier's defaults — double quotes — against a single-quoted codebase. And eslint.config.js enabled zero rules: parser and plugin registered, the three rules it named turned off, no recommended set imported. npm run lint had reported green for the project's entire history while linting nothing. Proved, not assumed: a plain unused variable draws exit 0 and no output from it.

The config is { singleQuote: true, printWidth: 100 }, derived by measuring — 12 options against all 158 committed files, scored by files already clean. Prettier's defaults scored 1 of 158; this scores 88, at the minimum of the changed-line curve. Rejected: picking a house style by preference, which makes the diff a matter of taste rather than of fit.

npm run build now runs fmt:check first. Rejected: leaving the formatter available but unenforced — precisely how 106 files drifted. Accepted cost: an agent running build for type feedback mid-refactor hits a formatting failure before any type error.

.astro was dropped from the fmt glob rather than adding a plugin, on the reasoning that the move to Vite + React (2026-08-31) was about to delete every .astro file. It did, days later, and the glob gained ui/vite.config.ts and ui/index.html in the same pass — so the gap opened and closed as planned rather than becoming permanent. Ten react-hooks findings were suppressed at config level until the hook-rules fix later that day turned the rules on; rules-of-hooks and exhaustive-deps, the two that catch correctness bugs, were on and clean throughout.

npm workspaces, three packages, ESM throughout​

2026-06-10 — core / api / ui, all "type": "module" (the docs workspace, added later, is the exception below). Every runtime path must resolve from import.meta.url, never process.cwd() — the app is started from several working directories and cwd()-relative paths broke in wave 5 (see the path-resolution fixes in 32af25e). This is the single most repeated bug in the project's history.

The docs workspace is the one package without "type": "module"​

2026-10-19 — docs/ (@newspapper/docs-site) moved from Astro Starlight to Docusaurus 3.10 on the owner's call of 2026-10-18, and Docusaurus's build fails when the site package is "type": "module" (TypeError: require.resolveWeak is not a function during static generation, reproduced 2026-10-18). So that package leaves the field out. Its own scripts are .mjs, ESM by extension, and still resolve paths from import.meta.url; docusaurus.config.ts and sidebars.ts are loaded by Docusaurus itself. core, api and ui stay ESM. Rejected: keeping Starlight, which was the owner's call, not a technical one.

Dependency versions are pinned exactly​

2026-06-10 (5c7ca55) — No ^ or ~ anywhere in a package.json; write the exact installed version when adding a dependency. Rejected: caret ranges. The reason is reproducible installs — the same checkout resolves to the same tree on any machine and at any later date, without a lockfile being the only thing standing between you and a silent upgrade.

No GitHub-hosted CI: the gate is an npm script​

2026-10-04 (owner) — No GitHub runners, workflows or other GitHub-specific automation in the repo. The full gate is npm run gate (build, test, lint, corpus lint, with CI=1 so a missing Chromium fails instead of skipping), run by hand or by the deploy. Rejected: .github/workflows/ci.yml, which the Chromium-guard work (2026-10-03) added and this removed. The estate deploys through its own vps-deploy, and the owner wants no GitHub machinery in the repos.

The API runs built JavaScript, started by node​

2026-11-04 (owner) — In production the API is node api/dist/server.js: core and api compile with tsc into dist/, and the image holds no npm process, no tsx and no dev dependencies. This revisits the call made when the app was containerized, "runs from SOURCE under tsx", with dev dependencies kept in the runtime image because there was no compile step. That call lived in the Dockerfile's header and commands.md, never on a decisions page. The reason is the box: 3.7 GiB of RAM shared by every app in the estate, which the owner will not upgrade, so on 2026-11-04 the owner decided its apps run built JavaScript and start with node directly. This container was the second largest there (138 MB; its tsx process 127 MB plus 58 MB in swap). Measured locally on Docker Desktop with the Reader's loop off, idle went from 175 MiB to 87 MiB, and the process tree from npm, sh, tsx, node and esbuild to one node.

How: core's exports keep their .ts source as the default, which tsx, Vite and vitest read, and each entry gains a newspapper-built condition pointing at dist/. The image sets NODE_OPTIONS=--conditions=newspapper-built, so an env file that sets NODE_OPTIONS must keep that flag. Node is now PID 1, which gets no default action for SIGTERM, so the server exits on it itself. Rejected: a bundler, because core finds the repo root by counting .. from its own file (util/paths.ts, render/fonts.ts); a bundle moves that code to another depth, where fonts, ui/dist and the seed list all miss, and tsc's dist/ sits at src/'s depth. Re-pointing the exports at dist/ for everyone, which the dead-config cleanup (2026-08-31) had already turned down: tsx, vitest and the UI's Vite build would read stale output or need core built first. Node's own type stripping, which is not built JavaScript and does not map the source's .js import specifiers to .ts files.