feat(cli): KV atomic ops + paginated list output (PR A — data access)#19
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
POST /api/v1/functions/{id}/kv/{key}/incrand…/casonKVOperatorHandler, mirroring the internal-tokenKVHandler.Incr/CASand thekv_incr/kv_casMCP 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).deploymentslisttotal—ListForFunctionnow returns aCOUNT(*)so clients can detect truncation (was a bare array). NewDB.CountDeploymentsForFunction.CLI
kv incr/kv cas— atomic counters + compare-and-swap (locks, idempotency).casexits non-zero and prints the current value on a precondition miss so scripts can branch/retry; honors-o json.functions list --limit/--offset+ aShowing N of Mfooter — fixes the silent 20-row cap that made agents miss functions.deployments list— truncation footer from the newtotal.traces list— surfacesnext_cursoras 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 incr1→6→4;kv casinsert-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 listcursor hint +--beforepaging.