Skip to content

fix(selfhost): paginate Orb export by event_at and target_id tie-break - #1917

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/orb-export-cursor-tiebreak
Jul 1, 2026
Merged

fix(selfhost): paginate Orb export by event_at and target_id tie-break#1917
JSONbored merged 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/orb-export-cursor-tiebreak

Conversation

@joaovictor91123

Copy link
Copy Markdown
Contributor

Summary

  • Add last_exported_target_id to orb_export_cursor (migration 0088_orb_export_cursor_target_id.sql) so the Orb fleet exporter can resume within a tied event_at group.
  • Paginate resolved PR rows with (event_at > cursor) OR (event_at = cursor AND target_id > cursorTargetId) and ORDER BY event_at ASC, target_id ASC.
  • Advance both watermark fields from the last exported row; add regression coverage for five PRs sharing one event_at exported in batches of two.

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 an issue, or this is small enough that the summary explains why an issue is not needed.

Issue creation is currently blocked for contributor accounts on the upstream repo; this is a focused data-loss fix with regression tests.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥97% coverage of the lines AND branches you changed (aim for 98%+ 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:

  • Full npm run test:ci runs in GitHub Actions; test/unit/selfhost-orb-collector.test.ts covers the new composite-cursor path.

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

N/A — self-host Orb export logic only.

Notes

Made with Cursor

A timestamp-only export cursor skipped remaining PRs when multiple resolved
rows shared the same event_at and batchSize was smaller than the tie group.
Persist last_exported_target_id and page with a composite watermark.

Co-authored-by: Cursor <cursoragent@cursor.com>
@loopover-orb

loopover-orb Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-01 16:15:00 UTC

3 files · 1 AI reviewer · no blockers · readiness 66/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This change correctly converts the Orb self-host export cursor from a timestamp-only watermark to a composite `(event_at, target_id)` cursor, and the query/update paths use the same ordering key, so tied timestamps are paginated without skipping the rest of the existing tie group. The migration is D1-safe and the regression test exercises the intended batched same-timestamp path. The main remaining risk is around proving the exact exported identities/order in the regression, but the production query and cursor advancement are internally consistent.

Nits — 5 non-blocking
  • test/unit/selfhost-orb-collector.test.ts:211 should capture the exported payloads and assert the five distinct PR identities are exported once, not only that the batch counts are 2/2/1/0.
  • src/selfhost/orb-collector.ts:176 should keep the optional `last_exported_target_id?: string` only if you intentionally support code running against a pre-migration database; after the migration it is `NOT NULL DEFAULT ''` and can be typed as `string`.
  • test/unit/selfhost-orb-collector.test.ts:211 add payload capture across the four calls and assert the exported `pr_hash`/raw target values are unique and ordered by the composite cursor.
  • src/selfhost/orb-collector.ts:186 consider documenting that the cursor is lexicographic by `target_id`, since the ordering is stable but not numeric by PR number.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No 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 (size label size:S; no linked issue context).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 56 registered-repo PR(s), 36 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor joaovictor91123; Gittensor profile; 56 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: joaovictor91123
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 56 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Explain no-issue PR.
  • Await review-lane availability.
  • Triage stale or unlinked PRs.
  • Refresh registry data or choose a registered active repo.
  • 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

@dosubot dosubot Bot added the lgtm label Jul 1, 2026
@JSONbored
JSONbored merged commit ad74b0c into JSONbored:main Jul 1, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 1, 2026
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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants