Skip to content

Client/host command classification with role-aware CLI display + auto-detection (CLN-3582) - #484

Open
sammy-vastai wants to merge 1 commit into
masterfrom
cln-3582-role-aware-cli
Open

Client/host command classification with role-aware CLI display + auto-detection (CLN-3582)#484
sammy-vastai wants to merge 1 commit into
masterfrom
cln-3582-role-aware-cli

Conversation

@sammy-vastai

@sammy-vastai sammy-vastai commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

  • Every command is classified host-only or not (is_host_only_command() in vastai/cli/parser.py) via an explicit host_only= kwarg, a per-command override set, or a per-module default (machines.py, metrics.py). Unclassified defaults to visible.
  • Role (client/host) is stored in ~/.config/vastai/vast_role. Unset = client, the default.
  • Auto-detected lazily on the user's next real command (get_client()ensure_host_role_detected()), via GET /users/current's host_agreement_accepted flag — resolves correctly even before a new host's first machine listing. Cached permanently once resolved; vastai set role host|client overrides manually.
  • The existing hand-written [Host] help-text prefixes are preserved as-is — no auto-generated prefix.

Validation

  • poetry run pytest tests/cli — 458 passed
  • bash tests/installer/run_tests.sh — 19 passed
  • CI green end to end

CLN-3582

@sammy-vastai

Copy link
Copy Markdown
Contributor Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on get_client().
  • Classify and tag commands as host-only, filtering them out of --help and tab completion for the client role, and add a host-only 401 “did you mean” hint.
  • Add vastai set role host|client plus related unit tests, and add a manual workflow_dispatch trigger 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.

Comment thread vastai/cli/main.py Outdated
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 thread vastai/cli/commands/auth.py Outdated
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 thread .github/workflows/installer-ci.yml Outdated
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 thread vastai/cli/util.py Outdated
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
sammy-vastai force-pushed the cln-3582-role-aware-cli branch from 3da1a7f to 4943169 Compare July 31, 2026 05:26
@sammy-vastai
sammy-vastai force-pushed the cln-3582-role-aware-cli branch 6 times, most recently from e6048f3 to f851643 Compare August 10, 2026 21:51
@sammy-vastai sammy-vastai changed the title Client/host command classification with role-aware CLI display + auto-detection CLN-3582: Client/host command classification with role-aware CLI display + auto-detection Aug 10, 2026
@sammy-vastai
sammy-vastai force-pushed the cln-3582-role-aware-cli branch from f851643 to 0386129 Compare August 10, 2026 21:57
@sammy-vastai sammy-vastai changed the title CLN-3582: Client/host command classification with role-aware CLI display + auto-detection Client/host command classification with role-aware CLI display + auto-detection (CLN-3582) Aug 10, 2026
@sammy-vastai
sammy-vastai force-pushed the cln-3582-role-aware-cli branch 4 times, most recently from b0de9da to b2e9cb6 Compare August 11, 2026 19:48
@sammy-vastai
sammy-vastai force-pushed the cln-3582-role-aware-cli branch from b2e9cb6 to 4320c5d Compare August 11, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants