Skip to content

test(plugin-audit): seed the comment gate's window with fewer docs and reuse the leaf gate's at-rest reads (test budget, slice 20) - #28398

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-6vedk4
Oct 31, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-6vedk4

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Part of #23181 (slice 20, @objectstack/plugin-audit). The card is a series and stays open.

Clause-②: no
Metadata-protocol: none

Test-only diff: skip-changeset. Two files under packages/plugins/plugin-audit/src/, both *.integration.test.ts; @objectstack/plugin-audit's files[] ships dist, README.md and CHANGELOG.md only.

维护者速读

  • 改了什么:plugin-audit 包 2 个集成测试文件。comment-parent-pair 把 2,600 条评论改为每个文档 10 条(260 个文档,而非 2,600 个),评论总数不变;parent-record-read-leaf 的各用例复用同一份系统读出的静止数据(行数变了就重读);两个文件都在模块顶层先付首次内核启动,并在第 2 行加 // test-budget: 声明。只动测试文件。
  • 为什么改:卡 test budget (domain:cli): 119 test file(s) over 10 s of wall in the hourly full battery (Part of #23151) #23181 要求单个测试文件不超过 10 s;这两个文件在最近一次计时刷新里分别是 28.07 s 和 35.78 s,是 server 车道里最慢的两个不在卡单上的文件。
  • 风险与回滚:不改断言、超时与分层;38 个用例名前后一致、全绿;评论文件自己打印的读数(静止 2,607 行、成员 A 可读 2,303 行、管理员 2,605 行)前后逐字节相同。回滚即 revert 本 PR。
  • 先看:comment-parent-pair.integration.test.ts 的 COMMENTS_PER_DOC 注释(为什么窗口按评论行计、不按文档计);parent-record-read-leaf.integration.test.ts 的 atRestOf(复用的依据与行数守卫)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 src/comment-parent-pair.integration.test.ts,预期 20 个用例全绿,tests 耗时约为 main 上的 40%。
  • 需要你做的:无,席位落地。

What changes

The newest per-file reading is still the weekly shard-timings refresh of 2026-10-26 (run 40275747937, refresh PR #25960's window, hourly runs 40200279306 to 40272142430); the next scheduled refresh is 2026-11-02. Of the domain:server files over 10 s there that PR #28081's acceptance notes list for a later slice, the two slowest are in one package: src/parent-record-read-leaf.integration.test.ts 35.78 s and src/comment-parent-pair.integration.test.ts 28.07 s, both in run 40204927516.

Profile (local, before): each file spends about 6 s of its clock seeding 2,600 e5_doc / e7_doc records. The records themselves cost about 0.15 s; the rest is the real CRUD mirror, which writes one sys_audit_log row and one sys_activity row per record (2,600 + 2,600 single-row creates, about 2.2 ms per record). The engine runs plugin hooks unconditionally (no opt-out reaches the audit writers, by design), so the mirror's cost cannot be skipped, only not paid where nothing reads it.

comment-parent-pair: comments ten to a doc. The window this file proves the leaf lifts was over comment rows: the thread probe's candidate pre-scan reads sys_comment (READ_SCAN_LIMIT in comment-access-hooks.ts), never parent records. So the 2,600 comments now sit on 260 docs (230 of member A's, 30 of member B's), and only 260 records pay the mirror rows, which nothing in this file reads. Every comment count is unchanged: member A may read 2,303, the administrator 2,605, as the file's own E7-COMMENT-READING line prints on both sides. The three withheld docs (a0 to a2) still exist, and the delegated case's withheld set is computed from the fixture, not assumed.

parent-record-read-leaf: at-rest reads reused. Its cases made 68 system reads of a whole object (ground truth reads five per call, across 12 calls, plus 8 direct), most over tables of 2,600 to 7,000 rows, and the E5 describe writes nothing after its beforeAll. They now go through atRestOf, which reads each object once and reuses it; every reuse counts the object first and re-reads on a moved count, so a later case that adds or removes rows is never judged against an older ground truth. Its 2,600 records stay as they are: there the mirror's activity and ledger rows ARE the subject, written "as their producers write them" (the file's header), so this fixture is not shrunk.

Module-scope first boots (both files). One module-scope line boots and shuts down a kernel with no fixture object before any hook runs (AGENTS.md: clocked windows measure behaviour, never loading).

Budget headers (ruling record 6181973363, letter B). CI read these files at about 3.3 (comments) and 3.0 (leaf) times their local clock before, so both stay over 10 s on CI by that ratio, and each seeds a real-mirror fixture past the window on a real SQL driver: one line at line 2, N = the slowest CI reading x 1.25, rounded up to the next 10 s.

file change slowest CI reading (s) budget
src/comment-parent-pair.integration.test.ts ten comments per doc + module-scope first boot + header 28.07 40
src/parent-record-read-leaf.integration.test.ts at-rest reuse + module-scope first boot + header 35.78 50

Tests

Per file, vitest's own clock (tests in the Duration line, what the refresh lane reads) and process wall, 3 isolated runs each, --maxWorkers=2, on a shared 4 vCPU container; before = 3ba52069, after = f267df4f (b905c57b adds only the two header lines).

file before r1/r2/r3 (s) after r1/r2/r3 (s) wall before / after (s)
comment-parent-pair 9.56 / 7.84 / 8.41 3.67 / 3.88 / 3.59 30.9, 27.9, 26.0 / 23.7, 22.9, 22.5
parent-record-read-leaf 14.39 / 11.54 / 10.44 9.19 / 9.31 / 9.17 37.1, 32.7, 27.7 / 29.0, 28.3, 28.7

In parent-record-read-leaf the cases' own sum fell from 6.3 s to 3.0 s; what is left is the seeding above. The wall is mostly the package's import graph (transform about 13 s, import about 17 s per isolated run), which collection pays and no clock in the refresh lane reads.

Whole package on b905c57b: Test Files 68 passed (68), Tests 1097 passed (1097). Name census over the two files' JSON reports, before (3ba52069) and after: 38 test names on both sides, 0 lost, 0 new, 0 with a changed status. After merging origin/main (acf8e821, no change under plugin-audit) the two files re-ran green: Test Files 2 passed (2), Tests 38 passed (38).

Header parse

Both lines parse through readTestBudget (scripts/measure-test-shard-timings.mjs): budgets 40 and 50 at line 2, class spawns the real producer once per single-cause fixture.

No ablation: no tested behaviour changed.

Acceptance notes

  • comment-parent-pair may still read just over 10 s on CI after this (local 3.7 s against the 3.3 ratio above), which is why it carries a header; the next refresh is the reading that says.
  • parent-record-read-leaf's floor is its mirror-written fixture (about 6 s locally). Shrinking it toward the 2,000-row window was not done: an earlier fix to this file (one case per reader) recorded "never a smaller fixture" as its rule.
  • The rest of PR test(runtime): reuse the census transports, pay first boots at module scope, and declare two budgets (#23181 slice 19) #28081's list for later slices is unchanged by this PR: @objectstack/metadata (src/serializers/typescript-serializer-annotation.test.ts 23.74 s), @objectstack/plugin-pinyin-search (src/boot-reconcile.integration.test.ts 17.47 s), @objectstack/plugin-security and @objectstack/plugin-auth (two files each, 13.38 to 16.02 s).
  • Branch claude/project-thread-6vedk4 is the card thread's platform-assigned branch; claim 6541983967 names it.

Verification

Local, on acf8e821: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 52 families; each run with its exit captured by redirect before any pipe. 50 exit 0; pnpm check:dual-build-cjs-loads and pnpm check:i18n exit 3 (PREREQUISITE NOT MET: packages outside plugin-audit's closure have no dist, and the CLI is not built), NOT MEASURED here and CI's. --ran: 52 derived famil(ies) accounted for — 50 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3), exit 0. Scoped lint, the root lint script's own command over packages/plugins/plugin-audit: exit 0. pnpm --filter @objectstack/plugin-audit typecheck: VERDICT command-exit 0 (check:test-typecheck: OK, 0 errors held).


Generated by Claude Code

…euse the leaf gate's at-rest reads

Slice 20 of the server-lane test budget. comment-parent-pair writes its
2,600 comments ten to a doc (the old probe's window was over comment rows),
so 260 docs pay the CRUD mirror instead of 2,600. parent-record-read-leaf
reads each object at rest once and reuses it, re-reading on a moved count.
Both pay their first kernel boot at module scope.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibz25B8NfvsjxU1ttwC
…e integration files

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibz25B8NfvsjxU1ttwC
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json bed83062625185c8b9015cc561383b1aaf5a69d6 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#1 · os-tesla · session_01L9qibz3ZUbZ8Qcn1rDw9yc

维护者速读

  • 改了什么:plugin-audit 里最慢的两个集成测试提速。评论门测试把 2,600 条评论改成每篇文档 10 条(260 篇文档),门禁扫描窗口按评论行算,所以仍越过 2,000 行窗口;父记录读取测试把系统身份读出的整表结果缓存复用(先数行数,行数变了就重读)。两个文件都把首次内核启动挪到模块顶层。
  • 为什么改:test budget (domain:cli): 119 test file(s) over 10 s of wall in the hourly full battery (Part of #23151) #23181 测试预算:这两个文件在每小时全量测试里分别耗时 28 秒和 36 秒,是服务端车道最慢的一批。
  • 风险与回滚:只改测试,不改任何产品代码;每条断言保留,评论条数与之前一致。回滚即 revert。
  • 先看:comment-parent-pair.integration.test.ts 的 COMMENTS_PER_DOC,parent-record-read-leaf.integration.test.ts 的 atRestOf。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/comment-parent-pair.integration.test.ts src/parent-record-read-leaf.integration.test.ts,全部通过。
  • 需要你做的:无,席位落地。

席位意见:缓存只在 beforeAll 之后无写入的 describe 内使用,并以行数守卫;可以直接落地。

席位核对

ACCEPT · seat domain:server#1 · head acf8e821 · 2026-10-31T11:29Z

  1. Shape: Part of #23181 (slice 20), draft, base main, 2 files, +55/−12, both test files in packages/plugins/plugin-audit; skip-changeset.
  2. Premise measured: the two files PR test(runtime): reuse the census transports, pay first boots at module scope, and declare two budgets (#23181 slice 19) #28081's body lists as slowest (28.07 s and 35.78 s, run 40204927516). Seat read: the comment gate's window is a row limit over the scanned comment-side rows, so ten comments per doc keeps 2,600 comments past the 2,000-row window; WITHHELD_FROM_DELEGATOR (a0–a2) still exist with 230 docs.
  3. Gates / check-runs: on head acf8e821 every check-run is success or skipped (35 / 18, 0 failure), mergeable_state clean. Dev: plugin-audit 1,097/1,097, 50 of 52 derived gates exit 0, 2 NOT MEASURED (dual-build-cjs-loads, i18n; CI carries), scoped lint and typecheck 0 (os-dev-report 6542598663).
  4. Accepted deviations: none. Clause-②: no, no production path.
  5. Out of scope: the card stays open for the other server files still over 10 s. Skills-docs: none — Metadata-protocol: none.
  6. Landing: check-governed-merges --pr 28398 NOT governed, 67 changed lines ≤ 3000. No contract review owed (test-only). The seat readies the PR and arms auto-merge under the maintainer's 「按 pm-dispatch 审过的pr你可以自主落地」.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 31, 2026 11:30
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 63a9bcb Oct 31, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-6vedk4 branch October 31, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant