managarten/services/mana-auth/src
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
..
auth feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up) 2026-04-27 01:21:31 +02:00
db feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
email feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
lib feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
middleware refactor(shared-tailwind): rewrite themes.css to single-layer shadcn convention 2026-04-09 01:13:06 +02:00
routes feat(auth): explicit bootstrap-singletons endpoint + idempotent functions (F4 robust) 2026-04-27 01:38:14 +02:00
services feat(auth): explicit bootstrap-singletons endpoint + idempotent functions (F4 robust) 2026-04-27 01:38:14 +02:00
spaces feat(spaces): move access tier from user to space 2026-04-20 20:10:06 +02:00
config.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
index.ts feat(auth): explicit bootstrap-singletons endpoint + idempotent functions (F4 robust) 2026-04-27 01:38:14 +02:00