Repository navigation
Commit 9f5562f
test(plugin-approvals): seed the past-500-decided stranded-scan cases in batches, not 1200 serial inserts (#38235)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu3fvgcmTNiNVgQgr2PxiD85)_
Fixes #38223
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 是什么:用户无感,只改一个测试文件。审批插件里“超过 500 条已决审批后仍能报出卡住的请求”这组用例,造数据从 1200
次逐行插入改成每批 200 行的批量写。
- 为什么:属于「CI 稳定与合并队列提速」专题(#38081)。这条用例在忙的队列机器上跑到 5.8 到 13 秒,超过 5
秒上限,已经把不相关的 PR(#38164、#38167)弹出合并队列。量下来九成时间花在逐行插入上,扫描本身只要约 50 毫秒。
- 出错会怎样:只影响测试。数据规模、顺序和断言都没变,还多了一条“601 行全部被读到”的断言;撤掉 #37808
的修法时,两条用例照样变红。
- 要你做的:无。
## What changes
`packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts`,
the `#37808 — past 500 decided requests` block only:
- `insertAll` seeds through the engine's own array insert,
`engine.insert('sys_approval_request', rows[], …)`, in batches of
`SEED_BATCH = 200` rows, instead of one `engine.insert` per row. Same
rows, same insertion order, same `isSystem` context, same real
`ObjectQL` over `SqlDriver` (better-sqlite3, in-memory).
- The batch is 200, not the whole set: one multi-row INSERT of 600 or
1200 rows is refused by SQLite with `too many terms in compound SELECT`
(its default 500-term compound limit; knex emits a multi-row insert as a
compound SELECT there). A comment beside `insertAll` says why the batch
exists and why it is 200.
- The 600-row case also asserts `out.scanned === 601`: the newest window
(ids 102–601) plus the first walk page (ids 1–500) read every seeded
row, so a short batch write cannot pass it silently. This only adds an
assertion; none is removed or loosened.
No timeout was raised, nothing is skipped, and the scale (600 and 1201
decided requests, 500 per window, 3 + 3 sweeps) is unchanged.
## Why
The card's evidence (comment 7236773117): the case took about 1 s
locally and 5.8 to 13 s on queue runners, against the 5000 ms default.
Measured here, on the case "an older strand outside the newest window is
reached by the cursor":
| | seeding 1201 rows | 6 sweeps | case total |
|---|---|---|---|
| before (serial inserts) | 789 / 1146 ms | 53 / 63 ms | ~1000 ms |
| after (batches of 200) | 93 / 99 / 103 ms | 41 / 54 / 52 ms | 149–178
ms |
The 600-row case went from about 570 ms to 100–170 ms. The whole file's
39 tests are unchanged and green.
## Verification
Ablation (the cases still detect the bug they pin): with
`inspectStrandedRequests` reverted to the pre-#37808 read (no `orderBy`
on the newest window, no id cursor on the walk), the 600-row and
1201-row cases both fail under the new seeding, exactly as they fail
under the old one; CONTROL passes in both. Restored, 3/3.
<details><summary>runs</summary>
Head 19eeab6.
- `pnpm turbo run build --filter='@objectstack/plugin-approvals^...'`:
exit 0.
- `npx vitest run src/stranded-request-inspection.test.ts` (in the
package), three times: 39/39 passed each time.
- `npx vitest run` (whole package): 131 files, 1979 tests passed.
- `pnpm typecheck` (package, includes `check:test-typecheck`): exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands --changed`: 54 derived;
51 exit 0; 3 exit 3 (PREREQUISITE NOT MET), so NOT MEASURED locally and
left to CI: `node scripts/check-plugin-teardown-shape.mjs --self-test`
(its fixture commit is out of this shallow clone), `pnpm
check:dual-build-cjs-loads` and `pnpm check:i18n` (both read every
package's `dist/`; only this package's closure is built here). `--ran`
reconcile: 54 accounted, 0 UNRUN.
- `npx eslint` on the changed file: exit 0.
</details>
## Acceptance notes
- Found on the way, not fixed here (out of this card's test-only scope):
an `ObjectQL` array insert of more than about 500 rows on SQLite throws
`too many terms in compound SELECT` from `SqlDriver.bulkCreate`, which
does not chunk. Reported to the seat as a follow-up candidate.
## 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; eslint on the changed file passes (the full
`pnpm lint` was not run locally; CI runs it).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (branch `claude/project-thread-4xkl1n` is the harness-assigned
name)
- [x] 5. A change that publishes carries a changeset: this diff is a
test file only and publishes nothing, so no changeset
(`skip-changeset`).
- [x] 6. `packages/spec` touched: no.
- [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
maintainer summary).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgVv7fqmna3sqqbjzf2
Co-authored-by: Claude <noreply@anthropic.com>1 parent 01c238a commit 9f5562f
1 file changed
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
798 | 805 | | |
799 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
800 | 809 | | |
801 | 810 | | |
802 | 811 | | |
| |||
837 | 846 | | |
838 | 847 | | |
839 | 848 | | |
| 849 | + | |
| 850 | + | |
840 | 851 | | |
841 | 852 | | |
842 | 853 | | |
| |||
0 commit comments