Skip to content

feat(account): expose quota status and quota-over-subscription precedence to agents - #660

Merged
pcfreak30 merged 2 commits into
developfrom
feat/account-quota-agent-surfaces
Sep 1, 2026
Merged

feat(account): expose quota status and quota-over-subscription precedence to agents#660
pcfreak30 merged 2 commits into
developfrom
feat/account-quota-agent-surfaces

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Adds account_quota to the operation catalog, surfacing upload/download/storage usage and a derived has_quota signal on the CLI (pinner account quota) and the MCP tool surface. Wires quota into pinner://account/status and the auth service's GetQuota.

Encodes the "quota trumps a subscription" access rule in the agent guide and prompt templates: proceed when has_quota is true regardless of subscription; only when quota is exhausted fall back to account_subscription and surface the subscription deep-link to the human.


Summary

This pull request introduces a new account_quota operation across the CLI, MCP, and agent guide surfaces. It exposes the user's quota status (upload, download, storage usage/limits/remaining) and establishes a clear access policy: quota trumps a subscription — if the user has any usable quota remaining, no subscription is required and agents should proceed without asking about one. Only when quota is exhausted should agents fall back to checking subscription status, and if not subscribed, they must surface the returned web-app deep-link for the human to subscribe (agents cannot subscribe on their behalf).

Key Changes

New account_quota operation (CLI + MCP)

  • Added a new catalog operation account_quota that fetches per-dimension quota (upload, download, storage) via AuthService.GetQuota and derives a has_quota boolean (true if any dimension is unlimited or has positive remaining allowance).
  • Returns a typed AccountQuotaResult with has_quota, per-dimension usage/limits/remaining/reserved/threshold/percentage, a human-readable message, and the web-app web_url deep-link for managing usage/subscribing.
  • Registered the new operation in AccountOperations alongside account_info, account_subscription, etc.

Auth service extension

  • Added GetQuota(ctx) to the AuthService interface and implemented it in AuthServiceDefault by calling the portal SDK's client.GetQuota(ctx).

CLI wiring

  • Added a CLI-only --open flag for account_quota to open the usage page in a browser (same pattern as account_subscription).
  • Added human-readable rendering for quota results (e.g., upload used=5 limit=100 remaining=95 (5%)), plus the covered/not-covered message and web URL.
  • JSON output paths return the full typed result including web_url and has_quota.

MCP surface

  • Replaced the previous Quota(ctx) no-op (returned nil via TODO) in the MCP accountStatusAdapter with a real implementation that calls GetQuota and returns a structured map (has_quota, upload, download, storage) under the pinner://account/status resource. On error, it returns an error key so the agent can see why quota is unavailable.

Agent guidance and prompt templates

  • Added a new agent-guide rule: "Access policy (quota trumps a subscription)" instructing agents to consult account_quota before paid/metered actions, proceed if has_quota is true, and only check subscription + surface web URL when quota is false.
  • Updated the ens_publish_auth_status, setup_auth_status_check, and website_auth_status prompt templates with matching access-verification instructions (check quota first; only fall back to subscription when quota is exhausted; never subscribe for the human).

Tests

  • Added tests for accountQuota covering: typed result with positive remaining → has_quota=true; all dimensions exhausted → has_quota=false; unlimited (nil remaining) → has_quota=true; service error propagation with account_quota: prefix.
  • Added a CLI wiring test verifying account_quota --json --open emits valid JSON with web_url and has_quota and no browser chatter on stdout.
  • Updated the MockAuthService with GetQuota expectations, and created a fakeAccountQuotaDeps helper for hermetic testing.

Cosmetic cleanup

  • Normalized struct field alignment in several existing catalog operation specs (whitespace-only changes, no functional impact).

@kody-ai

This comment has been minimized.

Comment thread internal/catalogops/account_ops.go Outdated
Comment thread internal/catalogops/account_ops.go
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Coverage Report

Total Coverage: 50.1%

Generated from commit: deafc99
Repository: LumeWeb/pinner-cli

The QuotaStatusResponse schema marks only used/percentage as required and
carries no explicit unlimited marker, so a nil remaining bound does not mean
unlimited. Only an explicit positive remaining now counts toward has_quota,
so zero-quota accounts (all nil) are no longer reported as covered.
@kody-ai

kody-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@pcfreak30
pcfreak30 marked this pull request as ready for review September 1, 2026 10:02
@pcfreak30
pcfreak30 merged commit 79d837f into develop Sep 1, 2026
13 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