Skip to content

op-reth: add CLI surface snapshot test - #22108

Draft
claude[bot] wants to merge 4 commits into
developfrom
claude/op-reth-cli-snapshot-test
Draft

op-reth: add CLI surface snapshot test#22108
claude[bot] wants to merge 4 commits into
developfrom
claude/op-reth-cli-snapshot-test

Conversation

@claude

@claude claude Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Requested by Josh Klopfenstein · Slack thread

Replaces #22107, which GitHub auto-closed after a transient bad force-push to the branch (the branch is now clean; the diff below is the intended 3-file change).

Before

op-reth inherits its entire CLI surface from the pinned upstream reth crates. A reth pin bump can add, remove, rename, or re-default operator-facing flags without producing any diff in this repository, so those changes ship silently and never get reviewed.

After

A snapshot test renders the full op-reth command tree — every subcommand and every argument, including hidden ones, with aliases, value names, env vars, defaults, possible values, and help text — into a deterministic text file checked in at rust/op-reth/crates/cli/tests/snapshots/cli.snap. Any CLI surface change now fails the test and must be acknowledged by regenerating the snapshot, which makes the change visible in review:

UPDATE_SNAPSHOT=1 cargo nextest run -p reth-optimism-cli --all-features cli_surface_snapshot

On mismatch the test prints the first differing line, prints the complete generated snapshot between BEGIN/END markers so it can be recovered verbatim from CI logs, and also writes it to the cargo target tmpdir.

How

The renderer in rust/op-reth/crates/cli/tests/cli_snapshot.rs walks the clap command tree built by CommandFactory (the same tree the binary parses) and emits one line per argument in clap definition order. It is deliberately hand-rolled and std-only:

  • It does not snapshot help output, which wraps at terminal width and varies by environment.
  • It renders only the short help, never the long help — long help embeds registry-derived content such as the built-in superchain chain list on the chain flag, which would churn on registry updates unrelated to the CLI surface.
  • Machine- and build-specific defaults are normalized to stable placeholders: defaults containing platform base directories (HOME, XDG dirs) and a small list of known build- or CPU-count-derived defaults (identity, builder.extradata, rpc.max-tracing-requests).
  • No new dependency is added; the comparison and update logic (UPDATE_SNAPSHOT=1) is plain std. The workspace has insta available, but using it here would require touching the lockfile and would not print the full snapshot on failure, which the CI recovery loop below relies on.

A short section was added to rust/UPDATING-RETH.md telling reth bumpers the snapshot will surface upstream CLI changes and how to regenerate it.

CI

The new test runs in the rust-tests CircleCI job (just test → cargo nextest run --workspace --all-features), which is part of the required-rust-ci gate. The test is gated on the crate dev feature because the dev-only test-vectors subcommand is part of the rendered surface; the --all-features run in CI enables it. Runs without that feature skip the test silently.

Caveats

The committed snapshot is a best-effort construction generated offline from the pinned reth sources — this environment cannot compile the Rust workspace (the reth git dependency is not fetchable here), so the snapshot could not be produced by running the test. The first CI run is expected to fail the new test; the authoritative snapshot will be printed between the BEGIN/END markers in the rust-tests output, and a follow-up commit pastes it into rust/op-reth/crates/cli/tests/snapshots/cli.snap (or a local checkout runs the UPDATE_SNAPSHOT command above), after which the job goes green.

Refs #21687


Generated by Claude Code

Renders the full clap command tree (every subcommand and argument,
including hidden ones) into a deterministic text snapshot and compares
it against a checked-in file, so any CLI surface change — typically
inherited silently from a reth pin bump — shows up as a reviewable
diff.

The renderer is hand-rolled and std-only: it avoids --help output
(terminal-width wrapping), long help (embeds the registry-derived
built-in chain list), and new dependencies. Machine- and
build-specific defaults (platform paths, client version strings,
CPU-count-derived values) are normalized to stable placeholders.

On mismatch the test prints the full generated snapshot between
BEGIN/END markers (recoverable from CI logs) and supports
UPDATE_SNAPSHOT=1 to rewrite the file in place.

The committed snapshot is a best-effort offline construction from the
pinned reth sources; the first CI run is expected to correct it.

Refs #21687

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017oDUppqTaWNyAbxV99uMMY
Co-authored-by: Josh Klopfenstein <joshklop@oplabs.co>
Replace the locally seeded CLI surface snapshot with the authoritative
version generated by the rust-tests CI job against the pinned reth
dependency (f2eecc6). Beyond help-text, alias, possible-value, and
positional-arg metadata differences, this corrects two semantic
mistakes in the offline approximation:

- --gpo.ignoreprice default is 0, not 2: DEFAULT_IGNORE_GAS_PRICE is
  U256::ZERO at the pinned rev.
- --engine.proof-jitter is absent: it is gated behind
  #[cfg(feature = "trie-debug")], which is not enabled in the CI
  test build.

Machine-specific defaults remain normalized placeholders.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Josh Klopfenstein <joshklop@oplabs.co>
@claude
claude Bot force-pushed the claude/op-reth-cli-snapshot-test branch from c8aad19 to 8d322b2 Compare July 29, 2026 17:17
claude and others added 2 commits July 29, 2026 17:24
The snapshot renderer emits trim_end() plus exactly one newline; the
committed file ended with two, which would still fail the byte-exact
comparison.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Josh Klopfenstein <joshklop@oplabs.co>
rust-clippy runs with -D warnings; bare "CircleCI" in the module doc
comment trips clippy::doc_markdown.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Josh Klopfenstein <joshklop@oplabs.co>
@sebastianst
sebastianst requested a review from joshklop July 30, 2026 08:45
@claude
claude Bot force-pushed the claude/op-reth-cli-snapshot-test branch from 6c7c483 to bf234d1 Compare July 30, 2026 09:00
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.

4 participants