Files
Language-Server/docs/roadmap/02-lsp-protocol-lifecycle.md
T
faumaray da8003f6d4 Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite:
protocol and document sync, VBS/compdb providers, stock GCC diagnostics
(including in-process default profile preparation), the stock occurrence
observer and hover/definition, the bounded Scheduler, C++ module graph,
scan and artifact cache with real CMI production, the context-aware
symbol index with schema-2 snapshot migration, navigation and guarded
rename, reflection provenance with splice-origin extraction, index-backed
completion and signature help, live GCC worker control with a registered
DAP suite, and the Neovim and VS Code clients.

VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced
from the versioned patches and verified stepping reflection/template code
with projected values 17/34 and 41/82.
2026-12-05 14:06:50 +03:00

33 lines
3.8 KiB
Markdown

# 02 — LSP framing, JSON envelope and lifecycle
Status: Lifecycle, checked serialization and synchronization are tested. The exact-number JSON gate passes on VoidLibrary main `9cb86f8f` after the StrictJson fix.
Requirements: R-002,R-003,R-004,R-005
Dependencies: 01, including the verified upstream JSON prerequisite.
## Ownership and boundaries
T-001 owns bootstrap protocol/source/tests. Later extraction into dedicated protocol directories requires a new exact ownership contract.
Future assignments must verify the then-current baseline and exact disjoint paths;
these proposed scopes do not authorize work in another repository.
## Contracts and data flow
LSP3.17 over stdio, UTF-8 JSON and byte-count Content-Length. Limits: header8192 bytes, body16777216 bytes, depth64. NEW frame reader and lifecycle processor are separately testable but main uses the same path. IDs are signed32-bit integers or strings; capability result is empty in milestone0.
## Implementation sequence
1. Read incremental headers/body with bounded allocation, support coalesced messages, reject missing/duplicate/overflow Content-Length and unsupported charset. Treat truncated/ambiguous framing as terminal rather than scan for a guessed next message.
2. Use upstream strict JSON plus required Unicode/protocol validation. Preserve string and signed32-bit ID values; accept finite integral values such as1.0 or1e0, rejecting fractional/out-of-range values before narrowing. Handle decimals in unknown/initialization fields. Invalid envelope/batch shapes receive InvalidRequest; malformed known-length JSON receives ParseError and permits the next frame. Ignore valid unmatched response envelopes, including null correlation IDs, without mutating lifecycle state; reject request/response hybrids.
3. Implement states before-initialize, initialized and shutdown. Pre-init requests receive ServerNotInitialized; repeated initialize is invalid; unknown initialized requests get MethodNotFound; unknown notifications produce no response.
4. Return serverInfo/version and capabilities:{}; shutdown returns null. Check shutdown-state errors before unknown-method handling. Exit0 follows shutdown, exit1 otherwise; broken writes/EOF cannot falsely report a completed exchange.
## Failure behavior and constraints
Keep diagnostics on stderr, even after malformed input. Avoid responses to notifications. Recover only when a valid frame length gives an unambiguous boundary. Allocation/stream errors terminate with a nonzero process status. Unsupported semantic methods remain unsupported rather than yielding empty fake results.
## Acceptance scenarios
1. Feed one byte at a time, split CRLF/body/UTF-8 sequences, concatenate frames and assert complete exact messages with no extra stdout.
2. Test lifecycle ordering, repeated initialize, pre-init/post-shutdown requests, unknown notifications, both exit statuses and premature EOF.
3. Exercise valid decimal/exponent options, integral-valued/fractional/out-of-range IDs, unmatched responses, escaped IDs/astral characters, raw controls, lone surrogates, invalid UTF-8, depth limits and length overflow; enforce subprocess deadlines. Current upstream uses double for decimal syntax and now exercises the numeric visitor; independent review must assess this actual representation before integration acceptance.
## Verification and integration
Run the documented configure/build/CTest commands from the repository README. Inspect ctest -N and test output for nonzero registration and real failures. Upstream main and local override use separate build trees.
Require fresh independent review of the implemented contract and affected integrations.
Keep the protocol library independent of future semantic services; added capabilities must be removable without changing lifecycle semantics. A failing JSON prerequisite blocks acceptance, not test execution.