@@ -41,15 +41,21 @@ export type TenantLifecycleState =
4141export type TenantProvisioningRequest = {
4242 tenant : Tenant ;
4343 product : Product ;
44- /** The tenant's already-provisioned database connection details (#7653) -- populated ONLY for the
45- * `injectSecrets` call, by `provisionTenant`'s own orchestration right after `provisionDatabase` resolves
46- * (#8066). Every other step (createContainer, destroyContainer, etc.) never sees this field . */
44+ /** The tenant's already-provisioned database connection details (#7653) -- populated for the `injectSecrets`
45+ * call (and, from there on, every step after it -- see `createContainer` below) by `provisionTenant`'s own
46+ * orchestration right after `provisionDatabase` resolves (#8066) . */
4747 database ?: DatabaseConnectionDetails ;
4848 /** An opaque, driver-specific reference to a previously injected secret (#8066) -- whatever `injectSecrets`
4949 * returned as `secretRef`, threaded back in by `deprovisionTenant` so `revokeSecrets` knows what to revoke.
5050 * Absent when a tenant was never provisioned with a real secret driver configured (idempotent revoke of an
5151 * unconfigured tenant, matching every other driver's teardown contract). */
5252 secretRef ?: string ;
53+ /** A one-time credential the tenant's OWN container can later exchange for a real custodied secret (#8202) --
54+ * whatever `injectSecrets` returned as `bootstrapSecret`, threaded by `provisionTenant` into the SAME
55+ * `createContainer` call that follows it (#8202 reordered provisioning so this is possible -- see
56+ * provisioning.ts). Populated ONLY for that one `createContainer` call; no other step ever sees it, and it is
57+ * never itself the delivered secret -- just the key the container uses to fetch one. */
58+ bootstrapSecret ?: string ;
5359} ;
5460
5561/** What `provisionDatabase` hands back (#7653): everything a caller needs to actually reach the tenant's
@@ -69,7 +75,12 @@ export type DatabaseConnectionDetails = {
6975} ;
7076
7177export interface TenantProvisioningDriver {
72- /** Step 1 (#7180): stand up the tenant's isolated container. Real driver → Cloudflare Containers API. */
78+ /** Step 1 in call order (#7180), but the LAST of the three to run within `provisionTenant` as of #8202: stand
79+ * up the tenant's isolated container. Real driver → Cloudflare Containers API. May see `request.bootstrapSecret`
80+ * (#8202, set when `injectSecrets` returned one) to deliver into the container's own process environment at
81+ * this, its actual cold-boot `start()` call -- the only point in a container's lifecycle Cloudflare Containers
82+ * actually applies `envVars` (confirmed against the real `@cloudflare/containers` SDK: a repeat `start()` on
83+ * an already-running/starting instance is a no-op or throws, never re-applies `envVars`). */
7384 createContainer ( request : TenantProvisioningRequest ) : Promise < void > ;
7485 /** Step 2 (#7180): provision the tenant's database, returning its connection details (#7653) -- a freshly
7586 * created role's password is typically retrievable from the provider only at creation time, so the caller
@@ -78,10 +89,14 @@ export interface TenantProvisioningDriver {
7889 provisionDatabase ( request : TenantProvisioningRequest ) : Promise < DatabaseConnectionDetails > ;
7990 /** Step 3 (#7180): inject the tenant's secrets, given its database connection details (`request.database`,
8091 * #8066). Returns an opaque `secretRef` the caller must persist and thread back into a later `revokeSecrets`
81- * call via `request.secretRef` -- `undefined` when the driver has nothing to track (e.g. the fake). A real
82- * driver delegates to #7174's generalized broker (src/orb/broker.ts, via #8064's stored-secret type); the
83- * fake only records the call. */
84- injectSecrets ( request : TenantProvisioningRequest ) : Promise < { secretRef ?: string } > ;
92+ * call via `request.secretRef` -- `undefined` when the driver has nothing to track (e.g. the fake). Also
93+ * returns `bootstrapSecret` (#8202): a one-time credential the caller threads into the SAME tenant's next
94+ * `createContainer` call (provisioning.ts runs this step BEFORE createContainer specifically so this is
95+ * possible), so the running container can itself exchange it later for the real secret this step just
96+ * custodied -- `undefined` when the driver has nothing for a container to bootstrap with. A real driver
97+ * delegates to #7174's generalized broker (src/orb/broker.ts, via #8064's stored-secret type); the fake only
98+ * records the call. */
99+ injectSecrets ( request : TenantProvisioningRequest ) : Promise < { secretRef ?: string ; bootstrapSecret ?: string } > ;
85100 /** Teardown inverse of createContainer. MUST be idempotent — safe to call when the container was never
86101 * created — so deprovisioning a nonexistent tenant is a no-op, never a throw. */
87102 destroyContainer ( request : TenantProvisioningRequest ) : Promise < void > ;
0 commit comments