Skip to content

Namespace Governance Architecture

The namespace governance system replaces the eight-entry hardcoded CHECK constraint on lensers.profiles with a policy-driven, data-governed authority that protects strategic handles, blocks impersonation, and requires zero code changes to protect newly discovered AI providers or models.

Core idea

Every handle claim goes through a single validation authority before it reaches the database. New providers and models are data rows, not code deployments.

Handle claim attempt


identity_gov.fn_validate_handle(candidate)

  ├─ [1] Syntax guard (length, charset)
  ├─ [2] Normalizer  (NFKC → leet fold → repeat collapse → filler strip)
  ├─ [3] Exact registry hit
  ├─ [4] Prefix / suffix / regex pattern match
  ├─ [5] Token + modifier composition check
  ├─ [6] Homoglyph skeleton probe (TR-39)
  ├─ [7] Levenshtein fuzzy probe (edit distance ≤ 2)
  ├─ [8] Trigram similarity probe (pg_trgm > 0.70)
  └─ [9] Phonetic probe (Double-Metaphone)


    verdict: allow | escalate | deny

Fail-CLOSED: on any internal exception, the function returns deny. Ecosystem safety is never traded for onboarding convenience.

The one table

sql
identity_gov.reserved_namespaces (
  entry_kind  exact | prefix | suffix | token | regex
  value       pre-normalized string or POSIX pattern
  class       system | security | provider | model | future | verified_only | restricted
  deny_score  0..100  (floor risk score when this entry matches)
  source      canonical | manifest | ai_inferred
  expires_at  NULL = permanent; set for ai_inferred during 30-day grace window
)

One table replaces seven draft tables and a family of CHECK constraints. Combinatorial coverage (e.g. openai-support, openai-bot, openai-admin) is achieved by token entries combined with the modifier list inside fn_validate_handle — no row explosion.

Namespace classification

ClassScoreExamplesWho can claim
system100lenserfight, chainabitNever claimable
security95admin, mod, abuse, trustInternal ops only
provider90openai, anthropic, googleDNS proof + trademark
model85claude, gpt, gemini, llamaProvider-verified only
future80lenscore, lensruntime, lensoHeld for roadmap products
verified_only70Notable public figuresT&S approval
restricted50Pattern-flagged via suffix/tokenAppeal-only
publicEverything elseSelf-serve

Protected handles (canonical seed)

The following handles are seeded into identity_gov.reserved_namespaces at bootstrap. All values are pre-normalized (lowercase, ASCII-clean). Combinatorial coverage (e.g. openai-support, claude-bot) is achieved via prefix and token entries, not row explosion.

System / platform identities — score 100

HandleEntry kindsWhy
lenserfightexact, prefixPlatform canonical identity; no variant may be claimed
chainabitexact, prefixChainabit ecosystem identity
conectlensexact, prefixConectLens parent brand
lenserfight-hqexactPlatform HQ handle

Security / moderation — score 90–95

These handles exist to prevent impersonation of platform operations roles.

HandleScoreWhy
admin95Platform admin namespace
root95System root namespace
system95System identity namespace
moderator95Moderation team namespace
mod95Short moderation namespace
trust95Trust & Safety namespace
safety95Safety team namespace
abuse95Abuse reporting namespace
report95Report namespace
security95Security team namespace
support95Platform support namespace
null95Null/undefined identity guard
undefined95Undefined guard
help90Help namespace
policy90Policy namespace
legal90Legal namespace
dmca90DMCA reporting namespace
anonymous90Anonymous identity guard

LenserFight brand family — score 80

Reserved for current and future platform products. No user may claim a lens* or lola handle without T&S approval.

HandleWhy
lenserLenserFight core brand token (also a token entry)
lensCore brand token (also a token entry)
lensoLenser AI family — @lenso
lensaLenser AI family — @lensa
lenseLenser AI family — @lense
lolaLenser AI family — @lola (also a token entry)
lenscoreFuture product: LensCore
lensruntimeFuture product: LensRuntime
lensagentFuture product: LensAgent
lensosFuture product: LensOS
lensaiFuture product: LensAI
lensinfraFuture product: LensInfra
lensizmLegacy reserved handle

Chainabit ecosystem handles reserved for future products:

HandleWhy
chainaChainabit brand token (also a token entry)
chaincoreFuture: ChainCore
chainagentFuture: ChainAgent
chainruntimeFuture: ChainRuntime
chainnodeFuture: ChainNode
chainlabsFuture: ChainLabs
chaininfraFuture: ChainInfra

AI provider companies — score 85–90

Blocked to prevent trademark impersonation. Exact + prefix + token entries provide combinatorial coverage.

HandleScoreSource
openai90OpenAI (trademark)
anthropic90Anthropic PBC (trademark)
google90Google LLC (trademark)
deepmind90Google DeepMind
meta90Meta Platforms
xai90xAI
mistral90Mistral AI
deepseek90DeepSeek AI
groq90Groq Inc.
cohere90Cohere Inc.
perplexity90Perplexity AI
huggingface90HuggingFace Inc.
stabilityai90Stability AI
elevenlabs90ElevenLabs
nvidia90NVIDIA Corp.
microsoft90Microsoft Corp.
amazon90Amazon/AWS
vertexai90Google Vertex AI
geminiapi90Google Gemini API
togetherai90Together AI
together85Together AI (short form)
stability85Stability AI (short form)
replicate85Replicate Inc.
bedrock85AWS Bedrock
sagemaker85AWS SageMaker
fireworks85Fireworks AI
octoai85OctoAI
anyscale85Anyscale
cerebras85Cerebras Systems

AI model names — score 75–90

Blocked to prevent model impersonation. Provider-verified accounts may petition T&S for access.

HandleScoreWhy
chatgpt90ChatGPT product name
claude90Anthropic Claude
gemini90Google Gemini
grok90xAI Grok
gpt4o85GPT-4o
gpt485GPT-4
gpt385GPT-3
gpt85OpenAI GPT family
llama85Meta Llama family
deepseekr185DeepSeek-R1
sonnet85Claude Sonnet tier
opus85Claude Opus tier
sora85OpenAI Sora
commandr80Cohere Command-R
qwen80Alibaba Qwen
phi80Microsoft Phi
haiku80Claude Haiku tier
gemma80Google Gemma
mixtral80Mistral Mixtral
codex80OpenAI Codex
dalle80OpenAI DALL-E (slug)
dall-e80OpenAI DALL-E
stable-diffusion80Stability AI SD
whisper80OpenAI Whisper
mistral7b80Mistral 7B
o180OpenAI o1
sdxl75Stable Diffusion XL
falcon75TII Falcon

Suffix / composition guards — score 50

These entries block impersonation patterns like mybot-official or something-admin. Score is lower because the tokens may appear legitimately in non-impersonation handles; the composition check in fn_validate_handle handles high-risk combinations.

SuffixWhy
officialImpersonation suffix guard
verifiedImpersonation suffix guard
iamIdentity claim suffix guard

Detection pipeline detail

[2] Normalizer — identity_gov.fn_normalize_handle

The IMMUTABLE normalizer reduces attack surface before any registry lookup:

  1. Strip invisible/directional Unicode (ZWJ, ZWNJ, RTL marks, BOM)
  2. NFKC normalization (ligatures: fi→fi, fullwidth: A→A)
  3. Casefold (lower())
  4. Homoglyph fold — Cyrillic а/е/о/р/с/х → a/e/o/p/c/x
  5. Leet-speak fold — 0→o, 1→l, 3→e, 4→a, 5→s, 7→t, @→a, $→s, 8→b
  6. Repeat collapse — runs of 3+ identical chars → 2 (ooopenai→oopenai)
  7. Filler suffix strip — official, support, admin, bot, ai, hq, team
  8. Leading the_ / the- strip
  9. Trim separator chars

openai-supportopenai → exact hit → deny.

[6] Homoglyph skeleton — identity_gov.fn_handle_skeleton

Applied on top of the normalizer. Collapses font-level confusables: rn→m, vv→w, ii→u. Detects rnetameta.

[5] Composition check

If any token entry appears inside the normalized handle and the original candidate contains a modifier word, the handle is denied:

lens_ai   → token 'lens' + modifier 'ai' → deny
gpt-admin → token 'gpt'  + modifier 'admin' → deny
claude-bot → token 'claude' + modifier 'bot' → deny

Modifier list lives in the function. Adding a new modifier is a single-line code change; adding a new protected token is a single row insert.

Functions (public API surface)

FunctionVolatilityCallerPurpose
public.fn_check_handle(text)STABLEauthenticated, anonAdvisory read-through; safe for debounced UI calls
identity_gov.fn_validate_handle(text)STABLEtrigger, fn_check_handleAuthoritative 9-step pipeline
identity_gov.fn_normalize_handle(text)IMMUTABLEfn_validate_handlePure normalizer
identity_gov.fn_handle_skeleton(text)IMMUTABLEfn_validate_handleHomoglyph folder

fn_check_handle is advisory — it is cached and safe to call from UI on every keystroke (debounced). The BEFORE INSERT/UPDATE trigger on lensers.profiles runs fn_validate_handle as the hard enforcement gate. Cache staleness can never produce a wrongful approval on the write path.

Security model

  • identity_gov schema has FORCE ROW LEVEL SECURITY on all tables.
  • authenticated and anon roles have SELECT only on reserved_namespaces.
  • All write mutations go through SECURITY DEFINER functions with SET search_path = ''.
  • The trigger on lensers.profiles raises P0001 on deny — no bypass through direct SQL.
  • A superuser/service_role can still insert rows (seeding, moderation) — the trigger only fires for client roles.

Adding new providers or models

No code change needed. Insert a row:

sql
INSERT INTO identity_gov.reserved_namespaces
  (entry_kind, value, class, deny_score, reason, source)
VALUES
  ('exact',  'newprovider',  'provider', 90, 'NewProvider Inc.', 'manifest'),
  ('prefix', 'newprovider',  'provider', 90, 'Prefix guard',     'manifest'),
  ('token',  'newprovider',  'provider', 90, 'Composition guard','manifest');

For ai_inferred entries (from the future AI Intel pipeline), set expires_at = now() + interval '30 days'. Entries that are not promoted within the grace window expire and become claimable again.

GRASP / OOAD alignment

PrincipleApplication
Information Expertidentity_gov owns all normalization, detection, and decision logic
Protected VariationsNew providers/models are data rows — the variation point is closed to code change
Pure Fabricationfn_normalize_handle, fn_handle_skeleton are stateless services
Controllerfn_validate_handle is the single validation authority
Low Couplinglensers.profiles trigger delegates entirely to fn_validate_handle
Chain of Responsibility9-step pipeline; each step is independent, first terminal verdict wins
Registryreserved_namespaces is the canonical registry
Strategyentry_kind column selects the matching strategy at runtime
SpecificationEach probe is a self-contained boolean sub-query

Tables introduced

TablePurpose
identity_gov.reserved_namespacesThe single registry — exact handles, prefix/suffix/token/regex rules

One schema, one table. No audit tables, no policy tables — the governance logic is pure SQL functions backed by Postgres extension capabilities (pg_trgm, fuzzystrmatch).