Repository navigation
feat(admin): list_orphaned_brands tool to audit relinquished brand pool - #3182
Merged
Merged
Conversation
When a hosted brand is relinquished, the row sits in an orphaned state (manifest preserved for adoption, paired with is_public=false). #3168 shipped the relinquish + adoption plumbing but left admins without a view into the queue. Adtech-product-expert flagged this as a 6-month data-hygiene problem if the admin tool didn't follow. * New BrandDatabase.listOrphanedBrands joins organizations to surface the prior owner's display name alongside its id, plus a manifest preview (logo URL, brand color) so the queue is readable without drilling in. Newest-first ordering. * New list_orphaned_brands admin MCP tool wires through to the admin tool set so the router can surface it. * Returns days_since_relinquished computed at read time so admins can spot stale entries without timestamp math. Pairs with transfer_brand_ownership for the resolve path. Listed brands become claimable through the normal brand-identity flow (which already forces explicit adopt-or-clear). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* relinquished_at field renamed to last_updated_at in the DB result shape — code-reviewer flagged the naming as a foot-gun since the value is sourced from the row's updated_at column. Added a comment documenting the relationship: while orphaned, only deleteHostedBrand writes to the row, so updated_at == relinquished_at in practice; if a future code path breaks that invariant, swap to a dedicated manifest_orphaned_at column. * days_since_relinquished retained at the handler boundary (still the right thing to surface to admins reading the queue). * Audit logger.info added on every invocation with adminUserId, count, limit, offset — security-reviewer's defense-in-depth note. Bulk enumeration of the orphan pool is now visible in logs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New `list_orphaned_brands` admin tool. Closes the "orphaned rows accumulate with no admin view" gap that adtech-product-expert flagged on #3168.
What it does
When a hosted brand is relinquished, the row enters an orphan state: ownership cleared, manifest preserved, `is_public=false`. #3168 shipped the relinquish + adoption-at-claim plumbing but left admins without a way to see what's in the orphan pool. This tool fixes that.
`list_orphaned_brands` returns one row per orphaned brand:
Newest-first ordering so the most-recent relinquishments surface first.
Pairs with
Test plan
🤖 Generated with Claude Code