← Back to Pull requests

perf(cache): reuse compilations with native directory aliases #1077

Closed
unknown closed this pull request without merging on Dec 04, 2026 03:21 UTC
View on GitHub
unknown unknown commented on Dec 04, 2026 02:18 UTC
Author

Projects using system native libraries can now restore compiler results when a library search directory contains directory aliases pointing elsewhere inside that same directory tree. On Debian, the OpenJPEG, Perl and ICU aliases under /usr/lib/aarch64-linux-gnu caused fnox and several dependencies to compile on every fresh-target mbx check.

The scan follows internal directory aliases and hashes their files under the searched names. Retargeting an alias between two existing directories therefore changes the key. External targets, dangling links and cycles remain refused; directory expansion, file count and byte size are bounded. A result is not published if a searched directory had an entry added, removed or renamed during compilation, which covers an alias retargeted or removed mid-build, even when the link and files involved have old timestamps. The prediction format is unchanged.

Measured with fnox 1ddad3016eb839ade236e1356a92bdc513c4e90f, default features, mbx check --locked --offline, Rust 1.98.0 on Linux arm64. Both mbx binaries used Rust 1.95.0 release builds. Runs used the same isolated local cache, checkout and fixed target path, with a fresh target for every trial, capped at four CPUs and 6 GB. After priming both clients, switching back to main and then to the candidate gave:

| Three warm trials | Main b49f18d | This change |
| --- | ---: | ---: |
| Median wall time | 11.08s | 2.47s |
| Range | 10.75–11.74s | 2.42–2.49s |
| Cache hits | 833 | 838 |

The candidate had zero misses or unconsulted compilations in those warm trials. A separate verification run rebuilt 2,363 cached compilations with zero divergences; 18 misses and 36 unconsulted compilations were also built, so verification did not cover every compilation. These are local-cache measurements on one host; remote restores and other platforms were not measured.

mise run ci passes in the isolated Linux arm64 runner (Clippy, workspace and integration tests, 107 Bats cases with platform/tool skips, PTY and docs/link checks). Final-source performance confirmation passed. A linked C/Rust fixture also checks actual output through library/header changes and alias retarget/removal/return; returning to a prior key restores its correct value. The focused adapter regression fails on main. Tests cover library/header edits, alias retargeting/removal/return, direct versus predicted keys, and rejection of external targets and cycles; a CLI regression drives real mbx check through those changes.

AI-assisted — Tool: Codex; model: openai/unavailable; version: unavailable.

<!-- CURSOR_SUMMARY -->
---

[!NOTE]

Medium Risk

Changes core compiler input discovery and publish gating for native search paths; incorrect alias or mtime logic could cause stale cache hits or extra bypasses, but behavior is heavily tested on Unix.

> Overview

Native -L native walks now follow directory symlinks inside the search tree and hash libraries/headers under the searched path names, so retargeting an alias (e.g. current → first vs second) changes the action key even when both targets already exist. Previously, canonicalizing through those links could miss alias-only changes and force bypasses on layouts common on Linux (versioned libs with current-style aliases).

> collect_native_directory returns a NativeWalk (traversed directories + alias paths). That walk is stored on DiscoveredInputs and replayed on prediction. verify_not_modified_since checks walk paths after file inputs so mid-compile adds/removes/retargets on searched dirs (including renames with old link mtimes) block publishing without masking a proven source change.

> Guards unchanged or tightened: aliases escaping the tree, dangling links, cycles, and alias chains over 63 still unsupported-search-path; directory count is bounded like predicted inputs.

> Docs in limits.md describe alias walking and compile-time directory mutation rules. New unit and mbx check integration tests cover retarget/remove/return, in-compile alias changes, and cycle refusal.

> <sup>Reviewed by Cursor Bugbot for commit 8a7134d76fa50ae1dbbdf51928b4fe4c322771c2. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

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

Summary by CodeRabbit

New Features
Native-library directory aliases are tracked by their searched paths, so retargeting an alias or changing files reached through it can invalidate cached build results.
Directory aliases within the searched tree are followed, including when the search root is a symlink. Cycles, dangling links, aliases that escape the tree, and excessive directory walks bypass caching.
Cached results are not used when tracked directories cannot be checked or change during compilation.
Documentation
Clarified symlink handling and directory-walk limits for native-library directory hashing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 650 lines (+487 / -163) across 8 files Reviewer: jdx Review duration: 62m
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
0.52
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%
56%
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.388
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1077"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% 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: 52% (MEDIUM) · Higher = larger blast radius
52%
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: 56.8% · Lower = rushed or shallow review
56.8%
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: 22.5% · Safe to merge
22.5%