feat(session): --scopes flag on create/authorize/revoke - #670
Conversation
Session create and authorize granted all four FWSS permissions and revoke removed all of them, with no way to choose a subset from the CLI. Add --scopes <ids> to all three (default unchanged: all permissions), so an owner can mint or revoke a least-privilege key. Canonical scope ids match FWSS scope (createDataSet, addPieces, schedulePieceRemovals, terminateService) with short aliases (create, add, remove/delete, terminate) are accepted as a typing shortcut. Parsing is case-insensitive, dedupes, rejects unknown tokens with the valid list, and the granted/revoked scopes are shown in the confirmation.
There was a problem hiding this comment.
Pull request overview
Adds a --scopes flag to the session create, session authorize, and session revoke CLI flows so users can grant/revoke a subset of FWSS permissions instead of always using the full default set. This fits the codebase by extending the existing session CLI runners and core session permission model with a small parsing/normalization layer and corresponding unit tests.
Changes:
- Introduces
src/session/scopes.tsto define canonical scope IDs, aliases, and parsing/formatting helpers. - Plumbs optional parsed permissions into session create/authorize/revoke runners (and surfaces the chosen scopes in CLI output).
- Adds unit tests for scope parsing/description, plus CLI/README documentation updates.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/unit/session-scopes.test.ts | Adds unit coverage for scope parsing, ordering, aliasing, and rendering. |
| src/session/types.ts | Extends session CLI option types with scopes?: string. |
| src/session/scopes.ts | New scope registry + parseScopes/describeScopes helpers. |
| src/session/run-revoke.ts | Parses --scopes and conditionally passes permissions to revocation. |
| src/session/run-create.ts | Parses --scopes and conditionally passes permissions to session key creation/authorization. |
| src/session/run-authorize.ts | Parses --scopes and conditionally passes permissions to authorization. |
| src/commands/session.ts | Wires --scopes into commander options/help text for create/authorize/revoke. |
| README.md | Documents scoped session keys and gives usage examples. |
Suppressed comments (2)
src/commands/session.ts:42
- The
--scopeshelp text has inconsistent spacing (e.g.remove, delete,terminate) which is easy to misread/copy. Consider normalizing the comma/space formatting.
'Comma-separated permissions to grant (default: all). Any of: createDataSet,addPieces,schedulePieceRemovals,terminateService (aliases: create,add,remove, delete,terminate)'
src/commands/session.ts:61
- The
--scopeshelp text has inconsistent spacing (e.g.remove, delete,terminate) which is easy to misread/copy. Consider normalizing the comma/space formatting.
'Comma-separated permissions to revoke (default: all). Any of: createDataSet,addPieces,schedulePieceRemovals,terminateService (aliases: create,add,remove, delete,terminate)'
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
BigLep
left a comment
There was a problem hiding this comment.
Conceptually makes sense to me. I'll leave to agent and Russell to actually certify the code. Happy to spend more time on this though if useful.
| # schedulePieceRemovals, terminateService (short aliases: create, add, | ||
| # remove, delete, terminate). E.g. --scopes add,create or --scopes remove. |
There was a problem hiding this comment.
I don't love the alias concept given this is a low-usage API (I assume). Your call, but I would simplify and not include it.
Also, it's not obvious to me how we have 4 verbose scopes:
createDataSet, addPieces, schedulePieceRemovals, terminateService
but 5 aliases:
create, add, remove, delete, terminate
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
commit: |
allow users to better control session key scopes and manage their operations respectively