Skip to content

feat(cli): KV atomic ops + paginated list output (PR A — data access)#19

Merged
Harsh-2002 merged 1 commit into
mainfrom
dev
Jun 14, 2026
Merged

feat(cli): KV atomic ops + paginated list output (PR A — data access)#19
Harsh-2002 merged 1 commit into
mainfrom
dev

Conversation

@Harsh-2002

Copy link
Copy Markdown
Owner

PR A — Data access for automation (Tier 1)

First of four back-to-back CLI gap-closure PRs (see plan). Makes the CLI a complete, non-truncating data surface for CI pipelines and AI agents.

Server

  • Operator KV atomic routesPOST /api/v1/functions/{id}/kv/{key}/incr and …/cas on KVOperatorHandler, mirroring the internal-token KVHandler.Incr/CAS and the kv_incr/kv_cas MCP tools. The only pre-existing incr/cas routes were internal-token-only (in-sandbox SDK), unreachable by the API-key CLI; these complete the operator KV surface (List/Get/Put/Delete/Incr/CAS).
  • deployments list totalListForFunction now returns a COUNT(*) so clients can detect truncation (was a bare array). New DB.CountDeploymentsForFunction.

CLI

  • kv incr / kv cas — atomic counters + compare-and-swap (locks, idempotency). cas exits non-zero and prints the current value on a precondition miss so scripts can branch/retry; honors -o json.
  • functions list --limit/--offset + a Showing N of M footer — fixes the silent 20-row cap that made agents miss functions.
  • deployments list — truncation footer from the new total.
  • traces list — surfaces next_cursor as a --before <cursor> paging hint + flag.

Tests

DB-level KVIncr/KVCAS/CountDeploymentsForFunction; CLI command-tree + required-flags for the new leaves. go vet ./... + go test ./... green; command-tree parity (slim vs server) green.

Live-verified on the dev instance (:3000)

kv incr 1→6→4; kv cas insert-if-absent + match + stale-miss (exit 1, prints current, incl. -o json); functions list --limit 1 → "Showing 1 of 5 (raise --limit…)"; deployments list --limit 2 → "Showing 2 of 7"; traces list cursor hint + --before paging.

Closes the Tier-1 data-access gaps for CI/agent automation:

- kv incr / kv cas: new operator-facing routes
  POST /api/v1/functions/{id}/kv/{key}/{incr,cas} on KVOperatorHandler,
  mirroring the internal-token handlers and the kv_incr/kv_cas MCP tools
  (the existing routes were internal-token only, unreachable by the
  API-key CLI). Adds `orva kv incr` and `orva kv cas`; cas exits non-zero
  and prints the current value on a precondition miss so scripts can
  branch/retry.
- functions list: --limit/--offset + a "Showing N of M" footer so an agent
  never silently misses functions past the page (was a silent 20-row cap).
- deployments list: server now returns `total`; CLI shows a truncation hint.
- traces list: surface next_cursor as a "--before <cursor>" paging hint.

Tests: DB-level KVIncr/KVCAS/CountDeploymentsForFunction; CLI command-tree
and required-flags for the new leaves.
@Harsh-2002 Harsh-2002 merged commit 2bce176 into main Jun 14, 2026
18 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