chore(lint): enforce proof minting with clippy disallowed-methods, replacing the grep in check-deps.sh
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with clippy.toml, the proof-minting section of scripts/check-deps.sh, and the documented mint sites in crates/thrust-ports/src/lib.rs and crates/thrust-core/src/lib.rs. Check whether disallowed-methods catches aliases and function values, then run the clippy command in the acceptance criteria and verify each specified control fails as expected. Done means the lint and any needed residual guard cover the mint paths, the outdated comments and docs are corrected, and all targets pass clippy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Context
Scope, WorkspaceScope and SystemScope (crates/thrust-ports/src/lib.rs:115, :143, :170) are the proofs that a user may act in a workspace and project, that they are an active member of a workspace, and that a caller may do the untenanted operations. Their fields are private, but their constructors, mint, are pub #[doc(hidden)] (:124, :152, :177), because core, the adapters and the two composition roots are different crates. So nothing in the type system stops any crate from forging a proof. What stops it is scripts/check-deps.sh, in the "proof minting" section (:103-134): an awk pass over crates/thrust-core/src/lib.rs that tracks which fn each call is in, and a grep over crates/ for (Scope|SystemScope|WorkspaceScope)::mint(. It allows Scope::mint only in authorize_with_role, WorkspaceScope::mint only in authorize_workspace, and SystemScope::mint only in the three composition-root files, and it exempts crates/*/tests/ and core's unit-test module.
ADR-0045 (.agents/plans/contrail/adrs/data/interfaces/0045-repository-and-unit-of-work-ports.md:133) decided that "Clippy's disallowed-methods replaces the grep once the clippy job exists (#40)". #40 is closed (#87): the lint job runs clippy with -D warnings. disallowed-methods is not configured, and the script says so (check-deps.sh:106).
Legitimate call sites on main today (a206319):
| Call | Where |
|---|---|
Scope::mint |
crates/thrust-core/src/lib.rs:293 (authorize_with_role) |
WorkspaceScope::mint |
crates/thrust-core/src/lib.rs:312 (authorize_workspace) |
SystemScope::mint |
crates/thrust-server/src/main.rs:124, crates/thrust-worker/src/lib.rs:139, crates/thrust-worker/src/memory.rs:50 |
Scope::mint in a unit-test helper |
crates/thrust-core/src/lib.rs:793 (fn scope() in the test module) |
| any of the three, in integration tests | 84 call sites in 19 files under crates/*/tests/ (25 in thrust-adapters-selfhosted/tests/model/mod.rs, 20 in tests/pg_adapter.rs, then 17 files with 1 to 6 each) |
Problem
The grep is a text match, so it passes anything that does not spell the call the way it expects. I tried each form on a one-line input with the script's own pattern (this was a test of the pattern, not a planted failing run of the script):
| Form | Caught? |
|---|---|
Scope::mint(a, b, c) |
yes |
thrust_ports::Scope::mint(a, b, c) |
yes |
use thrust_ports::Scope as S; then S::mint(a, b, c) |
no |
let f = SystemScope::mint; then f() |
no |
<Scope>::mint(a, b, c) |
no |
Each of the three that pass forges a proof and leaves check-deps.sh green. (The comment at check-deps.sh:104-106 says a qualified path is not caught; by this test a fully qualified call is, and the real gaps are the three above. That comment is wrong and should be corrected.) The awk half also decides "which function" by matching fn <name> in the text, which is a heuristic.
A lint resolves the call to the function it names, so it does not depend on how the call is spelled. That is the reason ADR-0045 chose it.
Proposal
- In the root
clippy.toml,disallowed-methodswiththrust_ports::Scope::mint,thrust_ports::WorkspaceScope::mintandthrust_ports::SystemScope::mint, each with areasonthat names its owner. - Put
#[allow(clippy::disallowed_methods, reason = "...")]on the five legitimate sites and the core test helper. For the 19 test files, first find out whether this lint has a tests exemption like the four panic lints'allow-*-in-tests. I don't know that it does. If it does not, each file needs the allow, as 21 test files needed one for those lints in #87. Of the 19 files that mint, 12 already carry that#![allow(..)]and could share it, andtests/model/mod.rsis covered by its parent (pg_adapter.rs). The other six do not:thrust-core/tests/projects.rsand five inthrust-compat-plane(a crate outside the seven that have the panic lints, so those files have no such allow yet). - Open question: does
disallowed-methodsalso flagmintused as a function value (let f = SystemScope::mint;), as opposed to called? Test it. If it does not, keep a small residualgrepfor::mintwithout the parenthesis. - Decide what stops someone adding an
#[allow(clippy::disallowed_methods)]where it does not belong. Today the exemption list is in a script that a reviewer reads; after this it would be an attribute that can be added anywhere. A shortgrepthat fails on that attribute outside the known files, or a code-owner rule, would keep the guarantee. - Then remove the "proof minting" section of
check-deps.sh(or reduce it to that residual guard), and update the three doc comments that cite it (crates/thrust-ports/src/lib.rs:113,:141,:168).
A structural alternative exists: a witness type that only core can construct, so a proof cannot be forged and no lint is needed. It is a bigger change and ADR-0045 chose the lint, so it is noted here and not proposed.
Acceptance criteria
-
disallowed-methodsis configured andcargo clippy --workspace --all-targets -- -D warningspasses onmain. - The controls, each shown failing (AGENTS.md rule 8): a
Scope::mintcall in non-testthrust-apicode fails clippy; and each of the three forms the grep misses (alias, function value,<Scope>::mint() fails clippy, or, where it does not, a residual check covers it and the gap is written down. - The "proof minting" section of
check-deps.shis removed or reduced to the residual guard, and the three doc comments inthrust-portsno longer name a script that does not check it. - Every non-test mint site outside the five above is gone or annotated with its reason, and the test sites carry the allow.
- The docs that describe this check say what is true after the change:
docs/src/testing/techniques/architecture-gates.mdanddocs/src/contributing/standards.md.
Docs that state this wrongly today
docs/src/testing/techniques/architecture-gates.md:59-60(the "Target" section, added in #87) says clippy'sdisallowed-methodsanddisallowed-types"are the complete check for whatcheck-deps.shdoes withgrep", in a sentence about R-P1 (no platform SDK outside adapters). Those are two different controls. Thegrepis the proof-minting check described here. R-P1 is the crate-graph rule thatcargo treeenforces. That sentence conflates them and should be corrected by this work, or sooner.docs/src/testing/defect-matrix.mdrow X10 (also from #87) suggests clippydisallowed-typesfor R-P1. That is a separate idea, untested, and not part of this issue.
References
#35 and #44 (the proof types), #40 and #87 (the clippy job); ADR-0045 line 133; scripts/check-deps.sh:103-134; crates/thrust-ports/src/lib.rs; crates/thrust-core/src/lib.rs; clippy.toml; AGENTS.md rules 8 and 9.
- Ngôn ngữ chính
- Rust
- Star
- 0
- Fork
- 0
- Merge trung bình
- 1 giờ 35 phút
- Pull request đã merge (30 ngày)
- 67
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aRustyDev/thrust
-
area:process bug prio:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:process prio:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:process prio:p1
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:process prio:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:app prio:p0 review:fable-2026-10-19
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aRustyDev/thrust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Clean master build fails in zune-jpeg error conversion and zero-IV array construction (patch)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CakeRepository/agentshangout#995 ·
-
area:frontend kind:bug priority:p3 ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày