Skip to content

opts reasoning alias: a top-level reasoningBudget silently disables opts.reasoning #1883

Closed

Description

@aaj3f

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_present in fluree-db-query/src/parse/options.rs tests.
  • 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

  1. 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 opts twin (unlikely, but it is a real compatibility surface).
  2. Reject the ambiguous shape. ParseError::InvalidOption when the top level and opts both 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.
  3. Leave as-is. The rule is documented and pinned; close as working-as-intended.

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

Activity

  1. added
    bug
    P3
    area:query
    on Sep 17, 2026
  2. aaj3f commented on Sep 17, 2026

    @aaj3f
    ContributorAuthor

    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 opts alias itself, the pinning test opts_ignored_when_any_top_level_reasoning_key_present, and the all-or-nothing precedence comment all arrive with that PR — they do not exist on main yet. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions