Repository navigation
Commit 3cdb162
ci(test-shards): the density cap carries the declaration closure's own displacement when a split carries the reader slice (#29838)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSi9paTx1Lu8ENYwwssthfK3h)_
Fixes #29777
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:Test Core 分片器判断「这次要不要把 CLI
切片」时,若切出的方案带着声明构建那一片,密度上限加上闭包计费分摊到其余分片的那一份(783 秒 ÷ 7 ≈ 112
秒);不带那一片时上限不变。
- 为什么改:每周分片计时刷新被分片器自检拒收。新数据里 CLI 降到 1432 秒、低于平均,原上限等于平均值,而闭包计费必然把其余分片推高约
7%,于是任何切法都过不了,全量运行只能把 CLI 整包串行跑(约 24 分钟,其余分片约 8 分钟)。
- 风险与回滚:只动一个仓根脚本,不发布任何包;今天的已提交数据切分结果逐字节不变。回滚即 revert 本 PR,影响仅是刷新 PR
再次被拒。
- 先看:`scripts/partition-test-shards.mjs` 的 `closureAllowance()` 与
`planShards()` 里 WITHIN CAP 那几行;再看自检新增的四个「declaration-closure
allowance」用例。
- 两分钟验证:`node scripts/partition-test-shards.mjs --self-test`,应见
`self-test OK`,且 bins 仍为
1600.11/1597.48/1597.14/1599.09/1598.01/1597.78/1599.48/1597.04s。
- 需要你做的:无,席位落地。
## What changes
`scripts/partition-test-shards.mjs` only, implementing maintainer ruling
record 6596963071 (option B, the first of its two slices):
- **`closureAllowance(items, shardCount)`** (new):
`DECLARATION_CLOSURE_CHARGE_SECONDS / (shardCount - 1)` when the items
carry the declaration-reader slice's closure charge, `0` otherwise and
on a one-shard run. Its docblock carries the measured reason. The charge
(783 s of packing weight) moves that much whole-package work onto the
other shards. So when the whole-package split is balanced, the density
cap (its densest bin) is the mean, and no split carrying the charge can
come back within it at any slice count. On the 2026-11-02 refresh the
cap read 1455.81 s against 1552.68 / 1552.77 / 1552.63 s for the CLI cut
2 / 3 / 4 ways, so the full list ran the CLI whole.
- **`planShards()`**: the WITHIN CAP check, and the repair placement
behind it (`placeItems` / `refineToCap`), judge a candidate split
against `cap + closureAllowance(candidate)`. The final placement uses
the same. Each decision records its `allowance`.
- **`renderSliceDecision()`**: names the allowance only when it was part
of the verdict (a refusal past it, or a slicing only it admitted), so
the shard log never claims a cap the split did not meet. Today's lines
are unchanged.
- **Self-test**: the hard constraint (the committed full list stays
within the cap) is scored against the same adjusted cap. The success
line names the allowance only when the bins exceed the bare cap.
Unchanged, as ruled: the pin "cap = the whole split's densest bin" and
the `capFixture` refusal/admission controls.
- **New pins (4)**, in the `density cap and the per-run slice decision`
battery, whose floor is raised 14 to 18. They are built on the refresh's
package weights **frozen in the test** (79 packages from PR 28978 head
`b5b4b790`, not read from the dataset file), at 8 shards:
- the allowance's arithmetic: carried at 8, plain at 8, carried at 1;
- carried: the CLI x2 is taken, cap 1455.81 s + allowance 111.86 s =
**1567.67 s**, densest shard 1553.36 s (past the bare cap, within the
adjusted one), slices spread, and the log names the allowance;
- not carried: the same shape with no reader slice is allowed 0 s;
- still binding: a cap one second short of admitting the carried split
refuses it, naming the allowance.
Not changed, as ruled: `scripts/test-shard-timings.json`,
`FILE_SHARDED_PACKAGES` / `PREVIOUS_FILE_SHARDED_PACKAGES`, `ci.yml`'s
`DTS_READER_SLICE` and the CLI vitest config's
`DECLARATION_READER_SLICE`. The dataset and map swap (CLI 4 to 2,
previous = 4) is the ruling's second slice, a separate lane PR that
replaces PR 28978.
## Tests
Measured on `objectstack-ai/objectstack` at head `e9569e920e` (merge
base `b0ef25f524`).
- `node scripts/partition-test-shards.mjs --self-test`, committed
dataset: exit 0, and the verdict line is byte-identical to the base's.
- **Byte-identity on today's committed dataset (base vs head).** I ran
main() for every shard `1/8`..`8/8` on a full-list document with
`--exclude @objectstack/dogfood`: stdout and stderr are byte-identical
on all 8. In the plan JSON (`planShards` on the full list, as the
self-test builds it), `items`, `bins`
(1600.11/1597.48/1597.14/1599.09/1598.01/1597.78/1599.48/1597.04) and
`cap` (2697.45) are identical. The one difference is the added decision
key `"allowance": 111.85714285714286`.
- **PR 28978's refreshed dataset (`b5b4b790`), scratch tree, not
committed.** At head the self-test is red on one check only: pin 3c,
"sliced 4 ways ... Lower it to 3". That is the map swap the second slice
carries. At base it was red on 7, the first being `slice spread`. With
the second slice's map applied in scratch (CLI 2, previous 4): exit 0,
`bins 1551.96/1551.44/1553.29/1552.46/1552.43/1553.22/1551.01/1553.36s
within the 1455.81s density cap plus its 111.86s declaration-closure
allowance`, whole legs within 1868 s, CLI x2.
- **Ablation** (scratch tree, `closureAllowance` mutated to `return 0`,
marker grep-confirmed): exit 1. With failures collected, the three cases
that depend on the allowance go red and the "not carried" case stays
green. Restored by byte comparison; the restored self-test exits 0.
- Importers' self-tests: `nightly-tiers`, `check-test-suite-ceilings`,
`measure-test-shard-timings`, `ci/select-shard-timings-run`,
`ci-shard-matrix`, `check-test-completeness` all exit 0.
## Acceptance notes
- The adjusted cap leaves a 14 s margin on the refreshed shape (1553.36
s against 1567.67 s).
- Pin 3c has no hysteresis: x2 holds on the refreshed dataset by 20 s
(716 s against 736.45 s), so a later refresh can flip the derived count
again. The ruling places that outside its scope, as its own finding.
- No changeset: a root script publishes nothing, so `skip-changeset`.
## Verification
<details><summary>Derived gates: 31 of 31 exit 0, reconciled with
--ran</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `e9569e920e` derived 31 commands (17
pnpm, 14 node). All 31 were run with exit codes captured before any
pipe, after `pnpm install --frozen-lockfile`. A first pass without
`node_modules` gave PREREQUISITE NOT MET (exit 3) on 6 commands and 1
environment finding; all reran green after the install. `pnpm
check:pm-dispatch-gates` exit 0 (fast tier, 1945 cases). `--ran`: "31
derived famil(ies) accounted for, 31 run, 0 NOT-MEASURED (a DERIVED
zero, all 31 recorded an exit code and none of them is 3)". The
derivation names one path-scheduled CI step (`Plan Test Core shards`)
and the type-check lanes as NOT MEASURED locally; CI runs those.
</details>
Session: https://claude.ai/code/session_017ihL2gLghEqeDKTbDTC7Zd
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6fc7872 commit 3cdb162
1 file changed
Lines changed: 168 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
1189 | | - | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
1190 | 1192 | | |
1191 | 1193 | | |
1192 | 1194 | | |
| |||
1269 | 1271 | | |
1270 | 1272 | | |
1271 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1272 | 1304 | | |
1273 | 1305 | | |
1274 | 1306 | | |
| |||
1291 | 1323 | | |
1292 | 1324 | | |
1293 | 1325 | | |
1294 | | - | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
1295 | 1329 | | |
1296 | 1330 | | |
1297 | 1331 | | |
| |||
1321 | 1355 | | |
1322 | 1356 | | |
1323 | 1357 | | |
| 1358 | + | |
1324 | 1359 | | |
1325 | | - | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
1326 | 1363 | | |
1327 | 1364 | | |
1328 | 1365 | | |
| |||
1331 | 1368 | | |
1332 | 1369 | | |
1333 | 1370 | | |
1334 | | - | |
| 1371 | + | |
1335 | 1372 | | |
1336 | 1373 | | |
1337 | | - | |
| 1374 | + | |
1338 | 1375 | | |
1339 | 1376 | | |
1340 | | - | |
| 1377 | + | |
1341 | 1378 | | |
1342 | 1379 | | |
1343 | | - | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1344 | 1384 | | |
1345 | 1385 | | |
1346 | 1386 | | |
| 1387 | + | |
| 1388 | + | |
1347 | 1389 | | |
1348 | 1390 | | |
1349 | 1391 | | |
1350 | | - | |
1351 | | - | |
| 1392 | + | |
| 1393 | + | |
1352 | 1394 | | |
1353 | 1395 | | |
1354 | 1396 | | |
| |||
1842 | 1884 | | |
1843 | 1885 | | |
1844 | 1886 | | |
1845 | | - | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
1846 | 1890 | | |
1847 | 1891 | | |
1848 | 1892 | | |
| |||
3198 | 3242 | | |
3199 | 3243 | | |
3200 | 3244 | | |
3201 | | - | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
3202 | 3248 | | |
3203 | | - | |
| 3249 | + | |
| 3250 | + | |
3204 | 3251 | | |
3205 | 3252 | | |
3206 | 3253 | | |
3207 | 3254 | | |
3208 | | - | |
| 3255 | + | |
| 3256 | + | |
3209 | 3257 | | |
3210 | 3258 | | |
3211 | 3259 | | |
| |||
3234 | 3282 | | |
3235 | 3283 | | |
3236 | 3284 | | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
3237 | 3386 | | |
3238 | 3387 | | |
3239 | 3388 | | |
| |||
3729 | 3878 | | |
3730 | 3879 | | |
3731 | 3880 | | |
3732 | | - | |
3733 | | - | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
3734 | 3887 | | |
3735 | 3888 | | |
3736 | 3889 | | |
| |||
0 commit comments