Skip to content

fix(engine): anchor objective-anchor's dependency-file regex to exact filenames - #8911

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/objective-anchor-dependency-anchor-8874
Jul 26, 2026
Merged

fix(engine): anchor objective-anchor's dependency-file regex to exact filenames#8911
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/objective-anchor-dependency-anchor-8874

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What & why

Closes #8874.

packages/loopover-engine/src/objective-anchor.ts's kindsFromPath classified any filename ending
in package.json/package-lock.json as a "dependency" change kind via an unanchored
/package(?:-lock)?\.json$/. A differently-prefixed sibling — mock-package.json,
sub-package.json — therefore got tagged "dependency", diluting that change-kind dimension that
scoreObjectiveAnchor relies on. This is inconsistent with the adjacent config check three lines
above in the same function, which uses exact-match CONFIG_FILENAMES set membership.

Change

Anchor the regex: /^package(?:-lock)?\.json$/u. Only the exact filenames package.json and
package-lock.json now classify as "dependency", matching the exact-match discipline already used
for the config check.

Validation

  • New negative test asserting sub-package.json/mock-package.json do not produce a
    "dependency" change-kind, while package.json/package-lock.json still do — added on both the
    engine's own suite (packages/loopover-engine/test/objective-anchor.test.ts) and the Codecov-graded
    vitest suite (test/unit/engine-objective-anchor-config-classification.test.ts).
  • Bug-catch verified: removing the ^ anchor fails exactly the new assertion in both runners.
  • 100% patch coverage on the changed line (both regex outcomes exercised).

… filenames

kindsFromPath tagged any path ending in package.json / package-lock.json as a
"dependency" change kind via an unanchored /package(?:-lock)?\.json$/, so a
differently-prefixed sibling like mock-package.json or sub-package.json was
misclassified -- inconsistent with the adjacent config check in the same
function, which uses exact-match CONFIG_FILENAMES set membership.

Anchor the regex (/^package(?:-lock)?\.json$/) so only the exact filenames
package.json and package-lock.json classify as "dependency".

Adds a negative test on both the engine's own suite and the Codecov-graded
vitest classification suite: package.json/package-lock.json still classify,
sub-package.json/mock-package.json no longer do.

Closes JSONbored#8874
@shin-core
shin-core requested a review from JSONbored as a code owner July 26, 2026 13:19
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 26, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.84%. Comparing base (8a3d2c9) to head (c4a0386).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8911   +/-   ##
=======================================
  Coverage   93.84%   93.84%           
=======================================
  Files         803      803           
  Lines       80084    80084           
  Branches    24277    24277           
=======================================
+ Hits        75157    75158    +1     
+ Misses       3562     3561    -1     
  Partials     1365     1365           
Flag Coverage Δ
backend 95.13% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/loopover-engine/src/objective-anchor.ts 28.33% <100.00%> (+4.16%) ⬆️

... and 1 file with indirect coverage changes

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

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-26 13:39:03 UTC

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

⏸️ Suggested Action - Manual Review

Review summary
This is a precise, minimal one-line regex fix: anchoring `/package(?:-lock)?\.json$/u` to `/^package(?:-lock)?\.json$/u` in kindsFromPath (packages/loopover-engine/src/objective-anchor.ts:238) so filenames like `sub-package.json` or `mock-package.json` no longer get misclassified as a `dependency` change kind, matching the exact-match discipline the adjacent CONFIG_FILENAMES check already uses. The fix is correct and traceable to the actual bug (an unanchored regex, not a downstream symptom), and it's backed by real negative-assertion tests in both the engine's node:test suite and the Codecov-graded vitest suite that would fail without the `^` anchor. The PR closes a linked issue (#8874), is narrowly scoped, and includes no unrelated changes.

Nits — 3 non-blocking
  • The vitest test file (test/unit/engine-objective-anchor-config-classification.test.ts) and the engine's own test/objective-anchor.test.ts duplicate the same assertion almost verbatim — acceptable per the stated Codecov-vs-node:test coverage rationale, but worth confirming that duplication is genuinely necessary rather than just belt-and-suspenders.
  • The FAILED 'Contributor trust' check has no detail provided and this branch is 6 commits behind default, so its cause can't be verified from what's given — likely stale-branch related, not a defect in this diff.
  • Consider also testing a case like `PACKAGE.JSON` (uppercase) if filename casing normalization matters elsewhere in the pipeline, though normalizePath already lowercases paths upstream so this is likely already covered.

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 #8874
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: 40 registered-repo PR(s), 25 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 40 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff anchors the regex to `/^package(?:-lock)?\.json$/u`, exactly matching the requested fix, and adds negative tests in both suites confirming `sub-package.json`/`mock-package.json` no longer produce a "dependency" change-kind while `package.json`/`package-lock.json` still do.

Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 40 PR(s), 0 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 added the manual-review Gittensor contributor context label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Held for manual review: the gate and required CI are green, but GitHub reports this pull request's mergeable state as unstable because a non-required check or status is not passing, so LoopOver will not auto-merge. A maintainer can resolve the failing check or review and merge manually. This is an automated maintenance action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. 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.

fix(engine): objective-anchor's unanchored "dependency" regex over-matches beyond package.json/package-lock.json

2 participants