Skip to Content
DevelopersHow Koomerce worksTesting and guardrails

2 min read

Testing and guardrails

Rules that matter are checked by code, so they hold no matter who (or which AI) writes the change. GitHub Actions are paused, so every check below runs locally before a PR.

CommandWhat it checksWhy
bun run lintBiome (format and lint, warnings are errors) and scripts/check-components.tsOne file shape for every React component
bun run lint:designOxlint with the shadcn rules; no-restyle is an error for the settled shared partsThe admin keeps one look
bun run typecheckTypeScript 7 across the workspace
bun run testVitest per package through Turbo; database suites need Postgres, one test database per packageBusiness rules, workflows, webhooks, RLS
bun run test:sweepsThe guardrail sweeps in scripts/sweeps/Rules a type checker cannot see
bun run --cwd apps/docs buildRedirects, every internal docs link, the static buildNo broken docs

How to run the suites quickly (only what changed, a namespace per worktree): Testing.

Tests worth knowing

  • Cross-store leak test (packages/api/test/cross-store-leak.test.ts): seeds two stores with a row in every store_id table, then calls every oRPC procedure and storefront loader as store A with store B’s ids. Any of B’s data showing or changing fails it.
  • RLS coverage (packages/db): a table with store_id but without the policy fails.
  • Workflow compensation: property-based tests that every completed step of a failed saga is undone in reverse.
  • Provider conformance: every payment, shipping, notification and storage app runs the same contract suite (offline; live runs behind env flags).

The sweeps

Each sweep is a Vitest file that reads the source tree. Most are ratchets: an allow-list that may only shrink, so old exceptions are tolerated but new ones fail. A few of the 30+:

SweepKeeps true
service-layerOnly core, db, the api services and scripts import the database
client-imports-serverBrowser code never imports server packages
storefront-action-storeStorefront actions take the store from the host, never from the caller
handler-grantsPermissions are checked by the procedure middleware, not inside handlers (so approvals apply)
admin-routesAdmin links use routes, not typed paths
design-guardNo raw text sizes, big radii or retired kit parts in the admin
hardcoded-colours, money-format, date-formatTokens for colour, one money formatter, one date formatter
deploy-composeThe production compose file passes every env key the apps need
app-catalogueThe App Store catalogue is regenerated after a manifest changes
site-configThe brand name is spelled once, in siteConfig
file-size, no-orphans, dead-code, duplicate-helpersNo huge files, unused exports, removed code coming back, or copies of helpers
source-of-truth-headerNew core files start with a header saying what they own and why

The full list with every rule: Guardrails and sweeps and docs/guardrails.md.

Before a release

The checkout smoke test and the manual checklist on the test server: Release checklist.

Was this helpful?
Last updated on