← Back to Pull requests

Run a subset of the sqlite test suite under miri via -Zmiri-native-lib #5258

Closed
unknown closed this pull request without merging on Oct 02, 2026 11:37 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 19:15 UTC
Author

Fixes #5224

Run a subset of the sqlite test suite under miri via -Zmiri-native-lib

This PR extends the existing Miri coverage (currently limited to check_as_ref_ and the json type tests) to ~150 more sqlite lib tests, following the approach discussed in the issue: Miri's new FFI options allow loading the system libsqlite3 so that FFI calls from Rust into sqlite are checked, while two things remain unsupported and are gated out with #[cfg(not(miri))] :
1. Native → Rust callbacks. register_diesel_sql_functions becomes a no-op under cfg(miri) (the registered diesel_manage_updated_at carries an xDestroy destructor that native code invokes at connection close), and the tests exercising hooks, custom/aggregate SQL functions, auto extensions, and collation registration are compiled out.
2. Reading memory allocated by the native library. Tests that hit sqlite3_errmsg / sqlite3_value_text error paths, plus the OOM child-process tests, are compiled out.

The gating mirrors the existing #[cfg(not(miri))] // ffi call style already used in diesel/src/sqlite/types/json.rs .

To run this reliably, the commands are wrapped in cargo xtask run-tests --miri sqlite , which locates libsqlite3 via pkg-config (overridable with MIRI_NATIVE_LIB ), sets MIRIFLAGS=-Zmiri-native-lib=... , and runs the diesel lib tests on nightly. A new Miri-Native-Lib CI job runs it on ubuntu-latest with libsqlite3-dev installed.

Testing done locally:

  • cargo miri test with -Zmiri-native-lib : 151 passed, 0 failed

  • Regular suite unchanged: cargo test -p diesel --lib -F sqlite -F serde_json : 319 passed, 0 failed

  • cargo fmt --check and clippy for xtask and the sqlite backend are clean. Full cargo xtask tidy couldn't run locally ( typos binary and MySQL dev headers not installed), so I may mark this DRAFT and let CI complete the remaining checks.
  • Checklist:
    [x] I checked for similar changes and make sure to reference them (extends the existing Miri: job in .github/workflows/ci.yml ; reuses the cfg pattern from the json type tests)
    [ ] I included a changelog entry for relevant new features or changes (skipped: this is test/CI infrastructure only, no user-visible library change)

    LLM/AI usage disclosure (per CONTRIBUTING.md): This change was developed with the assistance of an AI coding agent (Freebuff). I reviewed and verified the generated code, ran the test suites locally to confirm the behavior described above, and understand the changes well enough to discuss them.

    Diff: 318 lines (+238 / -80) across 3 files Reviewer: weiznich Review duration: 2421m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 318 lines diff across 3 files
    0.40
    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.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5258"
    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: 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: 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: 16.0% · Safe to merge
    16.0%