/vivreal-knowledge:vivreal-tenancyfrom vivreal-knowledge
Use when a task touches which DATABASE a tenant lives in, rather than what is inside it: reading or writing group.dbKey, resolvePlacement, choosePlacementForNewGroup, isKnownPlacement or isRoutablePlacement, the pod rename, the tenant-placement plus mongo-connection package merge, a group whose site returns 403 because it has no usable placement, a tier change somebody expects to move data, or any question shaped like "should this tenant get its own database yet". Teaches what is TRUE TODAY against what is only PLANNED, the placement-versus-slug confusion that fails silently everywhere, and why the document-count threshold was never set and cannot be. Triggers on: dbKey, placement, resolvePlacement, pod_01, pod_02, general_shared, pro_plus, tenant database, tenancy, pod rename, tenant-placement, mongo-connection, tenant-db, PLACEMENT_MISSING, PlacementMissingError, which database does this group use, split a tenant out, new pod, placement_weights.
Ships in vivreal-knowledge. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill states pointers and mechanisms, not values. Every census, count and roster below is something a query produces in seconds. A number here that a query could have produced is a defect in this file. Report it rather than quoting it.
Cross-repo flows, decisions and maps: the vivreal-hq dev docs under ${VIVREAL_REPOS}/vivreal-hq/docs/dev-docs/, starting at 02-architecture/data-and-tenancy.md, 03-use-cases/U21-provisioning-a-new-tenant.md; npm run docs:route -- "tenant-db" from vivreal-hq names the rest. This skill and the repo's CLAUDE.md own the repo's internals.
This skill is about routing a tenant to a database. For querying once you are in the right
database (collection shapes, join rules, the publishDate gate) use vivreal-db. For cluster
capacity, connection arithmetic and pool hygiene use vivreal-atlas-topology.
dbKey and group.key are different fields with different jobs, and they look alike enough
that they have been swapped by hand more than once.
| Field | What it names | Used for |
|---|---|---|
group.dbKey | the tenant database | selecting the database, read via resolvePlacement(group) |
group.key | the group's URL slug | the S3 bucket name, CDN media paths |
group._id | the group | the groupID filter on every tenant document |
Confusing the first two points every media URL at a bucket that does not exist, and it fails silently everywhere: no error, no alarm, just missing images. Going the other way strands the tenant's entire database.
The unique index does not protect you. A group holding a placement name in its slug satisfies uniqueness perfectly. No constraint catches this class of mistake, which is why the repair is a runbook rather than a one-line fix.
Read this section as the state of the world, and the next one as a plan that has not run.
pod_01 and
pod_02, alongside the Vivreal control plane and the outreach service database. Every
stored placement was repointed (groups.dbKey, the legacy groups.database, domainOrders.dbKey)
and the placement_weights rows keyed by the old names were deleted
(vivreal-hq/docs/projects/tenancy-architecture/migration-run-2026-09-23.md). Census them rather
than quoting a roster: group Vivreal.groups by dbKey.general_shared and pro_plus are GONE as placements. @hillbombcreations/tenant-db puts
both on its forbidden list, with test beside them (src/placement/placementNames.ts:80-96 in
Vivreal-Mongo-Connection, package 1.0.6), so a connect to either name is refused. The first drop
attempt stopped at a red gate the same day; a live database listing on 2026-09-28 showed only
Vivreal, outreach, pod_01, pod_02, admin and local. A script that still hardcodes
general_shared gets ZERO documents, not an error, which reads as "the record was deleted".
Pair every lookup with a positive control.pod_01 holds every customer group and the Vivreal group; pod_02 holds only
the Vivreal Content group (<_id: look up group key vivrealcontent>), placed there deliberately to keep
Vivreal's own content tenant off the shared placement. Tier does NOT decide placement.DEFAULT_PLACEMENT for a new group is pod_01 (src/placement/choosePlacement.ts:19). The
retired @hillbombcreations/tenant-placement package still says general_shared; anything that
imports it is the bug.pro_plus database never held a group on that retired tier), which is why they went.deriveDbKey() is deleted from every repository, and so
is the databaseDict[group.tier] ladder, which is gone for the same reason. An inline ladder
from a tier to a database IS the bug. Report it rather than copying it.@hillbombcreations/tenant-db, which is what the consumer
repositories depend on now. Import the placement half from the
@hillbombcreations/tenant-db/placement subpath: it pulls in no driver, so it is safe inside a
bundle. The root re-exports the same members but needs mongo. The retired package cannot be
deprecated on this registry, the command is rejected and its failure reads as success, so
installing it warns nobody. Somebody writing the old name is the only signal there is, which is
why a pasteable snippet naming it is worse than a sentence that merely mentions it.const { resolvePlacement } = require('@hillbombcreations/tenant-db/placement');
const dbKey = resolvePlacement(group); // throws PlacementMissingError if absent or unroutable
groups.dbKey is
the only copy: Vivreal.domainOrders carries a dbKey, and Vivreal.placement_weights stores
the placement name as _id, which is immutable and therefore cannot be repointed by a field
update. Scan for the name rather than assuming where it lives.Vivreal.domainOrders (camelCase), and it is the live one. The
lowercase domainorders an old model registration produced is gone (VR_Secure_API #231 plus a data
migration; measured absent 2026-10-15), so the "empty orphan" note older skills carried is backwards.
Mongoose lowercases and pluralizes a model name with no collectionName, which is how two copies
existed at all._id can exist in more than one database. The live site renders the copy in the
group's placement (<group.dbKey>.sites). During the pod migration the help site existed under one
_id in two databases, and two writes went to the copy nothing reads. Before any site write, check
for the _id elsewhere and verify against the RENDERED page.tenant-db model is undefined, not unbound. createLegacyMainDb builds DB as
{ conn } plus one key per DECLARED model, and each Lambda declares its own narrow map, so
mainDb.DB.groups in a worker that never declared groups is a TypeError, not a connection
error. A mock carrying extra models hides it at 100% coverage. Read the worker's own map, and pin
Object.keys(mainDb.DB) against the real one in a test.group.database legacy fallback is populated on at least one group. The placement
package's own source comment says this field "is already undefined on the one group anybody
thought still needed it". That comment is wrong. Do not rely on the field being empty, and note
that Vivreal_Site_Migrator's expectedDbKeyForGroup still falls through to it.Plan and runbook: vivreal-hq/docs/projects/tenancy-architecture/. If you are about to tell
somebody about pods, read the status line at the top of pod-rename-migration.md first.
Both items this section used to list have now happened: the package merge, and the pod rename (2026-09-23, phase 2 run; see "What is TRUE TODAY"). Do not describe either in the future tense.
Still only planned or open, as of 2026-10-04:
scripts/build-indexes.js --build --new-placement <pod> (on the deployed lines of VR_CMS_API,
VR_Secure_API, VR_Client_API and Vivreal_EventHandler at this sync; the EventHandler header says
seven services build a tenant pod, so check each). The name must be exactly the pod tenant-db's
choosePlacementForNewGroup would open next from the stored dbKeys, and a build is refused when
any collection there already holds a document. Before a new-pod build, compare two inputs that
can disagree: signup reads the Vivreal.placement_weights census, the script reads
Vivreal.groups.dbKey, and a census row with no group (or the reverse) makes them name different
next pods. Build only when they match.general_shared. Several notes and the 2026-09-16 precedent
scripts were written before the move and carry the old name; treat any hardcoded general_shared
or pro_plus database name as stale on sight.An agent that describes a finished change in the future tense sends the next person to redo it; one that describes a plan in the present tense sends them looking for something that is not there. Check the run records before saying either.
The rename is naming. The merge closes a real enforcement hole: the validator and the thing it
validates live in different packages, so the per-group allowlist is advisory everywhere and
mandatory nowhere. Measured in VR_CMS_API: many controllers route a database open on a
caller-supplied key, and only one of them calls the allowlist isKnownPlacement. The shared tenant
wrapper imports the weaker structural check isRoutablePlacement only, and mentions the allowlist
in a comment. So a structurally legal name that no longer exists gets created on first write
rather than refused. That is the mechanism that produced a database literally named undefined.
This is enforcement-check-the-caller in its natural habitat: a manifest row claiming the allowlist
exists is only true if the path the product actually calls runs it.
One trap the plan records: naively wiring isRoutablePlacement into the connection function
takes VR_Outreach_API offline, because it opens a service-global database that is deliberately not
a tenant placement. A guard installed at the wrong layer is an outage.
The portal mints a signed context cookie carrying groupID, dbKey and bucketname, and the proxy
injects that dbKey into every upstream call. The silent refresh carries dbKey over verbatim
and does not re-read the group document. The refresh token's validity is measured in weeks, so
without a deliberate intervention a stale placement survives far longer than the short context TTL
suggests.
The invariant the portal source states for itself, which any migration inherits:
nothing may mutate
group.dbKeyoutside a deliberate ops migration, and that migration's runbook must force session invalidation so these carried-over claims cannot outlive the move.
So a change to a stored placement is incomplete until sessions are invalidated. Read the current TTLs off the source and the Cognito app client rather than trusting any number written in prose, here or anywhere else.
Two distinct failure reasons, needing different repairs:
reason | Means |
|---|---|
absent | no dbKey, or it is null, empty, or not a string |
unroutable | a dbKey that can never name a tenant database: a coercion accident, a forbidden name, or a retired name after a migration |
Symptoms, and why they mislead:
authorizerResultTtlInSeconds off the REST API
before re-testing a repair. A source comment in VR_Client_Auth understates it by a large factor,
and anyone trusting that comment re-tests inside the cache window, reads the cached refusal, and
concludes a correct repair failed. A code comment is not evidence, and this is the place where
believing one costs an outage.The repair is a runbook, not an improvisation:
vivreal-hq/docs/projects/tenancy-architecture/runbook-missing-dbkey.md. Its own uncomfortable
finding: the repair it describes, a hand-written single-field write to a group document with dbKey
and key both on screen, is the exact act that caused a previous incident. Follow it, do not
freehand it.
This arrives as "are we near a limit". It has been worked out and written down, and the reasoning matters more than the verdict, because the verdict will change and the reasoning will not.
The threshold in the placement package was never set, and could not have been. It thresholds on document count, and the vendor publishes no document-count limit at any scope or any tier. From the MongoDB manual, verbatim:
"MongoDB does not impose a hard limit on collection or database sizes. The maximum size of a collection or database depends on the file system of the host server."
A threshold has to be a fraction of a ceiling. This one is a fraction of a ceiling that does not exist, which is exactly why nobody could pick the number: there was nothing to pick it as a fraction of. Recognising that shape is the transferable part. When a threshold resists being chosen for months, check that the quantity it bounds is bounded at all.
Two further independent reasons document count is the wrong axis, either sufficient alone:
What actually bounds a managed MongoDB deployment, in the order it bites:
serverStatus returned no storage-engine block and resident memory read
zero); M10 is a dedicated tier, so re-read serverStatus before saying it still is.vivreal-atlas-topology.atlas-limits, read 2026-10-17). Every pod carries a full
set of tenant collections and their indexes, so a new database spends a slice of that budget
permanently, before it holds a tenant. Count with listDatabases and listCollections per
database rather than trusting a remembered total. The M0 Free tier before it had hard caps of
100 databases and 500 collections, 100 operations per second and 10 GB of data out per rolling
7 days; none of those apply now. vivreal-atlas-topology carries the live tier and its limits.The honest position (written on M0): the thing that matters was unmeasurable there, everything measurable had substantial headroom, and document count is a third thing that is not a limit at all.
Rules that follow:
Vivreal.groups by dbKey and pair it with a query that
must return zero, such as a deliberately misspelled placement name. A placement query returning
nothing looks identical to a placement that is not there. See verification-discipline.groups.dbKey, groups.database,
domainOrders.dbKey and placement_weights._id have each held one.pod_01 default are TODAY;
general_shared and pro_plus are retired database names. Re-read the run records before restating either.dbKey and key both on screen.
That is the incident, not the fix.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub hillbombcreations/vivreal-skills --plugin vivreal-knowledge27 skills in this plugin
/sentry-tracerUse when investigating what happened during a Vivreal user action across the stack, tracing an error end-to-end, validating a deploy, or doing tenant-scoped triage with Sentry. Teaches WHEN to trace cross-stack (frontend spans ↔ backend logs ↔ WebSocket events) and HOW (trace-ID propagation, the standard tag set, request_id fallback, service.* breadcrumbs). Triggers on: "what happened when I did X", "why did this error", trace this request, Sentry issue, deploy validation, "everything's broken for this group", crash, error timeline. For the full investigation agent with Sentry MCP tools wired in, dispatch the `sentry` agent / `/sentry-trace` (both in the `vivreal-sentry` plugin); this skill is the passively-loaded knowledge layer. Also covers the step from a Sentry error to the AWS and Atlas metric that confirms an infrastructure cause (502 with no backend event, Lambda timeout, Mongo connect-hang, throttling, OOM, stalled deploy)./vivreal-accounts-and-writesUse before filming, walking or capturing anything in the Vivreal portal or on vivreal.io, and before any write a capture or walk makes. Carries which login to use for which business (the demo account, the QA scratch owner, the owner session), the eight-step owner-approved write protocol (named approval, snapshot, write through the UI, fresh-process read-back, restore, manifest entry), the never-list (Post, Publish, Schedule, Connect and the rest), and the rules for stills that fill vivreal.io marketing slots (pair by what the slot says, no demo site has its own web address, mask comped plan figures). Shared by footage-recorder, tutorial-maker, help-page-producer, qa-walker and marketing-auditor. Triggers on: which login, demo account, QA scratch-2, test account, switch business, owner-approved write, write protocol, snapshot and restore, mutations, marketing still, screenshot swap, vivreal.io slot, walk harness, write guard, POST allow list, PRO badge./vivreal-admin-app-knowledgeUse when working on, walking, deploying or reasoning about the internal admin app (vivreal-hq packages/admin-app), the invite-only, sign-in-only staff hub that holds every staff surface since v7 (outreach CRM, sign-ups, monitoring, errors, tickets, flags, audit, usage, economics, deployed sites, team, staff push), covering where it lives, its own identity pool and session, how it calls the fleet with no active_ctx, the deploy by fast-forwarding deploy/admin-app, its two ops Lambdas, what each page reads, including the dark navy restyle and the Releases, Database, Marketing and Inbound pages. Source of truth: `vivreal-hq` `packages/admin-app/CLAUDE.md` (and the docs it links) at `origin/deploy/admin-app`./vivreal-agent-knowledgeUse when working on, writing about, or debugging Vivreal AI. The AI offering is connecting an AI agent through the Vivreal MCP server (VR-MCP-Server, plan flag mcpAccess, metered in mcpToolCalls), and nothing else: the in-app assistant is RETIRED (owner 2026-10-07, agentActions 0 on every tier; the global FAB, drawer and /agent page were deleted 2026-09-24) and only dead code survives in the portal (Studio AiRail, EditPlan) and VR_Secure_API's agent Lambda. Covers the copy rule ("AI agent", never assistant or a model name), the real gates, and the retired surface's archaeology. Triggers on: AI agent, MCP, connect an AI agent, AI assistant, AI assistant not showing, agentActions, aiActionsEnabled, aiSiteEditing, aiComponentGen, mcpAccess, mcpToolCalls, AiRail, useAgentAccess, EditPlan, proposeSiteEdits, agent/execute, agentProgress. Sources: VR-MCP-Server, Vivreal-Tier-Quotas src/tierQuotas.ts./vivreal-analytics-knowledgeUse when working on Vivreal's first-party analytics, VR_Analytics_API (the collect→store→rollup pipeline), the Templates SiteBeacon, or the per-site traffic dashboard (VR_Secure_API read route + portal AnalyticsPanel). Covers the CloudFront+WAF → Lambda Function URL ingest chain (X-Origin-Verify, bot filter, Joi, per-IP rate limit, daily-salt visitor hash), the analytics_rollup DynamoDB design, the daily rollup cron into mainDb.site_traffic_daily, the LIVE auto-deploy status (GitHub Actions → CloudFormation) plus the W4 CDN egress meter (runs unconditionally), and where increment 2 lives. Triggers on: analytics, site traffic, beacon, SiteBeacon, visitor stats, page views, unique visitors, analytics_rollup, site_traffic_daily, first-party analytics, per-site dashboard, collect.vivreal.io, visitor hash, rollup cron, CDN egress meter, VR_Analytics_API. Source of truth: `VR_Analytics_API` `CLAUDE.md` (and the docs it links) at `origin/main`./vivreal-blender-knowledgeUse when scripting or rendering in Blender for Vivreal, above all the Vivreal duck mascot in vivreal-hq/brand/mascot/model. Covers headless renders (blender -b -P script.py -- args, --factory-startup, --python-exit-code), bpy data versus ops, bmesh, depsgraph evaluated_get and new_from_object, mathutils transform gotchas, flat toon and NPR rendering in EEVEE (Emission plus the Standard view transform, exact sRGB hex, dither, filter size, transparent film, orthographic framing), outline methods compared (Freestyle, Grease Pencil Line Art, inverted hull, ID-pass edge inking), and the 4.2 to 5.2 API changes that break scripts (EEVEE engine id, blend_method, use_nodes, Grease Pencil v3). Triggers on: Blender, bpy, bmesh, headless render, background render, EEVEE, Workbench, Cycles, toon, cel, NPR, outline, inverted hull, Freestyle, Line Art, Grease Pencil, view transform, AgX, Filmic, mascot, the duck, duck.py, render.py, mascot-artist.