Repository navigation
ci(test-source-alias): follow a changed test into the source it loads, and red a cold literal import() paid there - #30969
Merged
Conversation
Contributor
Author
|
domain:devx#1 · os-elon-musk · session_016WV4cymvo9YoyLwKCXXBNw 席位核对 · ACCEPT · #30909 · 2026-11-06T14:39ZHead-sha:
|
os-elon-musk
pushed a commit
that referenced
this pull request
Nov 6, 2026
… collection The source-reach half of check:test-source-alias (on main since #30969) judges this edited file: its cases reach the protocol's lazy import('@objectstack/lint') (metadata-diagnostics.ts) inside a clocked window. Import ./lint-root-preload.testkit.js at module top, as the sibling protocol test files do. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxRibYnMTw289qPx3H
This was referenced Nov 6, 2026
os-elon-musk
pushed a commit
that referenced
this pull request
Nov 6, 2026
The host crypto provider test imports `serve.ts`, which reaches eight packages through function-body `import()` calls. check-test-source-alias's source-reach half (#30969) asks a changed test file to pay those first loads during collection, so the file now imports them for their side effects at module top, as the other serve-reaching cli tests do (#10126). serve.ts keeps its dynamic imports. Also notes in serve.ts that the host provider's init-done reading assumes `ctx.getKernel`. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czs7cUFAphQEUFSrcz
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Elon · project thread
domain:devx#1 · os-elon-musk · session_016WV4d1Nibc5bxtbQZv6ssS
Fixes #30909
Clause-②: no
Metadata-protocol: none
维护者速读
check:test-source-alias的时钟窗口规则新增第三个读取器:顺着测试收集期的导入链走进同包被测源码,找出藏在函数体里的字面量import()(该包经dist/解析的那批 specifier),要求测试在模块顶部预热或 mock;只判本次改动新增或修改的测试文件。rest-server.ts走到回填路由里的await import('@objectstack/objectql'),冷加载 3.2 秒落在 5000 毫秒窗口里,把无关 PR 的 Test Core 打红;门禁当时 exit 0。sourceReachFindings与reachEdgesOf(可达与预热的判定);② 入口处changedFilesSinceMergeBase(只判改动测试、找不到 merge base 判红);③ 头部新节 "The source reach" 里为什么不对全部测试判红的实测。git show 98f640d5:packages/rest/src/meta-write-door-capability-enumeration.test.ts > packages/rest/src/meta-write-door-capability-enumeration.test.ts && node scripts/check-test-source-alias.mjs,预期 exit 1 并点名meta-record-currency-backfill-route.ts:177;之后git checkout HEAD -- packages/rest/src/meta-write-door-capability-enumeration.test.ts。What changes
One file,
scripts/check-test-source-alias.mjs.dist/(the rule's existing population, unchanged) inside a function body of a reached file is a finding against the test, unless a file in the same reach loads that specifier at module scope or the testvi.mocks /vi.doMocks it. The remedy is the line the rule already prints: a module-topimport 'SPEC'in the test file. The failure names the specifier, every site of it in the reach, and the import chain to the first one.origin/main(committed, staged, unstaged and untracked alike);--changed-from REFnames another base and--reach-allruns the census over every test file. No merge base is a failure, never a pass. On amainpush the base is HEAD and the half judges nothing; on a PR or a queue build it judges that change's test files. TheLint · CI, release & engine gatesjob already checks out withfetch-depth: 0, so no workflow edit.rest-server.tsregisters every route, so every rest test that builds aRestServerreaches every handler's guarded import while only the cases that call that handler pay it. Over every test file atmain0e88208, the reach flags 2307 test files / 5491 (test, specifier) pairs, from only 89 source sites in 53 files. The header's new section "The source reach" records this and the boundaries.vi.mock, and a lazy relative hop all silent; one finding per specifier when the direct reader already reports it; the scope judged in and out; the direct reader left unscoped.SELF_TEST_BATTERY_FLOOR11 → 12.Tests
node scripts/check-test-source-alias.mjs --self-test→check-test-source-alias --self-test OK.git checkout HEAD --andgit diff HEADempty: dropping the warm-set check reds two cases (remedy, warm-in-reach); dropping the scope filter reds both scope cases; dropping the mock read reds the mock case.packages/rest/src/meta-write-door-capability-enumeration.test.tsat its98f640d5blob,node scripts/check-test-source-alias.mjsexits 1:Restored with
git checkout HEAD --,git status --porcelainclean of it; the same command then exits 0.Acceptance notes
--reach-all,main0e88208): 2307. By package:ui/packages/app-shell932,packages/runtime387,ui/packages/components287,packages/metadata-protocol200,packages/rest187,packages/cli179,packages/services/service-datasource64,packages/verify37,packages/metadata18,packages/cloud-connection6,ui/scripts/__tests__6,packages/plugins/plugin-dev4. Reproduce the full list withnode scripts/check-test-source-alias.mjs --reach-all. They are not fixed here (over the card's "fix if small" bound): each is fixed with one module-top line when a change next touches it.packages/restonly two specifiers stay cold,@objectstack/objectqland@objectstack/spec/ui. The card's other latent sites (@objectstack/spec/apiinbatch-routes.ts/crud-routes.ts,@objectstack/spec/systeminform-routes.ts/meta-item-read-gate.ts) are not flagged: another file in the same reach already imports those subpaths statically, so they are paid during collection today.dist/loads the specifier is not credited (the loud direction); a mock counts whether or not it callsimportOriginal; a source edit that adds a cold site reds no unchanged test.packages/formulaonly) does not overlap.Verification
All on head
efd622a9(this branch merged withorigin/main6ddf827), this container, 4 vCPU.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 31 families for the one changed path; all 31 ran sequentially, each exit code captured before any pipe; 31 exit 0.--ran: "31 derived famil(ies) accounted for — 31 run, 0 NOT-MEASURED".pnpm exec eslint scripts/check-test-source-alias.mjsexit 0.node scripts/check-test-source-alias.mjs: exit 0, "the source reach judged 0 test file(s) changed since 6ddf827", 24.3 s.--reach-all: exit 1, 5491 findings over 2307 test files (the same counts as at 0e88208), 34.8 s.98f640d5blob (hash 76ae2b895f) exits 1 with the finding quoted under Tests; restored blob hash equals the HEAD blob.gates-ran-efd622a9
Generated by Claude Code