Skip to content

feat(clients): add stats() to the Python and TypeScript clients - #1044

Open
cl0ud08 wants to merge 1 commit into
caura-ai:mainfrom
cl0ud08:feat/clients-stats
Open

cl0ud08 wants to merge 1 commit into
caura-ai:mainfrom
cl0ud08:feat/clients-stats

Conversation

@cl0ud08

@cl0ud08 cl0ud08 commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Adds stats() to the Python and TypeScript clients, wrapping GET /api/v1/stats. Returns a new Stats model/interface exposing tenant_count, memory_count, agent_count, plus the raw payload on .raw.

Related Issue

Closes #552.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation update
  • Refactor / internal cleanup
  • Other:

How Has This Been Tested?

  • pytest in clients/python: 138 passed. The 7 failures in test_interviewer_installer.py / test_interviewer_platform.py are POSIX-only (fcntl, chmod semantics) and reproduce identically on unmodified main on Windows.
  • npm test in clients/typescript: 17/17 pass; tsc compiles clean.
  • New tests cover: correct path with empty query string, counter parsing, missing keys defaulting to 0, and a 503 raising CauraAPIError with the right status code.

Checklist

  • I have read CONTRIBUTING.md
  • I have added tests that cover my changes (or explained why none are needed)
  • ruff check and ruff format --check pass — see tooling note below
  • mypy passes — see tooling note below
  • pytest passes locally
  • I have updated relevant documentation (README, docs, etc.)
  • I have updated CHANGELOG.md under the Unreleased section (if user-facing)

Additional Notes

The issue describes query params (scope, memory_type, status, fleet_id, include_deleted) that don't exist on the route — public_stats() in core-api/src/core_api/routes/stats.py has an empty signature. Implemented as a no-arg method matching the route as it stands; flagged this on the issue before starting.

Two deliberate choices, both easy to reverse:

  • Counters are deployment-wide (count_all(tenant_id="")), not scoped to tenant_id like every other client method. Called out explicitly in both docstrings and both READMEs so nobody misreads memory_count as their own tenant's count.
  • stats() calls _raise_for_status() although health() deliberately doesn't. A wrong base_url or a deployment predating this route returns non-2xx, and a bare .json() would surface a ValueError instead of a CauraAPIError.

Tests mock the exact response shape emitted by stats.py rather than an assumed one.

CHANGELOG: not edited — it's release-please-generated with no Unreleased section. The commit message is a conventional commit, so the entry should generate on release. Happy to add one manually if that's wrong.

Tooling notes, both pre-existing and unrelated to this change:

  • ruff check passes clean. ruff format --check reports 11 files, including tests/test_client.py — all are already unformatted on main, verified by checking out upstream's copy and re-running. Not reformatted here to keep the diff scoped; happy to do it as a separate PR.
  • mypy passes on every file this PR touches. It reports 3 errors in interviewer/cli.py (fcntl.flock / LOCK_EX / LOCK_NB), which are Windows-only — that file is untouched here and errors identically on upstream's version.

@cl0ud08
cl0ud08 marked this pull request as ready for review August 29, 2026 08:52
@cl0ud08
cl0ud08 requested a review from a team as a code owner August 29, 2026 08:52
@Eldad-Caura

Copy link
Copy Markdown
Member

Thank you for implementing stats() in both clients and adding focused tests. The Python and TypeScript suites pass, but DCO fails because commit 355f714 does not contain your Signed-off-by trailer. Please amend and sign off that commit yourself, rebase onto current main, and force-push the updated branch; we will rerun exact-head CI and review after that.

This branch has not been deployed

No deployments
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.

feat(clients): add stats() to the Python and TypeScript clients

2 participants