Skip to content

feat(rust): check declared dependencies with cargo meta verify --deps - #702

Merged
dmealing merged 7 commits into
mainfrom
fm/mo-140-w0-r1b
Dec 3, 2026
Merged

dmealing merged 7 commits into
mainfrom
fm/mo-140-w0-r1b

Conversation

@dmealing

@dmealing dmealing commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds metaobjects::dependency_check (check_dependencies), which resolves each declared path dependency, validates the publisher's metaobjects.pkg.json, re-hashes the artifact beside it, and reports each dependency as current, drifted or unresolved against .metaobjects/deps.lock.json. Non-path transports report unresolved and point to meta deps check.
  • cargo meta verify --deps now runs this check instead of exiting 2. It is opt-in and not part of a bare verify. Drifted or unresolved dependencies exit 1 with ERR_DEPENDENCY_UPSTREAM_DRIFT; an unreadable config or lock, or a --project that is not a project, exits 2.
  • dependency_conformance runs the 11 expectCheck cases of fixtures/dependency-conformance/ against the Rust port. metaobjects::dependencies gains validate_manifest and MANIFEST_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 --deps exit 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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Matching publisher artifact reports current and exits 0 (live cargo-meta CLI, synthetic fixture acme-common v1) ✅ pass live rust-verify-deps-live.txt: 'acme-common: current', exit 0
Newer artifact than lock reports drifted, exits 1 with ERR_DEPENDENCY_UPSTREAM_DRIFT (adversarial) ✅ pass live rust-verify-deps-live.txt: 'drifted — lock 1.0.0, installed 1.1.0', exit 1
Missing path reports unresolved, exits 1 (adversarial) ✅ pass live rust-verify-deps-live.txt: 'unresolved — ... no directory exists there', exit 1
Unreadable lock exits 2 rather than 1 (boundary: config or lock unreadable) ✅ pass live rust-verify-deps-live.txt: ERR_DEPENDENCY_SNAPSHOT_STALE, exit 2
Evidence: Live cargo-meta verify --deps transcript (4 cases)
== matching artifact (expect current, exit 0): exit 0
acme-common: current — 1.0.0 (10fbf886)
verify --deps: every dependency's installed artifact matches the lock.

== newer artifact than lock (expect drifted, exit 1): exit 1
acme-common: drifted — lock 1.0.0 (10fbf886), installed 1.1.0 (fa00b9f3); run meta deps sync and review the artifact diff
verify --deps: 1 of 1 dependency drifted or unresolved (ERR_DEPENDENCY_UPSTREAM_DRIFT).

== missing path (expect unresolved, exit 1): exit 1
acme-common: unresolved — the "path" transport resolved to <scratch>/unresolved/app/../acme-common/metaobjects, but no directory exists there; run meta deps sync once the dependency is reachable
verify --deps: 1 of 1 dependency drifted or unresolved (ERR_DEPENDENCY_UPSTREAM_DRIFT).

== unreadable lock (expect exit 2): exit 2
verify --deps: ERR_DEPENDENCY_SNAPSHOT_STALE: <scratch>/badlock/app/.metaobjects/deps.lock.json exists but could not be read as JSON: key must be a string at line 1 column 2; run `meta deps sync`

{"current": 0, "drift": 1, "unresolved": 1, "badlock": 2}

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos

♻️ 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 requires detail exactly 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 --deps passes when it never found a project. project_root returns cwd.join(--project) without checking it, and verify_deps treats a missing .metaobjects/config.json as zero dependencies. So cargo meta verify --deps --project &lt;typo&gt;, or --project &lt;root&gt;/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 --codegen on the same path fails in resolve_collection (ERR_COLLECTION_NOT_FOUND), but --deps alone never reaches it. Fix: exit 2 when the root is not a directory, or has neither .metaobjects/config.json nor the default metadata directory. Do not call the full resolve_collection, because it refuses an unsynced snapshot before the check can report it. Sibling at line 665: loaded.warnings is dropped, so a misspelled top-level key such as dependancies also passes with no hint. Print those warnings to stderr.

  • ℹ️ server/rust/metaobjects-cli/src/lib.rs:107 - Reflowed the --deps help 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 --project clause 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 "unresolved and naming the Node meta deps check. Before, --deps exited 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, --deps exited 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 --deps help 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 --project clause made overlong, matching the file's ~100-column wrap. Text unchanged.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Matching publisher artifact reports current and exits 0 (live cargo-meta CLI, synthetic fixture acme-common v1) ✅ pass live rust-verify-deps-live.txt: 'acme-common: current', exit 0
Newer artifact than lock reports drifted, exits 1 with ERR_DEPENDENCY_UPSTREAM_DRIFT (adversarial) ✅ pass live rust-verify-deps-live.txt: 'drifted — lock 1.0.0, installed 1.1.0', exit 1
Missing path reports unresolved, exits 1 (adversarial) ✅ pass live rust-verify-deps-live.txt: 'unresolved — ... no directory exists there', exit 1
Unreadable lock exits 2 rather than 1 (boundary: config or lock unreadable) ✅ pass live rust-verify-deps-live.txt: ERR_DEPENDENCY_SNAPSHOT_STALE, exit 2
  • scripts/ci-local.sh --affected --strict-toolchains
  • cargo test -p metaobjects --test dependency_conformance (server/rust) — 2 passed, including every_check_case_reports_each_dependency_as_in_every_port
  • cargo build -p metaobjects-cli then live cargo-meta verify --deps --project &lt;disposable app&gt; 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 --deps passed on a path that is not a project), fixed in the second.

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.
@dmealing
dmealing merged commit d90ca97 into main Dec 3, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-140-w0-r1b branch December 3, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant