Skip to content

cli: fold 5 binary-local diagnostic verbs into ServiceabilityCommand#3826

Merged
ben-dz merged 3 commits into
mainfrom
bdz/infra-1459
Jun 3, 2026
Merged

cli: fold 5 binary-local diagnostic verbs into ServiceabilityCommand#3826
ben-dz merged 3 commits into
mainfrom
bdz/infra-1459

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

@ben-dz ben-dz commented Jun 3, 2026

Summary of Changes

Moves 5 diagnostic CLI verbs (version, account, accounts, log, subscribe) from binary-local dispatch into the shared ServiceabilityCommand enum, conforming them to the RFC-20 async pattern (async fn execute<C: CliCommand, W: Write>(self, ctx: &CliContext, client: &C, out: &mut W)).

  • Infrastructure: Added client_version field to CliContext and builder; added get_account_data and get_transactions methods to CliCommand trait; re-exported DZTransaction from SDK
  • Verb migrations: All 5 verbs now use generic C: CliCommand + &CliContext + &mut W writer pattern. Added --json flag to account and log verbs with structured serializable output types
  • Dispatch consolidation: Moved enum variants into ServiceabilityCommand (with accounts and subscribe hidden); binary Command enum slimmed; binary-level override wired for subscribe to use real websocket streaming
  • Tests: 15 new unit tests across all 5 verbs using MockCliCommand, covering table output, JSON output, error paths, and parse verification

Fixes malbeclabs/infra#1459

Testing Verification

  • All 314 serviceability CLI tests pass (cargo test -p doublezero-serviceability-cli --lib)
  • 29 cli-core tests pass (cargo test -p doublezero-cli-core --lib)
  • SDK tests pass (cargo test -p doublezero-sdk --lib)
  • Clippy clean on all changed crates
  • Formatted with nightly rustfmt
  • Architecture and security reviews posted as issue comments — all MEDIUM findings addressed before push

ben-dz added 3 commits June 3, 2026 13:22
Migrate version, account, accounts, log, and subscribe from the binary's
top-level Command enum into ServiceabilityCommand per RFC-20. Each verb
now takes &CliContext + generic &C: CliCommand + &mut W writer and is
async. Add --json to account, accounts, and log (RFC-20 §Output). Add
client_version field to CliContext so the version verb reads the build
string from context instead of a passed parameter. Replace println!/
eprintln! in subscribe with writeln!/tracing. Subscribe uses get_all()
snapshot instead of the blocking websocket loop (DZClient::subscribe
takes FnMut which is incompatible with mockall's #[automock]).

Fixes #1459
Switch account/log validators from validate_pubkey_or_code to
validate_pubkey since these verbs only accept pubkeys. Add
tracing::warn for transaction fetch failures. Remove dead --json
flag from accounts (output is always JSON). Add binary-level
subscribe override using real DZClient::subscribe for live streaming.
…ation

Update Account, Accounts, and Log command dispatch in doublezero-admin
to use the new (&CliContext, &client, &mut writer).await signature.
Merge two use-statements in client/doublezero to satisfy rustfmt.
@ben-dz ben-dz marked this pull request as ready for review June 3, 2026 14:04
@ben-dz ben-dz requested a review from juan-malbeclabs June 3, 2026 14:04
Copy link
Copy Markdown
Contributor

@juan-malbeclabs juan-malbeclabs left a comment

Choose a reason for hiding this comment

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

LGTM

@ben-dz ben-dz merged commit 3495d1d into main Jun 3, 2026
33 checks passed
@ben-dz ben-dz deleted the bdz/infra-1459 branch June 3, 2026 15:33
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.

2 participants