Expand description
Field classification + filter inference (renamed from
intelligence per Section 4 of the strategic reset plan).
Pure helpers that turn schema metadata into user-facing hints:
the form-field label beside an input, the masked display of a
sensitive value on a list page, the filter dropdown inferred from
a status column. Nothing in this module touches the filesystem,
the database, or produces HTML — it returns structured data that
the admin renderer consumes.
§Public API
classify_field— labels a field by role (Id,Email,Status, …). Every downstream renderer branches on this enum.field_ui_metadata— packages the label, placeholder, hint, and sensitivity marker a form needs to render one input.infer_filters— walks a model’s fields and decides which filters make sense on its list page.format_relation_cell— render a foreign-key cell on the list page asTarget #42(or42when the target name is unknown).mask_pii— deterministic string masker used to hide personal data by default on list views.
Slimmed for Tier 1: the legacy module’s country/industry/GDPR
ContextConfig plumbing was wired through crate::ai (Tier 2) so
it’s been removed; classification is now shape-based only.
classify_search / SearchIntent are dropped per Section 3.
Structs§
- FieldUI
- Everything a form / list renderer needs to present one field to a human. All strings are plain text (no HTML) — the caller escapes before emitting.
- Filter
Def - One filter the list page should show for a model.
Enums§
- Field
Role - The role a field plays in the admin UI. One field maps to exactly
one role; the ordering of branches in
classify_fieldresolves overlaps (e.g. anemailcolumn isFieldRole::Email, notFieldRole::PlainText). - Filter
Kind - What shape of filter the admin list page should render for a given field.
Functions§
- classify_
field - Assign a
FieldRoleto one field. - field_
ui_ metadata - Package a field’s display metadata for the admin form / list renderers. All strings are plain text — escape before emitting.
- field_
ui_ metadata_ with_ relation - Like
field_ui_metadatabut relation-aware. Pass the singular display name of the target model when the schema records a relation for this field; the returnedFieldUIthen carriesrelation_labeland a hint of the form “Foreign key to Target”. - format_
relation_ cell - Render “Target #42” for a foreign-key cell on a list view. Falls back to the raw id when the caller doesn’t have a target name.
- infer_
filters - Infer the filter controls for a model’s list page from its fields.
Order follows the order of
fields; every filter references a field that actually exists on the model. - infer_
filters_ with_ registry - Like
infer_filters_with_relationsbut consults thesuper::relations::RelationRegistryso FK fields can be promoted toFilterKind::FkAutocomplete— the registry carries the target’s admin slug, which the autocomplete endpoint URL depends on. - infer_
filters_ with_ relations - Like
infer_filtersbut invokesrelation_target_offor each field to detect relation columns. If the callback returnsSome(target), the filter is emitted asFilterKind::RelationSelectinstead of the numeric-exact fallback. - mask_
pii - Produce a masked display string for a sensitive value. Keeps the
first few characters so a reviewer can tell which row they’re
looking at, replaces the rest with
•. Length of the output matches the input. Deterministic, Unicode-safe.