| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
preferHighestValueFor picks the numerically highest value across upstreams for configured methods/fields, gated only by agreementThreshold. A single upstream returning an outlier (stale cache, corrupted state, bug) can still win outright as long as it independently satisfies the threshold. Add an opt-in, per-method PreferHighestValueForMaxDeviationPct config that filters out candidate values straying more than N percent from the median of all threshold-qualifying candidates before picking the highest survivor. Unset (default) keeps existing behavior byte-for-byte unchanged.
|
This looks like a really clever way to handle outliers! 🤓 Carefully crafted by Subweave · 🧶 used ~590k LLM tokens |
Sorry, something went wrong.
…n-finite pct, document config Address review findings on the bounded-deviation check: - rules.go: the median for preferHighestValueForMaxDeviationPct was computed from one value per distinct candidate group, ignoring how many upstreams voted for it. For [5, 5, 500] with threshold=1, that took the median of [5, 500] and rejected both as outliers instead of keeping the 2-vote majority. Weight the median by each candidate's agreement count instead. - validation.go: reject NaN/+-Inf for preferHighestValueForMaxDeviationPct. NaN silently disabled filtering (NaN comparisons are always false); +Inf reached big.Rat.SetFloat64, which returns nil for non-finite input, causing a nil-pointer panic in the analyzer. - docs: document preferHighestValueForMaxDeviationPct in the consensus config reference. - tests: regression case for the majority-vs-outlier median weighting, and validation tests for NaN/Inf/negative/missing-pair rejection.
| Back | FazBrowse Home | New Git URL |
Problem
preferHighestValueFor picks the numerically highest value across upstreams for configured methods/fields, gated only by agreementThreshold (how many upstreams must report the same value). It has no check on how far a value sits from the rest of the pack: one upstream returning a wildly larger number (stale cache, corrupted state, bug) can win outright as long as it independently satisfies agreementThreshold — even with agreementThreshold: 1, unconditionally.
Change
Adds an opt-in, per-method preferHighestValueForMaxDeviationPct config. Before picking the highest value among threshold-qualifying candidates, candidates whose primary field deviates from the median of the other qualifying candidates by more than the configured percent are filtered out first.
Testing
Scope
This is intentionally the smaller of two approaches considered for guarding preferHighestValueFor against outliers: it keeps the existing design of trusting multiple upstreams' own reported values (rather than collapsing to a single source of truth) and makes no client-facing response-contract change. A distinct "flag without rejecting" mode was considered and dropped — flagging with no enforcement had no forcing use case, and rejection is already observable via the debug log line.