Fail loud on scoring integrity errors instead of scoring 0 - #214
Merged
Conversation
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.
Owner
Author
|
Suite de revue — deux correctifs poussés :
Suite complète verte en local (1552 exemples). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
computeRegionalizedLCIAScorereserves itsLeftfor genuine integrity errors — mismatched table lengths, absent weights — never for coverage gaps. Yet every consumer collapsed thatLeftto 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
Eithernow 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 inresolveBatchedScore(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.