Skip to content

Commit 6d833b5

Browse files
test(plugin-security): split the three-officer posture cases one per auditor variant (#35452)
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Fixes #35436 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;只拆分了一组权限测试,断言一条不少、含义不变。 - 为什么做:这组测试在 CI 负载高时会撞到单条测试 5 秒的默认上限,跟改动无关却让别的修复一直是红的。 - 出错会怎样:只动测试,不动产品代码;撤回即可。 - 要你做什么:无,席位落地。 ## 席位核对 ### What changes - `packages/plugins/plugin-security/src/org-admin-assignment-boundary.posture.test.ts`, the three-officer describe. The 12 cases (2 postures × 6 callers) each looped over the 3 auditor variants. They become 36 cases (2 postures × 6 callers × 3 variants). Each case does one variant's grant insert, removal by id, bulk removal and position holding, then removes every row it wrote, with the same `finally` as before. Every `expect` line is unchanged. The only code that moved is the `for (const variant ...)` loop, lifted from inside the `it` to around it. - The file's `test-budget:` header line keeps its number (20) and its class. Its REASON now says 128 cases, thirty-six of them three-officer cases, and why they were split. - No global `testTimeout` raise, no per-case timeout, no skip, nothing deleted. - Two-minute check: run this one file. You should see 128 green, with each three-officer case under 0.25 s locally. ### Tests These were run locally on one shared 4-core box under `os-verify-lock.sh`. Absolute seconds are shared-box readings; the ratios are the claim. Head `3de047739a`: | | before (BASE `a9b36efffa`) | after (`3de047739a`) | |---|---|---| | file | 104 passed, tests phase 20.94 s | 128 passed, tests phase 22.27 s | | three-officer cases | 12, 265 to 611 ms each | 36, 71 to 223 ms each | The slowest three-officer case drops from 611 ms to 223 ms (×0.36). Applied to the worst CI reading on the card (5534 ms on #35386's loaded shard), that is about 2.0 s, which leaves 2.5× headroom under the 5 s default. <details><summary>vitest verdict lines</summary> ```text before: Test Files 1 passed (1) Tests 104 passed (104) Duration 30.67s (tests 20.94s) after: Test Files 1 passed (1) Tests 128 passed (128) Duration 32.81s (tests 22.27s) os-verify-lock: VERDICT command-exit 0 (both runs) typecheck (@objectstack/plugin-security, tsc + scripts + check:test-typecheck): VERDICT command-exit 0 ``` </details> ### Acceptance notes - Mechanism reading: the repo's declared-budget shape is the one-line file header `test-budget: SECONDS — CLASS: REASON`, which `scripts/measure-test-shard-timings.mjs` (`readTestBudget`) reads. It governs the timings report's 10 s per-FILE wall line, not vitest's per-case timeout, and this file already carries one (20 s). It cannot hold a single case under 5 s, so splitting is the route. - The card reports the whole file at 75 to 179 s on loaded CI shards, against its declared 20 s budget. That was not re-measured here; it is left for the timings refresh lane. - Three other cases in the same file (the per-posture hidden-column cases) run about 0.56 to 0.64 s locally, the same order as the old three-officer cases. None is reported timing out, and they are untouched. ### Verification - Gates: `node scripts/pm/dispatch-gates.mjs --commands` derived 54 commands for this diff. 52 exit 0. 2 exited 3, PREREQUISITE NOT MET (`check:i18n` and `check:dual-build-cjs-loads` need a full workspace build); they are recorded NOT MEASURED and left to CI. `--ran` reconciliation: 54 accounted, 52 run, 2 NOT-MEASURED, 0 UNRUN. - `skip-changeset`: this is a test-only diff, so nothing is published. - No ablation: no tested behaviour changed. The assertions are byte-identical; only their grouping into cases moved. --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 20badae commit 6d833b5

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)