Skip to content

[Self-Hosting Phase 5] Port Language Server Protocol (LSP) Server to Flow #693

Closed

Description

@godofecht

Scope

Port JSON-RPC framing and protocol handling from src/flow/lsp_server.py to compiler/src/lsp_server.flow.

Deliverables

  • JSON-RPC 2.0 parser and serializer in Flow.
  • Stdio transport event loop.
  • Connect protocol handlers to existing compiler/src/lsp_intel.flow and compiler/src/lsp_syntax.flow.
  • Diagnostics publishing, definition lookup, completions, and symbol renaming.

Activity

  1. added
    self-hosting
    tooling
    P2-medium
    on Aug 21, 2026
  2. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP transport progress: valid string JSON-RPC IDs are now dispatched and echoed in response/error envelopes instead of being silently ignored. Added integration coverage for initialize with id="init"; both LSP lifecycle tests pass. bootstrap_from_c --verify and self_host_full (three generations) pass. Full document indexing/semantic analysis and broader JSON-RPC parity remain open.

  3. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP capability parity update: initialize now advertises the documentSymbol, references, formatting, and documentHighlight providers that the transport already handles. Integration assertions cover all four capabilities; both LSP tests pass. bootstrap_from_c --verify and self_host_full (three generations) pass. Semantic document indexing remains the next major gap.

  4. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP parsing progress: added flowc_lsp_json_nested_field for bounded access to nested payloads such as params.textDocument.text, preserving zero-copy spans and JSON kind/error semantics. Native protocol fixture and both LSP integration tests pass; bootstrap_from_c --verify and self_host_full (three generations) pass. This is the prerequisite for storing didOpen/didChange documents and returning real symbols.

  5. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native semantic tooling progress: added compiler/src/lsp_symbols.flow, an allocation-free scanner that enumerates top-level and exported function declarations with name spans, line numbers, and malformed-input errors. Added tests/lang/test_lsp_symbols_native.flow; Python host and regenerated Stage-A execution pass. bootstrap_from_c --verify and self_host_full (three generations) pass. Wiring this scanner to didOpen document state and documentSymbol JSON responses remains.

  6. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native document-symbol slice is now wired end to end: didOpen retains bounded document text with JSON escape decoding, and documentSymbol scans the stored source to return real LSP symbols with line/character ranges and selection ranges. Integration now verifies exported alpha and regular beta symbols; both LSP tests pass. bootstrap_from_c --verify and self_host_full (three generations) pass. didChange updates, URI-keyed multi-document state, and deeper semantic indexing remain.

  7. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP document-state progress: didChange now reads contentChanges[0].text, decodes JSON escapes, and replaces the bounded stored document. documentSymbol immediately reflects the updated source; integration verifies alpha/beta are replaced by gamma. Both LSP tests pass, along with bootstrap_from_c --verify and self_host_full (three generations). URI-keyed multi-document state and incremental range edits remain.

  8. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP lifecycle progress: didClose now clears the bounded stored document, preventing stale documentSymbol results after a client closes a document. Integration sends didOpen, didChange, didClose, then documentSymbol and verifies the final result is empty. Both LSP tests pass; bootstrap_from_c --verify and self_host_full (three generations) pass. URI-keyed multi-document state remains.

  9. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP URI groundwork: added flowc_lsp_document_uri to extract params.textDocument.uri as a bounded zero-copy JSON span for didOpen/didChange/didClose and request payloads. Native protocol test passes under Stage-A; bootstrap_from_c --verify and self_host_full (three generations) pass. The next step is replacing the single document buffer with URI-keyed slots.

  10. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    URI-state groundwork: added flowc_lsp_uri_equals, a bounded zero-copy comparison between a document URI JSON span and a stored URI buffer. Native protocol, bootstrap fixed-point, bootstrap_from_c verification, and self_host_full (three generations) pass. This is the key lookup primitive for the pending multi-document slot store.

  11. godofecht commented on Sep 17, 2026

    @godofecht
    ContributorAuthor

    Native LSP state progress: added compiler/src/lsp_store.flow with bounded two-slot URI-keyed document storage. Open/change/close operations preserve independent document text and reclaim only the matching slot; native regression covers two documents and mutation isolation. Stage-A native execution, LSP integration, bootstrap_from_c --verify, and self_host_full (three generations) pass. Wiring the store into lsp_server dispatch is next.

  12. godofecht commented on Sep 27, 2026

    @godofecht
    ContributorAuthor

    Status check from the host-tools retirement pass (checked against origin/main at 660ff30).

    There is no native LSP on main. compiler/src/lsp_server.flow and compiler/src/lsp_store.flow, described in the comments above, are not on origin/main or on any remote branch. What exists in Flow is the helper set: lsp_intel.flow, lsp_syntax.flow, lsp_dynamics.flow, lsp_ordering.flow, lsp_utils.flow. Every editor path still runs python3 -m flow.lsp_server (flow-lsp, the VS Code extension, and now ./flow lsp, which used to fall through to the help text).

    The blocker for replacing the Python server is diagnostics and symbol extraction, which come from the Python parser and type checker. Running the Stage-A driver over the corpus with FLOWC_TYPECHECK=0:

    Tree Files flowc parse failures
    examples/verify 1,054 1,054 (theorem syntax)
    rest of examples/ 433 109
    tests/lang 126 10
    lib/stdlib 112 1 (ui_layout.flow)
    total 1,725 1,174

    So a server that took diagnostics from flowc would report a syntax error on 68% of the repo's .flow files, most of them proof files. Type findings also differ: flowc requires extern for sqrt, printf and the other C functions the Python checker treats as built-ins, so the LSP harness's "clean" file (scripts/test_lsp_server.py) gets an unbound-call warning. Parse failures carry only a byte offset (flowc emit: at 62), with no message.

    Everything else the server does (hover, completion, definition, references, rename, symbols, highlight) is lexical or structural and could move to Flow now. Diagnostics and formatting need the full-language front end first.

  13. godofecht commented on Sep 30, 2026

    @godofecht
    ContributorAuthor

    Delivered on main (ee5048d) by #1016: tools/lsp is the JSON-RPC language server in Flow (diagnostics, hover, completion, definition, references, rename, symbols, formatting, highlight), and flow-lsp, ./flow lsp and the VS Code extension use it. The Python server is deleted.

    $ tests/tools/lsp/run.sh
    PASS lifecycle
    PASS references_rename
    PASS repo_files
    lsp transcripts: 9 passed, 0 failed
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumself-hostingtooling

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions