Skip to content

refactor: RegistryBuilder duplicates six DimensionRegistry accessors #1491

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Summary

RegistryBuilder holds the same three fields that DimensionRegistry holds, and re-implements six accessors over them with identical bodies.

Detail

crates/graphcal-compiler/src/registry/types.rs:92-96 holds them as three loose fields:

pub struct RegistryBuilder {
    base_dim_names: BTreeMap<BaseDimId, String>,
    base_dim_symbols: BTreeMap<BaseDimId, String>,
    ...
    dimensions: HashMap<DimName, Dimension>,
    ...
}

and build() (types.rs:125-129) moves them verbatim into the registry:

dimensions: DimensionRegistry {
    base_dim_names: self.base_dim_names,
    base_dim_symbols: self.base_dim_symbols,
    dimensions: self.dimensions,
},

Both types then expose the same six accessors with identical bodies:

Method types.rs dimension_registry.rs
base_dim_names 424 169
base_dim_symbols 429 175
format_dimension 437 187
resolve_dim_expr 447 226 (#[cfg(test)])
resolve_dim_expr_detailed 455 233
resolve_type_expr 467 245

Note

The shared logic is already correctly factored into free *_impl functions in dimension_registry.rs (resolve_dim_expr_impl, resolve_dim_expr_detailed_impl, resolve_type_expr_impl, format_dimension_preferring_alias_after_validation). So this is purely six duplicated forwarders plus a duplicated field triple — a small, low-risk cleanup, not a logic duplication.

Suggested fix

Have RegistryBuilder own a DimensionRegistry under construction and delegate to it (or Deref to it for the read methods). build() then moves one field instead of three, and the accessors exist once.

Provenance

Found during a full-workspace code review at 6e462341a (v0.0.1-alpha.27). Baseline at that commit: cargo clippy --workspace --all-targets clean, cargo test --workspace 2926 passed / 0 failed, cargo deny check advisories ok.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions