Fix historical sliding window semantics - #25
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core historical query semantics across parsing, execution, and storage boundary behavior, which is high-impact and warrants final human verification despite strong test updates.
Pull request overview
Updates Janus historical sliding-window execution to match the Janus-QL spec by resolving sliding historical bounds as a half-open interval anchored at T - OFFSET, and propagates that semantic through the executor, storage queries, API/baseline paths, docs, benchmarks, and tests.
Changes:
- Reworks historical sliding bound resolution to
[T - OFFSET, T - OFFSET + RANGE)using checked arithmetic and keepsRANGE <= OFFSETvalidation. - Introduces half-open query adapters (
query_half_open/query_rdf_half_open) and updates historical sliding executors/operators to use them while preserving inclusive fixed-window behavior. - Hardens storage durability and startup behavior around dictionary persistence (fail open when persisted segments exist but dictionary is missing/corrupt) and improves segment recovery metadata handling.
File summaries
| File | Description |
|---|---|
| tests/segmented_storage_regression_test.rs | Adds regression coverage for failing to open persisted segments without a valid dictionary. |
| tests/segmented_storage_error_test.rs | Ensures synchronous flush failures (dictionary persistence) don’t commit segments and preserve in-memory query visibility. |
| tests/public_spec_behavior_test.rs | Updates spec-facing tests and expected messaging to reflect the new sliding historical semantics. |
| tests/janusql_parser_test.rs | Aligns parser error expectation strings with updated validation messaging. |
| tests/janus_api_integration_test.rs | Aligns API registration validation test expectations with updated historical sliding error messaging. |
| tests/historical_window_bounds_test.rs | Expands historical bound tests, including boundary/half-open query behavior against storage. |
| tests/historical_sliding_window_test.rs | Updates test comments to reflect half-open interval semantics. |
| src/stream/operators/historical_sliding_window.rs | Uses resolve_historical_bounds + half-open storage querying for historical sliding iteration. |
| src/storage/segmented_storage/segment.rs | Makes dictionary durability precede segment commit, adds failed-flush restoration, and improves segment/index recovery metadata reading. |
| src/storage/segmented_storage/query.rs | Adds half-open query adapters while keeping the underlying inclusive query API for fixed ranges/point lookups. |
| src/storage/segmented_storage/mod.rs | Fails fast when persisted segments exist but the dictionary is missing or unreadable; adjusts flush() to rely on the new durability ordering. |
| src/storage/segmented_storage/background.rs | Ensures background flush persists dictionary before segment commit and reuses shared failed-flush restoration. |
| src/registry/baseline_registry.rs | Updates baseline test expectations to match shifted historical sliding window bounds. |
| src/parsing/janusql_parser/mod.rs | Updates historical sliding validation error message wording. |
| src/parsing/janusql_parser/ast.rs | Implements checked-arithmetic historical sliding bounds as [T - OFFSET, T - OFFSET + RANGE). |
| src/execution/historical_executor.rs | Aligns historical execution paths to use half-open queries for sliding windows and inclusive queries for fixed windows. |
| src/bin/hybrid_scaling_combined.rs | Updates benchmark/driver historical subquery path to use half-open RDF querying for sliding windows. |
| src/api/janus_api/tests.rs | Updates API tests to use half-open RDF queries for historical sliding windows. |
| src/api/janus_api/baseline.rs | Uses half-open executor path when baseline sources are historical sliding windows. |
| docs/WINDOW_TYPES_EXPLAINED.md | Updates documentation to describe the new half-open historical sliding window semantics. |
| docs/JANUSQL.md | Updates language spec documentation for historical sliding window bounds and rationale. |
| benches/historical_sliding.rs | Updates benchmark commentary to reflect the new covered scan range/window count under half-open semantics. |
Review details
- Files reviewed: 22/22 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns Janus historical sliding-window execution with the Janus-QL specification.
Historical sliding windows now resolve as:
instead of:
Changes
RANGE <= OFFSETvalidationSemantics
At evaluation instant
T:Therefore:
RANGE <= OFFSETensures that the historical interval does not extend beyondT.Verification
The following checks pass:
cargo fmt --check cargo test cargo check --benches cargo clippy --all-targets --all-features -- -D warnings