Skip to content

Push typed IDs through repo trait layer — drop ~80 boundary conversions#176

Merged
saltyskip merged 10 commits into
mainfrom
feat/public-id-repos
May 29, 2026
Merged

Push typed IDs through repo trait layer — drop ~80 boundary conversions#176
saltyskip merged 10 commits into
mainfrom
feat/public-id-repos

Conversation

@saltyskip
Copy link
Copy Markdown
Owner

Summary

Follow-up to #174. Migrates every repo.rs trait + impl to take typed &TenantId / &AffiliateId / &SecretKeyId / &WebhookId / &UserId / &PublishableKeyId / &AuthSessionId / &AppId / &SourceId / &InstallEventId parameters instead of &ObjectId. Inside repo bodies, BSON construction works through the existing From<Id<P>> for Bson impl — storage format unchanged (still native ObjectId on the wire).

Result: 89 → 8 .as_object_id() / .to_object_id() calls in production code.

What changed

13 repo modules migrated, one commit per domain:

  • domains, publishable_keys, tenants, users, secret_keys, webhooks, apps, sessions, event_counters, conversions, install_events, app_users, links

For each: trait signatures → impl signatures → BSON doc! literals → service-layer callers → route-layer callers → in-memory test mocks.

Why

After #174 landed, services + routes spoke typed IDs everywhere but repos still spoke ObjectId — so every repo call site was a boundary conversion. The architecture test allowlists **/repo.rs, so this dead weight was structurally invisible.

This PR pushes typed IDs all the way to the repo trait boundary, and the boundary conversions vanish from service / route / mcp / test code.

Storage layer

ObjectId still appears inside repo bodies (e.g. tenant_id.as_object_id() for _id lookups, ObjectId::new() for the app_users sentinel). That's intentional — repos own storage. The architecture allowlist for **/repo.rs is unchanged.

Verification

  • cargo test: 205 lib + 179 doc + 147 integration passing at every commit
  • cargo clippy --all-targets -- -D warnings: clean
  • cargo fmt: clean
  • OBJECT_ID_BACKLOG still empty; architecture tests still actively enforcing

Test plan

  • Smoke-test: create link → get → list → click → identify → create affiliate → mint affiliate credential → use scoped credential to create link (round trips through every migrated repo)
  • Spot-check a mongosh row to confirm BSON storage is still native ObjectId (no schema drift on the wire)

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rift Ready Ready Preview, Comment May 29, 2026 6:32pm

Request Review

@saltyskip saltyskip merged commit 42cfb58 into main May 29, 2026
5 checks passed
@saltyskip saltyskip deleted the feat/public-id-repos branch May 29, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant