-
Notifications
You must be signed in to change notification settings - Fork 3
feat: integrate Tier 6 distributed monad into build and add tests #508
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
6627908
7e7f82a
832b7b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||||
| #include <cassert> | ||||||||||||||
| #include <iostream> | ||||||||||||||
| #include <vector> | ||||||||||||||
|
|
||||||||||||||
| #include "t81/experimental/cog/tier6/distributed_monad.hpp" | ||||||||||||||
| #include "t81/tracing/canonhash.hpp" | ||||||||||||||
|
|
||||||||||||||
| using namespace t81::cog::v6; | ||||||||||||||
|
|
||||||||||||||
| void test_empty_mesh() { | ||||||||||||||
| MeshReflector reflector; | ||||||||||||||
| std::vector<MonadState> monads; | ||||||||||||||
|
|
||||||||||||||
| auto result = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(result.converged); | ||||||||||||||
| assert(result.convergence_hash == "EMPTY_MESH"); | ||||||||||||||
| assert(result.iterations == 0); | ||||||||||||||
| std::cout << "Empty mesh test passed.\n"; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| void test_mesh_reflection_convergence() { | ||||||||||||||
| MeshReflector reflector; | ||||||||||||||
| std::vector<MonadState> monads; | ||||||||||||||
|
|
||||||||||||||
| MonadState m1; | ||||||||||||||
| m1.address.node_hash = t81::hash::hash_string("hash1"); | ||||||||||||||
| m1.label = "node1"; | ||||||||||||||
|
|
||||||||||||||
| MonadState m2; | ||||||||||||||
| m2.address.node_hash = t81::hash::hash_string("hash2"); | ||||||||||||||
| m2.label = "node2"; | ||||||||||||||
|
|
||||||||||||||
| m1.peers.push_back(m2.address); | ||||||||||||||
| m2.peers.push_back(m1.address); | ||||||||||||||
|
|
||||||||||||||
| monads.push_back(m1); | ||||||||||||||
| monads.push_back(m2); | ||||||||||||||
|
|
||||||||||||||
| auto result = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(!result.converged); | ||||||||||||||
| assert(result.iterations == 1); | ||||||||||||||
| assert(monads[0].label == "node1+node2"); | ||||||||||||||
| assert(monads[1].label == "node2+node1"); | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These assertions assume each monad reflects against a snapshot of pre-round labels, but Useful? React with 👍 / 👎. |
||||||||||||||
| assert(monads[0].reflection_depth == 1); | ||||||||||||||
|
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Tracing the first call:
So the assertion on line 43 The test correctly encodes the intended synchronous (Jacobi) semantics — each monad should see the pre-round labels of its peers. The implementation needs to snapshot all labels before the loop. This is a bug in the existing |
||||||||||||||
| assert(monads[1].reflection_depth == 1); | ||||||||||||||
|
|
||||||||||||||
| auto result2 = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(!result2.converged); | ||||||||||||||
| assert(result2.iterations == 1); | ||||||||||||||
| assert(monads[0].label == "node1+node2+node2+node1"); | ||||||||||||||
| assert(monads[1].label == "node2+node1+node1+node2"); | ||||||||||||||
|
|
||||||||||||||
| std::cout << "Mesh reflection test passed.\n"; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| void test_entropy_containment() { | ||||||||||||||
| MeshReflector reflector(2); // Set max depth to 2 | ||||||||||||||
| std::vector<MonadState> monads; | ||||||||||||||
|
|
||||||||||||||
| MonadState m1; | ||||||||||||||
| m1.address.node_hash = t81::hash::hash_string("hash1"); | ||||||||||||||
| m1.label = "node1"; | ||||||||||||||
|
|
||||||||||||||
| MonadState m2; | ||||||||||||||
| m2.address.node_hash = t81::hash::hash_string("hash2"); | ||||||||||||||
| m2.label = "node2"; | ||||||||||||||
|
|
||||||||||||||
| m1.peers.push_back(m2.address); | ||||||||||||||
| m2.peers.push_back(m1.address); | ||||||||||||||
|
|
||||||||||||||
| monads.push_back(m1); | ||||||||||||||
| monads.push_back(m2); | ||||||||||||||
|
|
||||||||||||||
| auto r1 = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(!r1.converged); | ||||||||||||||
| assert(monads[0].entropy_contained); | ||||||||||||||
|
|
||||||||||||||
| auto r2 = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(!r2.converged); | ||||||||||||||
| assert(!monads[0].entropy_contained); | ||||||||||||||
| assert(!monads[1].entropy_contained); | ||||||||||||||
|
|
||||||||||||||
| auto r3 = reflector.mesh_reflect(monads); | ||||||||||||||
| assert(!r3.converged); | ||||||||||||||
| assert(r3.convergence_hash == "ENTROPY_VIOLATION"); | ||||||||||||||
|
|
||||||||||||||
| std::cout << "Entropy containment test passed.\n"; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| int main() { | ||||||||||||||
| test_empty_mesh(); | ||||||||||||||
| test_mesh_reflection_convergence(); | ||||||||||||||
| test_entropy_containment(); | ||||||||||||||
| std::cout << "All tier 6 tests passed.\n"; | ||||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t81_tracinglink dependencyt81_tracingis declared as anOBJECTlibrary (line 195) and its objects are already compiled directly intot81_coreviatarget_sources(t81_core PRIVATE $<TARGET_OBJECTS:t81_tracing>)(line 202). Listing it again here is redundant — the symbols are already present throught81_core. Compare with the analogoust81_tier5_testtarget which links onlyt81_core t81_experimental.