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:
| Feature | Edition |
|---|---|
| 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/, underee/LICENSE, in the same repository and the same public export. Backend code is inee/src/, tests inee/test/, dashboard pages inee/dashboard/. - Code outside
ee/never imports fromee/. Code inee/imports fromsrc/freely.test/edition.spec.tsandscripts/export-public.shcheck 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.
| Port | Community | Enterprise |
|---|---|---|
DASHBOARD_SSO (src/modules/auth/dashboard-sso.ts) | NoDashboardSso: no session tokens, no tenant requires SSO | SsoService |
KMS_SIGNER (src/modules/evidence/create-signer.ts) | null: EVIDENCE_SIGNER=kms stops the boot | the KMS signer factory |
EVIDENCE_SEALING (src/modules/evidence/sealing.ts) | null, and any EVIDENCE_SEALER other than none stops the boot | the 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 isRISKBOUND_EE=1and 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 intoee/: a runtimeimport()ofee/src/index, so the Community build compiles withee/deleted. When the gate says Enterprise andee/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) sayscommunityorenterpriseand lists the features.- On a Community server,
/v1/insure/*and/v1/sso/*answer402with codeenterprise_featureand a message that names the feature, even without a key.POST /v1/events/sealanswers402too.GET /v1/events/sealsand verify say sealing is off, as they did before when no store was set. - The build output moves from
dist/todist/src/anddist/ee/src/, becauseee/compiles alongsidesrc/with one root. The server isnode dist/src/main.js, the migrationnode dist/src/db/migrate.js. Compilingee/separately would give it its own copy ofsrc/, and two copies of each injection token.
Database#
- The migrations for the Enterprise tables (
0003_evidence_seals,0010_sso) stay indrizzle/, 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.tsreads both schema files. Generate migrations withee/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 inee/dashboard/, at the paths they take in the dashboard, anddashboard/scripts/ee-overlay.mjscopies them in beforedev,build,lintandtypecheck. It removes the copies whenee/is gone. - Copies go only into places git ignores: route groups named
(ee),lib/ee/andcomponents/ee/. The script refuses anything else, and never overwrites a Community file. next.config.tssetsRISKBOUND_DASHBOARD_EEat 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 listsso. 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 seeee/.
Proof#
- CI's
communityjob deletesee/, then runs the backend lint, format check, typecheck, tests (with a real Postgres) and build, starts the built server, checks the 402s, checks thatRISKBOUND_EE=1withoutee/stops the server, and builds the dashboard. - The other jobs run with
ee/present.npm testrunsee/test/too. - The e2e workflow runs twice:
RISKBOUND_EE=1, and0, 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.mdsays so. @aws-sdk/client-kmsand@aws-sdk/client-s3stay in the rootpackage.json, becauseee/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 inee/test/, dashboard files in an(ee)group. - The gate is a switch, not a licence check. Until the licence key check
lands,
ee/LICENSEgoverns use ofee/, not the code.