@@ -23,15 +23,22 @@ const CLI_BIN = join(CLI_ROOT, 'bin', 'run.js');
2323/** The ceremony's sys_migration row: its marker. */
2424export const OWNERSHIP_MARKER = 'adr-0131-organization-ownership' ;
2525
26+ /**
27+ * The environment a production `os serve` of the showcase is started with: an
28+ * auth secret, without which it is refused, and its auth family (the tenant
29+ * tables among them) is not composed.
30+ */
31+ export const SERVED_ENV : NodeJS . ProcessEnv = { OS_AUTH_SECRET : 'dogfood-upgrade-harness-auth-secret-0123456789' } ;
32+
2633/**
2734 * Run the ceremony on `file`: the plan into `dir/<tag>-plan.json`, then
2835 * `--apply --plan-file … --backup-taken`. The apply report. Throws, with both
29- * runs' output, when either exits non-zero.
36+ * runs' output, when either exits non-zero. `env` is laid over this process's.
3037 */
31- export function runOwnershipCeremony ( dir : string , file : string , tag : string ) : Record < string , unknown > {
38+ export function runOwnershipCeremony ( dir : string , file : string , tag : string , env : NodeJS . ProcessEnv = { } ) : Record < string , unknown > {
3239 const run = ( args : string [ ] ) => spawnSync ( process . execPath , [
3340 CLI_BIN , 'migrate' , 'organization-ownership' , '--database-url' , `file:${ file } ` , ...args ,
34- ] , { cwd : SHOWCASE_DIR , encoding : 'utf8' , timeout : 300_000 , env : { ...process . env , NO_COLOR : '1' } } ) ;
41+ ] , { cwd : SHOWCASE_DIR , encoding : 'utf8' , timeout : 300_000 , env : { ...process . env , ... env , NO_COLOR : '1' } } ) ;
3542 const planFile = join ( dir , `${ tag } -plan.json` ) ;
3643 const plan = run ( [ '--out' , planFile ] ) ;
3744 if ( plan . status !== 0 ) throw new Error ( `the ceremony's plan exited ${ plan . status } :\n${ plan . stdout } \n${ plan . stderr } ` ) ;
@@ -52,7 +59,7 @@ export interface SchemaPlanChange {
5259 * `os migrate plan --json` on `file`, the real binary in the showcase's
5360 * directory, as an operator reads the drift before serving a database. Writes
5461 * no row or table. The parsed document; throws, with the run's output, when it
55- * exits non-zero.
62+ * exits non-zero. `env` is laid over this process's.
5663 */
5764/** One tenant column `os migrate plan` lists as still nullable: its advisory, never drift (ADR-0131 D1). */
5865export interface NullableTenantColumn {
@@ -63,7 +70,7 @@ export interface NullableTenantColumn {
6370 reason ?: string ;
6471}
6572
66- export function runSchemaPlan ( file : string ) : {
73+ export function runSchemaPlan ( file : string , env : NodeJS . ProcessEnv = { } ) : {
6774 total : number ;
6875 changes : SchemaPlanChange [ ] ;
6976 pending : unknown [ ] ;
@@ -73,7 +80,7 @@ export function runSchemaPlan(file: string): {
7380 cwd : SHOWCASE_DIR ,
7481 encoding : 'utf8' ,
7582 timeout : 300_000 ,
76- env : { ...process . env , NO_COLOR : '1' } ,
83+ env : { ...process . env , ... env , NO_COLOR : '1' } ,
7784 } ) ;
7885 if ( plan . status !== 0 ) throw new Error ( `os migrate plan exited ${ plan . status } :\n${ plan . stdout } \n${ plan . stderr } ` ) ;
7986 return JSON . parse ( plan . stdout ) ;
0 commit comments