Repository navigation
Conversation
…g them A write evaluates no reasoning: an update's where runs through the plain WHERE executor and matches stored facts only. An update that carried "reasoning": "datalog", at the top level or in opts, was accepted and the key ignored, so a where naming a fact only a rule derives matched nothing and the write committed. That reads exactly like "the rules derived nothing". The JSON-LD transaction parser now refuses, with a 400 that says a write does not evaluate reasoning, every reasoning key a query reads (reasoning, rules, ontology, reasoningBudget, reasoningTime): in opts on every write (update, insert, upsert, graph insert, graph sync), and at the top level of an update, whose top-level keys are the request's own. An insert's top-level keys stay data. "reasoning": "none", which asks for what a write does anyway, is accepted. The check sits in the parser every transport shares (HTTP routes, the Rust API, the CLI, the Python binding), beside the existing opts.unionDefaultGraph refusal, and reads the key list from the query parser's REASONING_KEYS, now public, so a key the query side gains is refused on a write too. SPARQL UPDATE already refused the reasoning pragmas; their message now says the same thing as the JSON-LD one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018gr44QJuUPpGdwWfXE9Bz9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018gr44QJuUPpGdwWfXE9Bz9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018gr44QJuUPpGdwWfXE9Bz9
bplatz
left a comment
There was a problem hiding this comment.
Approving. Please review the inline comments before merging.
| let Some(value) = keys.get(key) else { | ||
| continue; | ||
| }; | ||
| if key == "reasoning" && disables_reasoning(value) { |
There was a problem hiding this comment.
On the open question: refuse every reasoning key whatever its value, none included. That matches the SPARQL pragma and opts.unionDefaultGraph (refused even as false), and drops disables_reasoning and the null / ["none"] cases. If writes ever evaluate reasoning, accepting none then is non-breaking, where refusing it later would not be. The docs line in update-where-delete-insert.md and the none legs of the API and server tests change with it.
| /// top-level keys are the request's own; an insert's or upsert's top-level | ||
| /// keys are its data. `"reasoning": "none"`, which asks for what a write | ||
| /// does anyway, is accepted. | ||
| fn refuse_query_only_opts(json: &Value, txn_type: TxnType) -> Result<()> { |
There was a problem hiding this comment.
Optional: parse_graph_insert returns before parse_rooted for an empty document (
db/fluree-db-transact/src/parse/jsonld.rs
Line 381 in 318374b
{"opts": {"reasoning": "datalog"}, "@graph": []} still accepts the key and ignores it, and opts.unionDefaultGraph too. Calling refuse_query_only_opts(json, TxnType::Insert) before that early return, plus an empty-@graph leg in writes_refuse_reasoning_keys, closes it.
Problem
A write evaluates no reasoning: an update's
whereruns through the plain WHERE executor, which takes no reasoning configuration, so it matches stored facts only. But an update that carried"reasoning": "datalog"(top level or inopts) was accepted and the key ignored. An update whosewherenames a fact only a rule derives matched nothing and committed, and the CLI printedCommitted t=3, 0 flakes, which reads exactly like "the rules derived nothing".What changed
The reasoning keys a query reads are now refused on a write with a
400whose message says a write does not evaluate reasoning:parse_rootedinfluree-db-transact/src/parse/jsonld.rs), the one funnel every transport goes through: HTTP/update,/insert,/upsert,/sync, the Rust API (Fluree::update/insert/upsert, thegraph(..).transact()andstage_ownedbuilders, the tracked/policy path the server uses), the CLI (local, and remote through the HTTP routes) and the Python binding (which calls the same builders). It extends the existingopts.unionDefaultGraphrefusal there.reasoning,rules,ontology,reasoningBudget,reasoningTime. The list is now the query parser's ownREASONING_KEYS(madepub), so a reasoning key a query gains is refused on a write without a second edit.optson every write, and at the top level of an update, whose top-level keys are the request's own. An insert's or upsert's top-level keys are its data (or, in envelope form, txn-meta), so a node property namedreasoningstays a property; a test pins that.reasoning*pragma on an update (applies to queries, not updates), so nothing reached the lowering. The message for those pragmas now also says a write does not evaluate reasoning, matching the JSON-LD one.docs/transactions/update-where-delete-insert.md.The error is a
TransactError::Parse, which the API maps to400(ApiError::Transact(_) => 400); the SPARQL refusal was already a400.Value policy
A reasoning key is refused whenever it is present, unless it is
reasoningand its value explicitly turns reasoning off: the single mode"none"(case-insensitive, as a query reads it), which asks for exactly what a write does. Everything else is refused, including values a query reads as no request at all (null) or as no mode (["none"]), and"none"does not excuse another reasoning key beside it.Open for review: the SPARQL surface refuses
# PRAGMA reasoning: noneon an update (every query-only pragma is refused there whatever its value, asopts.unionDefaultGraphis in JSON-LD), so the two surfaces differ onnonealone. Either JSON-LD can refusenonetoo, or the pragma can accept it; this PR leaves the pragma as it was.Tests
fluree-db-transact(parse::jsonld::tests):writes_refuse_reasoning_keys: each key × top level of an update,optson an update, insert, upsert (single node and envelope), graph insert and graph sync. The sample table must list every key ofREASONING_KEYS.writes_accept_only_reasoning_none:"none"/"NONE"accepted in both placements;null,["none"],"rdfs", a list, an unknown mode and a boolean refused;nonebesiderulesrefused.an_insert_property_named_reasoning_is_data.fluree-db-sparql:test_reasoning_pragmas_refused_on_update, everyreasoning*pragma (andreasoning: none) on an update, with the new message. Twin of the JSON-LD tests.fluree-db-api(grp_reasoning,it_datalog_rules_sparql::writes_refuse_reasoning): the issue's repro. A stored SPARQL rule derivesex:SparqlCandidate; a query under reasoning reads both candidates; the update withreasoningat the top level, inopts, and withrules, an insert withopts.reasoning, and a SPARQL update with the pragma each fail withstatus_code() == 400and the message; the ledger'stis unchanged; an update with"reasoning": "none"commits.fluree-db-server(grp_query,sparql_pragmas::writes_refuse_reasoning):400with the message on/update(SPARQL pragma, JSON-LD top level, JSON-LDopts),/insertand/upsert(opts);"reasoning": "none"on/updateis a200.Non-vacuity, run on the committed fix with the fix reverted in place and then restored:
writes_refuse_reasoning_keysandwrites_accept_only_reasoning_nonefail; the API test fails at its first write, which commits (flake_count: 0, the issue's symptom); the server test fails with a200committing the top-level-reasoningupdate.an_insert_property_named_reasoning_is_datapasses either way, as a boundary test should.test_reasoning_pragmas_refused_on_updatefails, and the server test fails on the SPARQL leg (400, but without the new message).The issue's repro on a CLI built from this branch (local ledger): the update with
reasoningat the top level and inoptsnow printserror: Transaction error: Parse error: `reasoning` applies to queries, not updates: a write does not evaluate reasoning, so an update's where clause matches stored facts only(exit 1) instead ofCommitted …, 0 flakes; the SPARQL update with the pragma prints the matching SPARQL message (run with--format sparql: the CLI's format detection does not look past a leading#line, which this PR leaves as it is); the update with"reasoning": "none"over stored facts commits.Breaking changes
A write that carried a reasoning key (
reasoningother than"none",rules,ontology,reasoningBudgetorreasoningTime) inopts, or at the top level of an update, used to succeed with the key ignored; it now fails with a400. Such a write never evaluated reasoning, so removing the key reproduces the old result exactly. A caller that wants the old behaviour removes the key (or sends"reasoning": "none").Partially addresses #2461. What remains is the design question in the issue: a supported way to commit what a rule run derives (reasoning in an update's
where, a rules materialization job, or a documented query-then-insert pattern).🤖 Generated with Claude Code
https://claude.ai/code/session_018gr44QJuUPpGdwWfXE9Bz9