Skip to content

fix: preserve Cargo context in parallel Rust resolution - #1850

Merged
DeusData merged 1 commit into
mainfrom
fix/issue-56-rust-parallel-cargo-context-resume
Aug 28, 2026
Merged

DeusData merged 1 commit into
mainfrom
fix/issue-56-rust-parallel-cargo-context-resume

Conversation

@DeusData

Copy link
Copy Markdown
Owner

Summary

  • parse the root Cargo manifest once for direct parallel resolution and install the shared immutable context in each resolve worker
  • run Rust cross-LSP for workspace files even when per-file resolution already emitted a confident result
  • let a manifest-qualified cross-crate result supersede only the same caller, source span, kind, and source origin
  • add deterministic two-worker Cargo workspace regressions plus retain the end-to-end production repro

References #56.

Root cause

The sequential cross-LSP driver built Cargo workspace context, but direct cbm_parallel_resolve workers had no manifest in their thread-local resolver state. In addition, the parallel eligibility heuristic skipped cross-LSP when a same-named local function had already produced a high-confidence result. That local result could then out-rank the correct workspace-member target.

Alternatives and trade-offs

Selected: build the manifest once on the coordinator, borrow it read-only for the worker lifetime, install it in worker TLS, and clear TLS before teardown. This preserves the existing cbm_parallel_resolve public signature, avoids repeated filesystem parsing, and matches the resolver's existing thread-local interface.

Alternatives considered:

  • Add a manifest parameter to cbm_parallel_resolve. This makes ownership explicit, but expands a frozen public surface and every caller for context that can already be derived from the pipeline context.
  • Parse Cargo.toml independently in every worker. This avoids sharing a pointer, but duplicates I/O and parsing and complicates per-thread ownership.
  • Keep the existing confidence/eligibility heuristic. This is cheaper for the affected Rust files, but preserves the wrong-local suppression bug.
  • Replace all same-named resolutions globally. This is simpler, but can conflate distinct occurrences. The selected replacement is restricted to exact caller, span, kind, and origin.

The selected fix adds a cross-LSP pass for Rust workspace files with semantic sites even when per-file results appear complete. That is bounded extra work in exchange for Cargo-qualified correctness; generated-file exclusions remain intact, and the manifest is parsed only once.

Deterministic proof

On exact main 909051c:

  • RED reproduced three times: 70 controls passed and only the two new target tests failed
  • final narrow suite: 72 passed
  • production-only eligibility revert: 71 passed, with exactly the confident-local target failing
  • production-only worker-manifest revert: 70 passed, with both target tests failing
  • combined parallel and Rust-LSP filters: 594 passed
  • filtered production repro: 1 passed

Validation

  • make -j2 -f Makefile.cbm lint-ci
  • native macOS arm64 scripts/test.sh: 7,585 passed, 0 failed, 8 documented skips across 139 suites; watchdog and security tail checks passed
  • independent exact-commit review of bafe4f3: PASS, no findings
  • DCO sign-off present

Platform caveat

The full local-CI run completed on macOS arm64. Linux arm64/amd64 and real-Windows local legs were not run in this isolated package; the PR remains unmerged for downstream platform CI and review.

@DeusData
DeusData force-pushed the fix/issue-56-rust-parallel-cargo-context-resume branch from bafe4f3 to 0f1e65d Compare August 27, 2026 19:17
@DeusData
DeusData merged commit 56dc82e into main Aug 28, 2026
35 checks passed
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