# Wait for rust-analyzer's on-save flycheck before trusting diagnostics Status: accepted ## Context The lens injects diagnostics at turn end. rust-analyzer publishes plain syntax/semantic diagnostics immediately, but the cargo check results (flycheck) arrive later, after a `$/progress` `end` event, and only when the file was saved. Taking the first publish after a change gives an empty or stale result. A check still running from an earlier turn, or one that ends after our save but belongs to an earlier save, carries stale results. Under parallel cargo load, flycheck may also start late. ## Decision `Client::diagnostics_after` waits in stages: any check still running from an earlier turn or startup must finish first; checks are counted from after our own save so a check that is still ending from an earlier save is ignored; with `expect_check` it waits until a flycheck completes (checks_done grows and none active) or, if none ever starts within 15s (checkOnSave disabled, or queued under load), gives up; once the check ends it waits up to 10s for a publish that arrives after it. The test script runs the real rust-analyzer test alone, after the parallel suite, for the same reason. The test fixture also keeps the fix file's mtime clearly newer than the last check's start, since cargo's freshness check uses mtimes. ## Consequences Turn-end reports are slower (bounded by the 15s/10s limits) but not stale. Tests depending on rust-analyzer are serialized in `tests/all.sh`. Code: crates/hx-lens/src/lsp.rs:Client::diagnostics_after, crates/hx-lens/src/lib.rs (rust_analyzer_turn_end test), tests/all.sh