← Back to Pull requests

fix(cargo): stop recursive explicit mbx wrappers #977

Closed
unknown closed this pull request without merging on Nov 27, 2026 21:48 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 17:15 UTC
Author

A temporary cargo wrapper ran exec mbx cargo "$@" ahead of real Cargo on PATH. Each metadata probe re-entered mbx through its explicit-command path, bypassing the Cargo shim's recursion guard. One container exhausted its 8,192-PID limit with a single chain of mbx processes.

Explicit Cargo commands now share the shim's 12-level nesting limit. Once recursion is detected, a shared counter limits retries across the invocation tree to 128, including sibling probes and command listings. Wrapper fallback, alias expansion and metadata recovery remain available within those bounds. Successful probes cannot reset the counter. After a loop has been detected, the budget remains active until the outer command exits; restart a long-running watcher after fixing its wrapper.

The guard uses private, random temporary paths and cleanup by the outer invocation. Nested commands require the counter initialized by their outer command and stop if it is missing, truncated or unwritable. Top-level direct Cargo queries remain usable without writable temporary storage. Nested sandboxes must retain access to the inherited guard state. No new settings or flags are required.

Each metadata probe retains its own loop diagnosis. An unrelated failed probe keeps its Cargo error, and a successful sibling cannot erase another probe's failure. If alias recovery also fails after a detected loop, the error reports both causes; ordinary alias failures continue to report the expanded project's actionable error. mbx explain --last replays recorded results without entering the Cargo guard. Programs launched by mbx run, including nested launches, receive their original application environment; a detached application can start a new build after its parent exits, while live Cargo re-entry keeps the active recursion limit.

For normal use, keep the supported Cargo shim or invoke mbx fmt --all -- --check with real Cargo reachable. mbx cargo fmt is not valid explicit syntax; wrappers using exec mbx "$@" can also recurse if selected as Cargo.

Validation:

  • Hosted CI passes on Linux x86-64 and ARM64, macOS, and Windows, including the final CI gate.

  • All 20 wrapper-loop integration tests, 16 Cargo-invocation tests and 17 session-scope tests pass. Regressions cover sibling and alias diagnostics, missing/truncated retry state, read-only explanation after budget exhaustion, paths containing apostrophes, private-file cleanup, fallback, live launch recovery, independent nested application daemons and unusable temporary storage. The budget-retention test requires an observed successful metadata probe.

  • Lossless non-UTF-8 Cargo-path serialization remains tested on Unix. The filesystem-name case is excluded on macOS because its filesystem rejects that name before mbx can run.

  • Earlier EC2 smoke testing reproduced the installed loop and verified the guard's bounds without changing the shared installation.

  • The complete workspace Rust suites/doctests, formatting, debug/release Clippy, build, documentation/links, terminal checks and release publication diagnostics pass locally. The three standalone C-cache Bats failures also reproduce on unchanged main (ee819a4) on this host.
  • AI-assisted — Tool: Codex; model: openai/GPT-6; version: 0.170.0.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Recursive Cargo wrappers now stop after bounded retries and provide clearer loop diagnostics.
    Cargo commands recover more reliably from wrapper failures, including when resolving Cargo directly.
    Temporary loop-tracking state is cleaned up after commands complete.
    Cargo selections with non-standard characters are preserved across wrapper invocations.
    Nested applications no longer inherit Cargo shim tracking state.
    * “Explain last” runs without preparing an explicit Cargo selection.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 499 lines (+374 / -125) across 6 files Reviewer: jbellis Review duration: 13233m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 499 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.372
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #977"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 18.8% · Safe to merge
    18.8%