Skip to content

Responsiveness: fewer completions, single parse, one diagnostics message per pass, shape cache (2/4) - #42

Merged
ajuvercr merged 4 commits into
mainfrom
claude/responsiveness
Nov 18, 2026
Merged

ajuvercr merged 4 commits into
mainfrom
claude/responsiveness

Conversation

@ajuvercr

@ajuvercr ajuvercr commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Second of four stacked PRs, based on #41. Merge #41 first; this PR's diff only shows its own commits.

Prefix suggestions

  • Before: a completion at an empty predicate position returned about 3,400 items, nearly all of them prefixes from prefix.cc. That was slow to send and buried the useful suggestions.
  • Declared prefixes are always suggested.
  • Undeclared prefixes (built-in vocabularies, then prefix.cc in popularity order) are only suggested once something was typed, and at most 30 (MAX_UNDECLARED_PREFIXES).
  • Removed the commented-out previous version of the helper.

One parse per new document

spawn_or_insert ran the parse schedule itself, and its callers (opening a document, loading a background document, configured shapes) ran it again right after. Every new document was therefore parsed twice. It no longer parses; the callers do, once everything is added. The built-in ontologies at startup and the test helper create_file relied on the implicit parse and now parse explicitly.

One diagnostics message per document per pass

The publisher sends a document's full, merged diagnostics once per reason (syntax, prefixes, namespaces, shapes), so one edit sent 8 publishDiagnostics messages for the document. The server now lets the pass finish (10 ms), drains what is queued and sends each document's latest set once (diagnostics::coalesce).

Shape index cache

Hover, completion and shape templates rebuilt the index of every visible shape triple on each request.

  • ShapeGraph now holds shared references (Arc) to the shape documents' triples and indexes positions instead of borrowing, so it can outlive a request.
  • ShapeCache (a Local of each system) reuses it while the visible documents and their triples are the same.
  • The cache is keyed by Arc identity: changed triples or another set of documents build a new graph.

Not included

  • Parsing large ontologies off the request thread at startup. The first request after loading many ontologies still waits for them. Doing this properly means moving parsing out of the ECS systems, which deserves its own design.

Testing

  • New tests:
    • e2e/tests/prefix_suggestions.rs: declared prefixes only for an empty word, at most 30 matching undeclared prefixes for a typed word, and a declared prefix suggested once;
    • over stdio, one edit publishes diagnostics once (8 times before);
    • unit tests for coalesce and the shape cache.
  • cargo test --workspace (593 tests), cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings (Rust 1.100) pass.

A completion at an empty predicate position returned about 3,400 items,
nearly all of them prefixes from prefix.cc. That was slow to send and
buried the useful suggestions.

Prefixes the document declares are always suggested. Undeclared prefixes
(built-in vocabularies, then prefix.cc in popularity order) are only
suggested once something was typed, and at most 30
(`MAX_UNDECLARED_PREFIXES`). Removes the commented-out previous version of
the helper.
`spawn_or_insert` ran the parse schedule itself, and its callers (opening a
document, loading a background document, configured shapes) ran it again
right after, so every new document was parsed twice. It no longer parses;
the callers do, once everything is added. The built-in ontologies at
startup and the test helper `create_file`, which relied on the implicit
parse, now parse explicitly.
The publisher sends a document's full, merged diagnostics on every publish,
once per reason (syntax, prefixes, namespaces, shapes), so one edit sent 8
`publishDiagnostics` messages for the document. The server now lets a pass
finish (10 ms), drains what is queued and sends each document's latest set
once (`diagnostics::coalesce`).

Tests: `coalesce` keeps the latest set per document, and over stdio one
edit now publishes once (it published 8 times before).
Hover, completion and shape templates rebuilt the index of every visible
shape triple on each request. `ShapeGraph` now holds shared references
(`Arc`) to the shape documents' triples and indexes positions instead of
borrowing, so it can outlive a request; `ShapeCache` (a `Local` of each
system) reuses it while the visible documents and their triples are the
same. Keyed by `Arc` identity: changed triples or another set of documents
build a new graph.
Base automatically changed from claude/reliability to main November 18, 2026 12:03
@ajuvercr
ajuvercr merged commit d0ad037 into main Nov 18, 2026
@ajuvercr
ajuvercr deleted the claude/responsiveness branch November 18, 2026 12:06
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.

2 participants