Context
src/signals/improvement.ts defines its own private clamp function at the bottom of the file (lines 257-259):
function clamp(value: number, min: number, max: number): number {
return Math.min(max, Math.max(min, value));
}
src/signals/slop.ts already re-exports a clamp function with the identical (value, min, max) signature and identical Math.min(max, Math.max(min, value)) body, sourced from packages/loopover-engine/src/signals/slop.ts:405. improvement.ts already imports from ./slop at line 29 (import { buildMissingTestEvidenceFinding, type SlopChangedFile } from "./slop";), so the dependency is already established — clamp simply was never added to that same import.
The sibling file src/signals/issue-slop.ts:7 already demonstrates the correct pattern this file should follow: import { clamp, slopBandFor, type SlopAssessment } from "./slop";.
improvement.ts's local clamp is used once, to bound improvementScore in buildStructuralImprovementAssessment (lines 123-130).
Requirements
- Remove the local
clamp function definition from src/signals/improvement.ts (lines 257-259).
- Add
clamp to the existing import from ./slop on line 29 of src/signals/improvement.ts (import { buildMissingTestEvidenceFinding, clamp, type SlopChangedFile } from "./slop";), matching the import style already used by src/signals/issue-slop.ts:7.
- This is a pure refactor: the computed
improvementScore value (and every build*Finding helper's output) must be byte-identical to before this change — both implementations already share the same signature and body.
Deliverables
Test Coverage Requirements
Touches src/signals/improvement.ts, under src/** — this repo's Codecov patch gate (99%+ on changed lines) applies to the changed import line. No new test file should be required: improvementScore's clamping behavior is already exercised by improvement.ts's existing test suite, and the replacement clamp is byte-identical in behavior to the one it replaces.
Expected Outcome
src/signals/improvement.ts has no locally-duplicated clamp implementation; it reuses the same canonical clamp that every other consumer of slop.ts's exports (e.g. issue-slop.ts) already shares.
Links & Resources
src/signals/improvement.ts:29,123-130,257-259
src/signals/slop.ts (re-export of clamp)
src/signals/issue-slop.ts:7 (existing precedent for importing clamp from ./slop)
packages/loopover-engine/src/signals/slop.ts:405 (canonical implementation)
Context
src/signals/improvement.tsdefines its own privateclampfunction at the bottom of the file (lines 257-259):src/signals/slop.tsalready re-exports aclampfunction with the identical(value, min, max)signature and identicalMath.min(max, Math.max(min, value))body, sourced frompackages/loopover-engine/src/signals/slop.ts:405.improvement.tsalready imports from./slopat line 29 (import { buildMissingTestEvidenceFinding, type SlopChangedFile } from "./slop";), so the dependency is already established —clampsimply was never added to that same import.The sibling file
src/signals/issue-slop.ts:7already demonstrates the correct pattern this file should follow:import { clamp, slopBandFor, type SlopAssessment } from "./slop";.improvement.ts's localclampis used once, to boundimprovementScoreinbuildStructuralImprovementAssessment(lines 123-130).Requirements
clampfunction definition fromsrc/signals/improvement.ts(lines 257-259).clampto the existing import from./slopon line 29 ofsrc/signals/improvement.ts(import { buildMissingTestEvidenceFinding, clamp, type SlopChangedFile } from "./slop";), matching the import style already used bysrc/signals/issue-slop.ts:7.improvementScorevalue (and everybuild*Findinghelper's output) must be byte-identical to before this change — both implementations already share the same signature and body.Deliverables
src/signals/improvement.tsimportsclampfrom./slopinstead of defining its own copybuildStructuralImprovementAssessmentand itsbuild*Findinghelpers pass unmodifiedTest Coverage Requirements
Touches
src/signals/improvement.ts, undersrc/**— this repo's Codecov patch gate (99%+ on changed lines) applies to the changed import line. No new test file should be required:improvementScore's clamping behavior is already exercised byimprovement.ts's existing test suite, and the replacementclampis byte-identical in behavior to the one it replaces.Expected Outcome
src/signals/improvement.tshas no locally-duplicatedclampimplementation; it reuses the same canonicalclampthat every other consumer ofslop.ts's exports (e.g.issue-slop.ts) already shares.Links & Resources
src/signals/improvement.ts:29,123-130,257-259src/signals/slop.ts(re-export ofclamp)src/signals/issue-slop.ts:7(existing precedent for importingclampfrom./slop)packages/loopover-engine/src/signals/slop.ts:405(canonical implementation)