managarten/services/mana-auth
Till JS 3df7391905 feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up)
Symmetrically extends the F4 server-side singleton bootstrap to the
per-Space `kontextDoc`. Every Space-creation — Personal at signup and
brand/club/family/team/practice via the org plugin — now writes an empty
kontextDoc row straight into mana_sync.sync_changes with origin='system',
client_id='system:bootstrap'. Fresh clients pull the row instead of
racing on a local insert that the next pull would clobber.

- New `bootstrapSpaceSingletons(spaceId, ownerUserId, syncSql)` in
  services/mana-auth/src/services/bootstrap-singletons.ts; shared
  `buildFieldMeta` helper extracted.
- `createBetterAuth(databaseUrl, syncDatabaseUrl, webauthn)` now takes
  the sync-DB URL and lazy-creates a module-scoped postgres pool for
  the bootstrap inserts.
- Hook into `databaseHooks.user.create.after` (only on `created: true`
  from createPersonalSpaceFor) and `organizationHooks.afterCreateOrganization`.
- Webapp `kontextStore.ensureDoc()` made private as `getOrCreateLocalDoc()` —
  same fallback role as userContextStore's after F5. Public API is now just
  setContent + appendContent.

Plan: docs/plans/sync-field-meta-overhaul.md (F4-fu row in Shipping Log).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 01:21:31 +02:00
..
sql feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
src feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up) 2026-04-27 01:21:31 +02:00
CLAUDE.md docs(local-dev): document setup-dev-user + the three founder accounts 2026-04-09 12:26:37 +02:00
Dockerfile fix(infra): include shared-types in mana-auth Dockerfile installer 2026-04-23 02:31:20 +02:00
drizzle.config.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
package.json feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
tsconfig.json feat(services): create mana-auth (Hono + Bun) — Phase 5 auth rewrite 2026-03-28 02:43:44 +01:00