Skip to content

feat(api,cli,mcp): usage metering v1 — per-project aggregates - #99

Merged
Dvorinka merged 4 commits into
mainfrom
feat/usage-metering
Nov 19, 2026
Merged

Dvorinka merged 4 commits into
mainfrom
feat/usage-metering

Conversation

@Dvorinka

Copy link
Copy Markdown
Owner

Summary

  • GET /api/v1/projects/{id}/usage?days=N — deploy counts, build seconds, artifact/image bytes (1–365d window)
  • runway usage [--days N] [--json] CLI command
  • get_project_usage MCP tool (same aggregate, shared fn)
  • Worker records artifact_bytes (static output dir size — covers local, remote-node, and KERN artifact paths) and image_bytes (docker inspect on the built image) into deployment.config at build completion

Verification

  • Live: bitbucket webhook deploy records artifact_bytes: 147; REST, MCP JSON-RPC, and CLI all return the aggregate
  • cargo fmt, cargo clippy --workspace -- -D warnings, cargo test clean

Test plan

  • REST endpoint returns aggregate for a real project
  • MCP tools/call get_project_usage
  • runway usage + runway usage --json
  • bandwidth metering — deferred (needs Traefik access-log accounting)

Generated with Devin

Deployments now record artifact_bytes (static output dir size at build
completion, covers local/remote/KERN paths) and image_bytes (built image
size for dockerfile deploys) into deployment.config. Build seconds come
from existing timestamps.

- GET /api/v1/projects/{id}/usage?days=N (1-365, default 30): deploy
  counts, succeeded/failed, build_seconds, artifact_bytes, image_bytes
- runway usage [--days N] [--json]
- MCP get_project_usage
- fmt_bytes shows sub-KB values as B

Verified live: bitbucket webhook deploy records artifact_bytes, REST +
MCP + CLI all return the aggregate.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mira-tdvorak

mira-tdvorak Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Mira PR Walkthrough

Adds usage metering v1 across the API, worker, CLI, and MCP surfaces: workers record artifact/image byte sizes at build completion, the API exposes a per-project usage aggregate over a configurable day window, and both the CLI and MCP tool expose that same aggregate. The change is cross-cutting but narrowly scoped to a read-only reporting path plus two new metrics captured during deployment builds.

graph LR
  worker["crates/worker/src/deploy.rs"] --> apiProjects["crates/api/src/routes/projects.rs"]
  apiLib["crates/api/src/lib.rs"] --> apiProjects
  apiMcp["crates/api/src/routes/mcp.rs"] --> apiProjects
  cliCommands["crates/cli/src/commands.rs"] --> apiProjects
  cliMain["crates/cli/src/main.rs"] --> cliCommands
Loading

❌ Review failed — click for details

The code review failed to complete due to an unexpected error.

Stage: Code review
Error type: LLMError
Message: Both primary and fallback models failed


Comment @mira-tdvorak help to get the list of available commands and usage tips.

@Dvorinka
Dvorinka merged commit 62316a5 into main Nov 19, 2026
2 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