Skip to content

Commit 3de0477

Browse files
committed
test(plugin-security): split the three-officer cases one per auditor variant
Each of the twelve caller cases did three variants' grant insert, removal by id, bulk removal and position holding, and on loaded Test Core shards reached vitest's 5 s per-test default. One case per posture, caller and variant does a third of that work; every assertion is unchanged. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-authored-by: Claude <noreply@anthropic.com>
1 parent a9b36ef commit 3de0477

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

‎packages/plugins/plugin-security/src/org-admin-assignment-boundary.posture.test.ts‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2-
// test-budget: 20 — spawns the real producer once per single-cause fixture: a fresh real ObjectQL engine and SecurityPlugin per case across three postures, 104 cases that each write and read back the same holder's assignments, so no boot is shared across cases, save the three delegated cases split one `it` per table, whose tables run in order on one boot and write ids of their own, and the twelve three-officer cases, which share one boot per posture and remove every row each wrote; 17.5 s in a local run on a shared 4-core box (18.2 s before the split); slowest CI reading 10.9 s (scheduled full-battery run 41199450735, Test Core shard log) x 1.25, rounded up; the three-officer cases add 39% on one shared box (tests phase 29.0 s against 20.8 s without them), so 10.9 s projects to 15.2 s, 19.0 s with headroom
2+
// test-budget: 20 — spawns the real producer once per single-cause fixture: a fresh real ObjectQL engine and SecurityPlugin per case across three postures, 128 cases that each write and read back the same holder's assignments, so no boot is shared across cases, save the three delegated cases split one `it` per table, whose tables run in order on one boot and write ids of their own, and the thirty-six three-officer cases (one per posture, caller and auditor variant, split from twelve so no case carries three variants' writes under vitest's 5 s per-test default), which share one boot per posture and remove every row each wrote; 17.5 s in a local run on a shared 4-core box (18.2 s before the split); slowest CI reading 10.9 s (scheduled full-battery run 41199450735, Test Core shard log) x 1.25, rounded up; the three-officer cases add 39% on one shared box (tests phase 29.0 s against 20.8 s without them), so 10.9 s projects to 15.2 s, 19.0 s with headroom
33

44
/**
55
* [ADR-0090 D12, amended 2026-10-17] The organization administrator's
@@ -1149,16 +1149,19 @@ describe('[ADR-0090 D12, amended 2026-10-17] the three-officer split: an auditor
11491149
await harness().engine.insert('sys_member', { id: `m_${userId}`, user_id: userId, organization_id: ORG_A, role }, inA);
11501150
}
11511151
});
1152+
// One case per caller and variant: each does one variant's grant insert,
1153+
// removal by id, bulk removal and position holding, so no single case
1154+
// carries three variants' writes under vitest's per-test default.
11521155
for (const caller of Object.keys(OFFICER_CALLERS) as OfficerCaller[]) {
1153-
it(`${caller}: adding and removing a holder — a grant, its removal by id, its bulk removal, a position holding — answers per variant`, async () => {
1154-
const h = harness();
1155-
const context = OFFICER_CALLERS[caller];
1156-
const door = bulkDoorOver(h.engine);
1157-
// Holders seated in `a_ops`: one receives each insert, the others hold the seeded rows.
1158-
const holders = IN_SCOPE_HOLDERS.slice(0, 4);
1159-
const [inserted, removed, bulkA, bulkB] = holders;
1160-
try {
1161-
for (const variant of AUDITOR_VARIANTS) {
1156+
for (const variant of AUDITOR_VARIANTS) {
1157+
it(`${caller} · ${variant}: adding and removing a holder — a grant, its removal by id, its bulk removal, a position holding — answers as the variant's verdict says`, async () => {
1158+
const h = harness();
1159+
const context = OFFICER_CALLERS[caller];
1160+
const door = bulkDoorOver(h.engine);
1161+
// Holders seated in `a_ops`: one receives each insert, the others hold the seeded rows.
1162+
const holders = IN_SCOPE_HOLDERS.slice(0, 4);
1163+
const [inserted, removed, bulkA, bulkB] = holders;
1164+
try {
11621165
const expected = OFFICER_EXPECTED[caller][variant];
11631166
const setName = AUDITOR_SETS[variant].name;
11641167
const cell = `${caller} · ${variant}`;
@@ -1206,13 +1209,13 @@ describe('[ADR-0090 D12, amended 2026-10-17] the three-officer split: an auditor
12061209
expect((answer.details as any)?.permissionSet, `${cell} · ${what}`).toBe(setName);
12071210
}
12081211
}
1212+
} finally {
1213+
for (const table of TABLE_NAMES) {
1214+
await h.engine.delete(table, { where: { user_id: { $in: holders } }, multi: true, context: SYS } as any);
1215+
}
12091216
}
1210-
} finally {
1211-
for (const table of TABLE_NAMES) {
1212-
await h.engine.delete(table, { where: { user_id: { $in: holders } }, multi: true, context: SYS } as any);
1213-
}
1214-
}
1215-
});
1217+
});
1218+
}
12161219
}
12171220
});
12181221
}

0 commit comments

Comments
 (0)