2613 — backend-owned labels for enum-key classification fields¶
Endgame of #2401: after this branch, the frontend renders backend labels for every factor-sourced classification value. The only client-side option labels left are professional-travel cabin classes (static form enums, kept by maintainer decision).
Why now¶
- energy_combustion fuels (
natural_gas, …) were translated ONLY client-side: French filter/sort on the energy table matched English, and English filter didn't even match the displayed label (Natural gasvsnatural_gas). - Five fields had two label sources (backend translation table for matching, frontend i18n for display) — the drift failure mode #2401 exists to kill.
Backend¶
- Seed migration (
seed_enum_label_translations, same pattern as the sius seed3b5609f893f4): en+fr rows for name(energy_combustion fuels ×7, wording fromi18n/buildings.ts),room_type(×6, wording frombuildings-room-type-*),researchfacility_type(fish/rodent),service_type(storage/compute/virtualisation — virtualisation covers legacy entries; the current catalog has no factor for it).- Handlers declare
translated_code_fields: energy_combustion("name",), buildings rooms("energy_type", "room_type"), RF animal("researchfacility_type",), external clouds("service_type",). The repo layer (filter, localized sort, row labels) already handles the shape in every language — no repo change. - Taxonomy builder (
module_handler_service): - fetches translation rows for
translated_code_fieldsin EVERY language (was: onlylang != en), so fuel/room-type nodes carry "Natural gas", not the slug, in English too; - handlers with
kind_field=Noneandtranslated_code_fields(headcount member, planner_headcount) get vocabulary children built from the translation table — the sius dropdown/planner grid label source. - Breakdown enrichment (
enrich_breakdown_with_labels): also consults the translation table in English when the group field is a translated code field (animal-facility bars grouped byresearchfacility_type).
Not seeded (deliberate)¶
process_emissions.category/subcategory: CSV values are real English text — already the self-labeling shape,_frCSV columns cover French. The frontendoptionLabelKeyslugs (co2,refrigerants, …) matched nothing in the current catalog: dead code, deleted.usage_type(external_ai): self-labeling;usage_type_frCSV wording still parked with the maintainer.- Known collision non-risk:
purchases_centralized.kind_field == "name"shares thenamefield namespace with fuels, but a purchase would have to be literally namednatural_gasto collide — accepted.
Frontend¶
optionLabelKeyandoptionLabelPrefixremoved frommoduleConfigand all render paths (ModuleTable, ModuleForm, ModuleInlineSelect, printTable);optionLabelsAreKeyssurvives ONLY for travel cabin classes.- New
optionLabelsFromTaxonomyconfig flag for static-vocab selects whose labels now come from the loaded taxonomy tree: headcountsius_code, buildingsroom_type. Taxonomy label maps flatten kind AND subkind nodes. - All
$te(node.name)/$te(opt.value)fallback branches deleted — nodes rendernode.label, rows render backendlabels. - Planner headcount (rows, print) reads sius labels from the planner_headcount taxonomy vocabulary; the student row keeps its own UI i18n key.
- Deleted:
i18n/headcount_factor.tsand the dead label keys (fuels, room types, RF types, storage/compute/virtualisation, process category slugs).
Delivery checklist¶
- seed migration + handler declarations
- taxonomy builder: en labels + vocabulary children
- breakdown enrichment en path
- backend tests (fuel filter/sort en+fr, taxonomy en labels, member vocab, RF-type breakdown)
- frontend flip + machinery deletion + CT coverage
- lint + type-check green