Skip to content

validate_cmd: 81 scopes kept as ~6 parallel hand-synced enumerations #618

Description

@ahuimanu

Observed

Adding or changing one gz validate --scope requires synchronized edits across ~7 files and ~10 sites inside the 1467-line validate_cmd.py alone. The same scope set is hand-enumerated in parallel:

  • validate() signature = 78 boolean params (check_<scope>: bool) — src/gzkit/commands/validate_cmd.py:1120-1198
  • re-enumerated in _other_scopes_active = any([...]):1215-1278
  • re-passed positionally into _collect_errors(...):1296
  • plus "<scope>": check_<scope> bool-maps and "<scope>": lambda: _validate_<scope>(...) dispatch dicts

One scope (req_kind_discipline) appears 10× in this file (rg -c) and across 7 files (parser flag, dispatch, audit impl, run_<scope>_audit wrapper, _build_check_steps). Live surface: 81 scopes (gz validate --help), 37 run_*_audit wrappers. validate_cmd.py is the repo's highest-churn file (83 touches/90d).

Expected

A single VALIDATOR_REGISTRY: dict[scope, ValidatorSpec] declaring each scope once (flag, audit callable, check-step membership). The parser flags, the dispatch, the any() guard, _collect_errors, and _build_check_steps are all derived from it — one declaration per scope, not ~6 parallel copies.

Canonical contradiction

AGENTS.md § MAKE LLM STOCHASTIC VIBES INERT (structure, not convention, on load-bearing seams). .claude/rules/pythonic.md size limits (validate_cmd.py = 1467 lines vs ≤600). The silent-drop failure mode below is the recurring class behind closed instances #394 and #473.

Class of failure

Add or rename any scope and miss one parallel enumeration → the scope silently stops running (drops from any(), or its bool never reaches _collect_errors) or crashes. This is the mechanical driver of gzkit's 52.6%-of-commits-are-fixes rate — the running cost of keeping ~6 copies × 81 scopes in hand-sync.

Scope hint (advisory, for routing)

  • Estimated diff: larger (registry + derive the 5-6 enumerations)
  • Surfaces touched: src/gzkit/commands/validate_cmd.py, src/gzkit/cli/parser_maintenance.py, src/gzkit/quality.py, src/gzkit/commands/quality.py
  • In-flight vs. new feature: structural remediation — likely its own ADR/OBPI

Related

Campaign home

Phase E (quality/infra) — booked as campaign item E.4 (additive dispatch drift-guards) and recorded in Appendix A as the structural root of the validator-was-the-defect tail (#394/#473), docs/governance/build-to-1.0-campaign-2026-06-10.md. The additive fence (validator-enumeration consistency test) is in-scope-now; the reductive VALIDATOR_REGISTRY collapse is Phase I per completion-before-reduction. Sibling of #615 (the decay class).

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectTracked defect discovered during implementation or governance workruntimeRuntime-affecting change (eligible for patch release)tech-debtQuality-of-implementation defect surfaced by gz-tech-debt-review or operator review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions