Skip to content

fix(signals): remove the unreachable "stale" OpenPrWorkClassification value #7448

Description

@JSONbored

Context

src/signals/contributor-open-pr-monitor.ts declares OpenPrWorkClassification (line 18)
including a "stale" variant, and wires it into cleanupFirst (line 115),
nextStepsForClassification (line 186), and priorityRank (line 284). The sole producer of this
type, mapPendingClassToWorkClassification (line 134), never returns "stale" — its only upstream
input (ClassifiedOpenPullRequest.classification from
packages/loopover-engine/src/scoring/pending-pr-scenarios.ts) has no plain "stale" value, only
"stale_likely_close", which is already mapped to "should_close_or_withdraw" above the fallthrough
default. "stale" is dead code: it can never be assigned to a real
ContributorOpenPrNextStepPacket.classification by any current code path, verified by tracing
every branch of mapPendingClassToWorkClassification and the upstream OpenPrPendingClass type.

nextStepsForClassification's "stale" case already shares its exact case body with
"should_close_or_withdraw" (line 186-188), so even if it were somehow produced today it would
render identical guidance — there's no distinct behavior riding on this value that would be lost by
removing it.

Whether this was a deliberate simplification (leaving a harmless legacy branch) or a real gap where
a distinctly-"stale-but-not-yet-close-worthy" PR should get its own guidance is a genuine open
question — but no existing signal in the codebase currently distinguishes a second staleness tier,
so designing one would be a product decision. This issue scopes the safer, purely-mechanical
resolution: removing the unreachable branch.

Requirements

  • Remove "stale" from the OpenPrWorkClassification union type.
  • Remove "stale" from cleanupFirst's trigger array (line 115) and from priorityRank's order
    array (line 284).
  • Collapse nextStepsForClassification's case "stale": case "should_close_or_withdraw": (line
    186) down to a single case "should_close_or_withdraw": now that the type no longer has the
    other member.
  • Do not change any other classification's behavior, ordering, or guidance text — this is a
    dead-code removal only, verified by the requirement that mapPendingClassToWorkClassification's
    own logic and every OTHER classification's next-steps/priority stay byte-identical.
  • Update/remove the existing test that exercises nextStepsForClassification("stale", ...) via a
    hand-cast literal (search test/unit/contributor-open-pr-monitor.test.ts for "stale" as a
    literal argument) since the type will no longer permit that value to be constructed without an
    explicit unsafe cast.

Deliverables

  • "stale" removed from the OpenPrWorkClassification type union and its three consuming
    arrays/switches in src/signals/contributor-open-pr-monitor.ts
  • npm run typecheck passes with the narrowed union (confirms no other code path anywhere still
    references the removed variant)
  • Existing test suite updated so no test constructs the now-invalid "stale" literal; all other
    classification cases' existing test coverage stays green and unchanged

Test Coverage Requirements

This repo's Codecov patch gate is 99%+ hard (branch-counted) on every changed line/branch in
src/**. Since this is a removal (fewer branches, not new ones), the requirement here is that the
existing suite continues to pass at its current coverage level with no regression — no new
uncovered branches should be introduced by the type-narrowing.

Expected Outcome

OpenPrWorkClassification only contains values that a real classification pipeline can actually
produce — no more misleadingly-live-looking dead branch in cleanupFirst, nextStepsForClassification,
or priorityRank that a future reader could mistake for reachable behavior.

Links & Resources

src/signals/contributor-open-pr-monitor.ts:18 (the type), :114-116 (cleanupFirst), :134-148
(mapPendingClassToWorkClassification, the sole producer), :173-192 (nextStepsForClassification),
:276-289 (priorityRank). packages/loopover-engine/src/scoring/pending-pr-scenarios.ts (the
upstream OpenPrPendingClass type, for confirming no "stale" value exists there either).

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