research(nightly): signed-receipt batch-fill latency — bounded hybrid scheduling (ADR-341) - #952
Draft
ruvnet wants to merge 3 commits into
Draft
research(nightly): signed-receipt batch-fill latency — bounded hybrid scheduling (ADR-341)#952ruvnet wants to merge 3 commits into
ruvnet wants to merge 3 commits into
Conversation
Adds BatchFillPolicy/BatchScheduler for deciding when a signed-receipt batch closes (fixed-size-only or size-or-timeout hybrid), with unit tests, extending ADR-340's signed anchoring without modifying it. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01DYBHRF7WVzMyTRpe9Fo4qd
Records the design decision, threat model, evidence summary, and rejection criteria for the bounded batch-fill scheduling policy added in the prior commit. Regenerates the ADR index via scripts/adr-index.mjs. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01DYBHRF7WVzMyTRpe9Fo4qd
Real, reproduced-3x discrete-event simulation evidence turning ADR-340's CPU-only signing-amortization result into an end-to-end receipt- availability latency claim: fixed-size-only batching's p99 latency is unbounded under light load (756ms measured) while a bounded size-or- timeout hybrid policy stays within its configured bound (50ms) at every tested regime, at negligible amortization cost under sufficient load. Includes raw per-run output and a standalone gist write-up. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01DYBHRF7WVzMyTRpe9Fo4qd
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.
Summary
MerkleReceiptroots and explicitly left wall-clock batch-fill latency unmeasured — its own "Next Research" item Implement Ruvector high-performance vector database #1. This PR implements that direct follow-up.BatchFillPolicy/BatchScheduler(crates/ruvector-retrieval-receipt/src/batch_fill.rs): a pure, clock-free scheduling module deciding when a batch of pending receipt roots closes — either fixed-size-only, or a hybrid policy that also closes on a fill-timeout.bin/batch_latency.rs) that drives real Poisson/bursty query-arrival timelines through the real production search + receipt-generation path, and performs realIssuer::sign_root/BatchAnchorsigning (timed withInstant, not estimated) whenever a batch closes, to measure genuine end-to-end receipt-availability latency.signing.rs,receipt.rs,index.rsuntouched); all 23 pre-existing tests plus 7 new tests (30 total) pass.Hypothesis & Result
Fixed-size-only batching (B=32) has unbounded tail latency under light load — measured p99 of 756ms, reproduced identically across 3 runs, at a modest 50 queries/second arrival rate. A hybrid policy (B=32, 50ms fill-timeout) bounds p99 latency to 50.03ms at that same load, while preserving full amortization at target load (1000 q/s) where the timeout essentially never fires.
ACCEPTANCE RESULT: ACCEPT — all 4 pre-registered acceptance thresholds passed in all 3 independent runs (100% batch verification; hybrid p99 ≤ 70ms bound at all 3 regimes; fixed-size-only p99 > 2× hybrid's at light load; hybrid amortized signing cost within 2× of fixed-size-only's at target load).
Benchmark command
Raw output for 3 independent runs:
docs/research/nightly/2026-09-01-signed-receipt-batch-fill-latency/raw-runs.txt.Darwin
Not executed this cycle.
max_wait_ns = 50mswas chosen analytically (between the target- and light-load fill times), not evolved — noted as a legitimate future Darwin candidate in the ADR.Flywheel / evidence retention
The nightly report's own "Next Research" section carries forward 5 concrete follow-ups (real-traffic re-derivation of the timeout, signer-throughput breakdown point, adaptive batch-size policy, BLS aggregate signatures, WASM measurement) for a future run to pick up, continuing the same evidence chain this run started from.
Security review
batch_fillcontains no cryptography; the simulation reuses ADR-340's existingIssuer/BatchAnchor/verify_rootAPI unmodified.Main limitations
max_wait_ns = 50msdemonstrates the mechanism, it is not a recommended default.Production recommendation
Not promoted to any default path. Production adoption of
BatchFillPolicy::hybridrequires re-derivingmax_wait_nsfrom real traffic traces and validating the single-signer assumption at the deployment's actual peak rate — both listed as open Rejection Criteria in ADR-341.Docs in this PR
docs/adr/ADR-341-signed-receipt-batch-fill-latency-simulation.md(+ regenerateddocs/adr/INDEX.md)docs/research/nightly/2026-09-01-signed-receipt-batch-fill-latency/README.mddocs/research/nightly/2026-09-01-signed-receipt-batch-fill-latency/gist.mdTest plan
cargo build --release -p ruvector-retrieval-receiptcargo test --release -p ruvector-retrieval-receipt(30/30 passing, 7 new)cargo clippy --release -p ruvector-retrieval-receipt --all-targets -- -D warnings(clean)cargo fmt -p ruvector-retrieval-receipt -- --check(clean)cargo run --release -p ruvector-retrieval-receipt --bin batch_latency× 3 (reproducible ACCEPT)cargo run --release -p ruvector-retrieval-receipt --bin benchmark(ADR-304/ADR-340 regression check — unchanged, ACCEPT)Co-Authored-By: claude-flow ruv@ruv.net
Claude-Session: https://claude.ai/code/session_01DYBHRF7WVzMyTRpe9Fo4qd
Generated by Claude Code