🔧 chore: give ResolvedTenant its core home and make constant.rs a leaf
Two structural defects a knowledge-graph pass over src/+tests/+migrations
surfaced. Both were verified against the real `use` lines before being called
defects — a module cycle is legal Rust, so only the layering facts count.
No behavior change: every moved item is byte-identical in name, type, value,
element order and doc text.
- `ResolvedTenant` was *declared* in `src/web/tenant_state.rs` but *built and
returned* by `Tenants::resolve` (`src/tenant.rs`), so the core tenant
registry imported the web layer. The struct moves to `src/tenant.rs`; its
`impl FromRequestParts` stays in the web module (same crate, local type).
That deletes the crate's only core→web import edge, and with it the three
module cycles running through `state.rs` and `ai::server`.
- `constant.rs` is documented "Validation limits, in one place" but imported
four domain enums to hold non-limit vocabularies: `ROLES` → `domain/role.rs`,
`THEMES`/`LANGUAGES` → `domain/preferences.rs`, `SENDER_FOLDERS`/
`RECIPIENT_FOLDERS` → `domain/message.rs`, and the 34-row `BADGES` catalogue
→ `domain/badge.rs`. Each now lives in the module that owns its type, so
`constant.rs` imports nothing from `crate::domain` and ten
`constant ↔ domain` cycles disappear. `AI_PRINCIPAL_KEY` and
`PALETTE_COLOR_*` stayed put.
Measured on the same corpus: 20 → 7 reported import cycles — all ten
constant↔domain and all three tenant↔web cycles gone. The surviving seven are
intra-layer domain cycles plus the ai↔web pair; the AI bridge is a peer
front-end reusing web authorization helpers, which is deliberate, not an
inversion.
Tests: the published-or-excluded guard in `limits_completeness` read only
`src/constant.rs`, so the five moved tables silently left its scan — the one
place this move weakened coverage. It now covers them by name, and its
`references()` check no longer counts a bare `use` line as "published", which
the first witness attempt proved had made the guard vacuous. Witnessed by
mutating BADGES and then ROLES out of `/limits`: each FAILs naming the moved
table, and each restore is sha256-identical.
Gates: no SQL touched (.sqlx and migrations clean), prepare DB unchanged;
SQLX_OFFLINE=true cargo check --all-targets, clippy -D warnings,
limits_completeness, spec_bounds all green; cargo nextest run 1386/1386 across
47 binaries (doc_sync included).