fix(scripts): 扫描根消失时判红并点名,不再在零个文件上报绿 (#4930) - #4941
Merged
Merged
Conversation
…tes (#4930) `check-single-authz-resolver`, `check-startup-registry-verdict` and `check-driver-conformance` each concluded from a walk that opened with `try { readdirSync(dir) } catch { return out/[]; }`. A root that was renamed, moved or made unreadable produced zero files, and zero files produce zero findings — the same verdict as a clean workspace. Same shape as #4916/#4934. Each script now resolves every declared root before drawing any conclusion from the scan, and fails naming the root and the reason ("does not exist" / "exists but is not a directory"). The swallows inside the walks are gone too: an error mid-walk means the corpus was only partly read, which must not print as a clean pass either. No whitelist and no `optional: true` flag — every root is a git-tracked directory, so an optional marker would be a supported way to silence the failure instead of fixing the rename. Measured on this tree, pre-fix: only check-single-authz-resolver was genuinely vacuous end to end (it went red by luck, because both DELEGATORS live under the same root, reporting "Delegator missing" for the wrong cause). The other two already failed, but named the wrong cause — startup-registry-verdict's `existsSync` accepted a file and then blamed an empty corpus, and driver-conformance answered a renamed `packages/spec/src/data` with five "CASE_SETS names X, which <file> no longer exports" errors that read as five deliberate deletions. Both now name the directory. The proofs are bidirectional and permanent, not one-offs in the PR body: each `--self-test` renames a root away mid-run and requires red naming that root, replaces one with a file and requires the not-a-directory verdict, dangles a symlink inside the walk and requires the error rather than a smaller corpus, then restores everything and requires green again. check-single-authz-resolver had no self-test and gained one covering both of its original invariants; `package.json` chains `--self-test &&` into `check:authz-resolver` to match the other ten `check:*` entries. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iARDqtrhQgz6fVHDeDkbQ
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iARDqtrhQgz6fVHDeDkbQ
Contributor
Author
CI 说明:
|
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.
Fixes #4930
三个
scripts/check-*.mjs的扫描根解析不到时静默返回空集,于是"没找到问题"和"根本没打开过"是同一条绿线。修法照抄 #4934(check-doc-authoring.mjs的assertRootsResolvable):扫描前先校验每个声明的根存在且是目录,死根判红并点名,不留 optional 白名单。先说一件与议题正文不符的实况
议题说三个脚本在根改名后都会报绿。按当前 main 实测,只有第 1 个是真的端到端静默;另外两个已经会判红,但把原因说错了。我没有为了对齐议题描述而放宽任何东西,下面每一组都是真实输出。
check-single-authz-resolverDelegator missing: packages/rest/src/rest-server.tsDELEGATORS恰好也住在同一个根下面。把任一 delegator 挪出packages/、或加第二个扫描根,这条就彻底静默了check-startup-registry-verdictnothing to scan — … does not existexistsSync放行,然后落到files.length === 0去怪"没有源文件";更深一层,walk 中途 stat 不到的目录会悄悄缩小语料而files.length仍然非零,响亮的空语料闸门根本不会触发check-driver-conformanceCASE_SETS names X, which …-conformance.ts no longer exports三个都改成:先解析根,死根带原因(
does not exist/exists but is not a directory)当场点名判红,并把 walk 里的吞掉一并删掉——扫描中途出错同样意味着语料只读了一半,不能当作"扫干净了"打印。不加白名单、不加
optional: true:这些根全是 git 跟踪的目录且目录里有跟踪文件,任何能在仓库根跑这些闸门的 checkout 都不会合法地缺其中之一。加个"以防万一"的可选标记,等于给下一个作者一条受支持的途径去消音而不是去修改名——就是那个空catch {},只是说得客气些(理由同 #4934)。三组红/绿双向证明(真实输出)
1.
check:authz-resolver改前同一次改名的输出(留档,说明红是蹭来的):
2.
check:startup-registry-verdict改前:
✗ startup-registry-verdict: nothing to scan — /home/user/objectstack-4930/packages does not exist.(根是目录时对,根是文件时把原因说成"没有源文件")。3.
check:driver-conformance改前同一次
packages/spec/src/data改名:双向证明已折进常驻自检
观察绿对一个"失败模式就是少扫"的闸门毫无意义,所以每次运行都先观察红。三个
--self-test现在都会:把一个根改名走开 → 要求红并点名该根、不牵连幸存的根 → 把另一个根换成文件 → 要求exists but is not a directory→ 在 walk 里挂一个悬空 symlink → 要求报错而不是语料变小 → 全部恢复 → 要求重新变绿。check-single-authz-resolver.mjs原本没有--self-test,本 PR 补上,并把它原有的两条不变量(重复 resolver 检测、入口点仍然委派)也用真实 walker 在真实临时目录上驱动一遍。package.json(一行)仓内 10 个
check:*条目都串了--self-test &&,只有check:authz-resolver没有(因为它没有自检)。本 PR 补齐:没有新增/删除脚本条目,不影响
check:generated的 ledger 对账。未改.github/workflows/。验证
pnpm check:authz-resolver/check:startup-registry-verdict/check:driver-conformance— 全绿(自检 + 实跑),即当前 main 的现存状态没有因为收紧被判红。npx eslint三个脚本 — 干净,exit 0。pnpm check:changeset-fixed/check:changeset-no-major— 绿。刻意没动的(议题已逐条排除的不同形状)
check-changeset-fixed.mjs/check-override-consistency.mjs的 glob 展开中途catch { continue; }、check-nul-bytes.mjs的记账式skipped.unreadable、check-changeset-no-major.mjs声明过的无.changeset行为——这三类是对的,保持原样。discoverDrivers()里那个statSync(package.json).isFile()的 try/catch 同理:它筛的是枚举出来的候选集,不是声明的根。