Files
hx/docs/adr/0021-flycheck-settling.md
johannesandClaude Sonnet 5.5 a94632ea3d chore: delete code comments, add ratchet lint and ADRs
Classify every comment as tautology, stale, excuse or decision record.
Tautology/stale/excuse comments are deleted (excuses filed as issues
#196-#236), decisions moved to docs/adr/0001-0034.

- scripts/lint-comments.sh + .comment-baseline: per-file comment count
  may only go down; wired into tests/all.sh
- .claude/skills/delete-comment: repeatable audit workflow
- cargo fmt applied to touched crates

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:37:32 +01:00

15 lines
1.6 KiB
Markdown

# 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