You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a9c6eac
Browse filesBrowse the repository at this point in the historyBrowse files
test(server): share repeated setup in four slow non-cli test files, budget five distinct floors (#28599)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X73hQETkXSTyG7U1jQZSGsv)_
Part of #23181 (slice 26). The card stays open: other `domain:server`
files still read over 10 s (slices 24, 25, 27 and 28 hold the cli ones),
and one cause found here needs a shared helper this slice may not edit
(Acceptance notes).
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:6 个非 cli
的服务端测试文件(plugin-auth、plugin-pinyin-search、rest、verify
×2、plugin-security)。4 个文件把重复执行的相同准备工作合并成一次(cloud-managed
只注册一次三个用户再给每个用例复制数据;posture-only 三次相同启动合成一次;pinyin 三个用例共用第一次 2,500
行遍历的数据库副本;promotion-selection 每种排序只跑一遍);5 个文件加第 2 行 `// test-budget: 20`
头,因为剩下的地板是互不相同的真实工作。
- **为什么改**:卡 #23181 的测试提速职责:CI 里超过 10 s 的测试文件要么提速,要么按裁决 6181973363 B
声明预算。
- **风险与回滚**:只改测试文件,五个包的 `files[]` 都只发
`dist`、README、CHANGELOG,不发布任何东西;用例名和断言一条没删、没放宽(四个改动文件 base/head
用例名逐条一致);回滚即 revert。
-
**先看**:`packages/plugins/plugin-auth/src/cloud-managed.test.ts`(`produceStagedRows`
+ 每例 `structuredClone`
复制);`packages/plugins/plugin-pinyin-search/src/boot-reconcile.integration.test.ts`(`beforeAll`
的首次遍历与
`fromWalked`);`packages/verify/src/harness.posture-only.test.ts`(合并的启动)。
- **两分钟验证**:`pnpm --filter @objectstack/plugin-auth exec vitest run
--maxWorkers=2 src/cloud-managed.test.ts` → 32/32 通过,文件行约 2 s(base 约 6.5
s)。
- **需要你做的**:无,席位落地。
## What changes
The six files slice 23's offender table
(`pm-orders/server/evidence/23181-s23/offenders-after-s23.md`) lists
outside `packages/cli`, read from the default reporter's per-file module
line in the Test Core shard logs of the scheduled `ci.yml` runs
`41199450735`, `41217827347`, `41237094739`, `41255489006` and
`41271604267`:
| file | 0735 | 7347 | 4739 | 9006 | 4267 | tests | boots / staged
units, base → head | distinct | cause | fix |
|:--|--:|--:|--:|--:|--:|--:|:--|--:|:--|:--|
| `plugin-auth/src/cloud-managed.test.ts` | 6.9 | 19.9 | **23.6** | 15.3
| 6.8 | 32 | 14 stagings → 1 (3 fresh-salt production-scrypt sign-ups
each, about 0.1 s apiece) | 1 | the same staging per case, plus 10
`#8243` cases re-run by importing `impersonation-bearer-rotation.test` |
stage once in `beforeAll`; each case builds a fresh engine,
`AuthManager` and mount over a `structuredClone` of the staged rows. No
header (see Acceptance notes) |
| `plugin-pinyin-search/src/boot-reconcile.integration.test.ts` | 12.1 |
14.1 | 10.6 | 11.8 | **15.2** | 8 | 11 kernel boots → 10; 2,500-row
seeds 7 → 5; full walks 9 → 7 | first walk ×3 | the first boot over the
seeded history, walked with the ledger on, repeated by three cases |
that walk runs once in the describe's `beforeAll` (readings taken while
it is up); the three cases boot over a copy of the database it left
(`fromWalked`). Header 20 |
| `rest/src/meta-draft-head-package-inheritance.test.ts` | 10.6 | 11.3 |
13.7 | 13.4 | **15.0** | 25 | 39 real-stack boots at about 12 ms (0.5 s
of the file) | 25 | each case's own save/read/publish/discard sequence
on the real `/meta` routes | header 20 |
| `verify/src/harness.key-custody.test.ts` | **14.2** | 7.0 | 9.1 | 13.6
| 10.3 | 7 | 5 `bootStack` boots, all in hooks | 5 | each boot is its
cases' subject (empty home, key file, `OS_SECRET_KEY`, restart pair) |
header 20 |
| `verify/src/harness.posture-only.test.ts` | **13.8** | 7.7 | 9.8 | 6.4
| 8.7 | 5 | 5 `bootStack` boots → 3 | 3 | three cases booted the same
app with the same options and no posture set | one boot in a `beforeAll`
takes all three cases' readings (tenancy fields and `org-scoping` while
up, the posture before, during and after `stop()`). Header 20 |
|
`plugin-security/src/bootstrap-platform-admin-promotion-selection.test.ts`
| 9.5 | 7.1 | 10.9 | **13.5** | 7.3 | 25 | 27 engine boots → 24;
card-population seeds 8 → 5 | per order ×2 | the per-order cases and the
same-answer case each ran the same boot + seed + promotion per natural
order | one pass per order in the describe's `beforeAll`; both sets of
cases read it. Header 20 |
**Headers** (ruling 6181973363 letter B, class `spawns the real producer
once per single-cause fixture`): N = the slowest of the five CI readings
× 1.25, rounded up to 10 s; 20 for all five. Where the file also
changed, the header keeps its pre-change CI reading. All five parse with
`readTestBudget` (`scripts/measure-test-shard-timings.mjs`);
`cloud-managed` reads `null` (no header).
Not changed: no case name, assertion, timeout, tier or project; no
source file; no test helper (the shared `createMemoryEngine` double,
`audience-gate-test-support`, the verify harness and the security
testkits are untouched).
## Tests
- **A/B** (one box, one lock hold, base copied beside head as
`zzbase.*`, interleaved, N=3, `--maxWorkers=1`, default reporter file
line; copies deleted before the gate run):
| file | base (s) | head (s) | change (mean) |
|:--|:--|:--|--:|
| `cloud-managed` | 7.08, 6.51, 6.03 | 2.21, 2.40, 2.15 | −65.9% (6.54 →
2.25) |
| `harness.posture-only` | 6.58, 6.27, 4.94 | 4.55, 3.76, 4.11 | −29.0%
(5.93 → 4.14) |
| `promotion-selection` | 2.18, 2.10, 1.99 | 1.76, 1.78, 1.75 | −16.3%
(2.09 → 1.76) |
| `boot-reconcile.integration` | 3.89, 3.55, 3.38 | 3.05, 3.12, 3.05 |
−13.6% (3.61 → 3.07) |
Every run exit 0, same test counts both sides (32, 5, 25, 8). `vitest
list` on base and head gives the same case names for all four files
(posture-only's three cases sit one describe deeper).
- **Header-only files**, run on head:
`meta-draft-head-package-inheritance` 25/25, `harness.key-custody` 7/7.
- `pnpm --filter PKG typecheck` (tsc + `check:test-typecheck`) exit 0
for `@objectstack/plugin-auth`, `plugin-pinyin-search`, `rest`,
`verify`, `plugin-security`.
- No ablation: no tested behaviour changed (test-only).
## Acceptance notes
- **`cloud-managed` re-runs another file's ten cases.** It imports
`createMemoryEngine` from `impersonation-bearer-rotation.test.ts`, and
importing that file registers its ten `#8243` cases in the importer. On
head they are about 2.3 s of the file's per-case time, against 0.85 s
for its own 22 cases. 32 test files in `plugin-auth` import that double
the same way, so each re-runs the same ten cases. The fix is a
registration guard in that file (the shape
`metadata-protocol/src/protocol.lock-one-resolution.kit.test.ts` already
uses: register its suites only when it is the file under test), which is
a helper shared beyond this slice's files, so it is not in this PR. That
is why `cloud-managed` takes no header: its remainder is not distinct
work. Carrier: #23181.
- **`skip-changeset`.** Test-only. All five packages ship `files:
["dist", "README.md", "CHANGELOG.md"]`; after build, a source symbol
from each package is in its `dist/` (positive control) and a fixture
string from each changed test is not, so no `files[]` content changes.
## Verification
All readings on head `978d4163` (two commits, then one merge of
`origin/main` after slice 23, #28581, landed).
- **Derived gate families:** `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` on the final head → 54
families, each run with its exit code captured before any pipe, all exit
0, after a full `pnpm exec turbo run build --concurrency=2` (the
`check:dual-build-cjs-loads` and `check:i18n` prerequisites) and `git
fetch --depth=1` of the commit the teardown-shape self-test names.
`--ran` reconciliation: `✓ dispatch-gates --ran: 54 derived famil(ies)
accounted for — 54 run, 0 NOT-MEASURED`. List:
`pm-orders/server/evidence/23181-s26-gates-ran-978d4163.txt` in the
project files.
- **The six files on the final head:** 32/32, 8/8, 25/25, 7/7, 5/5,
25/25, every run exit 0.
- **Hand gates:** `pnpm exec eslint --no-inline-config` over the six
files exit 0 (none of the five packages has a `lint` script; the
repo-wide `pnpm lint` is CI's); `node
scripts/check-commit-card-trailers.mjs --range origin/main..HEAD` exit
0.
- **CI** families (Test Core, lint farm, type-check lanes) are read off
this PR's check-runs by the seat.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5kTs9zGs8tcMtB1Kys
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/plugins/plugin-pinyin-search/src/boot-reconcile.integration.test.ts
+60-22Lines changed: 60 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2
+
// test-budget: 20 — spawns the real producer once per single-cause fixture: real-kernel boots over a SQLite file holding a 2,500-row history, each remaining full walk its case's subject (the shared first walk, a write raced against a held walk, readiness against a held page, a shutdown mid-walk, the ledger-less boots, the forced rebuild); slowest CI reading 15.2 s (scheduled full-battery run 41271604267, Test Core shard log) x 1.25, rounded up; read before the three cases sharing the first walk took a copy of it
2
3
3
4
/**
4
5
* #25634 — the boot reconcile reads what changed, not the whole table, and
@@ -17,8 +18,8 @@
17
18
* `find` for the probe object — the cost a boot actually pays.
Copy file name to clipboardExpand all lines: packages/plugins/plugin-security/src/bootstrap-platform-admin-promotion-selection.test.ts
+25-13Lines changed: 25 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
// 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 on its own better-sqlite3 :memory: database per fixture, most seeded row by row through a natural-order facade (populations of up to 201 users) before the real promotion pass, each population and order its case's subject; slowest CI reading 13.5 s (scheduled full-battery run 41255489006, Test Core shard log) x 1.25, rounded up; read before the card-shape passes were shared by the per-order and same-answer cases
2
3
3
4
/**
4
5
* Commit 9b9581b11 — WHICH user the `single`-posture bootstrap promotes, and why.
Copy file name to clipboardExpand all lines: packages/rest/src/meta-draft-head-package-inheritance.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2
+
// test-budget: 20 — spawns the real producer once per single-cause fixture: 25 cases on 39 real-stack boots (better-sqlite3 :memory:, the real sys_metadata objects, protocol and routes; about 12 ms each, 0.5 s of the file), each case's own save, read, publish and discard sequence on the real /meta routes being its subject, no two the same; slowest CI reading 15.0 s (scheduled full-battery run 41271604267, Test Core shard log) x 1.25, rounded up
2
3
3
4
/**
4
5
* [#22128] One head row per `/meta` write address: the save's expected-parent
Copy file name to clipboardExpand all lines: packages/verify/src/harness.key-custody.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2
+
// test-budget: 20 — spawns the real producer once per single-cause fixture: five in-process bootStack boots, each the subject of its cases and no two the same setup (an empty key home, a key file already in the home, an OS_SECRET_KEY in the environment, and a restart pair over one database file), every boot in a hook and none warmed up at module scope; slowest CI reading 14.2 s (scheduled full-battery run 41199450735, Test Core shard log) x 1.25, rounded up
2
3
//
3
4
// [#21499] `bootStack` never creates key material in the key home, and never
0 commit comments