Skip to content

calibration/signal-tracking.ts's real node:test coverage is invisible to Codecov #8343

Description

@JSONbored

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

  • New file test/unit/signal-tracking.test.ts (vitest, imports via the engine barrel).
  • No changes to any file under packages/loopover-engine/src/** or packages/loopover-engine/test/**.

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

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