feat(federation): shared epoch types + getInstanceId()

This commit is contained in:
Jannis Braun
2026-07-01 21:19:25 +02:00
parent d8f2b1a9c7
commit 7acf48d0a4
6 changed files with 131 additions and 1 deletions
+3
View File
@@ -171,9 +171,12 @@ No authentication. Returns:
federatedRegistrationOpen: boolean; // NOT NULL DEFAULT 1; gates federated-account creation
sourceCodeUrl: string; // AGPL § 13; config.sourceCodeUrl (env BACKSPACE_SOURCE_URL)
commit: string | null; // AGPL § 13; config.commit (env BACKSPACE_COMMIT, build-injected)
instanceId: string; // Persistent per-instance epoch (incarnation UUID); getInstanceId()
}
```
`instanceId` is the persistent per-instance epoch — a UUID minted once by `ensureDefaults` on first boot and stable across restarts (stored in `instance_settings.instance_id`, guaranteed non-null after boot). It changes only when the instance is wiped/re-provisioned. Peers read it to detect that a remote has been re-provisioned (federation epoch self-healing). The server reads it via the cached `getInstanceId()` in `utils/federationEpoch.ts`, which throws if the epoch is unset (invariant: `ensureDefaults` runs before any read).
Registration resolution order: `instance_settings.registrationOpen` (if not null) > `config.registrationOpen` (from `REGISTRATION_OPEN` env, default true).
`federatedRegistrationOpen` is consumed by the Connections UI (client-federation.md) to decide whether to surface the "create federated account on this instance" affordance.