Skip to content

[M2.3g1a] Bind node certificates to their organization (ADR 0015) - #117

Merged
samuelmbabhazi merged 3 commits into
mainfrom
feat/m2.3g1a-node-certificate-tenant
Nov 5, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
feat/m2.3g1a-node-certificate-tenant

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

M2.3g1a, the first half of fleet tenant isolation (ADR 0015).

  • Migration 20261105120000_node_certificate_organization:
    • adds node_certificates.organization_id, backfills it from nodes, then sets it NOT NULL;
    • adds a unique (organization_id, id) on nodes;
    • replaces the single-column foreign key with (organization_id, node_id) -> nodes(organization_id, id) (ON DELETE CASCADE, ON UPDATE RESTRICT) and re-indexes.
  • Prisma schema. It mirrors the migration, with names matching Prisma's conventions.
  • Domain. NodeCertificateRecord.organizationId. Enrollment sets it from the token's organization, and renewal from the authenticated identity.
  • ADR 0015. Records the full design. g1b will add forced RLS on nodes, join_tokens and node_certificates. Gateway lookups will be scoped to the organization of the verified certificate. Enrollment will use a context-bound, SELECT-only join_token_lookup policy instead of the separate database role the PLAN proposed earlier, the same pattern as account discovery.
  • SPEC data model and PLAN. Updated; M2.3g1 is split into g1a (done here) and g1b.

Why

SPEC 4 requires every tenant table to carry its organization. Without it, node_certificates could not get a tenant RLS policy. The composite key also makes a certificate of another tenant's node unrepresentable.

How it was tested

  • New fleet-tenant.integration.spec.ts case:
    • a certificate whose organization differs from its node's is rejected (23503);
    • a missing organization is rejected (23502);
    • moving a certificate to another organization is rejected;
    • deleting the node cascades.
  • prisma validate and prisma format pass. Unit tests and the local gate pass.
  • Not run locally: the integration tests (no Docker). They run in CI-1.

Security considerations

This is a stronger data-model invariant. It does not touch the action list or credentials.

@samuelmbabhazi
samuelmbabhazi merged commit 6ca8fef into main Nov 5, 2026
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.3g1a-node-certificate-tenant branch November 5, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant