managarten/packages
Till JS cb9a9bb42e refactor(profile,tool-registry): flip meImages from user-scoped to space-scoped (v40)
Flips `meImages` out of USER_LEVEL_TABLES so it lives under the same
tenancy model as every other data table (tags, scenes, tasks, …).
Precursor to the Wardrobe module, which is space-scoped across all
six space types — leaving meImages user-global would leave an
inconsistency where the Wardrobe catalog is per-space but its
reference input is cross-space, plus a latent privacy leak in shared
spaces (agents in a brand-space would see the owner's entire pool).

Plan: docs/plans/me-images-space-scope-migration.md.

Key decisions:

- Strict scope, no cross-space fallback. Switching into a brand-space
  with no uploaded face shows an empty state and links back to
  /profile/me-images; it does not quietly reach into the personal-
  space pool. Keeps the mental model clean.
- auth.users.image remains pinned to personal-space primary-avatar.
  Only a primary change inside personal space triggers the Better
  Auth sync; brand/club/family/team/practice primaries stay local.
- Single Dexie v40 upgrade: stamps `spaceId=_personal:<uid>`
  sentinel, `authorId=<uid>`, `visibility='space'` on every existing
  row and drops the legacy `userId` column. Dexie upgrades block app
  startup, so by the time the new code's scopedForModule reads run,
  every row is already space-stamped. reconcileSentinels() on the
  next active-space bootstrap rewrites `_personal:<uid>` to the real
  personal-space id, same path v28 used.
- Legacy-avatar migration (M2.5) now pins its row to
  `_personal:<uid>` explicitly — the legacy avatar is the user's
  global SSO identity and belongs in the personal space even if the
  migration happens to fire while the user is in a brand space.

Code changes:

- types.ts: LocalMeImage gains spaceId/authorId/visibility (all
  optional — stamped by hook). Public MeImage exposes spaceId for
  queries that want to branch on space type.
- database.ts: meImages out of USER_LEVEL_TABLES; new v40 upgrade
  block that stamps sentinels + drops userId in one pass.
- queries.ts: all four hooks (useAllMeImages, useMeImagesByKind,
  useReferenceImages, useImageByPrimary) read via scopedForModule.
  Scope-switch triggers automatic re-render via the existing
  scopedTable filter path.
- stores/me-images.svelte.ts: setPrimaryInTx uses scopedForModule so
  a setPrimary in Brand-space never clears Personal-space's holder.
  syncAvatarToAuth gates on activeSpace.type==='personal' so non-
  personal primary changes don't leak into Better Auth.
  createMeImage accepts optional spaceId override — the legacy-
  avatar migration uses it, regular uploads let the hook stamp the
  active space.
- migration/legacy-avatar.ts: explicitly passes
  spaceId=_personal:<uid> to pin the legacy row into personal space.
- MeImagesView.svelte: subtle badge in the intro card shows the
  active space ("Persönlich" for personal, space name otherwise) so
  users notice when the pool changes on space switch.
- packages/mana-tool-registry/src/modules/me.ts: me.listReferenceImages
  filters pulled rows by row.spaceId === ctx.spaceId. mana-sync
  returns all spaces the user belongs to; the tool only wants the
  active space's subset.

No schema/index change on meImages (non-indexed fields, pool size
small enough for in-memory scopedTable filter). If perf matters
later, adding [spaceId+kind] is a 5-minute follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 18:09:57 +02:00
..
credits fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
eslint-config fix(timeblocks): type errors from recurrence migration 2026-04-07 13:22:59 +02:00
feedback fix(packages): cross-package broken imports + missing exports 2026-04-09 20:23:34 +02:00
help refactor: rename planta → plants, clean up codebase 2026-04-12 18:59:44 +02:00
local-llm fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
local-store fix(mana/web): sprint 2 — auth-aware data layer + guest migration 2026-04-07 13:07:12 +02:00
local-stt fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
mana-tool-registry refactor(profile,tool-registry): flip meImages from user-scoped to space-scoped (v40) 2026-04-23 18:09:57 +02:00
notify-client chore(matrix): final scrub of stale matrix references 2026-04-08 16:47:54 +02:00
qr-export chore(workspace): unify vitest to ^4.1.2 across all packages 2026-04-07 13:58:29 +02:00
shared-ai feat(agent-loop): expose compactionsDone + compactedReminder producer 2026-04-23 15:36:21 +02:00
shared-auth feat(broadcast): M2 audience + editor + compose wizard 2026-04-20 20:41:09 +02:00
shared-auth-ui chore: final cleanup — dead link, security status, showTitle, drop subscriptions 2026-04-16 14:27:46 +02:00
shared-branding feat(webapp): wire isParallelSafe in Companion chat + Mission runner 2026-04-23 14:11:24 +02:00
shared-crypto feat(mcp): M1+M1.5 MCP gateway + tool-registry + shared-crypto 2026-04-23 13:18:35 +02:00
shared-drizzle-config feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-error-tracking feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-go chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-hono fix(type-check): clear the last five failures — monorepo type-check is now 76/76 green 2026-04-20 15:53:07 +02:00
shared-i18n chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-icons perf(shared-icons): mark package as side-effect-free for tree-shaking 2026-04-14 17:16:19 +02:00
shared-landing-ui refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-links refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-llm fix(type-check): unblock two more pre-existing failures 2026-04-20 15:20:08 +02:00
shared-logger fix(type-check): clear the last five failures — monorepo type-check is now 76/76 green 2026-04-20 15:53:07 +02:00
shared-pwa feat(articles): M7 share-target + bookmarklet — save from anywhere 2026-04-21 19:03:33 +02:00
shared-python/manacore_auth feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-research feat(mana-research): add Gemini 3.1 Pro Deep Research async providers 2026-04-22 17:55:30 +02:00
shared-rss refactor(shared-rss): extract RSS parsing + Readability into one package 2026-04-15 22:30:44 +02:00
shared-storage chore(ci): add v8 test coverage tracking (non-blocking baseline) 2026-04-19 19:21:14 +02:00
shared-stores fix(ai): P1 batch — N+1 queries, vault-locked, debug hardening, timeout 2026-04-16 16:25:17 +02:00
shared-tags chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-tailwind refactor(theming): migrate who semantic colours to theme tokens 2026-04-22 17:19:53 +02:00
shared-theme refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-theme-ui feat(web): wallpaper system + sticky PageHeader 2026-04-12 16:00:03 +02:00
shared-types feat(webapp): wire isParallelSafe in Companion chat + Mission runner 2026-04-23 14:11:24 +02:00
shared-ui feat(pill-nav): show Anmelden pill for guests next to menu icon 2026-04-23 15:36:09 +02:00
shared-uload fix(packages): modal keydown handlers, $derived.by usage, UserData fields 2026-04-09 20:24:05 +02:00
shared-utils refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-vite-config chore(packages): remove 4 dead zero-consumer packages 2026-04-09 11:56:25 +02:00
spiral-db refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
test-config fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
wallpaper-generator fix(a11y): replace 215 suppression comments with real fixes 2026-04-10 22:43:05 +02:00
website-blocks feat(website): M4 — forms + moduleEmbed 2026-04-23 14:36:52 +02:00