DRY zaino-common#1371
Open
zancas wants to merge 3 commits into
Open
Conversation
Deduplicate zaino-common and delete its dead public API; net -247 lines of Rust, behavior preserved. logging.rs (386 -> 187 lines): - Collapse the six init_*/try_init_* bodies into one private try_install(LogConfig); init() panics if a global subscriber is already set, try_init() ignores that case. - Delete unused DisplayHash/DisplayHexStr and the unreachable programmatic config surface (LogConfig builder methods, show_span_events, the *_with_config entry points); LogConfig and LogFormat are now private. - The ZAINOLOG_FORMAT/ZAINOLOG_COLOR/RUST_LOG interface and all three output formats are unchanged. config/network.rs (371 -> 308 lines): - New activation_heights_mirror! macro records the NetworkUpgrade variant <-> ActivationHeights field correspondence once and expands to the two mirror From impls plus from_zebra_pairs (all-None init + upgrade-list walk). Exhaustive destructures and match keep full compile-time drift detection; a future network upgrade lands as a single (Variant, field) pair. - Delete Network::zaino_regtest_heights (no callers workspace-wide). CHANGELOG: breaking removals and internal refactors recorded under Unreleased; version bump deferred to release. Verified: cargo check --workspace, cargo clippy --all-targets, cargo fmt, cargo nextest run -p zaino-common (19/19 passed), doctests (8/8 passed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Compiler-verified sweep: each dependency in zaino-common's manifest was deleted one at a time and the crate re-checked with `cargo check -p zaino-common --all-targets`; a passing check kept the deletion, a failing one restored the dependency. Dropped (zero references, check passes without them): - thiserror — never used by this crate - nu-ansi-term — never used directly; tracing-tree pulls its own copy transitively - hex — last consumers were DisplayHash/DisplayHexStr, removed in the preceding DRY commit Kept (check fails without them): zebra-chain, serde, tracing, tracing-subscriber, tracing-tree, time. The root [workspace.dependencies] nu-ansi-term entry is now unused by every member but left in place; removing it is a separate root-manifest decision. Verified: cargo check --workspace --all-targets clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Deduplicates
zaino-commonand deletes its dead public API. Net −247 lines of Rust (391 deleted, 144 added including CHANGELOG), behavior preserved throughout.logging.rs— 386 → 187 linesinit_tree/try_init_tree/init_stream/try_init_stream/init_json/try_init_jsonbodies (plus the duplicatedEnvFilterconstruction) collapse into one privatetry_install(LogConfig) -> Result<(), TryInitError>.init()panics if a global subscriber is already set;try_init()ignores that case — same public semantics as before.DisplayHash,DisplayHexStr,init_with_config,try_init_with_config, theLogConfigbuilder methods, andshow_span_events(only settable through the deleted builder, so effectively constantfalse).LogConfig/LogFormatare now private, per minimum-visibility policy.ZAINOLOG_FORMAT/ZAINOLOG_COLOR/RUST_LOGbehave exactly as before, and all three output formats (stream/tree/json) are preserved.config/network.rs— 371 → 308 linesactivation_heights_mirror!declarative macro records theNetworkUpgrade-variant ↔ActivationHeights-field correspondence exactly once and expands to:Fromimpls betweenActivationHeightsand zebra'sConfiguredActivationHeights, andActivationHeights::from_zebra_pairs, replacing the hand-written all-Noneliteral + 12-arm upgrade match insideFrom<zebra_chain::parameters::Network>.(Variant, field)entry (plus the struct field). The macro's doc comment records why a macro (plainfns cannot abstract over struct fields;Nu5/nu5casing is not derivable inmacro_rules!) and why it also covers the upgrade walk (upstream conversion shape is stable; upgrades are the recurring edit).Network::zaino_regtest_heights— no callers anywhere in the workspace.CHANGELOG / versions
Breaking removals and the internal refactors are recorded in
packages/zaino-common/CHANGELOG.mdunder Unreleased. No version bumps — deferred to release per project policy.Verification
cargo check --workspace— cleancargo clippy -p zaino-common --all-targets— cleancargo fmt— appliedcargo nextest run -p zaino-common— 19/19 passed (includes the round-trip test now exercising the macro-generated impls)cargo test --doc -p zaino-common— 8/8 passed🤖 Generated with Claude Code