Per-user preferences (locale now; timezone/notifications later) keyed to auth users. Typed, FK-backed; the single source for resolve_locale.
| Tier | identity |
| Role | unclassified (baselined) |
| Path | crates/identity/user-prefs |
| Edition | 2021 |
| Targets | identity_user_prefs, integration_tests |
| Public items | 0 across 0 modules |
| Tests | 24 |
What it is for
identity-user-prefs — per-user preferences keyed 1:1 to an auth user.
Owns the user_preferences table (typed, FK'd to auth.users) and the canonical resolve_locale helper. Holds the user-adjustable settings that follow the user (locale now; timezone / notifications later).
# Why a dedicated library crate (and not infrastructure-preferences) The generic infrastructure-preferences K/V store (scope/namespace/key/JSONB) can hold a per-user value but cannot express a typed locale column, an FK to users, or supported-set validation as a boundary invariant. Auth owns identity, not user-adjustable settings (Gate-1.5 consensus). So per-user identity-adjacent prefs live here, typed and FK-backed.
# The single locale source Every locale-aware surface calls resolve_locale rather than reading the column directly, so precedence (user pref → tenant/site default → framework fallback) lives in one place and Forge never hardcodes a default language.
Capabilities
No public items.
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
Locale | foundation_i18n::Locale |
LocaleSettings | state::LocaleSettings |
SupportedLocales | supported::SupportedLocales |
resolve_locale | resolve::resolve_locale |
{Theme,UserPreferences} | model::{Theme,UserPreferences} |
{UserPrefsError,UserPrefsResult} | error::{UserPrefsError,UserPrefsResult} |
{get_locale,get_or_create_default,set_locale,set_theme} | repo::{get_locale,get_or_create_default,set_locale,set_theme} |
Boundary
Reaches into foundation.
Shares tier identity with 7 other crates: identity-auth, identity-identifiers, identity-impersonation, identity-parties, identity-party-places, identity-rbac, identity-tenant.
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | identity |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/identity/user-prefs |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_identity["identity"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-i18n` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
dotenvy | ^0.15 | — | no | always |
tokio | ^1 | full, rt-multi-thread, macros | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_auth["application-auth"] -->|uses| SELF SELF["identity-user-prefs"] SELF -->|runtime| n_foundation_i18n["foundation-i18n"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
postgres | — | no |
flowchart LR n_postgres["postgres"]
Targets
| Kind | Name | Source |
|---|---|---|
| lib | identity_user_prefs | `src/lib.rs` |
| test | integration_tests | `tests/integration_tests.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | yes |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-auth.
Verification
| Kind | Count |
|---|---|
| Unit tests | 16 |
| Integration tests | 8 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
get_or_create_default_is_lazy_and_idempotent—tests/integration_tests.rslocale_and_theme_persist_independently—tests/integration_tests.rsper_user_isolation_one_users_locale_does_not_affect_another—tests/integration_tests.rsprefs_row_cascades_on_user_delete—tests/integration_tests.rsset_locale_rejects_unsupported—tests/integration_tests.rsset_locale_upserts_and_normalizes—tests/integration_tests.rstheme_defaults_to_system_and_round_trips—tests/integration_tests.rstheme_deny_rejects_bad_value_and_does_not_persist—tests/integration_tests.rsresolve_canonicalizes_casing—src/lib.rsresolve_falls_through_to_framework_fallback_when_no_pref_or_tenant—src/lib.rsresolve_falls_through_to_tenant_default_when_no_user_pref—src/lib.rsresolve_no_hardcoded_es_framework_default—src/lib.rsresolve_prefers_user_pref—src/lib.rsresolve_returns_fallback_even_if_set_is_empty—src/lib.rsresolve_skips_unsupported_user_and_tenant_and_uses_framework—src/lib.rsresolve_skips_unsupported_user_pref_and_uses_tenant—src/lib.rssupported_normalizes_and_matches_case_insensitively—src/lib.rssupported_region_variants_are_distinct_from_base—src/lib.rssupported_rejects_unknown_and_garbage—src/lib.rssupported_skips_unparseable_config_tags—src/lib.rsas_str_round_trips_through_parse—src/model.rsdefault_is_system—src/model.rsparse_accepts_the_canonical_set—src/model.rsparse_rejects_out_of_set_and_casing—src/model.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 7 |
| Source lines | 603 |
| Code lines | 338 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 24 |
| Examples | 0 |
| Cargo features | 1 |
| Direct runtime dependencies | 7 |
| Workspace reverse dependencies | 1 |
pie showData
title Rust source composition
"Code" : 338
"Blank or comment" : 265
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.