Repository navigation
feat(node): read-only GET /v1/usage endpoint (Phase P2) - #8
Merged
Merged
Conversation
Adds usage accounting for Valori Cloud's plan/quota system — records count, collection count, and billable storage bytes (event-log + archived rotation segments), read directly from the live engine. Never mutates state (proven by a dedicated test comparing the BLAKE3 state hash before/after a call). - server.rs: usage_handler() (standalone), storage_bytes_standalone(), file_size(); sum_log_and_archives() made pub(crate) for reuse. - cluster_server.rs: usage() handler sums records/storage across all shards; collections read from shard 0's namespace registry (correct, since the registry itself isn't sharded). - tests/usage_endpoint_tests.rs: 5 tests covering fresh-engine defaults, real inserts, collection create/drop, rotated-segment storage accounting, and the never-mutates-state invariant. Both standalone and cluster paths implemented per the mandatory dual-path checklist (CLAUDE.md). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Adds usage accounting for Valori Cloud's plan/quota system — records count, collection count, and billable storage bytes (event-log + archived rotation segments), read directly from the live engine. Never mutates state (proven by a dedicated test comparing the BLAKE3 state hash before/after a call).
Both standalone and cluster paths implemented per the mandatory dual-path checklist (CLAUDE.md).
Summary
What does this change do, and why?
Determinism Impact
FxpScalar)If arithmetic behavior changes, explain why and what compatibility fixtures were updated.
no_std/ Kernel ABIOnly applies if
crates/valori-kernelorcrates/valori-corewere touched.use std::added insidevalori-kernel/src/; std-only code is gated behind#[cfg(feature = "std")]cargo build -p valori-kernel --target wasm32-unknown-unknownpasses locallyStandalone + Cluster Parity
Only applies if this adds or changes an HTTP endpoint or a
KernelEvent.server.rsandcluster_server.rsraft.client_write(), not a direct engine lockcargo test -p valori-node --test route_paritypasses (or the allowlist was updated with a reason)Cross-Architecture Behavior
Tested on:
Tests
cargo test -p valori-kernel -p valori-nodepassescargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningspassInclude reproduction / validation cases below.
UI (if applicable)
Notes
If this relates to forensic or evaluator tracks, confirm that logic is kernel-appropriate.
Anything deferred to a follow-up, and which phase/issue owns it.