← All decisions

TDD and stability as primary; the RLS isolation test is the keystone gate

accepted

0009 — TDD and stability as primary; the RLS isolation test is the keystone gate

Context

Ark is built by a one-engineer team whose day job is C++ low-level graphics — a discipline-heavy, correctness-paramount, deeply tested practice. The pitch (“one engineer + AI agents at N tenants”) collapses if anything breaks unpredictably.

Combined with multi-tenancy via row-partitioning (ADR 0002), correctness becomes existential: a single missing or wrong RLS policy leaks data across organizations. The mitigation isn’t “be careful” — careful doesn’t scale.

Decision

Test-driven development is the default, not optional. Every package follows: failing test first, implementation second, passing test third. New behavior without a test is a review-blocker.

The RLS isolation test (packages/db/test/rls-isolation.spec.ts) is the keystone gate. It boots a real Postgres (Supabase local), applies all migrations, creates two organizations with members, exercises every CRUD path and every published-content read path, and asserts that no query in either direction can see data from the other org.

CI runs the RLS isolation test on every push. A red gate blocks merge. There is no merge-with-failing-tests escape valve.

New tables and policies extend the RLS test as part of their PR. A migration that adds a table without a corresponding test row is rejected. The migration linter (pnpm migrate:lint) checks structurally; the test verifies behaviorally.

Consequences

Easier:

Harder:

Trip-wires

We reconsider this stance only if:

Alternatives considered