From 399d9b7d30065032e9959acc16ecc2d83093060c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 01:41:51 +0000 Subject: [PATCH 1/2] test(organizations): pin that a restart between the un-walled seed and the person's sign-up still fills the seed's person columns The held list of seed person references lives in the process, and the restart window was read as a loss. Measured: an un-walled boot runs its inline seed on every start, so the second process's replay meets the same unresolved person on the row the first landed on and holds it again. The seed declaration is the durable holder; no second record is needed. Claude-Session: https://claude.ai/code/session_01ADHkmT4PX8G5q4d3Z7C1TF Co-authored-by: Claude --- ...fault-organization-seed-owner.wall.test.ts | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts b/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts index 881b2f30c64..aa01762f693 100644 --- a/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts +++ b/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts @@ -24,6 +24,13 @@ * while its column is still NULL. So the un-walled boot resolves the owner too, * through its own moment rather than the walled replay's. * + * The held list lives in the process, and the last leg restarts between the + * seed and the person's sign-up to show that a restart loses nothing: the + * durable holder is the seed declaration itself. An un-walled boot runs its + * inline seed on every start; the replay meets the same unresolved person on + * the row it landed on before, and holds it again. No second record of the + * held references is kept. + * * ## What is real * * `bootStack` (`@objectstack/verify`): an `ObjectKernel` over in-process @@ -35,6 +42,9 @@ */ import { describe, it, expect, beforeAll, afterAll } from 'vitest'; +import { mkdtempSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; import { bootStack, type VerifyStack } from '@objectstack/verify'; import { OrganizationsPlugin } from './organizations-plugin.js'; @@ -293,3 +303,74 @@ describe('un-walled: a held seed person reference fills only the seed’s own ro expect((await taskNamed('Guest task')).assignee).toBeNull(); }); }); + +/** + * A restart between the un-walled seed and the person's sign-up loses nothing. + * The first process holds the reference in memory and stops before the person + * exists. The second process boots cold over the same database file; its own + * inline seed replays, meets the same NULL on the same row, and holds it again, + * so the person's sign-up in the second process fills the row. + */ +describe('un-walled: a restart between the seed and the person’s sign-up still fills the seed’s person columns', () => { + const env = legEnv([ + ['OS_TENANCY_POSTURE', undefined], + ['OS_AUTH_MEMBERSHIP_POLICY', undefined], + ]); + const RESTART_NAME = 'Restart Person'; + const RESTART_EMAIL = 'restart.person@example.com'; + /** Built again for each boot: a live boot holds references into its configuration. */ + const restartApp = () => ({ + ...APP, + manifest: { ...APP.manifest, id: 'com.example.seedowner.restart' }, + data: [ + { + object: TASK, + mode: 'upsert', + externalId: 'name', + records: [{ name: 'Restart task', assignee: RESTART_NAME, reviewer: RESTART_NAME }], + }, + ], + }); + const dir = mkdtempSync(join(tmpdir(), 'seed-person-restart-')); + const databaseFile = join(dir, 'restart.sqlite'); + let stack: VerifyStack | undefined; + let firstProcess: Array>; + let afterRestart: Array>; + let afterSignUp: Array>; + let personId: string; + + beforeAll(async () => { + env.apply(); + const first = await bootStack(restartApp() as never, { extraPlugins: [new OrganizationsPlugin()], databaseFile }); + const firstQl = await first.kernel.getServiceAsync('objectql'); + firstProcess = await firstQl.find(TASK, { where: {}, ...SYS }); + await first.stop(); + + stack = await bootStack(restartApp() as never, { extraPlugins: [new OrganizationsPlugin()], databaseFile }); + await stack.signIn(); + const ql = await stack.kernel.getServiceAsync('objectql'); + afterRestart = await ql.find(TASK, { where: {}, ...SYS }); + await stack.signUp(RESTART_EMAIL, undefined, RESTART_NAME); + personId = String((await ql.findOne('sys_user', { where: { email: RESTART_EMAIL }, ...SYS }))?.id ?? ''); + afterSignUp = await ql.find(TASK, { where: {}, ...SYS }); + }, 180_000); + + afterAll(async () => { + await stack?.stop(); + env.restore(); + rmSync(dir, { recursive: true, force: true }); + }); + + it('PREMISE: the first process seeded the row with NULL person columns, and the second booted over that same row', () => { + expect(firstProcess).toHaveLength(1); + expect(firstProcess[0]).toMatchObject({ assignee: null, reviewer: null }); + expect(afterRestart).toHaveLength(1); + expect(afterRestart[0]).toMatchObject({ id: firstProcess[0].id, assignee: null, reviewer: null }); + }); + + it('the person’s sign-up after the restart fills both columns on the row the first process seeded', () => { + expect(personId).not.toBe(''); + expect(afterSignUp).toHaveLength(1); + expect(afterSignUp[0]).toMatchObject({ id: firstProcess[0].id, assignee: personId, reviewer: personId }); + }); +}); From 2bd14db290a9eaeb73e6a07a4e42d7d855184d7c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:46:03 +0000 Subject: [PATCH 2/2] test(organizations): narrow the restart pin's header to keyed seed datasets A restart re-holds a seed person reference only where the replay matches the row it landed on before by its key (mode ignore, upsert, update). An insert or replace dataset matches no row on replay, so its first row is not held again; the header now says so instead of claiming every seed. Claude-Session: https://claude.ai/code/session_01ADHkmT4PX8G5q4d3Z7C1TF Co-authored-by: Claude --- ...fault-organization-seed-owner.wall.test.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts b/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts index aa01762f693..ac45bec5145 100644 --- a/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts +++ b/packages/plugins/organizations/src/default-organization-seed-owner.wall.test.ts @@ -25,11 +25,13 @@ * through its own moment rather than the walled replay's. * * The held list lives in the process, and the last leg restarts between the - * seed and the person's sign-up to show that a restart loses nothing: the - * durable holder is the seed declaration itself. An un-walled boot runs its - * inline seed on every start; the replay meets the same unresolved person on - * the row it landed on before, and holds it again. No second record of the - * held references is kept. + * seed and the person's sign-up. For a keyed dataset (`mode` `ignore`, `upsert` + * or `update`) a restart loses nothing: the durable holder is the seed + * declaration itself. An un-walled boot runs its inline seed on every start; + * the replay matches the row it landed on before by its key, meets the same + * unresolved person there, and holds it again. No second record of the held + * references is kept. An `insert` or `replace` dataset matches no row on + * replay, so its first row is not held again; that leg is not pinned here. * * ## What is real * @@ -305,11 +307,12 @@ describe('un-walled: a held seed person reference fills only the seed’s own ro }); /** - * A restart between the un-walled seed and the person's sign-up loses nothing. - * The first process holds the reference in memory and stops before the person - * exists. The second process boots cold over the same database file; its own - * inline seed replays, meets the same NULL on the same row, and holds it again, - * so the person's sign-up in the second process fills the row. + * A restart between the un-walled seed and the person's sign-up loses nothing + * for a keyed dataset (`mode: 'upsert'` here). The first process holds the + * reference in memory and stops before the person exists. The second process + * boots cold over the same database file; its own inline seed replays, matches + * the same row by its key, meets the same NULL there, and holds it again, so + * the person's sign-up in the second process fills the row. */ describe('un-walled: a restart between the seed and the person’s sign-up still fills the seed’s person columns', () => { const env = legEnv([