Repository navigation
Conversation
`adapt identities` lists, inspects, creates, updates, enables, disables and deletes Platform identities, and starts, lists and revokes their sessions. `permissions` shows or changes the Read/Write/Use grid with --allow/--deny RESOURCE:ACTION, using the dashboard's resource names and rejecting actions Platform does not check. `access` sets a member's assume and manage access by member ID or email, and `account` chooses the caller's personal connection for a personal-account binding. `create` accepts --name, --description, --allow and --max-session, filling the permission resources Platform requires, alongside --data. Identity routes take full UUIDs, so a name is resolved case-insensitively among the identities the caller can assume or manage; a full UUID is always an ID. Platform's update replaces the whole configuration and resets omitted fields, so updates merge the change onto the current identity and save with its version. Because every save or access change ends the identity's sessions, a change that alters nothing is not sent. Session tokens are printed once in the start response and never saved. Revoke confirms the result, since Platform answers 204 even when nothing matched. An expired or revoked identity token now points to starting a new session instead of signing in again. Part of #7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Confidence Score: 1/5
Summary
Adds identity management and scoped sessions, affecting authorization and session invalidation. Formatting, Clippy, and 147 tests passed locally; additional grant checks used mocks, and live API behavior remains unverified.
Deployed verification not applicable: adapt/platform-cli is outside the adapt/adapt and adapt/platform pilot. Its CI builds CLI artifacts without PR preview deployments. No verification webhook was sent.
Important Files Changed
| File | Changes |
|---|---|
| src/identities.rs | Identity commands, configuration merging, grant comparison, member lookup, and session management. |
| src/cli.rs | Identity command definitions, flags, validation, and help. |
| src/api.rs | Identity-token authentication and organization error hints. |
| src/output.rs | Whole-object rendering for identity details. |
| src/input.rs | Identity selector, name, and session-label validation. |
| src/commands.rs | Dispatches identity commands using resolved credentials and organization. |
| tests/identities/mod.rs | Mock API, grant comparison, and terminal-output regression tests. |
| tests/support/mod.rs | Pseudo-terminal helper for interactive-output checks. |
| docs/cli-reference.md | Identity workflows, permissions, no-op guarantees, and session handling. |
| docs/api-coverage.md | Identity endpoint coverage and caller-member lookup dependencies. |
| skills/adapt/SKILL.md | Agent-facing identity workflow and token-handling guidance. |
Run info
| Field | ID |
|---|---|
| Agent | 0d6ccd7e-b62f-4075-a561-199d1a7b1bf0 |
| Automation | ec14e69d-634f-4af0-a6dd-27aa06a1f6b3 |
| Run | 096a26fb-3e11-49ff-b56d-6b2462bc4bf5 |
Reviewed: 0abc22f-9edc6b3 · ↻ Re-run review
|
|
||
| pub async fn run(api: &Api, command: IdentityCommand, json: bool) -> Result<u8> { | ||
| if let Some(result) = dispatch(api, command, json).await.map_err(explain)? { | ||
| output::print(&result, json)?; |
There was a problem hiding this comment.
[P2] Must fix: preserve identity details in terminal output
In a TTY, connections: [] makes output::print emit only No results. for get/create/update. Reproduced locally. Use a detail renderer and add a PTY regression test.
| clear: _, | ||
| } => { | ||
| let id = resolve(api, &identity).await?; | ||
| api.json( |
There was a problem hiding this comment.
[P2] Must fix: skip unchanged personal-account bindings
Repeated account --use and already-empty --clear still PUT. Platform unconditionally revokes the caller's sessions, interrupting agents despite unchanged settings. Compare current account bindings before writing.
| body.as_object().is_some_and(|fields| { | ||
| fields | ||
| .iter() | ||
| .all(|(field, value)| field == "version" || current.get(field) == Some(value)) |
There was a problem hiding this comment.
[P2] Must fix: compare grants by effective access
Reapplying identical input-shaped --data.grants always writes because GET grants include name/email, unnecessarily revoking every session. Normalize grant fields/order for comparison, respecting Platform's preserved self-grant semantics.
| if identity_session { | ||
| write!( | ||
| f, | ||
| "; start a new one with `adapt identities sessions start`" |
There was a problem hiding this comment.
[P3] Explain how to clear the expired token override
With exported ADAPT_TOKEN, the recommended session-start command reuses the expired token and returns the same 401. Tell users to unset the override before issuing with their saved browser login.
| if self.status == StatusCode::FORBIDDEN && identity_session { | ||
| write!( | ||
| f, | ||
| "; an identity session works only in its own organization, so remove --org or ADAPT_ORG_ID" |
There was a problem hiding this comment.
[P3] Account for the saved organization in the 403 hint
Removing --org/ADAPT_ORG_ID restores the profile's saved organization, which can produce the same 403. Recommend explicitly selecting the identity's organization instead. Reproduced with a saved profile.
`output::print` treats a top-level `connections` array as table rows, so in a terminal an identity without connections printed only "No results." for get, create, update, enable and disable. Single identity results now go through `output::detail`, which prints indented JSON in a terminal and compact JSON when piped, never a table. A new `in_terminal` test helper runs the CLI with stdout on a pseudo-terminal; the regression test fails with the old output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| clear: _, | ||
| } => { | ||
| let id = resolve(api, &identity).await?; | ||
| api.json( |
There was a problem hiding this comment.
[P2] Must fix: skip unchanged personal-account bindings
Repeated account --use and already-empty --clear still PUT. Platform unconditionally revokes the caller's sessions, interrupting agents despite unchanged settings. Compare current account bindings before writing.
| body.as_object().is_some_and(|fields| { | ||
| fields | ||
| .iter() | ||
| .all(|(field, value)| field == "version" || current.get(field) == Some(value)) |
There was a problem hiding this comment.
[P2] Must fix: compare grants by effective access
Reapplying identical input-shaped --data.grants always writes because GET grants include name/email, unnecessarily revoking every session. Normalize grant fields/order for comparison, respecting Platform's preserved self-grant semantics.
| if identity_session { | ||
| write!( | ||
| f, | ||
| "; start a new one with `adapt identities sessions start`" |
There was a problem hiding this comment.
[P3] Explain how to clear the expired token override
With exported ADAPT_TOKEN, the recommended session-start command reuses the expired token and returns the same 401. Tell users to unset the override before issuing with their saved browser login.
| if self.status == StatusCode::FORBIDDEN && identity_session { | ||
| write!( | ||
| f, | ||
| "; an identity session works only in its own organization, so remove --org or ADAPT_ORG_ID" |
There was a problem hiding this comment.
[P3] Account for the saved organization in the 403 hint
Removing --org/ADAPT_ORG_ID restores the profile's saved organization, which can produce the same 403. Recommend explicitly selecting the identity's organization instead. Reproduced with a saved profile.
Re-applying the same `grants` in `identities update --data` always saved, because Platform's responses add each member's name and email, so every session of the identity ended even though access did not change. Supplied grants now count as unchanged when they would leave the same access in place: Platform keeps the caller's own grant, gives each listed member its access, and removes everyone else, so the comparison ignores order, ID case, entries with no access, and response-only fields. Input Platform would reject, such as a duplicate member or a different access for the caller, still counts as a change so its error is shown. This needs the caller's member ID, looked up with `/v1/whoami` and a member list filtered by user ID, only when grants are the sole possible change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| }; | ||
| use uuid::Uuid; | ||
|
|
||
| const ROOT: &str = "/v1/identities"; |
There was a problem hiding this comment.
[P1] Must fix: reconcile with Platform's identity removal
Platform #235 merged since the previous review, removing these routes and rejecting identity tokens. Commands now target an unsupported API on current main. Retarget supported functionality or withdraw this feature.
| match body.get("grants") { | ||
| None => Ok(true), | ||
| Some(grants) => { | ||
| Ok::<_, anyhow::Error>(same_grants(current, grants, caller_member(api).await?)) |
There was a problem hiding this comment.
[P2] Must fix: do not compare redacted grants as complete access
The legacy API hides grants from non-managers. An assume-only caller's update --data '{"grants":[]}' now falsely succeeds despite other members retaining access. Require canManage before skipping the write.
| /// a different access for the caller, counts as a change so its error is shown. | ||
| fn same_grants(current: &Value, supplied: &Value, me: Uuid) -> bool { | ||
| let me = me.to_string(); | ||
| let access = |grant: &Value| (grant["canAssume"] == true, grant["canManage"] == true); |
There was a problem hiding this comment.
[P2] Must fix: validate grant fields before no-op comparison
canAssume:"true" becomes false; malformed grants can return success without granting access or reaching API validation. Reproduced locally. Validate UUIDs, required booleans, and list limits before comparing.
| clear: _, | ||
| } => { | ||
| let id = resolve(api, &identity).await?; | ||
| api.json( |
There was a problem hiding this comment.
[P2] Must fix: skip unchanged personal-account bindings
Repeated account --use and already-empty --clear still PUT. The legacy API unconditionally revokes the caller's sessions, interrupting agents despite unchanged settings. Compare current account bindings before writing.
| if identity_session { | ||
| write!( | ||
| f, | ||
| "; start a new one with `adapt identities sessions start`" |
There was a problem hiding this comment.
[P3] Explain how to clear the expired token override
With exported ADAPT_TOKEN, the recommended session-start command reuses the expired token and returns the same 401. Tell users to unset the override before issuing with their saved browser login.
| if self.status == StatusCode::FORBIDDEN && identity_session { | ||
| write!( | ||
| f, | ||
| "; an identity session works only in its own organization, so remove --org or ADAPT_ORG_ID" |
There was a problem hiding this comment.
[P3] Account for the saved organization in the 403 hint
Removing --org/ADAPT_ORG_ID restores the profile's saved organization, which can produce the same 403. Recommend explicitly selecting the identity's organization instead.
|
Closing without merging: Platform removed scoped identities in adapt/platform#235 (the |
Part of #7. This PR covers the identity commands;
adapt run --identityfollows in a separate PR.Summary
adapt identities list | get | create | update | enable | disable | deletemanage Platform identities (/v1/identities, from platform640c00b).adapt identities permissions IDENTITY [--allow RESOURCE:ACTION] [--deny RESOURCE:ACTION]shows or changes the Read/Write/Use grid. It accepts the dashboard's resource names (commands,endpoints,registries,models,mcp-tools,secrets) and the API's (execs,ingresses, …). It rejects actions Platform never checks, such assandboxes:use. As in the dashboard, allowing Write or Use also allows Read.adapt identities access IDENTITY MEMBER [--assume] [--manage]sets a member's access by member ID or email. With neither flag, it removes access.adapt identities account IDENTITY CONNECTION_ID --use PERSONAL_CONNECTION_ID | --clearchooses the caller's personal account for a connection that uses personal accounts.adapt identities sessions list | start | revokemanage identity sessions.createaccepts--name,--description,--allowand--max-session, filling in the permission resources Platform requires, so--datais only needed for connections, secrets and grants. Options override fields in--data.Behavior
update,enable,disableandpermissionsread the identity, apply only the change, leavegrantsout unless supplied, and save with the current version. Aversionin--datathat doesn't match is refused before saving.enableon an enabled identity, allowing a permission it already has, re-setting a member's current access.sessions startprints the token once in its response on stdout. The stderr note never includes it, and it's never saved.sessions revokere-reads the session list and fails if the session wasn't found or isn't revoked.adapt identities sessions startinstead ofadapt auth login. Matching uses Platform's exact message, so/mcp's "…an identity session, or an organization API key" 401 keeps the login hint.--orggets an organization hint.Docs
docs/cli-reference.mdhas a new Identities section covering permissions, member access, personal accounts and sessions.docs/api-coverage.mdand the bundled skill are updated.Testing
tests/identities/mod.rshas 34 mock-server tests:enable/disable, the no-op skips, anddelete.accessby email across pages, by member ID, the no-op skip, non-managers, and the member-ID hint.accountselecting, clearing and requiring a choice.createfrom options, options overriding--data, and required inputs.--allow/--denyapplication, the merge, the no-op comparison, the grid and the table rows.ADAPT_TOKEN, then failed with the new 401 hint after an edit ended its session.accessby email worked, and every hint appeared on the real error bodies.createfrom options worked, with--datamerging.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo test --lockedpass.Known limits
updatesupplies correctedconnections, and that includesdisable.deletestill works. The dashboard has the same limit.🤖 Generated with Claude Code