Repository navigation
fix(ledger): resolve §6 paths through pub mod / pub use chains (Refs #2847) - #3556
Conversation
master fmt drift from #3511 makes `cargo fmt --check` (the pre-commit hook and CI fmt) fail on every branch; formatting only, no test change. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…2847) The tripwire proved presence by declaration pattern over the module's whole subtree, so `item rubash::api::CandidateKind` stayed green while the real export was `rubash::api::capabilities::CandidateKind`. Item paths now resolve like a consumer would write them: each module step must be a `pub mod` (or a `pub use` module re-export) from src/lib.rs, and the final name must be `pub` at that module's top level or re-exported there (named, `as` rename, or glob, including globs of private modules). Variant and method entries resolve their owner type path the same way. Failures name the step: "declared in the tree but not exported under <path>" vs "not found in tree". The pre-#2850 tree (4f0d493~1) is the issue's reproducer: the old checker reports all 279 symbols present, the new one fails the five CandidateKind entries. Current master: all 287 present, --niu clean. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
队长复核:PASS只读 + 决定性腿全部一手跑过,判词 PASS。未推送、未合入。 决定性腿(复核员一手跑过,我核过卷宗与 live 态)
CI 逐名(run 43560449915,头 8c6ec74):3 fail + 8 pass + 1 skipping,无新失败名。goldens 1350/1 与 macOS 1243/1 均为 交集:真 merge-base 8b48c16 = live tip,交集 ∅,无需 update-branch。d11 fmt hunk 为 11 支 open PR 共用,先合者落地。 合入体选择(我定的):接受正文 合入后 owed:O1 卷宗: |
_check-api-ledger.py _child_module() only inspected the single line immediately above a 'mod name;' declaration when looking for a #[path = "..."] attribute. Rust allows doc comments and blank lines between attributes and the declaration, so a ledger tree using that layout resolved the fallback <name>.rs instead of the attributed file. Walk back over contiguous attribute/comment/blank lines instead. Also reword docs/api-ledger.md #5: the tripwire no longer proves presence 'by declaration patterns only' — since #3556 it resolves real export paths (pub mod steps + pub use re-exports, #[path] honored). The niubash copy of the ledger still needs the same rewording (the byte-identical cmp check in niu-canary job pairing enforces pairing). GNU cite: n/a — tooling, not shell semantics. Refs #3571, #3572 Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fixes #2847
修了什么
scripts/check-api-ledger.py的 §6 校验从「子树里有同名声明」改为「记录的路径就是真实导出路径」:item rubash::a::b::Name:从src/lib.rs起逐段解析,每一段必须是pub mod(内联或文件,含#[path])或把模块pub use出来的再导出;末段Name必须在该模块顶层以pub声明(fn/struct/enum/trait/type/const/static/union/mod),或被该模块pub use再导出(具名、as改名、glob;glob 目标可以是私有模块,如parser的pub use nodes::*)。只认裸pub,pub(crate)不算对外面。variant/method:其所属类型路径按同一解析器校验(此前 method 完全不看类型路径)。declared in the tree but not exported under rubash::…(路径错)与not found in tree(符号没了)。--self-test)新增一组:真实导出路径(具名/改名/私有模块 glob/#[path]/根再导出/子模块路径)必须过;未再导出、穿私有模块、类型路径错的 item/variant/method 必须各自失败。删了什么
item_exists原先的「模块子树 rglob + 声明模式」判定(即 issue 所说的盲区)。PUB_DECL_PATTERNS只保留用于失败诊断(区分「路径错」与「不存在」)。依据
工程面,无 GNU 锚。
验证
4f0d493c~1,CandidateKind尚未在src/api/mod.rs再导出):all 279 ledger symbols present,rc=0(假绿)item rubash::api::CandidateKind+ 4 个 variant,均为declared in the tree but not exported under rubash::api::CandidateKind),rc=1all 287 ledger symbols present,rc=0;--niu D:/repo/niubash:287 present、97 consumed paths recorded,rc=0。--self-testrc=0(四段自检全部通过)。tests/d11_pipeline_squote_carrier_regressions.rs(fix(executor): restore DATA_SQUOTE carrier on pipeline child-argv boundaries #3511 在 master 留下的 fmt 漂移,pre-commit hook 必红;与 fix(cd): announce the verbatim CDPATH join under -P (Refs #3395) #3531/fix(read): re-tag carrier bytes on the C-locale byte-domain write-back (Refs #3489) #3547 中的同一 hunk 相同,合并无冲突)。Owed
docs/api-ledger.md§5 第 1 条仍写「proves presence by declaration patterns only」,现已不准确;但该文件要求与 niubash 副本逐字节相同(canarycmp),需 rubash/niubash 成对改,本 PR 未动。niu-canary.yml的ledger/pairingjob)上实跑,仅本地 Windows Python 3 运行。