RiskboundDocs

Architecture

ADR 0018: Open-core editions

Date: 2026-12-02. Status: accepted.

Context#

Riskbound goes open source under Apache 2.0, with an open-core model: a free Community edition anyone can self-host, and commercial Enterprise and Cloud editions. Anything published under Apache stays Apache for that version, so the commercial features had to leave the Apache-licensed code before the first public export. EDITIONS.md and ee/LICENSE already existed, but every feature still lived in src/.

The split, as decided:

FeatureEdition
Postgres row-level security (ADR 0015)Community
SSO for the dashboard (ADR 0016)Enterprise
KMS signer (ADR 0007)Enterprise
Sealing evidence to S3 Object Lock (ADR 0009)Enterprise
Insure: exposure, risk price, insurer pack (ADR 0014)Enterprise

Decision#

Layout#

  • Enterprise code lives in ee/, under ee/LICENSE, in the same repository and the same public export. Backend code is in ee/src/, tests in ee/test/, dashboard pages in ee/dashboard/.
  • Code outside ee/ never imports from ee/. Code in ee/ imports from src/ freely. test/edition.spec.ts and scripts/export-public.sh check the first rule.
  • Sealing moved whole: the seal service, the schedule, the S3 and local directory stores, and the seal check. Community has no sealing at all, rather than a local-only sealer that looks like a protection it is not.

Ports, filled by Community or by ee/#

Community defines each port and fills it with an implementation that fails closed. Enterprise fills the same port instead.

PortCommunityEnterprise
DASHBOARD_SSO (src/modules/auth/dashboard-sso.ts)NoDashboardSso: no session tokens, no tenant requires SSOSsoService
KMS_SIGNER (src/modules/evidence/create-signer.ts)null: EVIDENCE_SIGNER=kms stops the bootthe KMS signer factory
EVIDENCE_SEALING (src/modules/evidence/sealing.ts)null, and any EVIDENCE_SEALER other than none stops the bootthe seal service and its schedule

The approval and key rules ask DASHBOARD_SSO, never the SSO code. Verify and export ask EVIDENCE_SEALING. The types they share (Person, SealReport and the rest) are Community's, in the port files.

Loading#

  • EditionGate (src/edition/edition-gate.ts) decides. Today it is RISKBOUND_EE=1 and nothing else; any other value, a typo included, is Community. A TODO marks where a signed licence key check goes. It must decide Community for a bad or expired key, never Enterprise.
  • loadEdition (src/edition/load-edition.ts) is the only door into ee/: a runtime import() of ee/src/index, so the Community build compiles with ee/ deleted. When the gate says Enterprise and ee/ is missing or broken, the server does not start. It never falls back to Community quietly.
  • AppModule.register(edition) adds the edition's controllers and providers. A provider for a port drops the Community filling of it.
  • GET /v1/edition (no key) says community or enterprise and lists the features.
  • On a Community server, /v1/insure/* and /v1/sso/* answer 402 with code enterprise_feature and a message that names the feature, even without a key. POST /v1/events/seal answers 402 too. GET /v1/events/seals and verify say sealing is off, as they did before when no store was set.
  • The build output moves from dist/ to dist/src/ and dist/ee/src/, because ee/ compiles alongside src/ with one root. The server is node dist/src/main.js, the migration node dist/src/db/migrate.js. Compiling ee/ separately would give it its own copy of src/, and two copies of each injection token.

Database#

  • The migrations for the Enterprise tables (0003_evidence_seals, 0010_sso) stay in drizzle/, in the one linear journal. Every database has every table, whichever edition runs, so a server can move between editions without a migration and row-level security covers them all.
  • Their Drizzle definitions moved to ee/src/db/schema.ts, so Community code cannot name them. drizzle.config.ts reads both schema files. Generate migrations with ee/ present, or drizzle-kit would drop those tables.
  • test/rls.spec.ts (Community) still fills the Enterprise tables, with plain SQL, to check that row-level security covers every table. That is the only Community code that touches them, and it is a test.

Dashboard#

  • Next.js finds pages only under app/. The Enterprise pages are kept in ee/dashboard/, at the paths they take in the dashboard, and dashboard/scripts/ee-overlay.mjs copies them in before dev, build, lint and typecheck. It removes the copies when ee/ is gone.
  • Copies go only into places git ignores: route groups named (ee), lib/ee/ and components/ee/. The script refuses anything else, and never overwrites a Community file.
  • next.config.ts sets RISKBOUND_DASHBOARD_EE at build time. The sidebar shows Insure, and the sign-in page offers SSO, only when the pages are in the build. The SSO link also needs the backend to list sso. The Insure page on a Community backend says Insure is Enterprise.
  • The image build (release.yml) runs the overlay first, since the dashboard's Docker context cannot see ee/.

Proof#

  • CI's community job deletes ee/, then runs the backend lint, format check, typecheck, tests (with a real Postgres) and build, starts the built server, checks the 402s, checks that RISKBOUND_EE=1 without ee/ stops the server, and builds the dashboard.
  • The other jobs run with ee/ present. npm test runs ee/test/ too.
  • The e2e workflow runs twice: RISKBOUND_EE=1, and 0, where the Insure and SSO tests skip and a test checks their routes answer 402.

Why#

  • One repository with an ee/ folder is how GitLab and PostHog do open core. The licence boundary is a folder anyone can see.
  • Ports keep the fail-closed rule: Community's filling of each port is the safe answer, and an operator who asks for an Enterprise protection on a Community server gets a stopped server, not a missing protection.
  • One migration journal means no edition-specific database states, and no migration to run when a licence starts or ends.

Consequences#

  • Turning Enterprise off is a downgrade the operator chooses. A tenant that required SSO goes back to admin-key sign-in on the dashboard, since Community never reads the SSO settings. Seals stay where they are but are not checked until Enterprise is on again. EDITIONS.md says so.
  • @aws-sdk/client-kms and @aws-sdk/client-s3 stay in the root package.json, because ee/ shares the root package. Community code does not use them.
  • New Enterprise code follows ee/README.md: a Community port first, ee/ fills it, tests in ee/test/, dashboard files in an (ee) group.
  • The gate is a switch, not a licence check. Until the licence key check lands, ee/LICENSE governs use of ee/, not the code.