Skip to content

Fail loud on scoring integrity errors instead of scoring 0 - #214

Merged
ccomb merged 5 commits into
mainfrom
loud-tainted-scores
Jul 15, 2026
Merged

Fail loud on scoring integrity errors instead of scoring 0#214
ccomb merged 5 commits into
mainfrom
loud-tainted-scores

Conversation

@ccomb

@ccomb ccomb commented Jul 14, 2026

Copy link
Copy Markdown
Owner

computeRegionalizedLCIAScore reserves its Left for genuine integrity errors — mismatched table lengths, absent weights — never for coverage gaps. Yet every consumer collapsed that Left to a score of 0 with only a server-side log line, so the API answered a plausible number the consumer could not tell from a real score: a silent undercount, the exact failure mode the engineering rules forbid.

The Either now travels to the handlers. Single-method, batch and multi-activity scoring answer 500 with the error text; sensitivity keeps partial results by putting the error on the affected perturbation entry, which already carries per-entry errors on the wire. The shared resolution lives in resolveBatchedScore (spec-covered), which also turns "method missing from the batched score set" — impossible by construction, silently 0 before — into an error.

Coverage gaps are unaffected: an unmapped flow still contributes nothing and is reported through the existing warning and mapping-stats channels.

ccomb added 3 commits July 15, 2026 00:05
computeRegionalizedLCIAScore reserves its Left for genuine integrity
errors — mismatched table lengths, absent weights — never for coverage
gaps. Yet every consumer collapsed that Left to a score of 0 with only
a server-side log line, so the API answered a plausible number the
consumer could not tell from a real score: a silent undercount.

The Either now travels to the handlers. Single-method, batch and
multi-activity scoring answer 500 with the error text; sensitivity
keeps partial results by putting the error on the affected perturbation
entry, which already carries per-entry errors. The shared resolution
lives in resolveBatchedScore, which also turns "method missing from
the batched score set" — impossible by construction, silently 0 before
— into an error.
The cross-DB regional sum only failed when every participating database
hit an integrity error; a mixed outcome dropped the broken database to a
0 contribution and returned Right — the silently undercounted total this
branch exists to eliminate. Coverage gaps are unaffected: tainted
columns still contribute 0 inside a Right (the existing specs pin that).

Two stale spec comments described the old tolerated-Left behavior;
the assertions themselves were already compatible with the new
semantics.
The batch path labeled twice: resolveBatchedScore prefixes its Left with
the method name, then computeCategoryResult prefixed again, so the 500
body read '[LCIA X] [LCIA X] ...'. computeCategoryResult now labels only
the score it computes itself; a precomputed Left arrives already
labeled. Also states at the batch sequence why a single integrity error
fails all entries: it is a property of the (db, method) tables, so every
entry would fail identically.
@ccomb

ccomb commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

Suite de revue — deux correctifs poussés :

  • La somme cross-DB propage désormais tout Left par base (sumRegionalizedLCIAScoreCrossDB). Avant, elle n'échouait que si toutes les bases frappaient une erreur d'intégrité : une base dépendante cassée tombait à une contribution 0 sans un log, exactement le sous-comptage silencieux que la PR élimine. Les trous de couverture restent inchangés (colonnes tainted → 0 dans un Right, specs existants conservés). Nouveau spec : une erreur d'intégrité sur la base dépendante fait échouer la somme même quand la racine est saine — l'entrée du CHANGELOG est maintenant vraie sans restriction.
  • Le message d'erreur n'est plus préfixé deux fois : le corps du 500 du chemin batch lisait [LCIA X] [LCIA X] …. computeCategoryResult n'étiquette plus que le score qu'il calcule lui-même. Plus un commentaire au sequence du batch expliquant le tout-ou-rien assumé.

Suite complète verte en local (1552 exemples).

@ccomb
ccomb merged commit b9ba142 into main Jul 15, 2026
9 checks passed
@ccomb
ccomb deleted the loud-tainted-scores branch July 15, 2026 04:18
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