Skip to content

feat(lsp): emit standard work-done progress for analysis lifecycle (#1971) - #2128

Merged
EffortlessSteven merged 2 commits into
mainfrom
codex/lsp-work-done-progress
Jul 21, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
codex/lsp-work-done-progress

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

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 typed ripr/analysisStatus notification stays as the richer RIPR-specific channel.

Token lifecycle: one token per accepted generation (ripr-analysis-{gen}); RefreshDecision::Deduplicated/Stopped create no traffic; a queued request begins as queued and transitions to analyzing on the same token when the scheduler promotes it; Queued now carries superseded_pending so the replaced pending generation gets its own superseded end. 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::drop for 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 as ripr/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/logMessage and the token dropped — best-effort, analysis state untouched. riprAgent's work_done_progress stays false deliberately: that field describes the riprAgent sub-protocol's own surface, not the standard LSP channel.

Proof (independently re-verified after the builder run)

RUSTC_WRAPPER="" cargo test -p ripr                      # full suite green (17 work-done-progress tests)
cargo clippy -p ripr --all-targets -- -D warnings         # clean
cargo fmt --check                                         # clean
cargo run -p xtask --quiet -- precommit                   # full gate list green

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::Queued gains an internal pub(super) field; no public API/schema change.

Rollback

Revert the commit; progress traffic disappears, all existing status surfaces unchanged.

…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).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added LSP work-done progress notifications for workspace analysis refreshes, including queued, analyzing, and publishing phases.
    • Emits exactly one terminal progress result per generation (complete, failed, cancelled, superseded), gated on client capability.
  • Bug Fixes
    • Improved lifecycle handling to avoid duplicate or leaking progress endings across cancellation, replacement, shutdown, and invalidation.
    • Better tracking of superseded queued work when multiple refreshes occur.
  • Tests
    • Expanded unit and wire-level integration tests covering capability detection and correct progress begin/report/end semantics.

Walkthrough

Adds 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.

Changes

Analysis progress lifecycle

Layer / File(s) Summary
Progress protocol and tracker
crates/ripr/src/lsp.rs, crates/ripr/src/lsp/progress.rs
Defines progress payloads, tracker state, phase transitions, terminal outcomes, capability gating, and exactly-once token completion.
Capability and scheduler contracts
crates/ripr/src/lsp/capabilities.rs, crates/ripr/src/lsp/refresh_scheduler.rs, crates/ripr/src/lsp/backend.rs
Detects client progress support, records it during initialization, and reports superseded queued refresh generations.
Refresh lifecycle and cancellation wiring
crates/ripr/src/lsp/backend.rs
Connects progress tokens to refresh decisions, analysis and publishing phases, outcomes, invalidation, cancellation, configuration changes, workspace changes, and shutdown.
Lifecycle and wire-level validation
crates/ripr/src/lsp/capabilities.rs, crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/tests.rs
Tests capability detection, token sequencing, deduplication, terminal states, cancellation cleanup, failure messaging, and real LSP progress traffic.

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
Loading

Poem

A rabbit watched the tokens flow,
From queued starts to ends aglow.
Through tasks canceled, endings stayed fair—
No duplicate tails went hopping there.
The LSP hummed, “Progress is clear!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the feature and proof, but it omits many required template sections like source links, scope, policy, gates, and traceability. Add the missing template sections: Swarm/Source Boundary, source links, scope/classification, support/policy impact, proof matrix, claim boundary, rollback, traceability, static checks, CI economics, and engineering checklists.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding standard LSP work-done progress for the analysis lifecycle.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/lsp-work-done-progress

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/ripr/src/lsp/progress.rs Resolved
Comment thread crates/ripr/src/lsp/progress.rs Resolved
Comment thread crates/ripr/src/lsp/progress.rs Resolved
Comment thread crates/ripr/src/lsp/progress.rs Resolved
@codecov

codecov Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.25248% with 103 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/lsp/progress.rs 89.05% 64 Missing ⚠️
crates/ripr/src/lsp/backend.rs 80.21% 37 Missing ⚠️
crates/ripr/src/lsp/capabilities.rs 92.85% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Comment thread crates/ripr/src/lsp/progress.rs Resolved
Comment thread crates/ripr/src/lsp/backend.rs Resolved
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lift

Residual begin/end race can still leave ripr-analysis-{generation} open crates/ripr/src/lsp/progress.rs:234-289: if end/end_all removes the placeholder while begin is awaiting sink.create/notify(Begin), begin still sends Begin and never records started, so no terminal End can follow. Store a pending terminal on the placeholder and flush it after Begin, 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

📥 Commits

Reviewing files that changed from the base of the PR and between af718c7 and 70b7455.

📒 Files selected for processing (2)
  • crates/ripr/src/lsp/backend.rs
  • crates/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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slice(#1909): emit standard LSP work-done progress for analysis lifecycle

1 participant