Skip to content

test(query): adopt the fast-path routing-stamp pattern across the remaining fast-path suites #1669

Open

Description

@bplatz

Context

#1666 (closing #1652) added routing assertions to a fast-path regression suite: each case pins not just the answer but which lane served it, asserted against the fast-path outcome tracing stamps — must-fire for shapes that keep their lane, must-not-fire for shapes that must decline.

That closes a failure mode the value assertions alone cannot see:

  • a correctness fix that silently degrades into a disable still passes every value assertion, because the generic pipeline gives the right answer — the lane is just gone, and with it the performance the lane existed for;
  • an eligibility gate that silently un-declines also passes, right up until it meets the data it was written to refuse.

Both were live risks in #1666: three of the four fixes keep their lane and one narrows eligibility, and mutation-checking the suite (reverting AggStateStar::observe to saturating_add(1)) fails exactly the four star cases, naming the proceeded sites in the failure message. The review asked where else this belongs. It belongs in more places than it currently sits.

Current state

fluree-db-query/src/fast_path_outcome.rs already defines the surface — stamp_fast_path(site, Proceed | Fallback(KillSwitch | GateDeclined)) on the fluree::fastpath target, allocation-free and lock-free. What is uneven is adoption on both sides.

Emit side — roughly eight named sites stamp today: four kill-switch gate sites in execute/operator_tree.rs, the generic FastPathOperator in fast_path_common.rs, the star top-k operator, and the EXISTS semijoin cache in filter.rs. Every other fast path routes unobserved.

Assert side — 5 of 8 fast-path test suites assert stamps at all:

Asserts fast-path outcome Does not
it_fastpath_1652_regression it_differential_fastpath
it_repeated_var_fast_path_guards it_fast_group_count
it_count_datatype_pin it_minmax_fast_path_fired (see below)
it_distinct_object_numbig_gate it_minmax_string_fast_path
it_exists_semijoin_correlation it_string_fold_fast_path

it_differential_fastpath is the notable one: it is the harness whose whole purpose is fast-vs-generic agreement, and it currently cannot distinguish "the fast path agreed" from "the fast path never ran."

A second, parallel surface. fast_path_common.rs:3833 emits "fast path produced result" with a label field purely so it_minmax_fast_path_fired keeps working, immediately alongside the structured stamp_fast_path call for the same event. The comment says as much. Two instrumentation surfaces answering the same question, one structured and one ad-hoc.

Proposed work

  1. Migrate it_minmax_fast_path_fired onto the fast-path outcome stamps and delete the "fast path produced result" shim, collapsing the two surfaces into one.
  2. Add routing assertions to it_differential_fastpath — every case in the differential harness should name the site it expects, so agreement-by-absence fails loudly.
  3. Extend must-fire / must-not-fire coverage to the remaining suites in the right-hand column.
  4. Audit unstamped fast paths and stamp them; a lane with no site name cannot be asserted on at all.
  5. Consider promoting the pattern to a shared test helper — every suite currently open-codes the find_events("fast-path outcome") + filter-on-proceed window. fix(query): correct three fast paths that diverged from the generic pipeline #1666's Routing::{MustFire, MustNotFire} enum is a reasonable starting shape.

Relationship to the EXPLAIN work

fast_path_outcome.rs carries a TODO(PR-3) to generalize this seed into a per-operator GateVerdict computed once, threaded through the execution context, and rendered in ExplainPlan — planned-vs-executed across all fast paths rather than only the kill-switch sites. That is the same seam. Whoever does either should probably do both: the test-side adoption above is what would keep such a GateVerdict honest once it exists, and the stamps are the interim surface it grows out of.

Not urgent

No known incorrect results depend on this. It is coverage against a class of regression that is invisible to the assertions we currently write — the reason #1652's three divergences reached a release.

Refs #1666, #1652.

Activity

  1. bplatz commented on Aug 20, 2026

    @bplatz
    ContributorAuthor

    Correction to the sizing above, found while acting on the same review item in #1667.

    I wrote that "roughly eight named sites stamp today" and framed the rest as unstamped. That undercounts. FastPathOperator::open stamps fast-path outcome using the operator's own label as the site, so every operator built on FastPathOperator is already routing-observable without a direct stamp_fast_path call of its own. Counting call sites per file understates coverage.

    The concrete case: fast_predicate_scalar_agg.rs contains zero stamp_fast_path calls, which is what led both me and the reviewer to conclude its fused lanes needed instrumenting. They do not — they stamp as SUM(DAY), SUM(YEAR), AVG numeric and COUNT(DISTINCT). #1667 now asserts on those stamps with no production change, and a mutation forcing the operator to decline fails exactly the routing assertions and no value assertion.

    So item 4 ("audit unstamped fast paths and stamp them") is smaller than written, and the audit should start by separating lanes that genuinely emit nothing from lanes that emit under a label nobody has asserted on yet. The latter need only a test.

    Items 1–3 and 5 are unaffected — it_differential_fastpath still asserts no routing at all, and the "fast path produced result" duplicate surface is still there.

  2. added
    P3
    area:query
    on Aug 25, 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

    P3area:query

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions