From 2eb9ca15707dfcc30343b739ffc438640092be03 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:22:44 +0000 Subject: [PATCH] refactor: move the shared core of the Python bindings into sqlbuild-python-base The native record, enum and error classes, the Python call plumbing, the host entry calls and the process allocator move into a new PyO3 crate that every later binding crate can depend on. sqlbuild-python imports them directly; the extension module surface is unchanged. --- Cargo.lock | 17 +- Cargo.toml | 5 +- crates/README.md | 23 +- crates/sqlbuild-python-base/Cargo.toml | 22 + .../src/boundary/_helpers}/allocator.rs | 0 .../src/boundary/_helpers}/call_arguments.rs | 0 .../src/boundary/_helpers}/config_values.rs | 2 +- .../src/boundary/_helpers}/expected_errors.rs | 0 .../src/boundary/_helpers}/mod.rs | 1 - .../src/boundary/_helpers}/oracles.rs | 0 .../src/boundary/_helpers}/panics.rs | 19 +- .../src/boundary/_helpers}/positional.rs | 9 +- .../boundary/_helpers}/positional_records.rs | 0 .../src/boundary/_helpers}/python_calls.rs | 91 +- .../src/boundary/main/call_argument.rs | 18 + .../src/boundary/main/call_with.rs | 15 + .../src/boundary/main/compiler_error.rs | 10 + .../src/boundary/main/compiler_guard.rs | 9 + .../boundary/main/config_value_to_python.rs | 12 + .../src/boundary/main/context_variable.rs | 19 + .../src/boundary/main/imported.rs | 13 + .../src/boundary/main/json_value_to_python.rs | 16 + .../src/boundary/main/keywords.rs | 17 + .../src/boundary/main/mod.rs | 15 + .../boundary/main/native_compiler_error.rs | 10 + .../boundary/main/register_expected_errors.rs | 12 + .../main/register_native_compiler_error.rs | 12 + .../src/boundary/main/register_oracles.rs | 12 + .../src/boundary/main/value_error.rs | 10 + .../src/boundary/main/within.rs | 15 + .../sqlbuild-python-base/src/boundary/mod.rs | 5 + .../src/boundary/models.rs | 139 +++ crates/sqlbuild-python-base/src/lib.rs | 8 + .../src/native_host/_helpers}/host.rs | 2 +- .../src/native_host/_helpers/mod.rs | 1 + .../src/native_host/main/flush_console.rs | 11 + .../src/native_host/main/host_entry.rs | 14 + .../src/native_host/main/log_debug_message.rs | 11 + .../native_host/main/log_warning_message.rs | 11 + .../src/native_host/main/mod.rs | 9 + .../src/native_host/main/module_installed.rs | 11 + .../src/native_host/main/python_executable.rs | 12 + .../main/redirect_stdout_to_stderr.rs | 13 + .../native_host/main/within_identity_pass.rs | 14 + .../src/native_host/main/write_console.rs | 11 + .../src/native_host/mod.rs | 4 + .../_helpers/compile_records/constants.rs | 4 +- .../records}/_helpers/compile_records/mod.rs | 0 .../_helpers/compiler_enums/constants.rs | 2 +- .../records}/_helpers/compiler_enums/mod.rs | 0 .../_helpers/compiler_errors/constants.rs | 4 +- .../records}/_helpers/compiler_errors/mod.rs | 0 .../_helpers/compiler_records/constants.rs | 4 +- .../records}/_helpers/compiler_records/mod.rs | 0 .../_helpers/contract_records/constants.rs | 4 +- .../records}/_helpers/contract_records/mod.rs | 0 .../src/records/_helpers/mod.rs | 9 + .../_helpers/native_classes}/behaviours.rs | 4 +- .../_helpers/native_classes}/construct.rs | 4 +- .../_helpers/native_classes}/error_classes.rs | 6 +- .../_helpers/native_classes}/fields.rs | 20 +- .../_helpers/native_classes}/getters.rs | 4 +- .../records/_helpers/native_classes/ids.rs | 1010 +++++++++++++++++ .../records/_helpers/native_classes}/mod.rs | 3 - .../_helpers/native_classes}/registration.rs | 64 +- .../_helpers/native_classes}/registry.rs | 6 +- .../_helpers/planner_records/constants.rs | 6 +- .../_helpers/planner_records/defaults.rs | 4 +- .../records}/_helpers/planner_records/mod.rs | 0 .../_helpers/rule_records/constants.rs | 4 +- .../src/records}/_helpers/rule_records/mod.rs | 0 .../_helpers/scope_records/constants.rs | 4 +- .../records}/_helpers/scope_records/mod.rs | 0 .../src}/records/constants.rs | 24 +- .../records/main/construct/enum_from_value.rs | 19 + .../src/records/main/construct/enum_member.rs | 14 + .../src/records/main/construct/error_class.rs | 14 + .../src/records/main/construct/mod.rs | 9 + .../main/construct/new_annotated_error.rs | 17 + .../src/records/main/construct/new_error.rs | 12 + .../main/construct/new_helped_error.rs | 17 + .../src/records/main/construct/new_record.rs | 21 + .../records/main/construct/new_record_with.rs | 18 + .../records/main/construct/record_class.rs | 14 + .../src/records/main/fields/all_specs.rs | 10 + .../src/records/main/fields/by_attribute.rs | 16 + .../src/records/main/fields/cached_value.rs | 14 + .../records/main/fields/enum_member_value.rs | 9 + .../src/records/main/fields/field.rs | 13 + .../src/records/main/fields/field_text.rs | 12 + .../src/records/main/fields/mapping_get.rs | 15 + .../src/records/main/fields/mapping_get_or.rs | 16 + .../src/records/main/fields/mapping_items.rs | 12 + .../src/records/main/fields/mapping_values.rs | 12 + .../src/records/main/fields/mod.rs | 18 + .../src/records/main/fields/path_posix.rs | 12 + .../records/main/fields/path_posix_text.rs | 12 + .../src/records/main/fields/path_stem.rs | 12 + .../main/fields/record_attribute_opt.rs | 15 + .../src/records/main/fields/record_spec.rs | 13 + .../src/records/main/fields/replaced.rs | 15 + .../records/main/fields/replaced_keywords.rs | 16 + .../src/records/main/fields/store_cached.rs | 18 + .../src/records/main/mod.rs | 3 + .../src/records/main/registry/capture.rs | 12 + .../src/records/main/registry/class_of.rs | 13 + .../src/records/main/registry/mod.rs | 7 + .../src/records/main/registry/native_attr.rs | 14 + .../src/records/main/registry/record_named.rs | 11 + .../records/main/registry/register_records.rs | 18 + .../main/registry/verify_attributes.rs | 12 + .../records/main/registry/verify_tables.rs | 10 + .../sqlbuild-python-base/src/records/mod.rs | 7 + .../src}/records/models.rs | 107 +- .../sqlbuild-python-base/src/records/types.rs | 995 ++++++++++++++++ .../src}/types.rs | 6 +- crates/sqlbuild-python/Cargo.toml | 2 +- .../_helpers/analysis/binding_catalog.rs | 20 +- .../_helpers/analysis/binding_locations.rs | 1 + .../src/bindings/_helpers/analysis/catalog.rs | 4 +- .../src/bindings/_helpers/analysis/getters.rs | 4 +- .../_helpers/analysis/normalization.rs | 4 +- .../analysis/normalization_results.rs | 2 +- .../bindings/_helpers/analysis/positions.rs | 2 +- .../src/bindings/_helpers/analysis/queries.rs | 4 +- .../_helpers/analysis/relation_names.rs | 4 +- .../_helpers/analysis/required_columns.rs | 10 +- .../_helpers/analysis/schema_request.rs | 8 +- .../_helpers/analysis/sql_test_comparisons.rs | 8 +- .../bindings/_helpers/analysis/sql_tests.rs | 4 +- .../analysis_session/fixture_columns.rs | 13 +- .../analysis_session/fixture_inferences.rs | 4 +- .../_helpers/analysis_session/getters.rs | 4 +- .../analysis_session/model_analyses.rs | 14 +- .../analysis_session/nullability_rules.rs | 2 +- .../_helpers/analysis_session/oracle.rs | 5 +- .../analysis_session/outcome_objects.rs | 9 +- .../analysis_session/profile_inputs.rs | 12 +- .../analysis_session/query_columns.rs | 5 +- .../_helpers/analysis_session/session.rs | 5 +- .../analysis_session/stage_functions.rs | 11 +- .../_helpers/attachments/ceremonial_select.rs | 2 +- .../_helpers/attachments/cursor_intrinsics.rs | 8 +- .../_helpers/attachments/reference_markers.rs | 6 +- .../_helpers/audit_command/command.rs | 21 +- .../bindings/_helpers/auditing/identity.rs | 6 +- .../bindings/_helpers/auditing/measurement.rs | 8 +- .../src/bindings/_helpers/auditing/render.rs | 6 +- .../_helpers/auditing/schema_audits.rs | 6 +- .../_helpers/authored_values/fields.rs | 2 +- .../_helpers/authored_values/project_vars.rs | 4 +- .../_helpers/authored_values/python_nodes.rs | 12 +- .../_helpers/authored_values/sql_values.rs | 12 +- .../_helpers/boundary/keyword_request.rs | 58 - .../_helpers/build_command/command.rs | 15 +- .../_helpers/build_command/completion.rs | 17 +- .../_helpers/build_command/defer_clone.rs | 30 +- .../_helpers/build_command/execution.rs | 32 +- .../_helpers/build_command/invocation.rs | 11 +- .../_helpers/build_command/lifecycle.rs | 23 +- .../_helpers/build_command/planning.rs | 13 +- .../_helpers/build_command/policies.rs | 8 +- .../_helpers/build_command/support.rs | 2 +- .../_helpers/build_progress/audit_progress.rs | 5 +- .../build_progress/build_callbacks.rs | 8 +- .../_helpers/build_progress/getters.rs | 4 +- .../build_progress/nested_progress.rs | 5 +- .../_helpers/build_progress/plan_facts.rs | 2 +- .../_helpers/build_progress/progress.rs | 10 +- .../build_progress/progress_reporters.rs | 2 +- .../_helpers/build_progress/progress_text.rs | 9 +- .../_helpers/build_progress/result_text.rs | 2 +- .../_helpers/build_progress/terminal.rs | 5 +- .../build_progress/transient_lines.rs | 2 +- .../build_progress/transient_status.rs | 5 +- .../bindings/_helpers/cache/native_store.rs | 14 +- .../_helpers/cache/sql_test_scan_store.rs | 2 +- .../_helpers/change_selection/base_compile.rs | 9 +- .../change_selection/definition_snapshot.rs | 2 +- .../_helpers/change_selection/fingerprints.rs | 2 +- .../_helpers/change_selection/selection.rs | 2 +- .../bindings/_helpers/check/check_command.rs | 33 +- .../src/bindings/_helpers/check/check_core.rs | 33 +- .../bindings/_helpers/check/check_results.rs | 4 +- .../src/bindings/_helpers/cli/argv.rs | 6 +- .../src/bindings/_helpers/cli/dispatch.rs | 17 +- .../src/bindings/_helpers/cli/entry.rs | 38 +- .../src/bindings/_helpers/cli/namespace.rs | 4 +- .../bindings/_helpers/cli/observability.rs | 24 +- .../src/bindings/_helpers/cli/termination.rs | 8 +- .../bindings/_helpers/clone/clone_command.rs | 19 +- .../_helpers/clone/clone_execution.rs | 32 +- .../bindings/_helpers/clone/clone_pipeline.rs | 10 +- .../bindings/_helpers/clone/clone_progress.rs | 2 +- .../_helpers/command_runtime/adapters.rs | 14 +- .../_helpers/command_runtime/concurrency.rs | 2 +- .../_helpers/command_runtime/connection.rs | 10 +- .../_helpers/command_runtime/invocation.rs | 11 +- .../command_runtime/preview_target.rs | 2 +- .../command_runtime/runtime_errors.rs | 6 +- .../command_runtime/warehouse_scope.rs | 5 +- .../_helpers/command_runtime/warehouses.rs | 28 +- .../compile_attachment/cursor_roles.rs | 8 +- .../compile_attachment/declaration_scope.rs | 14 +- .../compile_attachment/effective_config.rs | 12 +- .../compile_attachment/model_config.rs | 8 +- .../compile_attachment/model_inputs.rs | 26 +- .../sql_expansion_context.rs | 14 +- .../compile_attachment/storage_policies.rs | 8 +- .../_helpers/compile_attachment/target.rs | 5 +- .../_helpers/compile_command/getters.rs | 4 +- .../_helpers/compile_command/models.rs | 2 +- .../compile_command/prepared_artifacts.rs | 9 +- .../_helpers/compile_command/report.rs | 18 +- .../_helpers/compile_command/reuse_attempt.rs | 22 +- .../compile_command/reuse_recording.rs | 15 +- .../compile_command/runtime_identity.rs | 10 +- .../compile_command/startup_inputs.rs | 2 +- .../_helpers/compile_command/target_writer.rs | 29 +- .../compile_command/test_artifact_cache.rs | 6 +- .../compile_context/compile_timings.rs | 2 +- .../compile_context/diagnostic_collector.rs | 9 +- .../_helpers/compile_context/getters.rs | 4 +- .../_helpers/compile_context/image_facts.rs | 2 +- .../bindings/_helpers/compile_delta/driver.rs | 2 +- .../_helpers/compile_delta/report_hooks.rs | 2 +- .../_helpers/compile_driver/analysis.rs | 21 +- .../_helpers/compile_driver/analysis_cache.rs | 9 +- .../_helpers/compile_driver/assembly.rs | 14 +- .../compile_driver/assembly_analysis.rs | 22 +- .../compile_driver/assembly_checks.rs | 15 +- .../_helpers/compile_driver/assembly_facts.rs | 8 +- .../compile_driver/assembly_models.rs | 12 +- .../compile_driver/assembly_project.rs | 15 +- .../compile_driver/assembly_sql_tests.rs | 18 +- .../_helpers/compile_driver/command.rs | 22 +- .../compile_driver/config_validation.rs | 15 +- .../_helpers/compile_driver/deferral.rs | 15 +- .../bindings/_helpers/compile_driver/diff.rs | 15 +- .../_helpers/compile_driver/discovery.rs | 21 +- .../_helpers/compile_driver/inputs.rs | 21 +- .../compile_driver/integration_loaders.rs | 15 +- .../_helpers/compile_driver/phases.rs | 16 +- .../_helpers/compile_driver/pipeline.rs | 16 +- .../compile_driver/pipeline_entries.rs | 10 +- .../_helpers/compile_driver/plan_pipeline.rs | 19 +- .../_helpers/compile_driver/plan_result.rs | 14 +- .../_helpers/compile_driver/project.rs | 12 +- .../compile_driver/python_plan_entries.rs | 22 +- .../compile_driver/relation_targets.rs | 16 +- .../compile_driver/selection_phases.rs | 10 +- .../_helpers/compile_driver/static_context.rs | 10 +- .../compile_driver/target_defaults.rs | 11 +- .../_helpers/compile_driver/targets.rs | 13 +- .../_helpers/compile_outputs/artifacts.rs | 2 +- .../_helpers/compile_outputs/json_report.rs | 5 +- .../_helpers/compile_outputs/reuse.rs | 3 +- .../compile_outputs/runtime_target.rs | 4 +- .../compiled_project/attachment_inputs.rs | 1 + .../_helpers/compiled_project/project.rs | 7 +- .../_helpers/compiled_project/rows.rs | 1 + .../_helpers/compiled_project/schema_facts.rs | 3 +- .../compiled_project/snapshot_boundary.rs | 3 +- .../compiled_project/snapshot_execution.rs | 2 +- .../compiled_project/snapshot_roles.rs | 2 +- .../_helpers/compiled_project/values.rs | 6 +- .../_helpers/compiled_views/audit_reads.rs | 2 +- .../_helpers/compiled_views/audit_views.rs | 2 +- .../compiled_views/compiled_model_analysis.rs | 7 +- .../compiled_views/compiled_model_view.rs | 2 +- .../_helpers/compiled_views/function_reads.rs | 2 +- .../_helpers/compiled_views/function_views.rs | 3 +- .../_helpers/compiled_views/getters.rs | 4 +- .../compiled_views/model_input_view.rs | 2 +- .../_helpers/compiled_views/model_reads.rs | 2 +- .../_helpers/compiled_views/project_reads.rs | 2 +- .../_helpers/compiled_views/project_view.rs | 2 +- .../_helpers/compiled_views/records.rs | 12 +- .../_helpers/compiled_views/relation_keys.rs | 3 +- .../_helpers/compiled_views/resource_reads.rs | 2 +- .../_helpers/compiled_views/seed_reads.rs | 2 +- .../_helpers/compiled_views/seed_views.rs | 3 +- .../_helpers/compiled_views/source_reads.rs | 2 +- .../_helpers/compiled_views/source_views.rs | 5 +- .../_helpers/compute_logs/conversion.rs | 19 +- .../bindings/_helpers/compute_logs/getters.rs | 4 +- .../bindings/_helpers/compute_logs/storage.rs | 18 +- .../bindings/_helpers/consumption/facts.rs | 4 +- .../bindings/_helpers/consumption/policy.rs | 2 +- .../bindings/_helpers/consumption/recorder.rs | 2 +- .../_helpers/consumption/relation_reads.rs | 3 +- .../_helpers/contract_command/command.rs | 14 +- .../_helpers/contract_command/write.rs | 15 +- .../contracts/contract_diagnostics.rs | 7 +- .../_helpers/contracts/effective_config.rs | 2 +- .../_helpers/contracts/model_contracts.rs | 4 +- .../_helpers/contracts/resource_identities.rs | 4 +- .../_helpers/contracts/spec_resolution.rs | 12 +- .../_helpers/contracts/state_literals.rs | 6 +- .../bindings/_helpers/cost_command/bounds.rs | 8 +- .../bindings/_helpers/cost_command/command.rs | 4 +- .../bindings/_helpers/cost_command/refresh.rs | 15 +- .../bindings/_helpers/cost_command/refusal.rs | 4 +- .../_helpers/cost_report/degradation.rs | 16 +- .../_helpers/cost_report/functions.rs | 2 +- .../_helpers/cost_report/publication.rs | 2 +- .../bindings/_helpers/cost_report/records.rs | 19 +- .../_helpers/cost_telemetry/allocation.rs | 15 +- .../_helpers/cost_telemetry/context.rs | 12 +- .../_helpers/cost_telemetry/ledger.rs | 17 +- .../_helpers/cost_telemetry/snowflake.rs | 16 +- .../_helpers/cost_telemetry/values.rs | 4 +- .../bindings/_helpers/cursor/conversion.rs | 18 +- .../src/bindings/_helpers/cursor/durations.rs | 5 +- .../src/bindings/_helpers/cursor/intervals.rs | 10 +- .../src/bindings/_helpers/cursor/overrides.rs | 8 +- .../src/bindings/_helpers/cursor/scalars.rs | 14 +- .../src/bindings/_helpers/cursor/values.rs | 5 +- .../_helpers/dag_artifact/artifact.rs | 6 +- .../_helpers/dag_artifact/projection.rs | 10 +- .../bindings/_helpers/dag_artifact/rows.rs | 4 +- .../_helpers/dag_artifact/selection.rs | 12 +- .../_helpers/dagster_invocation/access.rs | 8 +- .../_helpers/dagster_invocation/arguments.rs | 5 +- .../_helpers/dagster_invocation/failures.rs | 4 +- .../_helpers/dagster_invocation/results.rs | 9 +- .../_helpers/dagster_invocation/translator.rs | 6 +- .../_helpers/dbt_command/auto_init.rs | 6 +- .../bindings/_helpers/dbt_command/command.rs | 17 +- .../bindings/_helpers/dbt_command/debug.rs | 2 +- .../src/bindings/_helpers/dbt_command/init.rs | 11 +- .../_helpers/dbt_command/init_project.rs | 18 +- .../bindings/_helpers/dbt_command/support.rs | 2 +- .../bindings/_helpers/dbt_events/getters.rs | 4 +- .../bindings/_helpers/dbt_events/results.rs | 6 +- .../bindings/_helpers/dbt_events/stream.rs | 4 +- .../src/bindings/_helpers/dbt_interop/cli.rs | 17 +- .../_helpers/dbt_interop/event_stream.rs | 8 +- .../_helpers/dbt_interop/execution.rs | 6 +- .../bindings/_helpers/dbt_interop/getters.rs | 4 +- .../bindings/_helpers/dbt_interop/graph.rs | 13 +- .../bindings/_helpers/dbt_interop/manifest.rs | 12 +- .../_helpers/dbt_interop/orchestration.rs | 13 +- .../bindings/_helpers/dbt_interop/pipeline.rs | 39 +- .../_helpers/dbt_interop/pipeline_phases.rs | 12 +- .../_helpers/dbt_interop/pipeline_prologue.rs | 14 +- .../src/bindings/_helpers/dbt_interop/plan.rs | 16 +- .../_helpers/dbt_interop/plan_output.rs | 22 +- .../bindings/_helpers/dbt_interop/profile.rs | 12 +- .../dbt_interop/profile_connection.rs | 11 +- .../_helpers/dbt_interop/profile_load.rs | 11 +- .../dbt_interop/reference_resolver.rs | 21 +- .../bindings/_helpers/dbt_interop/runner.rs | 19 +- .../_helpers/dbt_interop/runtime_config.rs | 16 +- .../_helpers/dbt_interop/runtime_execution.rs | 10 +- .../_helpers/dbt_interop/runtime_results.rs | 8 +- .../_helpers/dbt_interop/sqlbuild_work.rs | 19 +- .../_helpers/debug_command/run_debug.rs | 17 +- .../_helpers/diagnostics/console_records.rs | 2 +- .../bindings/_helpers/diagnostics/getters.rs | 4 +- .../_helpers/diagnostics/log_records.rs | 12 +- .../_helpers/diagnostics/redaction.rs | 4 +- .../bindings/_helpers/diagnostics/trackers.rs | 13 +- .../bindings/_helpers/diff_report/command.rs | 16 +- .../bindings/_helpers/diff_report/facts.rs | 4 +- .../bindings/_helpers/diff_report/output.rs | 5 +- .../bindings/_helpers/diff_report/query.rs | 34 +- .../bindings/_helpers/diff_report/support.rs | 12 +- .../_helpers/diff_report/tolerances.rs | 18 +- .../_helpers/discovery/configuration.rs | 13 +- .../_helpers/discovery/declaration_files.rs | 4 +- .../_helpers/discovery/declaration_records.rs | 17 +- .../_helpers/discovery/description_inputs.rs | 5 +- .../src/bindings/_helpers/discovery/faults.rs | 4 +- .../bindings/_helpers/discovery/getters.rs | 4 +- .../bindings/_helpers/discovery/guidance.rs | 4 +- .../_helpers/discovery/header_declarations.rs | 8 +- .../_helpers/discovery/header_values.rs | 9 +- .../_helpers/discovery/hook_entries.rs | 6 +- .../_helpers/discovery/imported_modules.rs | 17 +- .../_helpers/discovery/imported_providers.rs | 19 +- .../discovery/imported_python_nodes.rs | 20 +- .../bindings/_helpers/discovery/locations.rs | 2 +- .../_helpers/discovery/model_file_record.rs | 6 +- .../_helpers/discovery/model_records.rs | 5 +- .../_helpers/discovery/project_config.rs | 17 +- .../_helpers/discovery/project_facts.rs | 3 +- .../_helpers/discovery/project_files.rs | 4 +- .../_helpers/discovery/project_validation.rs | 2 +- .../_helpers/discovery/provider_secrets.rs | 6 +- .../discovery/python_function_files.rs | 11 +- .../src/bindings/_helpers/discovery/raised.rs | 6 +- .../_helpers/discovery/scope_snapshot.rs | 7 +- .../_helpers/discovery/sql_test_blocks.rs | 12 +- .../_helpers/discovery/sql_test_records.rs | 8 +- .../_helpers/discovery/yaml_entries.rs | 4 +- .../_helpers/discovery/yaml_records.rs | 8 +- .../_helpers/event_exporting/dispatcher.rs | 10 +- .../_helpers/event_exporting/getters.rs | 4 +- .../_helpers/event_exporting/registration.rs | 2 +- .../_helpers/event_exporting/scope.rs | 19 +- .../_helpers/event_exporting/values.rs | 8 +- .../_helpers/event_exporting/workers.rs | 7 +- .../_helpers/execution_history/conversion.rs | 25 +- .../_helpers/execution_history/functions.rs | 2 +- .../_helpers/execution_history/getters.rs | 4 +- .../_helpers/execution_history/postgres.rs | 16 +- .../_helpers/execution_history/sqlite.rs | 14 +- .../exported_constants/registration.rs | 2 +- .../_helpers/fingerprints/latest_rows.rs | 12 +- .../_helpers/fingerprints/query_hashes.rs | 8 +- .../_helpers/fingerprints/storage_io.rs | 12 +- .../_helpers/fingerprints/storage_sql.rs | 2 +- .../_helpers/format_command/command.rs | 10 +- .../_helpers/format_command/config.rs | 4 +- .../_helpers/format_command/report.rs | 2 +- .../bindings/_helpers/format_command/run.rs | 14 +- .../_helpers/format_command/selection.rs | 16 +- .../_helpers/freshness/freshness_command.rs | 14 +- .../_helpers/freshness/freshness_observe.rs | 10 +- .../_helpers/freshness/observation.rs | 36 +- .../bindings/_helpers/freshness/planning.rs | 19 +- .../_helpers/freshness/publication.rs | 29 +- .../bindings/_helpers/freshness/state_io.rs | 10 +- .../bindings/_helpers/freshness/support.rs | 2 +- .../_helpers/frontier/compile_frontier.rs | 11 +- .../src/bindings/_helpers/frontier/encoder.rs | 6 +- .../_helpers/frontier/python_types.rs | 4 +- .../_helpers/frontier/stage_capture.rs | 7 +- .../src/bindings/_helpers/graph/algorithms.rs | 4 +- .../_helpers/graph/execution_gates.rs | 9 +- .../src/bindings/_helpers/graph/getters.rs | 4 +- .../src/bindings/_helpers/graph/keys.rs | 6 +- .../bindings/_helpers/graph/project_graph.rs | 5 +- .../_helpers/graph/python_lifecycle.rs | 6 +- .../_helpers/graph/python_node_graph.rs | 22 +- .../_helpers/graph/python_selection.rs | 11 +- .../src/bindings/_helpers/graph/views.rs | 10 +- .../_helpers/hand_built/compiled_model.rs | 10 +- .../bindings/_helpers/init_command/command.rs | 9 +- .../_helpers/init_command/scaffold.rs | 2 +- .../_helpers/input_loops/attachment.rs | 30 +- .../_helpers/input_loops/audit_loop.rs | 2 +- .../_helpers/input_loops/expanded_offsets.rs | 6 +- .../_helpers/input_loops/loop_classes.rs | 27 +- .../_helpers/input_loops/model_loop.rs | 7 +- .../input_loops/model_loop_contracts.rs | 2 +- .../_helpers/input_loops/model_loop_header.rs | 2 +- .../_helpers/input_loops/model_loop_hooks.rs | 2 +- .../_helpers/input_loops/model_loop_host.rs | 3 +- .../_helpers/input_loops/model_loop_macros.rs | 2 +- .../_helpers/input_loops/model_loop_named.rs | 2 +- .../input_loops/model_loop_opt_out.rs | 8 +- .../input_loops/model_loop_python_hooks.rs | 2 +- .../_helpers/input_loops/model_loop_schema.rs | 2 +- .../input_loops/model_loop_visibility.rs | 2 +- .../input_loops/resource_attachment.rs | 2 +- .../input_loops/resource_diagnostics.rs | 2 +- .../_helpers/input_loops/source_loop.rs | 2 +- .../_helpers/input_loops/sql_test_loop.rs | 2 +- .../janitor/janitor_classification.rs | 2 +- .../_helpers/janitor/janitor_command.rs | 9 +- .../_helpers/janitor/janitor_facts.rs | 18 +- .../bindings/_helpers/janitor/janitor_keys.rs | 9 +- .../_helpers/janitor/janitor_old_names.rs | 14 +- .../_helpers/janitor/janitor_phases.rs | 19 +- .../bindings/_helpers/janitor/janitor_plan.rs | 2 +- .../_helpers/janitor/janitor_planning.rs | 14 +- .../_helpers/janitor/janitor_progress.rs | 2 +- .../_helpers/janitor/janitor_usage.rs | 11 +- .../_helpers/lifecycle_events/envelopes.rs | 6 +- .../_helpers/lifecycle_events/payloads.rs | 8 +- .../_helpers/lifecycle_events/validation.rs | 4 +- .../_helpers/lineage/column_lineage_graph.rs | 7 +- .../_helpers/lineage/lineage_cache.rs | 3 +- .../_helpers/lineage/lineage_command.rs | 14 +- .../_helpers/lineage/lineage_facts.rs | 12 +- .../_helpers/lineage/lineage_index.rs | 9 +- .../_helpers/lineage/lineage_objects.rs | 10 +- .../_helpers/lineage/project_lineage.rs | 10 +- .../_helpers/lineage/project_schema.rs | 2 +- .../_helpers/lineage/relation_fingerprint.rs | 7 +- .../bindings/_helpers/load/dlt_destination.rs | 9 +- .../bindings/_helpers/load/ingestr_command.rs | 12 +- .../bindings/_helpers/load/load_command.rs | 29 +- .../bindings/_helpers/load/load_progress.rs | 9 +- .../bindings/_helpers/load/load_selection.rs | 18 +- .../_helpers/location_command/command.rs | 10 +- .../_helpers/location_command/runtime.rs | 4 +- .../_helpers/location_command/snapshot.rs | 4 +- .../location_command/snapshot_lineage.rs | 4 +- .../location_command/snapshot_providers.rs | 2 +- .../_helpers/location_command/worker.rs | 11 +- .../_helpers/macro_bridge/module_digests.rs | 4 +- .../_helpers/macro_bridge/store_keys.rs | 7 +- .../src/bindings/_helpers/manifest/builder.rs | 14 +- .../src/bindings/_helpers/manifest/rows.rs | 10 +- .../_helpers/microbatches/conversion.rs | 6 +- .../_helpers/microbatches/projection.rs | 18 +- .../_helpers/microbatches/statements.rs | 25 +- .../src/bindings/_helpers/mod.rs | 12 - .../_helpers/model_config/authored_nodes.rs | 2 +- .../_helpers/model_config/config_errors.rs | 4 +- .../_helpers/model_config/config_nodes.rs | 4 +- .../_helpers/model_config/config_values.rs | 8 +- .../_helpers/model_config/contract_classes.rs | 14 +- .../_helpers/model_config/described_models.rs | 2 +- .../bindings/_helpers/model_config/getters.rs | 4 +- .../_helpers/model_config/header_audits.rs | 2 +- .../_helpers/model_config/header_columns.rs | 6 +- .../_helpers/model_config/header_families.rs | 6 +- .../_helpers/model_config/header_metadata.rs | 9 +- .../model_config/model_config_builder.rs | 2 +- .../_helpers/model_config/model_validator.rs | 7 +- .../_helpers/model_config/project_defaults.rs | 2 +- .../_helpers/model_config/template_data.rs | 9 +- .../_helpers/model_config/typed_config.rs | 9 +- .../model_config/unicode_environment.rs | 6 +- .../_helpers/native_host/connections.rs | 4 +- .../_helpers/native_host/consumption_state.rs | 4 +- .../src/bindings/_helpers/native_host/mod.rs | 1 - .../_helpers/native_host/model_lookup.rs | 2 +- .../native_host/observations_state.rs | 4 +- .../native_host/orchestration_declarations.rs | 2 +- .../native_host/orchestration_sensors.rs | 6 +- .../native_host/orchestration_triggers.rs | 6 +- .../_helpers/native_host/provider_settings.rs | 9 +- .../native_host/resource_costs_state.rs | 5 +- .../bindings/_helpers/native_host/results.rs | 6 +- .../_helpers/native_host/sqlite_connection.rs | 2 +- .../native_host/state_column_evolution.rs | 10 +- .../_helpers/native_host/synced_copy.rs | 11 +- .../_helpers/native_host/warehouse_catalog.rs | 4 +- .../native_host/warehouse_metadata.rs | 8 +- .../native_host/warehouse_statistics.rs | 4 +- .../_helpers/observations/publication.rs | 8 +- .../_helpers/output_capture/context.rs | 8 +- .../_helpers/output_capture/dispatcher.rs | 20 +- .../_helpers/output_capture/records.rs | 24 +- .../_helpers/output_capture/values.rs | 8 +- .../bindings/_helpers/plan_command/plan.rs | 15 +- .../bindings/_helpers/plan_command/rules.rs | 12 +- .../_helpers/plan_output/cursor_details.rs | 10 +- .../bindings/_helpers/plan_output/display.rs | 12 +- .../_helpers/plan_output/migrations.rs | 2 +- .../_helpers/plan_output/plan_json.rs | 4 +- .../_helpers/plan_output/plan_text.rs | 10 +- .../_helpers/plan_output/python_identity.rs | 2 +- .../bindings/_helpers/plan_output/safety.rs | 2 +- .../bindings/_helpers/plan_output/values.rs | 2 +- .../_helpers/planner_changes/actions.rs | 8 +- .../_helpers/planner_changes/detect.rs | 22 +- .../_helpers/planner_changes/metadata.rs | 2 +- .../_helpers/planner_changes/renames.rs | 17 +- .../_helpers/planner_changes/results.rs | 8 +- .../_helpers/planner_entries/clone_plans.rs | 11 +- .../_helpers/planner_entries/command_plans.rs | 10 +- .../_helpers/planner_entries/contexts.rs | 6 +- .../_helpers/planner_entries/display_plan.rs | 4 +- .../planner_entries/execution_plan.rs | 12 +- .../_helpers/planner_entries/getters.rs | 4 +- .../_helpers/planner_entries/model_entries.rs | 11 +- .../_helpers/planner_entries/plan_output.rs | 13 +- .../_helpers/planner_entries/relations.rs | 10 +- .../_helpers/planner_entries/test_planning.rs | 9 +- .../_helpers/planner_entries/values.rs | 12 +- .../_helpers/planner_identity/graph.rs | 15 +- .../_helpers/planner_identity/hashing.rs | 12 +- .../_helpers/planner_identity/identities.rs | 18 +- .../_helpers/planner_identity/json_values.rs | 2 +- .../_helpers/planner_identity/metadata.rs | 10 +- .../_helpers/planner_identity/staleness.rs | 12 +- .../planner_migrations/column_candidates.rs | 2 +- .../planner_migrations/column_entries.rs | 15 +- .../planner_migrations/column_objects.rs | 8 +- .../planner_migrations/column_overlay.rs | 10 +- .../planner_migrations/column_planning.rs | 7 +- .../planner_migrations/column_warnings.rs | 6 +- .../_helpers/planner_migrations/columns.rs | 8 +- .../planner_migrations/compatibility.rs | 10 +- .../_helpers/planner_migrations/discovery.rs | 4 +- .../planner_migrations/discovery_events.rs | 10 +- .../planner_migrations/discovery_models.rs | 8 +- .../planner_migrations/discovery_requests.rs | 10 +- .../planner_migrations/fingerprint.rs | 8 +- .../_helpers/planner_migrations/getters.rs | 4 +- .../planner_migrations/known_input_columns.rs | 4 +- .../_helpers/planner_migrations/matching.rs | 6 +- .../planner_migrations/model_entries.rs | 16 +- .../planner_migrations/model_handover.rs | 4 +- .../planner_migrations/model_overlay.rs | 4 +- .../planner_migrations/model_planning.rs | 13 +- .../planner_migrations/model_warnings.rs | 2 +- .../planner_migrations/old_name_entries.rs | 13 +- .../planner_migrations/old_name_objects.rs | 13 +- .../planner_migrations/old_name_planning.rs | 10 +- .../planner_migrations/old_name_references.rs | 15 +- .../_helpers/planner_migrations/old_names.rs | 13 +- .../planner_migrations/planning_boundary.rs | 6 +- .../planner_migrations/planning_execution.rs | 12 +- .../planner_migrations/planning_origin.rs | 11 +- .../planner_migrations/projections.rs | 10 +- .../planner_migrations/state_inspection.rs | 16 +- .../_helpers/planner_phases/buildability.rs | 2 +- .../planner_phases/deferred_origins.rs | 8 +- .../planner_phases/execution_changes.rs | 4 +- .../_helpers/planner_phases/full_refresh.rs | 2 +- .../_helpers/planner_phases/getters.rs | 4 +- .../_helpers/planner_phases/identities.rs | 8 +- .../_helpers/planner_phases/objects.rs | 20 +- .../planner_phases/output_assembly.rs | 11 +- .../_helpers/planner_phases/retention.rs | 14 +- .../_helpers/planner_phases/runtime.rs | 2 +- .../_helpers/planner_phases/scopes.rs | 4 +- .../planner_phases/warehouse_state.rs | 4 +- .../planner_resolution/cursor_bounds.rs | 16 +- .../planner_resolution/cursor_model.rs | 19 +- .../planner_resolution/cursor_overrides.rs | 12 +- .../planner_resolution/cursor_policies.rs | 9 +- .../planner_resolution/cursor_ranges.rs | 19 +- .../planner_resolution/cursor_safety.rs | 16 +- .../planner_resolution/cursor_warnings.rs | 7 +- .../planner_resolution/cursor_windows.rs | 14 +- .../planner_resolution/future_safety.rs | 11 +- .../planner_resolution/maximum_safety.rs | 15 +- .../planner_resolution/orchestration.rs | 14 +- .../_helpers/planner_resolution/refs.rs | 11 +- .../_helpers/planner_resolution/sources.rs | 8 +- .../_helpers/planner_resolution/values.rs | 7 +- .../_helpers/planner_scenario/artifacts.rs | 9 +- .../bindings/_helpers/planner_scenario/cli.rs | 15 +- .../_helpers/planner_scenario/entries.rs | 10 +- .../_helpers/planner_scenario/execution.rs | 18 +- .../_helpers/planner_scenario/fixtures.rs | 11 +- .../_helpers/planner_scenario/graph.rs | 7 +- .../_helpers/planner_scenario/helper_scope.rs | 4 +- .../_helpers/planner_scenario/relations.rs | 11 +- .../bindings/_helpers/planner_scenario/sql.rs | 6 +- .../_helpers/planner_scenario/values.rs | 6 +- .../_helpers/planner_scope/loaders.rs | 6 +- .../_helpers/planner_scope/retained.rs | 9 +- .../bindings/_helpers/planner_scope/scope.rs | 8 +- .../_helpers/planner_scope/sources.rs | 10 +- .../bindings/_helpers/planner_scope/values.rs | 4 +- .../_helpers/planner_selection/carrier.rs | 4 +- .../planner_selection/model_selectors.rs | 8 +- .../_helpers/planner_selection/selectors.rs | 9 +- .../_helpers/planner_selection/unit_tests.rs | 7 +- .../planner_strategy/audit_entries.rs | 14 +- .../_helpers/planner_strategy/audits.rs | 6 +- .../planner_strategy/cursor_inputs.rs | 14 +- .../_helpers/planner_strategy/cursor_types.rs | 12 +- .../planner_strategy/fixture_completion.rs | 2 +- .../planner_strategy/fixture_context.rs | 2 +- .../planner_strategy/fixture_metadata.rs | 2 +- .../planner_strategy/fixture_preparation.rs | 4 +- .../planner_strategy/fixture_reads.rs | 6 +- .../_helpers/planner_strategy/fixture_sql.rs | 4 +- .../planner_strategy/fixture_values.rs | 6 +- .../_helpers/planner_strategy/lineage.rs | 6 +- .../planner_strategy/microbatch_limits.rs | 9 +- .../_helpers/planner_strategy/microbatches.rs | 12 +- .../planner_strategy/model_entries.rs | 21 +- .../_helpers/planner_strategy/strategy.rs | 7 +- .../_helpers/planner_strategy/values.rs | 9 +- .../_helpers/planner_warehouse/constants.rs | 2 +- .../_helpers/planner_warehouse/cursors.rs | 26 +- .../planner_warehouse/fingerprint_cache.rs | 6 +- .../planner_warehouse/semantic_sources.rs | 12 +- .../_helpers/planner_warehouse/snapshot.rs | 22 +- .../planner_warehouse/source_columns.rs | 10 +- .../planner_warehouse/source_deferral.rs | 10 +- .../planner_warehouse/source_freshness.rs | 16 +- .../planner_warehouse/source_tables.rs | 14 +- .../_helpers/planner_warehouse/watermarks.rs | 2 +- .../_helpers/presentation_text/functions.rs | 4 +- .../_helpers/presentation_text/getters.rs | 4 +- .../project_assembly/declared_relations.rs | 7 +- .../_helpers/project_assembly/getters.rs | 4 +- .../project_assembly/native_resources.rs | 21 +- .../_helpers/project_assembly/resources.rs | 4 +- .../project_assembly/syntax_checks.rs | 2 +- .../project_assembly/syntax_validation.rs | 9 +- .../bindings/_helpers/python_values/values.rs | 6 +- .../bindings/_helpers/query_command/dag.rs | 6 +- .../_helpers/query_command/project.rs | 6 +- .../bindings/_helpers/query_command/query.rs | 15 +- .../_helpers/query_command/query_values.rs | 2 +- .../_helpers/recall/clickhouse_calls.rs | 10 +- .../src/bindings/_helpers/recall/command.rs | 6 +- .../src/bindings/_helpers/recall/console.rs | 2 +- .../src/bindings/_helpers/recall/events.rs | 6 +- .../bindings/_helpers/recall/replacements.rs | 13 +- .../src/bindings/_helpers/recall/session.rs | 6 +- .../src/bindings/_helpers/recall/sinks.rs | 4 +- .../src/bindings/_helpers/recall/writer.rs | 8 +- .../_helpers/record_behaviours/auditing.rs | 6 +- .../_helpers/record_behaviours/compiled.rs | 10 +- .../_helpers/record_behaviours/config.rs | 2 +- .../_helpers/record_behaviours/constants.rs | 39 +- .../_helpers/record_behaviours/cursors.rs | 13 +- .../_helpers/record_behaviours/discovery.rs | 2 +- .../_helpers/record_behaviours/durations.rs | 2 +- .../_helpers/record_behaviours/error_inits.rs | 4 +- .../_helpers/record_behaviours/freshness.rs | 6 +- .../_helpers/record_behaviours/lexical.rs | 4 +- .../_helpers/record_behaviours/macros.rs | 4 +- .../_helpers/record_behaviours/migrations.rs | 8 +- .../_helpers/record_behaviours/planner.rs | 14 +- .../record_behaviours/python_nodes.rs | 6 +- .../_helpers/record_behaviours/rule_shapes.rs | 10 +- .../_helpers/record_behaviours/scopes.rs | 2 +- .../_helpers/record_behaviours/values.rs | 4 +- .../src/bindings/_helpers/records/ids.rs | 1006 ---------------- .../src/bindings/_helpers/records/types.rs | 24 - .../_helpers/refactor/contract_compare.rs | 19 +- .../_helpers/refactor/contract_edits.rs | 12 +- .../_helpers/refactor/offline_compile.rs | 13 +- .../_helpers/refactor/python_strings.rs | 8 +- .../_helpers/refactor/refactor_command.rs | 13 +- .../_helpers/refactor/refactor_facts.rs | 2 +- .../references/explicit_references.rs | 23 +- .../_helpers/references/reference_facts.rs | 8 +- .../bindings/_helpers/references/relations.rs | 12 +- .../_helpers/references/source_relations.rs | 8 +- .../_helpers/relation_naming/fitting.rs | 6 +- .../bindings/_helpers/render/authored_sql.rs | 20 +- .../_helpers/render/declaration_indexes.rs | 8 +- .../_helpers/render/declaration_values.rs | 35 +- .../_helpers/render/macro_call_classes.rs | 4 +- .../_helpers/render/macro_call_rows.rs | 1 + .../bindings/_helpers/render/macro_calls.rs | 8 +- .../_helpers/render/macro_evaluation.rs | 2 +- .../_helpers/render/macro_expansion.rs | 8 +- .../_helpers/render/macro_expansion_result.rs | 30 +- .../render/macro_generated_references.rs | 2 +- .../bindings/_helpers/render/macro_modules.rs | 8 +- .../_helpers/render/sql_macro_host.rs | 15 +- .../_helpers/render/sql_macro_inventory.rs | 4 +- .../_helpers/render/sql_macro_mocks.rs | 2 +- .../_helpers/result_output/aggregation.rs | 12 +- .../bindings/_helpers/result_output/assets.rs | 6 +- .../bindings/_helpers/result_output/checks.rs | 2 +- .../_helpers/result_output/documents.rs | 8 +- .../_helpers/result_output/event_writer.rs | 4 +- .../_helpers/result_output/getters.rs | 4 +- .../result_output/integration_envelope.rs | 2 +- .../result_output/integration_records.rs | 4 +- .../result_output/integration_values.rs | 4 +- .../_helpers/result_output/projection.rs | 6 +- .../_helpers/result_output/resource_ids.rs | 4 +- .../_helpers/result_output/terminal_index.rs | 12 +- .../_helpers/review_command/command.rs | 2 +- .../_helpers/review_command/comparison.rs | 17 +- .../_helpers/review_command/execution.rs | 6 +- .../_helpers/review_command/impact.rs | 6 +- .../_helpers/review_command/planning.rs | 5 +- .../_helpers/review_command/schema.rs | 17 +- .../_helpers/review_command/support.rs | 14 +- .../_helpers/rules/builtin_catalogue.rs | 7 +- .../src/bindings/_helpers/rules/catalogue.rs | 16 +- .../bindings/_helpers/rules/config_json.rs | 2 +- .../_helpers/rules/custom_evaluation.rs | 10 +- .../_helpers/rules/custom_host_observation.rs | 6 +- .../_helpers/rules/custom_host_payload.rs | 2 +- .../bindings/_helpers/rules/custom_hosts.rs | 6 +- .../_helpers/rules/custom_rule_cache.rs | 6 +- .../_helpers/rules/custom_rule_evidence.rs | 9 +- .../bindings/_helpers/rules/dsl_headers.rs | 8 +- .../_helpers/rules/early_builtin_rules.rs | 6 +- .../bindings/_helpers/rules/early_sql_lint.rs | 4 +- .../src/bindings/_helpers/rules/evaluation.rs | 4 +- .../bindings/_helpers/rules/fact_encoder.rs | 8 +- .../bindings/_helpers/rules/fact_replay.rs | 8 +- .../src/bindings/_helpers/rules/findings.rs | 9 +- .../src/bindings/_helpers/rules/fix_facts.rs | 8 +- .../bindings/_helpers/rules/fix_session.rs | 19 +- .../bindings/_helpers/rules/fix_verdict.rs | 7 +- .../_helpers/rules/fixture_formatting.rs | 5 +- .../_helpers/rules/fixture_schemas.rs | 2 +- .../src/bindings/_helpers/rules/getters.rs | 4 +- .../src/bindings/_helpers/rules/guidance.rs | 8 +- .../src/bindings/_helpers/rules/lint.rs | 4 +- .../bindings/_helpers/rules/lint_expansion.rs | 17 +- .../bindings/_helpers/rules/lint_headers.rs | 8 +- .../bindings/_helpers/rules/lint_inputs.rs | 2 +- .../bindings/_helpers/rules/lint_pipeline.rs | 16 +- .../_helpers/rules/lint_preparation.rs | 9 +- .../_helpers/rules/lint_sql_bodies.rs | 8 +- .../src/bindings/_helpers/rules/lint_text.rs | 15 +- .../_helpers/rules/native_header_parser.rs | 6 +- .../_helpers/rules/project_tree_queries.rs | 8 +- .../src/bindings/_helpers/rules/results.rs | 3 +- .../src/bindings/_helpers/rules/rows.rs | 15 +- .../src/bindings/_helpers/rules/rule_api.rs | 11 +- .../src/bindings/_helpers/rules/rule_cache.rs | 5 +- .../bindings/_helpers/rules/rule_dispatch.rs | 16 +- .../src/bindings/_helpers/rules/rule_plan.rs | 17 +- .../src/bindings/_helpers/rules/rule_run.rs | 12 +- .../bindings/_helpers/rules/rules_config.rs | 11 +- .../src/bindings/_helpers/rules/run_lint.rs | 2 +- .../src/bindings/_helpers/rules/selection.rs | 8 +- .../src/bindings/_helpers/rules/skills.rs | 2 +- .../bindings/_helpers/rules/sql_document.rs | 6 +- .../src/bindings/_helpers/rules/sql_rules.rs | 18 +- .../_helpers/rules/sql_test_objects.rs | 8 +- .../scenario_command/capture_command.rs | 8 +- .../_helpers/scenario_command/conversions.rs | 8 +- .../_helpers/scenario_command/presentation.rs | 10 +- .../_helpers/scenario_command/setup.rs | 24 +- .../scenario_command/snapshot_sync.rs | 12 +- .../_helpers/scenario_command/test_command.rs | 14 +- .../_helpers/scopes/compile_usages.rs | 9 +- .../_helpers/scopes/declaration_contexts.rs | 5 +- .../_helpers/scopes/declaration_resolution.rs | 2 +- .../src/bindings/_helpers/scopes/getters.rs | 4 +- .../_helpers/scopes/relationship_names.rs | 4 +- .../_helpers/scopes/relationship_scan.rs | 4 +- .../bindings/_helpers/scopes/scope_cache.rs | 6 +- .../bindings/_helpers/scopes/scope_command.rs | 12 +- .../bindings/_helpers/scopes/scope_errors.rs | 6 +- .../bindings/_helpers/scopes/scope_index.rs | 15 +- .../bindings/_helpers/scopes/scope_loading.rs | 14 +- .../bindings/_helpers/scopes/scope_lookup.rs | 11 +- .../bindings/_helpers/scopes/scope_objects.rs | 7 +- .../_helpers/scopes/scope_report_objects.rs | 4 +- .../bindings/_helpers/scopes/scope_reports.rs | 9 +- .../_helpers/scopes/scope_tolerant.rs | 4 +- .../_helpers/scopes/scope_validation.rs | 13 +- .../_helpers/scopes/scope_visibility.rs | 7 +- .../bindings/_helpers/seed_command/command.rs | 19 +- .../_helpers/semantic_checks/completion.rs | 6 +- .../_helpers/semantic_checks/failures.rs | 2 +- .../_helpers/semantic_checks/inputs.rs | 6 +- .../_helpers/semantic_checks/metadata.rs | 10 +- .../_helpers/semantic_checks/resource_sql.rs | 17 +- .../_helpers/semantic_checks/stage.rs | 8 +- .../_helpers/semantic_checks/stage_objects.rs | 13 +- .../_helpers/semantic_checks/type_recovery.rs | 12 +- .../_helpers/semantic_shapes/coverage.rs | 2 +- .../_helpers/semantic_shapes/declarations.rs | 4 +- .../_helpers/semantic_shapes/delta_shapes.rs | 2 +- .../_helpers/semantic_shapes/shapes.rs | 16 +- .../semantic_shapes/source_bindings.rs | 16 +- .../_helpers/sql_test_command/python_tests.rs | 12 +- .../_helpers/sql_test_command/test_command.rs | 26 +- .../_helpers/sql_test_command/timeouts.rs | 6 +- .../_helpers/sql_test_glue/assembly.rs | 10 +- .../_helpers/sql_test_glue/authored_ctes.rs | 6 +- .../_helpers/sql_test_glue/compiled_tests.rs | 9 +- .../_helpers/sql_test_glue/cursor_window.rs | 10 +- .../sql_test_glue/fixture_validation.rs | 12 +- .../_helpers/sql_test_glue/plan_assembly.rs | 8 +- .../_helpers/sql_test_glue/plan_driver.rs | 11 +- .../_helpers/sql_test_glue/plan_entries.rs | 7 +- .../_helpers/sql_test_glue/plan_errors.rs | 11 +- .../_helpers/sql_test_glue/plan_fixtures.rs | 6 +- .../_helpers/sql_test_glue/plan_rendering.rs | 8 +- .../_helpers/sql_test_glue/plan_rows.rs | 5 +- .../_helpers/sql_test_glue/plan_values.rs | 8 +- .../_helpers/sql_test_glue/planning.rs | 7 +- .../_helpers/sqltext/authored_values.rs | 4 +- .../bindings/_helpers/sqltext/code_scanner.rs | 4 +- .../bindings/_helpers/sqltext/ddl_effects.rs | 6 +- .../_helpers/sqltext/lexical_syntax.rs | 6 +- .../_helpers/sqltext/model_headers.rs | 6 +- .../bindings/_helpers/sqltext/placeholders.rs | 4 +- .../_helpers/sqltext/sql_references.rs | 16 +- .../bindings/_helpers/state_rows/events.rs | 8 +- .../bindings/_helpers/state_rows/freshness.rs | 14 +- .../_helpers/state_rows/migration_io.rs | 6 +- .../_helpers/state_rows/migration_objects.rs | 8 +- .../state_rows/migration_projections.rs | 6 +- .../_helpers/state_rows/migration_rows.rs | 12 +- .../_helpers/state_rows/state_tables.rs | 12 +- .../_helpers/state_rows/timestamps.rs | 4 +- .../bindings/_helpers/type_system/equality.rs | 8 +- .../_helpers/type_system/normalization.rs | 3 +- .../_helpers/type_system/nullability.rs | 5 +- .../_helpers/workspace_commands/commands.rs | 18 +- .../src/bindings/main/register.rs | 33 +- crates/sqlbuild-python/src/bindings/mod.rs | 1 - crates/sqlbuild-python/src/bindings/models.rs | 3 +- fensu.toml | 105 +- .../fensu_policy/_helpers/native_crossings.py | 4 +- scripts/fensu_policy/constants.py | 7 +- scripts/fensu_policy/rules/native_boundary.py | 7 +- scripts/native_layering/_helpers/layering.py | 13 +- scripts/native_layering/models.py | 4 +- scripts/native_module_paths/constants.py | 1 + .../native_layering/_helpers/helpers.py | 2 +- .../native_layering/_helpers/test_layering.py | 10 +- 892 files changed, 7063 insertions(+), 4584 deletions(-) create mode 100644 crates/sqlbuild-python-base/Cargo.toml rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/allocator.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/call_arguments.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/config_values.rs (98%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/expected_errors.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/mod.rs (88%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/oracles.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/panics.rs (64%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/positional.rs (94%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/positional_records.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers/boundary => sqlbuild-python-base/src/boundary/_helpers}/python_calls.rs (53%) create mode 100644 crates/sqlbuild-python-base/src/boundary/main/call_argument.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/call_with.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/compiler_error.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/compiler_guard.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/config_value_to_python.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/context_variable.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/imported.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/json_value_to_python.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/keywords.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/mod.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/native_compiler_error.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/register_expected_errors.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/register_native_compiler_error.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/register_oracles.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/value_error.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/main/within.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/mod.rs create mode 100644 crates/sqlbuild-python-base/src/boundary/models.rs create mode 100644 crates/sqlbuild-python-base/src/lib.rs rename crates/{sqlbuild-python/src/bindings/_helpers/native_host => sqlbuild-python-base/src/native_host/_helpers}/host.rs (98%) create mode 100644 crates/sqlbuild-python-base/src/native_host/_helpers/mod.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/flush_console.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/host_entry.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/log_debug_message.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/log_warning_message.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/mod.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/module_installed.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/python_executable.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/redirect_stdout_to_stderr.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/within_identity_pass.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/main/write_console.rs create mode 100644 crates/sqlbuild-python-base/src/native_host/mod.rs rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compile_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compile_records/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_enums/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_enums/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_errors/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_errors/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/compiler_records/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/contract_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/contract_records/mod.rs (100%) create mode 100644 crates/sqlbuild-python-base/src/records/_helpers/mod.rs rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/behaviours.rs (80%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/construct.rs (97%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/error_classes.rs (96%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/fields.rs (97%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/getters.rs (93%) create mode 100644 crates/sqlbuild-python-base/src/records/_helpers/native_classes/ids.rs rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/mod.rs (74%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/registration.rs (78%) rename crates/{sqlbuild-python/src/bindings/_helpers/records => sqlbuild-python-base/src/records/_helpers/native_classes}/registry.rs (94%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/planner_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/planner_records/defaults.rs (80%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/planner_records/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/rule_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/rule_records/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/scope_records/constants.rs (99%) rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src/records}/_helpers/scope_records/mod.rs (100%) rename crates/{sqlbuild-python/src/bindings/_helpers => sqlbuild-python-base/src}/records/constants.rs (98%) create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/enum_from_value.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/enum_member.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/error_class.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/mod.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/new_annotated_error.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/new_error.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/new_helped_error.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/new_record.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/new_record_with.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/construct/record_class.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/all_specs.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/by_attribute.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/cached_value.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/enum_member_value.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/field.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/field_text.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/mapping_get.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/mapping_get_or.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/mapping_items.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/mapping_values.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/mod.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/path_posix.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/path_posix_text.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/path_stem.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/record_attribute_opt.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/record_spec.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/replaced.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/replaced_keywords.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/fields/store_cached.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/mod.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/capture.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/class_of.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/mod.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/native_attr.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/record_named.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/register_records.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/verify_attributes.rs create mode 100644 crates/sqlbuild-python-base/src/records/main/registry/verify_tables.rs create mode 100644 crates/sqlbuild-python-base/src/records/mod.rs rename crates/{sqlbuild-python/src/bindings/_helpers => sqlbuild-python-base/src}/records/models.rs (79%) create mode 100644 crates/sqlbuild-python-base/src/records/types.rs rename crates/{sqlbuild-python/src/bindings => sqlbuild-python-base/src}/types.rs (82%) delete mode 100644 crates/sqlbuild-python/src/bindings/_helpers/boundary/keyword_request.rs delete mode 100644 crates/sqlbuild-python/src/bindings/_helpers/records/ids.rs delete mode 100644 crates/sqlbuild-python/src/bindings/_helpers/records/types.rs diff --git a/Cargo.lock b/Cargo.lock index d5469aec5..dcade63b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4430,7 +4430,6 @@ dependencies = [ "chrono", "chrono-tz", "fensu-policy", - "mimalloc", "pyo3", "rayon", "rusqlite", @@ -4452,6 +4451,7 @@ dependencies = [ "sqlbuild-orchestration", "sqlbuild-project", "sqlbuild-pysource", + "sqlbuild-python-base", "sqlbuild-recall", "sqlbuild-refactor", "sqlbuild-render", @@ -4465,6 +4465,21 @@ dependencies = [ "uuid", ] +[[package]] +name = "sqlbuild-python-base" +version = "0.0.0" +dependencies = [ + "mimalloc", + "pyo3", + "serde_json", + "sqlbuild-analysis", + "sqlbuild-config", + "sqlbuild-core", + "sqlbuild-discovery", + "sqlbuild-host", + "sqlbuild-rules", +] + [[package]] name = "sqlbuild-recall" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index b284cece3..bfc5666be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = [ "crates/sqlbuild-refactor", "crates/sqlbuild-project", "crates/sqlbuild-cli", + "crates/sqlbuild-python-base", "crates/sqlbuild-python", ] resolver = "2" @@ -53,9 +54,10 @@ order = [ "sqlbuild-refactor", "sqlbuild-project", "sqlbuild-cli", + "sqlbuild-python-base", "sqlbuild-python", ] -python-boundary = "sqlbuild-python" +python-boundary = ["sqlbuild-python-base", "sqlbuild-python"] polyglot-floor = "sqlbuild-analysis" [workspace.package] @@ -174,6 +176,7 @@ sqlbuild-model-config = { path = "crates/sqlbuild-model-config" } sqlbuild-orchestration = { path = "crates/sqlbuild-orchestration" } sqlbuild-process-ownership = { path = "crates/sqlbuild-process-ownership" } sqlbuild-project = { path = "crates/sqlbuild-project" } +sqlbuild-python-base = { path = "crates/sqlbuild-python-base" } sqlbuild-pysource = { path = "crates/sqlbuild-pysource" } sqlbuild-recall = { path = "crates/sqlbuild-recall" } sqlbuild-scopes = { path = "crates/sqlbuild-scopes" } diff --git a/crates/README.md b/crates/README.md index cb8dc5b80..5f69aad8d 100644 --- a/crates/README.md +++ b/crates/README.md @@ -1,8 +1,9 @@ # Native crates SQLBuild's native code is a Cargo workspace that builds one Python extension module, -`sqlbuild._native`, and the `sqb`/`sqlbuild` executables in the `sqlbuild-cli` wheel. Only `sqlbuild-python` knows about Python; every other crate is plain Rust -that can be tested and benchmarked with `cargo test` alone. +`sqlbuild._native`, and the `sqb`/`sqlbuild` executables in the `sqlbuild-cli` wheel. Only the +`sqlbuild-python*` binding crates know about Python; every other crate is plain Rust that can be +tested and benchmarked with `cargo test` alone. | Crate | Responsibility | |---|---| @@ -26,14 +27,15 @@ that can be tested and benchmarked with `cargo test` alone. | `sqlbuild-refactor` | Native rename/move plans, contract-adoption edits, MODEL/SCHEMA/YAML text edits and atomic staging/commit with rollback. Shared scope placement delegates to the native scope implementation; user Python source inspection remains at the Python AST boundary. | | `sqlbuild-project` | The compiled project as plain Rust: `CompiledProject` with the producers' facts and each resource's records (model inputs and schemas, compiled models and their analysis, sources, functions, audits and seeds), and what those records answer without Python, such as lineage rows, resolved namespaces and dependency keys. Values the host owns, such as user config and discovered files, and the views it builds lazily live in one slot per record, whose types `sqlbuild-python` supplies through the `ProjectHost` trait; reads that need Python stay in the bindings as extension traits. | | `sqlbuild-cli` | The `sqb` and `sqlbuild` executables: `--version`, unchanged compiles replayed from the shared reuse store with Python's exact streams, exit code and compute log capture, and a handoff of every other invocation to the installed `sqlbuild-python` script. Built as its own wheel (`crates/sqlbuild-cli/pyproject.toml`). | -| `sqlbuild-python` | The only PyO3 crate: the `_native` module, its Python classes and functions, conversions from Python objects, and the process allocator. | +| `sqlbuild-python-base` | The base of the PyO3 bindings: native record, enum and error classes with their specs, registration, construction and field reads; keyword calls, imports, conversions and panics at the Python boundary; host entry calls; and the process allocator. | +| `sqlbuild-python` | The `_native` module: its Python classes and functions and the conversions from Python objects, on top of `sqlbuild-python-base`. | ## Layering Dependencies point one way, from the top of this graph to the bottom: ```text -sqlbuild-python +sqlbuild-python -> sqlbuild-python-base -> sqlbuild-project -> sqlbuild-refactor -> sqlbuild-rules -> sqlbuild-analysis -> sqlbuild-attachments -> sqlbuild-model-config -> sqlbuild-scopes -> sqlbuild-render -> sqlbuild-discovery -> sqlbuild-host -> sqlbuild-config -> sqlbuild-sqltext -> sqlbuild-cache -> sqlbuild-pysource -> sqlbuild-state -> sqlbuild-cursor -> sqlbuild-core @@ -52,7 +54,7 @@ in `[workspace.metadata.native-layers]` in the workspace `Cargo.toml`, and - a crate depends on a crate that is not in an earlier layer, or a workspace crate is missing from the order; -- any crate other than `sqlbuild-python` reaches `pyo3`, directly or through another package; +- a crate not listed in `python-boundary` reaches `pyo3`, directly or through another package; - a crate below `sqlbuild-analysis` reaches polyglot. The same check fails when the `sqlbuild-cli` and `sqlbuild-python` versions, the `pyproject.toml` @@ -63,7 +65,8 @@ entry carries a version other than its manifest's. `main/` entry points, `models.rs`, `types.rs` and `constants.rs`, not through `_helpers/`. Inside `sqlbuild-python`, the custom rule XSB075 orders the `bindings/_helpers` modules in layers -that follow the planned crate split: shared Python plumbing (`infra`), then the glue of the lower +that follow the planned crate split: shared Python plumbing (`infra`, part of which is already +`sqlbuild-python-base`, which Cargo keeps below every other layer), then the glue of the lower crates (`front`), the compiled project (`project`), planning and compilation as siblings (`plan`, `compile`), command output (`output`), command handlers (`commands`) and registration (`registry`). A module may import only from lower layers; `plan` and `compile` may not import each @@ -88,10 +91,10 @@ empty: every import points down, and a new upward import fails the check. `sqlbuild._native_host`. Staying-Python entry points (adapter, user code, executor and runtime, third-party and public -facade) are reached through the host table and `native_host::host::entry`, which imports only -`sqlbuild._native_host`. Classes, enums, errors and functions `sqlbuild._native` registers are -reached through the typed registry (`records::registry` with `RecordId`, `ErrorId` and -`NativeAttr`), never by module path. +facade) are reached through the host table and `host_entry` in `sqlbuild-python-base`, which +imports only `sqlbuild._native_host`. Classes, enums, errors and functions `sqlbuild._native` registers are +reached through the typed registry of `sqlbuild-python-base` (`records` with `RecordId`, +`ErrorId` and `NativeAttr`), never by module path. ## Compiler diff --git a/crates/sqlbuild-python-base/Cargo.toml b/crates/sqlbuild-python-base/Cargo.toml new file mode 100644 index 000000000..58ec6a9a8 --- /dev/null +++ b/crates/sqlbuild-python-base/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "sqlbuild-python-base" +description = "The shared base of the sqlbuild._native bindings: native records, Python calls and host entries." +version.workspace = true +edition.workspace = true +license.workspace = true +publish.workspace = true +rust-version.workspace = true + +[dependencies] +mimalloc.workspace = true +pyo3.workspace = true +serde_json.workspace = true +sqlbuild-analysis.workspace = true +sqlbuild-config.workspace = true +sqlbuild-core.workspace = true +sqlbuild-discovery.workspace = true +sqlbuild-host.workspace = true +sqlbuild-rules.workspace = true + +[lints] +workspace = true diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/allocator.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/allocator.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/allocator.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/allocator.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/call_arguments.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/call_arguments.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/call_arguments.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/call_arguments.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/config_values.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/config_values.rs similarity index 98% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/config_values.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/config_values.rs index 0a444023a..d1cdef435 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/config_values.rs +++ b/crates/sqlbuild-python-base/src/boundary/_helpers/config_values.rs @@ -1,6 +1,6 @@ //! Loaded configuration values as the Python objects `tomllib` builds. -use crate::bindings::_helpers::records::fields::field as native_field; +use crate::records::main::fields::field::field as native_field; use pyo3::IntoPyObjectExt; use pyo3::prelude::{Bound, IntoPyObject, Py, PyAny, PyAnyMethods, PyModule, PyResult, Python}; use pyo3::types::{IntoPyDict, PyDict, PyDictMethods, PyList, PyListMethods}; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/expected_errors.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/expected_errors.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/expected_errors.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/expected_errors.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/mod.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/mod.rs similarity index 88% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/mod.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/mod.rs index 003e71517..afb7571d0 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/mod.rs +++ b/crates/sqlbuild-python-base/src/boundary/_helpers/mod.rs @@ -5,7 +5,6 @@ mod allocator; pub(crate) mod call_arguments; pub(crate) mod config_values; pub(crate) mod expected_errors; -pub(crate) mod keyword_request; pub(crate) mod oracles; pub(crate) mod panics; mod positional_records; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/oracles.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/oracles.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/oracles.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/oracles.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/panics.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/panics.rs similarity index 64% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/panics.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/panics.rs index b1f1fbcdc..679e5e9c8 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/panics.rs +++ b/crates/sqlbuild-python-base/src/boundary/_helpers/panics.rs @@ -2,16 +2,31 @@ use pyo3::Python; use pyo3::exceptions::{PyRuntimeError, PyValueError}; +use pyo3::prelude::{Bound, PyModule, PyModuleMethods, PyResult}; use pyo3::{PyErr, create_exception}; use sqlbuild_core::constants::PANIC_MESSAGE; use sqlbuild_core::panics::main::catch_compiler_panic::catch_compiler_panic; use sqlbuild_core::panics::main::is_compiler_panic::is_compiler_panic; use std::panic::{AssertUnwindSafe, catch_unwind}; -use crate::bindings::types::CompilerDetach; +use crate::types::CompilerDetach; create_exception!(_native, NativeCompilerError, PyRuntimeError); +/// The named compiler error for an internal native failure. +pub(crate) fn native_compiler_error(message: impl Into) -> PyErr { + NativeCompilerError::new_err(message.into()) +} + +/// Add `NativeCompilerError` to the extension module. +pub(crate) fn register_native_compiler_error(module: &Bound<'_, PyModule>) -> PyResult<()> { + module.add( + "NativeCompilerError", + module.py().get_type::(), + ) +} + +/// A panic message as `NativeCompilerError`, anything else as `ValueError`. pub(crate) fn compiler_error(error: impl std::fmt::Display) -> PyErr { let message = error.to_string(); if is_compiler_panic(&message) { @@ -21,10 +36,12 @@ pub(crate) fn compiler_error(error: impl std::fmt::Display) -> PyErr { } } +/// The same as `compiler_error`. pub(crate) fn value_error(error: impl std::fmt::Display) -> PyErr { compiler_error(error) } +/// Run `operation`, turning an unwinding panic into `NativeCompilerError`. pub(crate) fn compiler_guard( operation: impl FnOnce() -> pyo3::PyResult, ) -> pyo3::PyResult { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/positional.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/positional.rs similarity index 94% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/positional.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/positional.rs index 0485f9623..47c16f889 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/positional.rs +++ b/crates/sqlbuild-python-base/src/boundary/_helpers/positional.rs @@ -10,7 +10,7 @@ macro_rules! positional_fields { )+ }; (@extract $name:ident { $($field:ident : $ty:ty),+ $(,)? }) => { - impl $crate::bindings::types::FromPositional for $name { + impl $crate::types::FromPositional for $name { fn from_positional(value: &pyo3::Bound<'_, pyo3::PyAny>) -> pyo3::PyResult { let ($($field,)+): ($($ty,)+) = pyo3::types::PyAnyMethods::extract(value)?; Ok($name { $($field),+ }) @@ -18,7 +18,7 @@ macro_rules! positional_fields { } }; (@into $name:ident { $($field:ident : $ty:ty),+ $(,)? }) => { - impl $crate::bindings::types::IntoPositional for $name { + impl $crate::types::IntoPositional for $name { fn into_positional<'py>( self, py: pyo3::Python<'py>, @@ -31,6 +31,7 @@ macro_rules! positional_fields { } /// Declare a struct naming the positions of a tuple Python sends (`extract`) or receives (`into`). +#[macro_export] macro_rules! positional_record { ( $($mode:ident),+; @@ -41,7 +42,7 @@ macro_rules! positional_record { $vis struct $name<$lifetime> $body $( - positional_record!( + $crate::positional_record!( @$mode $name <$lifetime> $body ); )+ @@ -55,7 +56,7 @@ macro_rules! positional_record { $vis struct $name $body $( - positional_record!( + $crate::positional_record!( @$mode $name $body ); )+ diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/positional_records.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/positional_records.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/positional_records.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/positional_records.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/python_calls.rs b/crates/sqlbuild-python-base/src/boundary/_helpers/python_calls.rs similarity index 53% rename from crates/sqlbuild-python/src/bindings/_helpers/boundary/python_calls.rs rename to crates/sqlbuild-python-base/src/boundary/_helpers/python_calls.rs index 1c9e5da34..5f46edfa9 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/python_calls.rs +++ b/crates/sqlbuild-python-base/src/boundary/_helpers/python_calls.rs @@ -3,10 +3,9 @@ use std::collections::HashMap; use std::sync::{Mutex, PoisonError}; -use pyo3::exceptions::PyTypeError; use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::sync::PyOnceLock; -use pyo3::types::{PyBool, PyDict, PyDictMethods, PyString}; +use pyo3::types::{PyDict, PyDictMethods}; /// Standard-library modules whose attributes tests and users never replace, so lookups are kept. const STABLE_MODULES: &[&str] = &[ @@ -100,94 +99,6 @@ pub(crate) fn within<'py, T>( } } -/// The transient status line, when one is shown. -pub(crate) struct Status<'py>(pub(crate) Bound<'py, PyAny>); - -impl Status<'_> { - pub(crate) fn start(&self, message: &str) -> PyResult<()> { - if !self.0.is_none() { - self.0.call_method1("start", (message,))?; - } - Ok(()) - } - - pub(crate) fn complete(&self, message: &str) -> PyResult<()> { - if !self.0.is_none() { - call_with( - &self.0.getattr("complete")?, - &[("message", PyString::new(self.0.py(), message).into_any())], - )?; - } - Ok(()) - } -} - -/// Keyword-only arguments of a driver entry point, checked as Python checks a signature. -pub(crate) struct KeywordArguments<'py> { - values: Bound<'py, PyDict>, -} - -impl<'py> KeywordArguments<'py> { - /// Accept `options` for `function`, rejecting missing `required` and unknown names. - pub(crate) fn read( - py: Python<'py>, - function: &str, - options: Option>, - (required, optional): (&[&str], &[&str]), - ) -> PyResult { - let values: Bound<'py, PyDict> = options.unwrap_or_else(|| PyDict::new(py)); - for name in values.keys() { - let name: String = name.extract()?; - if !required.contains(&name.as_str()) && !optional.contains(&name.as_str()) { - return Err(PyTypeError::new_err(format!( - "{function}() got an unexpected keyword argument '{name}'" - ))); - } - } - for name in required { - if !values.contains(*name)? { - return Err(PyTypeError::new_err(format!( - "{function}() missing 1 required keyword-only argument: '{name}'" - ))); - } - } - Ok(Self { values }) - } - - /// Whether the argument `name` was passed. - pub(crate) fn contains(&self, name: &str) -> PyResult { - self.values.contains(name) - } - - /// The argument `name`, or `None` when it was not passed. - pub(crate) fn value(&self, name: &str) -> PyResult> { - let py: Python<'py> = self.values.py(); - Ok(self - .values - .get_item(name)? - .unwrap_or_else(|| py.None().into_bound(py))) - } - - /// The argument `name` as a truth value, `False` when it was not passed. - pub(crate) fn flag(&self, name: &str) -> PyResult { - self.value(name)?.is_truthy() - } - - /// The argument `name`, or `False` when it was not passed. - pub(crate) fn value_or_false(&self, name: &str) -> PyResult> { - let py: Python<'py> = self.values.py(); - Ok(self - .values - .get_item(name)? - .unwrap_or_else(|| PyBool::new(py, false).to_owned().into_any())) - } - - /// Whether `name` was passed. - pub(crate) fn passed(&self, name: &str) -> PyResult { - self.values.contains(name) - } -} - /// The `contextvars.ContextVar(name, default=None)` kept in `cell`, created once per interpreter. pub(crate) fn context_variable<'py>( py: Python<'py>, diff --git a/crates/sqlbuild-python-base/src/boundary/main/call_argument.rs b/crates/sqlbuild-python-base/src/boundary/main/call_argument.rs new file mode 100644 index 000000000..7e45c62fc --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/call_argument.rs @@ -0,0 +1,18 @@ +//! The argument `name`, passed by keyword or at `position`. + +use crate::boundary::_helpers::call_arguments; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::types::PyDict; +use pyo3::types::PyTuple; + +/// The argument `name`, passed by keyword or at `position`. +#[inline] +pub fn call_argument<'py>( + (args, kwargs): (&Bound<'py, PyTuple>, Option<&Bound<'py, PyDict>>), + name: &str, + position: usize, +) -> PyResult> { + call_arguments::call_argument((args, kwargs), name, position) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/call_with.rs b/crates/sqlbuild-python-base/src/boundary/main/call_with.rs new file mode 100644 index 000000000..e02488a6e --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/call_with.rs @@ -0,0 +1,15 @@ +//! `callable(**pairs)`. + +use crate::boundary::_helpers::python_calls; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `callable(**pairs)`. +#[inline] +pub fn call_with<'py>( + callable: &Bound<'py, PyAny>, + pairs: &[(&str, Bound<'py, PyAny>)], +) -> PyResult> { + python_calls::call_with(callable, pairs) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/compiler_error.rs b/crates/sqlbuild-python-base/src/boundary/main/compiler_error.rs new file mode 100644 index 000000000..c460dc708 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/compiler_error.rs @@ -0,0 +1,10 @@ +//! A panic message as `NativeCompilerError`, anything else as `ValueError`. + +use crate::boundary::_helpers::panics; +use pyo3::PyErr; + +/// A panic message as `NativeCompilerError`, anything else as `ValueError`. +#[inline] +pub fn compiler_error(error: impl std::fmt::Display) -> PyErr { + panics::compiler_error(error) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/compiler_guard.rs b/crates/sqlbuild-python-base/src/boundary/main/compiler_guard.rs new file mode 100644 index 000000000..c0d08c561 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/compiler_guard.rs @@ -0,0 +1,9 @@ +//! Run `operation`, turning an unwinding panic into `NativeCompilerError`. + +use crate::boundary::_helpers::panics; + +/// Run `operation`, turning an unwinding panic into `NativeCompilerError`. +#[inline] +pub fn compiler_guard(operation: impl FnOnce() -> pyo3::PyResult) -> pyo3::PyResult { + panics::compiler_guard(operation) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/config_value_to_python.rs b/crates/sqlbuild-python-base/src/boundary/main/config_value_to_python.rs new file mode 100644 index 000000000..3a6c05995 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/config_value_to_python.rs @@ -0,0 +1,12 @@ +//! Build the Python object for one loaded value; mapping entries keep their document order. + +use crate::boundary::_helpers::config_values; +use pyo3::prelude::PyResult; +use pyo3::prelude::{Py, PyAny, Python}; +use sqlbuild_config::models::ConfigValue; + +/// Build the Python object for one loaded value; mapping entries keep their document order. +#[inline] +pub fn config_value_to_python(py: Python<'_>, value: ConfigValue) -> PyResult> { + config_values::config_value_to_python(py, value) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/context_variable.rs b/crates/sqlbuild-python-base/src/boundary/main/context_variable.rs new file mode 100644 index 000000000..775fb91f4 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/context_variable.rs @@ -0,0 +1,19 @@ +//! The `contextvars.ContextVar(name, default=None)` kept in `cell`, created once per interpreter. + +use crate::boundary::_helpers::python_calls; +use pyo3::prelude::Bound; +use pyo3::prelude::Py; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; +use pyo3::sync::PyOnceLock; + +/// The `contextvars.ContextVar(name, default=None)` kept in `cell`, created once per interpreter. +#[inline] +pub fn context_variable<'py>( + py: Python<'py>, + cell: &'static PyOnceLock>, + name: &str, +) -> PyResult> { + python_calls::context_variable(py, cell, name) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/imported.rs b/crates/sqlbuild-python-base/src/boundary/main/imported.rs new file mode 100644 index 000000000..fae64e761 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/imported.rs @@ -0,0 +1,13 @@ +//! `module.name`, imported. + +use crate::boundary::_helpers::python_calls; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// `module.name`, imported. +#[inline] +pub fn imported<'py>(py: Python<'py>, module: &str, name: &str) -> PyResult> { + python_calls::imported(py, module, name) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/json_value_to_python.rs b/crates/sqlbuild-python-base/src/boundary/main/json_value_to_python.rs new file mode 100644 index 000000000..f92df69a0 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/json_value_to_python.rs @@ -0,0 +1,16 @@ +//! JSON-backed configuration keeps integer widths and recursively constructs native Python values. + +use crate::boundary::_helpers::config_values; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// JSON-backed configuration keeps integer widths and recursively constructs native Python values. +#[inline] +pub fn json_value_to_python<'py>( + py: Python<'py>, + value: &serde_json::Value, +) -> PyResult> { + config_values::json_value_to_python(py, value) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/keywords.rs b/crates/sqlbuild-python-base/src/boundary/main/keywords.rs new file mode 100644 index 000000000..caef2f4cb --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/keywords.rs @@ -0,0 +1,17 @@ +//! Keyword arguments built from `(name, value)` pairs, in order. + +use crate::boundary::_helpers::python_calls; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; +use pyo3::types::PyDict; + +/// Keyword arguments built from `(name, value)` pairs, in order. +#[inline] +pub fn keywords<'py>( + py: Python<'py>, + pairs: &[(&str, Bound<'py, PyAny>)], +) -> PyResult> { + python_calls::keywords(py, pairs) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/mod.rs b/crates/sqlbuild-python-base/src/boundary/main/mod.rs new file mode 100644 index 000000000..689ee6deb --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/mod.rs @@ -0,0 +1,15 @@ +pub mod call_argument; +pub mod call_with; +pub mod compiler_error; +pub mod compiler_guard; +pub mod config_value_to_python; +pub mod context_variable; +pub mod imported; +pub mod json_value_to_python; +pub mod keywords; +pub mod native_compiler_error; +pub mod register_expected_errors; +pub mod register_native_compiler_error; +pub mod register_oracles; +pub mod value_error; +pub mod within; diff --git a/crates/sqlbuild-python-base/src/boundary/main/native_compiler_error.rs b/crates/sqlbuild-python-base/src/boundary/main/native_compiler_error.rs new file mode 100644 index 000000000..530fa05e1 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/native_compiler_error.rs @@ -0,0 +1,10 @@ +//! The named compiler error for an internal native failure. + +use crate::boundary::_helpers::panics; +use pyo3::PyErr; + +/// The named compiler error for an internal native failure. +#[inline] +pub fn native_compiler_error(message: impl Into) -> PyErr { + panics::native_compiler_error(message) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/register_expected_errors.rs b/crates/sqlbuild-python-base/src/boundary/main/register_expected_errors.rs new file mode 100644 index 000000000..3da7331be --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/register_expected_errors.rs @@ -0,0 +1,12 @@ +//! Register expected errors. + +use crate::boundary::_helpers::expected_errors; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// register_expected_errors. +#[inline] +pub fn register_expected_errors(module: &Bound<'_, PyModule>) -> PyResult<()> { + expected_errors::register(module) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/register_native_compiler_error.rs b/crates/sqlbuild-python-base/src/boundary/main/register_native_compiler_error.rs new file mode 100644 index 000000000..e961a3232 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/register_native_compiler_error.rs @@ -0,0 +1,12 @@ +//! Add `NativeCompilerError` to the extension module. + +use crate::boundary::_helpers::panics; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// Add `NativeCompilerError` to the extension module. +#[inline] +pub fn register_native_compiler_error(module: &Bound<'_, PyModule>) -> PyResult<()> { + panics::register_native_compiler_error(module) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/register_oracles.rs b/crates/sqlbuild-python-base/src/boundary/main/register_oracles.rs new file mode 100644 index 000000000..e1bf9b1a3 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/register_oracles.rs @@ -0,0 +1,12 @@ +//! Register oracles. + +use crate::boundary::_helpers::oracles; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// register_oracles. +#[inline] +pub fn register_oracles(module: &Bound<'_, PyModule>) -> PyResult<()> { + oracles::register(module) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/value_error.rs b/crates/sqlbuild-python-base/src/boundary/main/value_error.rs new file mode 100644 index 000000000..3bad6940e --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/value_error.rs @@ -0,0 +1,10 @@ +//! The same as `compiler_error`. + +use crate::boundary::_helpers::panics; +use pyo3::PyErr; + +/// The same as `compiler_error`. +#[inline] +pub fn value_error(error: impl std::fmt::Display) -> PyErr { + panics::value_error(error) +} diff --git a/crates/sqlbuild-python-base/src/boundary/main/within.rs b/crates/sqlbuild-python-base/src/boundary/main/within.rs new file mode 100644 index 000000000..dd7f66d8c --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/main/within.rs @@ -0,0 +1,15 @@ +//! Run `body` inside `with manager as entered:`; managers here never suppress exceptions. + +use crate::boundary::_helpers::python_calls; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// Run `body` inside `with manager as entered:`; managers here never suppress exceptions. +#[inline] +pub fn within<'py, T>( + manager: &Bound<'py, PyAny>, + body: impl FnOnce(&Bound<'py, PyAny>) -> PyResult, +) -> PyResult { + python_calls::within(manager, body) +} diff --git a/crates/sqlbuild-python-base/src/boundary/mod.rs b/crates/sqlbuild-python-base/src/boundary/mod.rs new file mode 100644 index 000000000..c1820ee79 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/mod.rs @@ -0,0 +1,5 @@ +//! Python call plumbing shared by every binding: keyword calls, imports, conversions and panics. + +pub(crate) mod _helpers; +pub mod main; +pub mod models; diff --git a/crates/sqlbuild-python-base/src/boundary/models.rs b/crates/sqlbuild-python-base/src/boundary/models.rs new file mode 100644 index 000000000..cf4462702 --- /dev/null +++ b/crates/sqlbuild-python-base/src/boundary/models.rs @@ -0,0 +1,139 @@ +//! Keyword arguments of native entry points and the transient status line they report to. + +use pyo3::exceptions::PyTypeError; +use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyResult, Python}; +use pyo3::types::{PyBool, PyDict, PyDictMethods, PyString}; + +use crate::boundary::_helpers::python_calls::call_with; + +/// Keyword arguments of one call, each required. +#[derive(Debug)] +pub struct Request<'a, 'py> { + function: &'static str, + arguments: &'a Bound<'py, PyDict>, +} + +impl<'a, 'py> Request<'a, 'py> { + pub fn new( + function: &'static str, + arguments: Option<&'a Bound<'py, PyDict>>, + ) -> PyResult { + match arguments { + Some(arguments) => Ok(Self { + function, + arguments, + }), + None => Err(PyTypeError::new_err(format!( + "{function}() missing required keyword-only arguments" + ))), + } + } + + pub fn py(&self) -> Python<'py> { + self.arguments.py() + } + + pub fn get(&self, name: &str) -> PyResult> { + self.arguments.get_item(name)?.ok_or_else(|| { + PyTypeError::new_err(format!( + "{}() missing 1 required keyword-only argument: '{name}'", + self.function + )) + }) + } + + /// The argument, or `None` when the caller left it out. + pub fn optional(&self, name: &str) -> PyResult>> { + self.arguments.get_item(name) + } +} + +/// The transient status line, when one is shown. +#[derive(Debug)] +pub struct Status<'py>(pub Bound<'py, PyAny>); + +impl Status<'_> { + pub fn start(&self, message: &str) -> PyResult<()> { + if !self.0.is_none() { + self.0.call_method1("start", (message,))?; + } + Ok(()) + } + + pub fn complete(&self, message: &str) -> PyResult<()> { + if !self.0.is_none() { + call_with( + &self.0.getattr("complete")?, + &[("message", PyString::new(self.0.py(), message).into_any())], + )?; + } + Ok(()) + } +} + +/// Keyword-only arguments of a driver entry point, checked as Python checks a signature. +#[derive(Debug)] +pub struct KeywordArguments<'py> { + values: Bound<'py, PyDict>, +} + +impl<'py> KeywordArguments<'py> { + /// Accept `options` for `function`, rejecting missing `required` and unknown names. + pub fn read( + py: Python<'py>, + function: &str, + options: Option>, + (required, optional): (&[&str], &[&str]), + ) -> PyResult { + let values: Bound<'py, PyDict> = options.unwrap_or_else(|| PyDict::new(py)); + for name in values.keys() { + let name: String = name.extract()?; + if !required.contains(&name.as_str()) && !optional.contains(&name.as_str()) { + return Err(PyTypeError::new_err(format!( + "{function}() got an unexpected keyword argument '{name}'" + ))); + } + } + for name in required { + if !values.contains(*name)? { + return Err(PyTypeError::new_err(format!( + "{function}() missing 1 required keyword-only argument: '{name}'" + ))); + } + } + Ok(Self { values }) + } + + /// Whether the argument `name` was passed. + pub fn contains(&self, name: &str) -> PyResult { + self.values.contains(name) + } + + /// The argument `name`, or `None` when it was not passed. + pub fn value(&self, name: &str) -> PyResult> { + let py: Python<'py> = self.values.py(); + Ok(self + .values + .get_item(name)? + .unwrap_or_else(|| py.None().into_bound(py))) + } + + /// The argument `name` as a truth value, `False` when it was not passed. + pub fn flag(&self, name: &str) -> PyResult { + self.value(name)?.is_truthy() + } + + /// The argument `name`, or `False` when it was not passed. + pub fn value_or_false(&self, name: &str) -> PyResult> { + let py: Python<'py> = self.values.py(); + Ok(self + .values + .get_item(name)? + .unwrap_or_else(|| PyBool::new(py, false).to_owned().into_any())) + } + + /// Whether `name` was passed. + pub fn passed(&self, name: &str) -> PyResult { + self.values.contains(name) + } +} diff --git a/crates/sqlbuild-python-base/src/lib.rs b/crates/sqlbuild-python-base/src/lib.rs new file mode 100644 index 000000000..862f42135 --- /dev/null +++ b/crates/sqlbuild-python-base/src/lib.rs @@ -0,0 +1,8 @@ +//! The shared base of the `sqlbuild._native` bindings: native records, Python calls and host entries. + +#![forbid(unsafe_code)] + +pub mod boundary; +pub mod native_host; +pub mod records; +pub mod types; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/native_host/host.rs b/crates/sqlbuild-python-base/src/native_host/_helpers/host.rs similarity index 98% rename from crates/sqlbuild-python/src/bindings/_helpers/native_host/host.rs rename to crates/sqlbuild-python-base/src/native_host/_helpers/host.rs index 6fa6820d8..dfd6cf90c 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/native_host/host.rs +++ b/crates/sqlbuild-python-base/src/native_host/_helpers/host.rs @@ -11,7 +11,7 @@ use sqlbuild_host::entries::constants::{HOST_ENTRIES, HOST_MODULE, HOST_TARGETS_ use sqlbuild_host::entries::models::{HostId, UserCodeHost}; use sqlbuild_host::entries::types::HostEntries; -use crate::bindings::_helpers::boundary::python_calls::within; +use crate::boundary::main::within::within; /// One entry's target module path and attribute name. type Target = (Py, Py); diff --git a/crates/sqlbuild-python-base/src/native_host/_helpers/mod.rs b/crates/sqlbuild-python-base/src/native_host/_helpers/mod.rs new file mode 100644 index 000000000..e5c0bc02e --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/_helpers/mod.rs @@ -0,0 +1 @@ +pub(crate) mod host; diff --git a/crates/sqlbuild-python-base/src/native_host/main/flush_console.rs b/crates/sqlbuild-python-base/src/native_host/main/flush_console.rs new file mode 100644 index 000000000..43c36b36a --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/flush_console.rs @@ -0,0 +1,11 @@ +//! Flush the interpreter's live console `stream` so text written before a child process appears first. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// Flush the interpreter's live console `stream` so text written before a child process appears first. +#[inline] +pub fn flush_console(py: Python<'_>, stream: &str) -> PyResult<()> { + host::flush_console(py, stream) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/host_entry.rs b/crates/sqlbuild-python-base/src/native_host/main/host_entry.rs new file mode 100644 index 000000000..27bd33a60 --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/host_entry.rs @@ -0,0 +1,14 @@ +//! The host entry `id`: its target module imported and the attribute read on every call. + +use crate::native_host::_helpers::host; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; +use sqlbuild_host::entries::models::HostId; + +/// The host entry `id`: its target module imported and the attribute read on every call. +#[inline] +pub fn host_entry<'py>(py: Python<'py>, id: impl Into) -> PyResult> { + host::entry(py, id) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/log_debug_message.rs b/crates/sqlbuild-python-base/src/native_host/main/log_debug_message.rs new file mode 100644 index 000000000..678e52867 --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/log_debug_message.rs @@ -0,0 +1,11 @@ +//! `log_debug_event(logger=logging.getLogger(logger), message=message)`. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// `log_debug_event(logger=logging.getLogger(logger), message=message)`. +#[inline] +pub fn log_debug_message(py: Python<'_>, logger: &str, message: &str) -> PyResult<()> { + host::log_debug_message(py, logger, message) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/log_warning_message.rs b/crates/sqlbuild-python-base/src/native_host/main/log_warning_message.rs new file mode 100644 index 000000000..e146fb971 --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/log_warning_message.rs @@ -0,0 +1,11 @@ +//! `logging.getLogger(logger).warning(message)`. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// `logging.getLogger(logger).warning(message)`. +#[inline] +pub fn log_warning_message(py: Python<'_>, logger: &str, message: &str) -> PyResult<()> { + host::log_warning_message(py, logger, message) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/mod.rs b/crates/sqlbuild-python-base/src/native_host/main/mod.rs new file mode 100644 index 000000000..6198f548b --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/mod.rs @@ -0,0 +1,9 @@ +pub mod flush_console; +pub mod host_entry; +pub mod log_debug_message; +pub mod log_warning_message; +pub mod module_installed; +pub mod python_executable; +pub mod redirect_stdout_to_stderr; +pub mod within_identity_pass; +pub mod write_console; diff --git a/crates/sqlbuild-python-base/src/native_host/main/module_installed.rs b/crates/sqlbuild-python-base/src/native_host/main/module_installed.rs new file mode 100644 index 000000000..9b968f53c --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/module_installed.rs @@ -0,0 +1,11 @@ +//! Whether this interpreter can import the top-level module `name`. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// Whether this interpreter can import the top-level module `name`. +#[inline] +pub fn module_installed(py: Python<'_>, name: &str) -> PyResult { + host::module_installed(py, name) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/python_executable.rs b/crates/sqlbuild-python-base/src/native_host/main/python_executable.rs new file mode 100644 index 000000000..d7a0b1eeb --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/python_executable.rs @@ -0,0 +1,12 @@ +//! The interpreter running SQLBuild, which child processes reuse. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; +use std::path::PathBuf; + +/// The interpreter running SQLBuild, which child processes reuse. +#[inline] +pub fn python_executable(py: Python<'_>) -> PyResult { + host::python_executable(py) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/redirect_stdout_to_stderr.rs b/crates/sqlbuild-python-base/src/native_host/main/redirect_stdout_to_stderr.rs new file mode 100644 index 000000000..d1f57a932 --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/redirect_stdout_to_stderr.rs @@ -0,0 +1,13 @@ +//! Keep user prints off machine-readable stdout while running project code. + +use crate::native_host::_helpers::host; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// Keep user prints off machine-readable stdout while running project code. +#[inline] +pub fn redirect_stdout_to_stderr(py: Python<'_>) -> PyResult> { + host::redirect_stdout_to_stderr(py) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/within_identity_pass.rs b/crates/sqlbuild-python-base/src/native_host/main/within_identity_pass.rs new file mode 100644 index 000000000..3a1656c2f --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/within_identity_pass.rs @@ -0,0 +1,14 @@ +//! Run `body` inside one Python-node identity pass, so the identities it builds share source work. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// Run `body` inside one Python-node identity pass, so the identities it builds share source work. +#[inline] +pub fn within_identity_pass<'py, T>( + py: Python<'py>, + body: impl FnOnce() -> PyResult, +) -> PyResult { + host::within_identity_pass(py, body) +} diff --git a/crates/sqlbuild-python-base/src/native_host/main/write_console.rs b/crates/sqlbuild-python-base/src/native_host/main/write_console.rs new file mode 100644 index 000000000..8b1b1f44e --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/main/write_console.rs @@ -0,0 +1,11 @@ +//! Write through the interpreter's live console, respecting redirection and surfacing delivery errors. + +use crate::native_host::_helpers::host; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// Write through the interpreter's live console, respecting redirection and surfacing delivery errors. +#[inline] +pub fn write_console(py: Python<'_>, stream: &str, text: &str) -> PyResult<()> { + host::write_console(py, stream, text) +} diff --git a/crates/sqlbuild-python-base/src/native_host/mod.rs b/crates/sqlbuild-python-base/src/native_host/mod.rs new file mode 100644 index 000000000..c954c0691 --- /dev/null +++ b/crates/sqlbuild-python-base/src/native_host/mod.rs @@ -0,0 +1,4 @@ +//! Calls into the permanent Python host entries of `sqlbuild._native_host`. + +pub(crate) mod _helpers; +pub mod main; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compile_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/compile_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/compile_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compile_records/constants.rs index 010e0b588..4d3ce8b6a 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/compile_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/compile_records/constants.rs @@ -2,8 +2,8 @@ use sqlbuild_host::entries::models::{FacadeHost, UserCodeHost}; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_RELATED_LOCATION: RecordSpec = RecordSpec { name: "RelatedLocation", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compile_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/compile_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/compile_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compile_records/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_enums/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_enums/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_enums/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_enums/constants.rs index a366d7d45..6c3b9ce8a 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/compiler_enums/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/compiler_enums/constants.rs @@ -1,6 +1,6 @@ //! The compiler, rule, lint and config string enums hosted natively. -use crate::bindings::_helpers::records::models::EnumSpec; +use crate::records::models::EnumSpec; const E_CONTRACT_FINDING_KIND: EnumSpec = EnumSpec { name: "ContractFindingKind", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_enums/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_enums/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_enums/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_enums/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_errors/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_errors/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_errors/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_errors/constants.rs index ba5fb5914..2a3bfbcd9 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/compiler_errors/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/compiler_errors/constants.rs @@ -1,7 +1,7 @@ //! The compiler, rule, lint and config expected-error classes hosted natively. -use crate::bindings::_helpers::records::constants::{EXCEPTION_PARENT, VALUE_ERROR_PARENT}; -use crate::bindings::_helpers::records::models::{ClassValue, ErrorSpec}; +use crate::records::constants::{EXCEPTION_PARENT, VALUE_ERROR_PARENT}; +use crate::records::models::{ClassValue, ErrorSpec}; /// Compiler, rule, lint and config expected-error classes, each after its parent. pub(crate) const COMPILER_ERRORS: &[ErrorSpec] = &[ diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_errors/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_errors/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_errors/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_errors/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_records/constants.rs index e9a5c0476..42289b766 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/compiler_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/compiler_records/constants.rs @@ -2,8 +2,8 @@ use sqlbuild_host::entries::models::UserCodeHost; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_NATIVE_PIVOT_TABLES: RecordSpec = RecordSpec { name: "NativePivotTables", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/compiler_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/compiler_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/compiler_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/compiler_records/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/contract_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/contract_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/contract_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/contract_records/constants.rs index e6224c7dc..d77c2bcff 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/contract_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/contract_records/constants.rs @@ -1,7 +1,7 @@ //! Layouts of the project configuration and contract value records hosted natively. -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_CLONE_POLICY: RecordSpec = RecordSpec { name: "ClonePolicy", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/contract_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/contract_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/contract_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/contract_records/mod.rs diff --git a/crates/sqlbuild-python-base/src/records/_helpers/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/mod.rs new file mode 100644 index 000000000..446ab8496 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/_helpers/mod.rs @@ -0,0 +1,9 @@ +pub(crate) mod compile_records; +pub(crate) mod compiler_enums; +pub(crate) mod compiler_errors; +pub(crate) mod compiler_records; +pub(crate) mod contract_records; +pub(crate) mod native_classes; +pub(crate) mod planner_records; +pub(crate) mod rule_records; +pub(crate) mod scope_records; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/behaviours.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/behaviours.rs similarity index 80% rename from crates/sqlbuild-python/src/bindings/_helpers/records/behaviours.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/behaviours.rs index 2c066186f..507b49a5f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/behaviours.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/behaviours.rs @@ -2,8 +2,8 @@ use std::sync::OnceLock; -use crate::bindings::_helpers::records::constants::NO_RECORD_BEHAVIOURS; -use crate::bindings::_helpers::records::models::RecordBehaviours; +use crate::records::constants::NO_RECORD_BEHAVIOURS; +use crate::records::models::RecordBehaviours; static INSTALLED: OnceLock<&'static RecordBehaviours> = OnceLock::new(); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/construct.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/construct.rs similarity index 97% rename from crates/sqlbuild-python/src/bindings/_helpers/records/construct.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/construct.rs index d21f1b0ad..ab9001ca1 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/construct.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/construct.rs @@ -7,8 +7,8 @@ use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyErr, PyModule, PyResult, P use pyo3::sync::PyOnceLock; use pyo3::types::{PyDict, PyDictMethods}; -use crate::bindings::_helpers::boundary::python_calls::keywords; -use crate::bindings::_helpers::records::ids::{ErrorId, RecordId}; +use crate::boundary::main::keywords::keywords; +use crate::records::types::{ErrorId, RecordId}; /// Each `RecordId`'s class, captured when the extension module is initialised. static CLASSES: PyOnceLock>> = PyOnceLock::new(); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/error_classes.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/error_classes.rs similarity index 96% rename from crates/sqlbuild-python/src/bindings/_helpers/records/error_classes.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/error_classes.rs index 474616f07..66e125b0a 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/error_classes.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/error_classes.rs @@ -5,9 +5,9 @@ use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods, PyTuple, PyTupleMethods, PyTypeMethods}; use pyo3::{IntoPyObjectExt, pyclass, pymethods}; -use crate::bindings::_helpers::records::constants::{ERROR_SPEC_ATTRIBUTE, ERRORS}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::models::{ClassValue, ErrorSpec}; +use crate::records::_helpers::native_classes::fields::field as native_field; +use crate::records::constants::{ERROR_SPEC_ATTRIBUTE, ERRORS}; +use crate::records::models::{ClassValue, ErrorSpec}; /// The `__init__` of the expected-error classes: `Error(message, *, code=None, help=None, **fields)`. #[derive(Debug)] diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/fields.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/fields.rs similarity index 97% rename from crates/sqlbuild-python/src/bindings/_helpers/records/fields.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/fields.rs index 358d1bd40..92fb5279c 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/fields.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/fields.rs @@ -16,19 +16,17 @@ use pyo3::types::{ use sqlbuild_discovery::model_files::main::model_file_stem::model_file_stem; use sqlbuild_rules::project_tree::main::pure_path_posix::pure_path_posix; -use crate::bindings::_helpers::boundary::python_calls::imported; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::behaviours::behaviours; -use crate::bindings::_helpers::records::constants::{ +use crate::boundary::main::imported::imported; +use crate::native_host::main::host_entry::host_entry; +use crate::records::_helpers::native_classes::behaviours::behaviours; +use crate::records::_helpers::native_classes::construct::{enum_member, new_record}; +use crate::records::_helpers::native_classes::getters::getter_field; +use crate::records::constants::{ CURRENT_DIRECTORY_PATH, ENUMS, FROZEN_INSTANCE_ERROR, NATIVE_MODULE, RECORD_SPEC_ATTRIBUTE, RECORDS, }; -use crate::bindings::_helpers::records::construct::{enum_member, new_record}; -use crate::bindings::_helpers::records::getters::getter_field; -use crate::bindings::_helpers::records::models::{ - EnumSpec, FieldDefault, NativeRecord, RecordSpec, -}; -use crate::bindings::_helpers::records::types::{ClassProperty, RecordFinish}; +use crate::records::models::{EnumSpec, FieldDefault, NativeRecord, RecordSpec}; +use crate::records::types::{ClassProperty, RecordFinish}; /// How a test run treats `field` falling back to `getattr` on a native class: unset outside tests. pub(crate) const NATIVE_FIELD_STRICT_ENV_VAR: &str = "SQLBUILD_NATIVE_FIELD_STRICT"; @@ -479,7 +477,7 @@ fn default_value<'py>( FieldDefault::EmptyDict => Ok(PyDict::new(py).into_any()), FieldDefault::EmptyFrozenset => Ok(PyFrozenSet::empty(py)?.into_any()), FieldDefault::Member(module, class, member) => imported(py, module, class)?.getattr(member), - FieldDefault::HostMember(class, member) => host::entry(py, class)?.getattr(member), + FieldDefault::HostMember(class, member) => host_entry(py, class)?.getattr(member), FieldDefault::NativeMember(class, member) => enum_member(py, class, member), FieldDefault::NativeCall(class) => new_record(py, class, (), None), FieldDefault::Factory(factory) => factory(py), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/getters.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/getters.rs similarity index 93% rename from crates/sqlbuild-python/src/bindings/_helpers/records/getters.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/getters.rs index 43c36fbcb..39e8b01c2 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/getters.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/getters.rs @@ -8,8 +8,8 @@ use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::sync::PyOnceLock; use pyo3::types::PyType; -use crate::bindings::_helpers::records::models::GetterEntry; -use crate::bindings::_helpers::records::types::GetterRead; +use crate::records::models::GetterEntry; +use crate::records::types::GetterRead; static TABLES: OnceLock<&'static [&'static [GetterEntry]]> = OnceLock::new(); static DISPATCH: PyOnceLock> = PyOnceLock::new(); diff --git a/crates/sqlbuild-python-base/src/records/_helpers/native_classes/ids.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/ids.rs new file mode 100644 index 000000000..36b3d857a --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/ids.rs @@ -0,0 +1,1010 @@ +//! The registered Python names of the typed native ids, so native code never looks them up by string. + +use crate::records::types::{ErrorId, NativeAttr, RecordId}; + +/// Each variant's declaration-order list and the Python name it is registered under. +macro_rules! native_id_names { + ($name:ident { $($enum:ident::$variant:ident => $text:literal,)* }) => { + impl $name { + /// Every variant, in declaration order. + pub const ALL: &'static [Self] = &[$($enum::$variant,)*]; + + /// The attribute name the variant is registered under. + pub const fn name(self) -> &'static str { + match self { + $(Self::$variant => $text,)* + } + } + } + + const _: () = { + let mut index: usize = 0; + while index < $name::ALL.len() { + assert!( + $name::ALL[index] as usize == index, + "ALL must follow declaration order: lookups index tables by `id as usize`" + ); + index += 1; + } + }; + }; +} + +native_id_names! { + RecordId { + RecordId::AdapterConnectionContext => "AdapterConnectionContext", + RecordId::AdapterSourceFreshnessBatch => "AdapterSourceFreshnessBatch", + RecordId::AlignedInterval => "AlignedInterval", + RecordId::AnalysisCacheContext => "AnalysisCacheContext", + RecordId::AttachedAuditGateEdge => "AttachedAuditGateEdge", + RecordId::AuditCommandRequest => "AuditCommandRequest", + RecordId::AuditGateIdentity => "AuditGateIdentity", + RecordId::AuditIdentity => "AuditIdentity", + RecordId::AuditInvocation => "AuditInvocation", + RecordId::AuditPlanEntry => "AuditPlanEntry", + RecordId::AuthoredSqlSet => "AuthoredSqlSet", + RecordId::AuthoredSqlValueCall => "AuthoredSqlValueCall", + RecordId::AuthoredTimeTravelRetention => "AuthoredTimeTravelRetention", + RecordId::BackfillAction => "BackfillAction", + RecordId::BackfillResult => "BackfillResult", + RecordId::BuildCommandRequest => "BuildCommandRequest", + RecordId::BuildCostFinalization => "BuildCostFinalization", + RecordId::BuildInvocation => "BuildInvocation", + RecordId::ChainStep => "ChainStep", + RecordId::ChangeDetectionResult => "ChangeDetectionResult", + RecordId::ChangeKind => "ChangeKind", + RecordId::CheckCommandRequest => "CheckCommandRequest", + RecordId::CheckInvocation => "CheckInvocation", + RecordId::CliCommand => "CliCommand", + RecordId::CliEntrypointHandlers => "CliEntrypointHandlers", + RecordId::CloneCommandRequest => "CloneCommandRequest", + RecordId::ClonePipelineConnection => "ClonePipelineConnection", + RecordId::ClonePipelineOptions => "ClonePipelineOptions", + RecordId::ClonePipelineResult => "ClonePipelineResult", + RecordId::ClonePolicy => "ClonePolicy", + RecordId::CloneSourcePlanEntry => "CloneSourcePlanEntry", + RecordId::CollectionRendering => "CollectionRendering", + RecordId::ColumnLineage => "ColumnLineage", + RecordId::ColumnLineageConfidence => "ColumnLineageConfidence", + RecordId::ColumnLineageEdge => "ColumnLineageEdge", + RecordId::ColumnLineageMode => "ColumnLineageMode", + RecordId::CompiledResourceType => "CompiledResourceType", + RecordId::ColumnLineageSource => "ColumnLineageSource", + RecordId::ColumnMigrationDecision => "ColumnMigrationDecision", + RecordId::ColumnMigrationEvent => "ColumnMigrationEvent", + RecordId::ColumnMigrationPlanEntry => "ColumnMigrationPlanEntry", + RecordId::ColumnRenameHint => "ColumnRenameHint", + RecordId::ColumnTransformKind => "ColumnTransformKind", + RecordId::CommandWarehouseScope => "CommandWarehouseScope", + RecordId::CompactLineageFacts => "CompactLineageFacts", + RecordId::CompileAdapterContext => "CompileAdapterContext", + RecordId::CompileAnalysis => "CompileAnalysis", + RecordId::CompileAnalysisSelection => "CompileAnalysisSelection", + RecordId::CompileCommandRequest => "CompileCommandRequest", + RecordId::CompileDirectLogicSqlTestInputPayload => "CompileDirectLogicSqlTestInputPayload", + RecordId::CompileFacts => "CompileFacts", + RecordId::CompileLineageMode => "CompileLineageMode", + RecordId::CompileModelConfig => "CompileModelConfig", + RecordId::CompileModelInput => "CompileModelInput", + RecordId::CompileModelSqlTestInputPayload => "CompileModelSqlTestInputPayload", + RecordId::CompilePipelineOptions => "CompilePipelineOptions", + RecordId::CompilePipelineResult => "CompilePipelineResult", + RecordId::CompileProfileFlags => "CompileProfileFlags", + RecordId::CompileProjectInputs => "CompileProjectInputs", + RecordId::CompileSqlReference => "CompileSqlReference", + RecordId::CompileSqlScenarioCte => "CompileSqlScenarioCte", + RecordId::CompileSqlScenarioInput => "CompileSqlScenarioInput", + RecordId::CompileSqlTestCte => "CompileSqlTestCte", + RecordId::CompileSqlTestInput => "CompileSqlTestInput", + RecordId::CompiledAudit => "CompiledAudit", + RecordId::CompiledDirectLogicSqlTestPayload => "CompiledDirectLogicSqlTestPayload", + RecordId::CompiledFunction => "CompiledFunction", + RecordId::CompiledLineageColumnFact => "CompiledLineageColumnFact", + RecordId::CompiledLineageSourceFact => "CompiledLineageSourceFact", + RecordId::CompiledModel => "CompiledModel", + RecordId::CompiledModelSqlTestPayload => "CompiledModelSqlTestPayload", + RecordId::CompiledObjectKey => "CompiledObjectKey", + RecordId::CompiledProject => "CompiledProject", + RecordId::CompiledProjectPhaseResult => "CompiledProjectPhaseResult", + RecordId::CompiledRelationLocation => "CompiledRelationLocation", + RecordId::CompiledSeed => "CompiledSeed", + RecordId::CompiledSource => "CompiledSource", + RecordId::CompiledSqlExpansion => "CompiledSqlExpansion", + RecordId::CompiledSqlScenario => "CompiledSqlScenario", + RecordId::CompiledSqlTest => "CompiledSqlTest", + RecordId::CompiledSqlTestResource => "CompiledSqlTestResource", + RecordId::CompilerDiagnostic => "CompilerDiagnostic", + RecordId::CompilerStage => "CompilerStage", + RecordId::CompletionState => "CompletionState", + RecordId::ConstantDeclaration => "ConstantDeclaration", + RecordId::ConstantMetadata => "ConstantMetadata", + RecordId::ConstantsConfig => "ConstantsConfig", + RecordId::ContractAdoptionResult => "ContractAdoptionResult", + RecordId::ContractCommandRequest => "ContractCommandRequest", + RecordId::ContractEvidence => "ContractEvidence", + RecordId::ContractFinding => "ContractFinding", + RecordId::ContractFindingKind => "ContractFindingKind", + RecordId::ContractPolicy => "ContractPolicy", + RecordId::ContractValidationResult => "ContractValidationResult", + RecordId::CostCommandRequest => "CostCommandRequest", + RecordId::CostConfig => "CostConfig", + RecordId::CostRunRecord => "CostRunRecord", + RecordId::CursorBounds => "CursorBounds", + RecordId::CursorGrain => "CursorGrain", + RecordId::CursorInputEvidence => "CursorInputEvidence", + RecordId::CursorInputRelation => "CursorInputRelation", + RecordId::CursorInputRoles => "CursorInputRoles", + RecordId::CursorOverridePair => "CursorOverridePair", + RecordId::CursorOverrides => "CursorOverrides", + RecordId::CursorSnapshotScope => "CursorSnapshotScope", + RecordId::CursorType => "CursorType", + RecordId::CursorWatermarkMode => "CursorWatermarkMode", + RecordId::CursorsConfig => "CursorsConfig", + RecordId::CustomHostPartition => "CustomHostPartition", + RecordId::CustomRuleEvaluation => "CustomRuleEvaluation", + RecordId::CustomRuleRun => "CustomRuleRun", + RecordId::CustomRulesOutcome => "CustomRulesOutcome", + RecordId::DateValue => "DateValue", + RecordId::DbtCliConfigOverrides => "DbtCliConfigOverrides", + RecordId::DbtCliOptions => "DbtCliOptions", + RecordId::DbtCommandExecutionResult => "DbtCommandExecutionResult", + RecordId::DbtCommandResult => "DbtCommandResult", + RecordId::DbtConfig => "DbtConfig", + RecordId::DbtInitCommandRequest => "DbtInitCommandRequest", + RecordId::DbtInitProgressCallbacks => "DbtInitProgressCallbacks", + RecordId::DbtInitRequest => "DbtInitRequest", + RecordId::DbtInitResult => "DbtInitResult", + RecordId::DbtInteropCommand => "DbtInteropCommand", + RecordId::DbtInteropCommandArgs => "DbtInteropCommandArgs", + RecordId::DbtInteropCompiledProject => "DbtInteropCompiledProject", + RecordId::DbtInteropExecutionRequest => "DbtInteropExecutionRequest", + RecordId::DbtInteropInvocation => "DbtInteropInvocation", + RecordId::DbtInteropParsedArgs => "DbtInteropParsedArgs", + RecordId::DbtInteropPlan => "DbtInteropPlan", + RecordId::DbtInteropPlanResolution => "DbtInteropPlanResolution", + RecordId::DbtInteropRoutedArgs => "DbtInteropRoutedArgs", + RecordId::DbtInteropSelectionResult => "DbtInteropSelectionResult", + RecordId::DbtInteropSkipReason => "DbtInteropSkipReason", + RecordId::DbtLsNode => "DbtLsNode", + RecordId::DbtLsResult => "DbtLsResult", + RecordId::DbtManifestIndex => "DbtManifestIndex", + RecordId::DbtManifestModel => "DbtManifestModel", + RecordId::DbtManifestSeed => "DbtManifestSeed", + RecordId::DbtManifestSource => "DbtManifestSource", + RecordId::DbtNodeExecutionResult => "DbtNodeExecutionResult", + RecordId::DbtNodeMessage => "DbtNodeMessage", + RecordId::DbtPlanEnvironment => "DbtPlanEnvironment", + RecordId::DbtSqlbuildPlanRequest => "DbtSqlbuildPlanRequest", + RecordId::DbtSqlbuildWorkContext => "DbtSqlbuildWorkContext", + RecordId::DeclarationExpansionContext => "DeclarationExpansionContext", + RecordId::DeclarationExplanation => "DeclarationExplanation", + RecordId::DeclarationIdentity => "DeclarationIdentity", + RecordId::DeclarationKind => "DeclarationKind", + RecordId::DeclarationRecord => "DeclarationRecord", + RecordId::DeclarationReport => "DeclarationReport", + RecordId::DeclarationResolutionContext => "DeclarationResolutionContext", + RecordId::DeclarationRuntimeProjection => "DeclarationRuntimeProjection", + RecordId::DeclarationScopeBuild => "DeclarationScopeBuild", + RecordId::DeclarationScopeResolver => "DeclarationScopeResolver", + RecordId::DeclarationVisibility => "DeclarationVisibility", + RecordId::DeclarationVisibilityIndex => "DeclarationVisibilityIndex", + RecordId::DefaultsConfig => "DefaultsConfig", + RecordId::DeferralInputs => "DeferralInputs", + RecordId::DiagnosticPhase => "DiagnosticPhase", + RecordId::DiagnosticSeverity => "DiagnosticSeverity", + RecordId::DiffCommandRequest => "DiffCommandRequest", + RecordId::DiffConfig => "DiffConfig", + RecordId::DirectModelVersionIdentities => "DirectModelVersionIdentities", + RecordId::DirectSemanticColumnUse => "DirectSemanticColumnUse", + RecordId::DirectSourceFreshnessPlanningResult => "DirectSourceFreshnessPlanningResult", + RecordId::DirectSourceFreshnessPropagationResult => "DirectSourceFreshnessPropagationResult", + RecordId::DiscoveredAdapterFile => "DiscoveredAdapterFile", + RecordId::DiscoveredAssetFunction => "DiscoveredAssetFunction", + RecordId::DiscoveredAuditBlock => "DiscoveredAuditBlock", + RecordId::DiscoveredAuditFactory => "DiscoveredAuditFactory", + RecordId::DiscoveredAuditFile => "DiscoveredAuditFile", + RecordId::DiscoveredCheckFunction => "DiscoveredCheckFunction", + RecordId::DiscoveredCommandOutputSink => "DiscoveredCommandOutputSink", + RecordId::DiscoveredCommandOutputSinkDeclaration => "DiscoveredCommandOutputSinkDeclaration", + RecordId::DiscoveredConstantFile => "DiscoveredConstantFile", + RecordId::DiscoveredEnumFile => "DiscoveredEnumFile", + RecordId::DiscoveredEventExporter => "DiscoveredEventExporter", + RecordId::DiscoveredEventExporterDeclaration => "DiscoveredEventExporterDeclaration", + RecordId::DiscoveredHookFunction => "DiscoveredHookFunction", + RecordId::DiscoveredLoaderFunction => "DiscoveredLoaderFunction", + RecordId::DiscoveredMacroFile => "DiscoveredMacroFile", + RecordId::DiscoveredMaterializationFile => "DiscoveredMaterializationFile", + RecordId::DiscoveredModelSchemaFile => "DiscoveredModelSchemaFile", + RecordId::DiscoveredProjectInputs => "DiscoveredProjectInputs", + RecordId::DiscoveredProvider => "DiscoveredProvider", + RecordId::DiscoveredProviderUsage => "DiscoveredProviderUsage", + RecordId::DiscoveredPythonAssetMetadata => "DiscoveredPythonAssetMetadata", + RecordId::DiscoveredPythonCheckMetadata => "DiscoveredPythonCheckMetadata", + RecordId::DiscoveredPythonFunctionFile => "DiscoveredPythonFunctionFile", + RecordId::DiscoveredPythonLoaderMetadata => "DiscoveredPythonLoaderMetadata", + RecordId::DiscoveredPythonNode => "DiscoveredPythonNode", + RecordId::DiscoveredPythonNodeFunctions => "DiscoveredPythonNodeFunctions", + RecordId::DiscoveredPythonTaskMetadata => "DiscoveredPythonTaskMetadata", + RecordId::DiscoveredRuntimeExtensions => "DiscoveredRuntimeExtensions", + RecordId::DiscoveredSchemaFile => "DiscoveredSchemaFile", + RecordId::DiscoveredSeedFile => "DiscoveredSeedFile", + RecordId::DiscoveredSourceFile => "DiscoveredSourceFile", + RecordId::DiscoveredSqlFunctionFile => "DiscoveredSqlFunctionFile", + RecordId::DiscoveredSqlHookFile => "DiscoveredSqlHookFile", + RecordId::DiscoveredSqlScenarioFile => "DiscoveredSqlScenarioFile", + RecordId::DiscoveredSqlTestBlock => "DiscoveredSqlTestBlock", + RecordId::DiscoveredSqlTestCase => "DiscoveredSqlTestCase", + RecordId::DiscoveredSqlTestFile => "DiscoveredSqlTestFile", + RecordId::DiscoveredTaskFunction => "DiscoveredTaskFunction", + RecordId::DiscoveryFileFault => "DiscoveryFileFault", + RecordId::DisplayOptions => "DisplayOptions", + RecordId::Duration => "Duration", + RecordId::DynamicColumnContractProof => "DynamicColumnContractProof", + RecordId::DynamicColumnFamilyProof => "DynamicColumnFamilyProof", + RecordId::EmptyCursorInputDecision => "EmptyCursorInputDecision", + RecordId::EnumDeclaration => "EnumDeclaration", + RecordId::EnumMember => "EnumMember", + RecordId::EnumMemberMetadata => "EnumMemberMetadata", + RecordId::EnumMetadata => "EnumMetadata", + RecordId::EventExportSeverity => "EventExportSeverity", + RecordId::ExecutionLimitsConfig => "ExecutionLimitsConfig", + RecordId::ExpansionSpan => "ExpansionSpan", + RecordId::Finding => "Finding", + RecordId::Fingerprint => "Fingerprint", + RecordId::FingerprintSet => "FingerprintSet", + RecordId::FixVerdict => "FixVerdict", + RecordId::FixtureColumnInference => "FixtureColumnInference", + RecordId::FreshnessCommandRequest => "FreshnessCommandRequest", + RecordId::FunctionArgument => "FunctionArgument", + RecordId::FunctionChangeResult => "FunctionChangeResult", + RecordId::FunctionPlanEntry => "FunctionPlanEntry", + RecordId::FunctionReturnColumn => "FunctionReturnColumn", + RecordId::FutureCursorAction => "FutureCursorAction", + RecordId::FutureCursorSafetyEvidence => "FutureCursorSafetyEvidence", + RecordId::FutureCursorsConfig => "FutureCursorsConfig", + RecordId::GrantKind => "GrantKind", + RecordId::GrantRecord => "GrantRecord", + RecordId::GraphEdgeExclusion => "GraphEdgeExclusion", + RecordId::GraphResourceKind => "GraphResourceKind", + RecordId::HandBuiltAnalysis => "HandBuiltAnalysis", + RecordId::HardCodedRelationOwnerKind => "HardCodedRelationOwnerKind", + RecordId::HeaderSpan => "HeaderSpan", + RecordId::HistoricalInput => "HistoricalInput", + RecordId::HookReadEdge => "HookReadEdge", + RecordId::HookReadType => "HookReadType", + RecordId::InaccessibleReason => "InaccessibleReason", + RecordId::InaccessibleRecord => "InaccessibleRecord", + RecordId::IncrementalMode => "IncrementalMode", + RecordId::IncrementalStrategy => "IncrementalStrategy", + RecordId::InferredColumn => "InferredColumn", + RecordId::InferredNullability => "InferredNullability", + RecordId::InitialValidFrom => "InitialValidFrom", + RecordId::IntegerValue => "IntegerValue", + RecordId::IntegrationLoaderConfig => "IntegrationLoaderConfig", + RecordId::InterpolationSite => "InterpolationSite", + RecordId::InvalidSqlReferenceCall => "InvalidSqlReferenceCall", + RecordId::JanitorCommandRequest => "JanitorCommandRequest", + RecordId::JanitorConfig => "JanitorConfig", + RecordId::JanitorInvocation => "JanitorInvocation", + RecordId::JanitorSettings => "JanitorSettings", + RecordId::LayoutConfig => "LayoutConfig", + RecordId::LifecycleEventSinkFilterConfig => "LifecycleEventSinkFilterConfig", + RecordId::LifecycleEventSinksConfig => "LifecycleEventSinksConfig", + RecordId::LineageCommandRequest => "LineageCommandRequest", + RecordId::LineageGraphViews => "LineageGraphViews", + RecordId::LintBody => "LintBody", + RecordId::LintConfig => "LintConfig", + RecordId::LintEdit => "LintEdit", + RecordId::LintFileRole => "LintFileRole", + RecordId::LintRunResult => "LintRunResult", + RecordId::LintSeverity => "LintSeverity", + RecordId::LintViolation => "LintViolation", + RecordId::LiteralSqlRelation => "LiteralSqlRelation", + RecordId::LoadCommandRequest => "LoadCommandRequest", + RecordId::LoadedMacro => "LoadedMacro", + RecordId::LoaderConnectionMode => "LoaderConnectionMode", + RecordId::LoaderDestinationParts => "LoaderDestinationParts", + RecordId::LocalClonePolicy => "LocalClonePolicy", + RecordId::LocalConfig => "LocalConfig", + RecordId::LocalDbtConfig => "LocalDbtConfig", + RecordId::LocalTargetConfig => "LocalTargetConfig", + RecordId::MacroContext => "MacroContext", + RecordId::MacroExpansionResult => "MacroExpansionResult", + RecordId::MacroMetadata => "MacroMetadata", + RecordId::ManualLocation => "ManualLocation", + RecordId::MappedOffset => "MappedOffset", + RecordId::MaterializationDefaultsConfig => "MaterializationDefaultsConfig", + RecordId::MaterializationRetentionDefaults => "MaterializationRetentionDefaults", + RecordId::MaterializationType => "MaterializationType", + RecordId::MaximumStartPolicyInputs => "MaximumStartPolicyInputs", + RecordId::MaximumStartSafetyEvidence => "MaximumStartSafetyEvidence", + RecordId::MeasurementContract => "MeasurementContract", + RecordId::MeasurementThresholdBound => "MeasurementThresholdBound", + RecordId::MeasurementThresholds => "MeasurementThresholds", + RecordId::MicrobatchLimitAction => "MicrobatchLimitAction", + RecordId::MicrobatchLimitsConfig => "MicrobatchLimitsConfig", + RecordId::MicrobatchStrategy => "MicrobatchStrategy", + RecordId::MicrobatchesConfig => "MicrobatchesConfig", + RecordId::MigrationCompatibility => "MigrationCompatibility", + RecordId::MigrationDecision => "MigrationDecision", + RecordId::MigrationDiscovery => "MigrationDiscovery", + RecordId::MigrationEvent => "MigrationEvent", + RecordId::MigrationPromotion => "MigrationPromotion", + RecordId::MigrationRelation => "MigrationRelation", + RecordId::MigrationsConfig => "MigrationsConfig", + RecordId::MissingMigrationOriginPolicy => "MissingMigrationOriginPolicy", + RecordId::MissingUpstream => "MissingUpstream", + RecordId::Model => "Model", + RecordId::ModelColumnLineage => "ModelColumnLineage", + RecordId::ModelCursorSnapshot => "ModelCursorSnapshot", + RecordId::ModelInputBuildContext => "ModelInputBuildContext", + RecordId::ModelMigrationPlanEntry => "ModelMigrationPlanEntry", + RecordId::ModelPlanEntry => "ModelPlanEntry", + RecordId::ModelSchemaDeclaration => "ModelSchemaDeclaration", + RecordId::ModelSql => "ModelSql", + RecordId::ModelSqlAnalysis => "ModelSqlAnalysis", + RecordId::ModelValidationRequest => "ModelValidationRequest", + RecordId::ModuleStateFingerprint => "ModuleStateFingerprint", + RecordId::ModuleStateTrace => "ModuleStateTrace", + RecordId::MovePreview => "MovePreview", + RecordId::NamedSqlHookEntry => "NamedSqlHookEntry", + RecordId::NativeColumnQuery => "NativeColumnQuery", + RecordId::NativeModelConfigInputs => "NativeModelConfigInputs", + RecordId::NativeModelConfigSession => "NativeModelConfigSession", + RecordId::NativePivotTables => "NativePivotTables", + RecordId::NativeQueryColumns => "NativeQueryColumns", + RecordId::NativeRulesEvaluation => "NativeRulesEvaluation", + RecordId::NativeSqlTestArtifact => "NativeSqlTestArtifact", + RecordId::NativeSqlTestAssembly => "NativeSqlTestAssembly", + RecordId::NativeSqlTestFailure => "NativeSqlTestFailure", + RecordId::NativeSqlTestPlan => "NativeSqlTestPlan", + RecordId::NestedProgressChildRow => "NestedProgressChildRow", + RecordId::NormalizedDbtProfileConnection => "NormalizedDbtProfileConnection", + RecordId::OldNameView => "OldNameView", + RecordId::OldNameViewAction => "OldNameViewAction", + RecordId::OldNameViewDropReason => "OldNameViewDropReason", + RecordId::OldNameViewEvent => "OldNameViewEvent", + RecordId::OldNameViewEventType => "OldNameViewEventType", + RecordId::OldNameViewHistory => "OldNameViewHistory", + RecordId::OldNameViewPlanEntry => "OldNameViewPlanEntry", + RecordId::OldNameViewStatus => "OldNameViewStatus", + RecordId::OnSchemaChange => "OnSchemaChange", + RecordId::OwnershipRoot => "OwnershipRoot", + RecordId::OwnershipRootKind => "OwnershipRootKind", + RecordId::ParsedCliInvocation => "ParsedCliInvocation", + RecordId::ParsedScenarioArtifactName => "ParsedScenarioArtifactName", + RecordId::ParsedSelector => "ParsedSelector", + RecordId::PartialBuildPhaseTimings => "PartialBuildPhaseTimings", + RecordId::PathSelector => "PathSelector", + RecordId::PlanAction => "PlanAction", + RecordId::PlanCommandRequest => "PlanCommandRequest", + RecordId::PlanOutput => "PlanOutput", + RecordId::PlanOutputExtras => "PlanOutputExtras", + RecordId::PlanProviderUsage => "PlanProviderUsage", + RecordId::PlanReason => "PlanReason", + RecordId::PlanSafetyGates => "PlanSafetyGates", + RecordId::PlanWarning => "PlanWarning", + RecordId::PlannedSqlTests => "PlannedSqlTests", + RecordId::PlannerChangeResults => "PlannerChangeResults", + RecordId::PlannerOverrides => "PlannerOverrides", + RecordId::PlannerPolicies => "PlannerPolicies", + RecordId::PlannerResolvedActions => "PlannerResolvedActions", + RecordId::PlannerScope => "PlannerScope", + RecordId::PlannerSelection => "PlannerSelection", + RecordId::PlaygroundCommandRequest => "PlaygroundCommandRequest", + RecordId::PlaygroundTemplate => "PlaygroundTemplate", + RecordId::PolyglotAnalysisDialect => "PolyglotAnalysisDialect", + RecordId::PolyglotAnalysisResult => "PolyglotAnalysisResult", + RecordId::Project => "Project", + RecordId::ProjectConfig => "ProjectConfig", + RecordId::ProjectPath => "ProjectPath", + RecordId::PythonHookEntry => "PythonHookEntry", + RecordId::PythonIdentityDependency => "PythonIdentityDependency", + RecordId::PythonIdentityStatus => "PythonIdentityStatus", + RecordId::PythonNodeDependencyEdge => "PythonNodeDependencyEdge", + RecordId::PythonNodeGraph => "PythonNodeGraph", + RecordId::PythonNodeIdentity => "PythonNodeIdentity", + RecordId::PythonPlanEntry => "PythonPlanEntry", + RecordId::PythonRunPhase => "PythonRunPhase", + RecordId::PythonRunPlanOutputs => "PythonRunPlanOutputs", + RecordId::PythonSqlReferenceReport => "PythonSqlReferenceReport", + RecordId::PythonSqlRunLifecyclePlan => "PythonSqlRunLifecyclePlan", + RecordId::PythonSqlRunSelection => "PythonSqlRunSelection", + RecordId::QualifiedLineageColumn => "QualifiedLineageColumn", + RecordId::QueryCostObservation => "QueryCostObservation", + RecordId::QueryDiffPreparation => "QueryDiffPreparation", + RecordId::QueryProjection => "QueryProjection", + RecordId::QueryShape => "QueryShape", + RecordId::RefactorCommandRequest => "RefactorCommandRequest", + RecordId::RefactorProject => "RefactorProject", + RecordId::ReviewCommandRequest => "ReviewCommandRequest", + RecordId::ReferenceRename => "ReferenceRename", + RecordId::ReferencesConfig => "ReferencesConfig", + RecordId::RelatedLocation => "RelatedLocation", + RecordId::RelationFixtureCompletion => "RelationFixtureCompletion", + RecordId::RelationFixtureDiagnostic => "RelationFixtureDiagnostic", + RecordId::ResolvedDbtConfig => "ResolvedDbtConfig", + RecordId::ResolvedDbtProfileOutput => "ResolvedDbtProfileOutput", + RecordId::ResolvedModelAction => "ResolvedModelAction", + RecordId::ResolvedTableType => "ResolvedTableType", + RecordId::ResolvedTimeTravelRetention => "ResolvedTimeTravelRetention", + RecordId::ResolvedWarehouse => "ResolvedWarehouse", + RecordId::ResourceCost => "ResourceCost", + RecordId::ResourceIdentity => "ResourceIdentity", + RecordId::ResourceKind => "ResourceKind", + RecordId::ResourceRecord => "ResourceRecord", + RecordId::RetentionDecreasePolicy => "RetentionDecreasePolicy", + RecordId::RetentionDirection => "RetentionDirection", + RecordId::RetentionPlanEntry => "RetentionPlanEntry", + RecordId::RetentionPlanPhase => "RetentionPlanPhase", + RecordId::Rule => "Rule", + RecordId::RuleCase => "RuleCase", + RecordId::RuleExemption => "RuleExemption", + RecordId::RuleFactViews => "RuleFactViews", + RecordId::RuleFile => "RuleFile", + RecordId::RuleFixResult => "RuleFixResult", + RecordId::RuleGuidance => "RuleGuidance", + RecordId::RuleIgnore => "RuleIgnore", + RecordId::RuleOption => "RuleOption", + RecordId::RuleResult => "RuleResult", + RecordId::RuleRunPlan => "RuleRunPlan", + RecordId::RuleSubject => "RuleSubject", + RecordId::RulesCacheConfig => "RulesCacheConfig", + RecordId::RulesCommandRequest => "RulesCommandRequest", + RecordId::RulesConfig => "RulesConfig", + RecordId::RulesResult => "RulesResult", + RecordId::RulesRunResult => "RulesRunResult", + RecordId::ScenarioArtifactIdentity => "ScenarioArtifactIdentity", + RecordId::ScenarioArtifactKind => "ScenarioArtifactKind", + RecordId::ScenarioArtifactName => "ScenarioArtifactName", + RecordId::ScenarioAssertionExpectationPlan => "ScenarioAssertionExpectationPlan", + RecordId::ScenarioCaptureCommandRequest => "ScenarioCaptureCommandRequest", + RecordId::ScenarioConfig => "ScenarioConfig", + RecordId::ScenarioExecutionPlan => "ScenarioExecutionPlan", + RecordId::ScenarioExpectedExpectationPlan => "ScenarioExpectedExpectationPlan", + RecordId::ScenarioFixturePlan => "ScenarioFixturePlan", + RecordId::ScenarioGraphPlan => "ScenarioGraphPlan", + RecordId::ScenarioRelationMap => "ScenarioRelationMap", + RecordId::ScenarioRelationPlan => "ScenarioRelationPlan", + RecordId::ScenarioSnapshotLimitInputs => "ScenarioSnapshotLimitInputs", + RecordId::ScenarioSnapshotLimitsConfig => "ScenarioSnapshotLimitsConfig", + RecordId::ScenarioTestCommandRequest => "ScenarioTestCommandRequest", + RecordId::SchemaAction => "SchemaAction", + RecordId::SchemaActionKind => "SchemaActionKind", + RecordId::SchemaAuditInstance => "SchemaAuditInstance", + RecordId::SchemaChangeKind => "SchemaChangeKind", + RecordId::SchemaColumn => "SchemaColumn", + RecordId::SchemaColumnSource => "SchemaColumnSource", + RecordId::SchemaDynamicColumnFamily => "SchemaDynamicColumnFamily", + RecordId::SchemaFinding => "SchemaFinding", + RecordId::SchemaModelEntry => "SchemaModelEntry", + RecordId::SchemaSeedEntry => "SchemaSeedEntry", + RecordId::ScopeBrowseResult => "ScopeBrowseResult", + RecordId::ScopeChainEntry => "ScopeChainEntry", + RecordId::ScopeCommandRequest => "ScopeCommandRequest", + RecordId::ScopeCompleteness => "ScopeCompleteness", + RecordId::ScopeDiagnostic => "ScopeDiagnostic", + RecordId::ScopeDiagnosticCode => "ScopeDiagnosticCode", + RecordId::ScopeDiagnosticSeverity => "ScopeDiagnosticSeverity", + RecordId::ScopeFolder => "ScopeFolder", + RecordId::ScopeIndex => "ScopeIndex", + RecordId::ScopeKind => "ScopeKind", + RecordId::ScopeListResult => "ScopeListResult", + RecordId::ScopeLookup => "ScopeLookup", + RecordId::ScopeReport => "ScopeReport", + RecordId::ScopeReportFilters => "ScopeReportFilters", + RecordId::ScopeResourceReport => "ScopeResourceReport", + RecordId::ScopeSection => "ScopeSection", + RecordId::ScopeSourceLocation => "ScopeSourceLocation", + RecordId::ScopeTargetQuery => "ScopeTargetQuery", + RecordId::ScopesConfig => "ScopesConfig", + RecordId::SeedCommandRequest => "SeedCommandRequest", + RecordId::SeedCsvSettings => "SeedCsvSettings", + RecordId::SeedInvocation => "SeedInvocation", + RecordId::SeedPlanEntry => "SeedPlanEntry", + RecordId::SelectStarAllow => "SelectStarAllow", + RecordId::SelectedDbtProfileOutput => "SelectedDbtProfileOutput", + RecordId::SelectionStalenessGraph => "SelectionStalenessGraph", + RecordId::SelectionStalenessNodeKey => "SelectionStalenessNodeKey", + RecordId::SelectionStalenessWarning => "SelectionStalenessWarning", + RecordId::SelectorExpansion => "SelectorExpansion", + RecordId::SelectorFileSummary => "SelectorFileSummary", + RecordId::SelectorKind => "SelectorKind", + RecordId::SettingsConfig => "SettingsConfig", + RecordId::SinksConfig => "SinksConfig", + RecordId::SkillMaintenanceResult => "SkillMaintenanceResult", + RecordId::SkillUpdateResult => "SkillUpdateResult", + RecordId::SnapshotSchemaChangePolicy => "SnapshotSchemaChangePolicy", + RecordId::SnapshotStrategy => "SnapshotStrategy", + RecordId::SnapshotsConfig => "SnapshotsConfig", + RecordId::SourceColumnEntry => "SourceColumnEntry", + RecordId::SourceEntry => "SourceEntry", + RecordId::SourceFreshnessAgePolicy => "SourceFreshnessAgePolicy", + RecordId::SourceFreshnessAgeStatus => "SourceFreshnessAgeStatus", + RecordId::SourceFreshnessConfig => "SourceFreshnessConfig", + RecordId::SourceFreshnessIdentity => "SourceFreshnessIdentity", + RecordId::SourceFreshnessObservation => "SourceFreshnessObservation", + RecordId::SourceFreshnessRecord => "SourceFreshnessRecord", + RecordId::SourceFreshnessRenderers => "SourceFreshnessRenderers", + RecordId::SourceFreshnessSet => "SourceFreshnessSet", + RecordId::SourceFreshnessStrategy => "SourceFreshnessStrategy", + RecordId::SourceFreshnessUnknown => "SourceFreshnessUnknown", + RecordId::SourceFreshnessUnknownReason => "SourceFreshnessUnknownReason", + RecordId::SourceFreshnessValueKind => "SourceFreshnessValueKind", + RecordId::SourceLoadPlanEntry => "SourceLoadPlanEntry", + RecordId::SourceLocation => "SourceLocation", + RecordId::SourceWriteStrategy => "SourceWriteStrategy", + RecordId::SqlBindingDiagnostic => "SqlBindingDiagnostic", + RecordId::SqlBindingResult => "SqlBindingResult", + RecordId::SqlExpansionContext => "SqlExpansionContext", + RecordId::SqlHookEntry => "SqlHookEntry", + RecordId::SqlLexicalSyntax => "SqlLexicalSyntax", + RecordId::SqlLogicalType => "SqlLogicalType", + RecordId::SqlNode => "SqlNode", + RecordId::SqlReferenceKind => "SqlReferenceKind", + RecordId::SqlReferenceScan => "SqlReferenceScan", + RecordId::SqlRulesEvaluation => "SqlRulesEvaluation", + RecordId::SqlSchemaValidationRequest => "SqlSchemaValidationRequest", + RecordId::SqlTestAssertionStep => "SqlTestAssertionStep", + RecordId::SqlTestParameterDeclaration => "SqlTestParameterDeclaration", + RecordId::SqlTestPlanEntry => "SqlTestPlanEntry", + RecordId::SqlTestPlanResult => "SqlTestPlanResult", + RecordId::SqlTestRulesConfig => "SqlTestRulesConfig", + RecordId::SqlTestSelection => "SqlTestSelection", + RecordId::SqlValue => "SqlValue", + RecordId::SqlValueKind => "SqlValueKind", + RecordId::SqlValueLimits => "SqlValueLimits", + RecordId::StartCursorsConfig => "StartCursorsConfig", + RecordId::StateSqlValueType => "StateSqlValueType", + RecordId::StatementLedgerEntry => "StatementLedgerEntry", + RecordId::StaticCommandContext => "StaticCommandContext", + RecordId::StaticMacroExport => "StaticMacroExport", + RecordId::StaticMacroFault => "StaticMacroFault", + RecordId::StaticMacroInventory => "StaticMacroInventory", + RecordId::TableType => "TableType", + RecordId::TableTypeDowngradePolicy => "TableTypeDowngradePolicy", + RecordId::TableTypePlanEntry => "TableTypePlanEntry", + RecordId::TableTypeSource => "TableTypeSource", + RecordId::TargetConfig => "TargetConfig", + RecordId::TargetDiffConfig => "TargetDiffConfig", + RecordId::TargetWarehousesConfig => "TargetWarehousesConfig", + RecordId::TestCommandRequest => "TestCommandRequest", + RecordId::TestInvocation => "TestInvocation", + RecordId::ThresholdOverride => "ThresholdOverride", + RecordId::TimeTravelRetentionSource => "TimeTravelRetentionSource", + RecordId::TimestampValue => "TimestampValue", + RecordId::TolerantScopeDiscovery => "TolerantScopeDiscovery", + RecordId::UnitTestSelectorSplit => "UnitTestSelectorSplit", + RecordId::UsageKind => "UsageKind", + RecordId::UsageRecord => "UsageRecord", + RecordId::VisibilityProvenance => "VisibilityProvenance", + RecordId::VisibilityReason => "VisibilityReason", + RecordId::VisibilityRecord => "VisibilityRecord", + RecordId::VisibilityResolution => "VisibilityResolution", + RecordId::VisibleModelDeclarations => "VisibleModelDeclarations", + RecordId::WarehouseFingerprints => "WarehouseFingerprints", + RecordId::WarehouseGroup => "WarehouseGroup", + RecordId::WarehouseSnapshot => "WarehouseSnapshot", + RecordId::WarningSeverity => "WarningSeverity", + RecordId::WrittenTarget => "WrittenTarget", + } +} + +native_id_names! { + ErrorId { + ErrorId::CliUser => "CliUserError", + ErrorId::CompileInput => "CompileInputError", + ErrorId::ConfigValueType => "ConfigValueTypeError", + ErrorId::ContractAdoption => "ContractAdoptionError", + ErrorId::DbtInteropArgument => "DbtInteropArgumentError", + ErrorId::DbtInteropConfig => "DbtInteropConfigError", + ErrorId::DbtInterop => "DbtInteropError", + ErrorId::DbtInteropRuntime => "DbtInteropRuntimeError", + ErrorId::DeclarationParse => "DeclarationParseError", + ErrorId::DiffSizeGuard => "DiffSizeGuardError", + ErrorId::DiscoveryConflict => "DiscoveryConflictError", + ErrorId::Discovery => "DiscoveryError", + ErrorId::EventExporterDiscovery => "EventExporterDiscoveryError", + ErrorId::FingerprintInput => "FingerprintInputError", + ErrorId::FutureCursorSafety => "FutureCursorSafetyError", + ErrorId::HostCancelled => "HostCancelledError", + ErrorId::InvalidQualifiedIdentity => "InvalidQualifiedIdentityError", + ErrorId::InvalidScopePath => "InvalidScopePathError", + ErrorId::Lint => "LintError", + ErrorId::LintStopped => "LintStoppedError", + ErrorId::MacroArgument => "MacroArgumentError", + ErrorId::MaximumAutomaticStart => "MaximumAutomaticStartError", + ErrorId::MeasurementAudit => "MeasurementAuditError", + ErrorId::MigrationState => "MigrationStateError", + ErrorId::ModelSqlParse => "ModelSqlParseError", + ErrorId::NativeLint => "NativeLintError", + ErrorId::NativeSqlTestPlanning => "NativeSqlTestPlanningError", + ErrorId::NativeStageMismatch => "NativeStageMismatchError", + ErrorId::NonHermeticRule => "NonHermeticRuleError", + ErrorId::OpaqueModuleState => "OpaqueModuleStateError", + ErrorId::PlannerInput => "PlannerInputError", + ErrorId::OrchestrationDeclaration => "OrchestrationDeclarationError", + ErrorId::ProjectCompile => "ProjectCompileError", + ErrorId::ProjectConfig => "ProjectConfigError", + ErrorId::ProjectPath => "ProjectPathError", + ErrorId::ProjectPythonPath => "ProjectPythonPathError", + ErrorId::ProviderDiscovery => "ProviderDiscoveryError", + ErrorId::PythonNodeDiscovery => "PythonNodeDiscoveryError", + ErrorId::QueryDiffExecution => "QueryDiffExecutionError", + ErrorId::QueryDiffIncomplete => "QueryDiffIncompleteError", + ErrorId::QueryDiffOutcome => "QueryDiffOutcomeError", + ErrorId::QueryExecution => "QueryExecutionError", + ErrorId::QueryFingerprint => "QueryFingerprintError", + ErrorId::RefactorIO => "RefactorIOError", + ErrorId::RefactorValue => "RefactorValueError", + ErrorId::ResourceIdentity => "ResourceIdentityError", + ErrorId::ReviewFailed => "ReviewFailedError", + ErrorId::RuleAssertion => "RuleAssertionError", + ErrorId::RuleUsage => "RuleUsageError", + ErrorId::RulesConfig => "RulesConfigError", + ErrorId::Rules => "RulesError", + ErrorId::SchemaParse => "SchemaParseError", + ErrorId::Scope => "ScopeError", + ErrorId::ScopeValidation => "ScopeValidationError", + ErrorId::SeedDiscovery => "SeedDiscoveryError", + ErrorId::SourceParse => "SourceParseError", + ErrorId::SpecConfig => "SpecConfigError", + ErrorId::SqlAuditParse => "SqlAuditParseError", + ErrorId::SqlHookParse => "SqlHookParseError", + ErrorId::SqlScenarioParse => "SqlScenarioParseError", + ErrorId::SqlTestParse => "SqlTestParseError", + ErrorId::SqlTestReference => "SqlTestReferenceError", + ErrorId::StagedArtifactsChanged => "StagedArtifactsChangedError", + ErrorId::UnindexableScope => "UnindexableScopeError", + ErrorId::UnknownLineageDialect => "UnknownLineageDialectError", + ErrorId::UnsupportedLexicalSyntax => "UnsupportedLexicalSyntaxError", + } +} + +native_id_names! { + NativeAttr { + NativeAttr::AnalyzeCompileProject => "analyze_compile_project", + NativeAttr::ApplyCommandWarehouse => "apply_command_warehouse", + NativeAttr::ApplyMaximumStartPolicy => "apply_maximum_start_policy", + NativeAttr::ApplyTypedCursorReplayPolicy => "apply_typed_cursor_replay_policy", + NativeAttr::AssembleProject => "assemble_project", + NativeAttr::AttachChecks => "attach_checks", + NativeAttr::AttachResources => "attach_resources", + NativeAttr::AttachSqlbuildPlanOutput => "attach_sqlbuild_plan_output", + NativeAttr::AuditProgressReporter => "AuditProgressReporter", + NativeAttr::BindingPositions => "BindingPositions", + NativeAttr::BuildAuditCommandPlan => "build_audit_command_plan", + NativeAttr::BuildCompileDbtManifestIndex => "build_compile_dbt_manifest_index", + NativeAttr::BuildCompileInputs => "build_compile_inputs", + NativeAttr::BuildCursorInputRelations => "build_cursor_input_relations", + NativeAttr::BuildDagJson => "build_dag_json", + NativeAttr::BuildDbtCombinedGraph => "build_dbt_combined_graph", + NativeAttr::BuildDbtInitProject => "build_dbt_init_project", + NativeAttr::BuildDbtInitProjectToml => "build_dbt_init_project_toml", + NativeAttr::BuildDeclarationScope => "build_declaration_scope", + NativeAttr::BuildDeferredLocations => "build_deferred_locations", + NativeAttr::BuildDirectSemanticUses => "build_direct_semantic_uses", + NativeAttr::BuildDisplayOnlySqlbuildPlan => "build_display_only_sqlbuild_plan", + NativeAttr::BuildEffectiveConnectionConfig => "build_effective_connection_config", + NativeAttr::BuildEffectiveRuntimeConfig => "build_effective_runtime_config", + NativeAttr::BuildEffectiveSettingsConfig => "build_effective_settings_config", + NativeAttr::BuildEffectiveTargetConfig => "build_effective_target_config", + NativeAttr::BuildEffectiveTargetNamespace => "build_effective_target_namespace", + NativeAttr::BuildExecutionPlan => "build_execution_plan", + NativeAttr::BuildFailedSqlbuildModelNames => "build_failed_sqlbuild_model_names", + NativeAttr::BuildIdentity => "BUILD_IDENTITY", + NativeAttr::BuildIntermediateSourceMap => "build_intermediate_source_map", + NativeAttr::BuildManifest => "build_manifest", + NativeAttr::BuildMergedDbtExecutionArgv => "build_merged_dbt_execution_argv", + NativeAttr::BuildModelWarnings => "build_model_warnings", + NativeAttr::BuildPhaseTimingTracker => "BuildPhaseTimingTracker", + NativeAttr::BuildPlannerRelationsContext => "build_planner_relations_context", + NativeAttr::BuildPlannerSourceFreshnessResult => "build_planner_source_freshness_result", + NativeAttr::BuildProgressCallbacks => "BuildProgressCallbacks", + NativeAttr::BuildProjectColumnLineage => "build_project_column_lineage", + NativeAttr::BuildProjectGraph => "build_project_graph", + NativeAttr::BuildProjectGraphFromCompiledProject => "build_project_graph_from_compiled_project", + NativeAttr::BuildProjectRelationTargets => "build_project_relation_targets", + NativeAttr::BuildPythonRelationTargets => "build_python_relation_targets", + NativeAttr::BuildPythonRunPlanOutputs => "build_python_run_plan_outputs", + NativeAttr::BuildPythonSqlRunLifecycle => "build_python_sql_run_lifecycle", + NativeAttr::BuildRuleCatalogue => "build_rule_catalogue", + NativeAttr::BuildRulesRequest => "build_rules_request", + NativeAttr::BuildScenarioExecutionPlan => "build_scenario_execution_plan", + NativeAttr::BuildScenarioHashIndex => "build_scenario_hash_index", + NativeAttr::BuildScenarioRelationMap => "build_scenario_relation_map", + NativeAttr::BuildSeedCommandPlan => "build_seed_command_plan", + NativeAttr::BuildSqlbuildPlanOutput => "build_sqlbuild_plan_output", + NativeAttr::BuildStaleOutOfSelectionWarnings => "build_stale_out_of_selection_warnings", + NativeAttr::BuildStaticPipelineResult => "build_static_pipeline_result", + NativeAttr::BuildTestCommandPlan => "build_test_command_plan", + NativeAttr::CheckBuildability => "check_buildability", + NativeAttr::CheckCompileReuse => "check_compile_reuse", + NativeAttr::CheckCursorTypeConsistency => "check_cursor_type_consistency", + NativeAttr::CliStyle => "CliStyle", + NativeAttr::CommandWarehouseScopeContext => "_command_warehouse_scope_context", + NativeAttr::CompareContracts => "compare_contracts", + NativeAttr::CompileDbtInteropProject => "compile_dbt_interop_project", + NativeAttr::CompileFrontier => "compile_frontier", + NativeAttr::CompileProjectPhase => "compile_project_phase", + NativeAttr::CompileReuseExcludedRootDirectories => "COMPILE_REUSE_EXCLUDED_ROOT_DIRECTORIES", + NativeAttr::CompileReuseRacyWindowNs => "COMPILE_REUSE_RACY_WINDOW_NS", + NativeAttr::CompileStaticCommandContext => "compile_static_command_context", + NativeAttr::CompiledCodeIdentity => "compiled_code_identity", + NativeAttr::CompiledProjectFacts => "compiled_project_facts", + NativeAttr::CompiledProjectRecord => "compiled_project_record", + NativeAttr::ComputeCursorBounds => "compute_cursor_bounds", + NativeAttr::ConnectionProgressReporter => "ConnectionProgressReporter", + NativeAttr::ContentDigest => "content_digest", + NativeAttr::ContextStoreToken => "context_store_token", + NativeAttr::CostArtifactError => "CostArtifactError", + NativeAttr::CostContext => "CostContext", + NativeAttr::CostOutputPayload => "cost_output_payload", + NativeAttr::CurrentNativeProgressProjector => "current_native_progress_projector", + NativeAttr::CursorCompare => "cursor_compare", + NativeAttr::CursorExclusiveToInclusive => "cursor_exclusive_to_inclusive", + NativeAttr::CursorObservedPartition => "cursor_observed_partition", + NativeAttr::CursorParse => "cursor_parse", + NativeAttr::CursorRender => "cursor_render", + NativeAttr::CursorSentinelToToken => "cursor_sentinel_to_token", + NativeAttr::CustomHostObserver => "custom_host_observer", + NativeAttr::CustomRuleIdentity => "custom_rule_identity", + NativeAttr::CustomRuleImplementationFingerprint => "custom_rule_implementation_fingerprint", + NativeAttr::CustomRuleImportClosure => "custom_rule_import_closure", + NativeAttr::DbtEventStream => "DbtEventStream", + NativeAttr::DbtExecutionLsArgv => "dbt_execution_ls_argv", + NativeAttr::DbtFailureDetail => "dbt_failure_detail", + NativeAttr::DbtInitProgressReporter => "DbtInitProgressReporter", + NativeAttr::DbtRunner => "DbtRunner", + NativeAttr::DebugDbtFromProject => "debug_dbt_from_project", + NativeAttr::DeclarationRows => "declaration_rows", + NativeAttr::DescribeConnectionWarehouse => "describe_connection_warehouse", + NativeAttr::DetectChanges => "detect_changes", + NativeAttr::DetectModelChanges => "detect_model_changes", + NativeAttr::DetectStaleWarningChanges => "detect_stale_warning_changes", + NativeAttr::DirectorySnapshotScope => "directory_snapshot_scope", + NativeAttr::DiscoverModelFiles => "discover_model_files", + NativeAttr::DiscoverModelSchemaFiles => "discover_model_schema_files", + NativeAttr::DiscoverSchemaFiles => "discover_schema_files", + NativeAttr::DiscoverSourceFiles => "discover_source_files", + NativeAttr::DiscoverTestFiles => "discover_test_files", + NativeAttr::DynamicContractProof => "dynamic_contract_proof", + NativeAttr::EditContractModel => "edit_contract_model", + NativeAttr::EditContractSource => "edit_contract_source", + NativeAttr::EffectiveConfigConnection => "effective_config_connection", + NativeAttr::EffectiveConfigSettings => "effective_config_settings", + NativeAttr::EffectiveConfigVars => "effective_config_vars", + NativeAttr::EnforceModelExecutionLimit => "enforce_model_execution_limit", + NativeAttr::EnforcePlanSafetyPolicies => "enforce_plan_safety_policies", + NativeAttr::EvaluateRules => "evaluate_rules", + NativeAttr::EvaluateRulesRequest => "evaluate_rules_request", + NativeAttr::EventExporterCommandScope => "EventExporterCommandScope", + NativeAttr::EventExporterCommandScopeFunction => "event_exporter_command_scope", + NativeAttr::EventExporterDispatcher => "EventExporterDispatcher", + NativeAttr::ExecuteDbtCommands => "execute_dbt_commands", + NativeAttr::ExecuteDbtInteropFromProject => "execute_dbt_interop_from_project", + NativeAttr::ExecuteDbtJsonEventStream => "execute_dbt_json_event_stream", + NativeAttr::ExecuteDbtSqlbuildWork => "execute_dbt_sqlbuild_work", + NativeAttr::ExecuteDbtWithoutStateTracking => "execute_dbt_without_state_tracking", + NativeAttr::ExecutionEventWriter => "ExecutionEventWriter", + NativeAttr::ExplicitReferencesHelp => "explicit_references_help", + NativeAttr::FinalizeRuleFindingsRows => "finalize_rule_findings_rows", + NativeAttr::FindPythonStringLocations => "find_python_string_locations", + NativeAttr::FinishRuleRun => "finish_rule_run", + NativeAttr::FormatAuditExecutionJson => "format_audit_execution_json", + NativeAttr::FormatBuildExecutionJson => "format_build_execution_json", + NativeAttr::FormatBuildFooter => "format_build_footer", + NativeAttr::FormatCloneExecutionJson => "format_clone_execution_json", + NativeAttr::FormatCompileErrorJson => "format_compile_error_json", + NativeAttr::FormatCostBreakdown => "format_cost_breakdown", + NativeAttr::FormatCostHistory => "format_cost_history", + NativeAttr::FormatCostHistoryJson => "format_cost_history_json", + NativeAttr::FormatCostJson => "format_cost_json", + NativeAttr::FormatDegradableBuildExecutionJson => "format_degradable_build_execution_json", + NativeAttr::FormatExecutionHeader => "format_execution_header", + NativeAttr::FormatExpectationDetail => "format_expectation_detail", + NativeAttr::FormatExpectationName => "format_expectation_name", + NativeAttr::FormatLintSqlBodies => "format_lint_sql_bodies", + NativeAttr::FormatLoadExecutionJson => "format_load_execution_json", + NativeAttr::FormatNativeHeaders => "format_native_headers", + NativeAttr::FormatPlan => "format_plan", + NativeAttr::FormatPlanJson => "format_plan_json", + NativeAttr::FormatRedundantFixtureNulls => "format_redundant_fixture_nulls", + NativeAttr::FormatRule => "format_rule", + NativeAttr::FormatRulesResult => "format_rules_result", + NativeAttr::FormatScenarioExecutionJson => "format_scenario_execution_json", + NativeAttr::FormatScenarioSnapshotExecutionJson => "format_scenario_snapshot_execution_json", + NativeAttr::FormatSeedExecutionJson => "format_seed_execution_json", + NativeAttr::FormatSkippedTypeProofRules => "format_skipped_type_proof_rules", + NativeAttr::FormatTestExecutionJson => "format_test_execution_json", + NativeAttr::GatherDeferredRelations => "gather_deferred_relations", + NativeAttr::GetConfigCursorBound => "get_config_cursor_bound", + NativeAttr::GetConfigStr => "get_config_str", + NativeAttr::GetMaterializationType => "get_materialization_type", + NativeAttr::GetSemanticSourceColumns => "get_semantic_source_columns", + NativeAttr::IdenticalRenames => "identical_renames", + NativeAttr::InferFixtureColumnFacts => "infer_fixture_column_facts", + NativeAttr::InferNativeExpressionSourceShapes => "infer_native_expression_source_shapes", + NativeAttr::InferNativeQueryColumns => "infer_native_query_columns", + NativeAttr::InstallRulesSkills => "install_rules_skills", + NativeAttr::LaunchRecordOffered => "_launch_record_offered", + NativeAttr::LaunchRecordWithheld => "_launch_record_withheld", + NativeAttr::ListCostRuns => "list_cost_runs", + NativeAttr::LoadCompiledDbtManifest => "load_compiled_dbt_manifest", + NativeAttr::LoadDbtManifestIndex => "load_dbt_manifest_index", + NativeAttr::LoadLocalConfigFile => "load_local_config_file", + NativeAttr::LoadOrBuildScopeIndex => "load_or_build_scope_index", + NativeAttr::LoadProgressReporter => "LoadProgressReporter", + NativeAttr::LoadProjectConfigFile => "load_project_config_file", + NativeAttr::LoadRulesConfig => "load_rules_config", + NativeAttr::LoaderDestinationPartsFunction => "loader_destination_parts", + NativeAttr::LocateModelBindingDiagnostics => "locate_model_binding_diagnostics", + NativeAttr::MachineOutputMode => "machine_output_mode", + NativeAttr::MacroStoreToken => "macro_store_token", + NativeAttr::MaintainSqlbuildSkills => "maintain_sqlbuild_skills", + NativeAttr::MatchingDynamicFamilies => "matching_dynamic_families", + NativeAttr::MaximumAllowedStart => "maximum_allowed_start", + NativeAttr::ModelPythonHookNames => "model_python_hook_names", + NativeAttr::NativeDeclarationContexts => "NativeDeclarationContexts", + NativeAttr::NativeModelLoop => "NativeModelLoop", + NativeAttr::NativeModelValidator => "NativeModelValidator", + NativeAttr::NativeProgressProjector => "NativeProgressProjector", + NativeAttr::NativeProgressProjectorContext => "_native_progress_projector_context", + NativeAttr::NestedCommandProgressCallbacks => "NestedCommandProgressCallbacks", + NativeAttr::NormalizeAnalysisSql => "normalize_analysis_sql", + NativeAttr::NormalizeDbtProfileConnection => "normalize_dbt_profile_connection", + NativeAttr::ParseDbtLsJsonLines => "parse_dbt_ls_json_lines", + NativeAttr::ParseHeaderValues => "parse_header_values", + NativeAttr::PlanColumnMigrations => "plan_column_migrations", + NativeAttr::PlanCompiledSqlTestArtifacts => "plan_compiled_sql_test_artifacts", + NativeAttr::PlanDbtInteropCommand => "plan_dbt_interop_command", + NativeAttr::PlanDbtInteropFromProject => "plan_dbt_interop_from_project", + NativeAttr::PlanHasExecutableWork => "plan_has_executable_work", + NativeAttr::PlanModel => "plan_model", + NativeAttr::PlanRuleFixes => "plan_rule_fixes", + NativeAttr::PlanRuleRun => "plan_rule_run", + NativeAttr::PlanSqlTests => "plan_sql_tests", + NativeAttr::PlanSqlTestsNatively => "plan_sql_tests_natively", + NativeAttr::PlanningProgressReporter => "PlanningProgressReporter", + NativeAttr::PreparedCompileArtifacts => "PreparedCompileArtifacts", + NativeAttr::ProjectWith => "project_with", + NativeAttr::PublicDeclarationIndexes => "public_declaration_indexes", + NativeAttr::PythonReadSourceNamesFor => "python_read_source_names_for", + NativeAttr::ReadCostRun => "read_cost_run", + NativeAttr::ReadLatestFingerprints => "read_latest_fingerprints", + NativeAttr::ReadOldNameViewHistories => "read_old_name_view_histories", + NativeAttr::ReadSelectedSeedFingerprints => "read_selected_seed_fingerprints", + NativeAttr::ReadsOutsideTargetLineage => "reads_outside_target_lineage", + NativeAttr::RecordTemplateReads => "record_template_reads", + NativeAttr::RejectUnparseableHeaderRewrites => "reject_unparseable_header_rewrites", + NativeAttr::RelationLineageFingerprint => "relation_lineage_fingerprint", + NativeAttr::RemainingContractFindings => "remaining_contract_findings", + NativeAttr::RenameHints => "rename_hints", + NativeAttr::RenamesExplainChange => "renames_explain_change", + NativeAttr::RenderAuditSql => "render_audit_sql", + NativeAttr::RenderDbtExecutionSummaryFooter => "render_dbt_execution_summary_footer", + NativeAttr::RenderDbtInteropPlan => "render_dbt_interop_plan", + NativeAttr::RenderDbtNodeResult => "render_dbt_node_result", + NativeAttr::RenderDiffErrorJson => "render_diff_error_json", + NativeAttr::RenderProjectVarText => "render_project_var_text", + NativeAttr::RenderSourceRelation => "render_source_relation", + NativeAttr::ReportCompileDiagnostic => "report_compile_diagnostic", + NativeAttr::ResolveCloneBoundary => "resolve_clone_boundary", + NativeAttr::ResolveCompileAnalysisSelection => "resolve_compile_analysis_selection", + NativeAttr::ResolveCostRun => "resolve_cost_run", + NativeAttr::ResolveDbtConfig => "resolve_dbt_config", + NativeAttr::ResolveDbtConnectionConfig => "resolve_dbt_connection_config", + NativeAttr::ResolveDbtExecutable => "resolve_dbt_executable", + NativeAttr::ResolveDbtExecutionInvocation => "resolve_dbt_execution_invocation", + NativeAttr::ResolveDbtInteropPlan => "resolve_dbt_interop_plan", + NativeAttr::ResolveDbtReferenceRelation => "resolve_dbt_reference_relation", + NativeAttr::ResolveDeferredTargetConfig => "resolve_deferred_target_config", + NativeAttr::ResolveEffectiveAdapterName => "resolve_effective_adapter_name", + NativeAttr::ResolveEffectiveScenarioConfig => "resolve_effective_scenario_config", + NativeAttr::ResolveExternalSqlReferenceResolver => "resolve_external_sql_reference_resolver", + NativeAttr::ResolveFunctionSql => "resolve_function_sql", + NativeAttr::ResolveFutureCursorSafety => "resolve_future_cursor_safety", + NativeAttr::ResolveModelDeferralInputs => "resolve_model_deferral_inputs", + NativeAttr::ResolveModelSql => "resolve_model_sql", + NativeAttr::ResolveProjectConnectionConfig => "resolve_project_connection_config", + NativeAttr::ResolveRawDbtProfileConnection => "resolve_raw_dbt_profile_connection", + NativeAttr::ResolveRefReferences => "resolve_ref_references", + NativeAttr::ResolveRuleIgnoreSelectors => "resolve_rule_ignore_selectors", + NativeAttr::ResolveSkippedViewChain => "resolve_skipped_view_chain", + NativeAttr::ResolveSourceReferences => "resolve_source_references", + NativeAttr::ResolveSqlbuildExecutionPlanOutput => "resolve_sqlbuild_execution_plan_output", + NativeAttr::ResolveStaticRelationContext => "resolve_static_relation_context", + NativeAttr::ResolveTargetConfig => "resolve_target_config", + NativeAttr::ResolveTargetConnectionConfig => "resolve_target_connection_config", + NativeAttr::ResolveTargetName => "resolve_target_name", + NativeAttr::RouteDbtInteropArgs => "route_dbt_interop_args", + NativeAttr::RuleSelected => "rule_selected", + NativeAttr::RulesBulkCachePath => "rules_bulk_cache_path", + NativeAttr::RunAuditCommand => "run_audit_command", + NativeAttr::RunBuildCommand => "run_build_command", + NativeAttr::RunCheckCommand => "run_check_command", + NativeAttr::RunCloneCommand => "run_clone_command", + NativeAttr::RunClonePipelineWithOptions => "run_clone_pipeline_with_options", + NativeAttr::RunCompile => "run_compile", + NativeAttr::RunCompileCommand => "run_compile_command", + NativeAttr::RunCompileOnlyPipeline => "run_compile_only_pipeline", + NativeAttr::RunCompilePipeline => "run_compile_pipeline", + NativeAttr::RunContractCommand => "run_contract_command", + NativeAttr::RunCostCommand => "run_cost_command", + NativeAttr::RunDagCommand => "run_dag_command", + NativeAttr::RunDbtCommand => "run_dbt_command", + NativeAttr::RunDbtInitCommand => "run_dbt_init_command", + NativeAttr::RunDbtSqlbuildWork => "run_dbt_sqlbuild_work", + NativeAttr::RunDebugCommand => "run_debug_command", + NativeAttr::RunDiffCommand => "run_diff_command", + NativeAttr::RunDiffPipeline => "run_diff_pipeline", + NativeAttr::RunFormatCommand => "run_format_command", + NativeAttr::RunInitCommand => "run_init_command", + NativeAttr::RunJanitorCommand => "run_janitor_command", + NativeAttr::RunLineageCommand => "run_lineage_command", + NativeAttr::RunLoadCommand => "run_load_command", + NativeAttr::RunPlanCommand => "run_plan_command", + NativeAttr::RunPlannedSqlRules => "run_planned_sql_rules", + NativeAttr::RunPlaygroundCommand => "run_playground_command", + NativeAttr::RunQueryCommand => "run_query_command", + NativeAttr::RunRefactorCommand => "run_refactor_command", + NativeAttr::RunRules => "run_rules", + NativeAttr::RunRulesCommand => "run_rules_command", + NativeAttr::RunScenarioCaptureCommand => "run_scenario_capture_command", + NativeAttr::RunScenarioTestCommand => "run_scenario_test_command", + NativeAttr::RunScopeCommand => "run_scope_command", + NativeAttr::RunSeedCommand => "run_seed_command", + NativeAttr::RunSkillsCommand => "run_skills_command", + NativeAttr::RunTestCommand => "run_test_command", + NativeAttr::RuntimeCursorProducerNames => "runtime_cursor_producer_names", + NativeAttr::SafeFormatFiles => "safe_format_files", + NativeAttr::SchemaValidations => "schema_validations", + NativeAttr::ScopeMetadataProjection => "scope_metadata_projection", + NativeAttr::SelectCatalogueRules => "select_catalogue_rules", + NativeAttr::SelectedRuleCodes => "selected_rule_codes", + NativeAttr::SessionOutcomeAnalysis => "session_outcome_analysis", + NativeAttr::SettingHelp => "setting_help", + NativeAttr::SharedTransientLineCoordinator => "shared_transient_line_coordinator", + NativeAttr::SourceBindingDiagnostics => "source_binding_diagnostics", + NativeAttr::SourceFreshnessInputError => "SourceFreshnessInputError", + NativeAttr::SourceFreshnessObservationError => "SourceFreshnessObservationError", + NativeAttr::SplitSelectorExpansion => "split_selector_expansion", + NativeAttr::SqlTestModelChainNamesByKey => "sql_test_model_chain_names_by_key", + NativeAttr::SqlTestScanCache => "SqlTestScanCache", + NativeAttr::SqlValueValidationError => "SqlValueValidationError", + NativeAttr::StoredOldNameViewColumns => "stored_old_name_view_columns", + NativeAttr::TerminalEventIndex => "TerminalEventIndex", + NativeAttr::TerminalEventIndexContext => "_terminal_event_index_context", + NativeAttr::TerminalEventIndexScopeFunction => "terminal_event_index_scope", + NativeAttr::TransientStatusReporter => "TransientStatusReporter", + NativeAttr::TypeCursorOverrides => "type_cursor_overrides", + NativeAttr::UpdateSqlbuildSkills => "update_sqlbuild_skills", + NativeAttr::ValidateAuthoredSqlTestCtes => "validate_authored_sql_test_ctes", + NativeAttr::ValidateCliWarehouse => "validate_cli_warehouse", + NativeAttr::ValidateCompileDbtModelNames => "validate_compile_dbt_model_names", + NativeAttr::ValidateCompileDbtModelReference => "validate_compile_dbt_model_reference", + NativeAttr::ValidateDbtInitProject => "validate_dbt_init_project", + NativeAttr::ValidatePreviewTarget => "validate_preview_target", + NativeAttr::ValidateSourceCursorInputColumns => "validate_source_cursor_input_columns", + NativeAttr::WithBindingDiagnostics => "with_binding_diagnostics", + NativeAttr::WithTypeRecovery => "with_type_recovery", + NativeAttr::WriteAtomically => "write_atomically", + NativeAttr::WriteCheckResults => "write_check_results", + NativeAttr::WriteCompileTarget => "write_compile_target", + NativeAttr::WriteCostRun => "write_cost_run", + NativeAttr::WriteDbtExecutionPlanText => "write_dbt_execution_plan_text", + NativeAttr::WriteDbtExecutionSummary => "write_dbt_execution_summary", + NativeAttr::WriteExecutionHeader => "write_execution_header", + NativeAttr::WriteExecutionJsonOutput => "write_execution_json_output", + NativeAttr::WriteRuntimeTarget => "write_runtime_target", + NativeAttr::WriteSourceFreshnessRecords => "write_source_freshness_records", + NativeAttr::WriteSqlbuildSkipNotice => "write_sqlbuild_skip_notice", + } +} + +impl RecordId { + /// The record registered under `name`, for class names a pure-Rust crate chose. + pub fn from_name(name: &str) -> Option { + Self::ALL.iter().copied().find(|id| id.name() == name) + } +} diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/mod.rs similarity index 74% rename from crates/sqlbuild-python/src/bindings/_helpers/records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/mod.rs index dc9157842..8523ec5fc 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/mod.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/mod.rs @@ -1,11 +1,8 @@ pub(crate) mod behaviours; -pub(crate) mod constants; pub(crate) mod construct; pub(crate) mod error_classes; pub(crate) mod fields; pub(crate) mod getters; pub(crate) mod ids; -pub(crate) mod models; pub(crate) mod registration; pub(crate) mod registry; -pub(crate) mod types; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/registration.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/registration.rs similarity index 78% rename from crates/sqlbuild-python/src/bindings/_helpers/records/registration.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/registration.rs index dd8b3acb3..5493a9876 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/registration.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/registration.rs @@ -4,63 +4,33 @@ use pyo3::exceptions::{PyException, PyValueError}; use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods, PyString, PyTuple}; -use crate::bindings::_helpers::records::constants::{ +use crate::records::_helpers::native_classes::error_classes::{ + BoundErrorInitializer, ErrorInitializer, class_value, +}; +use crate::records::constants::{ BUILTIN_PARENT_PREFIX, BUILTINS_MODULE, DATACLASS_FIELD_KIND, DATACLASS_FIELDS_ATTRIBUTE, DATACLASSES_MODULE, ENUM_MODULE, ENUMS, ERROR_SPEC_ATTRIBUTE, ERRORS, EXCEPTION_PARENT, NATIVE_MODULE, RECORD_SPEC_ATTRIBUTE, STR_ENUM, VALUE_ERROR_PARENT, }; -use crate::bindings::_helpers::records::error_classes::{ - BoundErrorInitializer, ErrorInitializer, class_value, -}; use std::collections::HashMap; -use crate::bindings::_helpers::record_behaviours::constants::RECORD_BEHAVIOURS; -use crate::bindings::_helpers::records::behaviours::{self, behaviours}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::{all_specs, register_specs}; -use crate::bindings::_helpers::records::getters; -use crate::bindings::_helpers::records::models::GetterEntry; -use crate::bindings::_helpers::records::models::{ +use crate::records::_helpers::native_classes::behaviours::{self, behaviours}; +use crate::records::_helpers::native_classes::fields::field as native_field; +use crate::records::_helpers::native_classes::fields::{all_specs, register_specs}; +use crate::records::_helpers::native_classes::getters; +use crate::records::models::{ BoundNativeMethod, EnumSpec, ErrorSpec, NativeMethod, NativeProperty, NativeRecord, RecordAttribute, RecordSpec, }; -use crate::bindings::_helpers::{ - analysis, analysis_session, build_progress, compile_command, compile_context, compiled_views, - compute_logs, dbt_events, dbt_interop, diagnostics, discovery, event_exporting, - execution_history, graph, model_config, planner_entries, planner_migrations, planner_phases, - presentation_text, project_assembly, result_output, rules, scopes, -}; - -/// The getter tables of every module that defines native pyclasses. -static GETTER_TABLES: &[&[GetterEntry]] = &[ - analysis::getters::GETTERS, - analysis_session::getters::GETTERS, - build_progress::getters::GETTERS, - compile_command::getters::GETTERS, - compile_context::getters::GETTERS, - compiled_views::getters::GETTERS, - compute_logs::getters::GETTERS, - dbt_events::getters::GETTERS, - dbt_interop::getters::GETTERS, - diagnostics::getters::GETTERS, - discovery::getters::GETTERS, - event_exporting::getters::GETTERS, - execution_history::getters::GETTERS, - graph::getters::GETTERS, - model_config::getters::GETTERS, - planner_entries::getters::GETTERS, - planner_migrations::getters::GETTERS, - planner_phases::getters::GETTERS, - presentation_text::getters::GETTERS, - project_assembly::getters::GETTERS, - result_output::getters::GETTERS, - rules::getters::GETTERS, - scopes::getters::GETTERS, -]; +use crate::records::models::{GetterEntry, RecordBehaviours}; -pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> { - getters::install(GETTER_TABLES); - behaviours::install(&RECORD_BEHAVIOURS); +pub(crate) fn register( + module: &Bound<'_, PyModule>, + getter_tables: &'static [&'static [GetterEntry]], + record_behaviours: &'static RecordBehaviours, +) -> PyResult<()> { + getters::install(getter_tables); + behaviours::install(record_behaviours); let py: Python<'_> = module.py(); module.add_class::()?; module.add_class::()?; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/registry.rs b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/registry.rs similarity index 94% rename from crates/sqlbuild-python/src/bindings/_helpers/records/registry.rs rename to crates/sqlbuild-python-base/src/records/_helpers/native_classes/registry.rs index a1e1e5dbc..deffaed90 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/registry.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/native_classes/registry.rs @@ -7,9 +7,9 @@ use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyModule, PyResult, Python}; use pyo3::sync::PyOnceLock; use pyo3::types::PyString; -use crate::bindings::_helpers::records::constants::{ENUMS, ERRORS, NATIVE_MODULE}; -use crate::bindings::_helpers::records::fields::all_specs; -use crate::bindings::_helpers::records::ids::{ErrorId, NativeAttr, RecordId}; +use crate::records::_helpers::native_classes::fields::all_specs; +use crate::records::constants::{ENUMS, ERRORS, NATIVE_MODULE}; +use crate::records::types::{ErrorId, NativeAttr, RecordId}; /// The extension module, imported once for attribute lookups. static MODULE: PyOnceLock> = PyOnceLock::new(); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/planner_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/planner_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/planner_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/planner_records/constants.rs index e9df69b09..76c6261f5 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/planner_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/planner_records/constants.rs @@ -2,9 +2,9 @@ use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::planner_records::defaults::forward_only_backfill; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{EnumSpec, FieldDefault, FieldSpec, RecordSpec}; +use crate::records::_helpers::planner_records::defaults::forward_only_backfill; +use crate::records::models::{EnumSpec, FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_PARSED_SELECTOR: RecordSpec = RecordSpec { name: "ParsedSelector", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/planner_records/defaults.rs b/crates/sqlbuild-python-base/src/records/_helpers/planner_records/defaults.rs similarity index 80% rename from crates/sqlbuild-python/src/bindings/_helpers/planner_records/defaults.rs rename to crates/sqlbuild-python-base/src/records/_helpers/planner_records/defaults.rs index da81e05b9..be73aa10d 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/planner_records/defaults.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/planner_records/defaults.rs @@ -3,8 +3,8 @@ use pyo3::prelude::{Bound, PyAny, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods}; -use crate::bindings::_helpers::records::construct::{enum_member, new_record}; -use crate::bindings::_helpers::records::ids::RecordId; +use crate::records::_helpers::native_classes::construct::{enum_member, new_record}; +use crate::records::types::RecordId; /// `ModelPlanEntry.backfill`'s default: a forward-only backfill. pub(crate) fn forward_only_backfill(py: Python<'_>) -> PyResult> { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/planner_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/planner_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/planner_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/planner_records/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/rule_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/rule_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/rule_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/rule_records/constants.rs index e41a21ad3..b0856b5a5 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/rule_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/rule_records/constants.rs @@ -1,7 +1,7 @@ //! Layouts of the rule engine value records hosted natively. -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_RULE_GUIDANCE: RecordSpec = RecordSpec { name: "RuleGuidance", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/rule_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/rule_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/rule_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/rule_records/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/scope_records/constants.rs b/crates/sqlbuild-python-base/src/records/_helpers/scope_records/constants.rs similarity index 99% rename from crates/sqlbuild-python/src/bindings/_helpers/scope_records/constants.rs rename to crates/sqlbuild-python-base/src/records/_helpers/scope_records/constants.rs index 103028b1f..154d8cd97 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/scope_records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/_helpers/scope_records/constants.rs @@ -1,7 +1,7 @@ //! Layouts of the declaration scope value records hosted natively. -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::models::{FieldDefault, FieldSpec, RecordSpec}; +use crate::records::types::RecordId; const R_RESOURCE_IDENTITY: RecordSpec = RecordSpec { name: "ResourceIdentity", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/scope_records/mod.rs b/crates/sqlbuild-python-base/src/records/_helpers/scope_records/mod.rs similarity index 100% rename from crates/sqlbuild-python/src/bindings/_helpers/scope_records/mod.rs rename to crates/sqlbuild-python-base/src/records/_helpers/scope_records/mod.rs diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/constants.rs b/crates/sqlbuild-python-base/src/records/constants.rs similarity index 98% rename from crates/sqlbuild-python/src/bindings/_helpers/records/constants.rs rename to crates/sqlbuild-python-base/src/records/constants.rs index 8647dd03c..402dde419 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/constants.rs +++ b/crates/sqlbuild-python-base/src/records/constants.rs @@ -2,20 +2,20 @@ use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::compile_records::constants::COMPILE_VALUE_RECORDS; -use crate::bindings::_helpers::compiler_enums::constants::COMPILER_ENUMS; -use crate::bindings::_helpers::compiler_errors::constants::COMPILER_ERRORS; -use crate::bindings::_helpers::compiler_records::constants::COMPILER_RECORDS; -use crate::bindings::_helpers::contract_records::constants::CONTRACT_RECORDS; -use crate::bindings::_helpers::planner_records::constants::{ +use crate::records::_helpers::compile_records::constants::COMPILE_VALUE_RECORDS; +use crate::records::_helpers::compiler_enums::constants::COMPILER_ENUMS; +use crate::records::_helpers::compiler_errors::constants::COMPILER_ERRORS; +use crate::records::_helpers::compiler_records::constants::COMPILER_RECORDS; +use crate::records::_helpers::contract_records::constants::CONTRACT_RECORDS; +use crate::records::_helpers::planner_records::constants::{ PLANNER_ENUMS, PLANNER_RECORDS, PLANNER_VALUE_RECORDS, }; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::models::{ +use crate::records::_helpers::rule_records::constants::RULE_RECORDS; +use crate::records::_helpers::scope_records::constants::SCOPE_RECORDS; +use crate::records::models::{ ClassValue, EnumSpec, ErrorSpec, FieldDefault, FieldSpec, RecordBehaviours, RecordSpec, }; -use crate::bindings::_helpers::rule_records::constants::RULE_RECORDS; -use crate::bindings::_helpers::scope_records::constants::SCOPE_RECORDS; +use crate::records::types::RecordId; pub(crate) const NATIVE_MODULE: &str = "sqlbuild._native"; /// The class attribute holding a record class's index into `RECORDS`. @@ -184,8 +184,8 @@ pub(crate) const NO_RECORD_BEHAVIOURS: RecordBehaviours = RecordBehaviours { sequences: &[], }; /// `SourceFreshnessObservation` field positions. -pub(crate) const DATA_VERSION_FIELD: usize = 2; -pub(crate) const OBSERVED_AT_FIELD: usize = 4; +pub const DATA_VERSION_FIELD: usize = 2; +pub const OBSERVED_AT_FIELD: usize = 4; const NESTED_PROGRESS_CHILD_ROW: RecordSpec = RecordSpec { name: "NestedProgressChildRow", diff --git a/crates/sqlbuild-python-base/src/records/main/construct/enum_from_value.rs b/crates/sqlbuild-python-base/src/records/main/construct/enum_from_value.rs new file mode 100644 index 000000000..916beb005 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/enum_from_value.rs @@ -0,0 +1,19 @@ +//! The member of the native string enum `id` whose value is `value`, as `Enum(value)` finds it. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::RecordId; +use pyo3::IntoPyObject; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// The member of the native string enum `id` whose value is `value`, as `Enum(value)` finds it. +#[inline] +pub fn enum_from_value<'py, V: IntoPyObject<'py>>( + py: Python<'py>, + id: RecordId, + value: V, +) -> PyResult> { + construct::enum_from_value(py, id, value) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/enum_member.rs b/crates/sqlbuild-python-base/src/records/main/construct/enum_member.rs new file mode 100644 index 000000000..a549c4481 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/enum_member.rs @@ -0,0 +1,14 @@ +//! The member `name` of the native string enum `id`, looked up rather than constructed. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::RecordId; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// The member `name` of the native string enum `id`, looked up rather than constructed. +#[inline] +pub fn enum_member<'py>(py: Python<'py>, id: RecordId, name: &str) -> PyResult> { + construct::enum_member(py, id, name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/error_class.rs b/crates/sqlbuild-python-base/src/records/main/construct/error_class.rs new file mode 100644 index 000000000..a78b511db --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/error_class.rs @@ -0,0 +1,14 @@ +//! The native error class `id` as registered, ignoring later attribute replacement. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::ErrorId; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// The native error class `id` as registered, ignoring later attribute replacement. +#[inline] +pub fn error_class(py: Python<'_>, id: ErrorId) -> PyResult> { + construct::error_class(py, id) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/mod.rs b/crates/sqlbuild-python-base/src/records/main/construct/mod.rs new file mode 100644 index 000000000..5f66c8f2a --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/mod.rs @@ -0,0 +1,9 @@ +pub mod enum_from_value; +pub mod enum_member; +pub mod error_class; +pub mod new_annotated_error; +pub mod new_error; +pub mod new_helped_error; +pub mod new_record; +pub mod new_record_with; +pub mod record_class; diff --git a/crates/sqlbuild-python-base/src/records/main/construct/new_annotated_error.rs b/crates/sqlbuild-python-base/src/records/main/construct/new_annotated_error.rs new file mode 100644 index 000000000..38f2928b3 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/new_annotated_error.rs @@ -0,0 +1,17 @@ +//! A raisable native `id` error carrying `message`, with each `(name, value)` attribute set on it. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::ErrorId; +use pyo3::prelude::PyErr; +use pyo3::prelude::Python; + +/// A raisable native `id` error carrying `message`, with each `(name, value)` attribute set on it. +#[inline] +pub fn new_annotated_error( + py: Python<'_>, + id: ErrorId, + message: String, + attributes: &[(&str, String)], +) -> PyErr { + construct::new_annotated_error(py, id, message, attributes) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/new_error.rs b/crates/sqlbuild-python-base/src/records/main/construct/new_error.rs new file mode 100644 index 000000000..e78f77f5e --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/new_error.rs @@ -0,0 +1,12 @@ +//! A raisable native `id` error carrying `message` and the diagnostic `code`. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::ErrorId; +use pyo3::prelude::PyErr; +use pyo3::prelude::Python; + +/// A raisable native `id` error carrying `message` and the diagnostic `code`. +#[inline] +pub fn new_error(py: Python<'_>, id: ErrorId, message: String, code: &str) -> PyErr { + construct::new_error(py, id, message, code) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/new_helped_error.rs b/crates/sqlbuild-python-base/src/records/main/construct/new_helped_error.rs new file mode 100644 index 000000000..552f712c7 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/new_helped_error.rs @@ -0,0 +1,17 @@ +//! A raisable native `id` error carrying `message`, the diagnostic `code` and optional `help`. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::ErrorId; +use pyo3::prelude::PyErr; +use pyo3::prelude::Python; + +/// A raisable native `id` error carrying `message`, the diagnostic `code` and optional `help`. +#[inline] +pub fn new_helped_error( + py: Python<'_>, + id: ErrorId, + (message, code): (String, &str), + help: Option<&str>, +) -> PyErr { + construct::new_helped_error(py, id, (message, code), help) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/new_record.rs b/crates/sqlbuild-python-base/src/records/main/construct/new_record.rs new file mode 100644 index 000000000..5bca3db32 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/new_record.rs @@ -0,0 +1,21 @@ +//! A new `id` record built exactly as calling its class builds it, finishers included. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::RecordId; +use pyo3::call::PyCallArgs; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; +use pyo3::types::PyDict; + +/// A new `id` record built exactly as calling its class builds it, finishers included. +#[inline] +pub fn new_record<'py, A: PyCallArgs<'py>>( + py: Python<'py>, + id: RecordId, + args: A, + kwargs: Option<&Bound<'py, PyDict>>, +) -> PyResult> { + construct::new_record(py, id, args, kwargs) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/new_record_with.rs b/crates/sqlbuild-python-base/src/records/main/construct/new_record_with.rs new file mode 100644 index 000000000..7eed23fe8 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/new_record_with.rs @@ -0,0 +1,18 @@ +//! A new `id` record built from `(field, value)` keyword pairs. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::RecordId; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// A new `id` record built from `(field, value)` keyword pairs. +#[inline] +pub fn new_record_with<'py>( + py: Python<'py>, + id: RecordId, + pairs: &[(&str, Bound<'py, PyAny>)], +) -> PyResult> { + construct::new_record_with(py, id, pairs) +} diff --git a/crates/sqlbuild-python-base/src/records/main/construct/record_class.rs b/crates/sqlbuild-python-base/src/records/main/construct/record_class.rs new file mode 100644 index 000000000..2de2a4ef8 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/construct/record_class.rs @@ -0,0 +1,14 @@ +//! The native record class or string enum `id` as registered, ignoring later attribute replacement. + +use crate::records::_helpers::native_classes::construct; +use crate::records::types::RecordId; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// The native record class or string enum `id` as registered, ignoring later attribute replacement. +#[inline] +pub fn record_class(py: Python<'_>, id: RecordId) -> PyResult> { + construct::record_class(py, id) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/all_specs.rs b/crates/sqlbuild-python-base/src/records/main/fields/all_specs.rs new file mode 100644 index 000000000..6272213e2 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/all_specs.rs @@ -0,0 +1,10 @@ +//! Every registered record spec, in registration order. + +use crate::records::_helpers::native_classes::fields; +use crate::records::models::RecordSpec; + +/// Every registered record spec, in registration order. +#[inline] +pub fn all_specs() -> impl Iterator { + fields::all_specs() +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/by_attribute.rs b/crates/sqlbuild-python-base/src/records/main/fields/by_attribute.rs new file mode 100644 index 000000000..7a98c4e24 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/by_attribute.rs @@ -0,0 +1,16 @@ +//! `{item.: item for item in items}`. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::types::PyDict; + +/// `{item.: item for item in items}`. +#[inline] +pub fn by_attribute<'py>( + items: &Bound<'py, PyAny>, + attribute: &str, +) -> PyResult> { + fields::by_attribute(items, attribute) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/cached_value.rs b/crates/sqlbuild-python-base/src/records/main/fields/cached_value.rs new file mode 100644 index 000000000..42d096274 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/cached_value.rs @@ -0,0 +1,14 @@ +//! The cached value of `name` on `record`, if computed before. + +use crate::records::_helpers::native_classes::fields; +use crate::records::models::NativeRecord; +use pyo3::prelude::Bound; +use pyo3::prelude::Py; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// The cached value of `name` on `record`, if computed before. +#[inline] +pub fn cached_value(record: &Bound<'_, NativeRecord>, name: &str) -> PyResult>> { + fields::cached_value(record, name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/enum_member_value.rs b/crates/sqlbuild-python-base/src/records/main/fields/enum_member_value.rs new file mode 100644 index 000000000..5f58887ea --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/enum_member_value.rs @@ -0,0 +1,9 @@ +//! The value of the native string enum `enum_name`'s member `member`. + +use crate::records::_helpers::native_classes::fields; + +/// The value of the native string enum `enum_name`'s member `member`. +#[inline] +pub fn enum_member_value(enum_name: &str, member: &str) -> Option<&'static str> { + fields::enum_member_value(enum_name, member) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/field.rs b/crates/sqlbuild-python-base/src/records/main/fields/field.rs new file mode 100644 index 000000000..9d1db7bbb --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/field.rs @@ -0,0 +1,13 @@ +//! A declared field of a native record read from its values; any other attribute, or object, by `getattr`. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// A declared field of a native record read from its values; any other attribute, or object, by `getattr`. +#[inline] +#[track_caller] +pub fn field<'py>(value: &Bound<'py, PyAny>, name: &str) -> PyResult> { + fields::field(value, name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/field_text.rs b/crates/sqlbuild-python-base/src/records/main/fields/field_text.rs new file mode 100644 index 000000000..e69c47ed6 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/field_text.rs @@ -0,0 +1,12 @@ +//! The text of a record's string field `name`. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// The text of a record's string field `name`. +#[inline] +pub fn field_text(value: &Bound<'_, PyAny>, name: &str) -> PyResult { + fields::field_text(value, name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/mapping_get.rs b/crates/sqlbuild-python-base/src/records/main/fields/mapping_get.rs new file mode 100644 index 000000000..b0db1266e --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/mapping_get.rs @@ -0,0 +1,15 @@ +//! `mapping.get(key)`: a dict is read through the C API. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `mapping.get(key)`: a dict is read through the C API. +#[inline] +pub fn mapping_get<'py, K: pyo3::IntoPyObject<'py>>( + mapping: &Bound<'py, PyAny>, + key: K, +) -> PyResult> { + fields::mapping_get(mapping, key) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/mapping_get_or.rs b/crates/sqlbuild-python-base/src/records/main/fields/mapping_get_or.rs new file mode 100644 index 000000000..1079f4faf --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/mapping_get_or.rs @@ -0,0 +1,16 @@ +//! `mapping.get(key, default)`: a dict is read through the C API. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `mapping.get(key, default)`: a dict is read through the C API. +#[inline] +pub fn mapping_get_or<'py, K: pyo3::IntoPyObject<'py>, D: pyo3::IntoPyObject<'py>>( + mapping: &Bound<'py, PyAny>, + key: K, + default: D, +) -> PyResult> { + fields::mapping_get_or(mapping, key, default) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/mapping_items.rs b/crates/sqlbuild-python-base/src/records/main/fields/mapping_items.rs new file mode 100644 index 000000000..4755b3587 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/mapping_items.rs @@ -0,0 +1,12 @@ +//! `mapping.items()` for iteration: a dict yields its `(key, value)` pairs through the C API. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `mapping.items()` for iteration: a dict yields its `(key, value)` pairs through the C API. +#[inline] +pub fn mapping_items<'py>(mapping: &Bound<'py, PyAny>) -> PyResult> { + fields::mapping_items(mapping) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/mapping_values.rs b/crates/sqlbuild-python-base/src/records/main/fields/mapping_values.rs new file mode 100644 index 000000000..9ff82930c --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/mapping_values.rs @@ -0,0 +1,12 @@ +//! `mapping.values()` for iteration: a dict yields its values through the C API. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `mapping.values()` for iteration: a dict yields its values through the C API. +#[inline] +pub fn mapping_values<'py>(mapping: &Bound<'py, PyAny>) -> PyResult> { + fields::mapping_values(mapping) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/mod.rs b/crates/sqlbuild-python-base/src/records/main/fields/mod.rs new file mode 100644 index 000000000..aa98e4b66 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/mod.rs @@ -0,0 +1,18 @@ +pub mod all_specs; +pub mod by_attribute; +pub mod cached_value; +pub mod enum_member_value; +pub mod field; +pub mod field_text; +pub mod mapping_get; +pub mod mapping_get_or; +pub mod mapping_items; +pub mod mapping_values; +pub mod path_posix; +pub mod path_posix_text; +pub mod path_stem; +pub mod record_attribute_opt; +pub mod record_spec; +pub mod replaced; +pub mod replaced_keywords; +pub mod store_cached; diff --git a/crates/sqlbuild-python-base/src/records/main/fields/path_posix.rs b/crates/sqlbuild-python-base/src/records/main/fields/path_posix.rs new file mode 100644 index 000000000..de2ad6275 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/path_posix.rs @@ -0,0 +1,12 @@ +//! `path.as_posix()` of a `pathlib` path, spelled natively from its text. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `path.as_posix()` of a `pathlib` path, spelled natively from its text. +#[inline] +pub fn path_posix(path: &Bound<'_, PyAny>) -> PyResult { + fields::path_posix(path) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/path_posix_text.rs b/crates/sqlbuild-python-base/src/records/main/fields/path_posix_text.rs new file mode 100644 index 000000000..61f525c89 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/path_posix_text.rs @@ -0,0 +1,12 @@ +//! `path.as_posix()` of a `pathlib` path, its text with the platform separator spelled `/`. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `path.as_posix()` of a `pathlib` path, its text with the platform separator spelled `/`. +#[inline] +pub fn path_posix_text(path: &Bound<'_, PyAny>) -> PyResult { + fields::path_posix_text(path) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/path_stem.rs b/crates/sqlbuild-python-base/src/records/main/fields/path_stem.rs new file mode 100644 index 000000000..c19b8b10e --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/path_stem.rs @@ -0,0 +1,12 @@ +//! `path.stem` of a `pathlib` path, spelled natively from its text. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `path.stem` of a `pathlib` path, spelled natively from its text. +#[inline] +pub fn path_stem(path: &Bound<'_, PyAny>) -> PyResult { + fields::path_stem(path) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/record_attribute_opt.rs b/crates/sqlbuild-python-base/src/records/main/fields/record_attribute_opt.rs new file mode 100644 index 000000000..9ea5f6933 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/record_attribute_opt.rs @@ -0,0 +1,15 @@ +//! `getattr(value, name, None)` of a native record, `None` when `value` is not one. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `getattr(value, name, None)` of a native record, `None` when `value` is not one. +#[inline] +pub fn record_attribute_opt<'py>( + value: &Bound<'py, PyAny>, + name: &str, +) -> Option>>> { + fields::record_attribute_opt(value, name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/record_spec.rs b/crates/sqlbuild-python-base/src/records/main/fields/record_spec.rs new file mode 100644 index 000000000..253c7b4c9 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/record_spec.rs @@ -0,0 +1,13 @@ +//! The spec registered for `cls`, read from its class attribute. + +use crate::records::_helpers::native_classes::fields; +use crate::records::models::RecordSpec; +use pyo3::prelude::Bound; +use pyo3::prelude::PyResult; +use pyo3::types::PyType; + +/// The spec registered for `cls`, read from its class attribute. +#[inline] +pub fn record_spec(cls: &Bound<'_, PyType>) -> PyResult<&'static RecordSpec> { + fields::record_spec(cls) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/replaced.rs b/crates/sqlbuild-python-base/src/records/main/fields/replaced.rs new file mode 100644 index 000000000..3c748ef5b --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/replaced.rs @@ -0,0 +1,15 @@ +//! `dataclasses.replace(value, **changes)`: a native record is rebuilt from its own values. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// `dataclasses.replace(value, **changes)`: a native record is rebuilt from its own values. +#[inline] +pub fn replaced<'py>( + value: &Bound<'py, PyAny>, + changes: &[(&str, Bound<'py, PyAny>)], +) -> PyResult> { + fields::replaced(value, changes) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/replaced_keywords.rs b/crates/sqlbuild-python-base/src/records/main/fields/replaced_keywords.rs new file mode 100644 index 000000000..e2afd4734 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/replaced_keywords.rs @@ -0,0 +1,16 @@ +//! `dataclasses.replace(value, **keywords)`: a native record is rebuilt from its own values. + +use crate::records::_helpers::native_classes::fields; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::types::PyDict; + +/// `dataclasses.replace(value, **keywords)`: a native record is rebuilt from its own values. +#[inline] +pub fn replaced_keywords<'py>( + value: &Bound<'py, PyAny>, + keywords: &Bound<'py, PyDict>, +) -> PyResult> { + fields::replaced_keywords(value, keywords) +} diff --git a/crates/sqlbuild-python-base/src/records/main/fields/store_cached.rs b/crates/sqlbuild-python-base/src/records/main/fields/store_cached.rs new file mode 100644 index 000000000..afd5d2ebc --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/fields/store_cached.rs @@ -0,0 +1,18 @@ +//! Keep `value` as the cached value of `name` on `record`. + +use crate::records::_helpers::native_classes::fields; +use crate::records::models::NativeRecord; +use pyo3::prelude::Bound; +use pyo3::prelude::Py; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; + +/// Keep `value` as the cached value of `name` on `record`. +#[inline] +pub fn store_cached( + record: &Bound<'_, NativeRecord>, + name: &'static str, + value: &Py, +) -> PyResult<()> { + fields::store_cached(record, name, value) +} diff --git a/crates/sqlbuild-python-base/src/records/main/mod.rs b/crates/sqlbuild-python-base/src/records/main/mod.rs new file mode 100644 index 000000000..f577160be --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/mod.rs @@ -0,0 +1,3 @@ +pub mod construct; +pub mod fields; +pub mod registry; diff --git a/crates/sqlbuild-python-base/src/records/main/registry/capture.rs b/crates/sqlbuild-python-base/src/records/main/registry/capture.rs new file mode 100644 index 000000000..633b51f86 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/capture.rs @@ -0,0 +1,12 @@ +//! Hold every registered record class, string enum and error class, read once while the module initialises. + +use crate::records::_helpers::native_classes::construct; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// Hold every registered record class, string enum and error class, read once while the module initialises. +#[inline] +pub fn capture(module: &Bound<'_, PyModule>) -> PyResult<()> { + construct::capture(module) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/class_of.rs b/crates/sqlbuild-python-base/src/records/main/registry/class_of.rs new file mode 100644 index 000000000..e63d7ab5b --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/class_of.rs @@ -0,0 +1,13 @@ +//! The type object of the native pyclass `T`, as a getter table entry names it. + +use crate::records::_helpers::native_classes::getters; +use pyo3::PyTypeInfo; +use pyo3::prelude::Bound; +use pyo3::prelude::Python; +use pyo3::types::PyType; + +/// The type object of the native pyclass `T`, as a getter table entry names it. +#[inline] +pub fn class_of<'py, T: PyTypeInfo>(py: Python<'py>) -> Bound<'py, PyType> { + getters::class_of::(py) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/mod.rs b/crates/sqlbuild-python-base/src/records/main/registry/mod.rs new file mode 100644 index 000000000..67f2435bd --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/mod.rs @@ -0,0 +1,7 @@ +pub mod capture; +pub mod class_of; +pub mod native_attr; +pub mod record_named; +pub mod register_records; +pub mod verify_attributes; +pub mod verify_tables; diff --git a/crates/sqlbuild-python-base/src/records/main/registry/native_attr.rs b/crates/sqlbuild-python-base/src/records/main/registry/native_attr.rs new file mode 100644 index 000000000..16122ec91 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/native_attr.rs @@ -0,0 +1,14 @@ +//! The module attribute `id`, read now so a replaced attribute is seen. + +use crate::records::_helpers::native_classes::registry; +use crate::records::types::NativeAttr; +use pyo3::prelude::Bound; +use pyo3::prelude::PyAny; +use pyo3::prelude::PyResult; +use pyo3::prelude::Python; + +/// The module attribute `id`, read now so a replaced attribute is seen. +#[inline] +pub fn native_attr(py: Python<'_>, id: NativeAttr) -> PyResult> { + registry::native(py, id) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/record_named.rs b/crates/sqlbuild-python-base/src/records/main/registry/record_named.rs new file mode 100644 index 000000000..9134a1574 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/record_named.rs @@ -0,0 +1,11 @@ +//! The native record class or string enum a pure-Rust crate names, failing as `getattr` would. + +use crate::records::_helpers::native_classes::registry; +use crate::records::types::RecordId; +use pyo3::prelude::PyResult; + +/// The native record class or string enum a pure-Rust crate names, failing as `getattr` would. +#[inline] +pub fn record_named(name: &str) -> PyResult { + registry::record_named(name) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/register_records.rs b/crates/sqlbuild-python-base/src/records/main/registry/register_records.rs new file mode 100644 index 000000000..5e708cc59 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/register_records.rs @@ -0,0 +1,18 @@ +//! Register records. + +use crate::records::_helpers::native_classes::registration; +use crate::records::models::GetterEntry; +use crate::records::models::RecordBehaviours; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// register_records. +#[inline] +pub fn register_records( + module: &Bound<'_, PyModule>, + getter_tables: &'static [&'static [GetterEntry]], + record_behaviours: &'static RecordBehaviours, +) -> PyResult<()> { + registration::register(module, getter_tables, record_behaviours) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/verify_attributes.rs b/crates/sqlbuild-python-base/src/records/main/registry/verify_attributes.rs new file mode 100644 index 000000000..b8e317a55 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/verify_attributes.rs @@ -0,0 +1,12 @@ +//! Fail module init when a `NativeAttr` names an attribute the finished module lacks. + +use crate::records::_helpers::native_classes::registry; +use pyo3::prelude::Bound; +use pyo3::prelude::PyModule; +use pyo3::prelude::PyResult; + +/// Fail module init when a `NativeAttr` names an attribute the finished module lacks. +#[inline] +pub fn verify_attributes(module: &Bound<'_, PyModule>) -> PyResult<()> { + registry::verify_attributes(module) +} diff --git a/crates/sqlbuild-python-base/src/records/main/registry/verify_tables.rs b/crates/sqlbuild-python-base/src/records/main/registry/verify_tables.rs new file mode 100644 index 000000000..53e188c52 --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/main/registry/verify_tables.rs @@ -0,0 +1,10 @@ +//! Fail module init when the typed names and the registration tables disagree. + +use crate::records::_helpers::native_classes::registry; +use pyo3::prelude::PyResult; + +/// Fail module init when the typed names and the registration tables disagree. +#[inline] +pub fn verify_tables() -> PyResult<()> { + registry::verify_tables() +} diff --git a/crates/sqlbuild-python-base/src/records/mod.rs b/crates/sqlbuild-python-base/src/records/mod.rs new file mode 100644 index 000000000..bdb1e773f --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/mod.rs @@ -0,0 +1,7 @@ +//! Native record, enum and error classes: their specs, registration, construction and field reads. + +pub(crate) mod _helpers; +pub mod constants; +pub mod main; +pub mod models; +pub mod types; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/records/models.rs b/crates/sqlbuild-python-base/src/records/models.rs similarity index 79% rename from crates/sqlbuild-python/src/bindings/_helpers/records/models.rs rename to crates/sqlbuild-python-base/src/records/models.rs index 5006a0fdd..97d1f757a 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/records/models.rs +++ b/crates/sqlbuild-python-base/src/records/models.rs @@ -9,18 +9,18 @@ use pyo3::types::{PyDict, PyTuple, PyType}; use pyo3::{IntoPyObjectExt, pyclass, pymethods}; use sqlbuild_host::entries::models::HostId; -use crate::bindings::_helpers::records::fields::{ +use crate::records::_helpers::native_classes::fields::{ build_values, cached_value, compared_values, frozen_error, ordered_comparison, record_spec, repr_text, store_cached, }; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::_helpers::records::types::{ +use crate::records::types::RecordId; +use crate::records::types::{ ClassMethod, ClassProperty, GetterClass, GetterRead, RecordFactory, RecordFinish, }; /// How a record field is filled when the caller does not pass it. #[derive(Debug, Clone, Copy)] -pub(crate) enum FieldDefault { +pub enum FieldDefault { Required, None, False, @@ -50,61 +50,61 @@ pub(crate) enum FieldDefault { /// One record field: its name, default, and whether it takes part in equality and in repr. #[derive(Debug, Clone, Copy)] -pub(crate) struct FieldSpec { - pub(crate) name: &'static str, - pub(crate) default: FieldDefault, - pub(crate) compared: bool, - pub(crate) shown: bool, +pub struct FieldSpec { + pub name: &'static str, + pub default: FieldDefault, + pub compared: bool, + pub shown: bool, } /// The layout of one native record class. #[derive(Debug, Clone, Copy)] -pub(crate) struct RecordSpec { - pub(crate) name: &'static str, - pub(crate) doc: &'static str, - pub(crate) fields: &'static [FieldSpec], +pub struct RecordSpec { + pub name: &'static str, + pub doc: &'static str, + pub fields: &'static [FieldSpec], } /// The members of one native string enum, in declaration order. #[derive(Debug, Clone, Copy)] -pub(crate) struct EnumSpec { - pub(crate) name: &'static str, - pub(crate) doc: &'static str, - pub(crate) members: &'static [(&'static str, &'static str)], +pub struct EnumSpec { + pub name: &'static str, + pub doc: &'static str, + pub members: &'static [(&'static str, &'static str)], } /// A class-level constant of a native error class. #[derive(Debug, Clone, Copy)] -pub(crate) enum ClassValue { +pub enum ClassValue { Text(&'static str), Int(i64), } /// One native expected-error class: its parent, class constants and keyword fields. #[derive(Debug, Clone, Copy)] -pub(crate) struct ErrorSpec { - pub(crate) name: &'static str, +pub struct ErrorSpec { + pub name: &'static str, /// A native error base or an earlier error in `ERRORS`. - pub(crate) parent: &'static str, - pub(crate) doc: &'static str, - pub(crate) class_attributes: &'static [(&'static str, ClassValue)], + pub parent: &'static str, + pub doc: &'static str, + pub class_attributes: &'static [(&'static str, ClassValue)], /// Keyword-only constructor fields stored as attributes. - pub(crate) required: &'static [&'static str], + pub required: &'static [&'static str], /// Keyword-only constructor fields stored as attributes, `None` when not passed. - pub(crate) optional: &'static [&'static str], + pub optional: &'static [&'static str], /// Attributes every instance is given. - pub(crate) fixed: &'static [(&'static str, ClassValue)], + pub fixed: &'static [(&'static str, ClassValue)], } /// Base of every native frozen record, built, compared, shown and pickled as a dataclass. #[derive(Debug)] #[pyclass(module = "sqlbuild._native", subclass, frozen)] -pub(crate) struct NativeRecord { +pub struct NativeRecord { /// The layout of the record's class. - pub(crate) spec: &'static RecordSpec, - pub(crate) values: Vec>, + pub spec: &'static RecordSpec, + pub values: Vec>, /// Values of the record's cached computed attributes, by attribute name. - pub(crate) cached: Mutex)>>, + pub cached: Mutex)>>, } #[pymethods] @@ -171,11 +171,11 @@ impl NativeRecord { /// A computed attribute of a native class, evaluated by its native function. #[derive(Debug)] #[pyclass(module = "sqlbuild._native", frozen)] -pub(crate) struct NativeProperty { - pub(crate) property: ClassProperty, - pub(crate) name: &'static str, +pub struct NativeProperty { + pub property: ClassProperty, + pub name: &'static str, /// Whether a record computes the attribute once and keeps it. - pub(crate) cached: bool, + pub cached: bool, } #[pymethods] @@ -209,8 +209,8 @@ impl NativeProperty { /// A method of a native class, run by its native function. #[derive(Debug)] #[pyclass(module = "sqlbuild._native", frozen)] -pub(crate) struct NativeMethod { - pub(crate) method: ClassMethod, +pub struct NativeMethod { + pub method: ClassMethod, } #[pymethods] @@ -235,7 +235,7 @@ impl NativeMethod { /// A `NativeMethod` bound to the instance or class it was read from. #[derive(Debug)] #[pyclass(module = "sqlbuild._native", frozen)] -pub(crate) struct BoundNativeMethod { +pub struct BoundNativeMethod { method: ClassMethod, receiver: Py, } @@ -255,9 +255,9 @@ impl BoundNativeMethod { /// Read-only access to one field of a native record. #[derive(Debug)] #[pyclass(module = "sqlbuild._native", frozen)] -pub(crate) struct RecordAttribute { - pub(crate) index: usize, - pub(crate) name: &'static str, +pub struct RecordAttribute { + pub index: usize, + pub name: &'static str, } #[pymethods] @@ -292,12 +292,12 @@ impl RecordAttribute { impl FieldSpec { /// A field every caller must pass. - pub(crate) const fn required(name: &'static str) -> Self { + pub const fn required(name: &'static str) -> Self { Self::new(name, FieldDefault::Required) } /// A field filled from `default` when it is not passed. - pub(crate) const fn new(name: &'static str, default: FieldDefault) -> Self { + pub const fn new(name: &'static str, default: FieldDefault) -> Self { Self { name, default, @@ -307,7 +307,7 @@ impl FieldSpec { } /// A field left out of equality, hashing and repr. - pub(crate) const fn uncompared(name: &'static str, default: FieldDefault) -> Self { + pub const fn uncompared(name: &'static str, default: FieldDefault) -> Self { Self { name, default, @@ -319,25 +319,24 @@ impl FieldSpec { /// One native pyclass and the reader of its `#[getter]` attributes. #[derive(Clone, Copy, Debug)] -pub(crate) struct GetterEntry { - pub(crate) class: GetterClass, - pub(crate) read: GetterRead, +pub struct GetterEntry { + pub class: GetterClass, + pub read: GetterRead, } /// The record behaviours registration installs, each as groups searched in order. #[derive(Clone, Copy, Debug)] -pub(crate) struct RecordBehaviours { +pub struct RecordBehaviours { /// Records whose bound values are normalized or validated before the record is created. - pub(crate) finishers: &'static [&'static [(&'static str, RecordFinish)]], + pub finishers: &'static [&'static [(&'static str, RecordFinish)]], /// `(class, attribute, getter)` computed attributes set on native classes after registration. - pub(crate) properties: &'static [&'static [(&'static str, &'static str, ClassProperty)]], + pub properties: &'static [&'static [(&'static str, &'static str, ClassProperty)]], /// `(class, attribute, getter)` computed attributes a record computes once and keeps. - pub(crate) cached_properties: - &'static [&'static [(&'static str, &'static str, ClassProperty)]], + pub cached_properties: &'static [&'static [(&'static str, &'static str, ClassProperty)]], /// `(class, attribute, method)` methods set on native classes after registration. - pub(crate) methods: &'static [&'static [(&'static str, &'static str, ClassMethod)]], + pub methods: &'static [&'static [(&'static str, &'static str, ClassMethod)]], /// Records ordered by their compared fields, as `order=True` dataclasses are. - pub(crate) ordered: &'static [&'static [&'static str]], + pub ordered: &'static [&'static [&'static str]], /// Native records registered as `collections.abc.Sequence` virtual subclasses. - pub(crate) sequences: &'static [&'static [&'static str]], + pub sequences: &'static [&'static [&'static str]], } diff --git a/crates/sqlbuild-python-base/src/records/types.rs b/crates/sqlbuild-python-base/src/records/types.rs new file mode 100644 index 000000000..7d9043d0c --- /dev/null +++ b/crates/sqlbuild-python-base/src/records/types.rs @@ -0,0 +1,995 @@ +//! Hooks applied while building native records. + +use pyo3::prelude::{Bound, Py, PyAny, PyResult, Python}; +use pyo3::types::{PyDict, PyTuple, PyType}; + +/// Normalizes the bound field values of one record before it is created. +pub type RecordFinish = fn(Python<'_>, Vec>) -> PyResult>>; + +/// Computes one read-only attribute of a native class instance. +pub type ClassProperty = fn(&Bound<'_, PyAny>) -> PyResult>; + +/// Runs one method of a native class with its receiver (the instance, or the class when unbound). +pub type ClassMethod = + fn(&Bound<'_, PyAny>, &Bound<'_, PyTuple>, Option<&Bound<'_, PyDict>>) -> PyResult>; + +/// Builds the default value of one record field. +pub type RecordFactory = fn(Python<'_>) -> PyResult>; + +/// Reads one `#[getter]` of a native pyclass instance by name, or `None` when the class has no such getter. +pub type GetterRead = for<'py> fn(&Bound<'py, PyAny>, &str) -> Option>>; + +/// The type object of one native pyclass. +pub type GetterClass = for<'py> fn(Python<'py>) -> Bound<'py, PyType>; + +/// A native record class or string enum, registered from the record and enum specs. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum RecordId { + AdapterConnectionContext, + AdapterSourceFreshnessBatch, + AlignedInterval, + AnalysisCacheContext, + AttachedAuditGateEdge, + AuditCommandRequest, + AuditGateIdentity, + AuditIdentity, + AuditInvocation, + AuditPlanEntry, + AuthoredSqlSet, + AuthoredSqlValueCall, + AuthoredTimeTravelRetention, + BackfillAction, + BackfillResult, + BuildCommandRequest, + BuildCostFinalization, + BuildInvocation, + ChainStep, + ChangeDetectionResult, + ChangeKind, + CheckCommandRequest, + CheckInvocation, + CliCommand, + CliEntrypointHandlers, + CloneCommandRequest, + ClonePipelineConnection, + ClonePipelineOptions, + ClonePipelineResult, + ClonePolicy, + CloneSourcePlanEntry, + CollectionRendering, + ColumnLineage, + ColumnLineageConfidence, + ColumnLineageEdge, + ColumnLineageMode, + CompiledResourceType, + ColumnLineageSource, + ColumnMigrationDecision, + ColumnMigrationEvent, + ColumnMigrationPlanEntry, + ColumnRenameHint, + ColumnTransformKind, + CommandWarehouseScope, + CompactLineageFacts, + CompileAdapterContext, + CompileAnalysis, + CompileAnalysisSelection, + CompileCommandRequest, + CompileDirectLogicSqlTestInputPayload, + CompileFacts, + CompileLineageMode, + CompileModelConfig, + CompileModelInput, + CompileModelSqlTestInputPayload, + CompilePipelineOptions, + CompilePipelineResult, + CompileProfileFlags, + CompileProjectInputs, + CompileSqlReference, + CompileSqlScenarioCte, + CompileSqlScenarioInput, + CompileSqlTestCte, + CompileSqlTestInput, + CompiledAudit, + CompiledDirectLogicSqlTestPayload, + CompiledFunction, + CompiledLineageColumnFact, + CompiledLineageSourceFact, + CompiledModel, + CompiledModelSqlTestPayload, + CompiledObjectKey, + CompiledProject, + CompiledProjectPhaseResult, + CompiledRelationLocation, + CompiledSeed, + CompiledSource, + CompiledSqlExpansion, + CompiledSqlScenario, + CompiledSqlTest, + CompiledSqlTestResource, + CompilerDiagnostic, + CompilerStage, + CompletionState, + ConstantDeclaration, + ConstantMetadata, + ConstantsConfig, + ContractAdoptionResult, + ContractCommandRequest, + ContractEvidence, + ContractFinding, + ContractFindingKind, + ContractPolicy, + ContractValidationResult, + CostCommandRequest, + CostConfig, + CostRunRecord, + CursorBounds, + CursorGrain, + CursorInputEvidence, + CursorInputRelation, + CursorInputRoles, + CursorOverridePair, + CursorOverrides, + CursorSnapshotScope, + CursorType, + CursorWatermarkMode, + CursorsConfig, + CustomHostPartition, + CustomRuleEvaluation, + CustomRuleRun, + CustomRulesOutcome, + DateValue, + DbtCliConfigOverrides, + DbtCliOptions, + DbtCommandExecutionResult, + DbtCommandResult, + DbtConfig, + DbtInitCommandRequest, + DbtInitProgressCallbacks, + DbtInitRequest, + DbtInitResult, + DbtInteropCommand, + DbtInteropCommandArgs, + DbtInteropCompiledProject, + DbtInteropExecutionRequest, + DbtInteropInvocation, + DbtInteropParsedArgs, + DbtInteropPlan, + DbtInteropPlanResolution, + DbtInteropRoutedArgs, + DbtInteropSelectionResult, + DbtInteropSkipReason, + DbtLsNode, + DbtLsResult, + DbtManifestIndex, + DbtManifestModel, + DbtManifestSeed, + DbtManifestSource, + DbtNodeExecutionResult, + DbtNodeMessage, + DbtPlanEnvironment, + DbtSqlbuildPlanRequest, + DbtSqlbuildWorkContext, + DeclarationExpansionContext, + DeclarationExplanation, + DeclarationIdentity, + DeclarationKind, + DeclarationRecord, + DeclarationReport, + DeclarationResolutionContext, + DeclarationRuntimeProjection, + DeclarationScopeBuild, + DeclarationScopeResolver, + DeclarationVisibility, + DeclarationVisibilityIndex, + DefaultsConfig, + DeferralInputs, + DiagnosticPhase, + DiagnosticSeverity, + DiffCommandRequest, + DiffConfig, + DirectModelVersionIdentities, + DirectSemanticColumnUse, + DirectSourceFreshnessPlanningResult, + DirectSourceFreshnessPropagationResult, + DiscoveredAdapterFile, + DiscoveredAssetFunction, + DiscoveredAuditBlock, + DiscoveredAuditFactory, + DiscoveredAuditFile, + DiscoveredCheckFunction, + DiscoveredCommandOutputSink, + DiscoveredCommandOutputSinkDeclaration, + DiscoveredConstantFile, + DiscoveredEnumFile, + DiscoveredEventExporter, + DiscoveredEventExporterDeclaration, + DiscoveredHookFunction, + DiscoveredLoaderFunction, + DiscoveredMacroFile, + DiscoveredMaterializationFile, + DiscoveredModelSchemaFile, + DiscoveredProjectInputs, + DiscoveredProvider, + DiscoveredProviderUsage, + DiscoveredPythonAssetMetadata, + DiscoveredPythonCheckMetadata, + DiscoveredPythonFunctionFile, + DiscoveredPythonLoaderMetadata, + DiscoveredPythonNode, + DiscoveredPythonNodeFunctions, + DiscoveredPythonTaskMetadata, + DiscoveredRuntimeExtensions, + DiscoveredSchemaFile, + DiscoveredSeedFile, + DiscoveredSourceFile, + DiscoveredSqlFunctionFile, + DiscoveredSqlHookFile, + DiscoveredSqlScenarioFile, + DiscoveredSqlTestBlock, + DiscoveredSqlTestCase, + DiscoveredSqlTestFile, + DiscoveredTaskFunction, + DiscoveryFileFault, + DisplayOptions, + Duration, + DynamicColumnContractProof, + DynamicColumnFamilyProof, + EmptyCursorInputDecision, + EnumDeclaration, + EnumMember, + EnumMemberMetadata, + EnumMetadata, + EventExportSeverity, + ExecutionLimitsConfig, + ExpansionSpan, + Finding, + Fingerprint, + FingerprintSet, + FixVerdict, + FixtureColumnInference, + FreshnessCommandRequest, + FunctionArgument, + FunctionChangeResult, + FunctionPlanEntry, + FunctionReturnColumn, + FutureCursorAction, + FutureCursorSafetyEvidence, + FutureCursorsConfig, + GrantKind, + GrantRecord, + GraphEdgeExclusion, + GraphResourceKind, + HandBuiltAnalysis, + HardCodedRelationOwnerKind, + HeaderSpan, + HistoricalInput, + HookReadEdge, + HookReadType, + InaccessibleReason, + InaccessibleRecord, + IncrementalMode, + IncrementalStrategy, + InferredColumn, + InferredNullability, + InitialValidFrom, + IntegerValue, + IntegrationLoaderConfig, + InterpolationSite, + InvalidSqlReferenceCall, + JanitorCommandRequest, + JanitorConfig, + JanitorInvocation, + JanitorSettings, + LayoutConfig, + LifecycleEventSinkFilterConfig, + LifecycleEventSinksConfig, + LineageCommandRequest, + LineageGraphViews, + LintBody, + LintConfig, + LintEdit, + LintFileRole, + LintRunResult, + LintSeverity, + LintViolation, + LiteralSqlRelation, + LoadCommandRequest, + LoadedMacro, + LoaderConnectionMode, + LoaderDestinationParts, + LocalClonePolicy, + LocalConfig, + LocalDbtConfig, + LocalTargetConfig, + MacroContext, + MacroExpansionResult, + MacroMetadata, + ManualLocation, + MappedOffset, + MaterializationDefaultsConfig, + MaterializationRetentionDefaults, + MaterializationType, + MaximumStartPolicyInputs, + MaximumStartSafetyEvidence, + MeasurementContract, + MeasurementThresholdBound, + MeasurementThresholds, + MicrobatchLimitAction, + MicrobatchLimitsConfig, + MicrobatchStrategy, + MicrobatchesConfig, + MigrationCompatibility, + MigrationDecision, + MigrationDiscovery, + MigrationEvent, + MigrationPromotion, + MigrationRelation, + MigrationsConfig, + MissingMigrationOriginPolicy, + MissingUpstream, + Model, + ModelColumnLineage, + ModelCursorSnapshot, + ModelInputBuildContext, + ModelMigrationPlanEntry, + ModelPlanEntry, + ModelSchemaDeclaration, + ModelSql, + ModelSqlAnalysis, + ModelValidationRequest, + ModuleStateFingerprint, + ModuleStateTrace, + MovePreview, + NamedSqlHookEntry, + NativeColumnQuery, + NativeModelConfigInputs, + NativeModelConfigSession, + NativePivotTables, + NativeQueryColumns, + NativeRulesEvaluation, + NativeSqlTestArtifact, + NativeSqlTestAssembly, + NativeSqlTestFailure, + NativeSqlTestPlan, + NestedProgressChildRow, + NormalizedDbtProfileConnection, + OldNameView, + OldNameViewAction, + OldNameViewDropReason, + OldNameViewEvent, + OldNameViewEventType, + OldNameViewHistory, + OldNameViewPlanEntry, + OldNameViewStatus, + OnSchemaChange, + OwnershipRoot, + OwnershipRootKind, + ParsedCliInvocation, + ParsedScenarioArtifactName, + ParsedSelector, + PartialBuildPhaseTimings, + PathSelector, + PlanAction, + PlanCommandRequest, + PlanOutput, + PlanOutputExtras, + PlanProviderUsage, + PlanReason, + PlanSafetyGates, + PlanWarning, + PlannedSqlTests, + PlannerChangeResults, + PlannerOverrides, + PlannerPolicies, + PlannerResolvedActions, + PlannerScope, + PlannerSelection, + PlaygroundCommandRequest, + PlaygroundTemplate, + PolyglotAnalysisDialect, + PolyglotAnalysisResult, + Project, + ProjectConfig, + ProjectPath, + PythonHookEntry, + PythonIdentityDependency, + PythonIdentityStatus, + PythonNodeDependencyEdge, + PythonNodeGraph, + PythonNodeIdentity, + PythonPlanEntry, + PythonRunPhase, + PythonRunPlanOutputs, + PythonSqlReferenceReport, + PythonSqlRunLifecyclePlan, + PythonSqlRunSelection, + QualifiedLineageColumn, + QueryCostObservation, + QueryDiffPreparation, + QueryProjection, + QueryShape, + RefactorCommandRequest, + RefactorProject, + ReviewCommandRequest, + ReferenceRename, + ReferencesConfig, + RelatedLocation, + RelationFixtureCompletion, + RelationFixtureDiagnostic, + ResolvedDbtConfig, + ResolvedDbtProfileOutput, + ResolvedModelAction, + ResolvedTableType, + ResolvedTimeTravelRetention, + ResolvedWarehouse, + ResourceCost, + ResourceIdentity, + ResourceKind, + ResourceRecord, + RetentionDecreasePolicy, + RetentionDirection, + RetentionPlanEntry, + RetentionPlanPhase, + Rule, + RuleCase, + RuleExemption, + RuleFactViews, + RuleFile, + RuleFixResult, + RuleGuidance, + RuleIgnore, + RuleOption, + RuleResult, + RuleRunPlan, + RuleSubject, + RulesCacheConfig, + RulesCommandRequest, + RulesConfig, + RulesResult, + RulesRunResult, + ScenarioArtifactIdentity, + ScenarioArtifactKind, + ScenarioArtifactName, + ScenarioAssertionExpectationPlan, + ScenarioCaptureCommandRequest, + ScenarioConfig, + ScenarioExecutionPlan, + ScenarioExpectedExpectationPlan, + ScenarioFixturePlan, + ScenarioGraphPlan, + ScenarioRelationMap, + ScenarioRelationPlan, + ScenarioSnapshotLimitInputs, + ScenarioSnapshotLimitsConfig, + ScenarioTestCommandRequest, + SchemaAction, + SchemaActionKind, + SchemaAuditInstance, + SchemaChangeKind, + SchemaColumn, + SchemaColumnSource, + SchemaDynamicColumnFamily, + SchemaFinding, + SchemaModelEntry, + SchemaSeedEntry, + ScopeBrowseResult, + ScopeChainEntry, + ScopeCommandRequest, + ScopeCompleteness, + ScopeDiagnostic, + ScopeDiagnosticCode, + ScopeDiagnosticSeverity, + ScopeFolder, + ScopeIndex, + ScopeKind, + ScopeListResult, + ScopeLookup, + ScopeReport, + ScopeReportFilters, + ScopeResourceReport, + ScopeSection, + ScopeSourceLocation, + ScopeTargetQuery, + ScopesConfig, + SeedCommandRequest, + SeedCsvSettings, + SeedInvocation, + SeedPlanEntry, + SelectStarAllow, + SelectedDbtProfileOutput, + SelectionStalenessGraph, + SelectionStalenessNodeKey, + SelectionStalenessWarning, + SelectorExpansion, + SelectorFileSummary, + SelectorKind, + SettingsConfig, + SinksConfig, + SkillMaintenanceResult, + SkillUpdateResult, + SnapshotSchemaChangePolicy, + SnapshotStrategy, + SnapshotsConfig, + SourceColumnEntry, + SourceEntry, + SourceFreshnessAgePolicy, + SourceFreshnessAgeStatus, + SourceFreshnessConfig, + SourceFreshnessIdentity, + SourceFreshnessObservation, + SourceFreshnessRecord, + SourceFreshnessRenderers, + SourceFreshnessSet, + SourceFreshnessStrategy, + SourceFreshnessUnknown, + SourceFreshnessUnknownReason, + SourceFreshnessValueKind, + SourceLoadPlanEntry, + SourceLocation, + SourceWriteStrategy, + SqlBindingDiagnostic, + SqlBindingResult, + SqlExpansionContext, + SqlHookEntry, + SqlLexicalSyntax, + SqlLogicalType, + SqlNode, + SqlReferenceKind, + SqlReferenceScan, + SqlRulesEvaluation, + SqlSchemaValidationRequest, + SqlTestAssertionStep, + SqlTestParameterDeclaration, + SqlTestPlanEntry, + SqlTestPlanResult, + SqlTestRulesConfig, + SqlTestSelection, + SqlValue, + SqlValueKind, + SqlValueLimits, + StartCursorsConfig, + StateSqlValueType, + StatementLedgerEntry, + StaticCommandContext, + StaticMacroExport, + StaticMacroFault, + StaticMacroInventory, + TableType, + TableTypeDowngradePolicy, + TableTypePlanEntry, + TableTypeSource, + TargetConfig, + TargetDiffConfig, + TargetWarehousesConfig, + TestCommandRequest, + TestInvocation, + ThresholdOverride, + TimeTravelRetentionSource, + TimestampValue, + TolerantScopeDiscovery, + UnitTestSelectorSplit, + UsageKind, + UsageRecord, + VisibilityProvenance, + VisibilityReason, + VisibilityRecord, + VisibilityResolution, + VisibleModelDeclarations, + WarehouseFingerprints, + WarehouseGroup, + WarehouseSnapshot, + WarningSeverity, + WrittenTarget, +} + +/// A native error class, registered from the error specs; variants drop the `Error` suffix. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ErrorId { + CliUser, + CompileInput, + ConfigValueType, + ContractAdoption, + DbtInteropArgument, + DbtInteropConfig, + DbtInterop, + DbtInteropRuntime, + DeclarationParse, + DiffSizeGuard, + DiscoveryConflict, + Discovery, + EventExporterDiscovery, + FingerprintInput, + FutureCursorSafety, + HostCancelled, + InvalidQualifiedIdentity, + InvalidScopePath, + Lint, + LintStopped, + MacroArgument, + MaximumAutomaticStart, + MeasurementAudit, + MigrationState, + ModelSqlParse, + NativeLint, + NativeSqlTestPlanning, + NativeStageMismatch, + NonHermeticRule, + OpaqueModuleState, + PlannerInput, + OrchestrationDeclaration, + ProjectCompile, + ProjectConfig, + ProjectPath, + ProjectPythonPath, + ProviderDiscovery, + PythonNodeDiscovery, + QueryDiffExecution, + QueryDiffIncomplete, + QueryDiffOutcome, + QueryExecution, + QueryFingerprint, + RefactorIO, + RefactorValue, + ResourceIdentity, + ReviewFailed, + RuleAssertion, + RuleUsage, + RulesConfig, + Rules, + SchemaParse, + Scope, + ScopeValidation, + SeedDiscovery, + SourceParse, + SpecConfig, + SqlAuditParse, + SqlHookParse, + SqlScenarioParse, + SqlTestParse, + SqlTestReference, + StagedArtifactsChanged, + UnindexableScope, + UnknownLineageDialect, + UnsupportedLexicalSyntax, +} + +/// A native function, class or value native code reaches through the module. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum NativeAttr { + AnalyzeCompileProject, + ApplyCommandWarehouse, + ApplyMaximumStartPolicy, + ApplyTypedCursorReplayPolicy, + AssembleProject, + AttachChecks, + AttachResources, + AttachSqlbuildPlanOutput, + AuditProgressReporter, + BindingPositions, + BuildAuditCommandPlan, + BuildCompileDbtManifestIndex, + BuildCompileInputs, + BuildCursorInputRelations, + BuildDagJson, + BuildDbtCombinedGraph, + BuildDbtInitProject, + BuildDbtInitProjectToml, + BuildDeclarationScope, + BuildDeferredLocations, + BuildDirectSemanticUses, + BuildDisplayOnlySqlbuildPlan, + BuildEffectiveConnectionConfig, + BuildEffectiveRuntimeConfig, + BuildEffectiveSettingsConfig, + BuildEffectiveTargetConfig, + BuildEffectiveTargetNamespace, + BuildExecutionPlan, + BuildFailedSqlbuildModelNames, + BuildIdentity, + BuildIntermediateSourceMap, + BuildManifest, + BuildMergedDbtExecutionArgv, + BuildModelWarnings, + BuildPhaseTimingTracker, + BuildPlannerRelationsContext, + BuildPlannerSourceFreshnessResult, + BuildProgressCallbacks, + BuildProjectColumnLineage, + BuildProjectGraph, + BuildProjectGraphFromCompiledProject, + BuildProjectRelationTargets, + BuildPythonRelationTargets, + BuildPythonRunPlanOutputs, + BuildPythonSqlRunLifecycle, + BuildRuleCatalogue, + BuildRulesRequest, + BuildScenarioExecutionPlan, + BuildScenarioHashIndex, + BuildScenarioRelationMap, + BuildSeedCommandPlan, + BuildSqlbuildPlanOutput, + BuildStaleOutOfSelectionWarnings, + BuildStaticPipelineResult, + BuildTestCommandPlan, + CheckBuildability, + CheckCompileReuse, + CheckCursorTypeConsistency, + CliStyle, + CommandWarehouseScopeContext, + CompareContracts, + CompileDbtInteropProject, + CompileFrontier, + CompileProjectPhase, + CompileReuseExcludedRootDirectories, + CompileReuseRacyWindowNs, + CompileStaticCommandContext, + CompiledCodeIdentity, + CompiledProjectFacts, + CompiledProjectRecord, + ComputeCursorBounds, + ConnectionProgressReporter, + ContentDigest, + ContextStoreToken, + CostArtifactError, + CostContext, + CostOutputPayload, + CurrentNativeProgressProjector, + CursorCompare, + CursorExclusiveToInclusive, + CursorObservedPartition, + CursorParse, + CursorRender, + CursorSentinelToToken, + CustomHostObserver, + CustomRuleIdentity, + CustomRuleImplementationFingerprint, + CustomRuleImportClosure, + DbtEventStream, + DbtExecutionLsArgv, + DbtFailureDetail, + DbtInitProgressReporter, + DbtRunner, + DebugDbtFromProject, + DeclarationRows, + DescribeConnectionWarehouse, + DetectChanges, + DetectModelChanges, + DetectStaleWarningChanges, + DirectorySnapshotScope, + DiscoverModelFiles, + DiscoverModelSchemaFiles, + DiscoverSchemaFiles, + DiscoverSourceFiles, + DiscoverTestFiles, + DynamicContractProof, + EditContractModel, + EditContractSource, + EffectiveConfigConnection, + EffectiveConfigSettings, + EffectiveConfigVars, + EnforceModelExecutionLimit, + EnforcePlanSafetyPolicies, + EvaluateRules, + EvaluateRulesRequest, + EventExporterCommandScope, + EventExporterCommandScopeFunction, + EventExporterDispatcher, + ExecuteDbtCommands, + ExecuteDbtInteropFromProject, + ExecuteDbtJsonEventStream, + ExecuteDbtSqlbuildWork, + ExecuteDbtWithoutStateTracking, + ExecutionEventWriter, + ExplicitReferencesHelp, + FinalizeRuleFindingsRows, + FindPythonStringLocations, + FinishRuleRun, + FormatAuditExecutionJson, + FormatBuildExecutionJson, + FormatBuildFooter, + FormatCloneExecutionJson, + FormatCompileErrorJson, + FormatCostBreakdown, + FormatCostHistory, + FormatCostHistoryJson, + FormatCostJson, + FormatDegradableBuildExecutionJson, + FormatExecutionHeader, + FormatExpectationDetail, + FormatExpectationName, + FormatLintSqlBodies, + FormatLoadExecutionJson, + FormatNativeHeaders, + FormatPlan, + FormatPlanJson, + FormatRedundantFixtureNulls, + FormatRule, + FormatRulesResult, + FormatScenarioExecutionJson, + FormatScenarioSnapshotExecutionJson, + FormatSeedExecutionJson, + FormatSkippedTypeProofRules, + FormatTestExecutionJson, + GatherDeferredRelations, + GetConfigCursorBound, + GetConfigStr, + GetMaterializationType, + GetSemanticSourceColumns, + IdenticalRenames, + InferFixtureColumnFacts, + InferNativeExpressionSourceShapes, + InferNativeQueryColumns, + InstallRulesSkills, + LaunchRecordOffered, + LaunchRecordWithheld, + ListCostRuns, + LoadCompiledDbtManifest, + LoadDbtManifestIndex, + LoadLocalConfigFile, + LoadOrBuildScopeIndex, + LoadProgressReporter, + LoadProjectConfigFile, + LoadRulesConfig, + LoaderDestinationPartsFunction, + LocateModelBindingDiagnostics, + MachineOutputMode, + MacroStoreToken, + MaintainSqlbuildSkills, + MatchingDynamicFamilies, + MaximumAllowedStart, + ModelPythonHookNames, + NativeDeclarationContexts, + NativeModelLoop, + NativeModelValidator, + NativeProgressProjector, + NativeProgressProjectorContext, + NestedCommandProgressCallbacks, + NormalizeAnalysisSql, + NormalizeDbtProfileConnection, + ParseDbtLsJsonLines, + ParseHeaderValues, + PlanColumnMigrations, + PlanCompiledSqlTestArtifacts, + PlanDbtInteropCommand, + PlanDbtInteropFromProject, + PlanHasExecutableWork, + PlanModel, + PlanRuleFixes, + PlanRuleRun, + PlanSqlTests, + PlanSqlTestsNatively, + PlanningProgressReporter, + PreparedCompileArtifacts, + ProjectWith, + PublicDeclarationIndexes, + PythonReadSourceNamesFor, + ReadCostRun, + ReadLatestFingerprints, + ReadOldNameViewHistories, + ReadSelectedSeedFingerprints, + ReadsOutsideTargetLineage, + RecordTemplateReads, + RejectUnparseableHeaderRewrites, + RelationLineageFingerprint, + RemainingContractFindings, + RenameHints, + RenamesExplainChange, + RenderAuditSql, + RenderDbtExecutionSummaryFooter, + RenderDbtInteropPlan, + RenderDbtNodeResult, + RenderDiffErrorJson, + RenderProjectVarText, + RenderSourceRelation, + ReportCompileDiagnostic, + ResolveCloneBoundary, + ResolveCompileAnalysisSelection, + ResolveCostRun, + ResolveDbtConfig, + ResolveDbtConnectionConfig, + ResolveDbtExecutable, + ResolveDbtExecutionInvocation, + ResolveDbtInteropPlan, + ResolveDbtReferenceRelation, + ResolveDeferredTargetConfig, + ResolveEffectiveAdapterName, + ResolveEffectiveScenarioConfig, + ResolveExternalSqlReferenceResolver, + ResolveFunctionSql, + ResolveFutureCursorSafety, + ResolveModelDeferralInputs, + ResolveModelSql, + ResolveProjectConnectionConfig, + ResolveRawDbtProfileConnection, + ResolveRefReferences, + ResolveRuleIgnoreSelectors, + ResolveSkippedViewChain, + ResolveSourceReferences, + ResolveSqlbuildExecutionPlanOutput, + ResolveStaticRelationContext, + ResolveTargetConfig, + ResolveTargetConnectionConfig, + ResolveTargetName, + RouteDbtInteropArgs, + RuleSelected, + RulesBulkCachePath, + RunAuditCommand, + RunBuildCommand, + RunCheckCommand, + RunCloneCommand, + RunClonePipelineWithOptions, + RunCompile, + RunCompileCommand, + RunCompileOnlyPipeline, + RunCompilePipeline, + RunContractCommand, + RunCostCommand, + RunDagCommand, + RunDbtCommand, + RunDbtInitCommand, + RunDbtSqlbuildWork, + RunDebugCommand, + RunDiffCommand, + RunDiffPipeline, + RunFormatCommand, + RunInitCommand, + RunJanitorCommand, + RunLineageCommand, + RunLoadCommand, + RunPlanCommand, + RunPlannedSqlRules, + RunPlaygroundCommand, + RunQueryCommand, + RunRefactorCommand, + RunRules, + RunRulesCommand, + RunScenarioCaptureCommand, + RunScenarioTestCommand, + RunScopeCommand, + RunSeedCommand, + RunSkillsCommand, + RunTestCommand, + RuntimeCursorProducerNames, + SafeFormatFiles, + SchemaValidations, + ScopeMetadataProjection, + SelectCatalogueRules, + SelectedRuleCodes, + SessionOutcomeAnalysis, + SettingHelp, + SharedTransientLineCoordinator, + SourceBindingDiagnostics, + SourceFreshnessInputError, + SourceFreshnessObservationError, + SplitSelectorExpansion, + SqlTestModelChainNamesByKey, + SqlTestScanCache, + SqlValueValidationError, + StoredOldNameViewColumns, + TerminalEventIndex, + TerminalEventIndexContext, + TerminalEventIndexScopeFunction, + TransientStatusReporter, + TypeCursorOverrides, + UpdateSqlbuildSkills, + ValidateAuthoredSqlTestCtes, + ValidateCliWarehouse, + ValidateCompileDbtModelNames, + ValidateCompileDbtModelReference, + ValidateDbtInitProject, + ValidatePreviewTarget, + ValidateSourceCursorInputColumns, + WithBindingDiagnostics, + WithTypeRecovery, + WriteAtomically, + WriteCheckResults, + WriteCompileTarget, + WriteCostRun, + WriteDbtExecutionPlanText, + WriteDbtExecutionSummary, + WriteExecutionHeader, + WriteExecutionJsonOutput, + WriteRuntimeTarget, + WriteSourceFreshnessRecords, + WriteSqlbuildSkipNotice, +} diff --git a/crates/sqlbuild-python/src/bindings/types.rs b/crates/sqlbuild-python-base/src/types.rs similarity index 82% rename from crates/sqlbuild-python/src/bindings/types.rs rename to crates/sqlbuild-python-base/src/types.rs index 367b8e9c5..d7009884c 100644 --- a/crates/sqlbuild-python/src/bindings/types.rs +++ b/crates/sqlbuild-python-base/src/types.rs @@ -1,7 +1,7 @@ use pyo3::prelude::{Bound, PyAny, PyResult, Python}; use pyo3::types::PyTuple; -pub(crate) trait CompilerDetach { +pub trait CompilerDetach { fn compiler_detach Result + Send>( self, operation: F, @@ -9,11 +9,11 @@ pub(crate) trait CompilerDetach { } /// A named record read from the positional tuple Python sends. -pub(crate) trait FromPositional: Sized { +pub trait FromPositional: Sized { fn from_positional(value: &Bound<'_, PyAny>) -> PyResult; } /// A named record converted into the positional tuple Python receives. -pub(crate) trait IntoPositional { +pub trait IntoPositional { fn into_positional<'py>(self, py: Python<'py>) -> PyResult>; } diff --git a/crates/sqlbuild-python/Cargo.toml b/crates/sqlbuild-python/Cargo.toml index 0dae6784f..d9d9bba81 100644 --- a/crates/sqlbuild-python/Cargo.toml +++ b/crates/sqlbuild-python/Cargo.toml @@ -19,7 +19,6 @@ extension-module = ["pyo3/extension-module"] chrono.workspace = true chrono-tz.workspace = true fensu-policy.workspace = true -mimalloc.workspace = true pyo3.workspace = true rayon.workspace = true rusqlite.workspace = true @@ -41,6 +40,7 @@ sqlbuild-model-config.workspace = true sqlbuild-orchestration.workspace = true sqlbuild-project.workspace = true sqlbuild-pysource.workspace = true +sqlbuild-python-base.workspace = true sqlbuild-recall.workspace = true sqlbuild-refactor.workspace = true sqlbuild-render.workspace = true diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_catalog.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_catalog.rs index 3aa2be4ba..5595f3c0b 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_catalog.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_catalog.rs @@ -11,20 +11,20 @@ use pyo3::{pyclass, pyfunction, pymethods, wrap_pyfunction}; use sqlbuild_analysis::semantic_validation::models as validation; use sqlbuild_analysis::semantic_validation::models::DiagnosticRow; -use crate::bindings::types::IntoPositional; use sqlbuild_analysis::semantic_validation::types::{BindingRequest, Relations}; +use sqlbuild_python_base::types::IntoPositional; use crate::bindings::_helpers::analysis::conversions; -use crate::bindings::_helpers::boundary::panics::compiler_error; -use crate::bindings::_helpers::records::construct::new_record; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::fields::mapping_get_or; -use crate::bindings::_helpers::records::fields::mapping_items; -use crate::bindings::_helpers::records::fields::mapping_values; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::models::{CatalogInput, ProjectCatalog}; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::main::fields::mapping_get_or::mapping_get_or; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; +use sqlbuild_python_base::records::main::fields::mapping_values::mapping_values; +use sqlbuild_python_base::records::types::RecordId; +use sqlbuild_python_base::types::CompilerDetach; /// Dialects whose quoted identifiers bind case-sensitively unless the session says otherwise. pub(crate) const CASE_SENSITIVE_BINDING_DIALECTS: [&str; 2] = ["snowflake", "postgresql"]; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_locations.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_locations.rs index 52f7e0d07..4a2c0e4e7 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_locations.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/binding_locations.rs @@ -8,6 +8,7 @@ use sqlbuild_analysis::binding_locations::models::{ AuthoredSpan, BindingSource, LocatedDiagnostic, }; use sqlbuild_analysis::semantic_validation::models::{DiagnosticRow, Expansion}; +use sqlbuild_python_base::positional_record; use crate::bindings::models::Positional; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/catalog.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/catalog.rs index 52c663d6b..a56da309e 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/catalog.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/catalog.rs @@ -2,10 +2,8 @@ use crate::bindings::_helpers::analysis::conversions; use crate::bindings::_helpers::analysis::normalization_results::normalization_results; -use crate::bindings::_helpers::boundary::panics::compiler_error; use crate::bindings::models::Positional; use crate::bindings::models::{CatalogInput, CompactAnalysisJob, ProjectCatalog}; -use crate::bindings::types::CompilerDetach; use pyo3::exceptions::PyValueError; use pyo3::prelude::{Bound, Py, PyAny, PyResult, Python}; use pyo3::pymethods; @@ -15,6 +13,8 @@ use sqlbuild_analysis::semantic_validation::models::DiagnosticRow; use sqlbuild_analysis::semantic_validation::types::{ BindingRequest, NormalizationRequest, Relations, }; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::types::CompilerDetach; use std::collections::HashMap; #[pymethods] diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/getters.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/getters.rs index 017033ba6..8e6a305bf 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/getters.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/getters.rs @@ -4,8 +4,8 @@ use pyo3::IntoPyObjectExt; use pyo3::prelude::{Bound, PyAny, PyResult, Python}; use crate::bindings::_helpers::analysis::binding_catalog::BindingCatalog; -use crate::bindings::_helpers::records::getters::class_of; -use crate::bindings::_helpers::records::models::GetterEntry; +use sqlbuild_python_base::records::main::registry::class_of::class_of; +use sqlbuild_python_base::records::models::GetterEntry; /// The getter readers of this module's native pyclasses. pub(crate) const GETTERS: &[GetterEntry] = &[GetterEntry { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization.rs index aafb773fe..94c65584f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization.rs @@ -4,10 +4,10 @@ use pyo3::prelude::{Bound, Py, PyAny, PyModule, PyModuleMethods, PyResult, Pytho use pyo3::{pyfunction, wrap_pyfunction}; use crate::bindings::_helpers::analysis::normalization_results::normalization_results; -use crate::bindings::_helpers::boundary::panics::value_error; use crate::bindings::models::Positional; -use crate::bindings::types::CompilerDetach; use sqlbuild_analysis::semantic_validation::models::DiagnosticRow; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::types::CompilerDetach; #[pyfunction] pub(crate) fn normalize_analysis_sql( diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization_results.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization_results.rs index aa116ff1a..e6fad9197 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization_results.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/normalization_results.rs @@ -10,7 +10,7 @@ pub(crate) fn normalization_results( .map(|result| match result { Ok(sql) => Ok(sql.into_pyobject(py)?.into_any().unbind()), Err(error) => Ok( - crate::bindings::_helpers::boundary::panics::compiler_error(error) + sqlbuild_python_base::boundary::main::compiler_error::compiler_error(error) .into_value(py) .into_any(), ), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/positions.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/positions.rs index 740a7b2e4..c3c61fcfe 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/positions.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/positions.rs @@ -1,10 +1,10 @@ //! Python methods of authored binding positions. -use crate::bindings::_helpers::boundary::panics::compiler_guard; use crate::bindings::models::{BindingPositions, PositionInput}; use pyo3::exceptions::PyValueError; use pyo3::{PyResult, pymethods}; use sqlbuild_analysis::semantic_validation::models as validation; +use sqlbuild_python_base::boundary::main::compiler_guard::compiler_guard; #[pymethods] impl BindingPositions { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/queries.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/queries.rs index b719e29b6..249917466 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/queries.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/queries.rs @@ -3,8 +3,8 @@ use pyo3::prelude::{Bound, PyModule, PyModuleMethods, PyResult, Python}; use pyo3::{pyfunction, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::types::CompilerDetach; #[pyfunction] fn query_fingerprint(py: Python<'_>, sql: &str, dialect: &str) -> PyResult { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/relation_names.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/relation_names.rs index 0c6efda93..a5aee1a37 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/relation_names.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/relation_names.rs @@ -7,8 +7,8 @@ use sqlbuild_analysis::relation_names::main::extract_relation_names::extract_rel use sqlbuild_analysis::relation_names::models::{ExtractedRelations, RelationName}; use sqlbuild_core::panics::main::native_failure::native_failure; -use crate::bindings::_helpers::boundary::panics::compiler_error; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::types::CompilerDetach; const RELATION_NAMES_CONTEXT: &str = "native relation name extraction"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/required_columns.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/required_columns.rs index 4afeef9f3..0077771a7 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/required_columns.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/required_columns.rs @@ -8,11 +8,11 @@ use sqlbuild_analysis::required_columns::errors::RequiredColumnsError; use sqlbuild_analysis::required_columns::main::resolve_required_columns::resolve_required_columns as resolve; use sqlbuild_analysis::required_columns::models::{ColumnRead, ReferenceInput}; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; +use sqlbuild_python_base::types::CompilerDetach; /// CTE-aware column reads of `query_sql`, resolved to the external resources it references. #[pyfunction] diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/schema_request.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/schema_request.rs index b2fc9f5f2..dd7787f69 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/schema_request.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/schema_request.rs @@ -7,10 +7,10 @@ use pyo3::types::PyDict; use sqlbuild_analysis::semantic_validation::main::normalize::normalize_analysis_sql; use sqlbuild_analysis::semantic_validation::models::NormalizationInput; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::_helpers::records::construct::new_record; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::types::RecordId; +use sqlbuild_python_base::types::CompilerDetach; const GENERIC_DIALECT: &str = "generic"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_test_comparisons.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_test_comparisons.rs index 7dd4056ec..47032bc53 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_test_comparisons.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_test_comparisons.rs @@ -11,10 +11,10 @@ use sqlbuild_analysis::compiler::main::scenario_expected_comparison_sql::scenari use sqlbuild_analysis::compiler::main::sql_test_difference_sampling::render_difference_sample_json; use sqlbuild_analysis::compiler::main::sql_test_rendering::render_json; -use crate::bindings::_helpers::boundary::keyword_request::Request; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::types::CompilerDetach; const RENDER_WORKERS: usize = 4; const DEFAULT_SET_DIFFERENCE: &str = "EXCEPT"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_tests.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_tests.rs index 63025f70b..ed84f097b 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_tests.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis/sql_tests.rs @@ -3,8 +3,8 @@ use pyo3::prelude::{Bound, PyModule, PyModuleMethods, PyResult, Python}; use pyo3::{pyfunction, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::types::CompilerDetach; #[pyfunction] fn extract_sql_tests_json(py: Python<'_>, request_json: &str) -> PyResult { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_columns.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_columns.rs index 43554846c..1a6890da2 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_columns.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_columns.rs @@ -14,12 +14,13 @@ use sqlbuild_core::text::main::python_casefold::python_casefold; use crate::bindings::_helpers::analysis_session::models::FixtureInferenceCount; use crate::bindings::_helpers::analysis_session::query_columns::ColumnsRow; use crate::bindings::_helpers::analysis_session::stage_functions::query_column_rows; -use crate::bindings::_helpers::boundary::keyword_request::Request; -use crate::bindings::_helpers::boundary::panics::compiler_error; -use crate::bindings::_helpers::records::construct::{enum_from_value, new_record}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::construct::enum_from_value::enum_from_value; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; +use sqlbuild_python_base::types::CompilerDetach; const PROJECTION_FACTS_CONTEXT: &str = "native fixture projection facts"; const LEGACY_MODE: &str = "legacy"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_inferences.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_inferences.rs index 0b39e7eba..e676df32f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_inferences.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/fixture_inferences.rs @@ -1,11 +1,11 @@ //! Fixture column inference computed once per fixture body and inference profile. use crate::bindings::_helpers::analysis_session::fixture_columns::infer_fixture_column_facts; -use crate::bindings::_helpers::boundary::python_calls::keywords; -use crate::bindings::_helpers::records::fields::field as native_field; use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods}; use pyo3::{pyclass, pymethods}; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::records::main::fields::field::field as native_field; use std::sync::Mutex; /// Reuse inference for identical fixture SQL under an equal, catalog-free profile. diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/getters.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/getters.rs index e05ca4974..2e8ae0d00 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/getters.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/getters.rs @@ -4,8 +4,8 @@ use pyo3::IntoPyObjectExt; use pyo3::prelude::{Bound, PyAny, PyResult, Python}; use crate::bindings::_helpers::analysis_session::session::NativeModelAnalysisSession; -use crate::bindings::_helpers::records::getters::class_of; -use crate::bindings::_helpers::records::models::GetterEntry; +use sqlbuild_python_base::records::main::registry::class_of::class_of; +use sqlbuild_python_base::records::models::GetterEntry; /// The getter readers of this module's native pyclasses. pub(crate) const GETTERS: &[GetterEntry] = &[GetterEntry { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/model_analyses.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/model_analyses.rs index a1aaa18cd..04ebc4692 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/model_analyses.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/model_analyses.rs @@ -26,15 +26,15 @@ use crate::bindings::_helpers::compiled_views::model_input_view::{ AttachedSchema, NativeModelInput, attached_schema, input_analysis_sql, input_model_name, input_reference_rows, input_sql_macro_checks, }; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::enum_member; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::fields::mapping_items; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::_helpers::semantic_shapes::shapes::{VALID_FROM_DEFAULT, VALID_TO_DEFAULT}; use sqlbuild_model_config::header_metadata::models::DynamicFamily; use sqlbuild_project::models::ReferenceRow; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; +use sqlbuild_python_base::records::types::RecordId; const LOGGING_MODULE: &str = "logging"; const DEBUG_LOGGER: &str = "sqlbuild.compile"; @@ -432,7 +432,7 @@ fn log_debug(py: Python<'_>, message: &str, failure: &Bound<'_, PyAny>) -> PyRes )?; arguments.set_item("message", message)?; arguments.set_item("sqlbuild_error", failure)?; - host::entry(py, ExecutorHost::LogDebugEvent)?.call((), Some(&arguments))?; + host_entry(py, ExecutorHost::LogDebugEvent)?.call((), Some(&arguments))?; Ok(()) } diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/nullability_rules.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/nullability_rules.rs index a8f718230..4eda4f885 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/nullability_rules.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/nullability_rules.rs @@ -2,10 +2,10 @@ use std::sync::{Arc, Mutex, PoisonError}; -use crate::bindings::_helpers::records::fields::field as native_field; use pyo3::prelude::{Py, PyAny, PyAnyMethods, PyDictMethods, PyErr, Python}; use pyo3::types::{PyDict, PyTuple}; use sqlbuild_analysis::assembly::analysis_session::models::NullabilityCallback; +use sqlbuild_python_base::records::main::fields::field::field as native_field; /// The first exception an adapter rule raised, which the session re-raises to Python. pub(crate) type RuleFailure = Arc>>; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/oracle.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/oracle.rs index e195edbd4..11dc02353 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/oracle.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/oracle.rs @@ -6,9 +6,10 @@ use sqlbuild_analysis::assembly::analysis_session::main::names_set_operation::na use sqlbuild_analysis::assembly::analysis_session::main::recover_cte_facts::recover_cte_facts; use sqlbuild_analysis::assembly::analysis_session::models::{CteFactRequest, CteFacts}; use sqlbuild_analysis::assembly::analysis_session::types::{Pairs, Shapes}; +use sqlbuild_python_base::positional_record; -use crate::bindings::_helpers::boundary::panics::value_error; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::value_error::value_error; +use sqlbuild_python_base::types::CompilerDetach; positional_record! { extract; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/outcome_objects.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/outcome_objects.rs index c31963b62..a0a1b9e96 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/outcome_objects.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/outcome_objects.rs @@ -4,11 +4,14 @@ use pyo3::IntoPyObjectExt; use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods, PyTuple}; use pyo3::{pyfunction, wrap_pyfunction}; +use sqlbuild_python_base::positional_record; -use crate::bindings::_helpers::boundary::keyword_request::Request; use crate::bindings::_helpers::lineage::lineage_facts::{confidence_member, transform_kind_member}; -use crate::bindings::_helpers::records::construct::{enum_from_value, new_record, record_class}; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::construct::enum_from_value::enum_from_value; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::types::RecordId; const LINEAGE_NATIVE: &str = "native"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/profile_inputs.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/profile_inputs.rs index 045cc2861..95e365fe7 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/profile_inputs.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/profile_inputs.rs @@ -8,11 +8,11 @@ use sqlbuild_host::entries::models::AdapterHost; use crate::bindings::_helpers::analysis::binding_catalog::{ BindingCatalog, CASE_SENSITIVE_BINDING_DIALECTS, CatalogKey, NATIVE_DIALECT_ALIASES, }; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::record_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_items; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; +use sqlbuild_python_base::records::types::RecordId; const GENERIC_DIALECT: &str = "generic"; pub(crate) const ADAPTER_RULE_ID: &str = "python"; @@ -34,7 +34,7 @@ pub(crate) fn nullability_rules(profile: &Bound<'_, PyAny>) -> PyResult<(Pairs, let py: Python<'_> = profile.py(); let known: Bound<'_, PyDict> = PyDict::new(py); for (rule, id) in KNOWN_RULES { - known.set_item(host::entry(py, rule)?, id)?; + known.set_item(host_entry(py, rule)?, id)?; } let adapter: Bound<'_, PyDict> = PyDict::new(py); let mut rows: Pairs = Vec::new(); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/query_columns.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/query_columns.rs index e54f8b327..f2761d28d 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/query_columns.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/query_columns.rs @@ -12,13 +12,14 @@ use sqlbuild_analysis::assembly::analysis_session::models::{ }; use sqlbuild_analysis::assembly::analysis_session::types::{Pairs, Shapes}; use sqlbuild_core::panics::main::native_failure::native_failure; +use sqlbuild_python_base::positional_record; use crate::bindings::_helpers::analysis_session::nullability_rules::{ RuleFailure, nullability_callback, raised, }; -use crate::bindings::_helpers::boundary::panics::compiler_error; use crate::bindings::models::ProjectCatalog; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::types::CompilerDetach; const QUERY_COLUMNS_CONTEXT: &str = "native query column analysis"; const PROJECTION_FACTS_CONTEXT: &str = "native fixture projection facts"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/session.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/session.rs index 1fd0bec4d..9943002f4 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/session.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/session.rs @@ -25,6 +25,7 @@ use sqlbuild_analysis::assembly::analysis_session::models::{ use sqlbuild_analysis::assembly::analysis_session::types::{Pairs, Shapes}; use sqlbuild_analysis::semantic_validation::models::DiagnosticRow; use sqlbuild_analysis::sql_macros::models::SqlMacroCheck; +use sqlbuild_python_base::positional_record; use sqlbuild_sqltext::compiler::main::placeholder_defaults::placeholder_defaults; use sqlbuild_cache::store::models::NativeStore; @@ -37,11 +38,11 @@ use std::path::PathBuf; use crate::bindings::_helpers::analysis_session::nullability_rules::{ RuleFailure, nullability_callback, raised, }; -use crate::bindings::_helpers::boundary::panics::compiler_error; use crate::bindings::_helpers::cache::native_store::{open_store, save_store}; use crate::bindings::models::Positional; use crate::bindings::models::ProjectCatalog; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::boundary::main::compiler_error::compiler_error; +use sqlbuild_python_base::types::CompilerDetach; /// `(name, type, nullability)`. type ColumnRow = (String, Option, String); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/stage_functions.rs b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/stage_functions.rs index 2f041b3a8..393504c71 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/stage_functions.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/analysis_session/stage_functions.rs @@ -19,16 +19,17 @@ use crate::bindings::_helpers::analysis_session::session::{ ContractRow, ExpressionShapesRow, FamilyRow, NativeModelAnalysisSession, PivotModelRow, PivotRequestRow, infer_expression_source_shapes, prove_dynamic_column_contracts, }; -use crate::bindings::_helpers::boundary::keyword_request::Request; use crate::bindings::_helpers::compile_driver::stage_work::{ EXPRESSION_SHAPE_BATCHES, EXPRESSION_SHAPES_INFERRED, count_stage, }; use crate::bindings::_helpers::model_config::header_families::family_specs; -use crate::bindings::_helpers::records::construct::{enum_from_value, new_record}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_items; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::models::ProjectCatalog; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::construct::enum_from_value::enum_from_value; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; +use sqlbuild_python_base::records::types::RecordId; const BATCH_MODE: &str = "batch"; const TABLE_FUNCTION_KIND: &str = "table_fn"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/attachments/ceremonial_select.rs b/crates/sqlbuild-python/src/bindings/_helpers/attachments/ceremonial_select.rs index 55bb64e12..1ffcd001f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/attachments/ceremonial_select.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/attachments/ceremonial_select.rs @@ -6,8 +6,8 @@ use sqlbuild_attachments::ceremonial_select::main::omitted_select_offset::omitte use sqlbuild_attachments::ceremonial_select::models::OmittedSelect; use sqlbuild_sqltext::sql_scan::models::LexicalSyntax; -use crate::bindings::_helpers::boundary::panics::compiler_guard; use crate::bindings::_helpers::sqltext::lexical_syntax::LexicalSyntaxInput; +use sqlbuild_python_base::boundary::main::compiler_guard::compiler_guard; /// The code-point offset to insert `SELECT 1` at, or `None`. #[pyfunction] diff --git a/crates/sqlbuild-python/src/bindings/_helpers/attachments/cursor_intrinsics.rs b/crates/sqlbuild-python/src/bindings/_helpers/attachments/cursor_intrinsics.rs index cbe9af746..6d52d7f64 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/attachments/cursor_intrinsics.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/attachments/cursor_intrinsics.rs @@ -9,10 +9,10 @@ use sqlbuild_attachments::cursor_intrinsics::main::replace_intrinsics_with_spans use sqlbuild_attachments::cursor_intrinsics::main::validated_model_intrinsics::validated_model_intrinsics; use sqlbuild_attachments::cursor_intrinsics::models::IntrinsicModel; -use crate::bindings::_helpers::boundary::panics::compiler_guard; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::boundary::main::compiler_guard::compiler_guard; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::types::ErrorId; const INCREMENTAL_MATERIALIZATION: &str = "incremental"; const CURSOR_START: &str = "__cursor_start"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/attachments/reference_markers.rs b/crates/sqlbuild-python/src/bindings/_helpers/attachments/reference_markers.rs index b11251c5b..8f151e1d2 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/attachments/reference_markers.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/attachments/reference_markers.rs @@ -7,9 +7,9 @@ use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_attachments::reference_markers::main::unresolved_reference_marker::unresolved_reference_marker; use sqlbuild_attachments::sql_lexing::main::unclosed_message::unclosed_message; -use crate::bindings::_helpers::boundary::panics::compiler_guard; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::boundary::main::compiler_guard::compiler_guard; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::types::ErrorId; /// The reference function and diagnostic code of each marker kind, in the scanner's order. const MARKER_KINDS: [(&str, &str); 5] = [ diff --git a/crates/sqlbuild-python/src/bindings/_helpers/audit_command/command.rs b/crates/sqlbuild-python/src/bindings/_helpers/audit_command/command.rs index f1deefee1..8f5126599 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/audit_command/command.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/audit_command/command.rs @@ -16,7 +16,6 @@ use sqlbuild_host::entries::models::ExecutorHost; use sqlbuild_host::models::{AuditExecutionResult, AuditOutcome}; use sqlbuild_orchestration::runs::models::NodeOutcome; -use crate::bindings::_helpers::boundary::python_calls::{call_with, keywords, within}; use crate::bindings::_helpers::build_progress::audit_progress::AuditProgressReporter; use crate::bindings::_helpers::build_progress::progress::current_native_progress_projector; use crate::bindings::_helpers::build_progress::progress_reporters::ConnectionProgressReporter; @@ -28,18 +27,22 @@ use crate::bindings::_helpers::compile_driver::static_context::compile_static_co use crate::bindings::_helpers::compiled_project::snapshot_execution::{VerifiedRun, WorkerBuild}; use crate::bindings::_helpers::cost_telemetry::context::CostContext; use crate::bindings::_helpers::dbt_interop::reference_resolver::resolve_external_sql_reference_resolver; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::native_host::results::ReadResult; use crate::bindings::_helpers::planner_entries::command_plans::build_audit_command_plan; -use crate::bindings::_helpers::records::construct::{new_record_with, record_class}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::_helpers::result_output::documents::{ audit_execution_json, audit_projection, write_execution_json_output, }; use crate::bindings::_helpers::result_output::event_writer::ExecutionEventWriter; use crate::bindings::_helpers::result_output::projection::audit_check_id; use crate::bindings::_helpers::result_output::resource_ids::audit_identity; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const EXECUTION_COMMAND: &str = "sqb audit"; @@ -368,7 +371,7 @@ fn execute<'py>( .into_any(); within(&scope, |_| { let callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::AuditPipelineCallbacks)?, + &host_entry(py, ExecutorHost::AuditPipelineCallbacks)?, &[ ( "on_connection_start", @@ -401,7 +404,7 @@ fn execute<'py>( ], )?; call_with( - &host::entry(py, ExecutorHost::RunAuditPipelineWithCallbacks)?, + &host_entry(py, ExecutorHost::RunAuditPipelineWithCallbacks)?, &[ ("plan", plan.clone()), ( @@ -445,7 +448,7 @@ fn audit_payload<'py>( (concurrency, worker_count): (i64, i64), ) -> PyResult { let projection: Bound<'py, PyAny> = - host::entry(py, ExecutorHost::CurrentAuditResultProjection)?.call0()?; + host_entry(py, ExecutorHost::CurrentAuditResultProjection)?.call0()?; let trailing = if projection.is_none() { Vec::new() } else { @@ -472,7 +475,7 @@ fn audit_payload<'py>( /// The warning line for audit results that could not be stored in the warehouse history table; audit outcomes are unaffected. fn projection_warning(py: Python<'_>, style: CliStyle) -> PyResult> { let projection: Bound<'_, PyAny> = - host::entry(py, ExecutorHost::CurrentAuditResultProjection)?.call0()?; + host_entry(py, ExecutorHost::CurrentAuditResultProjection)?.call0()?; if projection.is_none() || !native_field(&projection, "degraded")?.is_truthy()? { return Ok(None); } diff --git a/crates/sqlbuild-python/src/bindings/_helpers/auditing/identity.rs b/crates/sqlbuild-python/src/bindings/_helpers/auditing/identity.rs index 10daf8c96..c1d329e11 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/auditing/identity.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/auditing/identity.rs @@ -1,8 +1,5 @@ //! Audit gate identities of planned audits, built as `AuditGateIdentity` objects. -use crate::bindings::_helpers::records::construct::record_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods, PyTuple}; use pyo3::{IntoPyObject, pyfunction, wrap_pyfunction}; @@ -10,6 +7,9 @@ use sqlbuild_analysis::auditing::main::audit_gate_identity::audit_gate_identity; use sqlbuild_analysis::auditing::models::{ GateIdentity, MeasurementFacts, PlannedAudit, ThresholdBound, Thresholds, }; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const MEASUREMENT_MODE: &str = "measurement"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/auditing/measurement.rs b/crates/sqlbuild-python/src/bindings/_helpers/auditing/measurement.rs index 075eb6312..2ca1179c2 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/auditing/measurement.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/auditing/measurement.rs @@ -9,9 +9,9 @@ use sqlbuild_analysis::auditing::models::{MeasurementOutcome, Thresholds}; use sqlbuild_host::entries::models::FacadeHost; use crate::bindings::_helpers::auditing::identity::thresholds as read_thresholds; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::types::ErrorId; fn measurement_error(py: Python<'_>, message: &str) -> PyErr { match error_class(py, ErrorId::MeasurementAudit).and_then(|class| class.call1((message,))) { @@ -40,7 +40,7 @@ fn evaluate_measurement<'py>( MeasurementOutcome::Error => "ERROR", MeasurementOutcome::Insufficient => "INSUFFICIENT", }; - host::entry(py, FacadeHost::AuditOutcome)?.getattr(member) + host_entry(py, FacadeHost::AuditOutcome)?.getattr(member) } pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/auditing/render.rs b/crates/sqlbuild-python/src/bindings/_helpers/auditing/render.rs index d4c929b39..9bff3a370 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/auditing/render.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/auditing/render.rs @@ -5,12 +5,12 @@ use pyo3::types::PyDict; use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_analysis::auditing::main::replace_reference_calls::replace_reference_calls; -use crate::bindings::_helpers::boundary::keyword_request::Request; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; use crate::bindings::_helpers::references::source_relations::{ render_source_read, render_source_relation, }; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; const REF_FUNCTION: &str = "__ref"; const SEED_FUNCTION: &str = "__seed"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/auditing/schema_audits.rs b/crates/sqlbuild-python/src/bindings/_helpers/auditing/schema_audits.rs index 7b1c66567..ec3d9abff 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/auditing/schema_audits.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/auditing/schema_audits.rs @@ -9,12 +9,12 @@ use sqlbuild_model_config::errors::{ConfigError, ErrorClass}; use sqlbuild_model_config::header_metadata::main::parse_audit_list::parse_audit_list; use sqlbuild_model_config::header_metadata::models::ParsedAudit; -use crate::bindings::_helpers::boundary::keyword_request::Request; use crate::bindings::_helpers::model_config::authored_nodes::PyNode; use crate::bindings::_helpers::model_config::contract_classes::contract_classes; use crate::bindings::_helpers::model_config::header_metadata::{ContractClasses, audit_tuple}; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::types::ErrorId; /// A resource identity error as `ResourceIdentityError`, anything else as `fallback_class(message)`. fn raised( diff --git a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/fields.rs b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/fields.rs index eb937deb4..3c31b6c87 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/fields.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/fields.rs @@ -4,7 +4,7 @@ use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyErr, PyModule, PyModuleMethods use pyo3::types::{PyBool, PyDict, PyString, PyStringMethods}; use pyo3::{pyfunction, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::keyword_request::Request; +use sqlbuild_python_base::boundary::models::Request; /// The setting a validator reads and how it names the setting in errors. struct Setting<'py> { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/project_vars.rs b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/project_vars.rs index 43990d41a..163924d25 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/project_vars.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/project_vars.rs @@ -2,12 +2,12 @@ use sqlbuild_host::entries::models::FacadeHost; -use crate::bindings::_helpers::native_host::host; use pyo3::prelude::{ Bound, PyAny, PyAnyMethods, PyErr, PyModule, PyModuleMethods, PyResult, Python, }; use pyo3::types::{PyBool, PyDict, PyFloat, PyInt, PyList, PyString, PyTypeMethods}; use pyo3::{pyfunction, wrap_pyfunction}; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; const JSON_MODULE: &str = "json"; /// Characters of a structured value's JSON preview before it is cut short. @@ -16,7 +16,7 @@ const PREVIEW_ELLIPSIS: &str = "..."; /// `SharedInputError(message)`. fn shared_input_error(py: Python<'_>, message: String) -> PyErr { - match host::entry(py, FacadeHost::SharedInputError).and_then(|class| class.call1((message,))) { + match host_entry(py, FacadeHost::SharedInputError).and_then(|class| class.call1((message,))) { Ok(error) => PyErr::from_value(error), Err(error) => error, } diff --git a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/python_nodes.rs b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/python_nodes.rs index 98a0f8082..8f3a9cb9f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/python_nodes.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/python_nodes.rs @@ -13,11 +13,11 @@ use sqlbuild_core::identifier_text::main::is_lowercase_identifier::is_lowercase_ use sqlbuild_host::entries::models::{FacadeHost, UserCodeHost}; use sqlbuild_model_config::header_metadata::main::json_meta_problem::json_meta_problem; -use crate::bindings::_helpers::boundary::keyword_request::Request; -use crate::bindings::_helpers::boundary::python_calls::imported; use crate::bindings::_helpers::model_config::authored_nodes::PyNode; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const RANDOM_MODULE: &str = "random"; const MAX_ATTEMPTS_TOO_LOW: &str = "RetryPolicy max_attempts must be at least 1"; @@ -37,7 +37,7 @@ const HOOK_READS_INVALID: &str = /// `SharedInputError(message)`. fn shared_input_error(py: Python<'_>, message: &str) -> PyErr { - match host::entry(py, FacadeHost::SharedInputError).and_then(|class| class.call1((message,))) { + match host_entry(py, FacadeHost::SharedInputError).and_then(|class| class.call1((message,))) { Ok(error) => PyErr::from_value(error), Err(error) => error, } @@ -183,7 +183,7 @@ fn validate_audit_case(request: Option<&Bound<'_, PyDict>>) -> Result<(), PyErr> #[pyfunction] fn normalize_hook_reads<'py>(value: &Bound<'py, PyAny>) -> PyResult> { let py: Python<'py> = value.py(); - let reference: Bound<'py, PyAny> = host::entry(py, UserCodeHost::SqlResourceRef)?; + let reference: Bound<'py, PyAny> = host_entry(py, UserCodeHost::SqlResourceRef)?; let reads: Vec> = if value.is_instance(&reference)? { vec![value.clone()] } else { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/sql_values.rs b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/sql_values.rs index dc47daa3e..598c9906c 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/authored_values/sql_values.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/authored_values/sql_values.rs @@ -1,9 +1,5 @@ //! Typed SQL value normalization between Python authored values and native `SqlValue`s. -use crate::bindings::_helpers::records::construct::{new_record, record_class}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::{NativeAttr, RecordId}; -use crate::bindings::_helpers::records::registry; use pyo3::prelude::{ Bound, PyAny, PyAnyMethods, PyErr, PyModule, PyModuleMethods, PyResult, Python, }; @@ -16,6 +12,12 @@ use sqlbuild_core::models::{SqlLogicalType, SqlValue}; use sqlbuild_model_config::sql_values::errors::SqlValueFailure; use sqlbuild_model_config::sql_values::main::normalize_sql_value::normalize_sql_value as normalized; use sqlbuild_model_config::sql_values::models::{RawKey, RawSqlValue, SqlValueLimits}; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::registry::native_attr::native_attr; +use sqlbuild_python_base::records::types::NativeAttr; +use sqlbuild_python_base::records::types::RecordId; /// The Python classes authored values are told apart by and normalized values are built from. pub(crate) struct SqlValueClasses<'py> { @@ -176,7 +178,7 @@ pub(crate) fn sql_value<'py>( pub(crate) fn sql_value_error(py: Python<'_>, failure: SqlValueFailure) -> PyResult { Ok(match failure { SqlValueFailure::Invalid(message) => PyErr::from_value( - registry::native(py, NativeAttr::SqlValueValidationError)?.call1((message,))?, + native_attr(py, NativeAttr::SqlValueValidationError)?.call1((message,))?, ), SqlValueFailure::DecimalOverflow => { let overflow = py.import("decimal")?.getattr("Overflow")?; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/boundary/keyword_request.rs b/crates/sqlbuild-python/src/bindings/_helpers/boundary/keyword_request.rs deleted file mode 100644 index 944c60fca..000000000 --- a/crates/sqlbuild-python/src/bindings/_helpers/boundary/keyword_request.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! Keyword-only native function arguments read from `**request`. - -use pyo3::exceptions::PyTypeError; -use pyo3::prelude::{Bound, PyAny, PyResult, Python}; -use pyo3::types::{PyDict, PyDictMethods}; - -/// Keyword arguments of one call, each required. -pub(crate) struct Request<'a, 'py> { - function: &'static str, - arguments: Option<&'a Bound<'py, PyDict>>, - py: Python<'py>, -} - -impl<'a, 'py> Request<'a, 'py> { - pub(crate) fn new( - function: &'static str, - arguments: Option<&'a Bound<'py, PyDict>>, - ) -> PyResult { - let py: Python<'py> = match arguments { - Some(arguments) => arguments.py(), - None => { - return Err(PyTypeError::new_err(format!( - "{function}() missing required keyword-only arguments" - ))); - } - }; - Ok(Self { - function, - arguments, - py, - }) - } - - pub(crate) fn py(&self) -> Python<'py> { - self.py - } - - pub(crate) fn get(&self, name: &str) -> PyResult> { - let value: Option> = match self.arguments { - Some(arguments) => arguments.get_item(name)?, - None => None, - }; - value.ok_or_else(|| { - PyTypeError::new_err(format!( - "{}() missing 1 required keyword-only argument: '{name}'", - self.function - )) - }) - } - - /// The argument, or `None` when the caller left it out. - pub(crate) fn optional(&self, name: &str) -> PyResult>> { - match self.arguments { - Some(arguments) => arguments.get_item(name), - None => Ok(None), - } - } -} diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/command.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/command.rs index b42d11672..2de90ace5 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/command.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/command.rs @@ -8,7 +8,6 @@ use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_cli::person_login::main::sync_after_build::sync_after_build; use sqlbuild_host::entries::models::{AdapterHost, ExecutorHost, UserCodeHost}; -use crate::bindings::_helpers::boundary::python_calls::{call_with, within}; use crate::bindings::_helpers::build_command::completion::{ complete_direct_build, finalize_exceptional_cost, finalize_no_work_with_timings, record_pending_cost, write_partial_timings, @@ -27,17 +26,19 @@ use crate::bindings::_helpers::discovery::provider_secrets::{ consumer_uses, provider_uses, require_used_secrets, sink_uses, }; use crate::bindings::_helpers::graph::python_node_graph::python_node_graph; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::observations::source_capture::{ arm_source_capture, take_source_capture, }; use crate::bindings::_helpers::recall::console::write_stderr; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; fn run_with_providers(context: &BuildContext<'_>) -> PyResult { let py: Python<'_> = context.py(); let session: Bound<'_, PyAny> = call_with( - &host::entry(py, UserCodeHost::BuildProviderSession)?, + &host_entry(py, UserCodeHost::BuildProviderSession)?, &[( "discovered_providers", context.get("discovered_inputs")?.getattr("providers")?, @@ -61,7 +62,7 @@ fn run_planned_build(context: &BuildContext<'_>, providers: &Bound<'_, PyAny>) - } run_defer_clone_prephase(context)?; let cache_scope: Bound<'_, PyAny> = call_with( - &host::entry(context.py(), AdapterHost::RelationMetadataCacheScope)?, + &host_entry(context.py(), AdapterHost::RelationMetadataCacheScope)?, &[("adapter", context.get("adapter")?)], )?; within(&cache_scope, |_| run_cached_build(context, providers)) @@ -165,7 +166,7 @@ fn run_within_limits( context.worker = worker; let limits: Bound<'_, PyAny> = context.get("execution_limits")?; let deadline: Bound<'_, PyAny> = call_with( - &host::entry(py, ExecutorHost::ExecutionDeadlineScope)?, + &host_entry(py, ExecutorHost::ExecutionDeadlineScope)?, &[ ( "max_duration_seconds", @@ -215,7 +216,7 @@ pub(crate) fn run_build( .and_then(|value| pyo3::Bound::new(py, value)) .map(pyo3::Bound::into_any)?; let reporting: Bound<'_, PyAny> = call_with( - &host::entry(py, ExecutorHost::ProcessResourceReporting)?, + &host_entry(py, ExecutorHost::ProcessResourceReporting)?, &[("enabled", native_field(request, "debug")?)], )?; within(&reporting, |_| { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/completion.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/completion.rs index 9c9b744be..2bfa001e9 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/completion.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/completion.rs @@ -12,7 +12,6 @@ use sqlbuild_core::cli_text::models::CliStyle; use sqlbuild_host::entries::models::ExecutorHost; use sqlbuild_host::models::BuildStatus; -use crate::bindings::_helpers::boundary::python_calls::{call_with, keywords}; use crate::bindings::_helpers::build_command::execution::{ Outcome, Preparation, write_run_context, }; @@ -31,15 +30,17 @@ use crate::bindings::_helpers::cost_report::degradation::{ finalize_build_cost as finalize_cost, render_build_cost, }; use crate::bindings::_helpers::cost_report::functions::cost_output_payload; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::_helpers::result_output::documents::format_build_execution_json; use crate::bindings::_helpers::result_output::documents::format_build_execution_json_with; use crate::bindings::_helpers::result_output::documents::write_execution_json_output; use sqlbuild_core::build_progress::models::PythonNodeText; use sqlbuild_core::check_command::models::{CheckResultText, CheckStatus}; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const SUCCESS_STATUS: &str = "success"; const CHECK_KIND: &str = "check"; @@ -107,7 +108,7 @@ pub(crate) fn finalize_build_cost<'py>( } fn cost_status<'py>(py: Python<'py>, name: &str) -> PyResult> { - host::entry(py, ExecutorHost::CostStatus)?.getattr(name) + host_entry(py, ExecutorHost::CostStatus)?.getattr(name) } /// Record a pending cost state before execution starts. @@ -242,10 +243,10 @@ fn finalize_no_work(context: &BuildContext<'_>, pipeline: &Bound<'_, PyAny>) -> }, )?; let result: Bound<'_, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildExecutionResult)?, + &host_entry(py, ExecutorHost::BuildExecutionResult)?, &[( "status", - host::entry(py, ExecutorHost::BuildStatus)?.getattr("SUCCESS")?, + host_entry(py, ExecutorHost::BuildStatus)?.getattr("SUCCESS")?, )], )?; let payload: Bound<'_, PyAny> = format_build_execution_json( diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/defer_clone.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/defer_clone.rs index 1af60b9f3..4ee06a539 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/defer_clone.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/defer_clone.rs @@ -16,7 +16,6 @@ use sqlbuild_core::graph_walk::models::ClonePolicy; use sqlbuild_core::build_command::errors::BuildCommandError; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::{call_with, keywords}; use crate::bindings::_helpers::build_command::invocation::BuildContext; use crate::bindings::_helpers::build_command::policies::build_command_error; use crate::bindings::_helpers::build_command::policies::enforce_model_execution_limit_binding; @@ -24,14 +23,17 @@ use crate::bindings::_helpers::clone::clone_pipeline::run_clone_pipeline_with_op use crate::bindings::_helpers::compile_driver::project::build_compiled_project; use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config; use crate::bindings::_helpers::dbt_interop::reference_resolver::resolve_external_sql_reference_resolver; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::planner_scope::retained::{ScopeData, scope_data}; use crate::bindings::_helpers::planner_scope::scope::build_planner_scope; use crate::bindings::_helpers::planner_selection::unit_tests::split_unit_test_selectors; -use crate::bindings::_helpers::records::construct::{enum_member, new_record_with}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::replaced; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::replaced::replaced; +use sqlbuild_python_base::records::types::RecordId; const VIEW_MATERIALIZATION: &str = "view"; const RECREATED_TYPES: [&str; 2] = ["udf", "table_fn"]; @@ -210,7 +212,7 @@ fn clone_input<'py>( selected.push(native_field(&entry?, "name")?); } let retention: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildDestinationRetentionRequests)?, + &host_entry(py, ExecutorHost::BuildDestinationRetentionRequests)?, &[ ("project", project.clone()), ( @@ -230,7 +232,7 @@ fn clone_input<'py>( let allow_decrease: bool = native_field(&target, "time_travel_retention_decrease")? .eq(enum_member(py, RecordId::RetentionDecreasePolicy, "ALLOW")?)?; let sources: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::CloneSourceEntries)?, + &host_entry(py, ExecutorHost::CloneSourceEntries)?, &[ ("origin", native_field(pipeline, "origin_source_entries")?), ( @@ -240,7 +242,7 @@ fn clone_input<'py>( ], )?; call_with( - &host::entry(py, ExecutorHost::CloneExecutionInput)?, + &host_entry(py, ExecutorHost::CloneExecutionInput)?, &[ ("source_entries", sources), ( @@ -275,7 +277,7 @@ fn clone_input<'py>( ( "destination_transient_models", call_with( - &host::entry(py, ExecutorHost::BuildDestinationTransientModels)?, + &host_entry(py, ExecutorHost::BuildDestinationTransientModels)?, &[("project", project.clone())], )?, ), @@ -297,7 +299,7 @@ fn executed_clone<'py>( ) -> PyResult> { let py: Python<'py> = context.py(); let progress_stream: Bound<'py, PyAny> = native_field(&context.invocation, "progress_stream")?; - let execute: Bound<'py, PyAny> = host::entry(py, ExecutorHost::ExecuteClone)?; + let execute: Bound<'py, PyAny> = host_entry(py, ExecutorHost::ExecuteClone)?; if progress_stream.is_none() { let inputs: Bound<'py, PyAny> = clone_input( context, @@ -335,7 +337,7 @@ fn executed_clone<'py>( }, )?; call_with( - &host::entry(py, ExecutorHost::RunPrephaseCloneStream)?, + &host_entry(py, ExecutorHost::RunPrephaseCloneStream)?, &[ ("stream", progress_stream), ("title", text(py, "defer clone")), @@ -348,7 +350,7 @@ fn executed_clone<'py>( fn failed_items(result: &Bound<'_, PyAny>) -> PyResult> { let py: Python<'_> = result.py(); - let status: Bound<'_, PyAny> = host::entry(py, ExecutorHost::CloneStatus)?; + let status: Bound<'_, PyAny> = host_entry(py, ExecutorHost::CloneStatus)?; let (failed, warning) = ( native_field(&status, "FAILED")?, native_field(&status, "WARNING")?, @@ -450,7 +452,7 @@ fn clone_boundaries<'py>( } let project: Bound<'py, PyAny> = native_field(&pipeline, "destination_project")?; call_with( - &host::entry(py, ExecutorHost::CopyCloneFingerprints)?, + &host_entry(py, ExecutorHost::CopyCloneFingerprints)?, &[ ("result", result), ( diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/execution.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/execution.rs index 34e0873df..4cebbd294 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/execution.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/execution.rs @@ -11,7 +11,6 @@ use sqlbuild_core::cli_text::models::CliStyle; use sqlbuild_host::entries::models::ExecutorHost; use sqlbuild_host::models::{BuildExecutionResult, BuildStatus, ExecutionStatus}; -use crate::bindings::_helpers::boundary::python_calls::{call_with, keywords, within}; use crate::bindings::_helpers::build_command::invocation::BuildContext; use crate::bindings::_helpers::build_command::lifecycle::{ DirectPythonLifecycle, LifecycleInputs, prepare_direct_python_lifecycle, @@ -40,16 +39,19 @@ use crate::bindings::_helpers::cursor::overrides::{cursor_integer, cursor_timest use crate::bindings::_helpers::freshness::publication::append_freshness_records; use crate::bindings::_helpers::graph::python_node_graph::python_node_graph; use crate::bindings::_helpers::native_host::consumption_state::recorder_callbacks; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::native_host::results::ReadResult; use crate::bindings::_helpers::observations::publication::append_build_observations; use crate::bindings::_helpers::planner_resolution::cursor_overrides::type_cursor_overrides; -use crate::bindings::_helpers::records::construct::new_record; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::_helpers::sql_test_command::test_command::timeout_record; use crate::bindings::_helpers::sql_test_command::timeouts::{TimeoutKind, resolve_run_timeout}; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::types::RecordId; use sqlbuild_state::consumption::models::ChangedPolicy; const EXECUTION_COMMAND: &str = "sqb build"; @@ -321,7 +323,7 @@ pub(crate) fn execute_build_plan<'py>( let [start_ts, end_ts, start_int, end_int] = &preparation.cursors; let request = |name: &str| native_field(&context.request, name); let runtime: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildRuntimeParams)?, + &host_entry(py, ExecutorHost::BuildRuntimeParams)?, &[ ("run_id", native_field(&project, "run_id")?), ( @@ -396,7 +398,7 @@ pub(crate) fn execute_build_plan<'py>( let (on_node_complete, before_node_write) = recorder_callbacks(recorder.as_any())?; let connection: &Bound<'py, PyAny> = &preparation.connection_progress; let build_callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildCallbacks)?, + &host_entry(py, ExecutorHost::BuildCallbacks)?, &[ ("on_migration_progress", line_writer(&context.stream)?), ( @@ -439,7 +441,7 @@ pub(crate) fn execute_build_plan<'py>( ], )?; let customizations: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildCustomizations)?, + &host_entry(py, ExecutorHost::BuildCustomizations)?, &[ ( "custom_materializations", @@ -449,7 +451,7 @@ pub(crate) fn execute_build_plan<'py>( ], )?; let initial_state: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildInitialState)?, + &host_entry(py, ExecutorHost::BuildInitialState)?, &[ ( "precompleted_keys", @@ -460,7 +462,7 @@ pub(crate) fn execute_build_plan<'py>( ], )?; let result: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::RunBuildPipeline)?, + &host_entry(py, ExecutorHost::RunBuildPipeline)?, &[ ("plan", plan.clone()), ("connection_config", connection_config.clone()), @@ -612,7 +614,7 @@ fn check_runtime<'py>( .map(|check| native_field(check, "name")) .collect::>()?; call_with( - &host::entry(py, ExecutorHost::PythonNodeRuntime)?, + &host_entry(py, ExecutorHost::PythonNodeRuntime)?, &[ ("adapter", adapter.clone()), ("connection_config", context.get("connection_config")?), @@ -719,7 +721,7 @@ pub(crate) fn run_post_build_python_checks<'py>( adapter.call_method1("connect", (context.get("connection_config")?,))?; let executed: PyResult> = (|| { let run_state: Bound<'py, PyAny> = - host::entry(py, ExecutorHost::PythonNodeRunState)?.call0()?; + host_entry(py, ExecutorHost::PythonNodeRunState)?.call0()?; record_python_run_state_results( &discovered, &run_state, @@ -727,7 +729,7 @@ pub(crate) fn run_post_build_python_checks<'py>( Some(&native_field(&plan, "source_map")?), )?; let callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::PythonCheckCallbacks)?, + &host_entry(py, ExecutorHost::PythonCheckCallbacks)?, &[ ( "on_check_start", @@ -740,7 +742,7 @@ pub(crate) fn run_post_build_python_checks<'py>( ], )?; call_with( - &host::entry(py, ExecutorHost::ExecutePythonChecks)?, + &host_entry(py, ExecutorHost::ExecutePythonChecks)?, &[ ("check_functions", tuple(py, &checks)?), ("python_graph", graph.clone()), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/invocation.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/invocation.rs index 2f6d753cc..cff18feb3 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/invocation.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/invocation.rs @@ -9,8 +9,6 @@ use sqlbuild_core::build_command::errors::BuildCommandError; use sqlbuild_core::build_command::main::duration_limit_error::duration_limit_error; use sqlbuild_core::build_command::models::DurationLimit; -use crate::bindings::_helpers::boundary::python_calls::imported; -use crate::bindings::_helpers::boundary::python_calls::keywords; use crate::bindings::_helpers::build_command::policies::build_command_error; use crate::bindings::_helpers::build_command::support::{boolean, or_none, text}; use crate::bindings::_helpers::build_progress::progress_reporters::ConnectionProgressReporter; @@ -26,9 +24,12 @@ use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_name; use crate::bindings::_helpers::discovery::provider_secrets::SecretPolicy; use crate::bindings::_helpers::presentation_text::terminal::stdout_supports_color; -use crate::bindings::_helpers::records::construct::{new_record, new_record_with}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const DEFER_CONFLICT_CODE: &str = "C408"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/lifecycle.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/lifecycle.rs index 6f9e9476c..c0b39e6e8 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/lifecycle.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/lifecycle.rs @@ -12,7 +12,6 @@ use sqlbuild_core::build_command::models::PythonNodeRow; use sqlbuild_core::cli_text::models::CliStyle; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported, keywords}; use crate::bindings::_helpers::build_command::support::{ boolean, emit, frozenset, or_none, text, tuple, }; @@ -20,12 +19,16 @@ use crate::bindings::_helpers::compile_driver::relation_targets::build_project_r use crate::bindings::_helpers::compile_driver::relation_targets::build_python_relation_targets; use crate::bindings::_helpers::graph::python_lifecycle::build_python_sql_run_lifecycle; use crate::bindings::_helpers::graph::python_node_graph::python_node_graph; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::planner_scope::loaders::build_intermediate_source_map; -use crate::bindings::_helpers::records::construct::{enum_member, new_record_with}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::replaced_keywords; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::replaced_keywords::replaced_keywords; +use sqlbuild_python_base::records::types::RecordId; const SUCCESS_STATUS: &str = "success"; @@ -264,7 +267,7 @@ fn node_runtime<'py>( let py: Python<'py> = connection.py(); let [start_ts, end_ts, start_int, end_int] = &parts.inputs.cursors; call_with( - &host::entry(py, ExecutorHost::PythonNodeRuntime)?, + &host_entry(py, ExecutorHost::PythonNodeRuntime)?, &[ ("adapter", parts.adapter.clone()), ("connection_config", parts.connection_config.clone()), @@ -445,7 +448,7 @@ pub(crate) fn prepare_direct_python_lifecycle<'py>( adapter.call_method1("connect", (connection_config.clone(),))?; let executed: PyResult> = (|| { let callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::IngressCallbacks)?, + &host_entry(py, ExecutorHost::IngressCallbacks)?, &[ ("use_color", boolean(py, context.use_color)), ("on_node_start", inputs.on_node_start.clone()), @@ -453,7 +456,7 @@ pub(crate) fn prepare_direct_python_lifecycle<'py>( ], )?; call_with( - &host::entry(py, ExecutorHost::RunIngressPythonLoaderNodes)?, + &host_entry(py, ExecutorHost::RunIngressPythonLoaderNodes)?, &[ ("python_graph", lifecycle.graph.clone()), ("selected_python_names", ingress_names.clone()), @@ -495,7 +498,7 @@ pub(crate) fn prepare_direct_python_lifecycle<'py>( } let scheduled: Vec = scheduled.into_iter().collect(); let tracker: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::CreateReadSidePythonExecutionTracker)?, + &host_entry(py, ExecutorHost::CreateReadSidePythonExecutionTracker)?, &[ ("python_graph", lifecycle.graph.clone()), ("selected_python_names", names_set(py, &read_side)?), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/planning.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/planning.rs index 19dec1b29..1b9feaae1 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/planning.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/planning.rs @@ -8,7 +8,6 @@ use sqlbuild_core::build_command::constants::{ use sqlbuild_core::build_command::models::PlanSafetyGates; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::{call_with, keywords}; use crate::bindings::_helpers::build_command::defer_clone::run_defer_clone_boundary_prephase; use crate::bindings::_helpers::build_command::invocation::BuildContext; use crate::bindings::_helpers::build_command::policies::{enforce_plan_policies, model_limit}; @@ -19,11 +18,13 @@ use crate::bindings::_helpers::build_progress::progress_text::with_verbose_inspe use crate::bindings::_helpers::compile_driver::plan_pipeline::run_compile_pipeline; use crate::bindings::_helpers::dbt_interop::reference_resolver::resolve_external_sql_reference_resolver; use crate::bindings::_helpers::manifest::builder::build_manifest; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::plan_output::plan_text::format_plan; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const CONNECTION_TIMING: [&str; 2] = ["connection_count", "elapsed_seconds"]; @@ -84,7 +85,7 @@ pub(crate) fn compile_build_plan<'py>(context: &BuildContext<'py>) -> PyResult = context.get("connection_progress")?; let hooks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::ConnectionHooks)?, + &host_entry(py, ExecutorHost::ConnectionHooks)?, &[ ( "on_progress", diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/policies.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/policies.rs index e00364441..e4498db77 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/policies.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/policies.rs @@ -16,10 +16,10 @@ use sqlbuild_core::build_command::models::{ TableTypeFact, }; -use crate::bindings::_helpers::boundary::python_calls::KeywordArguments; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; const SNAPSHOT_VALUE: &str = "snapshot"; const FULL_REFRESH_REASON: &str = "full_refresh"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_command/support.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_command/support.rs index 2f888513f..840b51bdf 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_command/support.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_command/support.rs @@ -6,7 +6,7 @@ use pyo3::types::{ }; use pyo3::{IntoPyObject, pyclass, pymethods}; -use crate::bindings::_helpers::boundary::python_calls::imported; +use sqlbuild_python_base::boundary::main::imported::imported; const DATETIME_MODULE: &str = "datetime"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/audit_progress.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/audit_progress.rs index c00bddbda..f093ac4b7 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/audit_progress.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/audit_progress.rs @@ -16,13 +16,14 @@ use sqlbuild_core::nested_progress::main::render_audit_row::render_audit_row; use sqlbuild_core::nested_progress::main::render_group_header::render_group_header; use sqlbuild_core::nested_progress::models::AuditAggregate; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, within}; use crate::bindings::_helpers::build_progress::result_text::{audit_text, optional, text}; use crate::bindings::_helpers::build_progress::terminal::{ CLEAR_LINE, HIDE_CURSOR, SHOW_CURSOR, claim, consume_terminal, flush, projector, release, shared_lines, tty_flag, write, }; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::fields::field::field as native_field; /// The identity an audit plan entry or result reports to the progress projector. fn resource_id(value: &Bound<'_, PyAny>, name_field: &str) -> PyResult { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/build_callbacks.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/build_callbacks.rs index 86948474e..15f456c54 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/build_callbacks.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/build_callbacks.rs @@ -21,7 +21,6 @@ use sqlbuild_core::build_progress::models::{ }; use sqlbuild_core::cli_text::models::CliStyle; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, imported, within}; use crate::bindings::_helpers::build_progress::plan_facts::{BuildPlanFacts, build_plan_facts}; use crate::bindings::_helpers::build_progress::result_text::{ function_text, load_text, model_text, optional, seed_text, test_text, text, @@ -32,9 +31,12 @@ use crate::bindings::_helpers::build_progress::terminal::{ terminal_columns, tty_flag, write, }; use crate::bindings::_helpers::compiled_project::snapshot_execution::WorkerBuild; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::replaced_keywords; use crate::bindings::_helpers::result_output::event_writer::ExecutionEventWriter; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::replaced_keywords::replaced_keywords; const RUNTIME_LOGGER: &str = "sqlbuild.executor.runtime"; const PASS_OUTCOME: &str = "pass"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/getters.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/getters.rs index d399ac6fa..40ac4d028 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/getters.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/getters.rs @@ -5,8 +5,8 @@ use pyo3::prelude::{Bound, PyAny, PyResult, Python}; use crate::bindings::_helpers::build_progress::build_callbacks::BuildProgressCallbacks; use crate::bindings::_helpers::build_progress::transient_lines::TransientLineCoordinator; -use crate::bindings::_helpers::records::getters::class_of; -use crate::bindings::_helpers::records::models::GetterEntry; +use sqlbuild_python_base::records::main::registry::class_of::class_of; +use sqlbuild_python_base::records::models::GetterEntry; /// The getter readers of this module's native pyclasses. pub(crate) const GETTERS: &[GetterEntry] = &[ diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/nested_progress.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/nested_progress.rs index 3a812ed3e..3bd9549f2 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/nested_progress.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/nested_progress.rs @@ -12,14 +12,15 @@ use sqlbuild_core::nested_progress::main::render_nested_item::render_nested_item use sqlbuild_core::nested_progress::main::render_nested_spinner_line::render_nested_spinner_line; use sqlbuild_core::nested_progress::models::{NestedChildRow, NestedItem, NestedLayout}; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, within}; use crate::bindings::_helpers::build_progress::result_text::text; use crate::bindings::_helpers::build_progress::terminal::{ CLEAR_LINE, HIDE_CURSOR, SHOW_CURSOR, SPINNER_FRAMES, SPINNER_TICK_SECONDS, claim, consume_terminal, flush, join_spinner, projector, release, shared_lines, start_spinner, terminal_columns, tty_flag, write, }; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const MIN_NAME_WIDTH: usize = 50; const ITEM_OPTIONS: (&[&str], &[&str]) = ( diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/plan_facts.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/plan_facts.rs index cc4f34a53..625fb38bf 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/plan_facts.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/plan_facts.rs @@ -11,7 +11,7 @@ use sqlbuild_core::plan_display::models::ModelLabelFacts; use crate::bindings::_helpers::build_progress::result_text::text; use crate::bindings::_helpers::plan_output::display::optional_facts; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const SOURCE_TYPE: &str = "source"; const SQL_TEST_TYPE: &str = "sql_test"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress.rs index f9ea84f47..02db6f3d9 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress.rs @@ -17,12 +17,12 @@ use sqlbuild_core::progress::models::{ }; use sqlbuild_core::terminal_events::models::TerminalRequest; -use crate::bindings::_helpers::boundary::python_calls::KeywordArguments; use crate::bindings::_helpers::build_progress::transient_lines::shared_transient_line_coordinator; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::fields::mapping_get_or; -use crate::bindings::_helpers::records::fields::mapping_items; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::main::fields::mapping_get_or::mapping_get_or; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; /// The module attribute holding the `ContextVar` of the installed projector. const CONTEXT_ATTRIBUTE: &str = "_native_progress_projector_context"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_reporters.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_reporters.rs index 960ac92d6..196f6b43f 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_reporters.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_reporters.rs @@ -13,11 +13,11 @@ use sqlbuild_core::progress::main::connection_start_message::connection_start_me use sqlbuild_core::progress::main::is_planning_completion_message::is_planning_completion_message; use sqlbuild_core::progress::main::is_planning_failure_message::is_planning_failure_message; -use crate::bindings::_helpers::boundary::python_calls::KeywordArguments; use crate::bindings::_helpers::build_progress::progress::{ NativeProgressProjector, current_projector, projector_operation_active, write_persistent, }; use crate::bindings::_helpers::build_progress::transient_status::status_reporter; +use sqlbuild_python_base::boundary::models::KeywordArguments; const CONNECTION_OPTIONS: (&[&str], &[&str]) = ( &["adapter_name", "stream"], diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_text.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_text.rs index 239ebba85..31f51f91c 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_text.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/progress_text.rs @@ -16,10 +16,11 @@ use sqlbuild_core::progress::models::{ExpectationStep, InspectionRecord}; use sqlbuild_core::progress::types::DifferenceSample; use sqlbuild_host::entries::models::AdapterHost; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, within}; use crate::bindings::_helpers::build_progress::progress::write_persistent; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const HEADER_OPTIONS: (&[&str], &[&str]) = ( &["stream", "command", "target", "concurrency", "use_color"], @@ -182,7 +183,7 @@ pub(crate) fn with_verbose_inspection<'py, T>( } let writer: Bound<'py, VerboseInspectionWriter> = Bound::new(py, VerboseInspectionWriter::new())?; - let sink: Bound<'py, PyAny> = host::entry(py, AdapterHost::InspectionQuerySink)? + let sink: Bound<'py, PyAny> = host_entry(py, AdapterHost::InspectionQuerySink)? .call1((native_field(&writer, "write")?,))?; let value: T = within(&sink, |_| body())?; writer.get().write_total(py)?; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/result_text.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/result_text.rs index f3d9ab4df..80649ee35 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/result_text.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/result_text.rs @@ -27,8 +27,8 @@ use sqlbuild_host::types::ResultEnum; use crate::bindings::_helpers::native_host::results::ReadResult; use crate::bindings::_helpers::plan_output::display::{cursor_bound_display, inclusive_cursor_end}; -use crate::bindings::_helpers::records::fields::field as native_field; use crate::bindings::_helpers::result_output::integration_values::json_value; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const DECIMAL_KIND: &str = "decimal"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/terminal.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/terminal.rs index 4e2dc1051..f71692995 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/terminal.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/terminal.rs @@ -4,10 +4,11 @@ use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyModule, PyModuleMethods, P use pyo3::types::{PyBool, PyDict, PyDictMethods, PyTuple}; use pyo3::{IntoPyObjectExt, pyfunction, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported}; use crate::bindings::_helpers::build_progress::progress::current_native_progress_projector; use crate::bindings::_helpers::build_progress::transient_lines::shared_coordinator; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const DEFAULT_TERMINAL_SIZE: (i64, i64) = (120, 24); const SPINNER_JOIN_SECONDS: f64 = 0.2; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_lines.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_lines.rs index 5bb373c56..f0d7ca70d 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_lines.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_lines.rs @@ -6,8 +6,8 @@ use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyModule, PyModuleMethods, P use pyo3::sync::PyOnceLock; use pyo3::{pyclass, pyfunction, pymethods, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::python_calls::imported; use crate::bindings::_helpers::build_progress::terminal::tty_flag; +use sqlbuild_python_base::boundary::main::imported::imported; /// The stream a transient line is drawn on and the renderer that owns it. type ActiveLine = (Py, Py); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_status.rs b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_status.rs index 1ceaa66c6..06e35b6b1 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_status.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/build_progress/transient_status.rs @@ -10,12 +10,13 @@ use pyo3::{pyclass, pymethods}; use sqlbuild_core::cli_text::models::CliStyle; use sqlbuild_core::progress::main::format_status_spinner_line::format_status_spinner_line; -use crate::bindings::_helpers::boundary::python_calls::{imported, within}; use crate::bindings::_helpers::build_progress::terminal::{ CLEAR_LINE, HIDE_CURSOR, SHOW_CURSOR, SPINNER_FRAMES, SPINNER_TICK_SECONDS, claim, flush, join_spinner, release, shared_lines, start_spinner, terminal_columns, tty_flag, write, }; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const NO_PROGRESS_VARIABLE: &str = "SQLBUILD_NO_PROGRESS"; const PROGRESS_DISABLED_VALUES: [&str; 4] = ["1", "on", "true", "yes"]; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cache/native_store.rs b/crates/sqlbuild-python/src/bindings/_helpers/cache/native_store.rs index ea7afd7c2..5922e3308 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cache/native_store.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cache/native_store.rs @@ -18,10 +18,10 @@ use sqlbuild_host::entries::models::FacadeHost; use std::collections::HashSet; use std::path::{Path, PathBuf}; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::ids::NativeAttr; -use crate::bindings::_helpers::records::registry; -use crate::bindings::types::CompilerDetach; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::registry::native_attr::native_attr; +use sqlbuild_python_base::records::types::NativeAttr; +use sqlbuild_python_base::types::CompilerDetach; /// Hexadecimal digest of length-prefixed UTF-8 `parts`, the digest every native cache key uses. #[pyfunction] @@ -93,13 +93,13 @@ pub(crate) fn save_store( pub(crate) fn compiled_code_identity(py: Python<'_>) -> PyResult { static INSTALLED: PyOnceLock = PyOnceLock::new(); let installed: &String = INSTALLED.get_or_try_init(py, || installed_identity(py))?; - let build_identity: String = registry::native(py, NativeAttr::BuildIdentity)?.extract()?; + let build_identity: String = native_attr(py, NativeAttr::BuildIdentity)?.extract()?; Ok(compiled(installed, &build_identity)) } /// `compiled_code_identity`, looked up on the extension module so tests can replace it. pub(crate) fn current_code_identity(py: Python<'_>) -> PyResult { - registry::native(py, NativeAttr::CompiledCodeIdentity)? + native_attr(py, NativeAttr::CompiledCodeIdentity)? .call0()? .extract() } @@ -126,7 +126,7 @@ fn installed_identity(py: Python<'_>) -> PyResult { .getattr("minor")? .extract()?, ); - let package_file: PathBuf = host::entry(py, FacadeHost::PackageFile)?.extract()?; + let package_file: PathBuf = host_entry(py, FacadeHost::PackageFile)?.extract()?; let (mut facts, editable) = py .compiler_detach(|| Ok(installed_code_facts(&search_paths))) .map_err(PyRuntimeError::new_err)?; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cache/sql_test_scan_store.rs b/crates/sqlbuild-python/src/bindings/_helpers/cache/sql_test_scan_store.rs index 54f165e95..18a1fc6af 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cache/sql_test_scan_store.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cache/sql_test_scan_store.rs @@ -12,9 +12,9 @@ use std::path::PathBuf; use std::sync::Mutex; use std::sync::atomic::{AtomicUsize, Ordering}; -use crate::bindings::_helpers::boundary::python_calls::imported; use crate::bindings::_helpers::cache::native_store::current_code_identity; use crate::bindings::_helpers::cache::native_store::{open_store, save_store}; +use sqlbuild_python_base::boundary::main::imported::imported; const SCAN_CACHE_LOGGER: &str = "sqlbuild.compile"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/base_compile.rs b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/base_compile.rs index 9dfb3aa2a..16a825131 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/base_compile.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/base_compile.rs @@ -10,15 +10,16 @@ use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_analysis::definition_changes::main::definition_snapshot_json::definition_snapshot_json; use sqlbuild_analysis::definition_changes::models::DefinitionSnapshot; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, keywords}; use crate::bindings::_helpers::change_selection::definition_snapshot::definition_snapshot; use crate::bindings::_helpers::command_runtime::invocation::resolve_adapter_connection_context; use crate::bindings::_helpers::compile_driver::discovery::discover_project_inputs; use crate::bindings::_helpers::compile_driver::pipeline_entries::run_compile_only_pipeline; use crate::bindings::_helpers::dbt_interop::reference_resolver::resolve_external_sql_reference_resolver; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; /// The extension of the file beside the snapshot that holds notes for the run's output. pub(crate) const NOTES_EXTENSION: &str = "notes"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/definition_snapshot.rs b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/definition_snapshot.rs index 7d6bb016f..34b76fdc5 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/definition_snapshot.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/definition_snapshot.rs @@ -27,7 +27,7 @@ use crate::bindings::_helpers::compiled_views::project_reads; use crate::bindings::_helpers::compiled_views::seed_reads; use crate::bindings::_helpers::compiled_views::source_reads; use crate::bindings::_helpers::planner_identity::metadata::{function_local_hashes, seed_identity}; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::records::main::fields::field::field as native_field; /// Header values that rename rather than redefine a model. const RENAME_CONFIG_KEYS: [&str; 2] = ["migrate_from", "description"]; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/fingerprints.rs b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/fingerprints.rs index 8d983c663..7418a11e9 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/fingerprints.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/fingerprints.rs @@ -13,7 +13,7 @@ use serde_json::{Map, Value}; use sqlbuild_analysis::definition_changes::main::definition_digest::definition_digest; use sqlbuild_pysource::rule_evidence::main::project_import_closure::project_import_closure; -use crate::bindings::_helpers::records::models::NativeRecord; +use sqlbuild_python_base::records::models::NativeRecord; /// Fields that document a definition without changing what it does. const DOCUMENTATION_FIELDS: [&str; 2] = ["description", "location"]; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/selection.rs b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/selection.rs index 33a5191ef..84f252a61 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/change_selection/selection.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/change_selection/selection.rs @@ -30,8 +30,8 @@ use crate::bindings::_helpers::compiled_views::model_reads; use crate::bindings::_helpers::compiled_views::project_reads; use crate::bindings::_helpers::graph::keys::native_key; use crate::bindings::_helpers::planner_scenario::graph::plan_scenario_graph; -use crate::bindings::_helpers::records::fields::field as native_field; use crate::bindings::_helpers::scenario_command::setup::{flush, write}; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const MACRO_TEST_MODE: &str = "macro"; /// The JSON document key of the changes and selection of a `--since` run. diff --git a/crates/sqlbuild-python/src/bindings/_helpers/check/check_command.rs b/crates/sqlbuild-python/src/bindings/_helpers/check/check_command.rs index ce9feea89..7fa6cb52d 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/check/check_command.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/check/check_command.rs @@ -2,7 +2,6 @@ use sqlbuild_host::entries::models::{ExecutorHost, UserCodeHost}; -use crate::bindings::_helpers::boundary::python_calls::keywords; use crate::bindings::_helpers::build_progress::progress::current_native_progress_projector; use crate::bindings::_helpers::build_progress::progress_text::write_execution_header; use crate::bindings::_helpers::compile_driver::pipeline_entries::build_static_pipeline_result; @@ -21,7 +20,6 @@ use crate::bindings::_helpers::planner_entries::command_plans::build_relation_co use crate::bindings::_helpers::planner_phases::objects::object; use crate::bindings::_helpers::planner_selection::selectors::parse_project_selector; use crate::bindings::_helpers::planner_selection::unit_tests::reject_unit_test_selectors; -use crate::bindings::_helpers::records::construct::{enum_member, new_record_with, record_class}; use crate::bindings::_helpers::result_output::documents::write_execution_json_output; use pyo3::prelude::{ Bound, Py, PyAny, PyAnyMethods, PyErr, PyModule, PyModuleMethods, PyResult, Python, @@ -34,8 +32,11 @@ use sqlbuild_core::check_command::main::render_check_summary::render_check_summa use sqlbuild_core::check_command::main::validate_check_selection::validate_check_selection; use sqlbuild_core::check_command::models::CheckResultText; use sqlbuild_core::cli_text::models::CliStyle; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::construct::record_class::record_class; -use crate::bindings::_helpers::boundary::python_calls::call_with; use crate::bindings::_helpers::check::check_core::{ ReadSideInputs, load_results_by_loader_name, record_python_run_state_results, run_read_side_dependencies, @@ -47,11 +48,13 @@ use crate::bindings::_helpers::command_runtime::invocation::resolve_reported_com use crate::bindings::_helpers::compile_outputs::runtime_target::write_python_check_runtime_target; use crate::bindings::_helpers::graph::python_node_graph::python_node_graph; use crate::bindings::_helpers::graph::python_selection::python_node_names; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::{ErrorId, RecordId}; use crate::bindings::_helpers::result_output::event_writer::ExecutionEventWriter; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; +use sqlbuild_python_base::records::types::RecordId; const GRAPH_OPERATOR_CODE: &str = "C681"; const GRAPH_OPERATOR_MESSAGE: &str = "sqb check selectors do not support graph operators; \ @@ -143,7 +146,7 @@ fn selected_check_names<'py>( .collect::>()?; refuse_graph_selectors(py, &selectors)?; let check_kind: Bound<'py, PyAny> = - host::entry(py, UserCodeHost::PythonNodeKind)?.getattr("CHECK")?; + host_entry(py, UserCodeHost::PythonNodeKind)?.getattr("CHECK")?; if select.is_truthy()? { let selected: Bound<'py, PyAny> = python_nodes(graph, (select, exclude))?; let mut non_checks: Vec = Vec::new(); @@ -194,7 +197,7 @@ fn compile_pipeline<'py>( )?, )?; let loader_kind: Bound<'py, PyAny> = - host::entry(py, UserCodeHost::PythonNodeKind)?.getattr("LOADER")?; + host_entry(py, UserCodeHost::PythonNodeKind)?.getattr("LOADER")?; let mut loaders: Vec> = Vec::new(); for name in closure.try_iter()? { let name: Bound<'py, PyAny> = name?; @@ -410,7 +413,7 @@ fn node_runtime<'py>( fields.push(("project_relations", prepared.project_relations.clone())); } fields.push(("providers", providers.clone())); - call_with(&host::entry(py, ExecutorHost::PythonNodeRuntime)?, &fields) + call_with(&host_entry(py, ExecutorHost::PythonNodeRuntime)?, &fields) } fn record_run_state<'py>( @@ -444,11 +447,11 @@ fn run_checks<'py>( let plan_output: Bound<'py, PyAny> = native_field(&prepared.pipeline, "plan_output")?; let source_map: Bound<'py, PyAny> = native_field(&plan_output, "source_map")?; let callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::IngressCallbacks)?, + &host_entry(py, ExecutorHost::IngressCallbacks)?, &[("use_color", native_field(invocation, "use_color")?)], )?; let ingress: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::ExecuteIngressPythonLoaderNodes)?, + &host_entry(py, ExecutorHost::ExecuteIngressPythonLoaderNodes)?, &[ ("python_graph", prepared.python_graph.clone()), ( @@ -511,11 +514,11 @@ fn run_checks<'py>( )? .into_any(); let check_callbacks: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::PythonCheckCallbacks)?, + &host_entry(py, ExecutorHost::PythonCheckCallbacks)?, &[("on_check_complete", on_complete)], )?; call_with( - &host::entry(py, ExecutorHost::ExecutePythonChecks)?, + &host_entry(py, ExecutorHost::ExecutePythonChecks)?, &[ ("check_functions", prepared.check_functions.clone()), ("python_graph", prepared.python_graph.clone()), @@ -669,7 +672,7 @@ pub(crate) fn run_check_command(py: Python<'_>, request: &Bound<'_, PyAny>) -> P uses.extend(sink_uses(&discovered)?); require_used_secrets(&discovered, &uses)?; let session: Bound<'_, PyAny> = call_with( - &host::entry(py, UserCodeHost::BuildProviderSession)?, + &host_entry(py, UserCodeHost::BuildProviderSession)?, &[( "discovered_providers", native_field(&invocation, "discovered_inputs")?.getattr("providers")?, diff --git a/crates/sqlbuild-python/src/bindings/_helpers/check/check_core.rs b/crates/sqlbuild-python/src/bindings/_helpers/check/check_core.rs index 2f64d0e6d..15d690312 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/check/check_core.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/check/check_core.rs @@ -2,7 +2,6 @@ use sqlbuild_host::entries::models::{AdapterHost, ExecutorHost, UserCodeHost}; -use crate::bindings::_helpers::boundary::python_calls::keywords; use crate::bindings::_helpers::compile_driver::relation_targets::build_python_relation_targets; use crate::bindings::_helpers::graph::python_selection::resolve_python_check_excludes; use crate::bindings::_helpers::planner_phases::objects::object; @@ -12,16 +11,18 @@ use pyo3::prelude::{ }; use pyo3::types::{PyDict, PyDictMethods, PyFrozenSet, PyFrozenSetMethods, PyTuple}; use pyo3::{pyfunction, wrap_pyfunction}; +use sqlbuild_python_base::boundary::main::keywords::keywords; use sqlbuild_core::build_command::errors::BuildCommandError; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, call_with}; use crate::bindings::_helpers::build_command::policies::build_command_error; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::fields::mapping_get_or; -use crate::bindings::_helpers::records::fields::mapping_items; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::main::fields::mapping_get_or::mapping_get_or; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; const MISSING_RELATION_CODE: &str = "C682"; const MODEL_KIND: &str = "model"; @@ -57,8 +58,8 @@ fn load_result_as_python_result<'py>( result: &Bound<'py, PyAny>, ) -> PyResult> { let py: Python<'py> = name.py(); - let execution: Bound<'py, PyAny> = host::entry(py, ExecutorHost::ExecutionStatus)?; - let node_status: Bound<'py, PyAny> = host::entry(py, UserCodeHost::PythonNodeStatus)?; + let execution: Bound<'py, PyAny> = host_entry(py, ExecutorHost::ExecutionStatus)?; + let node_status: Bound<'py, PyAny> = host_entry(py, UserCodeHost::PythonNodeStatus)?; let status: Bound<'py, PyAny> = native_field(result, "status")?; let mapped: Bound<'py, PyAny> = if status.eq(native_field(&execution, "SUCCESS")?)? { native_field(&node_status, "SUCCESS")? @@ -68,12 +69,12 @@ fn load_result_as_python_result<'py>( native_field(&node_status, "FAILED")? }; call_with( - &host::entry(py, ExecutorHost::PythonNodeExecutionResult)?, + &host_entry(py, ExecutorHost::PythonNodeExecutionResult)?, &[ ("node_name", name.clone()), ( "kind", - host::entry(py, UserCodeHost::PythonNodeKind)?.getattr("LOADER")?, + host_entry(py, UserCodeHost::PythonNodeKind)?.getattr("LOADER")?, ), ("status", mapped), ("payload", result.clone()), @@ -208,7 +209,7 @@ pub(crate) fn relevant_check_functions<'py>( resolve_python_check_excludes(python_graph, exclude.extract::>()?)?, )?; let check_kind: Bound<'py, PyAny> = - host::entry(py, UserCodeHost::PythonNodeKind)?.getattr("CHECK")?; + host_entry(py, UserCodeHost::PythonNodeKind)?.getattr("CHECK")?; let upstream_deps: Bound<'py, PyAny> = native_field(python_graph, "upstream_deps")?; let mut check_names: Vec> = Vec::new(); for node in native_field(python_graph, "nodes")?.try_iter()? { @@ -377,7 +378,7 @@ fn validate_reference_exists( ), )?; let relation: Bound<'_, PyAny> = call_with( - &host::entry(py, AdapterHost::ResolveRelationLocationQualifiedName)?, + &host_entry(py, AdapterHost::ResolveRelationLocationQualifiedName)?, &[("adapter", inputs.adapter.clone()), ("location", location)], )?; (exists, relation) @@ -444,7 +445,7 @@ fn node_runtime<'py>(inputs: &ReadSideInputs<'py>) -> PyResult let py: Python<'py> = inputs.adapter.py(); let project: Bound<'py, PyAny> = native_field(&inputs.pipeline_result, "project")?; call_with( - &host::entry(py, ExecutorHost::PythonNodeRuntime)?, + &host_entry(py, ExecutorHost::PythonNodeRuntime)?, &[ ("adapter", inputs.adapter.clone()), ("connection_config", inputs.connection_config.clone()), @@ -489,7 +490,7 @@ pub(crate) fn run_read_side_dependencies<'py>( } } let lookup: Bound<'py, PyAny> = call_with( - &host::entry(py, AdapterHost::BuildRelationLookup)?, + &host_entry(py, AdapterHost::BuildRelationLookup)?, &[ ("adapter", inputs.adapter.clone()), ("connection", inputs.connection.clone()), @@ -503,7 +504,7 @@ pub(crate) fn run_read_side_dependencies<'py>( return Ok(PyTuple::empty(py).into_any()); } let tracker: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::CreateReadSidePythonExecutionTracker)?, + &host_entry(py, ExecutorHost::CreateReadSidePythonExecutionTracker)?, &[ ("python_graph", inputs.python_graph.clone()), ("selected_python_names", read_side_names), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/check/check_results.rs b/crates/sqlbuild-python/src/bindings/_helpers/check/check_results.rs index d9c236d62..5b3f6c256 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/check/check_results.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/check/check_results.rs @@ -14,11 +14,11 @@ use sqlbuild_core::check_command::models::{CheckGrouping, CheckResultText, Check use sqlbuild_core::cli_text::models::CliStyle; use sqlbuild_core::json::models::JsonValue; -use crate::bindings::_helpers::boundary::python_calls::KeywordArguments; use crate::bindings::_helpers::build_progress::progress::current_native_progress_projector; -use crate::bindings::_helpers::records::fields::field as native_field; use crate::bindings::_helpers::result_output::integration_values::json_value; use crate::bindings::_helpers::result_output::terminal_index::current_terminal_event_index; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const WARN_SEVERITY: &str = "warn"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/argv.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/argv.rs index ad566ed3e..acd0e07d4 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/argv.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/argv.rs @@ -19,9 +19,9 @@ use sqlbuild_core::text::main::python_str_repr::python_str_repr; use crate::bindings::_helpers::cli::namespace::new_cli_namespace; use crate::bindings::_helpers::cli::surrogates::{python_text, rust_text, uses_placeholders}; use crate::bindings::_helpers::recall::console::write_stdout_bytes; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; const INT_CONVERTER: &str = "int"; const POSITIVE_INTEGER_CONVERTER: &str = "_positive_integer"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/dispatch.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/dispatch.rs index 234f01bd6..7f5cf1f54 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/dispatch.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/dispatch.rs @@ -32,7 +32,6 @@ use crate::bindings::_helpers::query_command::dag::run_dag_command; use crate::bindings::_helpers::query_command::query::run_query_command; use crate::bindings::_helpers::recall::command::run_recall_command; use crate::bindings::_helpers::recall::session::InvocationRecall; -use crate::bindings::_helpers::records::construct::{new_record_with, record_class}; use crate::bindings::_helpers::refactor::refactor_command::run_refactor_command; use crate::bindings::_helpers::review_command::command::run_review_command; use crate::bindings::_helpers::scenario_command::capture_command::run_scenario_capture_command; @@ -56,12 +55,16 @@ use sqlbuild_cli::dispatch::models::{ ClassRef, CommandFacts, DiffSide, Dispatch, DispatchFailure, Field, Route, Source, }; use sqlbuild_core::format_command::main::format_path_selectors::format_path_selectors; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::construct::record_class::record_class; -use crate::bindings::_helpers::boundary::python_calls::{imported, within}; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::{ErrorId, RecordId}; -use crate::bindings::_helpers::records::registry; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::registry::record_named::record_named; +use sqlbuild_python_base::records::types::ErrorId; +use sqlbuild_python_base::records::types::RecordId; const PATHLIB_MODULE: &str = "pathlib"; const UTF8: &str = "utf-8"; @@ -243,7 +246,7 @@ fn path_class(py: Python<'_>) -> PyResult> { } fn class_object<'py>(py: Python<'py>, class: ClassRef) -> PyResult> { - record_class(py, registry::record_named(class.name)?) + record_class(py, record_named(class.name)?) } fn tuple_of<'py>(value: &Bound<'py, PyAny>) -> PyResult> { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/entry.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/entry.rs index 2641f2db3..ab3c9aeea 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/entry.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/entry.rs @@ -19,7 +19,6 @@ use sqlbuild_cli::dispatch::models::{CommandFacts, CommandFailure, InvocationPol use sqlbuild_host::entries::models::{ExecutorHost, FacadeHost}; use sqlbuild_orchestration::runs::models::RunOutcome; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported, keywords, within}; use crate::bindings::_helpers::build_progress::transient_lines::shared_transient_line_coordinator; use crate::bindings::_helpers::cli::argv::parse_cli_invocation; use crate::bindings::_helpers::cli::dispatch::{command_facts, dispatch_command}; @@ -37,7 +36,6 @@ use crate::bindings::_helpers::compile_command::constants::COMPILE_COMMAND_NAME; use crate::bindings::_helpers::compile_command::report::format_compile_error_json; use crate::bindings::_helpers::cost_report::attribution::take_cost_status; use crate::bindings::_helpers::diff_report::output::render_diff_error_json; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::native_host::interrupt::{InterruptHandler, interrupted}; use crate::bindings::_helpers::output_capture::records::invocation_context; use crate::bindings::_helpers::presentation_text::terminal::stdout_supports_color; @@ -48,15 +46,23 @@ use crate::bindings::_helpers::recall::session::{ InvocationRecall, effective_selection, finish_invocation_recall, start_invocation_recall, }; use crate::bindings::_helpers::recall::sinks::{RecallLifecycleSink, publish_lifecycle_event}; -use crate::bindings::_helpers::records::construct::record_class; -use crate::bindings::_helpers::records::construct::{error_class, new_error}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::{ErrorId, RecordId}; use crate::bindings::_helpers::rules::constants::DEFAULT_RULES_NOTICE_ATTR; use crate::bindings::_helpers::workspace_commands::commands::maintain_sqlbuild_skills; use sqlbuild_cli::launcher::constants::LAUNCH_RECORD_OPTION; use sqlbuild_core::cli_text::main::format_coded_error::format_coded_error; use sqlbuild_core::cli_text::models::CliStyle; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::native_host::main::redirect_stdout_to_stderr::redirect_stdout_to_stderr; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::construct::new_error::new_error; +use sqlbuild_python_base::records::main::construct::record_class::record_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; +use sqlbuild_python_base::records::types::RecordId; const NO_COLOR_OPTION: &str = "--no-color"; const CLI_LOGGER: &str = "sqlbuild.cli"; @@ -394,7 +400,7 @@ fn failure_kind(py: Python<'_>, error: &Bound<'_, PyAny>) -> PyResult( payload: Bound<'py, PyDict>, ) -> PyResult> { call_with( - &host::entry(py, ExecutorHost::CreateLifecycleEvent)?, + &host_entry(py, ExecutorHost::CreateLifecycleEvent)?, &[ ("event_type", PyString::new(py, event_type).into_any()), ("payload", payload.into_any()), @@ -705,7 +711,7 @@ fn record_interrupted_end( let occurred_at: Bound<'_, PyDateTime> = PyDateTime::from_timestamp(py, seconds, Some(&PyTzInfo::utc(py)?.to_owned()))?; let started: Bound<'_, PyAny> = call_with( - &host::entry(py, ExecutorHost::CreateLifecycleEvent)?, + &host_entry(py, ExecutorHost::CreateLifecycleEvent)?, &[ ( "event_type", @@ -773,7 +779,7 @@ fn external_context(py: Python<'_>) -> PyResult> { match invocation_context(py, None) { Ok(context) => Ok(context), Err(error) - if error.is_instance(py, &host::entry(py, ExecutorHost::OutputCaptureInputError)?) => + if error.is_instance(py, &host_entry(py, ExecutorHost::OutputCaptureInputError)?) => { Ok(PyDict::new(py).into_any()) } @@ -810,7 +816,7 @@ fn parsed_invocation<'py>( .transpose()? .flatten(); if command.as_deref() == Some("location") && location_command.as_deref() == Some("runtime") { - return within(&host::redirect_stdout_to_stderr(py)?, |_| { + return within(&redirect_stdout_to_stderr(py)?, |_| { execute_parsed_invocation(args, handlers, identity, use_color) }); } @@ -870,7 +876,7 @@ fn execute_parsed_invocation<'py>( }, )?; let evidence_scope: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::AuditEvidenceScope)?, + &host_entry(py, ExecutorHost::AuditEvidenceScope)?, &[( "mode", PyString::new(py, recall.audit_evidence.setting()).into_any(), @@ -881,7 +887,7 @@ fn execute_parsed_invocation<'py>( call_with(&operation.into_any(), &[]) } else { call_with( - &host::entry(py, FacadeHost::DispatchWithComputeLogs)?, + &host_entry(py, FacadeHost::DispatchWithComputeLogs)?, &[ ("args", args), ("identity", identity.clone()), @@ -981,15 +987,15 @@ fn invoke<'py>( ) -> PyResult> { let external: Bound<'py, PyAny> = external_context(py)?; let invocation_scope: Bound<'py, PyAny> = - host::entry(py, ExecutorHost::InvocationScope)?.call0()?; + host_entry(py, ExecutorHost::InvocationScope)?.call0()?; within(&invocation_scope, |identity| { let external_scope: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::InvocationExternalContextScope)?, + &host_entry(py, ExecutorHost::InvocationExternalContextScope)?, &[("external_context", external.clone())], )?; within(&external_scope, |_| { let diagnostics: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::DiagnosticsContext)?, + &host_entry(py, ExecutorHost::DiagnosticsContext)?, &[( "sqlbuild_invocation_id", native_field(identity, "invocation_id")?, diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/namespace.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/namespace.rs index 0434da163..8e72d6a08 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/namespace.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/namespace.rs @@ -7,8 +7,8 @@ use pyo3::{IntoPyObjectExt, pyclass, pymethods}; use sqlbuild_cli::argv::main::cli_namespace_defaults::cli_namespace_defaults; use sqlbuild_cli::argv::models::NamespaceDefault; -use crate::bindings::_helpers::records::construct::enum_member; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::types::RecordId; /// Typed namespace for all CLI arguments across all commands. #[pyclass(module = "sqlbuild._native", dict, frozen)] diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/observability.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/observability.rs index 6c2dde3d9..39b81187b 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/observability.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/observability.rs @@ -15,19 +15,23 @@ use sqlbuild_cli::dispatch::models::{ExportSummary, ExporterLoss}; use sqlbuild_core::event_export::constants::DEFAULT_EVENT_EXPORT_SHUTDOWN_TIMEOUT_SECONDS; use sqlbuild_host::entries::models::{ExecutorHost, UserCodeHost}; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported, keywords, within}; use crate::bindings::_helpers::build_progress::progress::NativeProgressProjector; use crate::bindings::_helpers::build_progress::progress::machine_output_mode; use crate::bindings::_helpers::cli::launch_state::withhold_launch_record; use crate::bindings::_helpers::event_exporting::dispatcher::EventExporterDispatcher; use crate::bindings::_helpers::event_exporting::scope::EventExporterCommandScope; use crate::bindings::_helpers::event_exporting::scope::event_exporter_command_scope; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::presentation_text::terminal::stdout_supports_color; use crate::bindings::_helpers::recall::console::write_stderr; -use crate::bindings::_helpers::records::fields::field as native_field; use crate::bindings::_helpers::result_output::terminal_index::TerminalEventIndex; use crate::bindings::_helpers::result_output::terminal_index::terminal_event_index_scope; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::native_host::main::redirect_stdout_to_stderr::redirect_stdout_to_stderr; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const OBSERVABILITY_LOGGER: &str = "sqlbuild.cli.observability"; const DEBUG_COMMAND: &str = "debug"; @@ -55,7 +59,7 @@ fn log_debug<'py>( ("message", PyString::new(py, message).into_any()), ]; pairs.extend(fields.iter().cloned()); - call_with(&host::entry(py, ExecutorHost::LogDebugEvent)?, &pairs)?; + call_with(&host_entry(py, ExecutorHost::LogDebugEvent)?, &pairs)?; Ok(()) } @@ -342,12 +346,12 @@ impl Observed { if native_field(args, "command")?.ne(LINEAGE_COMMAND)? { let discover = || { call_with( - &host::entry(py, UserCodeHost::DiscoverRuntimeExtensions)?, + &host_entry(py, UserCodeHost::DiscoverRuntimeExtensions)?, &[("project_dir", project_dir.clone())], ) }; let extensions: Bound<'_, PyAny> = if machine_output_mode(args)? { - within(&host::redirect_stdout_to_stderr(py)?, |_| discover())? + within(&redirect_stdout_to_stderr(py)?, |_| discover())? } else { discover()? }; @@ -420,7 +424,7 @@ impl Observed { } } self.enter( - host::entry(py, ExecutorHost::DispatcherScope)?.call1((self.dispatcher.bind(py),))?, + host_entry(py, ExecutorHost::DispatcherScope)?.call1((self.dispatcher.bind(py),))?, )?; self.enter(pyo3::IntoPyObjectExt::into_bound_py_any( terminal_event_index_scope(terminal_index.extract::>()?), @@ -438,10 +442,10 @@ impl Observed { py, )?)?; let identity: Bound<'_, PyAny> = - host::entry(py, ExecutorHost::CurrentExecutionIdentity)?.call0()?; + host_entry(py, ExecutorHost::CurrentExecutionIdentity)?.call0()?; if !identity.is_none() && command_output_sinks { self.enter(call_with( - &host::entry(py, ExecutorHost::ConfiguredOutputCaptureScope)?, + &host_entry(py, ExecutorHost::ConfiguredOutputCaptureScope)?, &[ ("exporter_scope", scope), ("identity", identity), @@ -494,7 +498,7 @@ impl CliObservabilityScope { fn __enter__(&self, py: Python<'_>) -> PyResult> { let args: &Bound<'_, PyAny> = self.args.bind(py); let dispatcher: Bound<'_, PyAny> = call_with( - &host::entry(py, ExecutorHost::EventDispatcher)?, + &host_entry(py, ExecutorHost::EventDispatcher)?, &[( "health_callback", wrap_pyfunction!(log_dispatch_failure, py)?.into_any(), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/cli/termination.rs b/crates/sqlbuild-python/src/bindings/_helpers/cli/termination.rs index 3256513ca..512886cef 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/cli/termination.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/cli/termination.rs @@ -13,10 +13,10 @@ use pyo3::prelude::{ use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::imported; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::recall::console::write_stderr; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; create_exception!( sqlbuild._native, @@ -116,7 +116,7 @@ fn watch(flags: &SigtermFlags, stop: &AtomicBool, main: MainThread) { if flags.terminated.load(Ordering::SeqCst) { flags.default.store(true, Ordering::SeqCst); Python::attach(|py| { - let cancelled = host::entry(py, ExecutorHost::CancelRunningStatements) + let cancelled = host_entry(py, ExecutorHost::CancelRunningStatements) .and_then(|cancel| cancel.call0()); drop(cancelled); if main.handles_interrupt { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_command.rs b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_command.rs index 25ae035e1..e5edeab95 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_command.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_command.rs @@ -19,8 +19,6 @@ use sqlbuild_core::clone_text::main::validate_clone_target_names::validate_clone use sqlbuild_core::clone_text::models::CloneItemText; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::keywords; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported, within}; use crate::bindings::_helpers::build_progress::progress_reporters::PlanningProgressReporter; use crate::bindings::_helpers::clone::clone_execution::{ destination_entry_count, execute_clone_plan, resource_types_by_name, @@ -35,16 +33,21 @@ use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_name; use crate::bindings::_helpers::dbt_interop::reference_resolver::resolve_external_sql_reference_resolver; use crate::bindings::_helpers::native_host::connections::connection_failure; -use crate::bindings::_helpers::native_host::host; use crate::bindings::_helpers::planner_entries::clone_plans::PhaseTimings; use crate::bindings::_helpers::planner_selection::unit_tests::reject_unit_test_selectors; use crate::bindings::_helpers::presentation_text::terminal::stdout_supports_color; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::{ErrorId, RecordId}; use crate::bindings::_helpers::result_output::documents::format_clone_execution_json; use crate::bindings::_helpers::result_output::documents::write_execution_json_output; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; +use sqlbuild_python_base::records::types::RecordId; const CLONE_LOGGER: &str = "sqlbuild.clone"; /// The clone phase that copies relations into the destination. @@ -101,7 +104,7 @@ fn progress_reporter<'py>( fn lifecycle<'py>(py: Python<'py>, (kind, name): (&str, &str)) -> PyResult> { call_with( - &host::entry(py, ExecutorHost::OperationLifecycle)?, + &host_entry(py, ExecutorHost::OperationLifecycle)?, &[ ("operation_kind", text(py, kind)), ("operation_name", text(py, name)), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_execution.rs b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_execution.rs index d5afb129b..0e1168cf7 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_execution.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_execution.rs @@ -9,18 +9,21 @@ use sqlbuild_core::clone_text::main::clone_relation_flow_text::clone_relation_fl use sqlbuild_core::clone_text::models::FingerprintProgress; use sqlbuild_host::entries::models::ExecutorHost; -use crate::bindings::_helpers::boundary::python_calls::{call_with, within}; use crate::bindings::_helpers::clone::clone_command::Invocation; use crate::bindings::_helpers::clone::clone_progress::{ CloneFingerprintReporter, CloneItemPrinter, }; use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::{enum_member, new_record, new_record_with}; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_items; -use crate::bindings::_helpers::records::ids::RecordId; use crate::bindings::_helpers::result_output::event_writer::ExecutionEventWriter; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::within::within; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::enum_member::enum_member; +use sqlbuild_python_base::records::main::construct::new_record::new_record; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_items::mapping_items; +use sqlbuild_python_base::records::types::RecordId; const DESTINATION_ENTRY_GROUPS: [&str; 4] = [ "destination_source_entries", @@ -180,7 +183,7 @@ fn execution_input<'py>( .map(|entry| native_field(&entry?, "name")) .collect::>()?; let retention: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildDestinationRetentionRequests)?, + &host_entry(py, ExecutorHost::BuildDestinationRetentionRequests)?, &[ ("project", project.clone()), ( @@ -200,7 +203,7 @@ fn execution_input<'py>( let allow_decrease: bool = native_field(&config, "time_travel_retention_decrease")? .eq(enum_member(py, RecordId::RetentionDecreasePolicy, "ALLOW")?)?; let source_entries: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::CloneSourceEntries)?, + &host_entry(py, ExecutorHost::CloneSourceEntries)?, &[ ("origin", native_field(pipeline, "origin_source_entries")?), ( @@ -210,7 +213,7 @@ fn execution_input<'py>( ], )?; let transient: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::BuildDestinationTransientModels)?, + &host_entry(py, ExecutorHost::BuildDestinationTransientModels)?, &[("project", project.clone())], )?; let mut fields: Vec<(&str, Bound<'py, PyAny>)> = vec![("source_entries", source_entries)]; @@ -246,10 +249,7 @@ fn execution_input<'py>( ), ("on_item", on_item), ]); - call_with( - &host::entry(py, ExecutorHost::CloneExecutionInput)?, - &fields, - ) + call_with(&host_entry(py, ExecutorHost::CloneExecutionInput)?, &fields) } /// Copy fingerprints of the cloned relations, reporting what was not confirmed on failure. @@ -288,7 +288,7 @@ fn copy_fingerprints<'py>( ("on_progress", reporter.clone().into_any()), ]); let lifecycle: Bound<'py, PyAny> = call_with( - &host::entry(py, ExecutorHost::OperationLifecycle)?, + &host_entry(py, ExecutorHost::OperationLifecycle)?, &[ ("operation_kind", PyString::new(py, "clone").into_any()), ( @@ -299,7 +299,7 @@ fn copy_fingerprints<'py>( )?; let copied: PyResult> = within(&lifecycle, |_| { call_with( - &host::entry(py, ExecutorHost::CopyCloneFingerprints)?, + &host_entry(py, ExecutorHost::CopyCloneFingerprints)?, &fields, ) }); @@ -344,7 +344,7 @@ pub(crate) fn execute_clone_plan<'py>( ), )?; call_with( - &host::entry(py, ExecutorHost::ExecuteClone)?, + &host_entry(py, ExecutorHost::ExecuteClone)?, &[("inputs", input)], ) })(); diff --git a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_pipeline.rs b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_pipeline.rs index 4c8bd38ee..331227a14 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_pipeline.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_pipeline.rs @@ -4,14 +4,14 @@ use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyRes use pyo3::types::{PyBool, PyDict, PyTuple}; use pyo3::{pyfunction, wrap_pyfunction}; -use crate::bindings::_helpers::boundary::keyword_request::Request; -use crate::bindings::_helpers::boundary::python_calls::keywords; use crate::bindings::_helpers::compile_driver::project::build_compiled_project; use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config; use crate::bindings::_helpers::planner_entries::clone_plans::{PhaseTimings, timed_clone_planning}; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::models::Request; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; /// The phase name of one target compile, before the target name. const COMPILE_PHASE_PREFIX: &str = "compile_"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_progress.rs b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_progress.rs index d67bfd1f9..2bb48c632 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_progress.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/clone/clone_progress.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; -use crate::bindings::_helpers::records::fields::field as native_field; use pyo3::exceptions::PyKeyError; use pyo3::prelude::{Bound, Py, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::types::PyDict; @@ -12,6 +11,7 @@ use sqlbuild_core::clone_text::main::render_clone_fingerprint_interrupted_line:: use sqlbuild_core::clone_text::main::render_clone_fingerprint_progress_line::render_clone_fingerprint_progress_line; use sqlbuild_core::clone_text::main::render_clone_item_line::render_clone_item_line; use sqlbuild_core::clone_text::models::{CloneItemText, CloneStatusKind, FingerprintProgress}; +use sqlbuild_python_base::records::main::fields::field::field as native_field; fn optional_text(value: Bound<'_, PyAny>) -> PyResult> { if value.is_none() { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/adapters.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/adapters.rs index 2b6eaa279..83745810b 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/adapters.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/adapters.rs @@ -7,11 +7,11 @@ use pyo3::types::{PyDict, PyDictMethods}; use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_host::entries::models::AdapterHost; -use crate::bindings::_helpers::boundary::python_calls::call_with; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; const ADAPTER_CONFIGURATION_CODE: &str = "C601"; @@ -36,14 +36,14 @@ pub(crate) fn resolve_cli_adapter<'py>( ) -> PyResult> { let py: Python<'py> = adapter_name.py(); let resolved: PyResult> = call_with( - &host::entry(py, AdapterHost::ResolveAdapter)?, + &host_entry(py, AdapterHost::ResolveAdapter)?, &[ ("adapter_name", adapter_name.clone()), ("project_dir", project_dir.clone()), ], ); match resolved { - Err(error) if error.is_instance(py, &host::entry(py, AdapterHost::AdapterUserError)?) => { + Err(error) if error.is_instance(py, &host_entry(py, AdapterHost::AdapterUserError)?) => { Err(cli_adapter_error(py, &error)?) } resolved => resolved, diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/concurrency.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/concurrency.rs index 3008e8120..047a888de 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/concurrency.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/concurrency.rs @@ -8,7 +8,7 @@ use crate::bindings::_helpers::compile_attachment::effective_config::build_effec use crate::bindings::_helpers::contracts::spec_resolution::{ resolve_target_config, resolve_target_name, }; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const CONCURRENCY: &str = "concurrency"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/connection.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/connection.rs index 495410b7a..637d093ff 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/connection.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/connection.rs @@ -16,7 +16,6 @@ use sqlbuild_config::command_connection::main::snowflake_key_warning::snowflake_ use sqlbuild_core::constants::PROJECT_CONFIG_FILENAME; use sqlbuild_host::entries::models::ThirdPartyHost; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, imported, keywords}; use crate::bindings::_helpers::command_runtime::runtime_errors::raised; use crate::bindings::_helpers::command_runtime::warehouses::{WarehouseInputs, apply_warehouse}; use crate::bindings::_helpers::compile_attachment::effective_config::build_effective_connection_config; @@ -24,8 +23,11 @@ use crate::bindings::_helpers::contracts::spec_resolution::resolve_effective_ada use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_config; use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_name; use crate::bindings::_helpers::dbt_interop::profile_connection::resolve_raw_dbt_profile_connection; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::native_host::main::host_entry::host_entry; +use sqlbuild_python_base::records::main::fields::field::field as native_field; const ATTACH_KEY: &str = "attach"; const ATTACH_PATH_KEY: &str = "path"; @@ -66,7 +68,7 @@ fn warn(py: Python<'_>, message: &str) -> PyResult<()> { } fn dbt_profile_error(py: Python<'_>) -> PyErr { - match host::entry(py, ThirdPartyHost::DbtProfileError) + match host_entry(py, ThirdPartyHost::DbtProfileError) .and_then(|class| class.call1((DBT_PROFILE_REQUIRES_PROJECT,))) { Ok(instance) => PyErr::from_value(instance), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/invocation.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/invocation.rs index 0f0db48fa..ed3befb78 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/invocation.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/invocation.rs @@ -3,8 +3,6 @@ use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyResult, Python}; use pyo3::types::PyBool; -use crate::bindings::_helpers::boundary::python_calls::keywords; -use crate::bindings::_helpers::boundary::python_calls::{call_with, imported}; use crate::bindings::_helpers::build_progress::progress_reporters::ConnectionProgressReporter; use crate::bindings::_helpers::build_progress::progress_reporters::PlanningProgressReporter; use crate::bindings::_helpers::command_runtime::adapters::resolve_cli_adapter; @@ -13,9 +11,12 @@ use crate::bindings::_helpers::compile_driver::discovery::discover_project_input use crate::bindings::_helpers::contracts::spec_resolution::resolve_effective_adapter_name; use crate::bindings::_helpers::discovery::provider_secrets::SecretPolicy; use crate::bindings::_helpers::presentation_text::terminal::stdout_supports_color; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::main::call_with::call_with; +use sqlbuild_python_base::boundary::main::imported::imported; +use sqlbuild_python_base::boundary::main::keywords::keywords; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::RecordId; /// The project directory, discovered inputs, adapter context, colour and progress stream. struct InvocationContext<'py> { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/preview_target.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/preview_target.rs index 8f83b4db8..3e9caaaa1 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/preview_target.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/preview_target.rs @@ -7,7 +7,7 @@ use pyo3::{pyfunction, wrap_pyfunction}; use sqlbuild_config::command_connection::main::check_preview_target::check_preview_target; use crate::bindings::_helpers::command_runtime::runtime_errors::raised; -use crate::bindings::_helpers::records::fields::field as native_field; +use sqlbuild_python_base::records::main::fields::field::field as native_field; fn target_names(config: &Bound<'_, PyAny>) -> PyResult> { native_field(config, "targets")? diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/runtime_errors.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/runtime_errors.rs index c36ab9771..80287181c 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/runtime_errors.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/runtime_errors.rs @@ -4,9 +4,9 @@ use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyErr, PyResult, Python}; use pyo3::types::{PyDict, PyDictMethods}; use sqlbuild_config::command_connection::errors::CommandConnectionError; -use crate::bindings::_helpers::records::construct::error_class; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::ids::ErrorId; +use sqlbuild_python_base::records::main::construct::error_class::error_class; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::types::ErrorId; /// The `CliUserError` or `ProjectConfigError` for `error`. pub(crate) fn raised(py: Python<'_>, error: CommandConnectionError) -> PyErr { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouse_scope.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouse_scope.rs index 7b9a63b92..ff80436dd 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouse_scope.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouse_scope.rs @@ -10,8 +10,9 @@ use pyo3::{pyclass, pyfunction, pymethods, wrap_pyfunction}; use sqlbuild_config::command_connection::constants::COMMAND_WAREHOUSE_GROUPS; -use crate::bindings::_helpers::records::construct::{enum_from_value, new_record_with}; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::records::main::construct::enum_from_value::enum_from_value; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::types::RecordId; const CONTEXT_ATTRIBUTE: &str = "_command_warehouse_scope_context"; const CONTEXT_NAME: &str = "sqlbuild_command_warehouse_scope"; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouses.rs b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouses.rs index 4b9a2bd62..fab0bb4d1 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouses.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/command_runtime/warehouses.rs @@ -16,24 +16,23 @@ use sqlbuild_config::command_connection::main::unsupported_cli_warehouse::unsupp use sqlbuild_config::command_connection::models::AuthoredWarehouse; use sqlbuild_core::text::main::python_strip::python_strip; -use sqlbuild_host::entries::models::AdapterHost; use sqlbuild_model_config::templates::models::TemplateOptions; -use crate::bindings::_helpers::boundary::python_calls::{KeywordArguments, call_with}; use crate::bindings::_helpers::command_runtime::runtime_errors::{ expected_resolution_error, raised, }; use crate::bindings::_helpers::command_runtime::warehouse_scope::current_command_warehouse_scope; use crate::bindings::_helpers::compile_attachment::effective_config::build_effective_runtime_config; +use crate::bindings::_helpers::compile_driver::config_validation::session_warehouse_support; use crate::bindings::_helpers::contracts::spec_resolution::resolve_effective_adapter_name; use crate::bindings::_helpers::contracts::spec_resolution::resolve_target_name; use crate::bindings::_helpers::discovery::configuration::discover_project_configuration; use crate::bindings::_helpers::model_config::template_data::expanded_template_data; -use crate::bindings::_helpers::native_host::host; -use crate::bindings::_helpers::records::construct::new_record_with; -use crate::bindings::_helpers::records::fields::field as native_field; -use crate::bindings::_helpers::records::fields::mapping_get; -use crate::bindings::_helpers::records::ids::RecordId; +use sqlbuild_python_base::boundary::models::KeywordArguments; +use sqlbuild_python_base::records::main::construct::new_record_with::new_record_with; +use sqlbuild_python_base::records::main::fields::field::field as native_field; +use sqlbuild_python_base::records::main::fields::mapping_get::mapping_get; +use sqlbuild_python_base::records::types::RecordId; /// The `WarehouseGroup` whose warehouse is a target's `warehouses.build`; any other reads `query`. const BUILD_GROUP: &str = "build"; @@ -210,21 +209,6 @@ fn connection_warehouse(connection_config: &Bound<'_, PyAny>) -> PyResult