Skip to content

feat(usage): add hotdata usage command#174

Merged
eddietejeda merged 1 commit into
mainfrom
feat/usage-command
Jun 20, 2026
Merged

feat(usage): add hotdata usage command#174
eddietejeda merged 1 commit into
mainfrom
feat/usage-command

Conversation

@eddietejeda

Copy link
Copy Markdown
Contributor

Summary

SDK 0.4.0 (#171) added the usage API (GET /v1/usage), but the CLI exposed no command for it. This adds hotdata usage:

hotdata usage [--since <rfc3339>] [--workspace-id <ws>] [--output table|json|yaml]

Reports workspace usage for the current billing window (or since --since): query_count, bytes_scanned, storage_bytes, and storage_captured_at.

Behavior

  • query_count and bytes_scanned accrue per query in real time (data reads).
  • storage_bytes is a periodic snapshot taken at storage_captured_at, so uploads are reflected on the next capture, not instantly.
  • Table view renders byte counts human-readably (e.g. 21.7 MiB (22706766 B)); -o json/yaml keep raw integers.

Implementation

  • New src/usage.rs, wired through command.rs + main.rs.
  • Uses the seam's raw get_json("/usage", …) helper — there's no typed SDK handle for usage (only the free usage_api::get_usage function), and this matches how indexes.rs already does untyped GETs.
  • Output shape is a curated struct (decoupled from the generated model), consistent with databases/indexes.
  • Documented in the core hotdata skill (subcommand list + a Usage section).

Tests / verification

  • Unit tests: response deserialization (incl. null storage_captured_at) and the human-bytes formatter.
  • Full suite green (211 passed); fmt/clippy clean for the new code.
  • Verified against production (AgentRyan):
    • hotdata usage → table with all five metrics
    • hotdata usage --since 2026-06-15T00:00:00Z -o jsonquery_count drops from 186 (month-to-date) to 45, confirming --since is honored

SDK 0.4.0 added the usage API (`GET /v1/usage`) but the CLI exposed no
surface for it. Add a `usage` command that reports workspace usage for the
current billing window (or `--since <rfc3339>`):

  hotdata usage [--since <ts>] [-w <ws>] [-o table|json|yaml]

Shows query_count, bytes_scanned, storage_bytes, and storage_captured_at.
Table view renders byte counts human-readably; json/yaml keep raw integers.
query_count/bytes_scanned accrue per query in real time; storage_bytes is a
periodic snapshot (storage_captured_at), so uploads show up on the next
capture, not instantly.

Uses the seam's raw `get_json` helper (no typed SDK handle exists for
usage). Documented in the core skill. Verified against production
(table + --since + json).

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. New usage command follows existing conventions (untyped get_json seam like indexes.rs, curated output struct, table::print). Well-tested: unit scaling, exact-value preservation, and null storage_captured_at.

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/usage.rs 62.50% 21 Missing ⚠️
src/main.rs 0.00% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@eddietejeda eddietejeda merged commit 06ddd4c into main Jun 20, 2026
14 checks passed
@eddietejeda eddietejeda deleted the feat/usage-command branch June 20, 2026 01:12
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