Repository navigation
test(remote): rerun the lean-lane measurement on a real nats-server - #856
Merged
Merged
Conversation
The received-bytes harness ran on an in-process FakeNats: real E2EE, real bridge, real client — but not a real broker process. Give the harness a Broker choice and rerun the same measurement through `nats-server` on a loopback port, so the numbers are witnessed by the server that production would use. Subscriptions are now synchronised with a publish/subscribe echo instead of Client::flush(): flush only proves the bytes left this process, while the server handles one connection's commands in order, so the echo of a publish sent after the SUB proves registration. Without that, a publish could overtake the SUB and be dropped (reproduced: ~1 fixture run in 5 stalled on its first message). When the script passes VERIFY_E2E_NATS_MONITOR, the test also snapshots the server's own /connz counters for the phone connection before and after the measured traffic and asserts the window delta equals what the harness received and decrypted — a broker-side witness for every payload byte. scripts/measure/verify-e2e-bytes.py (the post-#847 location) starts the server, prints its version and launch command, runs both brokers and compares the decoded results. It now also fails on a non-zero test exit code: a panic after the result markers were printed looked like a pass.
# Conflicts: # desktop/src-tauri/src/remote/verify_e2e.rs # scripts/measure/verify-e2e-bytes.py
The real-broker accounting compared the server's `/connz` delta for the phone
connection against what the harness received and decrypted, and asserted they
were equal. They are not, and my reruns failed deterministically by exactly
32 bytes and 2 messages:
left: 72696018 (server out_bytes) right: 72695986 (decrypted)
left: 176880 (server out_msgs) right: 176878 (received)
The cause is this harness's own subscription-readiness probe, not the
transport: `await_subscription` subscribes to `{pattern}.verify-sub-probe` on
the **phone** connection and publishes `"verify-sub-probe"` (16 bytes) to it,
and `replay_live_lane` runs twice per measurement. That is 2 messages and
2 x 16 = 32 bytes the server counts and the harness does not.
Rather than loosen the assertion to a tolerance — which would stop it
catching the thing it exists to catch — the probe now reports its payload size
and the accounting subtracts it, so the comparison stays an **exact**
equality. Per-message framing or header inflation would still fail it.
The measurement itself is unaffected and reproduces: real broker and the
in-process fake agree byte-for-byte (`liveEqual: true, historyEqual: true`),
and the real-broker fixture numbers are identical to the fake's.
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.
Follows #854, which replaced the plaintext-tap model with a measurement of what a phone actually receives and decrypts. Its broker was the in-process
FakeNats; this runs the same measurement against a realnats-serverprocess (v2.15.0, randomly chosen port, loopback TCP).Result: the fake was not flattering us
--broker bothruns both and compares:fakeLiveandrealLiveare identical field for field — live lane declared/undeclared messages, wire bytes and plaintext bytes; history full and paged. So every number in #854's report holds on a real broker, and the replayed fixture agrees too (live 1415/1195/5, 2031/1723/7; history 14305/550/14311/556).The server's own accounting, cross-checked
The strongest evidence that NATS adds nothing on this leg is not our own count but the server's:
/connzreports what it relayed to the phone connection, and that is compared against what the harness received and decrypted.That comparison initially failed, deterministically, and finding out why was the useful part:
My first guess — client-consumed control frames — was wrong. The cause is this harness's own subscription-readiness probe:
await_subscriptionsubscribes to{pattern}.verify-sub-probeon the phone connection and publishes"verify-sub-probe"(16 bytes) to it, andreplay_live_laneruns twice per measurement. Two messages, 2 × 16 = 32 bytes, counted by the server and not by the harness.The probe now reports its payload size and the accounting subtracts it, so the comparison stays an exact equality instead of acquiring a tolerance — a tolerance would have stopped catching per-message framing or header inflation, which is precisely what this check exists to detect.
Also in this branch
Two fixes to the measurement tooling, both found by running it for real:
async_nats::Client::flush()proves the bytes left this process, not that the server processed theSUB. On a real broker the subsequentPUBfrom another connection can overtake it and the event is silently dropped — one run in eight waited 30s and timed out. Replaced with a same-connection publish/subscribe echo: the server handles one connection's commands in order, so the echo proves registration. 8/8 stable since.Scope
Real E2EE, real bridge, real subscribe-and-decrypt, real broker. The agent hop is still
MockPlatform/MockAgent, and the journal and history pages are still read read-only from the realagent.dband a live agent via grpcurl. Thewire == plaintext + HEADER(28) + TAG(16)andFRE2assertions are unchanged from #854.Verification
I reran the broker measurement myself rather than taking the report's word: the byte-equality claim in the accompanying note did not hold and is what led to the accounting fix above. After it,
--broker realexits 0 and--broker bothreports both equalities — reproduced twice.cargo fmt --checkandcargo clippy --all-targets -D warningsclean on pinned 1.97; the fixture test (verify_e2e_lean_lane_real_crypto_round_trip) passes, and the three broker-dependent tests stay#[ignore]d so CI needs no server.