managarten/services/mana-auth/src/services
Till JS 099cac4a01 feat(auth): explicit bootstrap-singletons endpoint + idempotent functions (F4 robust)
The F4 server-side singleton bootstrap was fire-and-forget at signup
time — a transient mana_sync outage during registration would leave the
user with no singleton and only the in-store `getOrCreateLocalDoc()`
fallback to race on the first write. The signup-hook is still the
happy-path zero-latency bootstrap; this commit adds a deliberate
reconciliation path that converges on every boot.

- Idempotent `bootstrapUserSingletons` / `bootstrapSpaceSingletons`:
  both functions now existence-check sync_changes before INSERT and
  return boolean (true=inserted, false=skipped).
- New endpoint `POST /api/v1/me/bootstrap-singletons` — JWT-gated under
  the existing `/api/v1/me/*` prefix. Provisions the caller's
  userContext and the kontextDoc for every Space they're a member of.
  Returns `{ ok, bootstrapped: { userContext, spaces: { id: bool } } }`.
- Webapp `(app)/+layout.svelte` calls the endpoint once per
  authenticated boot, after `restoreClientIdFromDexie()` and before
  `createUnifiedSync.startAll()`. Best-effort; failures swallow into a
  console warning and the in-store fallback still covers the rare
  race window.

Plan: docs/plans/sync-field-meta-overhaul.md (F4-robust row).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 01:38:14 +02:00
..
encryption-vault feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
api-keys.ts feat(mana-auth): add guilds, api-keys, me, security, auth routes 2026-03-28 02:57:22 +01:00
bootstrap-singletons.ts feat(auth): explicit bootstrap-singletons endpoint + idempotent functions (F4 robust) 2026-04-27 01:38:14 +02:00
passkey-rate-limit.spec.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
passkey-rate-limit.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
security.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
signup-limit.ts feat: GPU offload, signup limit, load tests & capacity planning 2026-03-28 21:14:24 +01:00
user-data.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00