@@ -146,7 +146,9 @@ for (const plugin of stack.plugins) await kernel.use(plugin);
146146await kernel.use(new PlatformObjectsPlugin());
147147await runtime.start();
148148const ql = kernel.getService('objectql');
149- const SYSTEM = { context: { isSystem: true } };
149+ // The fixture's rows name an organization: a fresh tenant column is NOT NULL
150+ // (ADR-0131 D1), and this stack composes no authentication to derive one.
151+ const SYSTEM = { context: { isSystem: true, tenantId: 'org_fixture' } };
150152await ql.insert('sys_metadata_history', {
151153 id: 'h_21529', event_seq: 1, name: 'os21529_note', type: 'object', version: 1,
152154 operation_type: 'create', recorded_by: 'system', recorded_at: new Date().toISOString(),
@@ -405,7 +407,9 @@ await kernel.use(new SettingsServicePlugin({
405407await kernel.use(new StorageServicePlugin({ registerRoutes: false }));
406408await runtime.start();
407409const ql = kernel.getService('objectql');
408- const SYSTEM = { context: { isSystem: true } };
410+ // The fixture's rows name an organization: a fresh tenant column is NOT NULL
411+ // (ADR-0131 D1), and this stack composes no authentication to derive one.
412+ const SYSTEM = { context: { isSystem: true, tenantId: 'org_fixture' } };
409413await ql.insert('sys_metadata', {
410414 type: 'object', name: 'os21552_note', state: 'active',
411415 metadata: JSON.stringify({ name: 'os21552_note', fields: { title: { type: 'text' } } }),
@@ -414,6 +418,8 @@ await kernel.shutdown();
414418
415419const raw = new SqlDriver({ client: 'better-sqlite3', connection: { filename: process.env.FIXTURE_DB }, useNullAsDefault: true });
416420const k = raw.knex;
421+ // Rows planted below the writer name the fixture's organization: every table
422+ // this release created has a NOT NULL tenant column (ADR-0131 D1).
417423await k.raw('CREATE TABLE sys_account (id text primary key, provider_id text, account_id text, issuer text, user_id text)');
418424await k('sys_account').insert([
419425 { id: 'acc_1', provider_id: 'github', account_id: 'g-1', issuer: 'github', user_id: 'u1' },
@@ -429,7 +435,7 @@ await k('sys_audit_log').insert({
429435const shard = (await k.raw("select name from sqlite_master where type = 'table' and name glob 'sys_activity__r*'"))[0];
430436if (!shard) throw new Error('the control has no sys_activity shard: the rotation did not run');
431437await k(shard.name).insert({
432- id: 'act_21552', timestamp: new Date().toISOString(), type: 'create', summary: 'created', object_name: 'sys_metadata', record_id: 'm_21552',
438+ organization_id: 'org_fixture', id: 'act_21552', timestamp: new Date().toISOString(), type: 'create', summary: 'created', object_name: 'sys_metadata', record_id: 'm_21552',
433439 metadata: JSON.stringify({
434440 old: null,
435441 new: {
@@ -446,23 +452,23 @@ await k('sys_audit_log').insert({
446452 new_value: JSON.stringify({ id: 'em_24693', subject: 's', body_text: 'mail-body-sentinel-24693', body_html: null }),
447453});
448454await k(shard.name).insert({
449- id: 'act_24693', timestamp: new Date().toISOString(), type: 'create', summary: 'created', object_name: 'sys_email', record_id: 'em_24693',
455+ organization_id: 'org_fixture', id: 'act_24693', timestamp: new Date().toISOString(), type: 'create', summary: 'created', object_name: 'sys_email', record_id: 'em_24693',
450456 changed_fields: '[]',
451457 metadata: JSON.stringify({ old: null, new: { id: 'em_24693', subject: 's', body_text: 'mail-body-sentinel-24693', body_html: null } }),
452458});
453459await k('sys_comment').insert({
454- id: 'cmt_23857', thread_id: 'sys_metadata:m_21552', body: 'planted below the writer', author_id: 'u1',
460+ organization_id: 'org_fixture', id: 'cmt_23857', thread_id: 'sys_metadata:m_21552', body: 'planted below the writer', author_id: 'u1',
455461 created_at: new Date().toISOString(),
456462});
457463await k('sys_secret').insert({
458464 id: 'sec_21552', namespace: 'os21552', key: 'orphan', kms_key_id: 'local', alg: 'aes-256-gcm', version: 1, ciphertext: 'not-a-real-ciphertext',
459465});
460466await k('sys_file').insert({
461- id: 'file_21552', key: 'attachments/os21552.txt', name: 'os21552.txt', size: 12, scope: 'attachments', status: 'committed',
467+ organization_id: 'org_fixture', id: 'file_21552', key: 'attachments/os21552.txt', name: 'os21552.txt', size: 12, scope: 'attachments', status: 'committed',
462468});
463469// A retired field's column: in the table, in no metadata, holding a value.
464470await k.raw('ALTER TABLE os21529_contact ADD COLUMN legacy_note text');
465- await k('os21529_contact').insert({ id: 'con_21573', name: 'Ann', legacy_note: 'kept-21573' });
471+ await k('os21529_contact').insert({ id: 'con_21573', name: 'Ann', legacy_note: 'kept-21573', organization_id: 'org_fixture' });
466472await raw.disconnect();
467473process.stderr.write('[fixture] seeded\\n');
468474process.exit(0);
0 commit comments