Skip to content

history range queries return flakes newer than to (consumers post-filter on ?t as a workaround) #1810

Closed

Description

@bplatz

Summary

A history/changes query over a from–to t-range can return flakes newer than to. Two consumers in fluree/solo carry explicit workarounds for it, which is how it surfaced while auditing the router's history paths.

Evidence in consuming code

Router, fluree-lambda-router/src/routes/ner_relations.rs (add_history_bound):

// The current engine's novelty scan can return facts newer than `to`.
// Filter transaction metadata explicitly, before LIMIT; replay also checks
// this upper bound so historical reads never inherit a later verdict.

It appends ["filter", "(<= ?t <upper>)"] to every internal history query whose selection includes ?t, with <upper> parsed from the to address.

SPA, web/src/lib/api/instances.ts (parseHistoryRows):

The cut is made here rather than in the query because the engine accepts a
`to:` bound on this range and does not honour it — `to: base@t:1` still
returns flakes from `t:3`.

Shape of the query

{"from": "<ledger>@t:1", "to": "<ledger>@t:N",
 "select": ["?p", "?v", "?t", "?op"],
 "where": [{"@id": "<subject>", "?p": {"@value": "?v", "@t": "?t", "@op": "?op"}}],
 "orderBy": "?t"}

With to at t:1, rows with ?t of 3 come back. The phrase "novelty scan" in the router comment suggests the bound is honoured for indexed state but not for flakes still in novelty.

Expected

Every row's ?t satisfies from ≤ ?t ≤ to, for indexed and novelty flakes alike, so consumers can drop their post-filters. A regression test: write three commits, query the range t:1..t:1, assert no row carries t 2 or 3, on a ledger whose recent commits have not yet been indexed.

Engine version: the fluree-db-api rev pinned by fluree/solo, 80894e7832e173ebc3c33f7d0299808718a69652. May already be known internally; no open issue matched a search for it.

Activity

  1. added
    bug
    area:query
    on Sep 8, 2026
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

    area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions