Skip to content

fix(engine): drop opportunity-metadata's blanket v8-ignore directives and branch-cover the scoring logic they hid - #9635

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
rsnetworkinginc:fix-9616
Jul 29, 2026
Merged

fix(engine): drop opportunity-metadata's blanket v8-ignore directives and branch-cover the scoring logic they hid#9635
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
rsnetworkinginc:fix-9616

Conversation

@rsnetworkinginc

Copy link
Copy Markdown
Contributor

Closes #9616

Summary

fix(engine): drop opportunity-metadata's blanket v8-ignore directives and branch-cover the scoring logic they hid

packages/loopover-engine/src/opportunity-metadata.ts computes the five ranker inputs that decide which issue the miner works next, yet v8 ignore directives suppressed branch counting across nearly all of its decision logic — computeMetadataPotential wholesale (plus per-branch ignores), the feasibility clock guard and title-length tiers, titlesOverlap, all five computeMetadataDupRisk branches, and six bare unexplained directives — in a file coverage.include and the engine Codecov flag are supposed to grade. The existing rationales are self-refuting: if a line is genuinely exercised, v8 ignore on it is redundant; the directive only changes anything when the line is NOT hit.

Root cause / RED evidence

Stripping the directives without adding tests proves they were concealing untested branches: under the existing ranker suites (miner-opportunity-ranker, opportunity-metadata-signals, miner-opportunity-fanout) the file immediately reports four partial-branch lines (46, 87, 96, 191) — including the clamp01 guard, the timestamp fallbacks, and the ?? -arm on the competition context. Scoring rules like the refactor bonus and the same-repo peer filter could have been inverted without any test failing.

Fix

  • Deleted every v8 ignore directive in the file — the start/stop pairs, the per-branch nexts, and the six bare ones — except the legitimate opportunityMetadataInternals test-only export block, which keeps its single pair. The file now contains exactly one v8 ignore pair and no other directive.
  • Zero production-logic change: the src diff is 27 pure comment-line deletions, 0 insertions (git show --numstat: 0 27). Every numeric literal, label array, comparison operator, and return expression is byte-for-byte identical.
  • Direct unit tests added in both graded suites — new packages/loopover-engine/test/opportunity-metadata.test.ts (node:test + node:assert/strict, importing from ../dist/index.js / ../dist/opportunity-metadata.js for the internals, per the opportunity-ranker.test.ts style) and a mirrored new test/unit/opportunity-metadata.test.ts (vitest) so the backend flag grades the same arms. They call the exported functions and opportunityMetadataInternals members directly, not only rankMetadataOpportunities.

Test coverage delivered (every enumerated branch)

  • computeMetadataPotential: negative label → 0 (also alongside a positive label), positive label (+0.35), "bug" (+0.1), "refactor" (+0.05), "bug"+"refactor", neutral-only baseline 0.45; label normalization (trim/lowercase/non-string/blank drops).
  • computeMetadataFeasibility: non-finite nowMs (NaN and Infinity → 0); title tiers >= 8 / 4-7 / < 4 on the normalized title (incl. whitespace collapse); comment-load zeroing at 25; non-finite and negative commentsCount normalized to 0; no-timestamp stale sentinel; unparseable updatedAt falling back to valid createdAt.
  • Defensive guards, exercised without any logic change by making the underlying primitive disagree: the issueAgeDays re-parse guard (Date.parse stubbed to differ between the validation call and the re-parse call) and the clamp01 non-finite guard (Math.exp stubbed to NaN) — the only branches unreachable through natural inputs, which is exactly why the old "exercised in ranker tests" rationales could never have been true for them.
  • opportunityMetadataInternals.titlesOverlap: empty left, empty right, exact equality, containment with shorter.length >= 12, containment with < 12, both swap arms, and no-containment.
  • computeMetadataDupRisk: blank/whitespace title → 1, self-peer skip (with repo case/whitespace variance), same-number-different-repo falling through to the cross-repo skip, cross-repo skip, same-repo overlapping peer (1 → 0.5, 2 → 2/3), zero-overlap batch → 0.
  • buildMetadataRankInput: highRiskDuplicateClusters/openPullRequests present (dupRisk = 0.5 from 2/4) and absent (?? 0 arms, dupRisk 0); updatedAt/createdAt present and absent (?? null arms).
  • rankMetadataOpportunities: ranks and orders targetable candidates; drops a repo whose goal spec sets minerEnabled: false (both filter arms).
  • Internals normalizeLabels, pickMetadataTimestamp (all fallback arms), resolveGoalSpec (match with case/whitespace variance, non-match, absent map).

Gates (verbatim)

Engine package suite (the engine flag's own suite, +29 tests): # tests 833 / # pass 833 / # fail 0.

engine flag — CI's exact command (node --experimental-strip-types scripts/engine-coverage.ts), lcov cross-checked:

OK: packages/loopover-engine/src/opportunity-metadata.ts
  whole-file uncovered lines: none | whole-file partial-branch lines: none

backend flag — root vitest v8 coverage, same cross-check:

OK: packages/loopover-engine/src/opportunity-metadata.ts
  whole-file uncovered lines: none | whole-file partial-branch lines: none

(The only remaining v8 ignore pair is the retained internals export block.)

Validation commands (repo root)

git diff --check                                  # clean
npm run build --workspace @loopover/engine        # clean tsc build
npm run test --workspace @loopover/engine         # 833 tests, 833 pass, 0 fail
node --experimental-strip-types scripts/engine-coverage.ts   # engine-flag lcov: file fully covered, zero partial branches
npm run test:coverage                             # unsharded, per the contributor guide: no uncovered line or branch in opportunity-metadata.ts outside the retained internals block
npm run typecheck                                 # clean (root + packages)

… and branch-cover the scoring logic they hid

opportunity-metadata.ts carried v8-ignore suppressions across nearly
all of its decision logic -- computeMetadataPotential wholesale, the
feasibility clock guard and title tiers, titlesOverlap, all five
computeMetadataDupRisk branches, and six bare unexplained directives --
in a file the engine Codecov flag is supposed to grade. The rationales
were self-refuting ("exercised in ranker tests": if true the directive
is redundant, if false it conceals an untested branch), and stripping
them proves the point: four partial branches surface under the
existing ranker suites alone.

Delete every directive except the opportunityMetadataInternals
test-only export block's legitimate pair. No production logic changes
-- the diff to the source file is 27 pure comment-line deletions; every
formula, threshold, label list, and return expression is byte-for-byte
identical. Direct unit tests now pin each previously-suppressed
branch: label tiers and normalization, the non-finite clock guard,
title-length tiers, titlesOverlap's emptiness/equality/containment-
threshold/swap arms, dup-risk's self/cross-repo/overlap filters, the
competition-context and timestamp ?? arms, the targetability filter,
and the defensive re-parse and clamp01 guards (exercised by making the
underlying primitive disagree, the only way without a logic change).

Regression tests land in BOTH graded suites: the engine package's own
node:test suite (the `engine` Codecov flag's coverage run) and the
root vitest unit suite (the `backend` flag). Under each flag's own
lcov the file now reports zero uncovered lines and zero partial
branches outside the retained internals block.

Closes JSONbored#9616
@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 02:51:34 UTC

3 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This is a pure comment-deletion diff (0 production-logic insertions) that strips 27 blanket/unexplained `v8 ignore` directives from opportunity-metadata.ts and backfills two mirrored, thorough test suites (node:test and vitest) that directly exercise every branch those directives previously suppressed, including the clamp01/finiteNonNegativeInt defensive guards via monkeypatched Date.parse/Math.exp. The tests are well-targeted at real, reachable code paths (label tiers, title-length tiers, dup-risk peer filtering, timestamp fallback logic) rather than fabricated states, and correctly closes #9616. The one legitimate remaining `v8 ignore` pair (opportunityMetadataInternals test-only export) is appropriately preserved since that export exists solely for test access.

Nits — 3 non-blocking
  • The two test files (packages/loopover-engine/test/opportunity-metadata.test.ts and test/unit/opportunity-metadata.test.ts) are near-duplicates of each other — consider whether both are truly necessary long-term or if one graded suite could re-export/import the other's cases to avoid double-maintenance drift.
  • The monkeypatching of global `Date.parse` and `Math.exp` in packages/loopover-engine/test/opportunity-metadata.test.ts:87-135 to force otherwise-unreachable defensive branches is a bit invasive; a comment noting these guards are intentionally unreachable under normal inputs (which the PR description does explain, but not the test file itself) would help future readers understand why this pattern is needed.
  • Consider extracting the shared `issueFor` fixture and constants (NOW_ISO, NOW) used identically in both test files into a shared test-utils module if the two suites are meant to stay long-term duplicates.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9616
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 60 registered-repo PR(s), 33 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor rsnetworkinginc; Gittensor profile; 60 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff removes all 18 v8 ignore directives except the legitimate opportunityMetadataInternals block, leaves scoring logic byte-for-byte unchanged (pure comment deletions), and adds packages/loopover-engine/test/opportunity-metadata.test.ts with direct node:test unit tests covering computeMetadataPotential's label tiers, computeMetadataFeasibility's clock guard and title-length tiers, titlesOverl

Review context
  • Author: rsnetworkinginc
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: not available
  • Official Gittensor activity: 60 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Await review-lane availability.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.14%. Comparing base (a402b9f) to head (7c3c89c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9635      +/-   ##
==========================================
+ Coverage   90.12%   90.14%   +0.02%     
==========================================
  Files         891      891              
  Lines      112306   112279      -27     
  Branches    26629    26680      +51     
==========================================
+ Hits       101216   101218       +2     
+ Misses       9760     9727      -33     
- Partials     1330     1334       +4     
Flag Coverage Δ
backend 95.51% <ø> (-0.01%) ⬇️
engine 67.27% <ø> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ckages/loopover-engine/src/opportunity-metadata.ts 100.00% <ø> (+13.02%) ⬆️

... and 2 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 29, 2026

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 61ab43e into JSONbored:main Jul 29, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 29, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine(ranker): opportunity-metadata.ts's blanket v8 ignore blocks hide untested scoring branches

1 participant