Repository navigation
feat(rust): check declared dependencies with cargo meta verify --deps - #702
Merged
Merged
Conversation
cargo meta verify --deps now reads each declared dependency's publisher manifest (metaobjects.pkg.json), hashes the artifact beside it and compares it with .metaobjects/deps.lock.json: current, drifted, or unresolved when it cannot compare. drifted or unresolved exits 1 with ERR_DEPENDENCY_UPSTREAM_DRIFT; an unreadable config or lock exits 2. It is opt-in, resolves the path transport only (as the Python, C#, Java and Kotlin checks do), and replaces the exit 2 the flag gave. The new metaobjects::dependency_check module is the engine; Rust now runs the check arm of fixtures/dependency-conformance/ (all 11 cases).
A mistyped --project, or the metadata directory named in place of the root, read as a project with no dependencies and passed. It now exits 2 naming the path. Config warnings (a misspelled key such as dependancies) are printed instead of dropped.
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.
What Changed
metaobjects::dependency_check(check_dependencies), which resolves each declaredpathdependency, validates the publisher'smetaobjects.pkg.json, re-hashes the artifact beside it, and reports each dependency ascurrent,driftedorunresolvedagainst.metaobjects/deps.lock.json. Non-path transports reportunresolvedand point tometa deps check.cargo meta verify --depsnow runs this check instead of exiting 2. It is opt-in and not part of a bareverify. Drifted or unresolved dependencies exit 1 withERR_DEPENDENCY_UPSTREAM_DRIFT; an unreadable config or lock, or a--projectthat is not a project, exits 2.dependency_conformanceruns the 11expectCheckcases offixtures/dependency-conformance/against the Rust port.metaobjects::dependenciesgainsvalidate_manifestandMANIFEST_FILE. Docs (docs/features/cli.md,docs/features/metadata-dependencies.md,docs/ports/rust.md,docs/CONFORMANCE.md), ADR-0065 and the changelog fragment are updated to match.Validation
Risk Assessment
✅ Low: The change is a small, bounded fix that makes
cargo meta verify --depsexit 2 on a path that is not a project and print config warnings, with matching docs, and I found no material defect in the traced cases (typo path, metadata directory passed as root, misspelled config key, config-less default project).Testing
Broad regression came from the configured test command
scripts/ci-local.sh --affected --strict-toolchains, which passed at this target commit; no re-run here since no source changed. Driven live: four scenarios through the built cargo-meta binary on disposable projects (matching, drifted, unresolved, unreadable lock), each giving the expected status and exit code; the check-arm conformance target passed 2/2. Transcript saved in the run's evidence directory. Scratch project removed.Evidence: Live cargo-meta verify --deps transcript (4 cases)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
♻️ Reviewed only the branch's changes since run 01M8XQG2ZPDKBD06HY1AZ1J3R2 approved; the rest of the branch carries that approval.
Findings carried from run 01M8XQG2ZPDKBD06HY1AZ1J3R2, already decided there:
ℹ️
server/rust/metaobjects/tests/dependency_conformance.rs:342- Corrected an inaccurate comment in the check-arm runner. It said "A result that is not current says why", but the assertion below it requiresdetailexactly when the status is unresolved, and a drifted result carries no detail. The comment now reads "An unresolved result says why; a current or drifted one does not."server/rust/metaobjects-cli/src/lib.rs:663-verify --depspasses when it never found a project.project_rootreturnscwd.join(--project)without checking it, andverify_depstreats a missing.metaobjects/config.jsonas zero dependencies. Socargo meta verify --deps --project <typo>, or--project <root>/metaobjects, prints "no dependencies declared — nothing to check." and exits 0. A CI step with a wrong path stays green while the real project's upstream has drifted.verify --codegenon the same path fails inresolve_collection(ERR_COLLECTION_NOT_FOUND), but--depsalone never reaches it. Fix: exit 2 when the root is not a directory, or has neither.metaobjects/config.jsonnor the default metadata directory. Do not call the fullresolve_collection, because it refuses an unsynced snapshot before the check can report it. Sibling at line 665:loaded.warningsis dropped, so a misspelled top-level key such asdependanciesalso passes with no hint. Print those warnings to stderr.ℹ️
server/rust/metaobjects-cli/src/lib.rs:107- Reflowed the--depshelp text: the added clause pushed one line far past the help column width; wrapped it back to match the surrounding OPTIONS block. Text unchanged.ℹ️
changelog.d/rust-verify-deps.md:8- Rewrapped the changelog bullet line that the new--projectclause made overlong, matching the file's ~100-column wrap. Text unchanged.changelog.d/rust-verify-deps.md:11- The review-inline-2 rewrap is incomplete. It moved the overflow to another line: the line starting "unresolvedand naming the Nodemeta deps check. Before,--depsexited 2. Rust now runs the check arm of" is about 111 columns, but the fix claims to match the file's ~100-column wrap. Rewrap from that line to the end of the bullet so every line is at most about 100 columns, for example by breaking after "Before,--depsexited 2." and reflowing the remaining lines. Do not change the text.🔧 Fix applied.
📝 2 wording or comment-placement notes left for the author (no fix round spent):
server/rust/metaobjects-cli/src/lib.rs:107- Reflowed the--depshelp text: the added clause pushed one line far past the help column width; wrapped it back to match the surrounding OPTIONS block. Text unchanged.changelog.d/rust-verify-deps.md:8- Rewrapped the changelog bullet line that the new--projectclause made overlong, matching the file's ~100-column wrap. Text unchanged.✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainscargo test -p metaobjects --test dependency_conformance(server/rust) — 2 passed, including every_check_case_reports_each_dependency_as_in_every_portcargo build -p metaobjects-clithen livecargo-meta verify --deps --project <disposable app>driven per case from fixtures/dependency-conformance/cases.json: matching artifact (current, exit 0); newer artifact than lock (drifted, exit 1, ERR_DEPENDENCY_UPSTREAM_DRIFT); missing path (unresolved, exit 1); unreadable lock (exit 2, ERR_DEPENDENCY_SNAPSHOT_STALE)Read-only check of ADR-0065 amendment (line 416 supersedes the --deps exit 2 ruling) and changelog.d/rust-verify-deps.md line widths (none over 101 columns)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Validated in 2 no-mistakes runs: the first left one review finding at its round cap (
verify --depspassed on a path that is not a project), fixed in the second.