Skip to content

Commit 6e894de

Browse files
os-support-aiclaude
andcommitted
test(dogfood): bind the harness admin before #8119's control-note write (ADR-0123 D2)
The fixture's setup step created a tenant-scoped row as an org-less caller under an ACTIVE Layer 0 wall — the state ADR-0123 D2 now refuses. Bind the admin to an organization before the first sign-in so the setup can reach the behaviour the file actually tests. Cross-lane touch (packages/qa is domain:cli), absorbed with PM authorisation and declared on the PR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PEVB6w7D7uCszR9Mw1BL73
1 parent d498c61 commit 6e894de

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎packages/qa/dogfood/test/federated-phantom-share-grant.dogfood.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ const STAMPED = 'showcase_ext_customer';
8181
const LOCAL = 'showcase_private_note';
8282
/** A row that really exists in the remote `customers` table (fixture seed). */
8383
const REMOTE_ID = 'c1';
84+
/** The organization the harness admin is bound to (see the `beforeAll` note). */
85+
const ADMIN_ORG = 'org_8119_harness';
8486

8587
const SYS = { isSystem: true } as ExecutionContext;
8688

@@ -141,6 +143,44 @@ describe('[#8119] federated phantom anchor: single-record gates + share posture'
141143
});
142144
await registrar.syncObjectSchema(FEDERATED);
143145

146+
// [ADR-0123 D2] Bind the harness admin to an organization BEFORE the first
147+
// sign-in. This stack boots `posture-only`, i.e. the Layer 0 wall is ACTIVE,
148+
// and under a walled posture the open default-org bootstrap deliberately
149+
// abstains — so nothing binds this admin and their session resolves with no
150+
// active organization. Tenant-scoped writes are refused in that state
151+
// (a 403 naming the missing organization), which the control note below is:
152+
// the fixture used to get a 2xx and a row stamped `organization_id: null`
153+
// that its own creator could not read back — #8208, which the refusal closes.
154+
//
155+
// Done by hand because there is no harness answer: `bootStack`'s
156+
// `orgContext` option REFUSES to compose with `multiTenant` (under a walled
157+
// posture it would be a no-op that reads like a feature — the #7762 vacuity
158+
// class), so an org-bound caller here has to be built explicitly.
159+
//
160+
// This is fixture SETUP, not the subject: every assertion in this file is
161+
// about the federated phantom anchor and share posture, and none of them
162+
// reads the admin's organization. The bind exists so the setup step can
163+
// reach the behaviour under test at all. The refusal itself is measured
164+
// deliberately, on its own scenario, in
165+
// `no-active-organization-write-refusal.dogfood.test.ts`.
166+
{
167+
const adminUser = (await ql.find('sys_user', {
168+
where: { email: 'admin@objectos.ai' }, limit: 1, context: SYS,
169+
})) as unknown;
170+
const adminRow = (Array.isArray(adminUser) ? adminUser[0] : undefined) as { id?: unknown } | undefined;
171+
const adminUserId = String(adminRow?.id ?? '');
172+
expect(adminUserId, 'the seeded harness admin resolves').toBeTruthy();
173+
await ql.insert('sys_organization', { id: ADMIN_ORG, name: 'Harness Org', slug: ADMIN_ORG }, { context: SYS });
174+
await ql.insert(
175+
'sys_member',
176+
{ id: 'mem_8119_admin', organization_id: ADMIN_ORG, user_id: adminUserId, role: 'owner' },
177+
{ context: SYS },
178+
);
179+
}
180+
181+
// Signed in AFTER the membership exists: `session.create.before` resolves the
182+
// active organization at MINT time, so a token taken earlier would not carry
183+
// one however the store looks afterwards.
144184
adminToken = await stack.signIn();
145185
adminCtx = await resolveAuthzContext({
146186
ql,

0 commit comments

Comments
 (0)