@@ -92,16 +92,24 @@ export type FakeDriverCall = {
9292
9393/** A fake `TenantProvisioningDriver` plus the recorded state a test inspects. */
9494export type FakeTenantProvisioningDriver = TenantProvisioningDriver & {
95- /** Tenant names whose container currently "exists" (an in-memory stand-in for real infrastructure). */
95+ /** Product-scoped keys (`${product}:${tenant.name}`, same as container-driver.ts's `instanceNameFor`)
96+ * whose container currently "exists" (an in-memory stand-in for real infrastructure). */
9697 readonly containers : ReadonlySet < string > ;
97- /** Tenant names whose database currently "exists". */
98+ /** Product-scoped keys whose database currently "exists". */
9899 readonly databases : ReadonlySet < string > ;
99- /** Tenant names whose secrets are currently injected. */
100+ /** Product-scoped keys whose secrets are currently injected. */
100101 readonly injectedSecrets : ReadonlySet < string > ;
101102 /** Every driver step this fake has run, in call order. */
102103 readonly calls : readonly FakeDriverCall [ ] ;
103104} ;
104105
106+ /** Same composite key as container-driver.ts's `instanceNameFor` (#8025) — ORB and AMS tenants that share a
107+ * name must not collide in the fake's in-memory maps (production composes this fake for any step without a
108+ * real backend yet). */
109+ function instanceKeyFor ( request : TenantProvisioningRequest ) : string {
110+ return `${ request . product } :${ request . tenant . name } ` ;
111+ }
112+
105113/** Minimal in-memory fake for orchestration/contract tests — three in-memory maps stand in for real infra
106114 * ("a container exists" / "a DB exists" / "secrets injected"), toggled by the create/destroy steps, plus an
107115 * ordered call log. NO Cloudflare, Postgres, or secret-broker IO of any kind. Mirrors
@@ -135,11 +143,11 @@ export function createFakeTenantProvisioningDriver(): FakeTenantProvisioningDriv
135143 } ,
136144 async createContainer ( request ) {
137145 record ( "createContainer" , request ) ;
138- containers . add ( request . tenant . name ) ;
146+ containers . add ( instanceKeyFor ( request ) ) ;
139147 } ,
140148 async provisionDatabase ( request ) {
141149 record ( "provisionDatabase" , request ) ;
142- databases . add ( request . tenant . name ) ;
150+ databases . add ( instanceKeyFor ( request ) ) ;
143151 // Deterministic per-tenant fake connection details -- no real IO, no state beyond the existing
144152 // `databases` set, just enough shape for callers/tests exercising the widened (#7653) return contract.
145153 const host = `fake-${ request . tenant . name } .control-plane.invalid` ;
@@ -151,30 +159,33 @@ export function createFakeTenantProvisioningDriver(): FakeTenantProvisioningDriv
151159 } ,
152160 async injectSecrets ( request ) {
153161 record ( "injectSecrets" , request ) ;
154- injectedSecrets . add ( request . tenant . name ) ;
162+ injectedSecrets . add ( instanceKeyFor ( request ) ) ;
155163 } ,
156164 async destroyContainer ( request ) {
157165 record ( "destroyContainer" , request ) ;
158166 // Idempotent teardown: the else-branch (nothing to remove) is the "destroy-of-a-nonexistent-tenant"
159167 // lifecycle path — a no-op, never a throw.
160- if ( containers . has ( request . tenant . name ) ) {
161- containers . delete ( request . tenant . name ) ;
168+ const key = instanceKeyFor ( request ) ;
169+ if ( containers . has ( key ) ) {
170+ containers . delete ( key ) ;
162171 }
163172 } ,
164173 async dropDatabase ( request ) {
165174 record ( "dropDatabase" , request ) ;
166- if ( databases . has ( request . tenant . name ) ) {
167- databases . delete ( request . tenant . name ) ;
175+ const key = instanceKeyFor ( request ) ;
176+ if ( databases . has ( key ) ) {
177+ databases . delete ( key ) ;
168178 }
169179 } ,
170180 async revokeSecrets ( request ) {
171181 record ( "revokeSecrets" , request ) ;
172- if ( injectedSecrets . has ( request . tenant . name ) ) {
173- injectedSecrets . delete ( request . tenant . name ) ;
182+ const key = instanceKeyFor ( request ) ;
183+ if ( injectedSecrets . has ( key ) ) {
184+ injectedSecrets . delete ( key ) ;
174185 }
175186 } ,
176187 async containerExists ( request ) {
177- return containers . has ( request . tenant . name ) ;
188+ return containers . has ( instanceKeyFor ( request ) ) ;
178189 } ,
179190 } ;
180191}
0 commit comments