Derive CLI value lists from library enums with analyzer drift guard#300
Merged
sdairs merged 2 commits intoJul 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 93f504b. Configure here.
…291) Replace eight hand-maintained KNOWN_* constant lists in the CLI with pub const VALUES on the library enums they validate against. The analyzer now verifies that any enum declaring a VALUES const has it exactly equal (as a set) to its non-catch-all wire values, producing FindingKind::EnumValuesMismatch on mismatch. Library (models.rs): - Add pub const VALUES to 9 enums: PgHaType, PgProvider, PgVersion, ServicePatchRequestReleasechannel, ServicePostRequestCompliancetype, ServicePostRequestProfile, ServicePostRequestProvider, ServicePostRequestRegion, ServicePostRequestReleasechannel. - VALUES on ServicePostRequestRegion includes europe-west2 and ca-central-1, fixing existing drift where the CLI rejected valid regions. Analyzer (clickhouse-openapi-analyzer): - rust_inventory.rs: parse Item::Impl blocks in models.rs to extract VALUES const string literals into EnumInfo.values_const. - report.rs: add FindingKind::EnumValuesMismatch, bump REPORT_SCHEMA_VERSION from 1 to 2. - compare.rs: compare_enum_values_consts checks every enum with a VALUES const against its wire values (set equality); emits EnumValuesMismatch with details[missing] and details[extra]. Python issue rendering: - check-openapi-drift.py: schema version check -> 2, summary table row and simple_sections entry for enum_values_mismatch. - test_check_openapi_drift.py: synthetic finding, assertion, and schema version rejection test updated. CLI (clickhousectl): - commands.rs: delete KNOWN_PROVIDERS, KNOWN_REGIONS, KNOWN_RELEASE_CHANNELS, KNOWN_COMPLIANCE_TYPES, KNOWN_PROFILES; use Enum::VALUES in parse_serde_enum calls. - postgres.rs: delete KNOWN_PG_PROVIDERS, KNOWN_PG_VERSIONS, KNOWN_PG_HA_TYPES; use Enum::VALUES in parse_serde_enum and PossibleValuesParser calls. Closes #291.
An impl block that lexically precedes its enum declaration was silently skipped, disabling the VALUES drift guard for that enum. Trait impls with an associated VALUES const were also misattributed. Address both review findings and replace the vacuous non-enum-impl test assertion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sdairs
force-pushed
the
issue-291-cli-known-values-drift-guard
branch
from
July 16, 2026 21:03
93f504b to
7e37405
Compare
This was referenced Jul 17, 2026
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.

Closes #291.
Summary
Replace eight hand-maintained
KNOWN_*constant lists in the CLI withpub const VALUESon the library enums they validate against. The analyzer now verifies that any enum declaring aVALUESconst has it exactly equal (as a set) to its non-catch-all wire values, producingFindingKind::EnumValuesMismatchon mismatch.This closes the drift chain: spec ↔ enum variants (guarded since #290) and enum variants ↔
VALUES(new check), soVALUESis transitively spec-accurate. A spec drift remediation that adds an enum value now flows automatically: spec → analyzer finding →models.rsvariant +VALUES(analyzer fails CI ifVALUESis not updated) → CLI validation, error messages, and--helpupdate with zero CLI edits.Changes
Library (
models.rs)pub const VALUES: &'static [&'static str]to 9 enums:PgHaType,PgProvider,PgVersion,ServicePatchRequestReleasechannel,ServicePostRequestCompliancetype,ServicePostRequestProfile,ServicePostRequestProvider,ServicePostRequestRegion,ServicePostRequestReleasechannel.VALUESonServicePostRequestRegionincludeseurope-west2andca-central-1, fixing existing drift where the CLI rejected valid regions.Analyzer (
clickhouse-openapi-analyzer)rust_inventory.rs: ParseItem::Implblocks inmodels.rsto extractVALUESconst string literals intoEnumInfo.values_const. 4 new inventory tests.report.rs: AddFindingKind::EnumValuesMismatch, bumpREPORT_SCHEMA_VERSIONfrom 1 to 2.compare.rs:compare_enum_values_constschecks every enum with aVALUESconst against its wire values (set equality); emitsEnumValuesMismatchwithdetails[missing]anddetails[extra]. 4 focused comparison tests.Python issue rendering
check-openapi-drift.py: Schema version check → 2, summary table row andsimple_sectionsentry forenum_values_mismatch.test_check_openapi_drift.py: Synthetic finding, assertion, and schema version rejection test updated.CLI (
clickhousectl)commands.rs: DeleteKNOWN_PROVIDERS,KNOWN_REGIONS,KNOWN_RELEASE_CHANNELS,KNOWN_COMPLIANCE_TYPES,KNOWN_PROFILES; useEnum::VALUESinparse_serde_enumcalls.postgres.rs: DeleteKNOWN_PG_PROVIDERS,KNOWN_PG_VERSIONS,KNOWN_PG_HA_TYPES; useEnum::VALUESinparse_serde_enumandPossibleValuesParsercalls.Documentation
AGENTS.md: AddedVALUESconst checking section under enum value coverage.Verification