Fix #162: add source semantics and effective routing endpoint#166
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2e16a87c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (params.autoProvisionEnabled && params.hasPlatformToken && params.billingEligible === true) { | ||
| return { | ||
| code: "AUTO_PROVISION_ELIGIBLE", |
There was a problem hiding this comment.
Restrict AUTO_PROVISION_ELIGIBLE to real fallback states
This branch marks every existing non-ready mapping as AUTO_PROVISION_ELIGIBLE when billing passes, but runtime auto-provisioning in resolveTenantTurso only runs for missing mappings, disabled/error mappings, or missing credentials. In the valid status="provisioning" + credentials case, this endpoint claims runtime will replace the mapping even though requests actually fail as not-ready, so the new effective-routing diagnostics can direct operators toward the wrong remediation path.
Useful? React with 👍 / 👎.
packages/web/src/app/api/sdk/v1/management/tenant-routing/effective/route.ts
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
|
Summary
mapping_source(auto/override) with migration/backfill insdk_tenant_databasesmapping_source = automapping_source = overrideGET /api/sdk/v1/management/tenant-routing/effective?tenantId=...to return effective routing diagnostics:metadata.provisionedByfallback)Verification
cd packages/web && pnpm vitest run src/app/api/mcp/tenants/__tests__/route.test.ts src/app/api/sdk/v1/management/tenant-overrides/__tests__/route.test.ts src/app/api/sdk/v1/management/tenant-routing/effective/__tests__/route.test.ts src/lib/memory-service/scope.test.tscd packages/core && pnpm vitest run src/__tests__/client.test.tscd packages/web && pnpm typecheckcd packages/core && pnpm typecheckNote
Medium Risk
Adds a new persistent column with backfill plus new/updated management endpoints that influence tenant routing decisions; mistakes could misclassify mappings or affect provisioning/disable flows, but changes are scoped and covered by tests.
Overview
Adds deterministic tenant mapping source semantics by introducing
mapping_source(autovsoverride) onsdk_tenant_databases, including a Supabase migration that backfills existing rows (usingmetadata.provisionedBy) and enforces defaults/constraints.Updates runtime auto-provisioning and both legacy (
/api/mcp/tenants) and SDK management (/api/sdk/v1/management/tenant-overrides) APIs to persist and returnsource, plus a sharednormalizeTenantMappingSourcehelper for legacy compatibility and dashboard UI badges/disable gating (onlyoverridemappings can be disabled).Adds
GET /api/sdk/v1/management/tenant-routing/effective?tenantId=...to return routing diagnostics (resolved target, mapping readiness/source/credentials, owner-scope context, and auto-provision eligibility/blocked reasons), and refactors management auth/rate-limit handling into a reusableresolveManagementIdentityutility.Written by Cursor Bugbot for commit ddf402e. This will update automatically on new commits. Configure here.