Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

8.9 KB
Raw Blame

Upstream issues

Reproducible defects found in dependencies while working on this repository. Nothing here has been filed. Each entry is a minimal case, staged for a human to send.


1. Twelve XSD integer-derived datatypes, and xsd:dateTimeStamp, are not preserved

Status, 28 Oct 2026. 1a is fixed in the pinned fork and filed upstream as oxigraph/oxigraph#2010 (issue #1989): the store value-encodes a literal only when decoding gives it back as written, so these datatypes, and non-canonical lexical forms such as "4.0"^^xsd:decimal, now survive a load (here #335, tests/datatype_preservation_test.rs::the_store_keeps_every_declared_datatype). 1b is NOT fixed: measured on the new pin, DATATYPE() still answers xsd:integer for the twelve and xsd:dateTime for xsd:dateTimeStamp, and STR() of a known-datatype literal is still its canonical form, inside any query, whether the literal is stored or written in the query text. So the workaround below stays.

Two independent defects, in two crates. They were first reported here as one, blamed on storage. That was wrong, and the correction matters for anyone acting on it: fixing the storage encoder alone leaves DATATYPE() still returning the wrong IRI, because the expression evaluator collapses the same set again.

Repository: oxigraph/oxigraph · Version: 0.5.9 · Severity: high. The store returns a literal with a different datatype IRI from the one it was given. RDF 1.1 makes the datatype IRI part of a literal's identity, so this is a change to the data, not a representation detail.

Reproduction

@prefix ex:  <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:s ex:p "0"^^xsd:nonNegativeInteger .
SELECT (DATATYPE(?v) AS ?dt) WHERE { ?s ?p ?v }

Observed: xsd:integer. Expected: xsd:nonNegativeInteger, which is what rdflib returns for the same input.

Scope, measured

Affected, all collapsing to xsd:integer:

byte, short, int, long, unsignedByte, unsignedShort, unsignedInt, unsignedLong, positiveInteger, negativeInteger, nonPositiveInteger, nonNegativeInteger

xsd:dateTimeStamp collapses into xsd:dateTime the same way.

Not affected: integer, decimal, float, double, boolean, string, token, normalizedString, Name, NCName, language, anyURI, date, dateTime, gYear, duration, yearMonthDuration, dayTimeDuration.

1a. oxigraph storage: the datatype is dropped on insert

oxigraph 0.5.9, src/storage/numeric_encoder.rs. Twelve datatype IRIs share one match arm calling parse_integer_str, which yields EncodedTerm::IntegerLiteral: a single variant carrying no datatype IRI, so read-back can only reconstruct xsd:integer.

The parser is not at fault. Parsing the document above and inspecting the quad before insertion gives the correct datatype every time; the loss happens at storage encoding. Demonstrated by a load-then-serialise round trip, which does not involve the query evaluator at all: "0"^^xsd:nonNegativeInteger is written back out as bare 0.

1b. spareval evaluator: DATATYPE() collapses the same set again

spareval 0.2.6, src/dataset.rs maps the same twelve IRIs to ExpressionTerm::IntegerLiteral, and src/expression.rs answers DATATYPE() on that variant with xsd:integer.

This is independent of storage. A literal typed in the query text, never stored, loses its datatype just the same:

SELECT (DATATYPE("0"^^xsd:nonNegativeInteger) AS ?dt) WHERE { }

Observed xsd:integer; rdflib answers xsd:nonNegativeInteger. In the same query DATATYPE("abc"^^xsd:token) correctly answers xsd:token, so the behaviour is specific to this set and not a general canonicalisation policy.

SPARQL 1.1 defines DATATYPE as returning the datatype IRI of the literal, so this is a conformance defect and not only a fidelity one.

Why this reads as a defect rather than a deliberate simplification

xsd:yearMonthDuration and xsd:dayTimeDuration are derived types too, and they have their own encodings and survive intact. The treatment of derived types is inconsistent, and the inconsistency is not documented.

Consequences seen in practice

  1. A SHACL sh:datatype xsd:nonNegativeInteger constraint cannot be decided against the store: a conforming literal and a widened one are the same term by the time the query runs. Answering anyway reported a violation against every value that satisfied the shape, nine of them in one repository, which is how this was found.
  2. A load-then-serialise round trip rewrites the published file. "0"^^xsd:nonNegativeInteger comes back out as bare 0.

Suggested fix

Both layers need the datatype IRI carried alongside the numeric value.

Declining the native encoding and falling through to the generic typed-literal path fixes fidelity but costs numeric semantics: these types are in the SPARQL numeric hierarchy, so arithmetic and ordering over them must keep working. That makes the honest fix a datatype slot on the numeric variants of both EncodedTerm and ExpressionTerm, rather than a re-routing of the match arms.

Neither enum has such a slot today, so this is a coordinated change across the two crates, and it wants their conformance suites run against it. It is written up here rather than attempted blind.

Our workaround

datatype_is_indistinguishable_in_store in src/shacl.rs records a sh:datatype constraint (and, since the #333 follow-ups, an sh:or, sh:not, qualified or sh:node member) naming one of these as unevaluated rather than answering it wrongly. With 1a fixed it rests on 1b alone. tests/datatype_preservation_test.rs pins the exact set DATATYPE() misreports and fails in both directions, so the workaround is removed when 1b is fixed.


2. A request that arrives before initialize ends the server without a reply

Repository: modelcontextprotocol/rust-sdk (rmcp) · Versions: 1.4.0 and 1.8.0, both measured · Severity: high. A conformant-enough client that opens with any request other than initialize cannot use an rmcp server at all, and the failure carries no diagnostic to the client because nothing is written back.

Reproduction

Feed a server built with serve(stdio()) two lines, in this order:

{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{}}
{"jsonrpc":"2.0","id":2,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}

Observed: the process exits non-zero with ExpectedInitializeRequest and writes zero bytes to stdout. The client sees the stream close while it waits on its own initialize and reports EOF.

Reverse the two lines and everything works: the same server/discover is answered -32601 by the default on_custom_request and the handshake completes. Arrival order is the whole difference between a routine error reply and a dead process.

Where it happens

src/service/server.rs. The handshake loop reads messages itself until it sees initialize, answers a pre-initialize ping, and turns everything else away (1.4.0 at :191 and :200; 1.8.0 at :212 and :221). serve then returns the error and the caller's ? ends the process.

Measured on both versions in the local registry: unguarded, both reject the sequence above; wrapped in a transport that answers the early request, both complete the handshake. The version bump is not the fix it looks like.

Why we think this is a defect and not strictness

JSON-RPC 2.0 obliges a server to respond to every request carrying an id. Exiting without a reply is itself a protocol violation, so the current behaviour is the less conformant of the two available ones, not the stricter. MCP's lifecycle says a client SHOULD NOT send non-ping requests before the initialize response, and SHOULD NOT is not MUST NOT.

rmcp already reasons this way one screen further down: the comment at 1.4.0 src/service/server.rs:250-256 explains why a message arriving before the initialized notification is processed rather than rejected. The suggestion here is to apply that same rule one message earlier, replying with a JSON-RPC error instead of ending the connection.

It is not hypothetical

Reported against us in fabio-rovai/open-ontologies#260 by a user whose client opens with server/discover. The same reporter notes the current release of Goose triggers it as well, so this reaches an MCP client with a real user base and would affect every rmcp-based server equally.

Our workaround

src/mcp_handshake.rs wraps the stdio transport and answers a pre-initialize request with a JSON-RPC error, -32601 for an unknown method so the reply matches what the post-handshake path already returns and -32600 for a known MCP method sent out of order, then becomes transparent. A pre-initialize notification is dropped. tests/mcp_handshake_guard_test.rs pins it and fails in both directions. The wrapper is removed if upstream takes this.