Skip to content

goal-model.ts's computeLaneFit has zero root-level (Codecov-visible) test coverage #8344

Description

@JSONbored

Context

packages/loopover-engine/src/goal-model.ts exports computeLaneFit: the pure lane-fit scorer that compiles
a repo's MinerGoalSpec path/label preferences into a single [0, 1] score, per the precedence rules
documented in the function's own doc comment (hard veto on blockedPaths/blockedLabels → 0; neutral 0.5
when no preferences are configured; 0 when preferences are configured but none match; otherwise
matchedDimensions / activeDimensions). It also contains a hand-rolled glob matcher
(compileGlobMatcher) supporting *, a bare **, a ** immediately followed by /, and ?. This is live,
load-bearing logic — it's consumed by miner-goal-lane-fit.ts and opportunity-metadata.ts's
computeMetadataLaneFit, and re-exported from the engine's public barrel.

It already has a full, passing test suite at packages/loopover-engine/test/goal-model.test.ts (14
scenarios, node --test). But — same failure mode as #6250 (review-enrichment's node:test suite being
invisible to Codecov) — that suite is not part of the root vitest run Codecov reads codecov/patch from.
No file under root test/** currently exercises computeLaneFit directly (test/integration/miner-discovery-pipeline.test.ts
exercises it only indirectly, composed through the full discovery ranker, and its own header comment
explicitly says dedicated unit coverage belongs in "goal-model.test.ts" — which exists, but only as the
engine package's node:test file, not a root-level vitest one). packages/loopover-engine/src/**/*.ts is
already listed in vitest.config.ts's coverage.include, so this is a per-file coverage gap, not a wiring
gap — computeLaneFit and compileGlobMatcher report as effectively 0% covered in Codecov today despite
being one of the largest branch surfaces in the package (~29 branches across the precedence rules and the
glob compiler).

⚠️ Read this before starting. This issue is test-coverage-only. Do NOT modify
packages/loopover-engine/src/goal-model.ts itself, and do NOT modify
packages/loopover-engine/test/goal-model.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/goal-model.test.ts using describe/it/expect from vitest, importing computeLaneFit
    (and any supporting types) from "../../packages/loopover-engine/src/index" — the barrel — matching the
    existing sibling pattern in test/unit/calibration-dashboard.test.ts.
  • Cover, at minimum, every scenario already exercised in packages/loopover-engine/test/goal-model.test.ts
    (read it for the exact fixtures/assertions to mirror), including all four precedence rules from
    computeLaneFit's own doc comment:
    1. Hard veto on a blocked path, and independently on a blocked label, each returning 0 even when a
      wanted/preferred match is also present.
    2. Neutral 0.5 when neither wantedPaths nor preferredLabels is configured.
    3. 0 when at least one preference dimension is configured but none match.
    4. Partial credit: one active dimension matching → 1; two active dimensions with only one matching →
      0.5; two active dimensions both matching → 1.
    • The glob matcher (compileGlobMatcher, reached only through computeLaneFit's path matching): a plain
      * (single-segment wildcard, must not cross /), a bare ** (crosses /), **/ as an optional
      directory prefix (zero or more leading segments), ? (single non-/ char), a pattern containing a
      literal regex-metacharacter (e.g. .), Windows-style backslash paths normalized before matching, and
      case-insensitivity.
  • Every ??, ternary, and boolean short-circuit in computeLaneFit and compileGlobMatcher must have both
    its taken and not-taken branch exercised.

Deliverables

  • New file test/unit/goal-model.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/goal-model.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 packages/loopover-engine/src/goal-model.ts at or near 100% line/branch coverage, including both
arms of every documented precedence rule and every glob-matcher branch.

Expected Outcome

goal-model.ts's already-real, already-tested lane-fit scoring and glob-matching logic becomes visible to
Codecov, so a future PR that changes this file's precedence rules or glob semantics is actually gated on real
coverage instead of a blind spot.

Links & Resources

  • packages/loopover-engine/src/goal-model.ts (module under test — do not modify)
  • packages/loopover-engine/test/goal-model.test.ts (the existing node:test suite to mirror scenarios from)
  • test/integration/miner-discovery-pipeline.test.ts (composes computeLaneFit indirectly; its own header
    comment already flags dedicated unit coverage as belonging in a goal-model.test.ts-shaped file)
  • test/unit/calibration-dashboard.test.ts (existing root-level vitest test following the exact pattern this
    issue asks for)
  • vitest.config.ts (coverage.include, confirms packages/loopover-engine/src/**/*.ts is already tracked)
  • fix(ci): review-enrichment's real node:test coverage is invisible to Codecov (83 of 83 files effectively unmeasured) #6250 (the same blind-spot failure mode, fixed for review-enrichment)

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