Skip to content

fix(signals): flag the .at(-1)/.at(0) idiom in boundary-test-generation - #6006

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix-boundary-at-v2
Jul 15, 2026
Merged

fix(signals): flag the .at(-1)/.at(0) idiom in boundary-test-generation#6006
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix-boundary-at-v2

Conversation

@lourincedaging0-commits

Copy link
Copy Markdown
Contributor

Summary

ARRAY_INDEX_BOUNDS_PATTERN in src/signals/boundary-test-generation.ts (the array/index-bounds detector for the #1972 boundary-safe test-generation signal) matched bracket-index forms (arr[arr.length - 1], arr[-1]) and .length comparisons, but not the modern Array.prototype.at() idiom (arr.at(-1), arr.at(0)) — the standard JS/TS way to express exactly the last-element/off-by-one access this detector exists to flag. Verified: ARRAY_INDEX_BOUNDS_PATTERN.test("items.at(-1)") returned false, so that access silently evaded the signal.

Fix

Add a \.at\(\s*-?\d+\s*\) alternative. Kept narrow per the module's own design principle ("deliberately SMALL and PRECISE — false positives are worse than a narrow true-positive set", #1972): only a numeric literal argument (optionally negative) matches. A bare identifier like .at(idx) carries none of the specific -1/0 boundary signal and matching it would reintroduce false-positive noise. Single additive regex alternative — no other pattern, BOUNDARY_PATTERNS, MAX_TOUCHES, or added-line-only scanning touched.

Tests

Extends test/unit/boundary-test-generation.test.ts: array_index_bounds now fires for items.at(-1), items.at(0), rows.at(-2); a negative test confirms .at(idx) (non-literal) does not trigger. All existing bracket-index / .length tests pass unmodified. 100% line coverage on the touched module locally.

Closes #5843

ARRAY_INDEX_BOUNDS_PATTERN in boundary-test-generation.ts caught bracket-index
boundary forms (arr[arr.length - 1], arr[-1]) and .length comparisons but not
the modern Array.prototype.at() idiom (arr.at(-1), arr.at(0)) — the standard
JS/TS way to express exactly the last-element/off-by-one access this detector
exists to flag, so that access silently evaded the boundary-safe
test-generation signal (JSONbored#1972).

Add a `\.at\(\s*-?\d+\s*\)` alternative. Kept narrow per the module's stated
"small and precise, false positives worse than missed positives" design: only
a numeric literal argument (optionally negative) matches — a bare identifier
like `.at(idx)` carries none of the specific -1/0 boundary signal and would
reintroduce false-positive noise. Single-pattern additive change; no other
pattern, BOUNDARY_PATTERNS, MAX_TOUCHES, or added-line scanning touched.
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.15%. Comparing base (f56edd2) to head (c86d489).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6006   +/-   ##
=======================================
  Coverage   95.15%   95.15%           
=======================================
  Files         589      589           
  Lines       46827    46827           
  Branches    14959    14959           
=======================================
  Hits        44560    44560           
  Misses       1511     1511           
  Partials      756      756           
Flag Coverage Δ
shard-1 43.48% <100.00%> (-0.42%) ⬇️
shard-2 35.61% <100.00%> (-0.83%) ⬇️
shard-3 32.80% <100.00%> (+0.81%) ⬆️
shard-4 32.01% <100.00%> (+0.05%) ⬆️
shard-5 32.24% <100.00%> (-0.22%) ⬇️
shard-6 44.91% <100.00%> (+0.18%) ⬆️

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

Files with missing lines Coverage Δ
src/signals/boundary-test-generation.ts 97.14% <100.00%> (ø)

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

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-15 06:51:25 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Adds a single regex alternative (`\.at\(\s*-?\d+\s*\)`) to ARRAY_INDEX_BOUNDS_PATTERN in src/signals/boundary-test-generation.ts so the `.at(-1)`/`.at(0)` idiom is now flagged, matching the existing narrow-scope design (numeric literal only, no bare identifiers). The added tests directly exercise the new alternative (positive cases for `.at(-1)`, `.at(0)`, `.at(-2)`, and a negative case for `.at(idx)`) and correctly validate the regex boundary. This is a minimal, well-targeted, low-risk change that closes the stated gap without touching any other pattern or scanning logic.

Nits — 3 non-blocking
  • The pattern won't match `.at(+1)` with an explicit plus sign, though this is an edge case with no real-world prevalence and consistent with the module's narrow-by-design philosophy.
  • Consider a brief comment noting that `\d+` intentionally excludes decimal/float arguments like `.at(1.5)`, though such usage would be unusual for array indexing anyway.
  • No functional changes suggested — the diff is narrow, tested, and consistent with the module's existing conventions.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5843
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: 65 registered-repo PR(s), 26 merged, 4 issue(s).
Contributor context ✅ Confirmed Gittensor contributor lourincedaging0-commits; Gittensor profile; 65 PR(s), 4 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The diff adds the required \.at\(\s*-?\d+\s*\) alternative to ARRAY_INDEX_BOUNDS_PATTERN, leaving other patterns/BOUNDARY_PATTERNS untouched, and adds tests covering .at(-1), .at(0), .at(-2) positive matches plus a .at(idx) negative test as specified.

Review context
  • Author: lourincedaging0-commits
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 65 PR(s), 4 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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://gittensory.aethereal.dev/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 3db64d8 into JSONbored:main Jul 15, 2026
15 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.

fix(signals): boundary-test-generation's array-bounds pattern misses the .at(-1) idiom

1 participant