Skip to content

[M3.6a] Domains: unique per organization, live DNS check - #178

Merged
samuelmbabhazi merged 3 commits into
mainfrom
feat/m3.6a-domains
Nov 7, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
feat/m3.6a-domains

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

M3.6a: domains, closing a real gap. SPEC says a hostname is unique per organization, but nothing enforced it, so two applications could claim the same host and overwrite each other's route.

  • domains table (forced tenant RLS), unique on (organization_id, hostname), synced from the configuration on every save. The configuration stays the source of truth. assertTenantDatabaseRole now covers 18 tables.
  • Claims: a host another application uses answers 409 domain_taken with the hostname, and the whole save rolls back. A rollback checks too, because an older configuration may name a host claimed since; it keeps the current domains claimed as well.
  • Wildcards are refused (400 wildcard_domain_unsupported): they need DNS-01, which neither the agent nor the control plane offers yet.
  • GET …/applications/{a}/domains does a live, bounded A and AAAA lookup (3 s, no connection to the answers) outside any transaction:
    • public with its addresses;
    • private, with the answers withheld, so tenants cannot use the control plane's resolver to map internal names;
    • none;
    • unknown when the lookup failed.
  • Web: a Domains section on the application page. isPublicAddress moves to platform/net, shared with the registry guard.

How it was tested

  • Unit tests: wildcard refusal, status classification, and non-public addresses never revealed. Web test for all three displayed states.
  • Full local gate: 294 API and 67 web tests, Go race tests, lint, drift, Semgrep, Prettier.
  • Not run: the new integration test (claim conflict, rollback of the refused application, freeing a host, wildcard) because Docker is not reachable here. DnsDomainResolver has no automated test against real DNS.

Assumptions

  • No backfill: there are no installations yet, so existing rows are not migrated. An application from a development database gets its claims at its next save.
  • Real verification against a node's public address, certificate expiry and DNS-01 are M3.6b. HTTP-01 itself is unproven until the VM run.

review added 3 commits November 7, 2026 13:19
A hostname belongs to one application per organization, with forced
tenant RLS. The public-address guard moves to platform/net so the DNS
check can share it.

Signed-off-by: review <[email protected]>
Saving a configuration syncs its domains, refusing a hostname another
application claims and wildcards until DNS-01 exists. A live DNS check
on the application page reports public addresses only, so the control
plane's resolver cannot be used to map internal names. Rollbacks check
their older domains too.

Signed-off-by: review <[email protected]>
@samuelmbabhazi
samuelmbabhazi merged commit 2869cd8 into main Nov 7, 2026
8 of 10 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m3.6a-domains branch November 7, 2026 11:22
samuelmbabhazi added a commit that referenced this pull request Nov 7, 2026
## What changed

Moved two suites into their own spec files, with no change to the tests
themselves:

- `application domains over HTTP` →
`application-domains-http.integration.spec.ts`
- `rollback over HTTP` → `rollback-http.integration.spec.ts`

## Why

**These two suites never ran.** Each started a second app in a file that
had already started one. Configuration is read once per module graph, so
the second app looked for the first one's deleted KEK file and failed in
setup with `KekError`. They shipped in #176 and #178 without any
integration run, so nobody saw it.

Also updates the PLAN status with what has now run.

## How it was tested

The first integration run of this code, on `main` at #187, against a
disposable local PostgreSQL 18.4 (`DATABASE_URL`, no Docker):

- **Before the split:** 304 passed, 3 failed, 2 skipped, and these 2
suites failed in setup.
- **After the split, these 4 files:** 9 of 9 pass, including rollback
and domain uniqueness.
- **The 3 failures** expect `23503` for `ON DELETE RESTRICT`, which
PostgreSQL 18 reports as `23001`. The project pins 17, where they should
pass, but that has not been run. They are left unchanged.

Not covered: a real Docker daemon or server, and the pinned PostgreSQL
17.

## Security considerations

Test-only and documentation change.

## Checklist

- [x] Integration tests run for the changed files
- [x] No new shell invocation, no new secret exposure path
- [x] PLAN updated

---------

Signed-off-by: review <[email protected]>
Co-authored-by: review <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant