Replace the Rust LSP stub with a pure OCaml server#8
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The LSP binary was bootstrapped as a Rust wrapper that would link the OCaml library via FFI and depend on httui-core for storage. Measurements showed the FFI premise does not hold: a persistent stdio subprocess round-trips in well under 0.1 ms, and the server only ever needs read-only SQLite access (never the OS keychain — secret values stay on the execution path). Going pure OCaml removes the FFI toolchain entirely (vendoring, macOS rustflags, runtime lifecycle, cross-runtime panics) and keeps this repository single-language.
Changes
bin/httui-lspis now an OCaml executable using thelsp/jsonrpcpackages: stdio framing, initialize with server info and full-sync capabilities, didOpen/didChange/didClose document store, correct MethodNotFound for unimplemented requests, spec-conformant shutdown/exit.ocamlformatconfig pinned at 0.28.1.bench/lsp_roundtrip.py+make bench: dependency-free transport benchmark against the built binary (spawn-to-initialize, request dispatch round-trip, didChange ingestion).httui_lang.opamcommitted soopam install . --deps-onlyworks in CI.spec/token-kinds.md: fallback is now described as a server-side capability downgrade (clients silently ignore unknown token types, so the server must emit the fallback kind for clients without support); added the rule that thesecretmodifier implies value masking on every surface.Validation
dune build,dune runtest,dune build @fmtgreen. Lifecycle smoke-tested over real JSON-RPC (initialize → didOpen → unknown request → shutdown → exit 0). Bench: dispatch round-trip p95 0.024 ms, didChange+probe p95 0.036 ms on Apple M4.