Skip to content

chore(review): delegate diffFilePriority's lockfile match to the canonical isLockfile#8427

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-lockfile-dedup-8357
Jul 24, 2026
Merged

chore(review): delegate diffFilePriority's lockfile match to the canonical isLockfile#8427
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-lockfile-dedup-8357

Conversation

@RealDiligent

@RealDiligent RealDiligent commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • diffFilePriority (src/review/review-diff.ts) hand-rolled a 31-alternative lockfile-name regex duplicating the canonical LOCKFILE_NAMES set exported by packages/loopover-engine/src/signals/path-matchers.ts. Any future ecosystem addition to the canonical set (which has been extended in batches before — cartfile.resolved/gopkg.lock/shard.lock/rebar.lock/renv.lock/chart.lock landed together) would silently not be reflected here, ranking the new format as SOURCE(0) — highest priority, survives budget trimming — instead of GENERATED(4), dropped first.
  • This is precisely the drift class this function's own header already documents fixing once for test-file detection (isTestPath), and a prior real instance of it in this same function is fix(engine): diffFilePriority's vendored-directory pattern misses vendored/third_party/third-party/bower_components/jspm_packages #7526.
  • Delegates the lockfile-name portion to isLockfile, imported through the src/signals/path-matchers re-export shim — the same engine-consumption convention this file already uses for isTestPath via src/signals/test-evidence.
  • The suffix-based generated-file matching (.min.js / .min.css / .map / .snap) is preserved inline, as required; only the name list moved.

Behavior-change check (as the issue requires): I diffed the two lists programmatically — the canonical LOCKFILE_NAMES set and the inline regex alternation are identical, 31 entries each, zero differences in either direction. Case-insensitivity is also preserved: the old regex used /i, and isLockfile matches the basename after normalize(), which lowercases. So this is a pure behavior-preserving delegation, and no existing test relies on a lockfile name isLockfile does not recognizetest/unit/review-diff.test.ts's lockfile cases (package-lock.json, plus the bun.lock/uv.lock/deno.lock/flake.lock/mix.lock/chart.lock sweep) all pass unchanged.

Closes #8357

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • This diff touches the three diffFilePriority copies, the engine-parity marker, and that marker's test (see the scope note above), so actionlint (no workflow change), build:mcp/test:mcp-pack (no MCP change), ui:* (no UI/OpenAPI change), test:workers (no worker change), and npm audit (no dependency change) are not exercised by it.
  • No new test, deliberately: this is a behavior-preserving delegation with the lists proven identical, and the issue's deliverable is to confirm the existing cases still pass unchanged — they do (test/unit/review-diff.test.ts, 23 tests, including the dedicated "ranks every path-matchers lockfile as noise(4)" sweep, which is exactly the test that now protects the delegation).
  • Diff coverage verified at 100%, lines and branches, via the scoped simulation CI runs (vitest run --coverage --coverage.all=false): the changed condition's branches are all exercised by existing tests — isLockfile true (short-circuit), isLockfile false with the suffix regex true (.map/.snap/.min.js), and both false (source files). Root tsc --noEmit is clean.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Not applicable — backend refactor in src/review/; no visible UI, frontend, docs, or extension change.

Scope note — why this touches more than review-diff.ts (CI-driven)

The issue scoped the change to review-diff.ts line 24. That alone fails CI, and finding out why changed the shape of the fix, so flagging it explicitly:

diffFilePriority is duplicated by function, not by file — three copies: src/review/review-diff.ts, src/review/review-grounding.ts (byte-identical host copy), and packages/loopover-engine/src/review/diff-file-priority.ts. scripts/check-engine-parity.ts registers the first and third as a named twin pair and asserts both contain the literal marker cartfile\.resolved — a deliberate regression guard for #4605 Finding 1, where the engine copy's Carthage regex had silently drifted to cartfile\.lock (not a real filename).

Delegating only review-diff.ts deletes that literal from one twin (validate-code fails: "missing expected twin-pair marker") and leaves the other two copies still hand-rolling the very list the issue wants de-duplicated — a worse state than before. So this PR:

  1. Delegates lockfile-name matching to canonical isLockfile in all three copies.
  2. Retargets the twin-pair marker from cartfile\.resolved to isLockfile(path).
  3. Updates that marker test's synthetic host body to match.

This strengthens the guard rather than weakening it. #4605 was caused by a copy owning a private, hand-maintained name list that could drift. After this change no copy owns one, so that drift is structurally impossible instead of merely detected for one sampled filename — and the marker now asserts the delegation itself, which is what actually prevents the bug class. I deliberately did not simply delete the marker or park the literal in a comment to make the gate pass.

Verification: npx tsx scripts/check-engine-parity.ts reports zero marker failures (both twins carry both markers). The script's other output — 25 "drifted apart (normalized comparison)" lines across unrelated pairs (slop.ts, test-evidence.ts, …) — reproduces identically on clean origin/main on my Windows checkout (a CRLF artifact of the normalized compare), as does check-engine-parity-script.test.ts (8 failed / 33 passed on both baseline and this branch). So this PR introduces no new parity failure. review-diff.test.ts + review-grounding.test.ts pass in full (73 tests) and root tsc --noEmit is clean.

Notes

  • packages/loopover-engine/src/signals/path-matchers.ts is untouched — it is the canonical source this now defers to.
  • The import goes through src/signals/path-matchers.ts (the thin re-export shim) rather than the engine's dist/, matching that shim's own documented rationale: the built output is not guaranteed to exist when typecheck/test:coverage run in CI.

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 24, 2026 12:48
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8427   +/-   ##
=======================================
  Coverage   92.42%   92.42%           
=======================================
  Files         791      791           
  Lines       79294    79294           
  Branches    23950    23951    +1     
=======================================
  Hits        73291    73291           
  Misses       4866     4866           
  Partials     1137     1137           
Flag Coverage Δ
shard-1 57.76% <66.66%> (-0.01%) ⬇️
shard-2 47.68% <33.33%> (ø)
shard-3 56.57% <66.66%> (ø)

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

Files with missing lines Coverage Δ
...s/loopover-engine/src/review/diff-file-priority.ts 100.00% <100.00%> (ø)
src/review/review-diff.ts 96.00% <100.00%> (ø)
src/review/review-grounding.ts 99.02% <100.00%> (ø)

@RealDiligent
RealDiligent force-pushed the fix/critical-issue-lockfile-dedup-8357 branch from c2f1bdf to eac57ad Compare July 24, 2026 13:04
RealDiligent added 2 commits July 24, 2026 21:08
…nical isLockfile

diffFilePriority hand-rolled a 31-name lockfile regex duplicating the canonical
LOCKFILE_NAMES set, so any future ecosystem addition to the shared set would
silently not be reflected here and the new format would rank as SOURCE(0)
instead of GENERATED(4) -- surviving budget trimming ahead of real source. This
is the same drift class this function's header documents already fixing once for
test-file detection.

Delegates the lockfile-name portion to isLockfile via the src/signals
re-export shim, matching how isTestPath is consumed. The suffix-based
.min.js/.min.css/.map/.snap matching stays inline.

Closes JSONbored#8357
…get the parity marker

CI's check-engine-parity gate failed: diffFilePriority is duplicated by FUNCTION
across three copies (review-diff.ts, review-grounding.ts, and the engine's
diff-file-priority.ts), and the named twin-pair guard asserts a literal
cartfile\.resolved marker in both twins. Delegating only review-diff.ts removed
that literal and left the other copies still hand-rolling the list.

Delegates all three to the canonical isLockfile and retargets the marker to
isLockfile(path). That guards the JSONbored#4605 Finding 1 regression at its root: the
bug was a hand-rolled name list drifting, and no copy owns one now, so asserting
the delegation is strictly stronger than asserting one name inside a private
regex. Updates the marker test's synthetic host body to match.
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 13:35:17 UTC

5 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR delegates the hand-rolled 31-name lockfile regex in three duplicated `diffFilePriority` copies (review-diff.ts, review-grounding.ts, diff-file-priority.ts) to the canonical `isLockfile`/`LOCKFILE_NAMES` matcher, mirroring the existing `isTestPath` delegation pattern in the same functions. The suffix-based generated-file matching (`.min.js`/`.min.css`/`.map`/`.snap`) is correctly preserved inline as the description promises, and the parity-script marker/test updates (swapping the `cartfile.resolved` literal marker for an `isLockfile(path)` presence marker) correctly generalize the #4605 regression guard to the new delegation pattern. The change closes #8357 directly and is a clean, well-scoped root-cause fix rather than a symptom patch.

Nits — 4 non-blocking
  • The PR description's behavior-preservation claim rests on an external diff of the two 31-entry lists that isn't independently verifiable from the diff alone — worth double-checking `isLockfile`'s case-insensitivity claim against `packages/loopover-engine/src/signals/path-matchers.ts` directly.
  • test/unit/review-diff.test.ts's existing lockfile assertions (bun.lock, uv.lock, etc.) already cover the delegated path, but no new test explicitly asserts a *new* addition to LOCKFILE_NAMES automatically flows through without a corresponding change to review-diff.ts/review-grounding.ts — a direct test of that claim would strengthen the regression guard this PR is motivated by.
  • Consider adding one test that adds a hypothetical entry to LOCKFILE_NAMES's consuming set (or asserts `diffFilePriority` output for every LOCKFILE_NAMES entry) to prove the delegation is truly drift-proof, not just currently in sync.
  • The parity script's DIFF_FILE_PRIORITY_MARKERS check for the literal string `isLockfile(path)` is a reasonable presence guard but is easy to defeat with a reformatted call (e.g. `isLockfile( path )`); low priority given the byte-identical drift check already covers full-body divergence.

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 #8357
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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 354 registered-repo PR(s), 137 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 354 PR(s), 37 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff replaces the inline lockfile regex in review-diff.ts's diffFilePriority with a call to the canonical isLockfile, preserves the suffix-based generated-file matching inline, and the PR description confirms no behavior change against existing test cases as the issue required.

Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Ruby, JavaScript, Svelte, TypeScript, Cuda, Markdown, MDX
  • Official Gittensor activity: 354 PR(s), 37 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
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

@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 7cf89c6 into JSONbored:main Jul 24, 2026
12 checks passed
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.

chore(review): diffFilePriority's hand-rolled lockfile regex duplicates (and can drift from) the canonical LOCKFILE_NAMES set

1 participant