Repository navigation
fix: one current valid-time window per (e, a, v) (#435) - #460
Merged
Merged
Conversation
At transaction time N a triple now has exactly one current valid-time window: the one from its latest assertion at or before N, if newer than its last retraction. A later assertion replaces the earlier window, which stays visible through :as-of. Closing, extending or reopening a window is a plain transact with the new bounds; retract still withdraws the triple. net_asserted_facts now picks a winner per (e, a, v) instead of per (e, a, v, vf, vt), and the on-disk key walk stops at each triple's first transaction group. Two windows of one triple in one transaction are rejected with the new API-011 before a tx_count is taken (execute, WriteTransaction::commit, the browser write path, FactStorage::transact*). Records written before the check with two windows in one transaction keep both; open, WAL replay and migration never fail on them. This changes query results for existing data, so it ships in v3.0.0. Design: docs/superpowers/specs/2026-10-06-one-window-per-triple-design.md Refs #435, #383 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
8000
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Refs #435 (tracker #383). Targets
v3; no file format change, but query results change for existing data (v3.0.0 behaviour change).Model
At transaction time N each
(e, a, v)has exactly one current valid-time window: the one from its latest assertion withtx_count ≤ N, if that is newer than its last retraction. A later assertion replaces the earlier window; the earlier one stays visible through:as-of. Closing, extending or reopening a window is a plaintransactwith the new bounds (noclosecommand).retractstill withdraws the triple.[2020, 2022), tx 2[2024, ∞)):as-of 1 :valid-at "2021-01-01":as-of 2 :valid-at "2021-01-01":as-of 2 :valid-at "2025-01-01"Changes
net_asserted_facts: winner per(e, a, v)bytx_count, with atiedflag; only tied triples (pre-check data) take a second pass. Still idempotent under duplicates, still uses the keyed hasher.OnDiskReader::live_scan: the first transaction group of a triple at or beforeas_ofdecides it; everything older is skipped (existing seek after 8). Per-triple window set removed.ERROR_REFERENCE.md): two different windows for one triple in one transaction are rejected before atx_countis allocated or the WAL is written. This coversMinigraf::execute,WriteTransaction::commit, the browser write path andFactStorage::transact*. Identical repeats, other values and retractions are allowed.Tests
tx_count.as_of, before and after reopen. I checked that it fails on the old per-window walk.tests/valid_time_window_test.rs(8 tests): the issue's table, close, extend/reopen, retract-then-reassert, API-011 fromtransactandWriteTransaction. Each runs in memory, checkpointed and reopened, via EAVT and AEVT.bitemporal_test::test_same_eav_later_valid_time_interval_replaces_earlierandmulti_value_test::multi_value_time_stints_…. Both encoded the old two-live-windows behaviour.same_transaction_multi_window_matches_full_scanand the golden corpus pass unchanged.Local:
cargo fmt --check,cargo clippy --all-features -D warnings,cargo check --target wasm32-unknown-unknown --features browser,cargo test→ 1258 passed, 0 failed, 9 ignored (1267 total).Follow-ups (not in this PR)
transact).🤖 Generated with Claude Code
https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn