Context
packages/loopover-engine/src/miner/loop-reentry-policy.ts (#2338) exports shouldReenter: the pure decision
half of "on a resolved outcome, automatically re-invoke discovery for the next candidate." Its own header
comment calls this "the top slop-at-scale risk for the whole miner subsystem" and gives it three independent
ceilings, all collected (not short-circuited) except the kill-switch check which IS checked first and does
short-circuit: a per-repo circuit breaker on consecutive "disengaged" outcomes, an hourly re-entry cap, and
a per-session re-entry cap. It is live and consumed via packages/loopover-miner/lib/loop-reentry.ts, and it
already has a full, passing test suite at packages/loopover-engine/test/loop-reentry-policy.test.ts (16
scenarios, node --test).
Same failure mode as #6250 (review-enrichment's node:test suite being invisible to Codecov): that engine
package suite doesn't run under root vitest, which is what Codecov's codecov/patch gate reads.
packages/loopover-engine/src/**/*.ts is already listed in vitest.config.ts's coverage.include, so this
is a per-file gap — nothing under root test/** currently exercises shouldReenter directly, so it reports
as ~0% covered in Codecov despite real, passing tests existing one directory over.
⚠️ Read this before starting. This issue is test-coverage-only. Do NOT modify
packages/loopover-engine/src/miner/loop-reentry-policy.ts,
packages/loopover-engine/src/governor/kill-switch.ts, or
packages/loopover-engine/test/loop-reentry-policy.test.ts. The only new artifact this issue calls for is
one new root-level vitest file that exercises the EXISTING, unchanged decision function. A PR that changes
any of this ceiling/circuit-breaker logic does not satisfy this issue and is out of scope for it.
Requirements
- Create
test/unit/loop-reentry-policy.test.ts using describe/it/expect from vitest, importing
shouldReenter, DEFAULT_MAX_CONSECUTIVE_DISENGAGEMENTS, DEFAULT_MAX_REENTRIES_PER_HOUR, and
DEFAULT_MAX_REENTRIES_PER_SESSION from "../../packages/loopover-engine/src/index" — the barrel —
matching the existing sibling pattern in test/unit/calibration-dashboard.test.ts. Use a fake/stubbed
MinerKillSwitchScope the same way packages/loopover-engine/test/loop-reentry-policy.test.ts already does
— do not exercise the real isMinerKillSwitchActive implementation's own IO paths.
- Cover, at minimum, every scenario already exercised in
packages/loopover-engine/test/loop-reentry-policy.test.ts (read it for the exact fixtures/assertions to
mirror), including:
- Kill-switch active short-circuits to
{ reenter: false, reasons: ["<scope>_kill_switch_active"] } even
when none of the other three ceilings would otherwise block — and the returned reasons array contains
ONLY the kill-switch reason, nothing else.
- Each of the three independent ceilings triggering on its own (consecutive disengagements at/above default
and an explicit override; hourly cap at/above default and an explicit override; session cap at/above
default and an explicit override) — boundary case for each: exactly at the threshold.
- Two or more ceilings breached simultaneously:
reasons contains ALL of them, not just the first
(verifies the "collected, not short-circuited" contract from the module's own doc comment).
outcome: "merged" alone does NOT bypass the hourly/session cap when a cap is already spent.
- A non-
"disengaged" outcome never contributes to the consecutive-disengagement ceiling regardless of the
consecutiveDisengagements count passed in (the module trusts the caller's own count; the ceiling check
itself is gated on outcome === "disengaged").
- A fully clean candidate (no kill-switch, no ceiling breached) returns
{ reenter: true, reasons: [] }.
Deliverables
Test Coverage Requirements
packages/loopover-engine/src/miner/loop-reentry-policy.ts is inside coverage.include in vitest.config.ts
and therefore IS subject to the 99% Codecov codecov/patch branch-counted gate — today it reports ~0%
because nothing under root test/** exercises it directly. After this PR, npm run test:coverage (run
unsharded locally) should show this file at or near 100% line/branch coverage, including every ceiling's both
arms and the kill-switch short-circuit.
Expected Outcome
loop-reentry-policy.ts's already-real, already-tested re-entry ceilings become visible to Codecov, so a
future PR that changes this file is actually gated on real coverage instead of a blind spot — closing a
coverage gap in the exact module this repo's own comments flag as the top slop-at-scale risk for the miner
subsystem.
Links & Resources
Context
packages/loopover-engine/src/miner/loop-reentry-policy.ts(#2338) exportsshouldReenter: the pure decisionhalf of "on a resolved outcome, automatically re-invoke discovery for the next candidate." Its own header
comment calls this "the top slop-at-scale risk for the whole miner subsystem" and gives it three independent
ceilings, all collected (not short-circuited) except the kill-switch check which IS checked first and does
short-circuit: a per-repo circuit breaker on consecutive
"disengaged"outcomes, an hourly re-entry cap, anda per-session re-entry cap. It is live and consumed via
packages/loopover-miner/lib/loop-reentry.ts, and italready has a full, passing test suite at
packages/loopover-engine/test/loop-reentry-policy.test.ts(16scenarios,
node --test).Same failure mode as #6250 (
review-enrichment's node:test suite being invisible to Codecov): that enginepackage suite doesn't run under root
vitest, which is what Codecov'scodecov/patchgate reads.packages/loopover-engine/src/**/*.tsis already listed invitest.config.ts'scoverage.include, so thisis a per-file gap — nothing under root
test/**currently exercisesshouldReenterdirectly, so it reportsas ~0% covered in Codecov despite real, passing tests existing one directory over.
Requirements
test/unit/loop-reentry-policy.test.tsusingdescribe/it/expectfromvitest, importingshouldReenter,DEFAULT_MAX_CONSECUTIVE_DISENGAGEMENTS,DEFAULT_MAX_REENTRIES_PER_HOUR, andDEFAULT_MAX_REENTRIES_PER_SESSIONfrom"../../packages/loopover-engine/src/index"— the barrel —matching the existing sibling pattern in
test/unit/calibration-dashboard.test.ts. Use a fake/stubbedMinerKillSwitchScopethe same waypackages/loopover-engine/test/loop-reentry-policy.test.tsalready does— do not exercise the real
isMinerKillSwitchActiveimplementation's own IO paths.packages/loopover-engine/test/loop-reentry-policy.test.ts(read it for the exact fixtures/assertions tomirror), including:
{ reenter: false, reasons: ["<scope>_kill_switch_active"] }evenwhen none of the other three ceilings would otherwise block — and the returned
reasonsarray containsONLY the kill-switch reason, nothing else.
and an explicit override; hourly cap at/above default and an explicit override; session cap at/above
default and an explicit override) — boundary case for each: exactly at the threshold.
reasonscontains ALL of them, not just the first(verifies the "collected, not short-circuited" contract from the module's own doc comment).
outcome: "merged"alone does NOT bypass the hourly/session cap when a cap is already spent."disengaged"outcome never contributes to the consecutive-disengagement ceiling regardless of theconsecutiveDisengagementscount passed in (the module trusts the caller's own count; the ceiling checkitself is gated on
outcome === "disengaged").{ reenter: true, reasons: [] }.Deliverables
test/unit/loop-reentry-policy.test.ts(vitest, imports via the engine barrel).packages/loopover-engine/src/**orpackages/loopover-engine/test/**.Test Coverage Requirements
packages/loopover-engine/src/miner/loop-reentry-policy.tsis insidecoverage.includeinvitest.config.tsand therefore IS subject to the 99% Codecov
codecov/patchbranch-counted gate — today it reports ~0%because nothing under root
test/**exercises it directly. After this PR,npm run test:coverage(rununsharded locally) should show this file at or near 100% line/branch coverage, including every ceiling's both
arms and the kill-switch short-circuit.
Expected Outcome
loop-reentry-policy.ts's already-real, already-tested re-entry ceilings become visible to Codecov, so afuture PR that changes this file is actually gated on real coverage instead of a blind spot — closing a
coverage gap in the exact module this repo's own comments flag as the top slop-at-scale risk for the miner
subsystem.
Links & Resources
packages/loopover-engine/src/miner/loop-reentry-policy.ts(module under test — do not modify)packages/loopover-engine/test/loop-reentry-policy.test.ts(the existing node:test suite to mirrorscenarios from)
test/unit/calibration-dashboard.test.ts(existing root-level vitest test following the exact pattern thisissue asks for)
vitest.config.ts(coverage.include, confirmspackages/loopover-engine/src/**/*.tsis already tracked)review-enrichment)