Skip to content

Commit 4320293

Browse files
committed
wip: harness pins compose the served auth family
Claude-Session: https://claude.ai/code/session_01RXxXFcq659RGJE6SsXAc3u Co-authored-by: Claude <noreply@anthropic.com>
1 parent 68bb8bd commit 4320293

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎packages/qa/dogfood/test/upgrade-18x-harness.dogfood.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import type { VerifyStack } from '@objectstack/verify';
5555
import { columnsOf, type FixtureManifest } from './upgrade-harness/fixture-manifest.js';
5656
import { FIXTURE_NAMES, FIXTURE_PEOPLE, bootFixture } from './upgrade-harness/populate-fixture.js';
5757
import { loadSqlIntoSqlite } from './upgrade-harness/sqlite-text-dump.js';
58-
import { OWNERSHIP_MARKER, runOwnershipCeremony, runSchemaPlan } from './upgrade-harness/ceremony.js';
58+
import { OWNERSHIP_MARKER, SERVED_ENV, runOwnershipCeremony, runSchemaPlan } from './upgrade-harness/ceremony.js';
5959

6060
const FIXTURE = new URL('./upgrade-harness/fixture-18.0/', import.meta.url);
6161
const MARKER = OWNERSHIP_MARKER;
@@ -368,7 +368,7 @@ describe(`[#24884] an 18.0.0 database (fixture from ${gaManifest.ref} @ ${gaMani
368368
}, 320_000);
369369

370370
it('[ADR-0131 D1] HEAD\'s schema plan lists its nullable tenant columns as an advisory naming the ceremony, and as no drift', () => {
371-
const plan = runSchemaPlan(file);
371+
const plan = runSchemaPlan(file, SERVED_ENV);
372372
const advisory = plan.nullableTenantColumns;
373373
if (advisory.status !== 'read') throw new Error(`the advisory did not read: ${advisory.detail}`);
374374
expect(advisory.remedy).toBe('os migrate organization-ownership');
@@ -424,7 +424,7 @@ describe(`[#24884] an 18.0.0 database (fixture from ${gaManifest.ref} @ ${gaMani
424424
expect(stack, 'HEAD has stopped before the ceremony reads the file').toBeUndefined();
425425
const ceremonied = join(dir, 'ga.ceremonied.db');
426426
copyFileSync(file, ceremonied);
427-
const report = runOwnershipCeremony(dir, ceremonied, 'ga-voluntary') as {
427+
const report = runOwnershipCeremony(dir, ceremonied, 'ga-voluntary', SERVED_ENV) as {
428428
complete?: boolean;
429429
steps?: Array<{ step: string; summary: Record<string, number>; notes: string[] }>;
430430
};
@@ -434,7 +434,7 @@ describe(`[#24884] an 18.0.0 database (fixture from ${gaManifest.ref} @ ${gaMani
434434
expect(notNull.summary.alreadyNotNull, JSON.stringify(notNull)).toBeGreaterThanOrEqual(1);
435435
expect(notNull.notes.filter((n) => /created with \S+ nullable column/.test(n))).toEqual([]);
436436

437-
const plan = runSchemaPlan(ceremonied);
437+
const plan = runSchemaPlan(ceremonied, SERVED_ENV);
438438
const advisory = plan.nullableTenantColumns;
439439
if (advisory.status !== 'read') throw new Error(`the advisory did not read: ${advisory.detail}`);
440440
expect(advisory.columns.filter((c) => c.ceremony === 'tightens'), 'a column the ceremony would still tighten').toEqual([]);
@@ -448,7 +448,7 @@ describe(`[#24884] an 18.0.0 database (fixture from ${gaManifest.ref} @ ${gaMani
448448
const fresh = join(dir, 'fresh.db');
449449
const booted = await bootFixture(fresh);
450450
await booted.stop();
451-
const plan = runSchemaPlan(fresh);
451+
const plan = runSchemaPlan(fresh, SERVED_ENV);
452452
expect(plan.nullableTenantColumns).toEqual({ status: 'read', adr: 'ADR-0131 D1', remedy: 'os migrate organization-ownership', columns: [] });
453453
// Its only nullable `organization_id` is the opt-out, which is no tenant column.
454454
expect(nullableOrganizationTables(fresh)).toEqual(['sys_sso_provider']);

‎packages/qa/dogfood/test/upgrade-harness/ceremony.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ const CLI_BIN = join(CLI_ROOT, 'bin', 'run.js');
2323
/** The ceremony's sys_migration row: its marker. */
2424
export 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). */
5865
export 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

Comments
 (0)