Relationships
↑ child of #662#703 serve-auth: add --server support to all read/query/operations commands
Opened by stack72 · 6/19/2026
Problem
Only run and access commands support `--server` today. A user who operates a remote server can run models and manage grants, but can't retrieve output, explore data, check secrets, run reports, or discover what's available — they'd need SSH for that.
Principle
If you're an operator or user of a remote server, you shouldn't need SSH for anything except starting the server and minting tokens.
Commands to add `--server` support
Data access
- `swamp data get` — retrieve model output (most urgent — remote run tells you to run this but you can't)
- `swamp data query` — search data with CEL predicates
- `swamp data list` — list data for a model
Discovery
- `swamp model list` / `swamp model search` — what models exist on the server
- `swamp model method describe` — what methods and inputs a model has
- `swamp workflow list` — what workflows exist
- `swamp workflow describe` — workflow structure
Operations
- `swamp vault get` / `swamp vault put` — manage secrets remotely
- `swamp audit` — audit the repo state
- `swamp summary` — summarise the repo
- `swamp report` — run reports
Already working
- ✅ `swamp model method run`
- ✅ `swamp workflow run`
- ✅ `swamp access grant create/list/revoke`
- ✅ `swamp access group create/add-member/remove-member/list/members`
- ✅ `swamp access check/reload/can-i`
- ✅ `swamp access policy` (alias)
- ✅ `swamp access token list/revoke/rotate`
Local-only (no `--server`)
- `swamp serve` — starts the server
- `swamp repo init` — initialises a repo
- `swamp model create` — creates model definitions
- `swamp access token mint` — requires vault access on the host
Implementation approach
Keep `--server` and `--token` as per-command options — NOT global. `auth login --server` means swamp-club registry URL (different semantics), and `worker connect --token` means enrollment token (different auth system). Global options would cause semantic collisions.
Create a shared helper to reduce duplication — a `withServerOption(command)` wrapper or utility that adds the `--server` and `--token` options plus `SWAMP_SERVE_URL` env var fallback to any command. Individual commands call the helper instead of defining the options manually.
Each command follows the same pattern:
- Add `--server` and `--token` options (via shared helper)
- In the action handler: if `options.server`, early exit to remote path
- New protocol frame type in `src/serve/protocol.ts`
- Server-side handler in `src/serve/connection.ts` with `authorizeOrReject`
- Client calls `requestServerResponse()` or `streamServerRun()`
- Same renderer for local and remote paths
Authorization on read operations:
- `data get/query/list` → `read` on `data:`
- `model list/search/describe` → `read` on `model:` (or `model:*` for listing)
- `workflow list/describe` → `read` on `workflow:` (or `workflow:*` for listing)
- `vault get/put` → `read`/`write` on appropriate resource
- `audit/summary/report` → `read` on appropriate scope
- Admin fallback already handles admins
Priority order:
- `swamp data get` — most urgent, breaks the remote run workflow
- `swamp data query` + `swamp data list` — exploring remote data
- `swamp model list` + `swamp workflow list` — discovery
- `swamp vault get/put` — secrets management
- `swamp audit` + `swamp summary` + `swamp report` — operations
- Everything else
Binary content handling: `data get` needs to handle both JSON resources and binary files (logs). Check how the data plane (`src/serve/data_plane.ts`) handles binary content for workers. For JSON resources, include parsed attributes in the response. For files, base64-encode or stream the content.
Subsumes
- #702 (`SWAMP_SERVE_URL` env var) — already shipped, used by the per-command approach
References
- Existing `--server` pattern: `src/cli/commands/model_method_run.ts`
- Serve protocol: `src/serve/protocol.ts`
- Connection handler: `src/serve/connection.ts`
- Token resolution: `src/cli/remote_run.ts`
- Authorization: `authorizeOrReject` in `connection.ts`
- Data plane binary handling: `src/serve/data_plane.ts`
Closed
No activity in this phase yet.
stack72 commented 6/19/2026, 10:45:52 PM
Closing — rescoped and replaced by a new issue with clearer direction. The global --server approach was abandoned due to semantic collisions (auth login, worker connect). New issue will track per-command --server support built incrementally, one commit per command.
Sign in to post a ripple.