feat(usage): period select and spend caps, with what happens at the limit

Open
#148 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active

Research direction

Start with the Usage design rows in plans/261202-0003-client-bootstrap/design-feature-matrix.md and the plan at plans/261202-0806-keep-all-design-features/plan.md; then check dependencies #111, #135 and PR #153. The issue requires server routes that are still upstream, plus web/PWA and desktop wiring, capability gating, tests and staging verification. Done means the real route is wired and verified; until then, the feature stays gated.

Written by the indexing model from the issue text.

Description

enhancement

Design: board 28 Usage, rows M11 (period select), M14 (edit monthly cap or per agent per day) and M15 (at 100%: agents pause, people keep chatting).

Invariant: caps are enforced by the Gateway at the model call. The client shows the server's caps and utilization and never computes a remaining amount itself. Editing a cap is a privileged policy write.

Acceptance criteria

  • Period select (this month, last month, custom) re-reads usage for that period from the server.
  • Caps list shows each policy's window, limit and utilization as reported.
  • Edit cap uses the typed write with expected_version and an Idempotency-Key; a version conflict shows the current value and asks again.
  • At 100%, the page and the affected rooms say that agents are paused by the cap and people can keep chatting, using the server's cap-exceeded state. Raising the cap needs authority.
  • Tests. A member (no caps view), an admin edit, a version conflict, a cap reached during a run, and flag off for the write slice.
  • Wired, not fixtures. This issue closes only on a slice wired to the real route it depends on, behind its dark capability id (or its local switch for a client-only feature), and verified on staging once the route exists. A fixture-backed screen satisfies none of the boxes above.

Capability

Client id spend-caps for cap edits, gated in demo builds (PR #153); the Usage page and the cap read keep usage. Server group usage, proposed children usage.caps (the cap read, requested on an upstream item (tracked privately)) and usage.caps_write (upstream, tracked privately). Until the server reports both, spend-caps resolves to gated, so the usage group flag alone never enables cap edits.

Denied, pending and recovery states

Denied: not an admin, so caps are hidden with an explanation. Pending: the write is in flight. Recovery: a conflict re-reads the policy.

Parity

Surface Evidence
Gateway API/RPC Usage and caps routes (upstream, tracked privately)
CLI Quota and caps parity an upstream item (tracked privately)
MCP Per an upstream item (tracked privately)
CCP / RGD / ACP RGD caps panel; CCP per an upstream item (tracked privately)
Dewee client Usage page and room notice on web/PWA and desktop
Conversation "Raise the monthly cap" opens an approval handoff
Docs docs/UX.md usage section
Traces Cap edits traced

Dependencies

An upstream item (tracked privately), #111, #135, PR #153 (spend-caps). Admin lane (screens/usage/**), after #127 in the Admin order.

Rules for this issue

  • The owner kept this feature on 2026-12-02 (DECISIONS.md D23, recorded by the keep-all docs PR #132). Design rows and states are in plans/261202-0003-client-bootstrap/design-feature-matrix.md. The plan is plans/261202-0806-keep-all-design-features/plan.md.
  • Done means wired. This issue closes only with a slice wired to the real route it depends on: the relay route through the web BFF and the desktop host command, or, for a client-only feature, the real native or browser path. The slice runs behind its dark capability id and is verified on staging once the route exists. Fixtures are for tests only. A fixture-backed screen never closes this issue and is never listed in plans/EVIDENCE.md. Until the route merges, the feature renders its gated or dark state.
  • One relay integrator. Only the relay-integrator lane adds ClientMethod entries to CLIENT_METHODS in packages/core/src/protocol.ts, one route at a time in merge order, together with the BFF allowlist entry and the desktop host command. A feature lane does not edit protocol.ts or capabilities.ts. The desktop host's shared files (lib.rs, capabilities/default.json, Cargo.toml, Cargo.lock, build.rs, apps/desktop/src/desktop-session.ts) have one owner at a time, in the order the plan names; a lane puts its commands in its own module and adds only a registration line.
  • Ships dark. The client id below resolves from the server's capability read through the capability map (#135). A feature without both renders its gated or dark state, never sample data presented as real. Where the route belongs to a domain that still awaits server-side relay parity, its relay child flag stays off until that domain's upstream parity work lands (tracked privately).
  • Both hosts. Web/PWA and desktop, en/vi, light/dark, 390/768/1024/1440, keyboard-only.
  • Checks. Typecheck, Biome and focused tests. Tests cover flag off, denied, pending, revocation and recovery.
  • Review. An independent review runs before the PR leaves draft. No auto-merge.
Dominant language
No language data
Stars
1
Forks
2
Avg merge
1h 51m
Merged PRs (30d)
103

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextlevelbuilder/dewee-desktop-app

All issues in nextlevelbuilder/dewee-desktop-app

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.