Skip to content

Reliability: fetch timeouts, no panics on I/O, stdio integration tests (1/4) - #41

Merged
ajuvercr merged 5 commits into
mainfrom
claude/reliability
Nov 18, 2026
Merged

ajuvercr merged 5 commits into
mainfrom
claude/reliability

Conversation

@ajuvercr

@ajuvercr ajuvercr commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

First of four stacked PRs: reliability → responsiveness → correctness → features. Each later PR is based on the previous one's branch.

Fetching

  • Timeouts: one shared HTTP client with a 10 s connect and a 30 s request timeout, and a swls/<version> user agent. Before, every fetch built a new client without timeouts, so a host that never answered kept a load pending forever.
  • Unreadable bodies: a response body that cannot be read is an error, not a panic (resp.text().await.unwrap()).
  • file: URLs: they are read through to_file_path, which decodes percent-escapes. Url::path kept them, so a path with a space failed.

No more panics or hangs

  • Remaining unwraps: no panic when a built-in ontology has no cache location, when the world does not answer during initialize, or on an unbound SPARQL variable.
  • Panics in the world: a panic inside a system ended the task that owns the world. Bevy only re-inserts a schedule after it finishes, so the server kept accepting requests that were never answered. The world loop now catches the panic, reports it on stderr and exits, so the editor restarts the server and shows the error in its log. Panics in background fetch tasks are unaffected.

Integration tests over stdio

swls/tests/stdio.rs starts the real binary and talks JSON-RPC to it the way an editor does. That exercises Backend, positions, the file system and the cache, which the ECS-level harness bypasses. Each test uses private cache and config directories and only built-in ontologies, so no network is needed.

  • completion right after foaf:, hover on the first character of a term, and goto-definition into the read-only cached ontology;

  • didClose clears the document's diagnostics;

  • a request for an unknown document is answered, and the server keeps working afterwards;

  • required shape properties are suggested first, for a reported setup:

    • a mapping that imports its shapes with a relative owl:imports <./shape.ttl>;
    • a foaf:Person that already has foaf:name;
    • completion on the next line puts the missing foaf:name22 first, then the template, and does not promote foaf:name;
    • checked as Turtle and TriG, and at the end of an unfinished file.

    This test fails against the server from before Suggest predicates that shapes require first #40 and passes now.

Housekeeping

  • The redundant package.homepage fields are gone. Cargo 1.100 warns about them once per crate. components-rs keeps its own, different homepage.

Testing

  • cargo test --workspace (587 tests), cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings on Rust 1.100 pass.
  • New unit tests: a host that accepts but never answers times out, and a file: URL with an escaped space is read.

…rors

- One shared HTTP client for all fetches, with a 10 s connect and a 30 s
  request timeout. Before, every fetch built a new client without timeouts,
  so a host that never answered kept that load pending forever.
- A response whose body cannot be read is an error instead of a panic
  (`resp.text().await.unwrap()`).
- `file:` URLs are read through `to_file_path`, which decodes
  percent-escapes; `Url::path` kept them, so a path with a space failed.
- No panic when a built-in ontology has no cache location, when the world
  does not answer during `initialize`, or on an unbound SPARQL variable.

Tests: a host that accepts but never answers times out, and a `file:` URL
with an escaped space is read.
`swls/tests/stdio.rs` starts the real binary and talks JSON-RPC to it the
way an editor does, so `Backend`, positions, the file system and the cache
are exercised for real. The ECS-level harness bypasses all of that, which
is how earlier position and lifecycle bugs slipped through.

Each test uses private cache and config directories and only built-in
ontologies, so no network is needed:
- completion right after `foaf:`, hover on the first character of a term,
  and goto-definition into the read-only cached ontology;
- `didClose` clears the document's diagnostics;
- a request for an unknown document is answered, and the server keeps
  working afterwards.
A regression test for a reported setup: a mapping that imports its shapes
with a relative `owl:imports <./shape.ttl>`, a `foaf:Person` that already
has `foaf:name`, and completion on the empty line after it. The missing
required `foaf:name22` must be the first suggestion, followed by the
template that adds it, and `foaf:name` must not be promoted. Checked as
Turtle and TriG, and at the end of an unfinished file.

The test fails against the server from before "suggest predicates that
shapes require first" (the first suggestion is the `foaf` prefix) and
passes now.
A panic inside a system ended the task that owns the world, and Bevy only
re-inserts a schedule after it finishes, so the server kept accepting
requests that were never answered. The world loop now catches the panic,
reports it on stderr and exits, so the editor restarts the server and shows
the error in its log. Panics in background fetch tasks are unaffected.
Cargo 1.100 warns that `package.homepage` equal to `package.repository` is
redundant, once per crate. components-rs keeps its own, different homepage.
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