Skip to content

feat(lsp): reload repository configuration safely - #1659

Merged
EffortlessSteven merged 6 commits into
mainfrom
lsp/1598-config-reload
Jul 14, 2026
Merged

EffortlessSteven merged 6 commits into
mainfrom
lsp/1598-config-reload

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements the configuration and session-option reload slice for #1598, building on the landed LspAnalysisInputIdentity model from #1642.

What changed

  • Reloads ripr.toml through workspace/didChangeWatchedFiles and coalesces the resulting refresh through the existing scheduler.
  • Preserves repository-default then documented session-override precedence across repository reloads.
  • Includes repository config content and supported session options in refresh input identity, using deterministic effective-field hashing.
  • Treats malformed configuration as typed config_invalid health, pauses analysis, and preserves last-known-good evidence without pretending defaults were accepted.
  • Makes the explicit refresh command a real config-recovery route when a watch notification was missed.
  • Clears obsolete configuration failure state across root transitions.
  • Registers the config watcher only for clients that advertise dynamic registration; the VS Code client also watches ripr.toml and synchronizes the ripr settings section.
  • Adds the config_reload refresh reason and focused precedence, identity, and recovery regressions.

Scope and non-goals

This is PR-B of #1598. Manifest/lockfile relevance and broader snapshot-handle identity remain for follow-up input slices. It does not add pull diagnostics or public headless-agent protocol surface.

Proof

Pass:

  • cargo fmt --check
  • cargo check -p ripr --lib
  • cargo clippy -p ripr --lib -- -D warnings
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test -p ripr --lib lsp:: -- --test-threads=1 — 301 passed
  • cargo test --workspace — 4,537 passed, 1 ignored before the final review-only correction; the final head has focused LSP proof and protected CI reruns
  • cargo xtask check-output-contracts
  • cargo xtask check-traceability
  • cargo xtask check-generated-clean
  • git diff --check

Not run locally:

  • VS Code TypeScript compile/test: this isolated worktree has no editors/vscode/node_modules; the compile reached the Rust bridge and stopped at the missing tsc.cmd path.
  • cargo xtask check-pr: the five-minute wrapper timed out during its workspace-test phase; the underlying workspace test and workspace Clippy passed directly.

Claim boundary

This PR makes selected-root repository configuration and supported session options reloadable with honest invalidation and recovery state. It does not claim completion of the full #1598 input matrix.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Repository configuration changes are now detected and reloaded automatically.
    • Added support for dynamic file watching when available.
    • Session configuration updates now preserve initialization settings.
  • Bug Fixes

    • Configuration errors are clearly reported and pause analysis until resolved.
    • Diagnostic refreshes no longer run against invalid configuration.
    • Workspace and repository changes now correctly reset configuration health.
  • Tests

    • Added coverage for configuration failures, reload behavior, and file watching.

Walkthrough

The LSP preserves session configuration overrides, fingerprints repository configuration in refresh identities, tracks configuration failures, reloads ripr.toml on relevant events, and conditionally registers dynamic file watching. VS Code synchronizes both Cargo.toml and ripr.toml.

Changes

LSP configuration refresh

Layer / File(s) Summary
Session configuration model
crates/ripr/src/lsp/config.rs
Supported session options are preserved, merged on updates, reapplied during repository reloads, and covered by tests.
Refresh identity and telemetry
crates/ripr/src/lsp/input_identity.rs, crates/ripr/src/lsp/refresh_scheduler.rs
Refresh identities include session options and repository config source text; configuration reload requests receive a dedicated reason and counter.
Backend failure and reload state
crates/ripr/src/lsp/backend.rs
Configuration failures are latched, diagnostics are paused during failure, and repository reloads clear or set the failure state.
Backend event wiring and client synchronization
crates/ripr/src/lsp/backend.rs, crates/ripr/src/lsp/tests.rs, editors/vscode/src/client.ts, editors/vscode/test/suite/extension.test.ts
Dynamic ripr.toml watching, configuration/workspace reload triggers, retry behavior, initialization assertions, and VS Code synchronization are updated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VSCode
  participant Backend
  participant RepositoryConfig
  participant RefreshScheduler
  VSCode->>Backend: initialize
  Backend->>RepositoryConfig: load ripr.toml
  Backend->>Backend: publish configuration failure or analysis status
  VSCode->>Backend: didChangeWatchedFiles
  Backend->>RepositoryConfig: reload repository config
  Backend->>RefreshScheduler: request ConfigReload
  RefreshScheduler-->>Backend: schedule diagnostics refresh
Loading

Possibly related PRs

Poem

A bunny found a config in the hay,
And watched ripr.toml change all day.
“If settings fail, pause and retry—
Then refresh diagnostics by and by!”
Hop, hop, the LSP knows the way.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, scope, proof, and claim boundary, but omits many required template sections and checklist items. Add the missing template sections: Swarm/Source Boundary, source links, scope classification, support/policy impacts, rollback, traceability, and checklists.
Docstring Coverage ⚠️ Warning Docstring coverage is 29.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: safer LSP repository configuration reloads.
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 lsp/1598-config-reload

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 implements dynamic configuration reloading and session option management in the LSP backend, allowing the server to watch for changes in ripr.toml and apply session configuration updates dynamically. Feedback on these changes highlights a potential issue where stale configuration failures may persist across workspace root changes, a recommendation to use more idiomatic Rust when cloning options from a mutex guard, and a warning regarding non-deterministic JSON serialization of session options which could trigger redundant workspace refreshes.

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

codecov Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.62924% with 101 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/lsp/backend.rs 45.40% 95 Missing ⚠️
crates/ripr/src/lsp/config.rs 96.52% 5 Missing ⚠️
crates/ripr/src/lsp/refresh_scheduler.rs 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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: 538568c7fe

ℹ️ 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

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

Actionable comments posted: 2

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

Inline comments:
In `@crates/ripr/src/lsp/backend.rs`:
- Around line 997-1015: Update apply_session_configuration_change to account for
an existing configuration_failure before invalidating analysis input. Preserve
the latched config_invalid health signal when configuration is gated, and skip
the invalidate/publish/refresh path that cannot rerun diagnostics; retain the
current behavior for sessions without a configuration failure.

In `@editors/vscode/src/client.ts`:
- Around line 305-309: Update the existing watcher assertion in the extension
test around the single-Cargo-watcher expectation to recognize the combined
Cargo.toml/ripr.toml glob configured by the synchronize block in the client
initialization. Preserve the test’s validation of watcher registration while
adjusting its expected pattern/count to match the broadened watcher.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d58b263-7ad6-4b1c-aebb-a4d3ace0bf4f

📥 Commits

Reviewing files that changed from the base of the PR and between cbf6f62 and 9439fee.

📒 Files selected for processing (6)
  • crates/ripr/src/lsp/backend.rs
  • crates/ripr/src/lsp/config.rs
  • crates/ripr/src/lsp/input_identity.rs
  • crates/ripr/src/lsp/refresh_scheduler.rs
  • crates/ripr/src/lsp/tests.rs
  • editors/vscode/src/client.ts
🔗 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)

Comment thread crates/ripr/src/lsp/backend.rs Resolved
Comment thread editors/vscode/src/client.ts Resolved
…/1598-config-reload

# Conflicts:
#	crates/ripr/src/lsp/backend.rs
#	editors/vscode/test/suite/extension.test.ts

@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/backend.rs (1)

966-995: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Config-reload retry after failure never runs the Full scope the ripr.refreshDiagnostics command promises.

reload_repository_config always calls refresh_diagnostics(RefreshScope::Interactive, ...) on success. That's fine for the did_change_watched_files/did_change_workspace_folders triggers, but execute_command's ripr.refreshDiagnostics retry path (Lines 1682-1689) reloads config through this same function and then returns immediately — it never issues the RefreshScope::Full refresh that this command normally performs when configuration is healthy. Per the doc comment on refresh_diagnostics (Lines 110-125), Full is what runs the complete seam inventory; Interactive only produces a seams_deferred snapshot. So a user who explicitly retries after fixing ripr.toml silently gets a partial/deferred refresh instead of the full one the same command delivers in the non-failure case.

🐛 Proposed fix — let callers choose the refresh scope
-    async fn reload_repository_config(&self) {
+    async fn reload_repository_config(&self, scope: RefreshScope) {
         let Some(root) = self.effective_root() else {
             return;
         };
         let current = self.analysis_config().unwrap_or_default();
         let had_configuration_failure = self.configuration_failure().is_some();
         match crate::config::load_for_root(&root) {
             Ok(repo_config) => {
                 let next = current.reload_repo_config(repo_config);
                 self.clear_configuration_failure();
                 if next != current || had_configuration_failure {
                     self.set_analysis_config(next);
                     self.invalidate_analysis_input(RefreshReason::ConfigReload.as_str());
                     self.publish_analysis_status().await;
-                    self.refresh_diagnostics(
-                        RefreshScope::Interactive,
-                        RefreshReason::ConfigReload,
-                    )
-                    .await;
+                    self.refresh_diagnostics(scope, RefreshReason::ConfigReload)
+                        .await;
                 } else {
                     self.publish_analysis_status().await;
                 }
             }
             Err(error) => {
                 self.invalidate_analysis_input(RefreshReason::ConfigReload.as_str());
                 self.set_configuration_failure(error);
                 self.publish_analysis_status().await;
             }
         }
     }

Then update call sites: did_change_watched_files/did_change_workspace_folders pass RefreshScope::Interactive, and the ripr.refreshDiagnostics retry branch (Line 1687) passes RefreshScope::Full.

🤖 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/backend.rs` around lines 966 - 995, Update
reload_repository_config to accept a RefreshScope parameter and use it when
calling refresh_diagnostics after a successful reload. Pass
RefreshScope::Interactive from did_change_watched_files and
did_change_workspace_folders, while the ripr.refreshDiagnostics retry branch in
execute_command must pass RefreshScope::Full so configuration recovery performs
the complete refresh.
🤖 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/backend.rs`:
- Around line 966-995: Update reload_repository_config to accept a RefreshScope
parameter and use it when calling refresh_diagnostics after a successful reload.
Pass RefreshScope::Interactive from did_change_watched_files and
did_change_workspace_folders, while the ripr.refreshDiagnostics retry branch in
execute_command must pass RefreshScope::Full so configuration recovery performs
the complete refresh.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d45c1f08-0c09-4809-89b2-a517acdad1f4

📥 Commits

Reviewing files that changed from the base of the PR and between 9439fee and 3c47a25.

📒 Files selected for processing (3)
  • crates/ripr/src/lsp/backend.rs
  • crates/ripr/src/lsp/tests.rs
  • editors/vscode/test/suite/extension.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • EffortlessMetrics/ripr (auto-detected)
  • EffortlessMetrics/unsafe-review (auto-detected)
  • EffortlessMetrics/ub-review (auto-detected)
  • EffortlessMetrics/perl-lsp (auto-detected)

@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 (2)
crates/ripr/src/lsp/config.rs (2)

53-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate diagnosticProfile application.

apply_session_options (lines 186-192) already parses and applies diagnosticProfile onto config. from_repo_config_and_options then repeats the exact same parse-and-assign logic immediately afterward (lines 67-73). This is dead, redundant work — harmless today since both blocks compute the same result, but it's an easy source of future divergence if one copy is updated and the other isn't.

♻️ Proposed fix — remove the duplicate block
         config.session_options = Some(Value::Object(options.clone()));
         apply_session_options(&mut config, &options);
-        if let Some(profile) = options
-            .get("diagnosticProfile")
-            .and_then(|value| value.as_str())
-            .and_then(|value| LspDiagnosticProfile::parse(value).ok())
-        {
-            config.diagnostic_profile = profile;
-        }
         config
     }

Also applies to: 186-192

🤖 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/config.rs` around lines 53 - 75, Remove the duplicate
diagnosticProfile parsing and assignment block from
from_repo_config_and_options, relying on apply_session_options to apply it.
Preserve the existing session-options filtering, storage, and application flow
without changing apply_session_options.

16-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stale doc comment: "four supported LSP options" is now five.

The session_options field doc says this is a projection of "the four supported LSP options, not an authority for arbitrary client settings." is_supported_session_option now lists five keys (baseRef, checkMode, includeUnchangedTests, seamDiagnostics, diagnosticProfile) after diagnosticProfile was added. Update the comment to avoid confusing future readers about the supported-option contract.

♻️ Proposed fix
-    /// Session overrides are retained so a repository configuration reload
-    /// preserves the initialization precedence contract. This is a bounded
-    /// projection of the four supported LSP options, not an authority for
-    /// arbitrary client settings.
+    /// Session overrides are retained so a repository configuration reload
+    /// preserves the initialization precedence contract. This is a bounded
+    /// projection of the five supported LSP options, not an authority for
+    /// arbitrary client settings.
     pub(super) session_options: Option<Value>,

Also applies to: 205-209

🤖 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/config.rs` around lines 16 - 20, Update the documentation
for the session_options field to state that it projects the five supported LSP
options, matching the keys recognized by is_supported_session_option, while
preserving the clarification that it is not an authority for arbitrary client
settings.
🤖 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/config.rs`:
- Around line 53-75: Remove the duplicate diagnosticProfile parsing and
assignment block from from_repo_config_and_options, relying on
apply_session_options to apply it. Preserve the existing session-options
filtering, storage, and application flow without changing apply_session_options.
- Around line 16-20: Update the documentation for the session_options field to
state that it projects the five supported LSP options, matching the keys
recognized by is_supported_session_option, while preserving the clarification
that it is not an authority for arbitrary client settings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b942f3f-6bf3-4eb4-9ff9-47ec288f28ae

📥 Commits

Reviewing files that changed from the base of the PR and between 3c47a25 and e1620ea.

📒 Files selected for processing (4)
  • crates/ripr/src/lsp/backend.rs
  • crates/ripr/src/lsp/config.rs
  • crates/ripr/src/lsp/tests.rs
  • editors/vscode/test/suite/extension.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • EffortlessMetrics/ripr (auto-detected)
  • EffortlessMetrics/unsafe-review (auto-detected)
  • EffortlessMetrics/ub-review (auto-detected)
  • EffortlessMetrics/perl-lsp (auto-detected)

This was referenced Jul 18, 2026
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.

1 participant