fix(orb): prefer the newest relay enrollment when forwarding events - #1785
Conversation
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-06-30 06:40:15 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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.
|
…SONbored#1783) enroll_id is a random opaque token and CURRENT_TIMESTAMP ties at second resolution, so the prior created_at/enroll_id tie-breakers were non-deterministic when multiple enrolled rows shared a relay_registered_at. Order by the implicit rowid (monotonic insertion order) so the most-recently-inserted enrollment wins deterministically.
1ad8030 to
92d9f7b
Compare
Summary
Fixes #1783.
forwardOrbEventloaded the brokered self-host relay target with a.first()query onorb_enrollmentsthat had noORDER BY. BecauseissueOrbEnrollmentinserts a newenrolledrow on every enrollment without revoking prior rows for the sameinstallation_id, re-enrollment left multiple active rows. The lookup could return a stale enrollment (no relay URL →skipped, or an old push URL → mis-delivered HMAC-signed payload).The enrollment lookup now orders by registered-relay presence, then
relay_registered_at DESC, thenenrolled_at DESC, so the current self-host container wins after re-enrollment.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlint(no workflow changes)npm run typechecknpm run test:coveragelocally for changed integration tests; full suite spot-checked vianpx vitest run test/integration/orb-relay.test.ts(63/63 pass).npm run test:workers(no worker changes)npm run build:mcp(no MCP changes)npm run test:mcp-pack(no MCP changes)npm run ui:openapi:check(no API schema changes)npm run ui:lint(no UI changes)npm run ui:typecheck(no UI changes)npm run ui:build(no UI changes)npm audit --audit-level=moderateIf any required check was skipped, explain why:
Skipped UI/MCP/workers/actionlint — orb relay-only change. Full
test:cion Windows hits environment-only failures (spawn claude/codex ENOENT); Linux CI is authoritative.Safety
UI Evidencesection 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.UI Evidence
N/A — orb relay backend only.
Notes
Regression test:
FORWARDS via the newest enrollment when multiple enrolled rows exist for one installation (regression for #1783)intest/integration/orb-relay.test.ts.