Skip to content

fix: bind broker requests and diagnostics to source snapshots - #254

Draft
ejgallego wants to merge 3 commits into
mainfrom
codex/fix-snapshot-identity
Draft

fix: bind broker requests and diagnostics to source snapshots#254
ejgallego wants to merge 3 commits into
mainfrom
codex/fix-snapshot-identity

Conversation

@ejgallego

@ejgallego ejgallego commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

This PR prevents stale requests and diagnostics from being accepted for replacement documents after refresh, close/reopen, backend restart, or workspace recreation. Public requests round-trip an opaque source snapshot token, and document requests and sync barriers reject results whose tracked source has changed.

  • Replace public numeric version arguments and result fields with opaque snapshot strings across the wrapper and MCP. Clients must pass the exact token returned by update or sync; numeric fields are removed.
  • Ignore diagnostic publications for other document revisions and preserve the snapshot identity when deduplicating streamed diagnostics.
  • Share document and position inputs across operation adapters, and use the accepted document revision when dispatching native LSP requests.
  • After contentModified, require reading the current source and resolving the intended target again before retrying with a fresh token.

This PR prevents stale requests from succeeding against replacement documents after refresh, close/reopen, backend restart, or workspace recreation. Public requests now round-trip an opaque snapshot token from update or sync, and pending document results are rejected if their source snapshot has changed.

Replace numeric version arguments with snapshot strings across the wrapper, MCP, sync/save results, diagnostics, and open-file reporting. Allocate fresh internal document revisions within each backend session and keep completed request progress from overwriting a replacement document. Require reading the current source and resolving the intended target again before retrying contentModified failures.
Reject a completed sync barrier when its document was edited, closed, or reopened while the backend response was pending. Share the current-document check with probe completion so validation and state updates happen under the same lock.

Filter diagnostic publications by the tracked document revision and include snapshot identity in stream deduplication. Cover stale completions and diagnostic observations with deterministic fixtures, and make the macOS fixture path and foreground startup checks respect their actual boundaries.
Consolidate document and position records, parsing, and broker conversion while preserving the flat wrapper and MCP interfaces. Remove unused default values and redundant token checks, and keep native request revisions tied to the accepted document.

Clarify source tokens versus elaboration snapshots, link the canonical recovery contract, and replace shell token placeholders with explicit extraction and quoted variables.
@ejgallego ejgallego changed the title fix: bind broker requests to lifecycle-safe source snapshots fix: bind broker requests and diagnostics to source snapshots Sep 8, 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