-
Notifications
You must be signed in to change notification settings - Fork 1
feat(warp-core): TTD domain logic — provenance storage + causal cone walk #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e2ee2c0
feat(warp-core): wire up TTD domain logic (provenance storage + publi…
flyingrobots ef9f0b0
feat(warp-core): implement causal cone walk for atom_history (Paper I…
flyingrobots df6db8e
fix(warp-core): preserve within-tick write order in atom_history
flyingrobots 313f38c
Merge branch 'main' into feat/ttd-domain-logic
flyingrobots 11a024e
test(echo-dind-harness): golden-vector coverage for TTD digest surface
flyingrobots 7841fb9
Merge branch 'feat/ttd-domain-logic' of github.com:flyingrobots/echo …
flyingrobots bffbef0
fix(warp-core): accurate CHANGELOG wording + debug assertion for out_…
flyingrobots e967564
fix(warp-core): accurate atom_history rustdoc + safe tick cast in ato…
flyingrobots c8fef40
fix(warp-core): validate AtomWrite.tick + non-uniform golden vectors
flyingrobots 7b1241e
test(warp-core): add SlotId::Node(atom) regression test for atom_history
flyingrobots File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
142 changes: 142 additions & 0 deletions
142
crates/echo-dind-harness/tests/digest_golden_vectors.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // © James Ross Ω FLYING•ROBOTS <https://github.com/flyingrobots> | ||
| #![allow(clippy::unwrap_used)] | ||
| //! Golden-vector tests for the TTD digest public API surface. | ||
| //! | ||
| //! These tests exercise `compute_emissions_digest`, `compute_op_emission_index_digest`, | ||
| //! and `compute_tick_commit_hash_v2` through warp-core's **crate-root re-exports** — | ||
| //! not via internal module paths. If a re-export is removed or a wire format changes, | ||
| //! these tests catch it. | ||
| //! | ||
| //! Each function is pinned to a known-good hash. The full chain is then exercised: | ||
| //! emissions → op-emission-index → tick-commit, so drift in any layer is detected. | ||
|
|
||
| use warp_core::materialization::{make_channel_id, FinalizedChannel}; | ||
| use warp_core::{ | ||
| compute_emissions_digest, compute_op_emission_index_digest, compute_tick_commit_hash_v2, | ||
| OpEmissionEntry, WorldlineId, | ||
| }; | ||
|
|
||
| // ─── Test vectors ──────────────────────────────────────────────────────────── | ||
|
|
||
| /// Creates a 32-byte hash where every byte position is distinguishable. | ||
| /// This catches serializer bugs that drop, reorder, or endian-flip tail bytes | ||
| /// (a uniform [n, 0, 0, ...] fixture would mask such issues). | ||
| fn make_hash(seed: u8) -> [u8; 32] { | ||
| #[expect(clippy::cast_possible_truncation, reason = "i ∈ 0..32, fits in u8")] | ||
| core::array::from_fn(|i| seed.wrapping_add((i as u8).wrapping_mul(17))) | ||
| } | ||
|
|
||
| // ─── compute_emissions_digest ──────────────────────────────────────────────── | ||
|
|
||
| #[test] | ||
| fn emissions_digest_golden_vector() { | ||
| let ch_a = make_channel_id("alpha"); | ||
| let ch_b = make_channel_id("beta"); | ||
|
|
||
| let channels = vec![ | ||
| FinalizedChannel { | ||
| channel: ch_a, | ||
| data: vec![1, 2, 3], | ||
| }, | ||
| FinalizedChannel { | ||
| channel: ch_b, | ||
| data: vec![4, 5], | ||
| }, | ||
| ]; | ||
|
|
||
| let digest = compute_emissions_digest(&channels); | ||
| let hex = hex::encode(digest); | ||
|
|
||
| // Pinned golden value. If this changes, the emissions wire format changed. | ||
| assert_eq!( | ||
| hex, "9cd163d40fd2b8b089c5bed80c328ffc5695926cdbe2aaf1a99c83adf0bbe2ea", | ||
| "emissions_digest golden vector mismatch — wire format may have changed!\nactual: {hex}" | ||
| ); | ||
| } | ||
|
|
||
| // ─── compute_op_emission_index_digest ──────────────────────────────────────── | ||
|
|
||
| #[test] | ||
| fn op_emission_index_digest_golden_vector() { | ||
| let ch_a = make_channel_id("alpha"); | ||
| let ch_b = make_channel_id("beta"); | ||
|
|
||
| let entries = vec![ | ||
| OpEmissionEntry { | ||
| op_id: make_hash(0xAA), | ||
| channels: vec![ch_a, ch_b], | ||
| }, | ||
| OpEmissionEntry { | ||
| op_id: make_hash(0xBB), | ||
| channels: vec![ch_a], | ||
| }, | ||
| ]; | ||
|
|
||
| let digest = compute_op_emission_index_digest(&entries); | ||
| let hex = hex::encode(digest); | ||
|
|
||
| // Pinned golden value. If this changes, the op-emission-index wire format changed. | ||
| assert_eq!( | ||
| hex, "cbb1f5f73d0b5da137b0bde7b7d242fb44b8b6d0f5d4f8391105b6c36aa7a974", | ||
| "op_emission_index_digest golden vector mismatch — wire format may have changed!\nactual: {hex}" | ||
| ); | ||
| } | ||
|
|
||
| // ─── compute_tick_commit_hash_v2 (full chain) ──────────────────────────────── | ||
|
|
||
| #[test] | ||
| fn tick_commit_hash_v2_full_chain_golden_vector() { | ||
| // Build the hash chain: emissions → op-emission-index → tick-commit. | ||
| // This exercises the full TTD provenance digest surface end-to-end. | ||
|
|
||
| let ch_a = make_channel_id("alpha"); | ||
| let ch_b = make_channel_id("beta"); | ||
|
|
||
| // Step 1: Compute emissions digest | ||
| let channels = vec![ | ||
| FinalizedChannel { | ||
| channel: ch_a, | ||
| data: vec![1, 2, 3], | ||
| }, | ||
| FinalizedChannel { | ||
| channel: ch_b, | ||
| data: vec![4, 5], | ||
| }, | ||
| ]; | ||
| let emissions_digest = compute_emissions_digest(&channels); | ||
|
|
||
| // Step 2: Compute op-emission-index digest | ||
| let entries = vec![OpEmissionEntry { | ||
| op_id: make_hash(0xAA), | ||
| channels: vec![ch_a, ch_b], | ||
| }]; | ||
| let op_emission_index_digest = compute_op_emission_index_digest(&entries); | ||
|
|
||
| // Step 3: Compute tick commit hash using the above digests | ||
| let schema_hash = make_hash(0xAB); | ||
| let worldline_id = WorldlineId(make_hash(0xCD)); | ||
| let tick = 42u64; | ||
| let parent = make_hash(0x11); | ||
| let patch_digest = make_hash(0x22); | ||
| let state_root = make_hash(0x33); | ||
|
|
||
| let commit_hash = compute_tick_commit_hash_v2( | ||
| &schema_hash, | ||
| &worldline_id, | ||
| tick, | ||
| &[parent], | ||
| &patch_digest, | ||
| Some(&state_root), | ||
| &emissions_digest, | ||
| Some(&op_emission_index_digest), | ||
| ); | ||
| let hex = hex::encode(commit_hash); | ||
|
|
||
| // Pinned golden value for the full chain. If this changes, any layer's | ||
| // wire format may have changed — check individual tests above to isolate. | ||
| assert_eq!( | ||
| hex, "8a769a8d8dd847be4ff546f1214a44d49446f05a0a10450b5d0ec21bd68613e9", | ||
| "tick_commit_hash_v2 full-chain golden vector mismatch!\nactual: {hex}" | ||
| ); | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.