26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
42 lines
1.9 KiB
Rust
42 lines
1.9 KiB
Rust
//! Regression: the first *cold* `open_or_build` on a fresh project must return a
|
|
//! built graph synchronously — not `None`.
|
|
//!
|
|
//! `open_best_effort` kicks off a one-shot background graph build the first time
|
|
//! a project is opened cold. If `open_or_build` went through that path, the
|
|
//! background build would acquire the `graph-idx` lock and the synchronous
|
|
//! `load_or_build` fallback would then contend on the same lock and return an
|
|
//! empty index, so the very first `ctx_graph` / `export_graph_html` on a fresh
|
|
//! repo failed with "No graph available" until a retry (#695/#682.2).
|
|
//!
|
|
//! Current `open_or_build` opens via `open_existing` (which never triggers the
|
|
//! background build) and only then builds synchronously, so the race cannot
|
|
//! happen. This is an integration test on purpose: the library is compiled
|
|
//! without `cfg!(test)`, so the background-build path that is skipped under unit
|
|
//! `cfg!(test)` actually exists in this binary and the guarantee is real.
|
|
|
|
#[test]
|
|
fn open_or_build_returns_graph_on_first_cold_open() {
|
|
let tmp = tempfile::tempdir().expect("tempdir");
|
|
let root = tmp.path();
|
|
std::fs::create_dir_all(root.join("src")).expect("mkdir src");
|
|
std::fs::write(
|
|
root.join("Cargo.toml"),
|
|
"[package]\nname = \"cold_open\"\nversion = \"0.1.0\"\nedition = \"2021\"\n",
|
|
)
|
|
.expect("write Cargo.toml");
|
|
std::fs::write(
|
|
root.join("src/lib.rs"),
|
|
"pub fn hello() -> &'static str { \"hi\" }\n",
|
|
)
|
|
.expect("write lib.rs");
|
|
let root_str = root.to_string_lossy().to_string();
|
|
|
|
// First call, no warm-up, no retry — must build synchronously.
|
|
let provider = lean_ctx::core::graph_provider::open_or_build(&root_str);
|
|
assert!(
|
|
provider.is_some(),
|
|
"first cold open_or_build must build the graph synchronously \
|
|
(regression: returned None / \"No graph available\")"
|
|
);
|
|
}
|