feat(retrieval-receipt): periodic index_state_root anchoring (ADR-341) - #959
feat(retrieval-receipt): periodic index_state_root anchoring (ADR-341)#959ruvnet wants to merge 4 commits into
Conversation
Implements ADR-341: independent, query-decoupled signing of index_state_root via a new AnchorPurpose::StateAnchor, reusing ADR-340's Ed25519 signing machinery unchanged. Lets an auditor authenticate a checkpoint of the index's state in O(1) without holding any specific query receipt or replaying the full write history. StateAnchorPolicy/StateAnchorLog/verify_state_anchor implement a write-count-based anchoring interval with an exact, disclosed staleness bound (interval_writes - 1), operating directly over WriteGate roots rather than any RetrievalIndex. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01KV63T53qpYkXYkAKXvfPXT
…cost table
Sweeps interval_writes in {1, 8, 32, 128, 512} over 5,000 writes, measuring
anchor count vs. the closed-form N/W prediction, exact staleness bound,
O(1) anchor-verify cost flatness, tamper detection, and amortized signing
cost. Adds a separate, explicitly non-gated verify_integrity O(n) scaling
table so the O(1) anchor-verify numbers are never read as a substitute for
full write-history integrity checking.
Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01KV63T53qpYkXYkAKXvfPXT
Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01KV63T53qpYkXYkAKXvfPXT
Research README, standalone gist, and raw 3-run benchmark output for the periodic index_state_root anchoring experiment (ADR-341), continuing the 2026-08-31 nightly run's named Next Research item. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01KV63T53qpYkXYkAKXvfPXT
|
CI status: every check has passed on this PR's head ( This is not caused by this PR's diff (2 small files in one experimental crate, This PR's own dedicated job, I'll trigger one re-run of the cancelled job to rule out a one-off scheduling issue, per the drive-to-green process; if it cancels again for the same reason I won't keep re-running it, since the evidence above indicates it's a pre-existing infra limit rather than something a re-run fixes. Generated by Claude Code Generated by Claude Code |
ruvnet
left a comment
There was a problem hiding this comment.
Dream exact-head review — INCONCLUSIVE
Frozen hypothesis: periodic signed state-root anchors reduce signing work by approximately the configured interval while bounding staleness to interval - 1, preserving tamper detection, and keeping verification effectively O(1).
The committed benchmark is falsifiable and promising: 5,000 writes across intervals 1/8/32/128/512, exact anchor counts/staleness, 400 tamper trials per run, and roughly 0.2% of interval-1 signing work at interval 512. Focused tests and native, WASM-dedup, regression, supply-chain, formatting, and clippy gates pass.
Two blockers remain:
- Required Workspace CI was cancelled.
StateAnchorLogrelies on callers to supply monotonically increasingwrite_count, but the public append path does not reject duplicate or decreasing counts. That can make insertion order diverge from logical order and invalidates the stated lookup/staleness contract.
Acceptance gate:
- Fail closed on duplicate/decreasing write counts and test out-of-order, duplicate, restart/reload, and concurrent append cases.
- Re-run the frozen benchmark after that invariant.
- Add native/WASM parity for checkpoint serialization and verification.
- Obtain a successful exact-head Workspace CI run.
Acceptance is limited to the software proof; no durable external transparency or production deployment claim is made.
Summary
Nightly research contribution continuing the 2026-08-31 run's own named
"Next Research" item and ADR-340's third Open Question: independent,
periodically-signed
index_state_rootanchoring, decoupled from anyspecific query or receipt.
roots, per-query and batched) → this PR, ADR-341 (Ed25519-signed
index_state_rootcheckpoints, independent of any query).crates/ruvector-retrieval-receipt/src/state_anchor.rs:StateAnchorPolicy,StateAnchorLog,verify_state_anchor, reusingADR-340's
Issuer/AnchorContext/verify_rootmachinery unchanged viaa new
AnchorPurpose::StateAnchor. No existing type, field, or testchanged.
ever attested to be in state R" in O(1), without replaying the full
write history (
HashChainGate::verify_integrity, O(n)).Hypothesis
Benchmark
Command:
cargo run --release -p ruvector-retrieval-receipt --bin benchmark -- 5000 128 10 200, 3 repeated process runs, 4 logical CPUs,rustc 1.94.1, release profile. Raw output:
docs/research/nightly/2026-09-03-state-root-anchoring/raw-runs.txt.Representative run (
interval_writessweep over 5,000 writes):Five acceptance thresholds, fixed before the run, all passed in all 3
runs — anchor count and max staleness matched the closed-form prediction
exactly (structural correctness, not statistical tolerance); 100%
tamper detection (400 trials/run); anchor-verify cost within a 2x band
(observed 1.04–1.07x); amortized signing cost at
W=512under 10% of theW=1cost (observed 0.2%).Honest counterpoint reported, not hidden: a separate, explicitly
non-gated table shows
verify_integrity's O(n) full-replay cost — atn=10,000 it's 28–31x more expensive than one O(1) anchor verify across the
3 runs, and that gap is real, but the periodic anchor does not replace
full-history integrity checking; it's a cheaper, bounded-staleness
checkpoint, and the ADR says so explicitly.
ACCEPTANCE RESULT (both the pre-existing receipt benchmark and the new
state-anchor benchmark): ACCEPT in all 3 runs.
Acceptance result
ACCEPT— full formal hypothesis, thresholds, and evidence inADR-341 and the
nightly research README.
Darwin result
Not executed. Capability verification (
npx metaharness --help,npx ruvector harness doctor/status --json) foundmetaharnessinstalled onlyas a project-scaffolding generator, not a research/Darwin/Flywheel harness
wired to this repository;
ruvector harnesshas no such executable here.This is disclosed explicitly in the research README rather than fabricating
Darwin generations or Flywheel evidence-store writes that no installed
tool actually produced. The
interval_writessweep plays the sameempirical exploration role a bounded Darwin generation would, authored
directly.
Security review
no new signature format.
AnchorPurpose::StateAnchoris bound into thesigned statement, so a receipt/batch-purpose signature can never be
replayed as a state anchor (tested).
add issuer honesty, durability, or stalled-job detection (all named
explicitly in ADR-341 Failure Modes).
cargo clippy --release -p ruvector-retrieval-receipt --all-targets -D warnings: clean.cargo fmt -- --check: clean.Main limitations
StateAnchorLogis in-process, non-durable, not thread-safe — aproduction deployment needs a persistence design first (Next Research
Implement Ruvector high-performance vector database #1).
anchoring policy for bursty traffic is deferred (Next Research Set up Claude Flow swarm initialization #2, also
the Rejected-Alternatives discussion in the README).
gaps ADR-340 already carries).
Production recommendation
Experimental, matching ADR-304/ADR-340's posture — not wired into any
default write or query path by this PR. Promotion requires a durable
StateAnchorLogpersistence design and benchmark evidence against a realdeployment's write-rate/staleness tolerance (see ADR-341 Governance and
Production Path).
Files changed
crates/ruvector-retrieval-receipt/src/state_anchor.rs(new) — policy,log, verification, 6 unit tests.
crates/ruvector-retrieval-receipt/src/signing.rs—AnchorPurpose::StateAnchor,AnchorError::InvalidInterval.crates/ruvector-retrieval-receipt/src/lib.rs— module wiring, re-exports.crates/ruvector-retrieval-receipt/src/bin/benchmark.rs— interval-sweepbenchmark + descriptive
verify_integrityscaling table.docs/adr/ADR-341-periodic-state-root-anchoring.md(new).docs/research/nightly/2026-09-03-state-root-anchoring/(new) — README,gist, raw 3-run benchmark output.
Research document
docs/research/nightly/2026-09-03-state-root-anchoring/README.md
ADR
docs/adr/ADR-341-periodic-state-root-anchoring.md
Gist
docs/research/nightly/2026-09-03-state-root-anchoring/gist.md
(standalone technical article; not separately published as a public GitHub
gist — no
gh/GitHub CLI access available in this environment).Test plan
cargo test -p ruvector-retrieval-receipt --release— 30/30 pass(16 pre-existing regression tests + 14 new/touched).
cargo test -p ruvector-proof-gate --release— pass, unaffected.cargo clippy --release -p ruvector-retrieval-receipt --all-targets -- -D warnings— clean.cargo fmt -p ruvector-retrieval-receipt -- --check— clean.ACCEPTin all 3 runs.🤖 Generated with claude-flow
https://claude.ai/code/session_01KV63T53qpYkXYkAKXvfPXT
Generated by Claude Code