Skip to content

fix(review): gate the auto-tune breaker on reversal-weighted precision (#2348)#5088

Merged
JSONbored merged 1 commit into
mainfrom
feat/gate-precision-weighted-breaker-2348
Jul 11, 2026
Merged

fix(review): gate the auto-tune breaker on reversal-weighted precision (#2348)#5088
JSONbored merged 1 commit into
mainfrom
feat/gate-precision-weighted-breaker-2348

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • planAutoTune/shouldAutoClear and their close-side mirrors (planCloseAutoTune/shouldAutoClearClose) now gate on GateEvalRow's reversal-discounted weightedMergePrecision/weightedClosePrecision (already computed by parity.ts's computeGateEval, landed in feat(review): discount reverted/reopened outcomes in the gate-eval fold #4169) instead of the raw precision fields — a high volume of later-reverted merges can no longer keep the raw number artificially healthy to dodge the breaker.
  • The raw fields are preserved on AutoTuneAction/CloseAutoTuneAction for log continuity, and both numbers are surfaced in the alert message (weighted merge precision 50% (raw 95%) ...) so an operator can see the gap at a glance.
  • computeTuningRecommendations (the separate advisory-only tuning surface, not "the breaker") is deliberately unchanged — out of this issue's named scope.
  • evalRowFromCalibration (selftune-wire.ts, sourced from agent_recommendation_outcomes) has no reversal signal in its data source, so its weighted fields mirror the raw ones by construction — documented inline.

Closes #2348.

Re-verification of the issue's second downstream consumer (orb collector)

The issue's deliverable 4 names two downstream consumers to re-verify: the auto-tune breaker (this PR) and the orb collector (src/orb/analytics.ts). I checked — the orb collector's foldInstance does not consume parity.ts's GateEvalRow/computeGateEval at all; it folds its own independent mergePrecision directly from fleet-submitted orb_signals cells, and already excludes a reversal_flag !== "reverted" merge from mergeConfirmed (see the field's own doc comment: P(merged & not reverted | gate said merge)). It predates and is structurally separate from this weighted-fold work, and was already reversal-aware by construction. No change needed there.

Scope

Validation

  • npm run typecheck — clean.
  • npm run test:coverage (full unsharded) — src/review/auto-tune.ts 100% lines (83/83) / 100% branches (79/79). src/review/selftune-wire.ts 100% lines (30/30); its one uncovered branch (line 123, isAgentConfigured guard in the pre-existing, untouched selfTuneRepos) is outside this diff — confirmed via raw lcov.info BRDA inspection that both new lines (including the new wouldMerge > 0 ? ... : null ternary) are fully hit.
  • Targeted suites: auto-tune.test.ts + outcomes-wire.test.ts + selftune-wiring.test.ts + selftune-readback.test.ts — 136/136 passing, including new tests proving the actual anti-gaming property (raw precision healthy + weighted precision failing → breaker now engages where it previously wouldn't; and the inverse recovery case for shouldAutoClear/shouldAutoClearClose).
  • npm run test:workers / npm run build:mcp / npm run ui:* — not run locally; no MCP, worker-binding, wrangler, or UI surface touched by this diff (pure src/review/** logic + tests), left to CI per this session's established "typecheck + affected tests locally, trust CI for the rest" practice.
  • npm audit --audit-level=moderate — no dependency changes in this PR.
  • New branches (the ?? raw-precision fallback on both the merge and close side) and the core anti-gaming property have dedicated tests, not just line coverage.

Safety

  • No secrets/wallets/hotkeys/trust-scores/rankings exposed.
  • No public-facing text changed.
  • Not an auth/cookie/CORS/session/GitHub-App/Cloudflare change.
  • Not an API/OpenAPI/MCP surface change.
  • No UI changes — backend calibration logic only.

Notes

#2348)

planAutoTune/shouldAutoClear and their close-side mirrors now engage and
clear on GateEvalRow's reversal-discounted weightedMergePrecision /
weightedClosePrecision (already computed by parity.ts's computeGateEval,
PR #4169) instead of the raw precision fields. A high volume of later-
reverted merges can no longer keep the raw number artificially healthy
to dodge the breaker. The raw fields are preserved on AutoTuneAction /
CloseAutoTuneAction for log continuity and surfaced alongside the
weighted number in the alert message. computeTuningRecommendations (the
separate advisory-only tuning surface) is unchanged.

evalRowFromCalibration's synthetic rows (selftune-wire.ts, sourced from
agent_recommendation_outcomes) carry no reversal signal, so their
weighted fields mirror the raw ones by construction.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.20%. Comparing base (0800f23) to head (d8b8c96).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5088   +/-   ##
=======================================
  Coverage   94.20%   94.20%           
=======================================
  Files         470      470           
  Lines       39722    39726    +4     
  Branches    14493    14497    +4     
=======================================
+ Hits        37421    37425    +4     
  Misses       1645     1645           
  Partials      656      656           
Flag Coverage Δ
shard-1 46.40% <0.00%> (-0.03%) ⬇️
shard-2 33.62% <0.00%> (+0.03%) ⬆️
shard-3 31.35% <0.00%> (+0.01%) ⬆️
shard-4 32.66% <100.00%> (-0.15%) ⬇️
shard-5 33.44% <0.00%> (-0.10%) ⬇️
shard-6 45.10% <0.00%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/review/auto-tune.ts 100.00% <100.00%> (ø)
src/review/selftune-wire.ts 96.66% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 11, 2026
@JSONbored JSONbored merged commit 978417e into main Jul 11, 2026
17 checks passed
@JSONbored JSONbored deleted the feat/gate-precision-weighted-breaker-2348 branch July 11, 2026 14:13
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.

maintainer: value-weighted gate-prediction calibration — optimize for merged-net-positive, not raw volume

1 participant