Skip to content

fix(engine): backport reviewer-consensus-calibration.ts's zero-weight and malformed-repo handling to its two older siblings #6170

Description

@JSONbored

Context

packages/loopover-engine/src has three sibling calibration modules (gate-verdict-calibration.ts, finding-severity-calibration.ts, reviewer-consensus-calibration.ts) that share a composite-scorer weight-resolution pattern. The newest, reviewer-consensus-calibration.ts, has two behaviors its two older siblings never got backported:

  1. Zero-weight handling (reviewer-consensus-calibration.ts:402-405 vs gate-verdict-calibration.ts:317-318 and finding-severity-calibration.ts:365-366): both older files do if (total <= 0) return DEFAULT_COMPOSITE_WEIGHTS;, silently restoring the 45/35/20 blend when a caller explicitly passes all-zero weights. reviewer-consensus-calibration.ts instead returns the explicit zeroed weights, with a comment: "a caller that zeroes every component must reach the objective-only fallback ... not silently get the default 45/35/20 blend." test/reviewer-consensus-calibration.test.ts:291 has a dedicated test for this; the other two have no equivalent test.

  2. Malformed-repo preservation (gate-verdict-calibration.ts:286 vs finding-severity-calibration.ts:331-334 and reviewer-consensus-calibration.ts:368-371): gate-verdict-calibration.ts's sanitizer uses normalizeRepoFullName(row.repoFullName) alone (returns null, dropping the row) for already-rejected audit rows; both siblings use normalizeRepoFullName(...) ?? normalizeId(...) to preserve the raw string instead. test/reviewer-consensus-calibration.test.ts:353,385 tests an invalid_repo rejected row surviving sanitization; test/gate-verdict-calibration.test.ts:478 only exercises a valid repo.

Requirements

  • In gate-verdict-calibration.ts and finding-severity-calibration.ts, change the zero-weight branch to return the explicit zeroed weights (matching reviewer-consensus-calibration.ts:402-405's behavior), not the silent DEFAULT_COMPOSITE_WEIGHTS fallback.
  • In gate-verdict-calibration.ts, change the sanitizer to use normalizeRepoFullName(...) ?? normalizeId(...) (matching the other two files), so a malformed-repo rejected row is preserved instead of dropped.
  • Do not change reviewer-consensus-calibration.ts — it's already correct and is the reference implementation for both fixes.

Test Coverage Requirements

99%+ Codecov patch coverage on both changed branches in both files; add the equivalent tests reviewer-consensus-calibration.test.ts already has (zero-weight explicit-fallback test, and an invalid_repo rejected-row-survives-sanitization test) to test/gate-verdict-calibration.test.ts and test/finding-severity-calibration.test.ts.

Deliverables

  • gate-verdict-calibration.ts: zero-weight fix + malformed-repo fix, both with regression tests.
  • finding-severity-calibration.ts: zero-weight fix, with regression test.

Expected Outcome

All three sibling calibration modules handle all-zero weights and malformed-repo rejected rows identically, instead of two of them silently diverging from the newest/correct one.

Links & Resources

  • packages/loopover-engine/src/gate-verdict-calibration.ts:286,317-318
  • packages/loopover-engine/src/finding-severity-calibration.ts:331-334,365-366
  • packages/loopover-engine/src/reviewer-consensus-calibration.ts:368-371,402-405 (reference implementation)
  • test/reviewer-consensus-calibration.test.ts:291,353,385 (reference tests)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions