Skip to content

feat(node): read-only GET /v1/usage endpoint (Phase P2) - #8

Merged
varshith-Git merged 1 commit into
mainfrom
phase/index-capacity-tuning-and-e2e
Aug 11, 2026
Merged

varshith-Git merged 1 commit into
mainfrom
phase/index-capacity-tuning-and-e2e

Conversation

@varshith-Git

Copy link
Copy Markdown
Owner

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).

Summary

What does this change do, and why?

Determinism Impact

  • No determinism impact
  • Improves determinism
  • Changes arithmetic behavior (Q16.16 / FxpScalar)

If arithmetic behavior changes, explain why and what compatibility fixtures were updated.

no_std / Kernel ABI

Only applies if crates/valori-kernel or crates/valori-core were touched.

  • N/A — kernel/core not touched
  • No use std:: added inside valori-kernel/src/; std-only code is gated behind #[cfg(feature = "std")]
  • cargo build -p valori-kernel --target wasm32-unknown-unknown passes locally

Standalone + Cluster Parity

Only applies if this adds or changes an HTTP endpoint or a KernelEvent.

  • N/A — no endpoint/event change
  • Handler added to both server.rs and cluster_server.rs
  • Write path in cluster mode goes through raft.client_write(), not a direct engine lock
  • cargo test -p valori-node --test route_parity passes (or the allowlist was updated with a reason)

Cross-Architecture Behavior

Tested on:

  • x86
  • ARM / Apple Silicon
  • Embedded / Jetson

Tests

  • cargo test -p valori-kernel -p valori-node passes
  • cargo fmt --all -- --check and cargo clippy --workspace --all-targets -- -D warnings pass

Include reproduction / validation cases below.

UI (if applicable)

  • N/A — no UI change
  • Verified in both dark and light mode (semantic tokens only, no hardcoded colors)

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.

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>
@varshith-Git
varshith-Git merged commit eee123d into main Aug 11, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant