Skip to content

Commit 30629ff

Browse files
committed
fix(dogfood): the criteria-less legacy sharing-rule row carries the organization the admin acts in
The case "a criteria-less rule already IN the table shares nothing and loses its grants" wrote its legacy row at the driver seam with no organization_id. Since the organization-less readers of sharing rules retired (ADR-0131 D1/D8, 7cacad5), no admin read resolves such a row, so POST /sharing/rules/srule_3896_legacy/evaluate answered 404 before the criteria guard the case pins was reached. The row now carries the admin's active organization, read off the admin's own session: the shape a pre-gate row has once the organization-ownership ceremony attributes it (ADR-0131 D10). Every assertion is unchanged: evaluate answers below 300, matches 0 records, and materialises no grant. Claude-Session: https://claude.ai/code/session_01LmjU2x1faLZ39DVTFyVca6 Co-authored-by: Claude <noreply@anthropic.com>
1 parent c2d4072 commit 30629ff

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎packages/qa/dogfood/test/sharing-rule-criteria-required.dogfood.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ describe('#3896 — a sharing rule POSTed without criteria is rejected, never ma
134134
// defense-in-depth the flip bought. A true legacy row predates all of it:
135135
// write it at the DRIVER seam, the same level a pre-gate deployment's
136136
// storage actually holds it.
137+
//
138+
// The row carries the organization the admin acts in. That is the shape a
139+
// pre-gate row has once the organization-ownership upgrade ceremony has
140+
// attributed it (ADR-0131 D10), and the only shape a certified deployment
141+
// holds. A row with no organization is one no admin read resolves any more
142+
// (ADR-0131 D1/D8: the caller's own organization only), so `evaluate`
143+
// would answer 404 before the criteria guard this case pins is reached.
144+
// The organization is read off the admin's own session, the field the
145+
// request context of the `evaluate` call below is resolved from.
146+
const me = await stack.apiAs(admin, 'GET', '/auth/get-session');
147+
expect(me.status, 'get-session answers for the admin').toBe(200);
148+
const organizationId = ((await me.json()) as { session?: { activeOrganizationId?: string | null } })
149+
.session?.activeOrganizationId;
150+
expect(organizationId, 'the admin acts in an organization').toMatch(/^\S+$/);
151+
137152
const id = 'srule_3896_legacy';
138153
const driver = (ql as any).getDriverForObject('sys_sharing_rule');
139154
expect(driver, 'sys_sharing_rule driver must be resolvable').toBeTruthy();
@@ -147,6 +162,7 @@ describe('#3896 — a sharing rule POSTed without criteria is rejected, never ma
147162
recipient_id: 'sales_rep',
148163
access_level: 'read',
149164
active: true,
165+
organization_id: organizationId,
150166
});
151167

152168
const res = await stack.apiAs(admin, 'POST', `${RULES}/${id}/evaluate`, {});

0 commit comments

Comments
 (0)