Skip to content

Resolve OpenAPI drift and add scaling-schedule API coverage#150

Merged
sdairs merged 5 commits into
issue-147-deprecate-cloud-clientfrom
issue-149-openapi-drift-scaling-schedule
May 14, 2026
Merged

Resolve OpenAPI drift and add scaling-schedule API coverage#150
sdairs merged 5 commits into
issue-147-deprecate-cloud-clientfrom
issue-149-openapi-drift-scaling-schedule

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented May 13, 2026

Summary

Resolves the daily OpenAPI drift report in #149 by:

  • Refreshing the committed OpenAPI snapshot.
  • Adding 7 new model types for the ClickHouse Cloud horizontal-autoscaling / scaling-schedule feature (CurrentScaling, ScalingSchedule, ScalingScheduleBaseConfig, ScalingScheduleEntry, ScalingScheduleEntryRequest, ScalingSchedulePatchRequest, ScalingSchedulePostRequest).
  • Adding 13 new struct fields to Service / ServiceScalingPatchResponse / ServiceReplicaScalingPatchRequest (currentScaling, scalingSchedule, minReplicas, maxReplicas, replicaMemoryGb).
  • Adding 3 new client methods: scaling_schedule_get, scaling_schedule_upsert, scaling_schedule_replace.

Resolver fix

The drift report also surfaced 86 field optionality mismatches caused by a recent spec convention shift: the OpenAPI team is now adding required[] arrays to schemas but only listing newly-introduced fields, leaving older fields to the existing "description doesn't start with 'Optional'" heuristic. Our previous resolver treated required[] as exclusive when present, which mis-classified every other field on Service and ServiceScalingPatchResponse as optional.

This PR introduces a PARTIAL_REQUIRED_SCHEMAS list (mirrored in both scripts/resolve-field-requirements.py and tests/spec_coverage_test.rs). Schemas in this list fall back to the description heuristic for fields absent from required[]. Currently Service and ServiceScalingPatchResponse. Other schemas with comprehensive required[] arrays (e.g. Scim*) keep the exclusive interpretation.

The Python drift checker now also parses NON_OPENAPI_CLIENT_METHODS and OPTIONALITY_EXEMPTIONS directly from spec_coverage_test.rs, so the daily report stays in sync with the Rust test's intentional divergences without a second source of truth.

Note

Stacked on #148 so it merges clean once that lands. Retarget to `main` after #148 (and #146) merge.

Closes #149.

Test plan

  • `cargo build` (workspace, macOS)
  • `cargo test --workspace` — 86 lib tests + 5 spec coverage tests + 249 CLI tests pass
  • `cargo clippy --workspace --all-targets` — no new warnings (pre-existing warnings in `spec_coverage_test.rs` are on lines untouched by this PR)
  • `python3 scripts/check-openapi-drift.py --dry-run` reports 0 drift
  • `python3 scripts/resolve-field-requirements.py --summary` shows 2 `partial_required` schemas
  • Cloud integration workflow run on this PR

🤖 Generated with Claude Code

Refreshes the OpenAPI snapshot and brings the typed client in sync with the
new horizontal-autoscaling / scaling-schedule feature on ClickHouse Cloud.
Also fixes a resolver bug exposed by a spec convention transition: the
OpenAPI team is starting to add `required[]` arrays to schemas but only
listing newly-introduced fields, which the previous required[]-exclusive
interpretation mis-classified as flipping every other field to optional.

- Adds 7 new model types: `CurrentScaling`, `ScalingSchedule`,
  `ScalingScheduleBaseConfig`, `ScalingScheduleEntry`,
  `ScalingScheduleEntryRequest`, `ScalingSchedulePatchRequest`,
  `ScalingSchedulePostRequest`.
- Adds 5 new fields to `Service` and `ServiceScalingPatchResponse`
  (`currentScaling`, `scalingSchedule`, `minReplicas`, `maxReplicas`,
  `replicaMemoryGb`) and 3 to `ServiceReplicaScalingPatchRequest`.
- Adds 3 new client methods: `scaling_schedule_get`,
  `scaling_schedule_upsert`, `scaling_schedule_replace`.
- Introduces `PARTIAL_REQUIRED_SCHEMAS` (mirrored in Rust and Python
  resolvers) so schemas whose `required[]` only lists new fields fall back
  to the description heuristic for older fields. Currently `Service` and
  `ServiceScalingPatchResponse`.
- Python drift checker now parses `NON_OPENAPI_CLIENT_METHODS` and
  `OPTIONALITY_EXEMPTIONS` from `spec_coverage_test.rs` to stay in sync
  with the Rust test's intentional divergences.

Closes #149.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner May 13, 2026 11:52
@sdairs sdairs temporarily deployed to cloud-integration May 13, 2026 11:53 — with GitHub Actions Inactive
sdairs and others added 3 commits May 13, 2026 13:49
Adds `BETA_OPERATIONS` (and `is_beta_operation`) to `clickhouse_cloud_api`,
sourced from `x-badges` Beta markers in the OpenAPI spec. Consumers — the
CLI in this repo, and any external user of the library — can now derive a
"(Beta)" affordance from spec metadata rather than maintaining a parallel
list by hand.

- New `meta.rs` module with a sorted constant of 36 snake-case operation
  names plus a `binary_search`-backed helper.
- `spec_coverage_test.rs` gains `beta_operations_match_spec` (snapshot)
  and `_live` variants. Drift produces a clear failure pointing at the
  regenerator script.
- `scripts/regenerate-beta-lists.py` reads the snapshot and prints the
  array body — run after each `clickhouse_cloud_openapi.json` refresh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`check-openapi-drift.py` now parses `BETA_OPERATIONS` out of `meta.rs`
and diffs it against `x-badges` Beta markers in the live spec. The
"Beta Status Changes" issue section calls out newly-Beta operations
(that need adding to the constant) and graduations (that need removing),
and the count rolls into the summary table.

This catches stability transitions that the snapshot-driven Rust test
cannot — e.g. an existing operation flipping from GA to Beta or vice
versa on the published spec before we refresh the snapshot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Postgres subcommand's help text already advertised "(beta)" via a
hand-written doc comment. Capitalise it to `(Beta)` (matching how the
OpenAPI spec's `x-badges` renders it) and add a test that asserts the
label is present iff `clickhouse_cloud_api::is_beta_operation` reports
the underlying operation as Beta. If Postgres ever graduates, the daily
drift check flags it, we delete the suffix, and the test keeps passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration May 13, 2026 12:49 — with GitHub Actions Inactive
Reverts commit e11d3bd. The label-and-test approach was overbuilt for
what it solved: the CLI never actually consults `is_beta_operation` at
runtime — clap renders help text from compile-time metadata, and
nothing in the CLI declares which client method each subcommand wraps.
The test held a literal string accountable to spec metadata without the
CLI ever consuming that metadata, which is rigour without leverage on a
surface that has one beta-backed command today.

The library-side `BETA_OPERATIONS` constant and the daily drift checker
remain. Those are the genuine consumers: external Rust callers of
`clickhouse-cloud-api` get a programmatic stability signal, and the
drift check flags upstream Beta/GA transitions. The Postgres help text
goes back to a hand-written `(beta)` doc comment — the same it was
before this stack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration May 13, 2026 13:11 — with GitHub Actions Inactive
@sdairs sdairs linked an issue May 13, 2026 that may be closed by this pull request
@sdairs sdairs merged commit b33c078 into issue-147-deprecate-cloud-client May 14, 2026
3 checks passed
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.

OpenAPI drift: 114 gaps between live spec and library

2 participants