Skip to content

Correctness: workspace index, watched files, saved edits, settings changes (3/4) - #43

Merged
ajuvercr merged 2 commits into
mainfrom
claude/correctness
Nov 18, 2026
Merged

ajuvercr merged 2 commits into
mainfrom
claude/correctness

Conversation

@ajuvercr

@ajuvercr ajuvercr commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Third of four stacked PRs, based on #42 (which is based on #41). This PR's diff only shows its own commits.

Workspace index (core::workspace)

At startup, the RDF files of the workspace folders are loaded as background documents, so their classes, properties and shapes are known without opening them.

  • File types: .ttl, .nt, .owl, .trig and .n3.
  • Skipped:
    • what git ignores: .gitignore files at every level, .git/info/exclude, the global git excludes and .ignore files, also outside a git repository (via the ignore crate, the one ripgrep uses);
    • always: hidden folders, node_modules and target;
    • RDF/XML and HTML content.
  • Limits: at most 500 files per folder and 5 MB per file.
  • Workspace root: clients that only send a rootUri get it as their workspace.
  • Opt out: "disabled": ["workspace_index"].
  • API: FsTrait::walk and FsTrait::is_ignored provide the bounded, ignore-aware walk. File systems without one (e.g. wasm) find nothing.

Indexed shape files are known, but they do not apply to other documents automatically. As before, shapes apply when they are configured (shapes), imported (owl:imports), or in the same document.

Files changed on disk (workspace/didChangeWatchedFiles)

  • Watchers: the server registers a watcher for RDF files when the client supports dynamic registration.
  • Changed: a background document is reloaded from disk.
  • Deleted: the document is dropped, together with its triples and shapes.
  • Created: a new RDF file in the workspace is indexed, unless the same ignore rules skip it.
  • A file open in the editor keeps the editor's text.

Saved edits (textDocument/didSave)

  • Saving one of your own background documents (not a cache file) loads its triples into the shared store, so other documents see the saved classes and properties.
  • Closing it restores the saved version.
  • Unsaved edits still never reach the store.

Settings changes (workspace/didChangeConfiguration)

  • Format: the settings may be the settings object itself or { "swls": … }. They are applied like initializationOptions and combined with the config files.
  • New sources: newly configured ontologies and shapes are loaded through a new ConfigChanged schedule. Loading is idempotent, so an ontology is never added twice.
  • Re-check: open documents are checked again with the new settings.
  • Errors: invalid settings are reported, and the current ones are kept.
  • Limit: capabilities announced at initialize cannot change.

Testing

  • New stdio tests (real binary):
    • workspace files are indexed without opening them, skipping node_modules and hidden folders;
    • a git-ignored folder is not indexed at startup, nor is a file created in it later;
    • the server registers a file watcher;
    • changed, deleted and created files update completions;
    • a workspace file edited in the editor is not known until saved, and is known after saving;
    • a settings change (completion_class disabled) applies without a restart.
  • Unit tests: the walk and is_ignored agree on nested .gitignore files, a negated pattern, node_modules, hidden folders and .git/info/exclude.
  • cargo test --workspace (602 tests), cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings (Rust 1.100) pass.

Workspace index (`core::workspace`)
- At startup, the RDF files of the workspace folders (`.ttl`, `.nt`,
  `.owl`, `.trig`, `.n3`) are loaded as background documents, so their
  classes, properties and shapes are known without opening them. Hidden
  folders, `node_modules` and `target` are skipped; at most 500 files of
  at most 5 MB per folder; RDF/XML and HTML are skipped. Clients that send
  only a `rootUri` get it as their workspace. Disable with
  `"disabled": ["workspace_index"]`. `FsTrait::walk` provides the bounded
  walk (nothing for file systems without one).

Files changed on disk (`workspace/didChangeWatchedFiles`)
- The server registers a watcher for RDF files when the client supports
  dynamic registration.
- A changed background document is reloaded from disk, a deleted one is
  dropped (its triples and shapes too), and a new RDF file in the
  workspace is indexed. A file open in the editor keeps the editor's text.

Saved edits (`textDocument/didSave`)
- Saving one of the user's own background documents (not a cache file)
  loads its triples into the shared store, so other documents see the
  saved classes and properties; closing it restores the saved version.
  Unsaved edits still never reach the store.

Settings changes (`workspace/didChangeConfiguration`)
- The settings (either the settings object or `{ "swls": … }`) are applied
  like `initializationOptions`, combined with the config files. Newly
  configured ontologies and shapes are loaded (the new `ConfigChanged`
  schedule; loading is idempotent), and open documents are re-checked.
  Invalid settings are reported and the current ones kept.

Tests over stdio: workspace files are indexed (skipping `node_modules`
and hidden folders), watchers are registered, changed / deleted / created
files update completions, a saved workspace file makes its changes known,
and a settings change applies without a restart.
Base automatically changed from claude/responsiveness to main November 18, 2026 12:06
The workspace walk now uses the `ignore` crate (ripgrep's), so it skips
what git would ignore: `.gitignore` files at every level,
`.git/info/exclude`, the global git excludes and `.ignore` files, also
outside a git repository. Hidden entries, `node_modules` and `target` stay
skipped regardless.

Files created after startup follow the same rule: before indexing a new
file, `FsTrait::is_ignored` checks the ignore files between the workspace
folder and the file (`util::fs::is_ignored`; the global git excludes only
apply to the startup walk).

Tests: the walk and `is_ignored` agree on nested `.gitignore` files, a
negated pattern, `node_modules`, hidden folders and `.git/info/exclude`;
over stdio, an ignored folder is not indexed at startup, nor is a file
created in it later.
@ajuvercr
ajuvercr merged commit d72ae65 into main Nov 18, 2026
3 checks passed
@ajuvercr
ajuvercr deleted the claude/correctness branch November 18, 2026 13:15
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