Skip to content

fix(orb): exclude contributor self-closes from the public homepage counter - #1632

Merged
JSONbored merged 2 commits into
mainfrom
fix/orb-outcome-self-close-guard
Jun 28, 2026
Merged

fix(orb): exclude contributor self-closes from the public homepage counter#1632
JSONbored merged 2 commits into
mainfrom
fix/orb-outcome-self-close-guard

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

recordOrbPrOutcome (the central Orb's terminal-PR-outcome capture feeding the public homepage merged/closed/total counter) recorded a contributor closing their own unmerged PR as an authoritative closed. A contributor can inflate the public counter (or flip a repo's stats) by opening + self-closing PRs — the same poisoning the cloud recordPrOutcome path already guards against, here on the more-visible metric.

Add the same anti-poisoning guard: when the close is unmerged, the actor is not a Bot, and sender.login === pull_request.user.login, early-return (record nothing, leave any prior authoritative row untouched). Merges stay trusted (GitHub enforces merge permission); maintainer and bot closes are authoritative and still recorded.

Surfaced by the 2026-06-27 review-pipeline hardening audit (accuracy).

Scope

  • Conventional Commit title; focused (orb/outcomes.ts + its test).
  • No site//CNAME/Pages; follows CONTRIBUTING.md.
  • Small self-evident parity fix (mirrors the existing cloud guard; no separate issue needed).

Validation

  • git diff --check · actionlint · typecheck
  • test:coverage — new tests cover every arm of the guard: self-close (records nothing + never overwrites a prior maintainer row), maintainer close (sender≠author → recorded), bot-actor close (recorded even when login matches), close with no author field (not a self-close → recorded); the existing merged + no-sender closed tests cover the !merged and falsy-sender short-circuits.
  • test:workers · build:mcp · test:mcp-pack · ui:* · npm audit --audit-level=moderate

If any required check was skipped, explain why:

  • No migration/OpenAPI/cf-typegen: a guard on existing logic only.

Safety

  • No secrets/wallets/trust-scores exposed.
  • No public GitHub text change · auth/CORS N/A — this hardens the integrity of a public metric (anti-poisoning).

Notes

  • Runs on the cloud Orb (gittensory-api), which auto-deploys on merge.

…unter

recordOrbPrOutcome (the central Orb's terminal-outcome capture feeding the
public homepage merged/closed/total counter) recorded a contributor closing
their OWN unmerged PR as an authoritative 'closed' — a contributor could inflate
the public counter by opening + self-closing PRs. Add the same anti-poisoning
guard the cloud recordPrOutcome path uses: when the close is unmerged, the actor
is not a Bot, and sender.login === pull_request.user.login, early-return (record
nothing, leave any prior authoritative row untouched). Merges stay trusted;
maintainer + bot closes remain authoritative.
@dosubot dosubot Bot added the size:S label Jun 27, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@JSONbored JSONbored self-assigned this Jun 27, 2026
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.53%. Comparing base (758e524) to head (d3e0502).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1632   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files         204      204           
  Lines       22084    22089    +5     
  Branches     7972     7975    +3     
=======================================
+ Hits        21097    21102    +5     
  Misses        412      412           
  Partials      575      575           
Files with missing lines Coverage Δ
src/orb/outcomes.ts 87.50% <100.00%> (+5.68%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 28, 2026
@loopover-orb

loopover-orb Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Tip

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

✅ Gittensory review — safe to merge

2 files · 1 AI reviewers · no blockers · readiness 48/100 · CI green · clean

✅ Approved — safe to merge

Review summary
Straightforward parity port of the cloud `recordPrOutcome` anti-poisoning guard to the Orb path. The guard logic is correct: `.toLowerCase()` comparison handles GitHub's case-insensitive logins, the `botWasActor` exemption correctly bypasses the guard for Bot-typed senders even when their login matches the PR author, and the `senderLogin && authorLogin` truthiness checks fail-open (record) when either identity is absent — the right call for a public integrity counter. Tests cover every new branch with real-path payloads and no fabricated impossible states; no schema change means no migration needed.

Signal Result Evidence
Code review ✅ No blockers 1 reviewers, synthesized
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Review load ❌ 8/20 Readiness component derived from cached public PR metadata and labels; size label size:S.
Validation evidence ❌ 5/25 Cached preflight status is hold.
Open PR queue ❌ 3/10 34 open PR(s), 17 likely reviewable, 17 unlinked.
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 80 PR(s), 291 issue(s).
Gate result ✅ Passing No configured blocker found.
Nits — 5 non-blocking
  • test/integration/orb-outcomes.test.ts (authoritative-cases `it`, ~line 66): the single `COUNT(*) = 3` assertion bundles three semantically distinct exemptions — maintainer close, bot-actor close, no-author close — into one count; a single-sub-case regression will not self-identify, requiring a manual bisect. Consider three targeted `expect` calls or three `it` blocks.
  • src/orb/outcomes.ts (lines 19–21): the three-line comment block is the longest in the file; 'mirrors the cloud recordPrOutcome anti-poisoning guard — merges stay trusted, bot/maintainer closes are authoritative' covers the intent in one line. The remaining sentences restate the code.
  • test/integration/orb-outcomes.test.ts: the sender-absent-but-author-present case (`{ author: 'alice' }`, no `sender` key) is not explicitly exercised in the new tests; it's covered incidentally by the existing pre-guard tests, but an explicit one-liner would nail the `senderLogin = ''` short-circuit branch in the new guard.
  • test/integration/orb-outcomes.test.ts (~line 66): split the three authoritative sub-cases into separate assertions so a regression names itself — e.g. `expect(await db(e)...WHERE pr_number=21...n).toBe(1)` repeated for 22 and 23.
  • test/integration/orb-outcomes.test.ts: add `closedPr('acme/nosender', 24, null, 100, { author: 'alice' })` → assert `COUNT(*) = 1` to explicitly document and lock the fail-open behavior when the sender field is absent.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Review top overlaps.
  • Add scope summary.
  • Fix blocker.
  • Expect slower review.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review details

Generated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative.

Straightforward parity port of the cloud `recordPrOutcome` anti-poisoning guard to the Orb path. The guard logic is correct: `.toLowerCase()` comparison handles GitHub's case-insensitive logins, the `botWasActor` exemption correctly bypasses the guard for Bot-typed senders even when their login matches the PR author, and the `senderLogin && authorLogin` truthiness checks fail-open (record) when either identity is absent — the right call for a public integrity counter. Tests cover every new branch with real-path payloads and no fabricated impossible states; no schema change means no migration needed.

Nits (5)

  • test/integration/orb-outcomes.test.ts (authoritative-cases `it`, ~line 66): the single `COUNT(*) = 3` assertion bundles three semantically distinct exemptions — maintainer close, bot-actor close, no-author close — into one count; a single-sub-case regression will not self-identify, requiring a manual bisect. Consider three targeted `expect` calls or three `it` blocks.
  • src/orb/outcomes.ts (lines 19–21): the three-line comment block is the longest in the file; 'mirrors the cloud recordPrOutcome anti-poisoning guard — merges stay trusted, bot/maintainer closes are authoritative' covers the intent in one line. The remaining sentences restate the code.
  • test/integration/orb-outcomes.test.ts: the sender-absent-but-author-present case (`{ author: 'alice' }`, no `sender` key) is not explicitly exercised in the new tests; it's covered incidentally by the existing pre-guard tests, but an explicit one-liner would nail the `senderLogin = ''` short-circuit branch in the new guard.
  • test/integration/orb-outcomes.test.ts (~line 66): split the three authoritative sub-cases into separate assertions so a regression names itself — e.g. `expect(await db(e)...WHERE pr_number=21...n).toBe(1)` repeated for 22 and 23.
  • test/integration/orb-outcomes.test.ts: add `closedPr('acme/nosender', 24, null, 100, { author: 'alice' })` → assert `COUNT(*) = 1` to explicitly document and lock the fail-open behavior when the sender field is absent.

🟩 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

@JSONbored
JSONbored merged commit d99b765 into main Jun 28, 2026
19 checks passed
@JSONbored
JSONbored deleted the fix/orb-outcome-self-close-guard branch June 28, 2026 02:32
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.

1 participant