Repository navigation
Commit d78a7e4
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XHbvKE5cT3AmzSZKFm5wgRg)_
Part of #23181 (slice 30, the seat's ruling D on report `6555141723`).
The card stays open for later slices.
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:`impersonation-bearer-rotation.test.ts` 只在自己是 vitest
正在运行的那个文件时才注册它的 10 个 #8243 用例(`expect.getState().testPath` 与本模块路径比较);另外
6 个导入它的测试文件里,以「代价已测量」为由解释导入的注释改为现状。共享的 `createMemoryEngine` 替身、两个门禁台账、32
处 import 行都不动。
- **为什么改**:32 个测试文件从这个测试文件导入替身,每次导入都把那 10 个用例在导入方里重新注册一遍,同样 10 个用例每轮跑 33
次(#23181 测试提速职责)。
- **风险与回滚**:只改测试文件;plugin-auth 的 `files[]` 只发
`dist`、README、CHANGELOG,不发布任何东西。模块级钩子(console 桩、`restoreAllMocks`、scrypt
记忆)仍不加守卫,24 个只靠这次导入拿到 scrypt 记忆的文件照旧拿到。回滚即 revert。
-
**先看**:`packages/plugins/plugin-auth/src/impersonation-bearer-rotation.test.ts`(`isEntry`
守卫;用 `git diff -w` 看,除守卫外只有缩进变化);`admin-impersonate-endpoint.test.ts` 第
32–43 行的注释。
- **两分钟验证**:`pnpm --filter @objectstack/plugin-auth exec vitest run
--maxWorkers=2 src/impersonation-bearer-rotation.test.ts
src/admin-has-permission-endpoint.test.ts` → 前者 10 个用例、后者 3 个(base 上后者是
13 个)。
- **需要你做的**:无,席位落地。
## What changes
-
`packages/plugins/plugin-auth/src/impersonation-bearer-rotation.test.ts`:
the three top-level `describe.concurrent` blocks (the ten #8243 cases)
are wrapped in `if (isEntry) { … }`, where `isEntry =
expect.getState().testPath === fileURLToPath(import.meta.url)`. A
comment says why (#23181 slice 30, the 32 importers). The precedent is
`metadata-protocol/src/protocol.lock-one-resolution.kit.test.ts`. `git
diff -w` shows only the guard, its comment, the `fileURLToPath` import
and a re-worded #23184 comment above it (which said the cases still run
in importers). Every case keeps its body and assertions. The export and
the double are byte-identical. The module-scope hooks stay unguarded:
the console stubs, `afterEach(restoreAllMocks)`, and `memoizeScrypt()`
with `afterAll(restore)`.
- Prose in importers. Import lines do not change. `git grep` over the 32
importers for comments justifying the import by its cost, or saying the
bearer-rotation cases run there:
- `admin-impersonate-endpoint.test.ts`: the "re-registers … 10 rotation
tests also execute" sentence and "Ten duplicated hermetic tests is the
cheapest of the four." are replaced by one sentence: the file registers
its `describe`s only when it is the one run. The reason to import (one
double in both gates' sight) stays.
- `platform-admin-standing.consolidation.test.ts` and
`session-positions-security-axis.test.ts`: "re-registering that file's
`describe`s here is cheaper than minting a second engine double" becomes
"sharing its double is better than minting a second engine double".
- `admin-impersonate-endpoint`, `platform-admin-standing.consolidation`,
`session-grants-resolved-once`, `two-factor-reenrollment-verified-reset`
and `two-factor-rotated-token-echo`: in the vendor-preload comment,
"(and the bearer-rotation cases it imports)" becomes "(and, until #23181
slice 30, the bearer-rotation cases it imported)". The preload lists
themselves are untouched.
- Left as they are, because they are still true:
`bridge-redispatch-transport.pin.test.ts` line 36 and
`sso-domain-verification-unknown-provider.pin.test.ts` line 123 (the
import still registers `afterEach(restoreAllMocks)` in the importer).
## Tests
Probe, a throwaway run with two temp files deleted after. A module that
reads `expect.getState().testPath` at collection sees the file vitest is
collecting, in all three runs:
```text
=== run: kit alone
PROBE kit-module: testPath=…/zzprobe-kit.test.ts own=…/zzprobe-kit.test.ts isEntry=true Tests 1 passed (1)
=== run: importer alone
PROBE kit-module: testPath=…/zzprobe-importer.test.ts own=…/zzprobe-kit.test.ts isEntry=false
PROBE importer-module: testPath=…/zzprobe-importer.test.ts Tests 1 passed (1)
=== run: both in one invocation
PROBE kit-module: testPath=…/zzprobe-importer.test.ts … isEntry=false
PROBE kit-module: testPath=…/zzprobe-kit.test.ts … isEntry=true Tests 2 passed (2)
```
Each file gets its own module graph (vitest's default `isolate: true`;
neither plugin-auth's config nor CI turns it off), so the module is
evaluated again per file and the reading is per file.
Count and wall A/B on one box: the full plugin-auth suite in separate
invocations, interleaved base, head, base, head, base, head, in one lock
hold. Base `ce001f97` was swapped in for the 7 files and HEAD restored
after; `git diff HEAD` was empty at the end.
| run | base | head |
|:--|--:|--:|
| tests (all runs identical) | 3943 passed, 10 skipped (3953) | 3623
passed, 10 skipped (3633) |
| package wall, s | 266.7 / 263.5 / 262.1 (mean 264.1) | 256.6 / 255.8 /
246.1 (mean 252.8, −4.3%) |
| sum of all 207 default-reporter file lines, s | 229.6 / 224.6 / 225.0
| 205.0 / 205.8 / 194.0 (−11%) |
| sum of the 32 importers' file lines, s | 86.7 / 85.3 / 85.0 | 65.0 /
63.4 / 61.0 (−26%) |
- The fall is exactly 320 = 10 × 32, and every exit is 0. From the JSON
reporter, per file: each of the 32 importers falls by exactly 10.
`impersonation-bearer-rotation.test.ts` runs 10 before and 10 after. The
other 174 files' counts are identical. Run alone,
`impersonation-bearer-rotation.test.ts` reads 10/10 at head.
- The package wall falls less than the summed file lines because the run
is bound by workers and module collection, not by these cases.
- `pnpm --filter @objectstack/plugin-auth typecheck` (tsc, examples,
`check:test-typecheck`): exit 0.
- No ablation: test-only, and no tested behaviour changed.
## Acceptance notes
- `// test-budget:` headers: none added or changed (order item 6).
- The hidden limit-blind `find` double in
`plugin-sharing/src/exec-context-seam.testkit.ts`, and whether the two
double gates should walk `*.testkit.ts`, are filed by the seat as a
finding for triage. They are not in this PR.
## Verification
- Head `31320abb`. `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 51 families. All 51 were run after a
full `turbo run build` (118/118) and all exit 0. `--ran` reports: 51
accounted, 51 run, 0 NOT-MEASURED.
- `check:engine-double-contract`: exit 0, 1060 rows held by the RETAINED
ledger, as on base. `check:objectql-double-limit`: exit 0, "baseline key
set verified … no files added". Neither ledger file is in the diff.
- `eslint --no-inline-config` over the 7 files: exit 0. plugin-auth has
no lint script.
- `check-commit-card-trailers --range ce001f9..HEAD`: exit 0.
- `skip-changeset`: plugin-auth's `files[]` is `dist`, `README.md`,
`CHANGELOG.md`, and the diff is `*.test.ts` only. No `files[]` changes.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5kvkRpCLsRcpPnABwj)_
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6e11a92 commit d78a7e4
7 files changed
Lines changed: 210 additions & 194 deletions
File tree
- packages/plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
0 commit comments