Repository navigation
Structure: formatting and lint CI, document registry, shared-data revisions, cursor context - #39
Merged
Merged
Conversation
`imports_granularity` and `group_imports` need a nightly rustfmt, so on stable `cargo fmt` warned about them and could not reproduce the intended formatting. Keep `use_field_init_shorthand`, which is stable.
Formatting only, no code changes. Listed in .git-blame-ignore-revs.
Makes `cargo clippy --workspace --all-targets -- -D warnings` pass.
- Workspace lints (`[workspace.lints.clippy]`, inherited by every crate):
`type_complexity` and `too_many_arguments` are allowed, because Bevy
systems take their data as parameters and nested `Query` types.
- `cargo clippy --fix` for the mechanical lints (needless borrows, redundant
closures and returns, `'static` on constants, …).
- By hand:
- `Option::is_none_or` (Rust 1.82) replaced in components-rs, whose MSRV
is 1.75;
- `try_next` (deprecated) replaced by `try_recv` on the command and
diagnostic channels;
- `MyQuad::into_oxi(_graph)` return `Option` instead of `Result<_, ()>`;
- `PartialOrd` for `MyTerm` delegates to `Ord`;
- `assert!(false, …)` → `panic!` in the conformance tests;
- a few `sort_by_key`, `while let`, `is_err()` and merged `if` branches;
- `TestFs: Default`;
- kept the needed clone in the config loaders (clippy's suggestion does
not compile, the value moves into a spawned future);
- pinned a lifetime in `prefix_completion_helper` that the elided form
could not express.
- `wrong_self_convention` is allowed on the two public `into_triples` trait
methods rather than renaming them across crates.
New `lint` job: `cargo fmt --all --check` and `cargo clippy --workspace --all-targets -- -D warnings`. It runs next to the build and test job, so a lint failure does not hide test results.
Documents were found by scanning every `Label` (in `spawn_or_insert`, `spawn_background`, the document lifecycle, the JSON-LD loader and the test harness), while `Backend` kept its own URL → entity map, filled on `didOpen`. The two could disagree, and a request looked up its entity before running, so a document closed in between would make `entity_mut` panic. - `Documents`: a resource mapping URLs to entities, kept up to date by `Label`'s `on_insert` / `on_replace` hooks, so it is correct however a document is spawned, relabelled or despawned. `Label` is now an immutable component, so it cannot change without the hooks running. - `find_document(world, url)` is the one lookup, used everywhere a label scan was. Without the registry (a bare test world) it falls back to a scan. - `Backend` drops its map. Requests carry the URL, and `run_schedule` looks the document up inside the world, in the same step that runs the schedule. - The registry docs describe the kinds of documents: `Open`, `Background`, both, and cached (a background document in the ontology cache).
Shared data (the store, known ontologies, the class hierarchy, SHACL shapes, configured sources) usually arrives after the documents that use it were opened. Each consumer had its own trigger: `Changed<Triples>` on background documents, `Changed<ShaclShapes>`, `Added<ConfiguredOntology>`, running the save schedule after an import, or simply rerunning for every open document on every parse. `Revisions` (`core::revisions`) counts changes per kind of shared data. Producers bump a counter when their data changed; consumers keep a `Local<Seen>` and process every open document once after a bump, otherwise only documents whose own triples changed. - `load_store` → `store`; `derive_ontologies` recomputes on `store` and bumps `ontologies`; `extract_type_hierarchy` and `derive_ontologies` bump `hierarchy` when it grew; `derive_shapes` bumps `shapes` only when a document has or had actual shapes; configured ontologies bump `sources`. - `infer_types` now reruns when ontologies or the hierarchy change. Before, types inferred from property domains stayed wrong until the next edit when the ontology arrived after the document was opened. It is ordered after its producers, so the change is seen in the same pass. - `validate_namespace_properties` no longer reruns for every open document on every parse; it runs on edits, ontology changes and config changes. - `validate_shapes`, `derive_prefix_links` and `fetch_lov_properties` use the counters instead of their ad-hoc queries, and imports no longer run the save schedule to force revalidation.
…y rule Positions - The token at a cursor is resolved with cursor semantics (`token_at_cursor`): a cursor sits between characters, so it belongs to a word it is inside of, else a word ending at it (`ex:fo|;` is `ex:fo`), else punctuation it touches, else no token (whitespace). The triple lookup prefers a term containing the cursor, then one ending at it. - `Backend` no longer shifts positions one character left. The shift made completion at the end of a word work, but hovering the first character of a term resolved the term before it. The server and the test harness now handle positions identically; the harness docs say so. Completion context - `CursorContext`, resolved once per completion request (`get_cursor_context`): the role at the cursor, the subject being described, the typed word, where to insert, and whether a space is needed after `;` / `,` / `[`. Inside `[ … ]`, not on a term, the cursor is at a predicate position of that blank node. - Class, property, shape-template and shape-property completion use it, replacing the templates' private cursor helpers. Property completion inside a blank node now works, with domain-aware ordering for its type. Shape visibility - `shapes::visible`: one rule for which shape documents apply to a document (global, the document itself, or linked), used by validation, templates, hover and completion. - Shape documentation shortens IRIs with all shape documents' prefixes as one set, and `Prefixes::shorten` breaks ties between equally long namespaces by preferring a named prefix, then alphabetical order, so the result no longer depends on the order documents are visited.
`TypeHierarchy::iter_subclass` walked a class's *superclasses* and `iter_superclass` its *subclasses* (the `subclass` field held a class's parents). The outputs were labelled correctly, but only because every caller knew the names were swapped. - Fields `parents` / `children`; `iter_ancestors(_ids)` (the class and its superclasses) and `iter_descendants(_ids)` (the class and its subclasses), sharing one breadth-first `walk`. - The old names stay as deprecated aliases, since `swls-core` is published. - Callers and their variables are renamed to match (`refinements` in class completion, `ancestors` in property and JSON-LD completion), with comments on what each set is used for. Behaviour is unchanged; a unit test pins the direction of both walks.
Rust 1.100 (CI stable) reports `prelude::*` in the code action tests as unused: `use super::*` already brings the prelude in. Rust 1.97 did not flag it.
ajuvercr
force-pushed
the
claude/dreamy-mendel-uxxfa0
branch
from
November 18, 2026 09:46
eccfc17 to
cbe9b3a
Compare
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.
Structural improvements that make features like the SHACL templates and shape docs easier and safer to add. Every commit builds and passes the tests on its own.
Merging: please use Create a merge commit. The formatting-only commit is listed by hash in
.git-blame-ignore-revs. Squash and "Rebase and merge" both give commits new hashes, which would leave that entry pointing at nothing.Formatting and lints
rustfmt.tomlkeeps only stable options.imports_granularityandgroup_importsneed nightly, so on stablecargo fmtwarned and could not reproduce the intended formatting.style: cargo fmt --all), listed in.git-blame-ignore-revs.cargo clippy --workspace --all-targets -- -D warningspasses, checked with Rust 1.97 and with Rust 1.100 (CI's current stable):[workspace.lints.clippy]allowstype_complexityandtoo_many_arguments, because Bevy systems naturally have many parameters and nestedQuerytypes.cargo clippy --fixhandled the mechanical lints.is_none_or);try_next;into_oxireturningOptioninstead ofResult<_, ()>;PartialOrdforMyTerm;lintjob (cargo fmt --all --checkand clippy), next to build and test.Document registry
Documentsresource maps URL → entity. It is kept up to date byLabel'son_insert/on_replacehooks, so it stays correct however a document is spawned, relabelled or despawned.Labelis now immutable, so it cannot change without the hooks running.find_documentreplaces every label scan:spawn_or_insert;spawn_background;Backenddrops its own URL → entity map. Requests carry the URL, and the document is looked up inside the world in the same step that runs the request. Before, a document closed between lookup and request madeentity_mutpanic.Revisions for shared data
core::revisions::Revisionscounts changes to data shared between documents:Local<Seen>and process every open document once after a bump, otherwise only documents whose own triples changed.Changed<ShaclShapes>,Added<ConfiguredOntology>, running the save schedule after imports, and revalidating every open document on every parse.infer_typesnow reruns on ontology and hierarchy changes, ordered after its producers.Cursor semantics and completion context
token_at_cursortreats the cursor as sitting between characters. It belongs to a word it is inside of, else a word ending at it (ex:fo|;isex:fo), else punctuation it touches, else nothing (whitespace). The triple lookup uses the same rule.Backendno longer moves positions one character left. That shift made completion at the end of a word work, but hovering the first character of a term resolved the term before it. The server and the test harness now handle positions identically.CursorContext: resolved once per completion request. It holds the role at the cursor, the subject being described, the typed word, the insertion range, and whether a space is needed after;/,/[.[ … ], with the cursor not on a term, it is a predicate position of that blank node.Shapes
shapes::visibleholds the single rule for which shape documents apply to a document: global, the document itself, or linked. Validation, templates, hover and completion all use it.shapes::model. Validation keeps the rudof engine.Prefixes::shortenbreaks ties between equally long namespaces by preferring a named prefix, then alphabetical order. The result no longer depends on the order documents are visited.Naming
TypeHierarchy::iter_subclasswalked superclasses anditer_superclasswalked subclasses. They are nowiter_ancestors/iter_descendants, with the old names kept as deprecated aliases. Callers' variables are renamed to match. Behaviour is unchanged.Testing
cargo fmt --all --check, clippy with-D warnings, build, andcargo test --workspace(576 tests) all pass.Seen;e2e/tests/late_data.rs: types and closed-namespace warnings after a late ontology, and no revalidation of unrelated documents;e2e/tests/cursor.rs: a word before;, hover on the first character, completion inside a blank node.didClose;