Context
packages/loopover-engine/src/calibration/signal-tracking.ts (#7982) is the shared, deployment-agnostic
"deterministic rule signal tracking" primitive both ORB's gate blockers and AMS's eligibility heuristics
record through: computeRulePrecision, computeRuleRepeatCount, and evaluateRuleRepeatAlarm. It is live
and consumed today (evaluateRuleRepeatAlarm is wired into src/review/rule-repeat-alarm-wire.ts), and it
already has a full, passing test suite at packages/loopover-engine/test/signal-tracking.test.ts (15
scenarios, run via npm run test --workspace @loopover/engine).
The problem: that engine-package test suite runs under Node's own node --test runner, which is not
part of the root vitest run (npm run test:coverage) that Codecov's codecov/patch gate actually reads
from. vitest.config.ts's coverage.include DOES list packages/loopover-engine/src/**/*.ts — so this
file is eligible for Codecov coverage in principle — but no root-level test/**/*.test.ts file imports
or exercises calibration/signal-tracking.ts today, so it reports as genuinely 0% covered in Codecov's
eyes despite having a real, passing test suite one directory over. This is the exact same failure mode
already fixed once in this repo for a different package (#6250, review-enrichment's node:test suite being
invisible to Codecov) — the difference here is packages/loopover-engine/src/** is already correctly
listed in coverage.include, so the fix is per-file test coverage, not a vitest.config.ts wiring change.
Net effect: a future PR that touches calibration/signal-tracking.ts for an unrelated reason (e.g. a small
bug fix) will fail the 99% Codecov patch-coverage gate on its changed lines, even though the module's real
behavior is already thoroughly tested by the engine package's own suite.
The established fix pattern for exactly this situation already exists many times in this repo: a root
test/unit/<name>.test.ts file that imports the engine's public API from packages/loopover-engine/src/index
and re-exercises the same behavior the package's own node --test suite already covers, purely so vitest
(and therefore Codecov) sees it too. See test/unit/calibration-dashboard.test.ts and
test/unit/discovery-soft-claim.test.ts for the exact existing shape of this pattern.
⚠️ Read this before starting. This issue is test-coverage-only. Do NOT modify
packages/loopover-engine/src/calibration/signal-tracking.ts itself, and do NOT modify
packages/loopover-engine/test/signal-tracking.test.ts. The only new artifact this issue calls for is one
new root-level vitest file. A PR that changes the source module's behavior does not satisfy this issue.
Requirements
- Create
test/unit/signal-tracking.test.ts using describe/it/expect from vitest (the same style as
test/unit/calibration-dashboard.test.ts).
- Import
computeRulePrecision, computeRuleRepeatCount, and evaluateRuleRepeatAlarm from
"../../packages/loopover-engine/src/index" — the barrel — not from a relative path into
packages/loopover-engine/src/calibration/signal-tracking.ts directly (matches every existing sibling
root-level engine test).
- Cover, at minimum, every scenario already exercised in
packages/loopover-engine/test/signal-tracking.test.ts
(read it for the exact fixtures/assertions to mirror), including:
computeRulePrecision: zero fired/zero overrides (precision null), overrides for a different ruleId
ignored, mixed reversed/confirmed verdicts producing the correct precision ratio, and an override
whose targetKey never appears in fired still counting toward decided.
computeRuleRepeatCount: counts only exact ruleId + targetKey matches, ignoring same-rule-different-target
and same-target-different-rule events.
evaluateRuleRepeatAlarm: triggered false below threshold, true at/above threshold (boundary case: exactly
threshold distinct targets), affectedTargets deduplicated and in first-seen order, and events for other
ruleIds excluded.
- Every
??, ternary, and boundary comparison (>=, >) in the three functions must have both its taken and
not-taken branch exercised by at least one test case.
Deliverables
Test Coverage Requirements
packages/loopover-engine/src/calibration/signal-tracking.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. After this PR, npm run test:coverage (run
unsharded locally) should show packages/loopover-engine/src/calibration/signal-tracking.ts at or near 100%
line/branch coverage. Since this PR only adds a new test file (no changed lines in src/**), the codecov/patch
gate itself won't directly grade this PR's own diff against this file, but the new test's presence is what
makes any future PR touching this file gate correctly.
Expected Outcome
calibration/signal-tracking.ts's already-real, already-tested behavior becomes visible to Codecov, so a
future PR that changes this file's logic is actually gated on real coverage instead of silently passing (or
being unfairly blocked) due to a coverage blind spot.
Links & Resources
Context
packages/loopover-engine/src/calibration/signal-tracking.ts(#7982) is the shared, deployment-agnostic"deterministic rule signal tracking" primitive both ORB's gate blockers and AMS's eligibility heuristics
record through:
computeRulePrecision,computeRuleRepeatCount, andevaluateRuleRepeatAlarm. It is liveand consumed today (
evaluateRuleRepeatAlarmis wired intosrc/review/rule-repeat-alarm-wire.ts), and italready has a full, passing test suite at
packages/loopover-engine/test/signal-tracking.test.ts(15scenarios, run via
npm run test --workspace @loopover/engine).The problem: that engine-package test suite runs under Node's own
node --testrunner, which is notpart of the root
vitestrun (npm run test:coverage) that Codecov'scodecov/patchgate actually readsfrom.
vitest.config.ts'scoverage.includeDOES listpackages/loopover-engine/src/**/*.ts— so thisfile is eligible for Codecov coverage in principle — but no root-level
test/**/*.test.tsfile importsor exercises
calibration/signal-tracking.tstoday, so it reports as genuinely 0% covered in Codecov'seyes despite having a real, passing test suite one directory over. This is the exact same failure mode
already fixed once in this repo for a different package (#6250,
review-enrichment's node:test suite beinginvisible to Codecov) — the difference here is
packages/loopover-engine/src/**is already correctlylisted in
coverage.include, so the fix is per-file test coverage, not avitest.config.tswiring change.Net effect: a future PR that touches
calibration/signal-tracking.tsfor an unrelated reason (e.g. a smallbug fix) will fail the 99% Codecov patch-coverage gate on its changed lines, even though the module's real
behavior is already thoroughly tested by the engine package's own suite.
The established fix pattern for exactly this situation already exists many times in this repo: a root
test/unit/<name>.test.tsfile that imports the engine's public API frompackages/loopover-engine/src/indexand re-exercises the same behavior the package's own
node --testsuite already covers, purely so vitest(and therefore Codecov) sees it too. See
test/unit/calibration-dashboard.test.tsandtest/unit/discovery-soft-claim.test.tsfor the exact existing shape of this pattern.Requirements
test/unit/signal-tracking.test.tsusingdescribe/it/expectfromvitest(the same style astest/unit/calibration-dashboard.test.ts).computeRulePrecision,computeRuleRepeatCount, andevaluateRuleRepeatAlarmfrom"../../packages/loopover-engine/src/index"— the barrel — not from a relative path intopackages/loopover-engine/src/calibration/signal-tracking.tsdirectly (matches every existing siblingroot-level engine test).
packages/loopover-engine/test/signal-tracking.test.ts(read it for the exact fixtures/assertions to mirror), including:
computeRulePrecision: zero fired/zero overrides (precisionnull), overrides for a differentruleIdignored, mixed
reversed/confirmedverdicts producing the correctprecisionratio, and an overridewhose
targetKeynever appears infiredstill counting towarddecided.computeRuleRepeatCount: counts only exactruleId+targetKeymatches, ignoring same-rule-different-targetand same-target-different-rule events.
evaluateRuleRepeatAlarm:triggeredfalse below threshold, true at/above threshold (boundary case: exactlythresholddistinct targets),affectedTargetsdeduplicated and in first-seen order, and events for otherruleIds excluded.??, ternary, and boundary comparison (>=,>) in the three functions must have both its taken andnot-taken branch exercised by at least one test case.
Deliverables
test/unit/signal-tracking.test.ts(vitest, imports via the engine barrel).packages/loopover-engine/src/**orpackages/loopover-engine/test/**.Test Coverage Requirements
packages/loopover-engine/src/calibration/signal-tracking.tsis insidecoverage.includeinvitest.config.tsand therefore IS subject to the 99% Codecovcodecov/patchbranch-counted gate — today itreports ~0% because nothing under root
test/**exercises it. After this PR,npm run test:coverage(rununsharded locally) should show
packages/loopover-engine/src/calibration/signal-tracking.tsat or near 100%line/branch coverage. Since this PR only adds a new test file (no changed lines in
src/**), thecodecov/patchgate itself won't directly grade this PR's own diff against this file, but the new test's presence is what
makes any future PR touching this file gate correctly.
Expected Outcome
calibration/signal-tracking.ts's already-real, already-tested behavior becomes visible to Codecov, so afuture PR that changes this file's logic is actually gated on real coverage instead of silently passing (or
being unfairly blocked) due to a coverage blind spot.
Links & Resources
packages/loopover-engine/src/calibration/signal-tracking.ts(module under test — do not modify)packages/loopover-engine/test/signal-tracking.test.ts(the existing node:test suite to mirror scenarios from)test/unit/calibration-dashboard.test.ts,test/unit/discovery-soft-claim.test.ts(existing root-levelvitest tests following the exact pattern this issue asks for)
vitest.config.ts(coverage.include, confirmspackages/loopover-engine/src/**/*.tsis already tracked)review-enrichment)