// file: crates/ksp-store-postgres-lib/tests/dependency_boundary.rs // version: 5 #![warn(missing_docs)] #![deny(unreachable_pub)] #![forbid(unsafe_code)] //! Dependency and ownership canaries for the physical PostgreSQL Store backend. #[test] fn pre_005_backend_owns_exact_physical_runtime_dependencies_without_reverse_facade_edge() { let manifest = include_str!("../Cargo.toml"); for required in ["deadpool-postgres", "ksp-logging-lib", "ksp-store-api", "rustls", "rustls-native-certs", "sha2", "tokio-postgres", "tokio-postgres-rustls"] { assert!(manifest.contains(required), "missing PostgreSQL backend dependency: {required}"); } for forbidden in ["ksp-store-lib", "ksp-config-lib", "ksp-materializer", "ksp-program", "ksp-onchain-transport-lib", "ksp-offchain-transport-lib", "sqlx"] { assert!(!manifest.contains(forbidden), "forbidden PostgreSQL backend dependency detected: {forbidden}"); } let migration = include_str!("../src/migration.rs"); let bootstrap_sql = include_str!("../migrations/V000__bootstrap.sql"); assert!(migration.contains("include_str!(\"../migrations/V000__bootstrap.sql\")")); assert!(bootstrap_sql.contains("ksp_store_schema_migrations")); for forbidden in ["RawTransaction", "RawAccountState", "raw_transaction", "raw_account", "CORE", "DECODE", "SPECIALIZED"] { assert!(!migration.contains(forbidden), "business migration implementation leaked into foundation: {forbidden}"); assert!(!bootstrap_sql.contains(forbidden), "business schema leaked into foundation SQL: {forbidden}"); } return; } #[test] fn pre_005_backend_keeps_environment_sql_migrations_and_physical_types_private() { let crate_root = include_str!("../src/lib.rs"); assert!(crate_root.contains("mod error;")); assert!(crate_root.contains("mod health;")); assert!(crate_root.contains("mod migration;")); assert!(crate_root.contains("mod runtime;")); assert!(crate_root.contains("const _: &str = crate::TRACING_TARGET;")); for forbidden in [ "pub mod ", "ksp_store_lib", "ksp_config_lib", "tokio_postgres::Client", "tokio_postgres::Row", "tokio_postgres::Statement", "deadpool_postgres::Pool;", ] { assert!(!crate_root.contains(forbidden), "forbidden PostgreSQL crate-root surface detected: {forbidden}"); } let runtime = include_str!("../src/runtime.rs"); for forbidden in [ "std::env", "dotenv", "KSP_", "KSPB_", "PGHOST", "PGPORT", "PGUSER", "PGPASSWORD", ".pgpass", "CREATE TABLE", "INSERT INTO", "UPDATE ", "DELETE FROM", "SELECT ", ] { assert!(!runtime.contains(forbidden), "forbidden PostgreSQL backend ownership/scope content detected: {forbidden}"); } return; } #[test] fn pre_007_health_probe_remains_foundation_only_and_private_sql() { let health = include_str!("../src/health.rs"); assert!(health.contains("SELECT 1::BIGINT")); assert!(health.contains("ksp_store_schema_migrations")); for forbidden in ["RawTransaction", "RawAccountState", "raw_transaction", "raw_account", "CORE", "DECODE", "SPECIALIZED", "std::env", "dotenv", "KSP_SECRET_"] { assert!(!health.contains(forbidden), "forbidden health ownership/scope content detected: {forbidden}"); } return; }