Skip to content

docs/cli: add cli-standard.md and CLAUDE.md pointer#3758

Open
juan-malbeclabs wants to merge 3 commits into
jo/5-cli-location-get-conforming-verbfrom
jo/6-docs-cli-standard
Open

docs/cli: add cli-standard.md and CLAUDE.md pointer#3758
juan-malbeclabs wants to merge 3 commits into
jo/5-cli-location-get-conforming-verbfrom
jo/6-docs-cli-standard

Conversation

@juan-malbeclabs
Copy link
Copy Markdown
Contributor

@juan-malbeclabs juan-malbeclabs commented May 22, 2026

RFC-20 implementation stack

This PR is part of a 9-PR chain delivering RFC-20: CLI standardization. Each PR's diff is only its own contribution; reviewers should consume them in order.

# PR Scope
1 #3753 doublezero-cli-core foundation crate + solana_l1_rpc_url
2 #3754 --solana-url + --log-verbose global flags + tracing init
3 #3755 CliContext built in main + centralized error rendering
4 #3756 rename doublezero_clidoublezero-serviceability-cli
5 #3757 rewrite location get as the async + CliContext reference verb
6 #3758 docs/cli-standard.md + CLAUDE.md pointer
7 #3759 move per-resource subcommand wrappers into the module crate
8 #3760 add ServiceabilityCommand enum + async dispatcher
9 #3761 #[command(flatten)] + collapse binary dispatch

This PR: #3758 — position 6 of 9. Previous: #3757 · Next: #3759


Summary of Changes

  • Adds docs/cli-standard.md, the contributor-facing summary of RFC-20 (rfcs/rfc20-cli-standardization.md). Covers the module contract, argument and output conventions, the global flag set, the diagnostic-logging facade, the preflight RequirementCheck bitflags, and walks through smartcontract/cli/src/location/get.rs as the worked example.
  • Updates CLAUDE.md with a CLI-standard section pointing at RFC-20, the new contributor doc, and the reference verb so future contributors land on the standard quickly.

Diff Breakdown

Category Files Lines (+/-) Net
Docs 3 +253 / -0 +253
Total 3 +253 / -0 +253

Pure documentation: a single new contributor doc plus a short pointer added to CLAUDE.md and the CHANGELOG entry recording it.

Key files (click to expand)
  • docs/cli-standard.md - new file. Roughly 240 lines covering the module contract, argument/output conventions, global flags, logging, the location get worked example, the RequirementCheck bitflag mapping, authorization rules, and the explicit open follow-ups (Command enum move, geolocation module crate, daemon-control module crate, JSON schema versioning, shell completion).
  • CLAUDE.md - new "CLI Standard (RFC-20)" section between "RFCs and Documentation" and "Style & Terminology" with four bullets pointing at the RFC, the contributor doc, the core crate, and the migration cadence.

Testing Verification

  • make rust-test green workspace-wide (no code changes; sanity check that the docs commit does not break anything).
  • Manually previewed the rendered markdown of both docs/cli-standard.md and the updated CLAUDE.md section for headings, lists, and the code block in the worked example.
  • Targets jo/5-cli-location-get-conforming-verb; the diff shown is only this PR's docs.

@vihu
Copy link
Copy Markdown
Contributor

vihu commented May 22, 2026

The new CLI docs list diagnostic logging as --verbose, -v, but the actual doublezero binary currently exposes --log-verbose with no short alias:

#[arg(long = "log-verbose", action = clap::ArgAction::Count, global = true)]
log_verbosity: u8,

The code comment also says this was renamed from --verbose to avoid collisions with legacy per-subcommand --verbose flags. Could the docs and CLAUDE.md be updated to say --log-verbose unless this PR also intends to rename the implemented flag?

@vihu
Copy link
Copy Markdown
Contributor

vihu commented May 22, 2026

The argument convention says identifiers using validate_pubkey_or_code accept pubkey/code and that the literal "me" resolves to the current payer. The current validator does not special-case "me":

pub fn validate_pubkey_or_code(val: &str) -> Result<String, String> {
    val.parse::<Pubkey>()
        .map(|pubkey| pubkey.to_string())
        .or_else(|_| validate_code(val).map_err(|_| "invalid pubkey or code format".to_string()))
}

Since validate_account_code accepts alphanumeric strings, "me" is accepted as a normal code here, not as a magic payer token. Can the doc clarify that "me" only works on flags/verbs that explicitly resolve it, or should the shared validator/tests be changed to enforce the standard?

@juan-malbeclabs juan-malbeclabs force-pushed the jo/5-cli-location-get-conforming-verb branch from 8d806a7 to 5056078 Compare May 24, 2026 14:41
@juan-malbeclabs juan-malbeclabs force-pushed the jo/6-docs-cli-standard branch from 4196e46 to a65bc24 Compare May 24, 2026 14:41
@juan-malbeclabs
Copy link
Copy Markdown
Contributor Author

Good catch. The doc overclaimed. validate_pubkey_or_code does not special-case "me"; the string falls through validate_account_code because it happens to be alphanumeric. Resolution to the payer is implemented per-verb in the execute path (e.g. device/create.rs:133, accesspass/set.rs:63, tenant/create.rs:44).

Fixed in 9f364e7 by clarifying in three places that "me" resolution is a verb-level responsibility, not a validator behavior:

  • docs/cli-standard.md (argument conventions)
  • rfcs/rfc20-cli-standardization.md (normative source)
  • crates/doublezero-cli-core/src/validators.rs (module docstring)

Kept the validator as-is. Pushing resolution into a clap value_parser would need the payer pubkey from CliContext, which is a runtime input not available at parse time, and some validate_pubkey_or_code sites (e.g. device get --code, link get --code) are not payer-scoped at all. The right model is grammar in validators, resolution in verbs. A future ctx.resolve_pubkey_or_code(s) helper in doublezero-cli-core could de-duplicate the per-verb if x == "me" checks, but that is a separate change.

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