Skip to content

fix(rees): run REES coverage's test child from review-enrichment/#8616

Merged
JSONbored merged 1 commit into
mainfrom
fix/rees-coverage-cwd
Jul 25, 2026
Merged

fix(rees): run REES coverage's test child from review-enrichment/#8616
JSONbored merged 1 commit into
mainfrom
fix/rees-coverage-cwd

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • scripts/rees-coverage.ts spawned c8 and the node:test child it wraps with the same cwd (the monorepo root) — needed so c8's lcov SF: paths remap to review-enrichment/src/** for Codecov — but this left the actual test process running from the wrong directory, so tests reading fixtures via bare relative paths (e.g. analyzer-metadata.test.ts reading "analyzer-metadata.json") failed with ENOENT even though the fixture exists at review-enrichment/analyzer-metadata.json.
  • Adds scripts/rees-coverage-chdir.cjs, preloaded via --require into only the spawned test child, chdir'ing it into review-enrichment/ before node:test loads any files. c8's own process cwd (and its SF: path remapping) is untouched.
  • Test file arguments switch from root-relative to absolute paths since they're now resolved against a different cwd than before.
  • This script is a diagnostic/Codecov-harvesting step (npm run rees:coverage, uploaded with || true in CI since c8 instrumentation is known to blow timing-sensitive budgets) — it is not the actual REES gate (npm --prefix review-enrichment test, unaffected by this bug and already passing).

Test plan

  • node --experimental-strip-types scripts/rees-coverage.ts — 1376/1376 pass, 0 failures (previously 1 ENOENT failure)
  • npm run test:node --prefix review-enrichment — same test count, clean pass, confirms parity
  • lcov.info's SF: lines all remain review-enrichment/src/** (unchanged from pre-fix behavior)
  • npx tsc --noEmit clean

spawnSync ran c8 and the node:test child it wraps with the same cwd
(the monorepo root), needed so c8's lcov SF: paths remap to
review-enrichment/src/** for Codecov. But that left the actual test
process running from the wrong directory, so tests that read fixtures
via bare relative paths (e.g. analyzer-metadata.test.ts reading
"analyzer-metadata.json") failed with ENOENT even though the fixture
exists at review-enrichment/analyzer-metadata.json.

Preload a small --require script into only the spawned test child to
chdir it into review-enrichment/ before node:test loads any files,
leaving c8's own process cwd (and therefore its SF: path remapping)
untouched. Test file arguments switch from root-relative to absolute
paths since they're now resolved from a different cwd.
@superagent-security

Copy link
Copy Markdown
Contributor

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

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

loopover-orb Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-25 09:49:30 UTC

2 files · 1 AI reviewer · 2 blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This is a narrow, well-traced fix for a real cwd bug in the diagnostic REES coverage harvester: c8 needs to run from the monorepo root for lcov SF: path remapping, but that same cwd broke tests that read fixtures via bare relative paths. The fix isolates the chdir to only the spawned node:test child via a --require preload (rees-coverage-chdir.cjs), leaving c8's own process cwd untouched, and correctly switches the test path list from root-relative to absolute since the child's cwd changed. The change is internally consistent — normalizeLcovSfPaths still operates on the c8 process's lcov output at the root cwd, unaffected by the child's chdir — and the PR's own test plan (1376/1376 passing, unchanged lcov SF: paths, clean tsc) supports the claimed fix.

Nits — 6 non-blocking
  • The PR doesn't cite an issue number for this specific bug (the fix(ci): review-enrichment's real node:test coverage is invisible to Codecov (83 of 83 files effectively unmeasured) #6250 reference in comments is for the original coverage-harvesting feature, not this ENOENT fix) — worth confirming there's a linked issue per repo convention.
  • rees-coverage-chdir.cjs and rees-coverage.ts duplicate the same lcov-remap-and-cwd-juggling pattern already present in scripts/control-plane-coverage.mjs; consider extracting a shared coverage-harness helper to avoid drift between the two scripts (nit, not blocking given they're independent per-package scripts today).
  • No test coverage exists for rees-coverage.ts/rees-coverage-chdir.cjs themselves, though this is consistent with control-plane-coverage.mjs also being untested tooling outside src/**.
  • Consider a small shared module (e.g. scripts/coverage-harness.mjs) exporting collectTests/normalizeLcovSfPaths logic used by both rees-coverage.ts and control-plane-coverage.mjs to reduce duplication.
  • Add a one-line comment in rees-coverage.ts near the `--require chdirPreload` invocation cross-referencing rees-coverage-chdir.cjs's own comment, so a future reader sees both halves of the cwd split without opening two files.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.

Concerns raised — review before merging

  • No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example Closes #123) before opening the PR.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example `Closes #123`) before opening the PR.

Decision drivers

  • ❌ Code review — 2 blockers (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 13 registered-repo PR(s), 13 merged, 250 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 13 PR(s), 250 issue(s).
Improvement ℹ️ None detected risk: low · value: none · LLM: moderate
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 13 PR(s), 250 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Then work through the remaining 2 steps 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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> 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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 25, 2026
@JSONbored
JSONbored merged commit d0d8c10 into main Jul 25, 2026
5 checks passed
@JSONbored
JSONbored deleted the fix/rees-coverage-cwd branch July 25, 2026 10:05
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. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant