aft_inspect: report current diagnostics or partial, never stale (#829)

Merged
AF
1d ago
+1451-248

Fixes the stale aft_inspect diagnostics reported in #829.

Problem. Right after a file changed, aft_inspect could return the language server's diagnostics for the old content, or a clean result it never checked, as if they were current.

Fix. A diagnostics report counts only if it matches the file's current content. Edits made outside AFT that the watcher hasn't reported yet are covered too. If no matching report arrives within the normal limit, the file is listed as partial with the approved reason: "no diagnostics for the current file content arrived in time; retry aft_inspect".

  • Servers that answer diagnostic requests use the strict rule (versioned or receive-order fenced).
  • Servers that only push diagnostics without a version (e.g. the default Kotlin server) get a fallback: a report counts if it arrived after AFT's last edit and the file still matches what AFT sent. Otherwise those files would stay partial forever.

Merge note. Merging main brought the per-server idle stop (#1170), which counts every didOpen/didChange/didSave as use. This branch sends full-document changes through an ordered sender that skipped that stamp, so a server being edited this way could have been stopped as idle. The ordered sender now stamps last use like every other document sender.

Tests. An outside edit with no watcher event, a timeout that names the file and returns no old errors, late server reports with and without a version, a version-less push-only server, and the receive-order fences.

Build server (main merged): 897 lsp/inspect lib tests, the inspect/LSP integration files (304 passed), formatting and the Windows check. Two tests that drive a real rust-analyzer now run on the build server's new image and failed: lsp_diagnostics_test::real_rust_analyzer_checks_do_not_block_cargo_build fails identically on main there, because the job sets CARGO_TARGET_DIR so rust-analyzer's check folder lands under it. inspect_command_test::scoped_rust_inspect_waits_for_a_late_first_cargo_check_with_real_rust_analyzer failed only in the full parallel run and passes alone on this branch and on main.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes aft_inspect reporting stale diagnostics or a false clean result as current right after a file changes.

  • Diagnostics only count if they match the file's current content; otherwise the file is reported as partial with the reason "no diagnostics for the current file content arrived in time; retry aft_inspect".
  • Edits made outside AFT before the watcher reports them are covered.
  • Versionless push-only servers (for example the default Kotlin server) use a receive-order fallback: a report counts if it arrived after AFT's last edit and the file still matches what AFT sent.
  • The ordered full-document sender now stamps last use so the per-server idle stop from #1170 doesn't shut down a server being edited this way.