Skip to content

refactor(config): unify validator-count rules across modes #108

Open
kangeunchan wants to merge 1 commit intoaltuslabsxyz:mainfrom
kangeunchan:refactor/unify-validator-count-ssot
Open

refactor(config): unify validator-count rules across modes #108
kangeunchan wants to merge 1 commit intoaltuslabsxyz:mainfrom
kangeunchan:refactor/unify-validator-count-ssot

Conversation

@kangeunchan
Copy link
Collaborator

@kangeunchan kangeunchan commented Feb 26, 2026

Enhancement Description

Unify validator count rules across YAML/TOML/CLI paths to prevent late runtime failures and inconsistent behavior.

Summary

This PR introduces a single source of truth for validator count validation and applies it consistently across config and CLI entry points.

Previously, validator checks differed by path:

  • deploy used mode-aware bounds (docker: 1-100, local: 1-4)
  • some config/YAML paths effectively enforced 1-4 regardless of mode
  • dvb provision had no upper bound check in flag mode

Now all relevant paths use one shared validator rule.

What Changed

1) SSOT validator function

Added shared mode-aware validation in:

  • internal/config/validator.go
  • internal/config/validator_test.go

Rules:

  • local: 1-4
  • docker: 1-100
  • empty mode defaults to docker

2) Replaced inconsistent call sites with SSOT

Updated:

  • internal/config/validate.go
    • EffectiveConfig.Validate() now validates validator count by mode
    • ValidateFileConfig() now validates validator count by mode (when mode is set; defaults to docker otherwise)
  • internal/config/yaml_validator.go
  • internal/config/yaml_config.go
  • cmd/devnet-builder/commands/manage/deploy.go
  • cmd/dvb/provision.go

3) Interactive path consistency

Updated interactive validator prompt to use the same mode-aware bounds:

  • internal/config/interactive.go

4) Tests

Added/updated tests:

  • internal/config/validate_test.go
  • internal/config/validator_test.go
  • internal/config/yaml_validator_test.go
  • internal/config/yaml_config_test.go
  • cmd/dvb/provision_test.go

Why This Is Needed

This is a consistency bugfix, not a semantic change:

  • the documented/runtime intent already included mode-specific bounds
  • validation behavior differed by entry point
  • invalid config could pass one path and fail later after expensive provisioning steps

Behavior Notes / Regression Impact

This may tighten validation for users who previously relied on permissive or inconsistent paths.
Example: values that passed some YAML/TOML flows but violate mode-specific constraints now fail early with consistent errors.

Validation Performed

  • go test ./internal/config/...
  • go test ./cmd/devnet-builder/commands/manage/...
  • go test ./cmd/dvb/...
  • go test ./...

golangci-lint run was also executed; repository has existing baseline lint issues outside this PR scope.

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.

1 participant