Skip to content

Commit 327c493

Browse files
hyperpolymathclaude
andcommitted
fix(p3): update stale Rust API consumers + fix KRaft flaky tests
- integration_test.rs: port to current OctadStore API (SimpleGraphStore, InMemoryProvenanceStore, InMemorySpatialStore, ConcreteOctadStore type alias, snapshot.embedding, OctadConfig::default(), two-arg search_similar) - modality_benchmarks.rs: same API migration; add provenance/spatial Arc args to both InMemoryOctadStore::new() calls; OxiGraphStore → SimpleGraphStore - kraft_node_test.exs: replace fixed Process.sleep assertions in two remove_server tests with poll_until/3 helper (polls every 50 ms, 2 s timeout) — eliminates pre-existing timeout failures under CI load Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 15b19cc commit 327c493

4 files changed

Lines changed: 227 additions & 155 deletions

File tree

.machine_readable/6a2/STATE.a2ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
[metadata]
77
project = "nextgen-databases"
88
version = "0.1.0"
9-
last-updated = "2026-04-11"
9+
last-updated = "2026-04-12"
1010
status = "active"
1111

1212
[project-context]
1313
name = "nextgen-databases"
14-
completion-percentage = 55
15-
phase = "Phase 5 — Tropical Consonance + KRL Integration (P2 DONE)"
14+
completion-percentage = 62
15+
phase = "Phase 5 — Tropical Consonance + KRL Integration (P2 + P3 DONE)"
1616

1717
[current-position]
18-
milestone = "verisim-modular-experiment tropical bridge v0.2 + bellman_ford proved"
19-
last-session = "2026-04-11"
20-
last-action = "P2: Tropical_Determinants.thy (sorry-free), TropicalDeterminant.jl, ProofOptimalAssignment VCL clause + 6 tests"
18+
milestone = "verisim-modular-experiment tropical bridge v0.2 + bellman_ford proved + P3 API fixes"
19+
last-session = "2026-04-12"
20+
last-action = "P3: integration_test.rs + modality_benchmarks.rs updated to current API; KRaft remove_server flaky tests fixed with poll_until helper"
2121

2222
[tropical-bridge]
2323
status = "v0.2 — RI + RII live, RIII stub (KnotTheory.jl r3_simplify is no-op)"
@@ -47,13 +47,13 @@ cargo-bench-compile = "PASS (throughput_benchmarks.rs — no errors, no warnings
4747
gleam-smoke = "Written; requires compiled lith_nif.so to run connection/lifecycle tests"
4848

4949
[blockers]
50-
- "Integration test (tests/integration_test.rs) uses old API — does not compile (pre-existing)"
51-
- "modality_benchmarks.rs uses old API — does not compile (pre-existing)"
50+
- "KRaft remove_server tests: timing-sensitive — mitigated with poll_until helper (was pre-existing timeout failure)"
5251

5352
[route-to-mvp]
54-
next = "Update integration_test.rs to current API"
55-
then = "Update modality_benchmarks.rs to current API"
53+
next = "Promote verisim-modular-experiment impl/ to shippable verisim-core package"
54+
then = "Wire RIII neighbors when KnotTheory.jl gains live r3_simplify"
5655

5756
[critical-next-actions]
58-
1 = "Update integration_test.rs to current API"
59-
2 = "Update modality_benchmarks.rs to current API"
57+
1 = "Promote impl/ to shippable verisim-core package"
58+
2 = "Wire _riii_neighbors when KnotTheory.jl gains live r3_simplify"
59+
3 = "Zig FFI port of VerisimCore per hyperpolymath standard"

verisimdb/benches/modality_benchmarks.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ use tokio::runtime::Runtime;
88

99
use verisim_document::{Document, DocumentStore, TantivyDocumentStore};
1010
use verisim_drift::{DriftDetector, DriftThresholds, DriftType};
11-
use verisim_graph::{GraphEdge, GraphNode, GraphObject, GraphStore, OxiGraphStore};
11+
use verisim_graph::{GraphEdge, GraphNode, GraphObject, GraphStore, SimpleGraphStore};
1212
use verisim_octad::{
1313
OctadConfig, OctadDocumentInput, OctadId, OctadInput, OctadSnapshot, OctadStore,
1414
OctadVectorInput, OctadSemanticInput, InMemoryOctadStore,
1515
};
16+
use verisim_provenance::InMemoryProvenanceStore;
1617
use verisim_semantic::{
1718
InMemorySemanticStore, ProofBlob, ProofType, SemanticStore, SemanticType,
1819
};
20+
use verisim_spatial::InMemorySpatialStore;
1921
use verisim_temporal::{InMemoryVersionStore, TemporalStore};
2022
use verisim_tensor::{InMemoryTensorStore, ReduceOp, Tensor, TensorStore};
2123
use verisim_vector::{DistanceMetric, Embedding, HnswConfig, HnswVectorStore, VectorStore};
@@ -142,7 +144,7 @@ fn bench_graph_operations(c: &mut Criterion) {
142144
let mut group = c.benchmark_group("graph");
143145

144146
group.bench_function("insert_edge", |b| {
145-
let store = OxiGraphStore::in_memory().unwrap();
147+
let store = SimpleGraphStore::in_memory().unwrap();
146148
let mut counter = 0u64;
147149

148150
b.to_async(&rt).iter(|| {
@@ -160,7 +162,7 @@ fn bench_graph_operations(c: &mut Criterion) {
160162
});
161163

162164
// Pre-populate for query benchmark
163-
let query_store = OxiGraphStore::in_memory().unwrap();
165+
let query_store = SimpleGraphStore::in_memory().unwrap();
164166
let query_node = GraphNode::new("https://example.org/hub");
165167
rt.block_on(async {
166168
for i in 0..100 {
@@ -190,12 +192,14 @@ fn bench_octad_operations(c: &mut Criterion) {
190192
let rt = Runtime::new().unwrap();
191193
let mut group = c.benchmark_group("octad");
192194

193-
let graph_store = Arc::new(OxiGraphStore::in_memory().unwrap());
194-
let vector_store = Arc::new(HnswVectorStore::new(384, DistanceMetric::Cosine, HnswConfig::default()));
195-
let document_store = Arc::new(TantivyDocumentStore::in_memory().unwrap());
196-
let tensor_store = Arc::new(InMemoryTensorStore::new());
197-
let semantic_store = Arc::new(InMemorySemanticStore::new());
195+
let graph_store = Arc::new(SimpleGraphStore::in_memory().unwrap());
196+
let vector_store = Arc::new(HnswVectorStore::new(384, DistanceMetric::Cosine, HnswConfig::default()));
197+
let document_store = Arc::new(TantivyDocumentStore::in_memory().unwrap());
198+
let tensor_store = Arc::new(InMemoryTensorStore::new());
199+
let semantic_store = Arc::new(InMemorySemanticStore::new());
198200
let temporal_store: Arc<InMemoryVersionStore<OctadSnapshot>> = Arc::new(InMemoryVersionStore::new());
201+
let provenance_store = Arc::new(InMemoryProvenanceStore::new());
202+
let spatial_store = Arc::new(InMemorySpatialStore::new());
199203

200204
let config = OctadConfig::default();
201205

@@ -207,6 +211,8 @@ fn bench_octad_operations(c: &mut Criterion) {
207211
tensor_store,
208212
semantic_store,
209213
temporal_store,
214+
provenance_store,
215+
spatial_store,
210216
);
211217

212218
group.bench_function("create_octad", |b| {
@@ -300,12 +306,14 @@ fn bench_cross_modal_query(c: &mut Criterion) {
300306
let rt = Runtime::new().unwrap();
301307
let mut group = c.benchmark_group("cross_modal");
302308

303-
let graph_store = Arc::new(OxiGraphStore::in_memory().unwrap());
304-
let vector_store = Arc::new(HnswVectorStore::new(384, DistanceMetric::Cosine, HnswConfig::default()));
305-
let document_store = Arc::new(TantivyDocumentStore::in_memory().unwrap());
306-
let tensor_store = Arc::new(InMemoryTensorStore::new());
307-
let semantic_store = Arc::new(InMemorySemanticStore::new());
309+
let graph_store = Arc::new(SimpleGraphStore::in_memory().unwrap());
310+
let vector_store = Arc::new(HnswVectorStore::new(384, DistanceMetric::Cosine, HnswConfig::default()));
311+
let document_store = Arc::new(TantivyDocumentStore::in_memory().unwrap());
312+
let tensor_store = Arc::new(InMemoryTensorStore::new());
313+
let semantic_store = Arc::new(InMemorySemanticStore::new());
308314
let temporal_store: Arc<InMemoryVersionStore<OctadSnapshot>> = Arc::new(InMemoryVersionStore::new());
315+
let provenance_store = Arc::new(InMemoryProvenanceStore::new());
316+
let spatial_store = Arc::new(InMemorySpatialStore::new());
309317

310318
let config = OctadConfig::default();
311319

@@ -317,6 +325,8 @@ fn bench_cross_modal_query(c: &mut Criterion) {
317325
tensor_store,
318326
semantic_store,
319327
temporal_store,
328+
provenance_store,
329+
spatial_store,
320330
);
321331

322332
// Create 1000 octads with multiple modalities

verisimdb/elixir-orchestration/test/verisim/consensus/kraft_node_test.exs

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ defmodule VeriSim.Consensus.KRaftNodeTest do
3434
:exit, _ -> :ok
3535
end
3636

37+
# Poll `fun` every `interval_ms` ms until it returns a truthy value, or
38+
# fail after `timeout_ms` ms have elapsed. Used for membership-change
39+
# assertions where the commit + apply cycle can be slower under CI load.
40+
defp poll_until(fun, timeout_ms \\ 2_000, interval_ms \\ 50) do
41+
deadline = System.monotonic_time(:millisecond) + timeout_ms
42+
43+
Enum.reduce_while(Stream.repeatedly(fn -> :poll end), nil, fn _, _acc ->
44+
if fun.() do
45+
{:halt, :ok}
46+
else
47+
remaining = deadline - System.monotonic_time(:millisecond)
48+
49+
if remaining <= 0 do
50+
{:halt, :timeout}
51+
else
52+
Process.sleep(min(interval_ms, remaining))
53+
{:cont, nil}
54+
end
55+
end
56+
end)
57+
end
58+
3759
describe "single-node leader election" do
3860
test "node with 0 peers becomes leader within 500ms" do
3961
node_id = "solo-#{System.unique_integer([:positive])}"
@@ -179,13 +201,24 @@ defmodule VeriSim.Consensus.KRaftNodeTest do
179201

180202
# Add then remove
181203
{:ok, _} = KRaftNode.add_server(node_id, "ephemeral-peer", [])
182-
Process.sleep(100)
204+
205+
# Wait for add to be committed before issuing remove
206+
:ok =
207+
poll_until(fn ->
208+
members = get_in(KRaftNode.registry(node_id), [:config, :members]) || []
209+
"ephemeral-peer" in members
210+
end)
211+
183212
{:ok, _} = KRaftNode.remove_server(node_id, "ephemeral-peer")
184-
Process.sleep(100)
185213

186-
registry = KRaftNode.registry(node_id)
187-
members = get_in(registry, [:config, :members]) || []
188-
refute "ephemeral-peer" in members
214+
# Poll until the commit + state-machine apply removes the member
215+
result =
216+
poll_until(fn ->
217+
members = get_in(KRaftNode.registry(node_id), [:config, :members]) || []
218+
"ephemeral-peer" not in members
219+
end)
220+
221+
assert result == :ok, "ephemeral-peer was not removed from registry within 2 s"
189222

190223
stop_kraft(pid)
191224
end
@@ -200,9 +233,20 @@ defmodule VeriSim.Consensus.KRaftNodeTest do
200233
leader_pid = start_kraft(leader_id, [follower_id])
201234
follower_pid = start_kraft(follower_id, [leader_id])
202235

203-
Process.sleep(1_000)
236+
# Poll until exactly one leader has been elected (up to 3 s under CI load)
237+
result =
238+
poll_until(
239+
fn ->
240+
roles = Enum.map([leader_id, follower_id], &KRaftNode.diagnostics(&1).role)
241+
Enum.count(roles, &(&1 == :leader)) == 1
242+
end,
243+
3_000,
244+
100
245+
)
246+
247+
assert result == :ok, "Cluster did not elect a leader within 3 s"
204248

205-
# Find which one is leader
249+
# Find which node is actually the leader
206250
leader_diag = KRaftNode.diagnostics(leader_id)
207251
{actual_leader, actual_follower, actual_follower_pid} =
208252
if leader_diag.role == :leader do
@@ -213,11 +257,19 @@ defmodule VeriSim.Consensus.KRaftNodeTest do
213257

214258
# Remove the follower via the leader
215259
{:ok, _} = KRaftNode.remove_server(actual_leader, actual_follower)
216-
Process.sleep(200)
217260

218-
# Leader's peer count should now be 0 (follower removed from peers)
219-
diag = KRaftNode.diagnostics(actual_leader)
220-
assert diag.peer_count == 0
261+
# Poll until the leader's peer list has been updated (commit + apply)
262+
remove_result =
263+
poll_until(
264+
fn ->
265+
KRaftNode.diagnostics(actual_leader).peer_count == 0
266+
end,
267+
2_000,
268+
50
269+
)
270+
271+
assert remove_result == :ok,
272+
"Leader peer_count did not drop to 0 within 2 s after remove_server"
221273

222274
stop_kraft(leader_pid)
223275
stop_kraft(follower_pid)

0 commit comments

Comments
 (0)