Skip to content

Fix historical sliding window semantics - #25

Merged
argahsuknesib merged 3 commits into
mainfrom
fix/historical-bounds-storage-recovery
Sep 10, 2026
Merged

Fix historical sliding window semantics#25
argahsuknesib merged 3 commits into
mainfrom
fix/historical-bounds-storage-recovery

Conversation

@argahsuknesib

@argahsuknesib argahsuknesib commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Aligns Janus historical sliding-window execution with the Janus-QL specification.

Historical sliding windows now resolve as:

[T - OFFSET, T - OFFSET + RANGE)

instead of:

[T - OFFSET - RANGE, T - OFFSET)

Changes

  • update historical sliding-bound resolution
  • use checked arithmetic for temporal bounds
  • preserve RANGE <= OFFSET validation
  • preserve fixed historical-window behavior
  • align historical executor and storage access paths
  • align materialized-subquery, baseline, API, and benchmark paths
  • update documentation and comments
  • update public-spec, parser, API, executor, and storage tests
  • add explicit half-open interval and boundary tests

Semantics

At evaluation instant T:

start = T - OFFSET
end   = T - OFFSET + RANGE

Therefore:

HistoricalSliding(T) =
[T - OFFSET, T - OFFSET + RANGE)

RANGE <= OFFSET ensures that the historical interval does not extend beyond T.

Verification

The following checks pass:

cargo fmt --check
cargo test
cargo check --benches
cargo clippy --all-targets --all-features -- -D warnings

@argahsuknesib argahsuknesib changed the title fix: correct historical bounds and segmented storage recovery Fix historical sliding window semantics Sep 10, 2026
@argahsuknesib
argahsuknesib requested a lite review from Copilot September 10, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 keeps RANGE <= OFFSET validation.
  • 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.

@argahsuknesib
argahsuknesib merged commit 0a490a0 into main Sep 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants