Repository navigation
Commit 12a1aba
test(ui/scripts): take the dead-keys sweep's whole-repo readings once, at collection (#27437)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ89F6xaEdNtTsXsYJyUBby9i)_
Fixes #27423
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`check-i18n-dead-keys.test.ts`
里读真实仓库的四个读数(`sweep`、`analyze`、`collectEnKeys`、间接模板头)每个文件只算一次,在 describe
体(收集阶段)里取,三个用例不再在自己的 15 秒预算里重扫整个仓库。
- 为什么改:main 上 `Test UI (10/16)` 在用例「keeps every key it makes reachable
OUT of both tiers」超时 15 秒;同一 sha
在合并队列里是绿的,属于负载下的间歇红。按裁决不调超时、不跳过、不重试、不改断言。
- 风险与回滚:只动一个测试文件,断言逐条不变,读数被冻结,用例之间无法互相污染;回滚即 revert 本 PR。
- 先看:`ui/scripts/__tests__/check-i18n-dead-keys.test.ts` 顶部新增的
`realTree` 备忘块,以及两个 `on the real tree` / `measured on THIS repository`
describe 体里的取值行。
- 两分钟验证:`pnpm --dir ui exec vitest run
scripts/__tests__/check-i18n-dead-keys.test.ts`,预期 146
passed,三个原慢用例各在几毫秒内完成。
- 需要你做的:无,席位落地。
## What changes
`ui/scripts/__tests__/check-i18n-dead-keys.test.ts` only.
- A module-level `realTree` memo takes each whole-repository reading
once per file: `sweep(REPO_ROOT)`, `analyze(REPO_ROOT)`,
`collectEnKeys(REPO_ROOT)` and `collectIndirectTemplateHeads(REPO_ROOT,
…)`. Each value is frozen (arrays and plain objects, recursively), so a
case that sorted or spliced one in place would throw instead of leaking
into the next case.
- The two describes that read the real tree (`the one-hop indirect
template leg › on the real tree` and `the applied dynamic heads are
REPORTED, not filtered › measured on THIS repository`) now take those
values in their describe bodies, which run at collection. Three cases
lose their in-case repository walks:
- `keeps every key it makes reachable OUT of both tiers` (the red one):
its own `sweep(repoRoot)`.
- `⛔ does NOT enrol its heads in the call-site gate’s family registry`:
its own `analyze(repoRoot)`.
- `reports one row per head the sweep actually applied — no head goes
unreported`: its own `analyze(repoRoot)` plus
`collectIndirectTemplateHeads(repoRoot, collectEnKeys(repoRoot))`.
- Three more `collectEnKeys(repoRoot).leaves` reads in the second
describe read the shared `packKeys` instead.
- `scripts/check-i18n-dead-keys.mjs` is untouched: no seam was needed.
## Why
The ruling carried over from #27076 holds: the timeout is not raised, no
case is skipped, no retry is added, and no assertion changes. The cost
was the test's own, so the cost moved out of the cases.
Collection is the right home. `ui/AGENTS.md` (测试纪律) puts warm-up cost at
module scope because no test or hook timeout bounds it, and it rules out
a `beforeAll`, whose 10 s `hookTimeout` is narrower than the 15 s
`testTimeout`. The second describe already took its `sweep(repoRoot)` in
its body; this PR makes both describes share that one reading. In
`@vitest/runner` 4.1.12, `withTimeout` wraps test bodies and hooks only,
not the suite collect path.
## Tests
Measured on this container (4 cores, a shared box). "Load" means four
`node -e 'for(;;){}'` CPU burners beside the run. Every run went through
`scripts/pm/os-verify-lock.sh`. Durations come from vitest's JSON
reporter (per case) and its `Duration` line (per file).
| leg | red case | `reports one row per head…` | `does NOT enrol…` |
file `Duration` (import / tests) | result |
|---|---|---|---|---|---|
| before, first run after install (cold) | **15305 ms, timed out** |
6482 ms | 4439 ms | lock held 45 s | 145/146, red |
| before, idle | 8378 ms | 5909 ms | 4709 ms | 32.52 s (11.40 / 20.74) |
146/146 |
| before, load | 10507 ms | 7544 ms | 5504 ms | 44.90 s (17.87 / 26.40)
| 146/146 |
| after, first run | 2 ms | 0 ms | 0 ms | lock held 22 s | 146/146 |
| after, idle | 3 ms | 0 ms | 0 ms | 20.82 s (18.32 / 2.04) | 146/146 |
| after, load | 5 ms | 1 ms | 0 ms | 31.34 s (27.51 / 3.15) | 146/146 |
The cold "before" run reproduces the main-red: the same case, `Error:
Test timed out in 15000ms`. After the change, the slowest case in the
file under load is 404 ms (`both control groups from the card …
POSITIVE`). The collection phase grows by the one extra `analyze()`
reading, about 7 s idle and 10 s loaded. No timeout bounds that phase.
The file's total wall drops by about 12 s idle and 13.5 s loaded.
The before legs ran the file restored from `HEAD~1` by `git restore
--source=HEAD~1`, with a trap that restores `HEAD`. Restore proof: `git
hash-object` = `git rev-parse HEAD:…` = `9c08a7b0`, and `git status
--porcelain` is empty.
## Acceptance notes
- Finding, not fixed here (the dispatch order asked for a read-only
measurement): `ui/scripts/__tests__/check-vi-mock-inherit.test.ts` has
the same in-case repository-sweep shape. Idle on this box, three cases
take 6.1 to 6.8 s each: `puts the census in the verdict…` (it spawns
`node scripts/check-vi-mock-inherit.mjs` over the whole tree) and both
`the sweep — every @object-ui/i18n factory inherits…` cases, which each
call `swept()` (a `scan(repoRoot, …)`) in-case. The file runs 29.17 s
(import 7.05 s, tests 21.77 s). About 2x load would put them near the 15
s budget.
- The card's "Done when" needs two consecutive green push runs and the
next scheduled full run. Those happen after merge and are the seat's to
read.
## Verification
Gates derived by `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at the final head. The exit codes and the
`--ran` reconciliation are in the os-dev report on #27423.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (CI owns the lint run)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset. This one publishes
nothing: it is a test file under the private `ui/` root, so the PR
carries `skip-changeset`.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (The 维护者速读 block is
the repo's Chinese summary convention.)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYeSmhiCsoJFL2RkQS)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e24d4eb commit 12a1aba
1 file changed
Lines changed: 52 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
47 | 86 | | |
48 | 87 | | |
49 | 88 | | |
| |||
1677 | 1716 | | |
1678 | 1717 | | |
1679 | 1718 | | |
1680 | | - | |
1681 | | - | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
1682 | 1724 | | |
1683 | 1725 | | |
1684 | 1726 | | |
| |||
1715 | 1757 | | |
1716 | 1758 | | |
1717 | 1759 | | |
1718 | | - | |
1719 | 1760 | | |
1720 | 1761 | | |
1721 | 1762 | | |
| |||
1730 | 1771 | | |
1731 | 1772 | | |
1732 | 1773 | | |
1733 | | - | |
1734 | 1774 | | |
1735 | 1775 | | |
1736 | 1776 | | |
| |||
2008 | 2048 | | |
2009 | 2049 | | |
2010 | 2050 | | |
2011 | | - | |
2012 | | - | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
2013 | 2056 | | |
2014 | 2057 | | |
2015 | | - | |
2016 | | - | |
2017 | 2058 | | |
2018 | 2059 | | |
2019 | 2060 | | |
| |||
2024 | 2065 | | |
2025 | 2066 | | |
2026 | 2067 | | |
2027 | | - | |
| 2068 | + | |
2028 | 2069 | | |
2029 | 2070 | | |
2030 | 2071 | | |
| |||
2037 | 2078 | | |
2038 | 2079 | | |
2039 | 2080 | | |
2040 | | - | |
| 2081 | + | |
2041 | 2082 | | |
2042 | 2083 | | |
2043 | 2084 | | |
| |||
2051 | 2092 | | |
2052 | 2093 | | |
2053 | 2094 | | |
2054 | | - | |
| 2095 | + | |
2055 | 2096 | | |
2056 | 2097 | | |
2057 | 2098 | | |
| |||
0 commit comments