Repository navigation
Description
Behaviour
parse_reasoning (fluree-db-query/src/parse/options.rs) accepts the four reasoning keys — reasoning, rules, ontology, reasoningBudget — at the top level of a JSON-LD query, and since #1877 also inside opts as an alias.
The precedence between the two is all-or-nothing, not per key: if the top level carries any one of the four, it becomes the sole source and opts is not consulted at all.
That is fine when both places carry a mode. It is surprising when the top level carries only a modifier:
{
"select": ["?s"],
"where": {"@id": "?s", "ex:p": "?o"},
"reasoningBudget": {"maxFacts": 20000000},
"opts": {"reasoning": "datalog"}
}This runs with no reasoning at all. reasoningBudget enables no mode by itself — it exists so a ledger-config default mode runs under a cap — but it still wins the source election, and opts.reasoning is dropped in silence: no error, no warning, just an unreasoned result set.
Why this is worth an issue
It is the #1863 shape one level down. #1863 was "a silently ignored condition produces a plausible-looking wrong answer"; this is "a silently ignored mode produces a plausible-looking under-populated answer". Neither tells the caller anything.
The specific pairing is also the realistic one. A budget plus a mode is exactly what someone writes when they want reasoning and want to cap it, and "budget goes at the top level, mode goes in opts" is a natural-enough split for a user who has already guessed wrong once about where reasoning lives — which is the whole reason the alias exists.
Current state — deliberate, documented, pinned
Not an oversight. As of #1877:
- The rule is stated at the precedence site in
parse_reasoning, with this worked example, and says outright that it is the COUNT(*) over a novelty-only or overlay-only predicate returns 0 #1863 shape one level down. - It is pinned by
opts_ignored_when_any_top_level_reasoning_key_presentinfluree-db-query/src/parse/options.rstests. - The rationale is that a per-key merge lets one request draw modes from two places at once, which is harder to predict than one source winning outright.
So this issue is a decision, not a defect report.
Options
-
Per-key merge. For each of the four keys, top level wins if present; otherwise take
opts. The example above would then run datalog under the top-level budget.- Pro: matches what the caller plainly meant; the budget/mode split stops being a trap.
- Con: one request can draw reasoning config from two places, so "where did this mode come from" needs two lookups. Changes behaviour for anyone currently relying on a top-level key to suppress an
optstwin (unlikely, but it is a real compatibility surface).
-
Reject the ambiguous shape.
ParseError::InvalidOptionwhen the top level andoptsboth carry reasoning keys and they are not identical.- Pro: nothing is ever silently dropped; forces the caller to be explicit.
- Con: turns a currently-working request into an error; strictly worse for anyone who already writes both.
-
Leave as-is. The rule is documented and pinned; close as working-as-intended.
- Pro: no compatibility surface at all.
- Con: keeps a silent-drop path in a parser whose last silent-drop path was COUNT(*) over a novelty-only or overlay-only predicate returns 0 #1863.
My preference is (1) per-key merge, on the grounds that the con is a diagnosability cost while the status quo is a correctness-of-intent cost, and the budget+mode pairing is common enough to matter. But it is a behaviour change and belongs to whoever owns the query-options surface.
If (1) is taken, the pinning test opts_ignored_when_any_top_level_reasoning_key_present inverts rather than disappears — it should become opts_fills_keys_the_top_level_omits, and the all-or-nothing comment at the precedence site must go with it, or the code and its own documentation will disagree.
Pointers
fluree-db-query/src/parse/options.rs—parse_reasoning,REASONING_KEYS, and thePRECEDENCE IS ALL-OR-NOTHINGcomment.fluree-db-query/src/ir/reasoning.rs—ReasoningModes::from_query_json, which consumes exactly those four keys.- fix(query): COUNT over a novelty-only or overlay-only predicate returned 0 #1877 — the alias, the doc comment, and the unit tests.
- COUNT(*) over a novelty-only or overlay-only predicate returns 0 #1863 — the defect the alias was written for.
Activity
aaj3f commentedon Sep 17, 2026
One note for anyone reading this before #1877 lands, because two things here will not resolve against
main.#1877 is open and not yet merged. The
optsalias itself, the pinning testopts_ignored_when_any_top_level_reasoning_key_present, and the all-or-nothing precedence comment all arrive with that PR — they do not exist onmainyet. The wording above ("since #1877", "as of #1877") describes the state that PR creates, not the state today.So if you go looking for that test and cannot find it, that means not-yet-merged, not stale. The distinction matters for the remediation specifically: the recommendation is that the test inverts rather than disappears, and someone who concluded the name had drifted would reasonably drop the one sentence that tells them what to do with it.
Everything else here — the precedence behaviour, the three options, the tradeoffs — is about code that exists today and is unaffected.