Skip to content

Enforce the LSP session lifecycle - #4944

Merged
Widthdom merged 4 commits into
mainfrom
fix-issue4849
Jul 28, 2026
Merged

Enforce the LSP session lifecycle#4944
Widthdom merged 4 commits into
mainfrom
fix-issue4849

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • enforce one thread-safe LSP lifecycle across normal dispatch, cancellation, and overload paths
  • reserve lifecycle decisions in receive order, synchronize initialize response publication, and reject out-of-phase requests with the required JSON-RPC errors
  • make shutdown wait for active dispatches and dispose owned query resources exactly once
  • add transcript, concurrency, overload, cancellation, and publication-race coverage

Root cause

Lifecycle booleans were updated only as handler side effects. The transport and alternate dispatch paths did not share a receive-ordered state machine, so queued or concurrent traffic could observe the wrong phase and shutdown did not provide one coordinated resource boundary.

Validation

  • dotnet restore CodeIndex.sln
  • dotnet build CodeIndex.sln -c Release --no-restore --nologo — 0 warnings, 0 errors
  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj -c Release --no-build --no-restore --filter "FullyQualifiedName~LspServerTests|FullyQualifiedName~LspServerBudgetTests" — 115 passed on net8.0 and 115 passed on net9.0
  • Issue Enforce the LSP initialize, shutdown, and exit lifecycle #4849 filter — 8 passed on each target framework
  • dotnet format CodeIndex.sln --verify-no-changes --no-restore
  • dotnet run --project tools/CodeIndex.Changelog -- check
  • full Release suite before the final targeted race fix: net9.0 passed 10,125 with 419 skipped; net8.0 passed 10,597 with 7 skipped and one unrelated MCP parallel-suite flake (ProcessFrameAsync_BatchInitializeDoesNotFlowBackIntoTimedOutPriorGeneration_Issue4540_Issue4545), which passed on immediate isolated rerun
  • Codex adversarial review: three first-round findings and one final publication-boundary finding were fixed and covered by regression tests

Documentation and changelog

Fixes #4849

@Widthdom
Widthdom marked this pull request as ready for review July 28, 2026 01:35
@Widthdom
Widthdom merged commit ffecbae into main Jul 28, 2026
12 checks passed
@Widthdom
Widthdom deleted the fix-issue4849 branch July 28, 2026 01:35
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.

Enforce the LSP initialize, shutdown, and exit lifecycle

1 participant