6.8 KiB
Heimdall Verse Service Contract
Heimdall is the shared auth authority for GameCult-hosted experiments. It owns auth/control-plane truth: provider OAuth, linked identities, grants, entitlements, sessions, managed provider credential custody, app-facing claims, and audit records.
Heimdall must not become the shared app-data swamp. App-domain state stays with the app that owns the consequence. Heimdall owns authentication and authorization evidence only.
Owner Map
- Owner: Heimdall owns provider identity/linking, signed session and claim issuance, entitlement refresh, managed provider token custody, grants, auth-completion handoffs, refresh sessions, and audit events.
- Inputs: provider OAuth callbacks, app profile requests, caller-supplied entitlement policy, provider API responses, configured signing/encryption keys, app backend callback receipts, and local Postgres/in-memory store records.
- Outputs: signed access claims, refresh claims, JWKS, discovery documents, backend handoff payloads, managed credential projections, audit records, and app-local verification material.
- Derived state: health/discovery/JWKS responses, browser completion pages, app-profile docs, and public status checks are projections. They do not own auth truth.
- Forbidden writers: app backends, dashboards, browser callback pages, Eve/TUI renderers, and Odin probes must not mutate Heimdall auth truth except through explicit Heimdall API command boundaries.
- Shared paths: local dev memory store, deployed Postgres store, future
CultCache
.ccwitness/export, Odin discovery, and Eve operator surface must describe the same auth/control-plane facts. - Deletion line: any app-specific access rule that outgrows a thin app profile must move back to the app. Heimdall should not absorb product state to make a dashboard easier.
CultCache Requirement
Heimdall currently has durable Postgres storage for deployed auth/control-plane state. That is acceptable for live auth operations, but it is not enough for the GameCult Verse service contract by itself.
The next state cut is a CultCache .cc witness/export path for Heimdall-owned
auth/control-plane documents:
heimdall.account.v0heimdall.linked_identity.v0heimdall.session.v0heimdall.grant.v0heimdall.entitlement_snapshot.v0heimdall.auth_completion.v0heimdall.audit_event.v0heimdall.app_profile.v0heimdall.managed_credential_projection.v0
The .cc store does not need to replace Postgres in the first pass. The first
pass should export a typed, redacted, operator-safe witness of Heimdall state so
CultMesh/Odin/Eve can inspect service truth without receiving provider secrets.
Sensitive fields must be handled explicitly:
- provider access and refresh tokens stay sealed server-side;
- exported linked identity records carry provider, provider subject, scopes, expiry, and custody status, not raw tokens;
- audit payloads must redact provider tokens, secrets, callback codes, and private user data that is not needed for service operation;
- app-domain data stays out of Heimdall exports.
Eve Surface Target
Heimdall should publish an Eve GUI/TUI DSL operator surface with these panels:
Authority: public base URL, service name, storage backend, signing key id, JWKS freshness, token custody source, deployment host.Providers: configured providers, callback readiness, scope policy, refresh support, and last provider error without secrets.Apps: app profiles, allowed providers, entitlement sources, handoff modes, claim audiences, and app-owned policy boundaries.Sessions And Grants: counts and freshness for active sessions, grants, entitlement snapshots, refreshes, and completion handoffs.Audit: recent redacted auth events, failed callback reasons, backend handoff failures, and stale provider-token custody.
Eve must send command intent only for explicit operator actions, such as rotating a configured key, disabling a provider, revoking a session, or refreshing an entitlement snapshot. Heimdall accepts or denies those actions.
Migration Order
- Define Heimdall CultCache document shapes for redacted auth/control-plane witness state.
- Add a read-only export command from the current store into a
.ccwitness. - Publish the witness through CultMesh with secret-safe projections only.
- Add an Eve DSL provider over the witness and existing health/discovery data.
- Register Heimdall's provider surface with Odin.
- Only after the witness path is stable, decide whether any live state should move from Postgres into a CultCache-backed primary store.
The invariant: Heimdall owns shared auth truth, not app-domain truth. CultCache and CultMesh make Heimdall inspectable; they do not leak secrets or move product state into the auth authority.
Read-Only Witness First Cut
The current repo cut defines the read-only witness/ad surface without wiring a runtime writer or migrating live state.
Authority map:
- Owner: Heimdall remains the only owner of auth/control-plane mutation.
- Inputs: static provider catalog, static app profiles, and the redacted witness
descriptor table in
src/verse-witness.ts. - Outputs:
gamecult.eve.provider_advertisement.v1JSON printed bypnpm export:provider-advertisement. - Derived state: advertised CultCache paths and schema IDs are witness/export
targets. They do not prove that a live
.ccwriter exists yet. - Forbidden writers: Odin probes, Eve renderers, dashboards, and this export command cannot mutate accounts, linked identities, grants, sessions, tokens, completions, entitlements, audit events, or app profiles.
- Shared paths: future CultCache export, CultMesh publication, and Eve lowering should reuse the same document IDs and redaction doctrine.
- Deletion line: if a future writer needs app-domain fields or provider tokens to make the surface useful, the design is wrong; keep those fields out or move the concern back to the owning app/service.
The advertised witness descriptors currently name these redacted .cc targets:
heimdall.account.v0atcultcache/heimdall/accounts/{accountId}.ccheimdall.linked_identity.v0atcultcache/heimdall/linked-identities/{provider}/{providerUserId}.ccheimdall.capability_grant.v0atcultcache/heimdall/grants/{grantId}.ccheimdall.session.v0atcultcache/heimdall/sessions/{sessionId}.ccheimdall.entitlement_snapshot.v0atcultcache/heimdall/entitlements/{accountId}/{provider}/{scope}.ccheimdall.auth_completion.v0atcultcache/heimdall/auth-completions/{completionCodeHash}.ccheimdall.audit_event.v0atcultcache/heimdall/audit/{eventId}.ccheimdall.app_profile.v0atcultcache/heimdall/app-profiles/{appSlug}.ccheimdall.managed_credential_projection.v0atcultcache/heimdall/managed-credentials/{appSlug}/{accountId}/{provider}.cc