Skip to content

Display labels for computed scoring variables#172

Merged
ccomb merged 6 commits into
mainfrom
etf_ui
Jul 2, 2026
Merged

Display labels for computed scoring variables#172
ccomb merged 6 commits into
mainfrom
etf_ui

Conversation

@ccomb

@ccomb ccomb commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Scoring-set breakdowns resolve each indicator's display name through the variables map (var → impact category). Computed variables live in computed, not variables, so their raw TOML key (e.g. etf) leaked into /impacts responses and every consumer UI instead of a human-readable name.

This adds an optional [methods.scoring.labels] table to scoring-set config:

[methods.scoring.computed]
etf = "2 * etfo + etfi"

[methods.scoring.labels]
etf = "Ecotoxicity, freshwater"

Name resolution is now labels → variables → raw key. list_scoring_sets exposes the labels so clients can render them too. A label naming an unknown scoring variable (a typo like eft) is rejected at config load instead of being silently ignored. Covered by ScoringLabelSpec and ConfigSpec.

ccomb added 6 commits July 2, 2026 20:25
Scoring breakdowns resolved indicator names only through the variables
map, so computed variables (e.g. a freshwater-ecotoxicity aggregate
rebuilt from its organics/inorganics parts) leaked their raw TOML key
into API responses and the UI.

Add an optional [methods.scoring.labels] table (var -> display label);
name resolution now checks labels, then variables, then falls back to
the key. Labels are also exposed in list_scoring_sets.
A [methods.scoring.labels] key that matches no computed or primitive
variable was parsed and then silently never displayed, so a config typo
(e.g. 'eft' for 'etf') left the raw key leaking into breakdowns with no
signal. The decoder now fails with the offending key names, surfacing
the mistake at config load instead of hiding it.
The nested findWithDefault encoded the labels → variables → raw-key
precedence in argument position, where a swapped argument would still
type-check. A single lookup in ssLabels <> ssVariables states the same
priority left-to-right, matching the identity-default idiom used
elsewhere. The spec now also covers the raw-key fallback its docstring
already promised, and uses a neutral scoring-set name.
score_activities summary mode emitted only the raw variable key in
dominant_indicator, so clients showed an opaque key (e.g. 'etf') for
the very field meant for human triage — while score_activity's
breakdown now resolves display labels. Carry the indicator's display
name alongside the key; it was already in hand via siCategory.
The list_scoring_sets tool description now names the labels key it
returns, the pyvolca ScoringIndicator docstring no longer claims
category is always an impact category (README regenerated), and the
changelog gains an entry for the feature.
@ccomb ccomb merged commit 85d817d into main Jul 2, 2026
10 checks passed
@ccomb ccomb deleted the etf_ui branch July 2, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant