Client/host command classification with role-aware CLI display + auto-detection (CLN-3582) - #484
Open
sammy-vastai wants to merge 1 commit into
Open
Client/host command classification with role-aware CLI display + auto-detection (CLN-3582)#484sammy-vastai wants to merge 1 commit into
sammy-vastai wants to merge 1 commit into
Conversation
This was referenced Jul 31, 2026
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
from
July 31, 2026 01:18
f94041a to
9d0857b
Compare
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a client vs host “display role” for the vastai CLI to hide host-only commands from --help, tab completion, and certain 401 error hints by default (client view), with a lazy best-effort role auto-detection triggered when a real client is created.
Changes:
- Add persistent role storage (
~/.config/vastai/vast_role) plus role helpers and lazy auto-detection onget_client(). - Classify and tag commands as host-only, filtering them out of
--helpand tab completion for the client role, and add a host-only 401 “did you mean” hint. - Add
vastai set role host|clientplus related unit tests, and add a manualworkflow_dispatchtrigger to installer CI.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vastai/cli/utils.py | Triggers lazy role detection after creating the API client. |
| vastai/cli/util.py | Adds role persistence and best-effort role auto-detection helper. |
| vastai/cli/parser.py | Implements host-only classification and role-based hiding for help + completions. |
| vastai/cli/main.py | Adds role-aware 401 hinting and filters completion candidates by role. |
| vastai/cli/commands/auth.py | Adds set role command to explicitly override the display role. |
| tests/cli/test_util.py | Adds unit tests for role file behavior and auto-detection caching. |
| tests/cli/test_parser.py | Adds tests for role-filtered completion/help and host-only classification. |
| tests/cli/test_main_error_handling.py | Adds tests for the new host-only 401 hint behavior. |
| tests/cli/test_auth_commands.py | Adds tests for set role command behavior. |
| .github/workflows/installer-ci.yml | Adds workflow_dispatch to re-run installer CI manually. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return | ||
|
|
||
| sp = getattr(getattr(args, "func", None), "mysignature", None) | ||
| if sp is not None and getattr(sp, "host_only", False) and is_client_view(get_role()): |
Comment on lines
+235
to
+237
| The role is auto-detected the first time you run a real command (or | ||
| 'vastai set api-key'), so most people never need to run this manually. | ||
| Use it to override the detected role — e.g. after your account starts |
Comment on lines
14
to
18
| # Manual escape hatch: the path-filtered pull_request trigger above occasionally drops a run silently (observed on PR #484); this lets it be re-run without an unrelated commit. | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: installer-ci-${{ github.event.pull_request.number }} |
Comment on lines
+228
to
+233
| try: | ||
| from vastai.api import billing as billing_api | ||
| is_host = bool(billing_api.show_user(client).get("host_agreement_accepted")) | ||
| except Exception: | ||
| return | ||
| set_role_file(ROLE_HOST if is_host else ROLE_CLIENT) |
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
from
July 31, 2026 05:26
3da1a7f to
4943169
Compare
vastzuby
approved these changes
Jul 31, 2026
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
6 times, most recently
from
August 10, 2026 21:51
e6048f3 to
f851643
Compare
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
from
August 10, 2026 21:57
f851643 to
0386129
Compare
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
4 times, most recently
from
August 11, 2026 19:48
b0de9da to
b2e9cb6
Compare
sammy-vastai
force-pushed
the
cln-3582-role-aware-cli
branch
from
August 11, 2026 19:49
b2e9cb6 to
4320c5d
Compare
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.
Renters (clients) no longer see host-only commands in
--help/tab completion (machine management, listings, min-bid, maintenance, etc.); hosts see everything. Display-only — the server still enforces real permissions, so any command still runs if typed directly.How
is_host_only_command()invastai/cli/parser.py) via an explicithost_only=kwarg, a per-command override set, or a per-module default (machines.py,metrics.py). Unclassified defaults to visible.client/host) is stored in~/.config/vastai/vast_role. Unset = client, the default.get_client()→ensure_host_role_detected()), viaGET /users/current'shost_agreement_acceptedflag — resolves correctly even before a new host's first machine listing. Cached permanently once resolved;vastai set role host|clientoverrides manually.[Host]help-text prefixes are preserved as-is — no auto-generated prefix.Validation
poetry run pytest tests/cli— 458 passedbash tests/installer/run_tests.sh— 19 passedCLN-3582