From 62e873aabf8c75381b86da525b6adcc8f30b1e51 Mon Sep 17 00:00:00 2001 From: ultrahighsuper Date: Fri, 17 Jul 2026 01:49:32 +0900 Subject: [PATCH] refactor(signals): reuse slop.ts's canonical clamp in improvement.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `src/signals/improvement.ts` defined its own private `clamp(value, min, max)` with a body identical to the `clamp` already re-exported from `./slop` (sourced from packages/loopover-engine/src/signals/slop.ts). The file already imports from `./slop`, so `clamp` simply was never added to that import. Add `clamp` to the existing `./slop` import and delete the local duplicate, matching the sibling `src/signals/issue-slop.ts`, which already imports `clamp` from `./slop`. Behavior is unchanged — same signature, same body, same call site. Closes #6607 --- src/signals/improvement.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/signals/improvement.ts b/src/signals/improvement.ts index 342fbfc624..1971e1c3df 100644 --- a/src/signals/improvement.ts +++ b/src/signals/improvement.ts @@ -26,7 +26,7 @@ // live source for complexityDeltas, duplicationDeltas, or patchCoverageDeltaPercent — all three are honest // gaps, not yet wired by design (a later sub-issue's job), and this module must degrade cleanly when they're // absent (see "insufficient signal" below) rather than fabricate a neutral score. -import { buildMissingTestEvidenceFinding, type SlopChangedFile } from "./slop"; +import { buildMissingTestEvidenceFinding, clamp, type SlopChangedFile } from "./slop"; import { isCodeFile } from "./path-matchers"; import type { SignalFinding } from "./engine"; @@ -253,7 +253,3 @@ function improvementBandFor(improvementScore: number, hasSignal: boolean): Impro if (improvementScore < 60) return "moderate"; return "significant"; } - -function clamp(value: number, min: number, max: number): number { - return Math.min(max, Math.max(min, value)); -}