crate_universe: resolve annotation patches against the current module #4425
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 245 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.329
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4425"
general
weight: 0.35
UebelAndre
Problem
crate.annotation(patches = ...)labels are stored incargo-bazel-lock.jsonas canonical strings, so their form depends on which module was root when the lockfile was pinned (@@//…vs@@my_module+//…). Since #3521 the digest ignores the repo part, so the lockfile is reused unchanged when the module is consumed by another root._generate_hub_and_spokesthen passes the stored string straight tohttp_archive/git_repository, and@@//resolves to the consumer's main repo:Re-pinning from the consumer only moves the breakage: the module then fails as root. No single lockfile works in both setups.
Fix
Build an index from the current invocation's annotation tags,
(crate, repo-stripped label) → label as resolved now, and use it to rewrite lockfile patch labels before creating crate repos. The repo-stripping is the same normalization the digest already uses. Labels with no matching annotation keep their lockfile value. There's no lockfile format change, no digest change and no forced re-pin.Testing
A module owns a
crate.from_cargohub with a patched crate annotation and its own lockfile pinned as root. A second root module depends on it throughlocal_path_overrideandinclude()s its*.MODULE.bazel.Happy to add a regression test under
test/(a nested module with a lockfile and a patch annotation, built as root and as a dependency) if that's the preferred shape.Notes
Other label-valued annotation fields (
deps,build_script_data,additive_build_file, …) may have the same problem when rendered into spoke BUILD files. This PR only fixespatches, whichextensions.bzlconsumes directly.Assisted-by: Claude Code:claude-opus-5-5