Skip to content

fix(review): make engine-parity's directory scan recursive - #4654

Merged
JSONbored merged 1 commit into
mainfrom
fix/engine-parity-recursive-listdir
Jul 10, 2026
Merged

fix(review): make engine-parity's directory scan recursive#4654
JSONbored merged 1 commit into
mainfrom
fix/engine-parity-recursive-listdir

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What

Completes #4605's third acceptance criterion. PR #4638 already shipped the other two (the Carthage
cartfile\.lockcartfile\.resolved regex fix, and named-pair coverage for the specific already-known
nested/renamed duplicates: safe-url.ts, diffFilePriority, sharesMeaningfulFile) — that PR merged
before this piece was caught as missing by independent review, so #4605 was reopened to track just this
remaining scope.

discoverEngineParityPairs only listed the immediate children of each src/{review,settings,signals}
area directory, so a hand-duplicated pair nested one directory deeper on both sides was invisible to the
scan by construction, even though the existing shim/stub filters would handle it correctly once
discovered.

Fix

collectTsFilesRecursive walks the tree via the same pluggable listDir(root, relativePath) shape the
function already accepted — a .ts-suffixed entry is a leaf, anything else is probed with another
listDir call and treated as a subdirectory only if that returns ≥1 entry (reusing defaultListDir's
existing resolve-to-[] convention for non-directories, no new stat call needed). Pairing is now by
identical relative sub-path on both sides, not bare filename — so a depth mismatch (e.g. safe-url.ts
nested under content-lane/ on the host but flat on the engine) still correctly falls through to its
NAMED_TWIN_PAIRS entry rather than going undiscovered or getting falsely paired with an unrelated
same-named file elsewhere in the tree.

Testing

4 new tests: nested-pair discovery on both sides, depth-mismatch still invisible (regression guard for
the safe-url.ts case), non-.ts/non-directory entries handled without recursing, and the existing
safe-url.ts non-discovery assertion re-confirmed against the real repo. All 34 tests in
check-engine-parity-script.test.ts pass, including the 2 pre-existing regression guards (real-repo pair
count, real-repo zero-drift). Coverage confirmed 100% on every new/changed line (the file's global branch
coverage number reported by vitest reflects pre-existing uncovered branches elsewhere in the file, not
this diff). Typecheck clean.

Part of #4605

discoverEngineParityPairs only listed the immediate children of each
src/{review,settings,signals} area directory, so a hand-duplicated pair
nested one directory deeper on both sides was invisible to the scan by
construction -- even though the existing shim/stub filters would have
handled it correctly once discovered. #4605's own Finding 1 (the
Cartfile.resolved regex typo) was found by manual audit rather than this
tripwire precisely because that class of duplicate lives in files the
directory-only scan can't see.

collectTsFilesRecursive walks the tree via the same pluggable listDir(root,
relativePath) shape the function already accepted, treating a `.ts`-suffixed
entry as a leaf and any other entry as a directory only if listDir on it
returns at least one entry -- reusing defaultListDir's existing
resolve-to-[] convention for non-directories rather than requiring a stat
call. Pairing is now by identical relative sub-path on both sides, not bare
filename, so a depth MISMATCH (e.g. safe-url.ts nested under
content-lane/ on the host but flat on the engine) still correctly falls
through to its NAMED_TWIN_PAIRS entry rather than silently going
undiscovered OR getting falsely paired with an unrelated same-named file
elsewhere in the tree.

Completes #4605's third acceptance criterion (PR #4638 shipped the other
two: the regex fix itself and named-pair coverage for the specific
already-known nested/renamed duplicates).

Part of #4605
@superagent-security

Copy link
Copy Markdown
Contributor

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

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

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.11%. Comparing base (bda42f7) to head (7508bd1).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4654   +/-   ##
=======================================
  Coverage   94.11%   94.11%           
=======================================
  Files         433      433           
  Lines       38494    38494           
  Branches    14037    14037           
=======================================
  Hits        36229    36229           
  Misses       1604     1604           
  Partials      661      661           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb

loopover-orb Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-10 09:47:54 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR extends discoverEngineParityPairs to recursively walk nested subdirectories via a new collectTsFilesRecursive helper, closing the third acceptance criterion of #4605 that #4638 missed. The recursion correctly reuses the existing listDir/defaultListDir convention (a non-directory path resolves to []) to avoid an extra stat call, and pairing now matches on relative sub-path rather than bare filename, so a depth mismatch (e.g. content-lane/safe-url.ts on the host vs a flat file on the engine) correctly stays undiscovered and still requires its own NAMED_TWIN_PAIRS entry. The 4 new tests exercise the real discoverEngineParityPairs path (nested-both-sides discovery, depth-mismatch non-discovery, non-.ts leaf handling, and a real-repo safe-url.ts re-confirmation) rather than fabricating unreachable states, and CI is green on this commit.

Nits — 4 non-blocking
  • scripts/check-engine-parity.ts: pairs[].fileName now holds a relative sub-path (e.g. "sub/nested.ts") instead of a bare filename — worth confirming no caller outside this diff still assumes fileName is a bare filename before merging.
  • scripts/check-engine-parity.ts collectTsFilesRecursive: an empty real subdirectory and a non-directory entry are indistinguishable under the listDir → [] convention; the doc comment calls this out as harmless, which is correct, but it's worth a short inline comment at the call site too since it's a subtle invariant future editors of listDir could break.
  • Add a one-line @​param/@​returns on collectTsFilesRecursive noting the returned strings are root-relative (not area-relative) paths, since that's easy to get wrong for a future caller.
  • The magic-number brief flagging `4605` at scripts/check-engine-parity.ts:177 is a false positive — it's an issue-number reference inside a doc comment, not a logic literal; no action needed.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
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: 48 registered-repo PR(s), 40 merged, 330 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 330 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
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: not available
  • Official Gittensor activity: 48 PR(s), 330 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 10, 2026
@JSONbored
JSONbored merged commit d571d80 into main Jul 10, 2026
11 checks passed
@JSONbored
JSONbored deleted the fix/engine-parity-recursive-listdir branch July 10, 2026 09:52
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

Development

Successfully merging this pull request may close these issues.

Fix engine-parity diffFilePriority typo; make drift-check recursive/function-aware

1 participant