Skip to content

refactor(api): split ClickStack models by resource (#1173) - #1181

Open
sdairs wants to merge 5 commits into
claude/1173-api-split-clickpipes-modelsfrom
claude/1173-api-split-clickstack-models
Open

sdairs wants to merge 5 commits into
claude/1173-api-split-clickpipes-modelsfrom
claude/1173-api-split-clickstack-models

Conversation

@sdairs

@sdairs sdairs commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Part of #1173 (6 of 6: models/clickstack). Stacked on #1180.

Summary

This splits src/models/clickstack.rs (6.7k lines) into src/models/clickstack/ and moves src/models/clickstack_enums.rs in as clickstack/enums.rs. Behaviour and the public surface are unchanged. mod.rs glob re-exports every submodule, so every crate-root and models::* path still resolves.

I chose the seams from the type-reference graph, starting at the request and response types of each Client method. Each resource's types are reachable only from that resource. Dashboard-only types are split into dashboards.rs and tiles.rs. The only types that alerts and dashboards share stay in mod.rs.

File Lines Contents
mod.rs 340 mod/pub use facade, plus the chart building blocks that alert and tile chart configs share: SelectItem, Formula, NumberFormat, BackgroundChart, NumberTileColorCondition and the between/equality/numeric colour conditions
alerts.rs 1469 alert request/response, channels, Alert*ChartConfig unions and their builder/raw-SQL variants, silenced/execution-error, overlay
dashboards.rs 806 dashboard create/update/response, containers and tabs, the Filter unions (query-expression, Prometheus label, source, static list), saved filter values (SQL and variable), validate-dashboard response
tiles.rs 2393 TileInput/TileOutput, TileConfig, every dashboard chart config (bar, categorical bar, line, stacked line, number, pie, table, heatmap, markdown, search, event patterns) and series, on-click types
sources.rs 1162 Source union; log, trace, metric, session and PromQL sources; materialized views, highlighted attributes, filter settings; connections
saved_searches.rs 75 saved search, input, filters
webhooks.rs 221 Webhook union and its variants, webhook input, validate-webhook response
roles.rs 284 role create/update, CASL permissions (ClickHouse and MongoDB conditions)
enums.rs 3303 git mv of clickstack_enums.rs, unchanged

Commits

  1. Pure git mvs, plus the minimal edit to compile. clickstack.rs → clickstack/mod.rs (99%) and clickstack_enums.rs → clickstack/enums.rs (100%), so blame follows both files. In mod.rs, use super::clickstack_enums::* becomes mod enums; pub use enums::*;. models.rs drops mod clickstack_enums and its re-export.
  2. Moves only. A script cut the items out at top-level boundaries and kept each file in the original order. Each union's trailing Default impl moved with its type. I compared the sorted line multisets before and after this commit. No line was removed, and the only added lines are mod, pub use and use lines. One of those is a #[cfg(doc)] import in alerts.rs, so the alert chart configs' rustdoc links to their tile counterparts still resolve (cargo doc -D warnings is clean). Review it with git show --color-moved=dimmed-zebra.
  3. Classifier. Every new models/clickstack/*.rs maps to NO_SUITES, as both parents did. The old paths stay mapped, as the classifier requires for deleted files. The install classifier needs no change.
  4. .git-blame-ignore-revs entry for commit 2. This SHA must be updated if the stack is rebased before merge.
  5. Docs. The crate's AGENTS.md layout section and the README layout table now describe src/models/clickstack/.

Visibility widenings

None. Every moved item was already pub. Submodules import shared types explicitly from super and the enums through super::enums::*.

Tests

  • Counts match before and after: 916 tests listed (887 passed, 29 ignored). The full sorted --list output is identical, module paths included. spec_coverage_test and model_facade_test pass untouched.
  • python3 scripts/check-openapi-drift.py --dry-run reports the same findings before and after (0 actionable).
  • cargo fmt --all, both clippy configurations, cargo check -p clickhousectl --no-default-features, cargo check --workspace --all-features, cargo test -p clickhouse-cloud-api -p clickhouse-openapi-analyzer and the Python classifier tests all pass.

Merge with a merge commit, not a squash. The .git-blame-ignore-revs entry names this PR's move commit. A squash merge would leave it pointing at a commit that isn't on main, and git would silently ignore it.

🤖 Generated with Claude Code


Note

Low Risk
Mechanical file moves and re-exports with no serde or type surface changes; risk is limited to merge/rebase hygiene for blame-ignore metadata.

Overview
Reorganizes the large monolithic ClickStack model layer into src/models/clickstack/, mirroring the existing clickpipes/ split pattern without changing API behavior or public paths.

clickstack.rs and clickstack_enums.rs become a directory: shared chart primitives stay in mod.rs, while alerts, dashboards, tiles, sources, saved searches, webhooks, roles, and enums live in dedicated modules re-exported through the facade. models.rs drops the separate clickstack_enums module; pub use clickstack::* still exposes the same crate-root types.

Supporting updates only: .git-blame-ignore-revs for the move commit, AGENTS.md / README layout notes, and the cloud integration classifier (new models/clickstack/*.rs paths mapped to NO_SUITES).

Reviewed by Cursor Bugbot for commit 5d5996b. Bugbot is set up for automated code reviews on this repo. Configure here.

sdairs and others added 5 commits October 30, 2026 20:54
…1173)

Move models/clickstack_enums.rs in as models/clickstack/enums.rs. mod.rs
now declares and glob re-exports enums in place of the old
`use super::clickstack_enums::*`, and models.rs drops its
clickstack_enums module, so models::* paths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the ClickStack models out of models/clickstack/mod.rs into alerts,
dashboards, tiles, sources, saved_searches, webhooks and roles
submodules. dashboards keeps the dashboard request/response, containers,
filters, saved filter values and validation types; tiles holds the tile
wrappers, every dashboard chart config and series, and the on-click
types. mod.rs keeps the chart building blocks that alert and tile chart
configs share (select items, formulas, number formats, background charts
and colour conditions) and glob re-exports every submodule, so
models::* paths are unchanged.

Moves only: the item text is unchanged; only mod/use lines were added,
including a #[cfg(doc)] import so the alert chart configs' intra-doc
links to their tile counterparts still resolve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each models/clickstack/*.rs module, enums.rs included, maps to no live
suite, like models/clickstack.rs and models/clickstack_enums.rs did.
The old paths stay mapped so diffs that name them remain classified.
The install classifier only inventories crates/clickhousectl and never
mapped either old path, so it needs no entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sdairs sdairs added enhancement New feature or request client Affects the HTTP client rust Pull requests that update rust code labels Oct 30, 2026
@sdairs
sdairs requested a review from iskakaushik as a code owner October 30, 2026 19:57
@sdairs
sdairs added this pull request to stack #1153 October 30, 2026 19:57
@sdairs sdairs added the run-cloud-integration Run live Cloud integration tests for this PR head label Oct 30, 2026
@sdairs
sdairs deployed to cloud-integration October 30, 2026 20:31 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
cloud-integration — 5d5996b8 Deployed Oct 30, 2026 by sdairs via Cloud integration tests #1500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Affects the HTTP client enhancement New feature or request run-cloud-integration Run live Cloud integration tests for this PR head rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant