Skip to content

test(scoring): cover pending-pr-scenarios' ghost-login and case-insensitive matching#8528

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-pending-pr-cov-8329
Jul 24, 2026
Merged

test(scoring): cover pending-pr-scenarios' ghost-login and case-insensitive matching#8528
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-pending-pr-cov-8329

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

src/scoring/pending-pr-scenarios.ts's two filter helpers had untested defensive behavior:

function sameRepoFullName(left: string, right: string): boolean {
  return left.toLowerCase() === right.toLowerCase();
}
function sameLogin(value: string | null | undefined, login: string): boolean {
  return Boolean(value && value.toLowerCase() === login.toLowerCase());
}
  • sameLogin's value && short-circuit exists because PullRequestRecord.authorLogin is string | null | undefined — a real case for ghost/deleted GitHub accounts. Without it, a null login would throw on .toLowerCase().
  • Both helpers lowercase before comparing because GitHub treats owner/repo and logins case-insensitively while stored values aren't guaranteed consistently cased.

Every existing test passed a concrete, identically-cased login and repo name, so neither behavior was pinned.

Adds a single case covering all four situations the issue lists, asserting through loadContributorRepoOpenPrSignalRecords:

Record Expected
authorLogin: null excluded (short-circuit, no throw)
authorLogin: undefined excluded
repoFullName: "Entrius/Allways-UI" vs query "entrius/allways-ui" included
authorLogin: "Miner-A" vs query "miner-a" included

The mock returns a review keyed to the requested pull number, so the assertion reads back the exact set of records that survived the filter ([82, 83]) rather than inferring inclusion from an array length.

Verified the test pins the behavior, rather than passing alongside it — each helper was reverted independently and the test failed both times:

Reverted Result
sameLogin short-circuit → (value as string).toLowerCase() fails
sameRepoFullName normalization → left === right fails

Closes #8329

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:

  • Test-only diff (one file, +28 lines): no workflow, MCP, UI, worker, or dependency surface is touched, so those checks are not exercised. Root tsc --noEmit is clean and git diff --check passes.
  • codecov/patch has no changed production lines to score. The scoped coverage run emits a non-empty coverage/lcov.info containing src/scoring/pending-pr-scenarios.ts (the suite imports it directly), satisfying the "Verify coverage report exists" step. test/unit/pending-pr-scenarios.test.ts passes in full — 18 tests.

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 — a unit-test addition; no visible UI, frontend, docs, or extension change.

Notes

  • authorLogin: null is passed as null as unknown as string because the pr() fixture's Partial<PullRequestRecord> narrows it, while the underlying PullRequestRecord.authorLogin really is string | null | undefined — the cast reproduces the genuine runtime shape the helper guards against, without loosening the fixture for every other test.

@superagent-security

Copy link
Copy Markdown
Contributor

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

…sitive matching

sameLogin's `value &&` short-circuit exists for PullRequestRecord.authorLogin
being string | null | undefined (ghost/deleted GitHub accounts), and both
helpers lowercase before comparing because GitHub treats owner/repo and logins
case-insensitively while stored values are not guaranteed consistent. Every
existing test passed a concrete, same-cased login, so neither behavior was
pinned.

Adds one case covering all four: null and undefined authorLogin are excluded,
and records differing only in repo-name or login case still match. The mock
returns a review keyed to the requested pull number, so the assertion reads
exactly which records survived the filter.

Closes JSONbored#8329
@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 18:39:21 UTC

1 file · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a pure test-addition PR that pins two previously-untested defensive branches in pending-pr-scenarios.ts: the ghost-account null/undefined login short-circuit and the case-insensitive repo/login matching. The test is well-constructed, keying mocked review responses to the requested PR number so inclusion is verified by exact PR-number set rather than array length, and the PR description documents that each helper was independently reverted to confirm the test actually fails without the fix. This closes issue #8329 and is narrowly scoped to the review-stack's test suite with no production code changes.

Nits — 2 non-blocking
  • The `authorLogin: null as unknown as string` cast in test/unit/pending-pr-scenarios.test.ts is a bit awkward; since `pr()`'s overrides type is `Partial<PullRequestRecord>` and `authorLogin` is typed `string | null | undefined` per the PR description, a direct `authorLogin: null` should type-check without the cast — worth double-checking if the cast is actually needed.
  • Consider asserting `records.pullRequestChecks` length in the new test too, for symmetry with the existing 'loads cached reviews and checks' test, since `listCheckSummaries` is also mocked here.

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 #8329
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: 366 registered-repo PR(s), 146 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 366 PR(s), 37 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: minor
Linked issue satisfaction

Addressed
The added test exercises all four requested cases (null authorLogin, undefined authorLogin, case-differing repoFullName, case-differing authorLogin) through loadContributorRepoOpenPrSignalRecords and asserts the correct include/exclude outcomes, matching the issue's requirements.

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: not available
  • Official Gittensor activity: 366 PR(s), 37 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://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 47daf90 into JSONbored:main Jul 24, 2026
6 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.

Add test coverage for pending-pr-scenarios.ts's null-login and case-insensitive matching branches

1 participant