Repository navigation
feat(lsp): emit standard work-done progress for analysis lifecycle (#1971) - #2128
Conversation
…1971) Wrap accepted analysis requests in window/workDoneProgress/create and $/progress, gated on the client's work-done-progress capability, while the typed ripr/analysisStatus notification stays the richer RIPR-specific channel. - One token per accepted generation; deduplicated/stopped requests create no traffic; a queued request begins as queued and transitions to analyzing on the same token when promoted. - Exactly one terminal end per generation on every path (complete, limited, failed, cancelled, superseded, not_started): the registry only ends after removing the token, outcome ends, guard-Drop ends, invalidation/shutdown drains, and pending-replacement ends cover every route; terminal messages derive from the same health/outcome as ripr/analysisStatus. - No fabricated percentages (denominator unknown); one bounded report at a real phase boundary (publishing); no file paths, source excerpts, or config values in generic messages. - Capability-absent clients see zero progress traffic and are never treated as failed; a create error is logged and cannot corrupt analysis state (best-effort, token dropped). - riprAgent work_done_progress stays false: that field describes the riprAgent sub-protocol's own surface, not the standard LSP channel. 17 tests: tracker unit tests, backend decision-level tests for success/queued/dedup/cancellation/supersession/config-unavailable/ failure-kind, and two wire-level tests over a real server (failed-end without path leaks, capability-absent silence).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
WalkthroughAdds capability-gated LSP work-done progress for analysis refreshes, including queued and active generations, phase reports, terminal outcomes, cancellation handling, shutdown cleanup, scheduler metadata, and unit and wire-level tests. ChangesAnalysis progress lifecycle
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant LSPClient
participant Backend
participant RefreshScheduler
participant AnalysisProgressTracker
LSPClient->>Backend: request refresh
Backend->>RefreshScheduler: schedule refresh
RefreshScheduler-->>Backend: return Start or Queued decision
Backend->>AnalysisProgressTracker: emit progress lifecycle
AnalysisProgressTracker->>LSPClient: send create, begin, report, and end notifications
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces standard LSP work-done progress tracking for accepted analysis requests, integrating it into the LSP backend, capabilities, and refresh scheduler. The feedback focuses on addressing potential race conditions in the asynchronous progress tracking lifecycle. Specifically, the reviewer recommends tracking whether a progress token has actually started (via a new started field in TokenRecord) to prevent out-of-order notifications or leaks if a token is cancelled or ended concurrently during await points in the begin function, and updating the reporting and termination methods accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- begin() inserts into the registry AFTER sink.create().await and sink.notify().await. A concurrent end() for the same generation during those awaits finds no entry and returns; begin then notifies on a token that will never be end-tracked. Add a guard field (e.g. record.started=false pre-insert, transition to started after notify) or insert a placeholder before await so concurrent ends remove it cleanly.
- RefreshCancellationGuard::drop silently drops progress termination when no tokio runtime handle is current (e.g. sync teardown). Either log+ignore, or document the invariant that Drops only happen under a current runtime; wire-level test only exercises the runtime-present path.
Confirmed findings
- begin() holds tokens lock only across the contains_key check (not across sink.create.await); if a concurrent end_queued/shutdown runs while create is pending, it can drop the token entry before begin inserts, so no leak but early-arriving End may arrive without Begin - create pre-empts notify of Begin per spec, but registry then has no record so later end silently no-ops, leaving token in client.
- ProgressSink::create drops error result on supported==false path before notifying Begin; registry entry not inserted, so subsequent end() no-ops - client never receives End for create-failed generations. Spec-compliant but the new terminal 'create failed' event is currently silent in the sink.
- ub-active-view lane is structurally out of scope: PR is LSP server work-done progress with no ArrayBuffer/TypedArray/resizable-buffer surface. Active-view analogs (BTreeMap token registry under Mutex) are bounded snapshots and do not exhibit length-staleness or detach hazards.
- Gemini prior review's race objection (started: bool in TokenRecord) is resolved by the tracker's remove-before-notify pattern plus contains_key guard in begin; PR body + new tests demonstrate this. Worth noting as sub-material polish: the create-then-insert ordering in begin still permits a transient window where a concurrent end sees no token and is a no-op — not a leak, but begin's Begin notification could in principle fire after the drop guard's End for an abandoned generation; the in-test guarded ordering masks this rather than asserting the invariant.
- Sibling helper coverage: new standard work-done progress is fully encapsulated in progress.rs + backend wiring; no parallel crypto/compression/runtime helper families exist in the 6-file diff. The refresh scheduler's Queued variant addition is the only sibling-shaped API change and its sole new match arm lives in emit_progress_for_decision. Residual risk: any future caller that pattern-matches RefreshDecision::Queued without
..will need updating. - supplanting superseded_pending: in emit_progress_for_decision the superseded generation is ended before the new queued request begins, so the superseded token transitions from queued to end(superseded) without ever moving to analyzing; ordering matches the issue spec but a wire-level test for 'queued replaced by queued' is not present.
Verification questions
- Confirm end_all in shutdown is awaited inline before clear_all_diagnostic_uris; guard-drop ends are spawned fire-and-forget. Ordering: shutdown's end_all can drain tokens the guard was about to end, leaving guard's spawn to no-op (registry-empty), which is correct but depends on runtime being live during shutdown.
- Confirm test asserts exactly two End events after guard drop but does not assert which token maps to which message: both rows are 'analysis cancelled', so a swapped assignment (gen-1=superseded, gen-2=active) would also pass.
- Confirm refreshDecision::Queued gained a pub(super) field; sibling callers outside the two updated sites may destructure and miss superseded_pending.
Verification questions
Refuted
[review body truncated; see review artifacts]
[review body truncated; see review artifacts]
Review on #2128 (six related threads, all valid): begin() inserted the token only after sink.create/notify awaited, so a concurrent end() during that window found nothing and the generation leaked a Begin with no End. Tokens now register as started: false before any await; ends remove unstarted tokens silently (no begin was ever sent, so no end may follow); transition/report/end/end_queued/end_all only notify for started tokens; a failed create drops the placeholder so a later begin can retry. Two new tests cover the silent unstarted end and the retry path. The cancellation guard's no-runtime skip is now an explicit documented invariant.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/ripr/src/lsp/progress.rs (1)
256-289: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftResidual begin/end race can still leave
ripr-analysis-{generation}opencrates/ripr/src/lsp/progress.rs:234-289: ifend/end_allremoves the placeholder whilebeginis awaitingsink.create/notify(Begin),beginstill sendsBeginand never recordsstarted, so no terminalEndcan follow. Store a pending terminal on the placeholder and flush it afterBegin, or serialize progress transitions per generation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ripr/src/lsp/progress.rs` around lines 256 - 289, Update the begin/end lifecycle around the progress placeholder and the begin method so a concurrent end or end_all cannot leave a progress token open while begin awaits sink.create or notify(Begin). Preserve a pending terminal state on the generation record when termination arrives before begin completes, then flush the corresponding End after Begin and mark the record started; alternatively serialize transitions per generation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/ripr/src/lsp/progress.rs`:
- Around line 256-289: Update the begin/end lifecycle around the progress
placeholder and the begin method so a concurrent end or end_all cannot leave a
progress token open while begin awaits sink.create or notify(Begin). Preserve a
pending terminal state on the generation record when termination arrives before
begin completes, then flush the corresponding End after Begin and mark the
record started; alternatively serialize transitions per generation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3fdea87e-7c71-4a77-a5bc-5ae92e6cf54a
📒 Files selected for processing (2)
crates/ripr/src/lsp/backend.rscrates/ripr/src/lsp/progress.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/ub-review(auto-detected)
Summary
Fixes #1971. Accepted analysis requests are now wrapped in standard
window/workDoneProgress/create+$/progress, gated on the client's work-done-progress capability. The typedripr/analysisStatusnotification stays as the richer RIPR-specific channel.Token lifecycle: one token per accepted generation (
ripr-analysis-{gen});RefreshDecision::Deduplicated/Stoppedcreate no traffic; a queued request begins asqueuedand transitions toanalyzingon the same token when the scheduler promotes it;Queuednow carriessuperseded_pendingso the replaced pending generation gets its ownsupersededend. One bounded report at a real phase boundary (publishing); no percentages — the denominator is unknown.Exactly one terminal end per generation on every path: the tracker registry only ends a token after removing it (repeat ends are no-ops); outcome ends in the refresh loop,
RefreshCancellationGuard::dropfor abandoned futures, root/config invalidation drains queued tokens as superseded, shutdown drains everything as cancelled, pending replacement ends the replaced generation. Terminal messages derive from the same health/outcome asripr/analysisStatus(complete,limited (run status: …),failed ({kind}),cancelled,superseded,not_started).Honesty bounds: no file paths, source excerpts, or config values in generic messages; capability-absent clients see zero progress traffic and are never treated as failed; a create error is logged via
window/logMessageand the token dropped — best-effort, analysis state untouched.riprAgent'swork_done_progressstaysfalsedeliberately: that field describes the riprAgent sub-protocol's own surface, not the standard LSP channel.Proof (independently re-verified after the builder run)
Test evidence per the issue's required matrix: success; queued-then-success (same token); deduplicated (no token); cancellation (guard-drop, exactly-once on repeat); superseded generation; config/root unavailable before start (zero events); analysis error (kind without paths, wire-level over a real server); capability-absent silence (wire-level).
Noted limits (honest, in-code): no timeout mechanism exists today (cooperative cancellation only), so the timeout terminal maps to cancelled/failed; the wire-level E2E covers the failed path deterministically while success is asserted at decision/tracker level.
Claim boundary
Additive standard-progress surface only. No change to refresh scheduling semantics, analysis behavior,
ripr/analysisStatus, or the riprAgent capability vocabulary.RefreshDecision::Queuedgains an internalpub(super)field; no public API/schema change.Rollback
Revert the commit; progress traffic disappears, all existing status surfaces unchanged.