Introduce pond-scoped hierarchical labels as the foundation for M4
organization and, later, M5 label-scoped permissions.
- shared: `labels.ts` with the label schemas/views and the pure tree
helpers (buildLabelTree, collectSubtreeIds, collectAncestorIds,
labelDepth, subtreeHeight). These are the single hierarchy walk the
label API and the future permission resolver both build on
(permissions.md: a grant on a label applies to all its descendants).
- prisma: `Label` (self-referential parent_id, unique per (pond, parent,
name), cascade to subtree) and `PageLabel` assignment table; migration.
- api: `LabelsService` + controller. Tree endpoint returns the hierarchy
in one call; create/rename/recolor/move/delete and page assign/unassign.
Validation: cycle prevention on move, depth limit 6, unique name per
(pond, parent) — enforced under a per-pond advisory lock so root-label
uniqueness holds despite Postgres treating NULL parents as distinct.
Delete cascades the subtree and requires `?force=true` when pages are
assigned. Assignment rejects labels from a different pond. Access gated
through InterimAccessService on the owning pond.
- i18n: label error codes and the colour validation message (de + en).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PGdhRiwU1WRL4XxJfZYipY