Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a8bfe70 to
b5f9d20
Compare
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/framework-cli/src/utilities/constants.rs (1)
118-146:⚠️ Potential issue | 🟡 MinorAdd rustdoc for new public constants (and the updated prompt).
Public API constants should use///docs; the current line comment won’t appear in rustdoc.Proposed fix
-// Keychain keys for remote ClickHouse credentials (separate from URL) +/// Keychain key for remote ClickHouse username (separate from URL). pub const KEY_REMOTE_CLICKHOUSE_USER: &str = "remote_clickhouse_user"; -// Keychain keys for remote ClickHouse credentials (separate from URL) +/// Keychain key for remote ClickHouse password (separate from URL). pub const KEY_REMOTE_CLICKHOUSE_PASSWORD: &str = "remote_clickhouse_password"; +/// Prompt shown when remote ClickHouse credentials are required for dev mirroring. pub const STORE_CRED_PROMPT: &str = r#"You have externally managed tables in your code base.As per coding guidelines "Document all public APIs and breaking changes".
🤖 Fix all issues with AI agents
In `@apps/framework-cli/src/cli/routines/mod.rs`:
- Around line 618-621: The parse_clickhouse_connection_string(remote_url).ok()
call swallows parsing errors and causes silent fallback; change this to handle
the Result explicitly (match or map_err) so parsing failures are logged or
warned before proceeding. Locate parse_clickhouse_connection_string and the
creation of remote_ch (used by ClickHouseRemote::from_config and
create_external_mirrors) and, on Err(e), emit a clear warning or error including
remote_url and e (using the existing logger), then pass None or bail depending
on desired behavior; ensure the log message mentions remote_url, the parse
error, and that local schema creation will be used if you keep the fallback.
- Around line 498-512: The PR adds a new config flag
project.dev.externally_managed.tables.create_local_mirrors but the dev
environment docs lack any mention; update the dev-environment.mdx reference to
document the [dev.externally_managed.tables] table and the create_local_mirrors
boolean: describe what setting create_local_mirrors = true does (creates local
mirrors for externally managed tables in dev), list default/behavior when false,
and include a short example TOML snippet showing the config and a brief note on
when to toggle it; ensure the section mentions the config key exactly as
project.dev.externally_managed.tables.create_local_mirrors so readers can map
docs to the code.
In `@apps/framework-cli/src/cli/routines/seed_data.rs`:
- Around line 792-894: The code duplicates the "check exists, optionally
drop-if-refresh" logic between create_external_tables_from_local_schema and
create_single_mirror; extract a helper (e.g., ensure_table_absent_or_skipped)
that accepts (&ClickHouseClient, &str db, &str table_name, bool
refresh_on_startup) and returns a Result<enum {Skipped, Ready}, String> (or
Result<bool, String> where true=ready) so both functions call it instead of
repeating local_client.table_exists, local_client.drop_table_if_exists and
pushing format_warning/format_error; update
create_external_tables_from_local_schema and create_single_mirror to call this
helper, handle the Skipped/Ready result, and keep existing calls to
format_warning/format_error/format_success unchanged.
In `@apps/framework-cli/src/framework/core/infrastructure_map.rs`:
- Around line 2971-2982: get_mirrorable_external_tables currently returns values
from a HashMap which is non-deterministic; collect the filtered Table references
into a Vec, sort that Vec by a stable key (e.g., Table::name or a stable id
field) using a deterministic comparator (lexicographic on name or numeric on
id), then return the sorted Vec so mirror creation/logs are reproducible; update
get_mirrorable_external_tables to perform the collect -> sort -> return sequence
while still filtering by life_cycle == LifeCycle::ExternallyManaged and
engine.supports_select().
In `@apps/framework-cli/src/infrastructure/olap/clickhouse/client.rs`:
- Around line 295-298: The SELECT query builder uses remote_database directly in
format!("SELECT * FROM `{}`.`{}` LIMIT 0", remote_database, table_name) without
validation; add the same identifier validation/sanitization used for
local_database and table_name (e.g., the validate_identifier or
sanitize_identifier helper used elsewhere) to verify or escape remote_database
before interpolation, and return an error if it contains invalid characters so
the constructed query is safe and consistent with the checks on
local_database/table_name.
- Around line 340-343: The call building select_query in insert_from_remote uses
remote_database without validation; add the same validation used elsewhere to
check remote_database (e.g., non-empty and matches the allowed identifier
pattern) before constructing select_query and return an error if invalid; update
the insert_from_remote function to validate remote_database (and reuse any
helper or regex used for table_name validation) so select_query =
format!("SELECT * FROM `{}`.`{}` LIMIT {}", remote_database, table_name, limit)
only runs with a sanitized/validated remote_database.
In `@apps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rs`:
- Around line 1-14: Add unit tests for the public resolver behavior: write tests
exercising resolve_remote_clickhouse (or the public function that resolves
config) using ClickHouseRemote/RemoteClickHouseConfig inputs to cover (1) when
no config exists (defaults applied), (2) when config exists and is used, (3)
rejection of empty passwords (simulate prompt_password/KeyringSecretRepository
returning empty and assert failure), and (4) port defaulting logic (when
protocol is Protocol::Http vs ClickHouseProtocol ensure port defaults match
expected values). Mock or stub SecretRepository/KeyringSecretRepository and
prompt_user/prompt_password to control inputs and assertions.
- Around line 108-139: store_credentials currently can leave the username saved
if storing the password fails; update store_credentials to perform a rollback on
partial success: after repo.store(project_name, KEY_REMOTE_CLICKHOUSE_USER,
user) succeeds but repo.store(...KEY_REMOTE_CLICKHOUSE_PASSWORD...) returns Err,
call the repository deletion method (e.g., repo.delete or repo.remove) to remove
KEY_REMOTE_CLICKHOUSE_USER for that project, map any errors to RoutineFailure
similarly, and then return the original error; reference the function
store_credentials and the constants KEY_REMOTE_CLICKHOUSE_USER /
KEY_REMOTE_CLICKHOUSE_PASSWORD and the repo.store call to locate where to add
the rollback.
In `@apps/framework-cli/src/project.rs`:
- Around line 271-276: Add a Rust doc comment for the public field `tables` on
the `DevExternallyManagedTablesConfig` struct: describe that it holds the
configuration for externally managed tables used in development mode, note that
it defaults via serde (#[serde(default)]), and mention the contained type
`DevExternallyManagedConfig` so users know what configuration is expected and
how it is used.
- Around line 288-307: Update the doc comment on the
RemoteClickHouseConfig::port field to clarify that the numeric defaults are not
set on the struct but are applied later during resolution in config_resolver.rs;
specifically change the comment to something like "Optional port; resolved to
8443 for SSL or 8123 for non-SSL during config resolution" so readers know the
defaults are applied by the config resolver rather than by the struct itself.
- Around line 310-321: DevConfig exposes two user-facing options that are
undocumented: externally_managed and remote_clickhouse; update the
dev-environment documentation to add entries for dev.externally_managed (explain
it maps to DevConfig.externally_managed / DevExternallyManagedTablesConfig, what
it controls, default behavior and an example of enabling externally managed
tables) and dev.remote_clickhouse (explain it maps to
DevConfig.remote_clickhouse / RemoteClickHouseConfig, describe that it is an
optional read-only ClickHouse connection, what credentials are expected to be
provided externally, defaults, and an example config snippet). Ensure both
entries mention types, defaults, and short examples so users know how to set
them in their config.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (11)
apps/framework-cli/src/cli/routines/mod.rsapps/framework-cli/src/cli/routines/seed_data.rsapps/framework-cli/src/framework/core/infra_reality_checker.rsapps/framework-cli/src/framework/core/infrastructure_map.rsapps/framework-cli/src/framework/core/plan.rsapps/framework-cli/src/framework/core/plan_validator.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rsapps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/project.rsapps/framework-cli/src/utilities/constants.rs
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Run
cargo clippyto ensure Rust code passes Clippy's linting standards before each commit
**/*.rs: Usethiserrorwith#[derive(thiserror::Error)]for error handling in Rust; define errors near the fallibility unit, never useanyhow::Result
Use snake_case for functions and variables, PascalCase for types and traits, SCREAMING_SNAKE_CASE for constants in Rust
Place constants inconstants.rsat the appropriate module level in Rust
Use tuple structs with validation constructors (newtypes) for Rust type safety (e.g.,struct UserId(String))
Write inline tests with#[cfg(test)]modules in Rust
Documentation is required for all public APIs in Rust
Runcargo clippy --all-targets -- -D warningsbefore committing Rust code; no warnings allowed
Files:
apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/framework/core/infra_reality_checker.rsapps/framework-cli/src/framework/core/plan_validator.rsapps/framework-cli/src/utilities/constants.rsapps/framework-cli/src/cli/routines/seed_data.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/cli/routines/mod.rsapps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rsapps/framework-cli/src/framework/core/infrastructure_map.rsapps/framework-cli/src/framework/core/plan.rsapps/framework-cli/src/project.rs
apps/framework-cli/**/*.rs
📄 CodeRabbit inference engine (apps/framework-cli/AGENTS.md)
apps/framework-cli/**/*.rs: Always runcargo clippy --all-targets -- -D warningsbefore commits; fix all warnings - no Clippy warnings may remain (treat warnings as errors)
Userustfmt --edition 2021for consistent formatting
Write meaningful names for functions, variables, and types
Document all public APIs and breaking changes
Usethiserrorcrate instead ofanyhow::Resultfor error handling
Define errors near their unit of fallibility (no global Error types)
Use#[derive(thiserror::Error)]with#[error()]messages for error definitions
Define newtypes as tuple structs:struct UserId(u64);
Add validation constructors for newtypes:UserId::new(id: u64) -> Result<Self, Error>
Derive standard traits for newtypes:#[derive(Debug, Clone, PartialEq)]
ImplementFrom/TryFromfor newtype conversions
Usederive_moreornutypeto reduce newtype boilerplate
Useconstfor static values (prefer overstatic)
UseUPPER_SNAKE_CASEnaming for constants
Scope constant visibility with preference:pub(crate)>pub(super)>pub
Group related constants together
Write unit tests for all public functions
Test error conditions and edge cases
Files:
apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/framework/core/infra_reality_checker.rsapps/framework-cli/src/framework/core/plan_validator.rsapps/framework-cli/src/utilities/constants.rsapps/framework-cli/src/cli/routines/seed_data.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/cli/routines/mod.rsapps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rsapps/framework-cli/src/framework/core/infrastructure_map.rsapps/framework-cli/src/framework/core/plan.rsapps/framework-cli/src/project.rs
**/framework-cli/src/**
⚙️ CodeRabbit configuration file
**/framework-cli/src/**: When reviewing changes to Moose CLI:
- Check if any user-facing changes were made (commands, flags, configs, apis, etc)
- If yes, verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content
- If docs for that feature doesn't exist yet, it should be added. If the change removes public apis, the documentation for those should also be removed. Changing unrelated docs doesn't satisfy this requirement.
- In addition to reviewing for docs discrepancies, you should also review the code as per usual guidelines.
Files:
apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/framework/core/infra_reality_checker.rsapps/framework-cli/src/framework/core/plan_validator.rsapps/framework-cli/src/utilities/constants.rsapps/framework-cli/src/cli/routines/seed_data.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/cli/routines/mod.rsapps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rsapps/framework-cli/src/framework/core/infrastructure_map.rsapps/framework-cli/src/framework/core/plan.rsapps/framework-cli/src/project.rs
apps/framework-cli/**/constants.rs
📄 CodeRabbit inference engine (apps/framework-cli/AGENTS.md)
Place constants in
constants.rsat deepest common module level
Files:
apps/framework-cli/src/utilities/constants.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: callicles
Repo: 514-labs/moosestack PR: 3143
File: apps/framework-cli/src/cli/routines/seed_data.rs:614-641
Timestamp: 2025-12-17T23:48:30.295Z
Learning: In apps/framework-cli/src/cli/routines/seed_data.rs, the create_mirror_schema function uses CREATE TABLE ... AS SELECT ... LIMIT 0 to create dev mirrors for EXTERNALLY_MANAGED tables. This intentionally does not preserve column codecs, TTL expressions, or materialized column definitions from the remote table, which is acceptable for local dev-only mirrors where matching column types is sufficient for materialized view sources.
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Document all public APIs and breaking changes
Applied to files:
apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/framework/core/infra_reality_checker.rsapps/framework-cli/src/utilities/constants.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/framework/core/plan.rsapps/framework-cli/src/project.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/constants.rs : Place constants in `constants.rs` at deepest common module level
Applied to files:
apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rsapps/framework-cli/src/utilities/constants.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Test error conditions and edge cases
Applied to files:
apps/framework-cli/src/framework/core/infra_reality_checker.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Write unit tests for all public functions
Applied to files:
apps/framework-cli/src/framework/core/infra_reality_checker.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Group related constants together
Applied to files:
apps/framework-cli/src/utilities/constants.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Use `const` for static values (prefer over `static`)
Applied to files:
apps/framework-cli/src/utilities/constants.rs
📚 Learning: 2025-12-16T23:09:10.917Z
Learnt from: CR
Repo: 514-labs/moosestack PR: 0
File: apps/framework-cli/AGENTS.md:0-0
Timestamp: 2025-12-16T23:09:10.917Z
Learning: Applies to apps/framework-cli/**/*.rs : Use `UPPER_SNAKE_CASE` naming for constants
Applied to files:
apps/framework-cli/src/utilities/constants.rs
📚 Learning: 2025-12-17T23:48:30.295Z
Learnt from: callicles
Repo: 514-labs/moosestack PR: 3143
File: apps/framework-cli/src/cli/routines/seed_data.rs:614-641
Timestamp: 2025-12-17T23:48:30.295Z
Learning: In apps/framework-cli/src/cli/routines/seed_data.rs, the create_mirror_schema function uses CREATE TABLE ... AS SELECT ... LIMIT 0 to create dev mirrors for EXTERNALLY_MANAGED tables. This intentionally does not preserve column codecs, TTL expressions, or materialized column definitions from the remote table, which is acceptable for local dev-only mirrors where matching column types is sufficient for materialized view sources.
Applied to files:
apps/framework-cli/src/cli/routines/seed_data.rsapps/framework-cli/src/infrastructure/olap/clickhouse/client.rsapps/framework-cli/src/cli/routines/mod.rsapps/framework-cli/src/framework/core/infrastructure_map.rsapps/framework-cli/src/project.rs
🧬 Code graph analysis (4)
apps/framework-cli/src/cli/routines/seed_data.rs (4)
apps/framework-cli/src/cli/display/status.rs (3)
format_error(47-49)format_success(25-27)format_warning(36-38)apps/framework-cli/src/infrastructure/olap/clickhouse/queries.rs (2)
table(3331-3336)create_table_query(3019-3430)apps/framework-cli/src/infrastructure/olap/clickhouse/client.rs (2)
config(49-51)new(36-47)apps/framework-cli/src/infrastructure/olap/clickhouse/mapper.rs (1)
std_table_to_clickhouse_table(350-379)
apps/framework-cli/src/infrastructure/olap/clickhouse/client.rs (1)
apps/framework-cli/src/infrastructure/olap/clickhouse/errors.rs (1)
validate_clickhouse_identifier(41-63)
apps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rs (4)
apps/framework-cli/src/cli.rs (2)
prompt_password(131-215)prompt_user(78-126)apps/framework-cli/src/utilities/validate_passthrough.rs (1)
None(515-515)apps/framework-cli/src/infrastructure/olap/clickhouse/client.rs (1)
host(105-107)apps/framework-cli/src/cli/display/message_display.rs (1)
show_message_wrapper(70-82)
apps/framework-cli/src/project.rs (6)
apps/framework-cli/src/framework/core/infrastructure_map.rs (1)
default(3576-3594)packages/py-moose-lib/moose_lib/main.py (1)
default(80-83)apps/framework-cli/src/project/python_project.rs (1)
default(66-92)apps/framework-cli/src/infrastructure/olap/clickhouse/model.rs (1)
default(586-588)apps/framework-cli/src/cli/processing_coordinator.rs (1)
default(97-99)apps/framework-cli/src/infrastructure/olap/clickhouse/diagnostics/mod.rs (1)
default(157-163)
🔇 Additional comments (16)
apps/framework-cli/src/framework/core/infra_reality_checker.rs (1)
865-907: LGTM: test fixture initializes DevConfig.apps/framework-cli/src/project.rs (2)
390-392: LGTM:Projectnow includesdevwith serde default.
444-468: LGTM:Project::newinitializesDevConfig::default().apps/framework-cli/src/framework/core/plan.rs (1)
857-896: LGTM: test project includesDevConfig::default().apps/framework-cli/src/framework/core/plan_validator.rs (1)
103-140: LGTM: test project includesDevConfig::default().apps/framework-cli/src/infrastructure/olap/clickhouse/mod.rs (1)
73-73: New module declaration looks good.Module is correctly placed alphabetically and follows existing patterns.
Per coding guidelines: this PR introduces user-facing external table mirroring functionality. Verify that documentation for this feature exists or is added in
apps/framework-docs-v2/content.[approve_code_changes, request_verification]
#!/bin/bash # Check for documentation related to external mirrors or externally managed tables fd -e md -e mdx . apps/framework-docs-v2/content --exec grep -l -i "external\|mirror" {} 2>/dev/null || echo "No matching docs found"apps/framework-cli/src/framework/core/infrastructure_map.rs (2)
2971-2982: Update Moose CLI docs for external mirror discovery.
This adds a new externally managed table mirroring capability. Verify the feature-specific docs underapps/framework-docs-v2/contentare updated.As per coding guidelines: “/framework-cli/src/: Check if any user-facing changes were made… verify the documentation for THAT SPECIFIC feature is updated in apps/framework-docs-v2/content.”
7790-7924: Verify linting and formatting compliance before merge.Unable to run
cargo clippy --all-targets -- -D warningsandcargo fmt --all -- --checkin the sandbox environment due to timeout. Please confirm locally that:
cargo fmt --all -- --checkpasses (no formatting changes needed)cargo clippy --all-targets -- -D warningsproduces no warningsapps/framework-cli/src/cli/routines/mod.rs (1)
358-431: LGTM: Well-structured mirror orchestration.Clean separation of remote vs local-schema paths. Error messages are user-friendly. Early return on
!create_local_mirrorsis efficient.apps/framework-cli/src/infrastructure/olap/clickhouse/client.rs (1)
269-312: Good documentation and structure.Clear doc comments explaining behavior, proper use of
#[allow(dead_code)]for future use, and consistent error propagation pattern.Also applies to: 314-357
apps/framework-cli/src/cli/routines/seed_data.rs (3)
738-779: LGTM: Clean external mirror creation.Properly uses
get_mirrorable_external_tables(), handles empty case, and iterates with clear status collection. Based on learnings, the schema-only approach (LIMIT 0) is intentional for dev mirrors.
646-652: Well-designed context struct.Clean encapsulation of mirror operation state. Lifetime annotation is correct.
657-724: LGTM: Solid single-mirror orchestration.Correct flow: check existence → skip/drop → create schema → seed data. Error handling returns formatted status strings consistently.
apps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rs (3)
21-74: LGTM: Clean credential resolution flow.Good early returns, proper validation of required fields, sensible port defaults (8443 for SSL, 8123 otherwise). Keychain integration is well-structured.
76-106: LGTM: User-friendly credential prompting.Clear messaging with host/database context. Empty password validation prevents silent failures.
141-173: LGTM: Correct partial credential handling.Returns
Noneif either user or password is missing, forcing re-prompt. Handles the partial storage scenario gracefully.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
apps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rs
Show resolved
Hide resolved
apps/framework-cli/src/infrastructure/olap/clickhouse/config_resolver.rs
Show resolved
Hide resolved
|
Addressed all CodeRabbit review feedback: Implemented:
Skipped (with reasoning):
|
9fa3675 to
0f65e28
Compare
0f65e28 to
ed58565
Compare
No description provided.