Skip to content

Commit 48462a1

Browse files
hotlongclaude
andcommitted
test(runtime): the seed-apply org-scope file hands its organization in where dispatch() now reads it
Its organization arrived through a stubbed `getSession`, the raw source this card retires; after the fix every measurement in the file had moved to the one-rung branch and only its section-0 control caught it. The organization now lands on the execution context's `tenantId`, and the dead session stub is gone. Claude-Session: https://claude.ai/code/session_local_1d2a197c-c20e-4e90-9be8-413d4d432289 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 65534cf commit 48462a1

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

‎packages/runtime/src/domains/packages-seed-apply-org-scope.test.ts‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* would double-insert"). So the second call presents a `publishPackageDrafts`
5151
* that reports the published seed without a `seedApplied` field — the exact
5252
* population this fallback documents itself as existing for. It also records
53-
* the request it received, which is §0's positive control that the session's
53+
* the request it received, which is §0's positive control that the caller's
5454
* organization really reached this request.
5555
*
5656
* ## Sections, and which are evidence vs. which are the bound
@@ -217,18 +217,24 @@ function makeEngine() {
217217
return engine;
218218
}
219219

220-
/** An authenticated package admin — the route's anonymous-deny + capability floor. */
221-
const PKG_ADMIN = (): any => ({
220+
/**
221+
* An authenticated package admin — the route's anonymous-deny + capability
222+
* floor. `organizationId` lands where `dispatch()`'s identity step puts the
223+
* caller's VETTED organization, the execution context's `tenantId`: the one
224+
* source the route reads (#20477), never the session claim as stored.
225+
*/
226+
const PKG_ADMIN = (organizationId?: string): any => ({
222227
request: { headers: {} },
223228
environmentId: 'env_1',
224229
executionContext: {
225230
userId: 'u_pkg_admin',
226231
systemPermissions: ['manage_metadata', 'studio.access', 'setup.access'],
232+
...(organizationId ? { tenantId: organizationId } : {}),
227233
},
228234
});
229235

230236
interface DriveOptions {
231-
/** Session's active organization; `undefined` drives the one-rung branch. */
237+
/** The caller's vetted active organization; `undefined` drives the one-rung branch. */
232238
activeOrganizationId?: string;
233239
/** Injection: the read-back throws this instead of answering. */
234240
readBackError?: () => Error;
@@ -297,13 +303,6 @@ async function publishThenRead(opts: DriveOptions = {}) {
297303
fields: { name: { type: 'text' }, status: { type: 'select' } },
298304
}),
299305
},
300-
auth: {
301-
api: {
302-
getSession: async () => (opts.activeOrganizationId
303-
? { session: { activeOrganizationId: opts.activeOrganizationId } }
304-
: { session: {} }),
305-
},
306-
},
307306
};
308307
const kernel: any = {
309308
getServiceAsync: async (name: string) => services[name] ?? null,
@@ -312,7 +311,7 @@ async function publishThenRead(opts: DriveOptions = {}) {
312311
};
313312

314313
const result = await new HttpDispatcher(kernel).handlePackages(
315-
`/${PKG}/publish-drafts`, 'POST', {}, {}, PKG_ADMIN(),
314+
`/${PKG}/publish-drafts`, 'POST', {}, {}, PKG_ADMIN(opts.activeOrganizationId),
316315
);
317316
expect(result.response?.status).toBe(200);
318317
const body: any = (result.response as any)?.body;
@@ -388,7 +387,7 @@ describe('#15068 · 0 · the publish-then-read path really runs', () => {
388387
expect(served?.item?.records).toHaveLength(2);
389388
});
390389

391-
it('the session organization really reaches this request', async () => {
390+
it('the caller\'s organization really reaches this request', async () => {
392391
const { publishRequest } = await publishThenRead({ activeOrganizationId: ORG });
393392

394393
// `applyPublishedSeeds` receives the SAME binding this route handed

0 commit comments

Comments
 (0)