Skip to content

feat(admin): list_orphaned_brands tool to audit relinquished brand pool - #3182

Merged
bokelley merged 2 commits into
mainfrom
bokelley/list-orphaned-brands
Apr 25, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/list-orphaned-brands

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

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:

  • `domain`
  • `prior_owner_org_id` + `prior_owner_org_name` (joined from organizations)
  • `relinquished_at` + `days_since_relinquished`
  • Manifest preview: `logo_url` + `brand_color`

Newest-first ordering so the most-recent relinquishments surface first.

Pairs with

  • `transfer_brand_ownership` (feat(admin): transfer_brand_ownership tool for brand registry #3159) — when an admin confirms the legitimate next owner out of band, transfer to hand off
  • `update_company_logo` member tool — orphaned brands become claimable through the normal flow once a prospective new owner identifies themselves; the orphan-decision is then forced explicitly in the chat (`orphan_manifest_decision_required` 409)

Test plan

  • Type-check passes
  • 834 unit tests pass
  • Reviewer to verify on staging: relinquish a test brand via DELETE `/api/brands/hosted/:domain`, run `list_orphaned_brands` from chat, confirm the row appears with prior owner name + manifest preview.

🤖 Generated with Claude Code

bokelley and others added 2 commits April 25, 2026 12:24
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]>
@bokelley
bokelley merged commit 5438e1d into main Apr 25, 2026
14 checks passed
@bokelley
bokelley deleted the bokelley/list-orphaned-brands branch April 25, 2026 17:18
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