{"record":{"id":"c83af0f38279aa55","repo":"BoundaryML/baml","slug":"engine-is-not-current-with-the-latest-sources-wait-for-the","errorCode":null,"errorMessage":"engine is not current with the latest sources; wait for the rebuild","messagePattern":"engine is not current with the latest sources; wait for the rebuild","errorType":"error_code","errorClass":"PrepareRunError","httpStatus":null,"severity":"warning","filePath":"baml_language/crates/baml_lsp_server/src/engine.rs","lineNumber":94,"sourceCode":"        receipt: CommitReceipt,\n        /// The engine this commit replaced, handed back for the caller to\n        /// shut down. Commits are owner-thread work and the owner is not a\n        /// tokio worker, so the runtime cannot spawn the drain itself — see\n        /// [`spawn_engine_shutdown`].\n        retired: Option<Arc<BexEngine>>,\n    },\n    /// The source revision advanced past the candidate; nothing changed and\n    /// the candidate was dropped quietly.\n    Superseded { current_revision: SourceRevision },\n}\n\n/// Why a run snapshot could not be produced. There is no `Busy`/`Broken`\n/// axis anymore: reads are owner-linearized and panics never poison state.\n#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]\npub enum PrepareRunError {\n    /// No engine yet, or the installed engine predates the current source.\n    /// Runs never silently use a last-known-good engine.\n    #[error(\"engine is not current with the latest sources; wait for the rebuild\")]\n    NeedsCurrentBuild,\n}\n\n/// Coherent snapshot for launching a function run.\n#[derive(Clone)]\npub struct RunSnapshot {\n    pub generation: u64,\n    pub engine: Arc<BexEngine>,\n}\n\n/// Ticket for one test-collection attempt, captured atomically.\npub struct CollectionTicket {\n    pub generation: u64,\n    collection_epoch: u64,\n    pub engine: Arc<BexEngine>,\n    pub cancel: sys_types::CancellationToken,\n}\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp_server/src/engine.rs#L76-L112","documentation":"This error comes from `PrepareRunError::NeedsCurrentBuild` in the LSP server's engine module. It means a function run could not be launched because there is no engine installed yet, or the installed engine binary predates the current source files. The server deliberately refuses to run against a stale or missing engine instead of silently using a last-known-good build.","triggerScenarios":"Calling the run-snapshot preparation path (`prepare_run`) when no engine has been built yet, or when the engine was built before the latest edits to the sources, i.e. the installed engine generation does not match the current source state.","commonSituations":"Editing a .bml function and immediately trying to run it before the incremental rebuild finishes; a fresh checkout where the engine was never built; a build that failed leaving a stale engine binary installed.","solutions":["Wait for the engine rebuild to complete, then retry the run","Trigger an explicit rebuild of the engine from the current sources","Check the build output for failures — a stale engine usually means the latest build errored or is still in progress","Verify the installed engine generation matches the current source generation before launching runs"],"exampleFix":"// before: immediately invoking run after an edit\nlet snapshot = prepare_run(&state, request)?;\n\n// after: retry until the engine is current\nmatch prepare_run(&state, request) {\n    Ok(snapshot) => snapshot,\n    Err(PrepareRunError::NeedsCurrentBuild) => {\n        schedule_retry_after_rebuild(request);\n        return;\n    }\n}","handlingStrategy":"retry","validationCode":"// rust\nfn engine_is_current(state: &State) -> bool { state.engine_generation() == state.source_generation() }","typeGuard":null,"tryCatchPattern":"match prepare_run(&state, req) {\n    Ok(s) => s,\n    Err(PrepareRunError::NeedsCurrentBuild) => { retry_after_rebuild(req); }\n}","preventionTips":["Gate run requests on a rebuild-completed notification","Never cache engine handles across source edits","Surface build status in the UI before enabling run commands"],"tags":["lsp","rust","stale-build","engine"],"backgroundTag":"invalid-state-transition","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}