← Back to Pull requests

fix: order builds by the requirements of inherited staging outputs #2973

Open
unknown opened this pull request with 317 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 28, 2026 11:20 UTC
Author

Fixes #2492.

With --recipe-dir, a recipe whose staging output host-depends on another local recipe could be built before that recipe and fail. With the recipes from the issue:

Cannot solve the request because of: No candidates were found for package_c ==0.1.0.

extract_dependency_names supplies the edges of the build-order graph, and it read only the output's own requirements. A staging output is not a node in that graph. Its requirements are stored in staging_caches on every output that inherits it, and the sort never read that field, so nothing ordered package_a after package_c. Repeating the dependency on the inheriting output, as described in the issue, worked around it.

This change adds the build and host requirements of recipe.staging_caches to the output's build-time dependencies. Both topological_sort_by_dependencies (--recipe-dir, --up-to) and topological_sort_variants (the order of one recipe's outputs) use this helper. Self-dependencies are still skipped, so a staging that host-depends on its own output adds no cycle. Staging requirements now follow the same rule as an output's own host dependencies. So if a staging host-depends on a local recipe that itself host-depends on the inheriting output, the sort now reports a cycle. Before, that recipe was ordered after the inheriting output, so the staging could only get it from a channel.

Not covered: with --parallel-builds 2, the issue's recipes still fail the same way. The readiness check (can_build in src/build_queue.rs) looks only at the output's own requirements, so package_a can start before package_c is built. I left that out to keep this change small.

Testing (Rust 1.100.0; the repo pins 1.99.1):

  • New test_topological_sort_considers_staging_requirements: fails on main (left: ["package-a", "package-c"], right: ["package-c", "package-a"]) and passes with the fix.

  • cargo test --workspace --all-targets --features=recipe-generation passes.

  • cargo fmt -- --check and typos pass. cargo clippy --all-targets --all-features --workspace -- -D warnings reports only clippy::needless_bool at src/build_queue.rs:600, a file this change does not touch.

  • The issue's recipes, full build with the output directory as the only channel: on main it fails with the error above. With the fix it builds package_c, package_a and package_b and writes all three packages.

  • --render-only on the 25 recipes in the repo that use a staging output gives the same order before and after.
  • AI-assisted.

    Diff: 317 lines (+237 / -80) across 3 files Reviewer: pb01ka Review duration: 7347m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 317 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2973"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%