Repository navigation
bench+test: query correctness guardrails — differential harness, baseline gating, and four fast-path fixes - #1477
Conversation
set_fast_paths_disabled(bool) / fast_paths_disabled() plus the FLUREE_DISABLE_QUERY_FAST_PATHS env var force the generic operator pipeline by skipping every detect_* shape recognizer — the fused chain and the three non-fused history-gated paths alike. Exists for the differential correctness harness and as an operational escape hatch when triaging a suspected fast-path bug; runtime operator-internal optimizations are unaffected. Re-exported through fluree-db-api.
Runs every registered query shape twice — once with fast paths enabled, once forced through the generic operator pipeline via the kill switch — and asserts the two produce identical results. Divergences that main has not yet fixed are pinned as known_divergence markers (reported, not enforced): FD-1 (AVG datatype drift), FD-2 (MIN/MAX-string on reindexed ledgers), FD-3 (per-predicate COUNT from stats estimates). Wired into grp_query.rs (autotests=false grouping) and adapted to today's insert_turtle_with_opts 6th-arg signature.
…ay condition-matrix bench Ports the June guardrail tooling additively onto main's bench chassis: fluree-bench-alloc tracking allocator, baseline.rs capture/compare + bench_baseline bin, mem.rs scenario sidecars, and the query_overlay_matrix bench (base/overlay/ novelty conditions x scales). Adds the query_overlay_matrix regression-budget.json row so workspace_reconcile stays green.
The AVG fast path accumulated Kahan-compensated f64 and emitted xsd:double; the generic finalize_avg emits exact xsd:decimal for integer inputs (SPARQL 1.1). Same value, different observable datatype depending on which plan ran — pinned by the differential harness (FD-1). AggState::Avg now mirrors finalize_avg per number kind: integers sum exactly in i64 (checked; overflow defers to the generic BigDecimal pipeline) and finalize via BigDecimal division at the shared AVG_DECIMAL_PRECISION; doubles use plain (non-Kahan) summation to bit-match the generic accumulator; other numeric encodings defer. Removes the FD-1 marker so the harness enforces L1, and updates two indexed-suite expectations that had pinned the old f64 rendering (one had baked the leaflet-vs-overlay divergence in as correct).
…ats estimates StatsCountByPredicateOperator returned StatsView property counts as query answers. Those are planner estimates: they count duplicate re-asserts that set-semantics novelty apply dedups, track rdf:type asymmetrically between indexer-built and novelty-accumulated stats, and apply novelty deltas inconsistently per predicate — three wrong answers pinned by the differential harness (FD-3). Rewritten as a FastPathOperator that counts exactly from POST leaf-directory metadata (homogeneous leaflets contribute row_count with no payload read; mixed leaflets decode only the PId column), gated by fast_path_store (epoch-0, at-head, root policy, single ledger) with the generic pipeline as the fallback for overlay/novelty/time-travel/policy. The detector declines OFFSET (not idempotent when the fallback re-applies the modifier stack). Removes the FD-3 marker so the harness enforces L2.
translate_overlay_flakes_with_untranslated (reached by export and the analytical BinaryScanOperator overlay fallback) dropped overlay flakes whose V3 translation returned a non-Unsupported error — a NotFound from a stale/detached DictNovelty silently lost data. Route every failed translation into the untranslated post-pass (raw (s,p,o,dt,m) flakes render without needing the dict), mirroring the already- hardened range path (binary_range.rs). Adds a white-box regression at the helper boundary: correct-dict and detached-dict now yield EQUAL totals (lossless); before the fix the detached case dropped every novel-subject flake.
overlay_lane_eligible reconciled an index_t-pinned base count with a to_t-bounded overlay delta but never checked to_t against the index. A from_t=None read whose to_t was pushed below index_t while a live overlay stayed attached (reachable via GraphDb::as_of) returned the index_t snapshot count instead of the to_t count — a silently wrong whole-graph aggregate through the public query API. Require to_t >= store.max_t() (mirrors the clean lane's to_t == max_t discipline) so the lane declines to the general pipeline below the index. Lifts the adversarial reproducer (trial/wga-gate-verify) as a permanent regression pin: the overlay fold now agrees with the barrier pipeline (2 == 2) at to_t=2 < index_t=3, and the head case still exercises the lane at to_t >= index_t.
…IN seed)
Minimal FastPathOutcome::{Proceed, Fallback(reason)} emitted on a dedicated
tracing target (fluree::fastpath) — no hot-path lock (a disabled tracing event is
a cheap atomic load). Stamped at the four kill-switch gate sites in operator_tree
(the fused chain + the three non-fused count paths) at plan time, and at
FastPathOperator::open() for the runtime Proceed/Fallback(GateDeclined) decision.
The four sites are plan-time (no ExecutionContext) and explain.rs is a plan-time
pattern explainer that never opens operators, so a threaded ExecutionContext slot
surfaced in ExplainPlan is out of scope here (PR-3): this is the seed and the
tracing target is the interim surface. TODO(PR-3) markers left at the seam
(fast_path_outcome.rs + explain.rs) for the per-operator GateVerdict generalization.
guardrails-pre.json: 24 scenarios captured at FLUREE_BENCH_PROFILE=quick, tiny+small — query_overlay_matrix (base/overlay/novelty x count/star/groupby, time + peak-mem) and query_hot_bsbm (q3/q5/q9, time), the two cheap benches the per-PR compare subset gates on. The query_overlay_matrix budget rows were added with the bench tooling; query_hot_bsbm already had rows. Round-trip self-check passes: compare-vs-self exits 0 (0 of 42 metric comparisons breached), a hand-doctored copy exits 1 (groupby_base/small +100% EXCEEDED). Quick-profile tiny+small only; a full nightly-grade small+medium baseline on CI-class hardware is a follow-up.
Adds a per-PR bench-compare job (ci.yml): runs the two cheap benches (query_overlay_matrix + query_hot_bsbm) at tiny/quick and compares against the committed baseline, exiting 1 on any regression-budget.json breach — a real speed-first gate. Extends the nightly bench-gate (bench.yml) with a real compare of the same captured subset against the baseline (if: always(), so it runs even when an unrelated workspace bench trips the smoke step). The full workspace compare at +medium against a phase post-baseline is a follow-up per ROADMAP §7 (needs the 45-min cap raised or the workflow split).
…ndependently) FD-2 (MIN/MAX-string fast path returning the last-inserted label instead of the lexicographic extreme) was fixed on main by its own fast_min_max_string work before this harness landed — the marker had stayed silent on every run. Per the D-10 ritual, remove the max_label/min_label known_divergence markers: this upgrades FD-2 from reported-only to harness-ENFORCED, so a future regression of main's fix fails the harness. Verified green.
reset_peak() rebases PEAK:=CURRENT, so the raw snapshot().peak_bytes the query_overlay_matrix scenario recorded still included the loaded snapshot's live bytes — a setup-side memory change could mask a query-side regression, and as a gate metric that is unsound (review item 3). reset_peak() now returns the live-bytes baseline it rebased to (current_at_reset); the scenario records peak_bytes - reset_base (saturating), i.e. the true scenario-attributable peak per the June D-9 definition. Budgets are percentages (unchanged); the committed baseline is re-captured under this semantics in a later commit.
…d order) The double lane summed f64 in POST (value-ascending) order while the generic pipeline folds in scan order; f64 addition is non-associative, so the fast sum was NOT guaranteed to equal the generic one — the 'bit-match' comment overclaimed (review item 2). Confirmed divergent by a new mixed-magnitude xsd:double harness case (fast 0.0 vs generic 1.03125). fold_row now declines every non-integer numeric encoding (return Ok(false), joining the existing other-encodings arm), so xsd:double AVG falls back to the generic pipeline. The integer lane stays: integer arithmetic is exact and order-free. Removes the now-dead dbl_sum accumulator and the F64 finalize branch.
…ecline, env doc - operator_tree stats-count dispatch: the OFFSET wrap was dead (the detector declines any query with offset.is_some(), ~:1690); replace it with a debug_assert!(query.offset.is_none()) so the next reader need not re-derive the double-OFFSET analysis (review item 5). Merge the two duplicate stats.is_some() comment paragraphs (item 6). - stats_query exact_count_by_predicate_post: map open_leaf_handle/load_columns IO errors to Ok(None) — decline to the generic scan — instead of hard-failing with QueryError::Internal. Declining is lossless (the fn only accumulates a local map and has emitted nothing) and honors the fast-path 'degrade to the correct slower path' contract; a real IO fault resurfaces in the generic scan (item 9). - set_fast_paths_disabled: document the env-override footgun — fast_paths_disabled() OR's the flag with FLUREE_DISABLE_QUERY_FAST_PATHS, so set_fast_paths_disabled(false) cannot re-enable fast paths when the env var is set (item 7).
…tch + global-switch hazard - Add an xsd:double AVG case (avg_double) over a mixed-magnitude ex:dscore predicate engineered to stress f64 non-associativity across the fast vs generic fold orders. Now green because the double lane declines to the generic pipeline (review item 2) — the case pins that decline-lane agreement. - Assert at harness startup that FLUREE_DISABLE_QUERY_FAST_PATHS is unset: with it set, the fast-paths-ON phase runs generically and every case passes vacuously (generic-vs-generic). Fail loudly instead (item 7). - Document the process-global kill-switch hazard on FastPathGuard: tests asserting fast-path routing must not share this binary (grp_query) — benign today because the only such test lives in grp_misc (item 8).
…hine time The per-PR gate compared absolute wall-clock time from a local (Apple-silicon) baseline against shared ubuntu-latest runners — unsound, and red on this PR's own CI (review item 1, blocking). Split enforcement by metric validity: peak memory is comparable cross-machine (reviewer measured ±2.2%) and stays ENFORCED; wall-clock time is advisory when it cannot gate. compare() takes a time_advisory flag; the bin sets it automatically when the baseline's runner_class differs from this runner's (env FLUREE_BENCH_RUNNER_CLASS, default "local"), or via --time-advisory. Time breaches then print as ::warning:: annotations and do NOT fail the gate; memory breaches still exit 1. Adds runner_class/host provenance to BaselineFile (serde default so old baselines load), and treats a sidecar-only current entry (bench not rerun; mean_ns==0) as not-rerun rather than comparing a stale mem sidecar (item 10).
The old baseline recorded git_sha 8b437b934 — a dangling commit unreachable from any branch, captured on the PR branch WITH the four engine fixes rather than at the merge-base the 'pre' convention specifies (review item 1b). Re-captured on a scratch worktree at the true merge-base 2c51620 (merge-base engine; only the bench tooling + the item-3 mem fix + the item-1a schema overlaid, NOT the engine fixes), quick profile, tiny+small — same subset as before (query_overlay_matrix + query_hot_bsbm). Records the real merge-base sha, runner_class=local, and host, so the per-PR CI compare (runner_class ci-*) auto-treats TIME as advisory while enforcing memory. Memory numbers now reflect the item-3 scenario-attributable semantics (e.g. groupby_base/small 2.49 MiB vs the old absolute 5.78 MiB). Round-trip: compare-vs-self exits 0; doctored MEM exits 1; doctored TIME under a mismatched runner_class exits 0 with a ::warning:: advisory.
…nd nightly Wire the split gate (review items 1a/1c/10). ci.yml bench-compare and bench.yml's nightly compare set FLUREE_BENCH_RUNNER_CLASS=ci-ubuntu-latest: since the committed baseline is runner_class=local, compare auto-treats wall-clock TIME as advisory (::warning:: annotations, non-gating) and ENFORCES memory (sound cross-machine). Both clear target/fluree-bench-mem before the run so a cache-persisted stale sidecar is never merged (item 10). Adds a workflow_dispatch bench-capture job that captures the cheap subset (tiny+small) on ubuntu-latest as runner_class=ci-ubuntu-latest and uploads it as an artifact; committing it lands a ci-* baseline whose runner class matches CI, at which point the time half enforces automatically (item 1c). The reviewer's same-runner interleaved base-vs-head compare is documented in BENCHMARKING.md as the longer-term option, deliberately not wired (2x build cost).
…te design baseline.rs, bench_baseline.rs, and bench-baselines/README.md all cite a BENCHMARKING.md section 'Baselines: capture & compare' that did not exist, and the doc still described a single bench-baselines.json file and a two-phase gate the PR supersedes (review item 4). Add the cited section (directory + bin scheme; capture records runner_class/host provenance; compare enforces memory always, time only when runner classes match). Rewrite the CI-gate section for the three-phase design (nightly reconcile+smoke, per-PR mem-enforced/time-advisory compare, workflow_dispatch CI-class capture) and reconcile 'Why two phases' into 'Why time can't gate cross-machine' — documenting the same-runner interleaved base-vs-HEAD compare as the longer-term option deliberately not wired (2x build cost). README notes the runner_class rule and guardrails-pre.json's merge-base provenance.
…narios match data The bench serializes its Person/Company graph under the `http://example.org/` namespace, then queries the resulting view with BARE Cypher identifiers (`MATCH (n:Person)`, `n.age`). Bare identifiers resolve through the queried view's default-context `@vocab`, and `db()` does not copy any ledger default context onto the view (see `GraphDb::with_default_context`). With no `@vocab`, every bare label/property resolved to namespace 0 and matched zero nodes, so all class-anchored and property scenarios silently ran over an empty result. The whole-graph `count(n)` sanity assert still passed (a subject scan needs no IRI resolution), but the filtered-histogram assert saw an empty result and panicked (`filtered histogram must produce group rows: null`), reddening bench.yml's nightly `--workspace -- --test` smoke. Attach `{"@vocab": "http://example.org/"}` to the queried GraphDb via `with_default_context` so bare labels/properties resolve to the written IRIs. Verified green at FLUREE_BENCH_SCALE=tiny FLUREE_BENCH_PROFILE=quick: `MATCH (n:Person)` now counts 900 (was 0), count(n.age)=900 (was 0), and the `n.age >= 40` histogram yields 26 age groups (was empty); bench `--test` exits 0.
…s-scenario history Per-PR CI compiles benches but never runs them; runtime panics surface only in the nightly smoke, on main. The whole_graph_agg @vocab bug sat in exactly this blind spot, with its class scenarios measuring empty result sets — their pre-fix numbers are void and must be re-baselined when a committed baseline first covers them. Promoting a tiny --test smoke into per-PR CI is noted as a costed follow-up.
|
Review response — all items addressed in 10 additive commits ( Blocking —
Proof of the split: compare-vs-self exits 0; doctored mem breach exits 1; doctored time breach under Double-lane AVG — you were right, and it was worse than the comment claimed. A new mixed-magnitude Should-fixes/nits ( Not done: renaming the bare Bonus (rider): the nightly |
bplatz
left a comment
There was a problem hiding this comment.
The four fixes are good work — but both merge conflicts with main are semantic, not textual, and resolving either in this branch's favor silently reverts a fix already on main (45d6009bf, "correct fast-path COUNT datatype and poison numeric aggregates", merged Jul 8 — after this branch forked). Details inline.
This branch is 216 commits behind main, and the conflict set is small (stats_query.rs, testsuite-sparql/tests/registers/mod.rs) — small enough that it looks like routine noise, which is why I want to flag it before the rebase happens.
What I verified as sound:
- The AVG fix is right, and better than the description suggests. The exact-
i64lane withchecked_add→ decline on overflow is order-free, and decliningxsd:doubleoutright is the correct call — folding in POST order vs the generic pipeline's scan order genuinely can't be made to agree. Removing the Kahan state also makesfold_rowcheaper than before, so hot-loop purity isn't just preserved, it improves. stamp_fast_pathis atopen(), not per-row, so the observability seed adds nothing to the kernels.- The non-numeric decline composes correctly with
main's aggregate poisoning.fold_rowreturningOk(false)on a non-numeric member hands off to the generic path, which now poisons per §18.5 — so the two changes agree rather than fighting.
One worth a look on the new CI job inline.
| return Ok(None); | ||
| }; | ||
|
|
||
| let dt = WellKnownDatatypes::new().xsd_long; |
There was a problem hiding this comment.
Definite issue — this line is the conflict with main, and it's a revert.
main changed exactly this to xsd_integer in 45d6009bf:
SPARQL COUNT yields xsd:integer (§18.5.1.6); the materialized and streaming aggregate paths already tag it so — this per-predicate fast-path must match or a COUNT re-typed as xsd:long leaks (agg02).
Because this PR rewrites the whole 1–195 region, git can't merge that one-line change in, and the natural resolution ("take the rewrite, it's newer work") puts xsd_long back.
What makes it worse than a plain revert: the register comment on this branch explicitly rejects the datatype theory —
The old note guessed a datatype re-typing; the real fault was the stats-estimate count operator this PR replaced.
I don't think that's right; it reads like two independent faults in one test. This branch fixed the count value (stats estimate → POST directory), main fixed the count datatype, and each was sufficient to green agg02 at its own base. Post-merge with only the value fix, agg02 fails again on the datatype — while this PR has removed its skip entry, so nothing reports it as expected.
Resolution: keep the rewrite, carry xsd_integer into it, and re-run the W3C aggregates suite after the rebase rather than trusting either branch's pre-rebase 36/36.
| // group_aggregate finalize; probe before fixing) | ||
| // expression/aggregate cluster (1) — PR-X2: agg-err-01 = aggregate must | ||
| // poison (unbind) on non-numeric group members. | ||
| // (agg02 = `SELECT ?P (COUNT(?O) AS ?C) … GROUP BY ?P` now PASSES — fixed by |
There was a problem hiding this comment.
Definite issue — the other half of the same conflict, in the opposite direction.
This branch correctly removes agg02, but it still lists agg-err-01 below (it forked before main greened that one via the SUM/AVG poison fix in the same 45d6009bf). main's register has neither entry.
So the two conflicts pull opposite ways: stats_query.rs resolved toward this branch loses a fix, and registers/mod.rs resolved toward this branch re-adds a skip for a test that now passes — which quietly stops the suite from enforcing main's poison fix. A skip entry for a passing test is the failure mode that doesn't announce itself.
Resolution here is just the union: drop both agg02 and agg-err-01. Worth updating the parenthetical too, since the datatype explanation it dismisses turned out to be a real second fault.
| # TIME breaches are ADVISORY (::warning:: annotations, non-gating) because the | ||
| # committed baseline is runner_class=local and shared ubuntu-latest runners | ||
| # flap — a 10% time budget on a single PR run false-positives (BENCHMARKING.md, | ||
| # "Baselines: capture & compare"). Once a ci-* baseline is committed (via |
There was a problem hiding this comment.
Worth a look — hard-failing on memory across machine classes, on every PR.
The time/memory split is well-reasoned and the ::warning::-only treatment of time is clearly right. My hesitation is that memory is gating while the committed baseline is runner_class=local — so every PR compares a shared ubuntu-latest peak against a number captured on someone's laptop. The ±2.2% figure is one measurement between two specific machines; allocator behaviour, page size, and background load on shared runners can move a tracking-allocator peak by more than that, and the failure lands on an unrelated PR author with no obvious cause.
Given the comment already anticipates the fix ("once a ci-* baseline is committed … time enforces automatically"), it'd be safer to make memory advisory too until that ci-class baseline exists, then flip both to gating at once. That also avoids the asymmetry where the less portable signal is the one that blocks.
Separately worth surfacing to the team rather than deciding here: this adds a ~30-minute job to every PR. Reasonable for the value, but it's a shared-cost change that people should opt into knowingly.
Both conflicts were semantic, not textual: main's 45d6009 ("correct fast-path COUNT datatype and poison numeric aggregates", merged after this branch forked) touched exactly the two regions this branch rewrote, and either naive one-sided resolution silently reverts part of that fix. fluree-db-query/src/stats_query.rs — keep this branch's exact leaf-directory count rewrite (which replaced the StatsView-estimate operator main still had), and carry main's datatype correction into it: the emitted count is now tagged xsd:integer, not xsd:long. SPARQL COUNT is xsd:integer (§18.5.1.6); the materialized and streaming aggregate paths already tag it so. 45d6009's only change to this file was that one datatype line plus its comment, both carried; its other three sites (aggregate.rs, group_aggregate.rs, fast_group_count_firsts.rs) auto-merged intact. testsuite-sparql/tests/registers/mod.rs — union: neither agg02 nor agg-err-01 is registered as skipped. This branch had removed agg02's entry but still carried agg-err-01 (greened on main by the same commit); re-adding it would have quietly stopped the suite enforcing main's SUM/AVG poison fix. The replacement comment records the real history: agg02 had two independent faults, count value and count datatype, each sufficient to fail it, fixed on the two branches respectively — the note this branch previously carried wrongly dismissed the datatype theory.
The COUNT fast paths tag their result datatype themselves instead of going through aggregate::finalize, so one wrong WellKnownDatatypes field re-types a count while leaving its value correct. Two of them did exactly that until main's 45d6009, and reconciling this branch with main nearly reverted it — with nothing in the tree to notice. Neither existing guard covers it. The W3C suite compares datatype IRIs strictly (result_comparison::terms_match, before any numeric value-equality fallback), but builds every ledger with FlureeBuilder::memory(), so fast_path_store declines and the correctly-tagging generic pipeline answers agg02 regardless of what the fast path would have emitted. The differential harness does run on an indexed ledger and does compare fast against generic, but formats with FormatterConfig::jsonld(), which renders an integer literal as a bare JSON number — the datatype never reaches the comparison. This closes both holes: a bulk-imported (indexed, novelty-free) ledger so the fast paths actually fire, to_sparql_json so the datatype is on the wire, and an exact string comparison of the datatype IRI. Seven COUNT shapes, each checked with fast paths on and again under the kill switch, with the two pipelines also required to agree byte-for-byte. Three of the four routes additionally assert their fluree::fastpath "proceed" stamp, so a drifting detector fails loudly rather than silently re-testing the generic path; group_by_object_star_topk cannot yet (the fused chain stamps one aggregate verdict — per-detector verdicts are the PR-3 TODO in fast_path_outcome), so its coverage was confirmed by mutation instead. Verified red-green: retyping either stats_query's `dt` or fast_group_count_firsts' `dt_count` to xsd_long fails the corresponding case. Own test binary: it toggles the process-global kill switch AND asserts fast-path routing, so it must not share a process with either.
Memory was enforcing while time was advisory, against a committed baseline captured with runner_class=local. On ubuntu-latest that meant every PR compared a shared-runner peak against a number from someone's laptop, and a breach failed an unrelated author's build with no obvious cause. The ±2.2% cross-machine figure that justified enforcing memory is one measurement between two specific machines, not a portability result: allocator behaviour, page size, and background load all move a tracking allocator's peak. So the gate had the less portable of its two signals doing the blocking. Both metrics now follow one rule — enforce when the baseline's runner_class matches the comparing runner's, advisory (::warning::, exit 0) when it doesn't. `compare`'s `time_advisory` parameter becomes `advisory` and applies to every comparison; `--time-advisory` becomes `--advisory`. Committing a ci-* baseline (bench.yml's workflow_dispatch capture job already produces one) flips both to enforcing with no further change. Also gates the ~30-minute bench-compare job on a new bench-paths job so it only runs when a PR touches perf-relevant code. GitHub's `paths:` filter is workflow-scoped and the rest of ci.yml must run on everything, so the filter is a job output rather than a workflow trigger; the job stays in ci.yml so the perf gate remains visible next to the other checks. The path list errs inclusive — a false positive costs one bench run, a false negative lets a regression through — and includes Cargo.toml/Cargo.lock, since a dependency or profile change moves timings without touching an engine file. Unit tests replace the two old asymmetric cases with the full truth table over (runner class matched?) × (which metric breached), plus a direct pin that a cross-class memory breach annotates rather than gates. The Cargo.lock hunk is merge fallout: main bumped the workspace to 4.1.4 and fluree-bench-alloc, added on this branch, was still pinned at 4.1.2.
BENCHMARKING.md still said memory is always enforced and only time depends on runner_class. Rewrites the gate section around the actual rule — both metrics enforce on a runner-class match, both are advisory otherwise — with the truth table, why peak memory is no more portable than wall clock, and what phase 1 (annotate) versus phase 2 (gate, on committing a ci-class baseline) look like. Also documents the bench-paths cost filter and renames --time-advisory to --advisory in the compare example.
|
Response to review — all three items adopted;
What the investigation turned up, which you'll want to know: the reason this branch's earlier 36/36 couldn't have caught the datatype fault is that neither guard can see it — CI gate (worth a look) — adopted, your way. Memory now follows the same rule as time: both metrics enforce only on a |
|
@bplatz -- ready for re-review at your convenience |
bplatz
left a comment
There was a problem hiding this comment.
Both conflicts resolved as prescribed in 27afaac — rewrite kept with xsd_integer carried in, register has neither agg02 nor agg-err-01, and the corrected comment records both faults. it_count_datatype_pin machine-enforcing the datatype on an indexed ledger closes the gap the memory-backed suite can't cover. Compare gate is now symmetric (both metrics advisory until a ci-* baseline lands) with the bench-paths filter addressing the shared-cost concern.
Re-verified post-merge as asked: aggregates suite 44/0 (2 documented ignores), query crate green. Also test-merged current main (54 commits ahead) — textually clean, and the suites pass on the merge result, so no new semantic conflicts from the duration fast-path or early-dedup work.
# Conflicts: # Cargo.toml
…loor Four extensions to the baseline gate fluree#1477 introduced, all of them aimed at the same failure: a compare run that produces a number which looks like a result and is not one. host block. `runner_class` becomes `host.class` inside a block that also records os, arch, cpu_model, and physical/logical cores. The class names a comparability SET, not a machine — two hosts share one when a human has decided their absolute numbers may be compared. A mismatch is now a refusal (exit 2) rather than a silent downgrade to advisory; `--allow-host-mismatch` opts back into the advisory posture, which is what CI runs today. The derived default is `{os}-{arch}`, deliberately coarse: an M1 and an M4 both derive `macos-aarch64` and are not interchangeable, so any host whose numbers are meant to gate should set FLUREE_BENCH_HOST_CLASS explicitly. corpus identity. A new `meta` sidecar (target/fluree-bench-meta/, same shape as the mem sidecar) carries sha256 + byte_len + element_count + input/output syntax + thread count per scenario, declarable per entry or once per file. Comparing a run over one input against a baseline captured over another is the most expensive silent failure available here, because the output is indistinguishable from a real regression — so it is a refusal with no override, unlike the host check. SHA-256 rather than BLAKE3: blake3 is not in the tree, sha2 already is, and a corpus is hashed once per capture. phase shares. Per-phase {ns, share_pct}, with the share derived from the ns at record time so the two can never disagree. Absolute phase ns gates only within a host class; share drift gates regardless, because a share is a ratio within one run and the machine cancels. Only share GROWTH gates — shares sum to 100, so gating both directions would fail a clean improvement twice, once for the phase that got better and once for its complement. noise floor. `capture --accumulate` folds repeat runs into a median + MAD over >= 5 samples, and the gate flags only when the median move exceeds max(budget_pct, 3*MAD/median). MAD over stddev because a single outlier run is the common case here and barely moves MAD. The floor only ever widens an envelope, never tightens one. Schema bumps to 2; schema-1 files still load (`runner_class` maps to `host.class`, a bare `host` string to `host.name`), so the committed guardrails-pre.json stays usable untouched. A baseline claiming a NEWER version is a refusal — silently ignoring fields we don't understand is how a gate stops gating.
…ly do Every claim in the file checked against the merged main + fluree#1477 tree. Five were wrong or stale: - "Where benches live" pointed at .github/workflows/bench-nightly.yml, which has never existed — the file is bench.yml. Both entries also carried "lands in bench-5" / "lands in bench-nightly PR" process notes for work that landed. Replaced with the real layout, including bench-baselines/ and the three target/ directories capture reads. - The bench table was missing six of the eighteen registered [[bench]] entries: query_overlay_matrix, query_hot_bsbm_bi, query_hot_property_path, query_hot_whole_graph_agg, annotation_hydration, annotation_planner. (Five of those are missing on main; fluree#1477 adds query_overlay_matrix.) Rows written from each bench's own module docs. Also says outright that nothing enforces this table, unlike the [[bench]] <-> budget reconcile, which is why it rots. - The env-var table's defaults are right for a laptop and were being read as though they described CI. Both jobs pin quick/tiny — the nightly included, despite `Full`'s doc calling itself the nightly profile. Noted in the table and corrected at the source in runtime.rs, where BenchProfile::Full claimed "Nightly CI" and referenced the unbuilt `bench-nightly`. - bench-baselines/README.md still described the pre-5d9d69513 asymmetric gate ("enforces memory across any runner class, time advisory"). That has been false on this branch since the gate was made symmetric. The rest of the section is rewritten for the extensions in the previous commit: the metric table with its per-metric portability column, the refusal conditions and their exit codes, the noise-floor accumulation loop, and why {os}-{arch} is a coarse default rather than a promise.
…conflict-free review Single conflict: fluree-db-api/src/lib.rs — convergent cfg-orphan fix. Both #1566 and the audit side moved build()'s #[cfg(native)] doc block below with_secret_resolver (kept iceberg-gated). The cfg fix is byte-identical on both sides; resolved the lone doc-wording hunk to main's #1566 text, so the merged file equals origin/main's api/lib.rs (zero diff, no audit feature lost). hash_join.rs, optional.rs, planner.rs auto-merged (disjoint hunks: audit #1477 fast-path vs main cypher #1553).
PR fluree#1528 (big-Iceberg-audit implementation + browse-parity + family-C, approved by bplatz) was merged while its base still pointed at the scaffolding branch perf/audit-mainmerge-base, so its content landed there instead of main. This merges current main (carrying fluree#1520, fluree#1507, fluree#1514, fluree#1477) into the audit content so the combined tree can be proposed to main. Conflict resolutions: - fluree-db-iceberg/src/mor_guard.rs (add/add): family-C converged superset. Its W1/W2 fail-closed guard bodies are byte-identical to main's; it omits the ensure_summary_scannable / ensure_manifests_scannable planner helpers, which the family-C planners inline. Verified those helpers have no remaining callers. - fluree-db-iceberg/src/lib.rs, scan/planner.rs, scan/send_planner.rs: family-C inlined-guard arms (+ has_delete_manifests ScanPlan stamp). Main's non-conflict additions (parse_manifest_list_with_deletes, the F-AUD-1 mor_guard_tests fixtures) auto-merged and were preserved. - fluree-db-api/src/graph_source/iceberg_catalog.rs: main's W3-evolved preview stats guard (typed 409 error, hoisted allow_mor, table_display, preview_counts_are_upper_bounds) — a functional superset of the audit's older F-AUD-1 form. Its preview_summary_guard called the dropped ensure_summary_scannable; inlined that helper's body (mor_deletes_allowed + ensure_no_summary_deletes), matching how the family-C planners inline the same guard. - fluree-db-api/src/format/mod.rs: family-C crawl formatter (crawl uses format_node_object_binding; the format_binding_with_result re-export is unused). Gated the crawl-only formatter helpers and their Binding import behind the iceberg feature to clear a pre-existing fluree#1528 featureless dead-code gap. - fluree-db-api/src/ledger_info.rs: auto-merged as the union of main's fluree#1534 redaction machinery and the audit /info mor-approximate extensions.
What this PR is
The safety net for upcoming query/ledger refactor work, plus the four live correctness issues it caught, in one self-contained, almost-entirely-additive PR. Nothing here changes a fast-path kernel; the four fixes make fast paths agree with the generic pipeline.
Contents (11 commits, reviewable per-commit)
Tooling (additive):
feat(query)— planner fast-path kill switch (set_fast_paths_disabled/FLUREE_DISABLE_QUERY_FAST_PATHS): lets any query run down both the fast and generic paths in-process. Zero cost when unset; also a production bisection tool.test(api)— differential fast-vs-generic harness (it_differential_fastpath, ingrp_query): randomized base + trailing-novelty + time-travel data; asserts fast ≡ generic per shape. On first run against main it reported the three divergences fixed below.feat(bench)—bench-baselinecapture/compare bin,fluree-bench-alloctracking allocator (scenario_mem= peak − scenario-start), andquery_overlay_matrix(count/star/group-by × base/overlay/novelty × scales — the overlay lane previously had zero bench coverage; every existing hot bench runs at epoch 0).Fixes (each with its regression pin; all four verified by the harness):
4.
fix(query)— AVG fast path is datatype-faithful to the generic pipeline: exactxsd:decimalfor integer inputs (was: f64 always). Two indexed test expectations that had pinned the old f64 output are updated in the same commit. Review-response follow-up: thexsd:doublelane now declines to the generic pipeline entirely — a new mixed-magnitude harness case demonstrated the fast fold's order-dependence diverging (0.0 vs 1.03125, catastrophic cancellation), so per the fallback contract the lane bails rather than risk it; the harness case pins the decline-lane agreement.5.
fix(query)— per-predicate COUNT answers from POST leaf-directory metadata, never fromStatsViewestimates: fixes over-counting duplicate re-asserts (e.g. 50 vs correct 26) and a droppedrdf:typerow under pure novelty; detector declines OFFSET (unsafe under outer re-wrapping). Also greens W3Cagg02— its stale skip-register entry is removed.6.
fix(query)— failed overlay translations keep the raw flake for all error kinds (was: non-Unsupportederrors were warn-logged and silently dropped). Brings the export/main-scan helper to parity with the range-provider path; lossless even under a degraded dictionary state (white-box test included).7.
fix(query)— whole-graph-agg overlay lane boundsto_t ≥ index_t: the lane reconciles an index-pinned base count with ato_t-bounded overlay delta, which is exact only at/above the index watermark; a publicGraphDb::as_of(t)below it produced a wrong count (reproducer included as a regression pin).Gate + observability:
8.
feat(query)—FastPathOutcome::{Proceed, Fallback(reason)}emitted on thefluree::fastpathtracing target at the four planner gate sites and at fast-operatoropen()— first step toward EXPLAIN showing the actually-executed path.9.
bench— committedguardrails-prebaselines (24 scenarios, time +scenario_mem); compare-vs-self exits 0, a doctored baseline exits 1.10.
ci(bench)— per-PR cheap compare (overlay matrix + hot-BSBM at tiny/quick) against the committed baseline; nightly compare of the same subset. Both metrics (time and peak_mem) enforce only when the committed baseline'srunner_classmatches the runner's; against a cross-class baseline both are::warning::advisory — so today'slocal-class baseline annotates without gating, and committing a CI-class baseline (theworkflow_dispatchcapture job) flips both to enforcing with no code change. The ~30-min job is gated on abench-pathscheck and skipped when a PR touches nothing perf-relevant. Deliberately small: the full-workspace nightly compare needs the bench timeout discussion first.11.
test(api)— FD-2 (MIN/MAX-string lex-order) marker removed: main's ownfast_min_max_stringfix is confirmed by the harness and now enforced against regression.Main reconciliation (post-review, 2026-07-27)
mainwas merged in (27afaac0e) with both conflicts resolved semantically, per review:stats_query.rskeeps this PR's exact leaf-directory COUNT but carries main's45d6009bfdatatype fix (xsd:integer, §18.5.1.6) into the rewrite — nothing else from that commit's hunks is lost (diff-verified); the W3C register takes the union — neitheragg02noragg-err-01is skipped, and the register comment now records the honest history (agg02 had two independent faults: count value, fixed here; count datatype, fixed on main — the earlier note dismissing the datatype theory was wrong).The investigation also found both test guards were structurally blind to fast-path datatype faults:
testsuite-sparqlbuilds memory-backed ledgers so indexed fast paths never fire (its datatype comparison is strict — it just never sees this code), and the differential harness formats through JSON-LD, which erases numeric datatypes. Henceit_count_datatype_pin.rs: an indexed, novelty-free ledger asserted throughto_sparql_jsonwith a strictxsd:integercheck — mutation-verified (re-typing toxsd_longturns it red). That converts the datatype contract from convention to enforcement, in both directions.Verification (re-run post-merge on the reconciled head)
-p fluree-db-apisuite green (testcontainers bins excluded locally — Docker; they run in CI).testsuite-sparqlW3C: 36/36 post-merge withagg02andagg-err-01un-skipped.fluree-db-query,fluree-db-api,fluree-bench-support,fluree-bench-alloc); rustfmt clean.Notes for reviewers
query_hot_whole_graph_aggbench sanity panic (triaged & resolved in this review response). Not an engine bug — bench-side. The bench writes its Person/Company graph underhttp://example.org/but queried thedb()view with bare Cypher identifiers (MATCH (n:Person),n.age), which resolve through the view's default-context@vocab;db()copies no ledger default context onto the view, so every bare label/property resolved to namespace 0 and matched zero nodes — the class-anchored scenarios silently benchmarked empty results and the filtered-histogram sanity assert panicked (nullrow). Fixed with a one-linewith_default_context({"@vocab":"http://example.org/"})in the bench setup (-- --testnow exits 0 —MATCH (n:Person)counts 900; theage >= 40histogram yields 26 groups). Two caveats documented in BENCHMARKING.md: the per-PR gate only compiles benches (runtime panics surface nightly-only — a costed follow-up), and this bench's class-scenario numbers pre-fix are void (re-baseline the first time a committed baseline covers it; theguardrails-presubset excludes it, so no collision).regression-budget.jsongains rows for the new bench; theworkspace_reconcileparity test stays green.