HoldFastPlayground

HoldFast host language server prototype

Connect an editor

python tools/run.py holdfast-lsp starts an LSP 3.17-compatible stdio server for pure Nat and bool buffers. For mathematical source, choose one optional mode at startup. Use --proof-hover to inspect goals in a standalone unsaved buffer or --package-definition WORKSPACE LOCK to navigate a locked package. Pure compiler · Proof hover · Package navigation

Configure stdio with python (python3 on Linux), the absolute path to tools/run.py and holdfast-lsp. Register .hf as language holdfast in the editor without a dedicated extension. Pure diagnostics and navigation use buffers.

For Neovim 0.11, adapt the path in init.lua and reopen a .hf file. Neovim configuration API · Pinned editor qualification

Lua
vim.filetype.add({ extension = { hf = 'holdfast' } })
vim.lsp.config['holdfast'] = {
  cmd = { 'python', 'C:/src/HoldFast/tools/run.py', 'holdfast-lsp' },
  filetypes = { 'holdfast' },
  root_markers = { '.git' },
}
vim.lsp.enable('holdfast')

Before connecting, use the manifest's Python minor version and run python tools/run.py holdfast check examples/pure.hf from the repository root. This prepares the locked Python environment and exercises the checked parser that the editor needs. Native tooling setup · Checked parser support

In Neovim, K shows hover, grr finds references, gO lists symbols and :lua vim.lsp.buf.definition() jumps to a declaration. The default server navigates accepted pure source and reports diagnostics on incomplete or unsupported code. Clients can also request inferred local types, semantic tokens with delta updates, explicit formatting edits, callable or value completion and signature help. Selected unfinished expressions get bounded value proposals. Hints · Editor operations · Completion and signatures · Single-expression recovery

Interface and bounds

Support initialize/initialized, shutdown/exit, incremental document synchronization (open/change/save/close), push diagnostics and cancellation notifications over stdio. Advertise UTF-16 positions and incremental synchronization. Unknown requests return method-not-found; pre-initialization requests return server-not-initialized. Refuse repeated initialization and requests after shutdown. EOF or exit before shutdown is an unsuccessful session. Logs use stderr. Editor commands operate on open documents. The server exposes no client-selected file, process or network access.

Immutable snapshots bind URI, document version, source bytes and a monotonically increasing session generation. URIs are opaque identifiers, never authority to read disk. Diagnostics use the existing checker's one-based Unicode code-point coordinates after newline normalization, converted explicitly to zero-based UTF-16 positions. Shared source utilities also convert half-open UTF-8 byte offsets, rejecting offsets inside encoded characters or CRLF. Handle LF, CRLF, bare CR and supplementary characters. Full unsaved text replaces earlier text; ranged edits use zero-based UTF-16 positions in the preceding edit's result. Convert positions back to exact UTF-8 boundaries without normalizing stored text. Clamp character offsets beyond a line's end as LSP requires; refuse negative or non-integer coordinates, nonexistent lines, reversed ranges and positions inside a supplementary character. An optional deprecated rangeLength must match the removed UTF-16 units, counting CRLF as two units. Apply each notification's edits in order and publish only its final snapshot. Versions strictly increase, and an invalid edit anywhere in a notification leaves the previous snapshot and session generation unchanged. Remember a newer received version even when its replacement text is refused; an older later update cannot restore synchronization. Close clears diagnostics. Save rechecks the overlay. Configuration and watched-file changes invalidate and recheck all open snapshots conservatively. The optional proof hover profile adds display of standalone goals. The local rename preview and Boolean comparison action return edits for a specific document version. Navigation consumes the pure compiler's resolution facts.

Resource Bound and refusal
Frame headers 8,192 bytes; ASCII CRLF lines and exactly one decimal Content-Length; malformed/truncated frames close the session
Frame bodies and replies 1,048,576 bytes; strict UTF-8 JSON objects, unique keys and finite numbers; malformed JSON receives a parse error and valid non-message JSON an invalid-request error
JSON nesting 64 containers, counted outside strings before decoding; over-budget input closes the session
Documents 16 open documents, each at most the pure producer's 65,536 UTF-8 bytes; URI at most 4,096 UTF-8 bytes
Changes At most 64 sequential edits per notification; every intermediate text must fit the document bound; an empty batch advances a synchronized document's version without changing its text
Diagnostic output One producer error per document; message at most 4,096 characters; include version and snapshot identity, never an acceptance claim
Work and concurrency One synchronous check at a time, isolated worker timeout 5 seconds; no queued/background work or late publication

Unsupported language constructs receive the producer's explicit unsupported diagnostic. An empty diagnostic list can reflect a successful check, a close, or a refused update that cleared earlier diagnostics. Every reply, including initialization and errors, must fit the frame bound. An oversized initialization result returns RequestFailed without initializing the session. Error replies retain correlation when a bounded refusal can carry the request ID; if even the shortest correlated refusal cannot fit, return a bounded RequestFailed with null ID. Either refusal leaves the session usable for later bounded requests. Cancellation has no outstanding asynchronous work to cancel; it cannot undo a published notification. A worker timeout produces a diagnostic for that snapshot. Invalid document notifications clear diagnostics for the affected open document, are logged and leave overlays unchanged. Save and invalidation cannot republish diagnostics for a refused edit's old text; a valid full replacement or close/reopen restores synchronization. A ranged edit cannot use a desynchronized overlay; a change batch must begin with a full replacement before any subsequent ranged edits can restore synchronization.

Pure navigation increment

Navigation uses a complete pure check's declaration identities, types and occurrences. Hover labels plain-text signatures and types as prototype information. Definition selects the declaration identifier. References stay within the document and honor includeDeclaration. Symbols list functions, parameters, constants and locals in source order. Each binding has a distinct identity, even across sibling branches. Half-open identifier ranges exclude surrounding comments, punctuation and whitespace.

Requests require an initialized session and a synchronized open document. Malformed parameters and unopened documents return InvalidParams (-32602). A document out of synchronization returns ContentModified (-32801). Refused source yields null hover and definition results and empty reference and symbol lists. Worker and resource failures return RequestFailed (-32803).

The isolated inspection worker has five seconds and a 1,048,576-byte output limit. Its result binds source_sha256 to the input and supplies up to 1,024 declarations and 4,096 occurrences, with typed symbol records and one-based Unicode code-point locations. The server caches one successful inspection per open document, keyed by the snapshot, inspector and producer generation. Edits, saves, invalidation, close and shutdown discard the affected facts. Cache hits use in-memory results.

Hover includes directly attached /// documentation as plain text, up to 8,192 UTF-8 bytes. Inspection rejects missing or forged documentation and facts that belong to another source snapshot. Documentation comments

Authoring hints

textDocument/inlayHint shows : Nat or : bool at the end of an inferred local identifier wholly inside the requested range. The server takes the type from the compiler. Hints omit parameters, constants and explicitly typed bindings and carry no edits. Constants appear in the outline with symbol kind 14. The producer checks their static values before publishing facts. Hint fixtures · Wider editor contract

Pure editor operations

  • textDocument/formatting returns one full-document replacement if the compiler's canonical layout differs from the buffer. It can format complete pure syntax with semantic errors. Canonical, malformed or unsupported source yields an empty edit list. The server validates the client's formatting options and uses the compiler's layout. The formatter has a five-second worker budget. Worker or output-limit failures return RequestFailed.
  • textDocument/semanticTokens/full uses token types function, parameter and variable and modifiers declaration and readonly. Constants use variable with readonly. Tokens use relative UTF-16 coordinates and form an empty stream when checking fails with an ordinary source diagnostic. Range tokens are unavailable. Delta-capable clients receive a 64-character resultId and can ask for integer-interval edits against the last retained result for that document. An unrecognized or invalidated base yields a full stream. The server retains one complete, bounded stream per document and clears it on save, refusal, invalidation, close or shutdown. Editor fixtures

Callable discovery

Completion and signature help use the current validated inspection. When inspection is unavailable for the source, completion returns an empty incomplete list unless expression recovery can supply proposals, and signature help returns null. Worker failures return RequestFailed.

  • Callable completion matches the prefix through the cursor against the resolved function and compatible functions declared before it. A candidate must match the callable type, const qualifiers and parameter labels.
  • Value completion at a resolved use matches the prefix against same-type bindings visible at that site, including parameters, earlier locals and unshadowed constants. A required-static context limits candidates to static parameters and constants.
  • Literal completion replaces a complete Nat or bool literal with an eligible same-type value. A cursor from the start through the end of the token can request these proposals, including in a numeral with separators. The available values follow the same scope and static checks. Literal text supplies no prefix filter. Literal completion controls

A supported site returns isIncomplete: true and one explicit replacement edit per proposal. Completion kinds are 3 for functions, 6 for parameters and locals, and 21 for constants. Value and literal inventories share a limit of 4,096 sites and 8,192 choices. The server validates inventories before reuse.

Single-expression recovery completion

For source without a checked inspection, the recovery worker tries replacing one unfinished value identifier or inserting at an empty expression boundary. It tests 0 and false through the checked parser and resolver in the same five-second worker. When exactly one succeeds, the server offers the compatible visible values matching the existing prefix. The incomplete list contains explicit replacement edits for the original buffer. The worker checks valid token and UTF-8 boundaries, and its result leaves the buffer and diagnostics intact. Recovery controls

Signature help

Opening parentheses and commas trigger signature help. The server uses a bounded delimiter pass over concrete tokens to find the innermost checked call at the cursor. It shows the resolved signature, parameter names and const qualifiers, with plain-text documentation when available. The active parameter follows the argument position. Zero-argument calls omit activeParameter and a trailing comma selects the last parameter. Requests outside checked calls return null. Qualification uses stdio, Neovim and Vim. Wider requirements

Local rename previews

The server advertises textDocument/prepareRename and textDocument/rename only to clients that accept versioned workspace.workspaceEdit.documentChanges. The operations cover resolved local let bindings. Requests at an unsupported location return null. Invalid names return InvalidParams (-32602).

For a new spelling, the server applies the replacements to a candidate buffer and checks it in the isolated worker. It verifies declaration types and occurrence identities and positions, rejecting even a type-correct edit that captures a reference. The reply contains one versioned TextDocumentEdit for the client to apply. A request for the current name returns an empty edit list. The candidate leaves the live overlay and disk untouched.

Run python tools/run.py holdfast-lsp --qualify-rename --output rename.json on Ubuntu 26.04 ARM64 to exercise Neovim 0.11.0 and GNU Emacs 30.2 with Eglot on unsaved Unicode buffers. The qualification checks edit application, declaration lookup after renaming, stale-version refusal and preservation of parameter bindings and on-disk source. Vim checks refusal when the client cannot apply versioned document changes. Workspace-wide rename remains open. Pinned clients

Mathematical proof hover

Add --proof-hover to the server command to prepare the locked native parser and enable standard hover on named holes and assert keywords in standalone mathematical modules. The server sends the current open buffer to the bounded mathematical compiler worker. Hover reports the expected proposition and local context for an open goal, or the proposition and branch facts for a reconstructed assertion. Its range selects the hole or keyword in UTF-16 coordinates. Mathematical diagnostic rules

These observations describe elaboration of the current buffer. Batch proof acceptance requires separately replayed evidence. Worker timeouts or unavailable producers return RequestFailed. The profile uses the pure server's diagnostics and other editor features. Its stdio regression checks a changed unsaved goal, reconstruction after repair, Unicode coordinates, and null hover outside a goal. Proof hover controls

Run python tools/run.py holdfast-lsp --qualify-proof-hover --output FILE on Ubuntu 26.04 ARM64 or from Windows with that WSL guest. Pinned Neovim 0.11.0 and Emacs 30.2 with Eglot use their cursor-to-position conversions to request hover after a supplementary Unicode character. The qualifier replays each client's wire edits and checks the changed goal, repaired assertion, removed hole and weakened guard against the expected proof observations. It verifies that both editors preserve the on-disk file. The schema-1 report retains client identities, both wire transcripts and both editor observations. Proof-hover qualifier · Pinned clients

Locked mathematical package navigation

Run python3 tools/run.py holdfast-lsp --package-definition WORKSPACE LOCK in the native guest for textDocument/definition, textDocument/references and workspace/symbol in one configured mathematical package closure. The server uses the ordinary locked builder's navigation facts and returns file URIs with half-open UTF-16 ranges. Imported aliases and local declarations keep their compiler identities even when their names agree. Locked package build

References check complete authored value-name coverage in every module of the closure. This covers scalar expression-bodied definitions over Nat and bool, positional calls and member uses through explicitly aliased imports. The query accepts a declaration or resolved use, and includeDeclaration controls whether the result includes the declaration. Results are sorted by module name and source span. Incomplete coverage and results exceeding 256 locations return RequestFailed. Positions without an authored value binding in the covered fragment return an empty list. Module aliases and type names are outside the value-reference scope. Wider syntax can still supply definition locations. LSP contract

Workspace symbol search covers authored top-level functions, definitions, constants, theorems and lemmas in the checked closure. A query matches a case-insensitive name substring. The empty query lists all covered declarations. Results carry the declaring module name and sort by module and source span. Queries may run with no open document. An unconfigured server omits the workspace symbol capability. More than 256 matches return RequestFailed.

The worker has 15 seconds to check the lock, parser and package contents for each lookup. Every open member of the closure must match its locked bytes. A changed overlay, out-of-sync dependency, stale lock, failed build or worker timeout returns RequestFailed. An out-of-sync requested document returns ContentModified. Restore the overlay or save the changes and refresh the lock to resume navigation. Definition queries outside the configured closure and unresolved definition locations in a current closure return null. Reference queries outside the closure use the pure prototype. Stdio checks exercise dependencies, Unicode coordinates and line endings, same-named definitions, incomplete reference coverage and recovery after refreshing the lock. Workspace controls

Run python tools/run.py holdfast-lsp --qualify-package-definition --output FILE on Ubuntu 26.04 ARM64 or from its Windows host. Pinned Neovim and Emacs Eglot independently convert editor cursor positions and request the imported definition and its references. They also search for a name exported by two modules and check both declaration locations. Both clients receive the same UTF-16 ranges, see refusals after an unsaved edit and recover after restoring the source. The report binds the observations to both client identities, the advertised capabilities and each request and reply in its wire transcript. It checks that both locked files retain their original bytes. Controls refuse changed position encoding, an early overlay close, reused request IDs, an incorrect declaration toggle and incomplete or dirty reply data. Workspace qualifier

Acceptance and remaining qualification

Run python tools/run.py holdfast-lsp --qualify-clients to check the advertised pure editor features in Neovim 0.11.0 and Vim 9.1.2141 with the pinned yegappan/lsp plugin. The qualifier checks wire transcripts and editor state, including full and incremental change delivery. Use --output FILE to save its schema-2 report. Client qualifier · Behavioral controls · Wider requirements