Skip to content

fix(engine): validate metadata candidate paths - #3950

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-metadata-lane-fit-scoring-vulnerability
Jul 7, 2026
Merged

fix(engine): validate metadata candidate paths#3950
JSONbored merged 1 commit into
mainfrom
codex/fix-metadata-lane-fit-scoring-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent runtime crashes and incorrect per-character path scoring when candidatePaths metadata is malformed or non-array by applying the repository's usual array guard pattern.
  • Keep path-aware lane-fit behavior when callers supply a proper string-array while ensuring malformed inputs gracefully fall back to label-only scoring.

Description

  • Change normalizeCandidatePaths in packages/gittensory-engine/src/miner-goal-lane-fit.ts to accept unknown and return [] when !Array.isArray(paths), preserving trimming and skipping of non-string/blank entries.
  • Route computeMetadataLaneFit through the revised normalizer so non-array candidatePaths no longer throw or iterate strings character-by-character.
  • Add regression tests covering malformed inputs (non-string entries, object value, and string value) in packages/gittensory-engine/test/miner-goal-lane-fit.test.ts and the root unit test test/unit/miner-goal-lane-fit.test.ts to ensure malformed metadata falls back to label-only scoring.

Testing

  • Ran npx vitest run test/unit/miner-goal-lane-fit.test.ts, which passed locally.
  • Ran npm --workspace @jsonbored/gittensory-engine run build, which completed successfully.
  • Running npm --workspace @jsonbored/gittensory-engine test -- miner-goal-lane-fit.test.ts hit unrelated package test type-check failures in other tests (pre-existing) before the targeted package test could complete.
  • Running the full gate with npm run test:ci progressed to coverage but was interrupted by an existing RangeError: Maximum call stack size exceeded coming from unrelated test/unit/queue.test.ts, so the full CI run could not be completed here.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 7, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui ca26ea5 Commit Preview URL

Branch Preview URL
Jul 07 2026, 07:41 AM

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3950   +/-   ##
=======================================
  Coverage   93.66%   93.66%           
=======================================
  Files         372      372           
  Lines       34856    34856           
  Branches    12743    12743           
=======================================
  Hits        32649    32649           
  Misses       1588     1588           
  Partials      619      619           
Files with missing lines Coverage Δ
...kages/gittensory-engine/src/miner-goal-lane-fit.ts 90.90% <100.00%> (ø)
🚀 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 added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-07 07:52:11 UTC

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

⏸️ 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 is a legitimate, narrowly-scoped bug fix: `normalizeCandidatePaths` in packages/gittensory-engine/src/miner-goal-lane-fit.ts now accepts `unknown` and guards with `Array.isArray`, so a non-array `candidatePaths` (object, string, etc.) falls back to `[]` and label-only scoring instead of throwing (iterating a non-iterable object) or silently mis-scoring by iterating a string's individual characters as path segments. The fix is applied at the correct layer (the normalizer itself, which is the sole call site feeding `computeMetadataLaneFit`), and the new tests in both test files exercise the previously-broken object and string cases in addition to the pre-existing malformed-array-entries case. The change is small, correct, and directly matches its description.

Nits — 4 non-blocking
  • packages/gittensory-engine/test/miner-goal-lane-fit.test.ts: the new malformed-values test adds `blockedPaths`/`wantedPaths` to the spec, but since normalization reduces malformed `candidatePaths` to an empty array, `computeMetadataLaneFit` takes the label-only fallback branch and never exercises `computeLaneFit`, so those fields are inert test noise.
  • The same duplicated test bodies across packages/gittensory-engine/test/miner-goal-lane-fit.test.ts and test/unit/miner-goal-lane-fit.test.ts (pre-existing repo pattern) mean any future signature change to computeMetadataLaneFit requires updating both files in lockstep.
  • Consider adding a one-line comment at the normalizeCandidatePaths guard (src/miner-goal-lane-fit.ts:57) noting that a bare string is a valid JS array-like but must be excluded, since that's the least obvious of the three malformed shapes being guarded against.
  • Drop the unused blockedPaths/wantedPaths additions in the malformed-values test spec objects, or add an assertion that actually exercises them, to keep the test intent unambiguous.

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: 51 registered-repo PR(s), 43 merged, 343 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 343 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: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 343 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 7, 2026
@JSONbored
JSONbored merged commit 8d507ae into main Jul 7, 2026
12 checks passed
@JSONbored
JSONbored deleted the codex/fix-metadata-lane-fit-scoring-vulnerability branch July 7, 2026 08:00
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.

1 participant