Skip to content

fix(lsp): refresh diagnostics when the gap ledger or checked-out branch changes (#4896) - #4904

Merged
EffortlessSteven merged 6 commits into
mainfrom
claude/project-thread-2rk3d2-lsp-watch
Oct 1, 2026
Merged

EffortlessSteven merged 6 commits into
mainfrom
claude/project-thread-2rk3d2-lsp-watch

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

  • Before: the root gap decision ledger can be rewritten by ripr check in a terminal, or .git/HEAD can move on git checkout, without touching an open buffer. In both cases ripr lsp kept publishing the old diagnostics until the next save.
  • After: the server watches exactly those two root paths and runs one watched_input refresh when either changes. That refresh resolves Git inputs fresh and skips input-identity dedup, because neither the ledger contents nor the branch is part of the identity.

When the client advertises relativePatternSupport, the watchers register as RelativePatterns anchored at the root URI. VS Code matches a bare string glob against the absolute path, so a bare .git/HEAD would never fire there. Nested ledgers and .git/HEAD files belong to other checkouts and are ignored.

Fixes #4896.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Governing issue or accepted claim: #4896
Acceptance delta (one sentence): a rewritten root gap ledger or a moved root .git/HEAD triggers exactly one diagnostics refresh that is not deduplicated away.

Candidate Relationships

Candidate branch: claude/project-thread-2rk3d2-lsp-watch
Stack parent or prerequisite PR: none. Related: #4709 made the LSP validate the ledger's source stamp; this PR makes it notice a new ledger.

Scope Classification

  • One production behavior

Production delta:

  • WorkspaceInputKind::DiagnosticsInput for the root ledger and the root .git/HEAD.
  • RefreshReason::WatchedInput (watched_input), which resolves fresh.
  • Root-anchored watcher registration.
  • Parsing of relativePatternSupport in the client profile.

Evidence/support delta: unit tests in backend.rs, client_features.rs, refresh_scheduler.rs and lsp/tests.rs.

Non-goals:

  • No change to the Python source watchers. They are still plain string globs and may never fire in VS Code for the same reason; that is left as a separate follow-up.
  • No watching of worktree .git files.

Support-tier Impact

  • none

Policy Impact

  • none

Proof

cargo test -p ripr --lib -- lsp::          # 784 passed
cargo clippy -p ripr --all-targets --locked -- -D warnings   # 0
cargo xtask precommit                      # 0

Negative experiment: with resolves_fresh narrowed back to ExplicitRefresh, watched_input_refresh_bypasses_dedup_of_an_unchanged_input_identity fails.

Claim Boundary

Claims that the refresh is triggered and not deduplicated. It makes no claim that every editor sends the watch events. Editors without dynamic watcher registration still refresh on save.

Rollback

Revert the commit. Diagnostics go back to refreshing on save and on explicit refresh only.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.

Gates

  • cargo xtask precommit

🤖 Generated with Claude Code

https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx


Generated by Claude Code

…ch changes (#4896)

Watch the root gap decision ledger and root .git/HEAD (root-anchored RelativePattern
when the client supports it) and schedule one watched_input refresh that bypasses
input-identity dedup, without reloading config or invalidating the workspace graph.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 29, 2026 09:19
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 3c4bb7b5-abaa-45e2-8b51-f4502f7fa0b3

📥 Commits

Reviewing files that changed from the base of the PR and between 944e147 and 9af7213.

📒 Files selected for processing (7)
  • .ripr/traceability.toml
  • CHANGELOG.md
  • crates/ripr/src/lsp/backend.rs
  • crates/ripr/src/lsp/client_features.rs
  • crates/ripr/src/lsp/refresh_scheduler.rs
  • crates/ripr/src/lsp/tests.rs
  • docs/specs/RIPR-SPEC-0143-lsp-client-feature-profile.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • New Features
    • LSP diagnostics now refresh when the workspace’s root gap-decision ledger or .git/HEAD changes. Watchers follow workspace-root changes and ignore nested copies.
    • Workspace status reports whether the client supports relative watched-file patterns.
  • Documentation
    • Updated the changelog and LSP client feature specification with watched-file behavior and test coverage.

Walkthrough

ripr lsp now watches the root gap-decision ledger and .git/HEAD for changes. It registers root-anchored watchers according to client capability, re-anchors them when the workspace root changes, and schedules fresh diagnostic refreshes for matching events.

Changes

Root-Scoped Diagnostic Refresh

Layer / File(s) Summary
Watcher capability and patterns
crates/ripr/src/lsp/client_features.rs, crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/tests.rs, docs/specs/RIPR-SPEC-0143-lsp-client-feature-profile.md
The feature profile captures relative-pattern support. Watchers use root-anchored relative patterns when supported, or absolute globs when the root allows them. Tests cover supported and fallback patterns, including metacharacter roots.
Root registration lifecycle
crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/tests.rs, CHANGELOG.md, .ripr/traceability.toml, docs/specs/RIPR-SPEC-0143-lsp-client-feature-profile.md
The backend arms watchers after initialization and synchronizes registrations with the effective root. Tests cover unregistering the old root and registering the new one.
Watched-input refresh handling
crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/refresh_scheduler.rs, crates/ripr/src/lsp/tests.rs
The backend classifies root ledger and .git/HEAD events as diagnostics-only inputs. Matching events schedule a WatchedInput refresh, which resolves Git inputs freshly and bypasses deduplication.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant LSPClient
  participant Backend
  participant RefreshScheduler
  Backend->>LSPClient: Register root diagnostic file watchers
  LSPClient->>Backend: Send watched-file event
  Backend->>RefreshScheduler: Schedule WatchedInput refresh
  RefreshScheduler->>RefreshScheduler: Resolve Git inputs freshly and bypass deduplication
Loading

Merge Risk: ⚪ Minimal · up to 9af72

The root-scoped watchers and fresh diagnostics flow are mergeable after normal checks. Registration failures retain manual refresh, and mixed file-change batches still refresh against current repository inputs.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9af72

Root-scoped refreshes preserve existing access boundaries and stale-result guards. No new privilege or cross-workspace access was identified. Remaining uncertainty concerns missed automatic updates and resource use during frequent notifications.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A connected client can forge a notification for an admitted diagnostic-input path and trigger fresh work for the effective workspace. The notification acts as a trigger rather than an arbitrary read-path or command selector; the inspected path does not expand refresh authority to another workspace.

Trust Boundaries and Controls

  • observed — Diagnostic-input admission combines effective-root containment with exact normalized file-URI matching. Existing paths use canonical containment to reject symlink escapes; missing paths use normalized lexical containment. Watcher registration rejects unsafe absolute globs rather than widening their match scope.

Resilience and Maintainability Implications

  • observed — Pending analysis work is bounded to one latest request. Completion, cancellation, and input invalidation clear episode state, while authority checks prevent obsolete requests from committing under another root. Each WatchedInput request still resolves Git inputs before coalescing, leaving burst-processing cost unestablished by queue bounds alone.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 3 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: refreshing LSP diagnostics when the gap ledger or checked-out branch changes.
Description check ✅ Passed The description is mostly complete and covers the change, scope boundary, source issue, acceptance criterion, non-goals, proof, claim boundary, rollback, and engineering checks. Some template sections…
Linked Issues check ✅ Passed The changes satisfy the coding requirements in [#4896]. The backend watches the root gap-decision ledger and root .git/HEAD. It classifies both paths as diagnostics inputs and schedules `WatchedInpu…
Out of Scope Changes check ✅ Passed The reviewed change summary shows changes connected to [#4896]: watcher registration, client capability parsing, refresh scheduling, root-transition handling, tests, specification updates, and changel…
Full details: Docstring Coverage

Explanation

Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 3 files. (4 skipped: 3 unsupported, 1 too large.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit; I watch the root,
The ledger changes, and off I scoot.
A branch tip shifts beneath the tree,
Fresh diagnostics come hopping to me.
New roots get watchers, neat and spry!

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

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exact-head review of 114ca6f. Disposition: no blocking findings; merge waits on required CI and bot reviews.

What I inspected (5 files):

  • workspace_input_kind: classifies only the exact root ledger and the root .git/HEAD as DiagnosticsInput. Nested and outside paths are rejected (tested).
  • did_change_watched_files: a graph change still wins, because its refresh re-reads both inputs. Otherwise it runs one WatchedInput refresh.
  • The scheduler: resolves_fresh covers explicit and watched-input refreshes.
    • Git inputs bypass the episode cache.
    • Dedup is skipped.
    • Negative experiment: narrowing the predicate fails watched_input_refresh_bypasses_dedup_of_an_unchanged_input_identity.
  • Watcher registration:
    • with relativePatternSupport: {baseUri, pattern};
    • without it: bare root-relative strings with no **.
    • The client-profile parse fails closed.
  • Feedback-loop check: the LSP reads the ledger (backend.rs receipt and gap artifact paths) and never writes it, so a refresh cannot trigger itself.

Local results after rebasing on main 3ebe6f3 (CHANGELOG conflict only):

  • lsp:: tests: 784 passed.
  • cargo clippy -p ripr --all-targets --locked -D warnings: 0.
  • cargo xtask precommit: 0.

External reviews are not in yet. CodeRabbit (rate-limited) and droid-review are recorded as missing, not clean.


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T09:23:52.895816Z 114ca6f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@EffortlessSteven EffortlessSteven added the full-ci Run required, advisory, and release-like CI lanes. label Sep 29, 2026 — with Claude

@devin-ai-integration devin-ai-integration 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.

Devin Review found 4 potential issues.

Devin Review

Comment thread crates/ripr/src/lsp/backend.rs Resolved
Comment thread crates/ripr/src/lsp/backend.rs Resolved
Comment thread crates/ripr/src/lsp/tests.rs Resolved
Comment thread crates/ripr/src/lsp/tests.rs Resolved

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 114ca6fe74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ripr/src/lsp/backend.rs Resolved
Comment thread crates/ripr/src/lsp/client_features.rs Resolved

Copy link
Copy Markdown
Member Author

The failing vscode check on 114ca6f is not this PR's. real server surfaces preview gap diagnostic, hover, status, and bounded actions times out in the same way on main since #4709 (push run 36543366218). The smoke writes an unstamped gap ledger, which the #4544 validator correctly withholds, and all 214 other VS Code tests pass here.

The fix is #4903 (issue #4902). I'll port its two test-only commits into this branch with the review fixes now in progress, so the next push runs the VS Code lane against the fixed smoke.


Generated by Claude Code

…4896)

Register the root gap ledger and root .git/HEAD watchers under their own
registration and resync it after every workspace-root transition, so a
root switch unregisters the old-root watchers and anchors new ones.
Without relativePatternSupport, register absolute string globs instead of
bare relative strings, skipping roots with glob metacharacters. Disclose
watched_files_relative_pattern_support in the client-feature status
projection and trace the new tests under RIPR-SPEC-0143.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
#4709 made ripr lsp withhold a gap ledger whose source_subject is missing
or stale. The smoke wrote an unstamped ledger and then edited pricing.ts,
so the preview diagnostic never appeared. Write the ledger after the save,
stamped with the digests of the files its record names.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
…#4902 review)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
…-2rk3d2-lsp-watch

# Conflicts:
#	CHANGELOG.md
@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.45324% with 46 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/lsp/backend.rs 83.63% 36 Missing ⚠️
crates/ripr/src/lsp/refresh_scheduler.rs 76.47% 8 Missing ⚠️
crates/ripr/src/lsp/client_features.rs 91.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@EffortlessSteven
EffortlessSteven merged commit a96d87e into main Oct 1, 2026
34 of 36 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-2rk3d2-lsp-watch branch October 1, 2026 11:06
EffortlessSteven added a commit that referenced this pull request Oct 1, 2026
Import union only: main's #4904 dynamic Unregistration import beside the
PR's PositionEncodingKind; no semantic overlap in the touched regions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run required, advisory, and release-like CI lanes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(lsp): a branch checkout or a regenerated gap ledger does not refresh editor diagnostics

2 participants