v0.3.8-pre.009

This commit is contained in:
2026-09-03 20:44:21 +02:00
parent 8c23625fee
commit 32c4b67541
25 changed files with 1319 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-store-postgres-lib/tests/dependency_boundary.rs
// version: 28
// version: 29
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -187,6 +187,7 @@ fn pre_005_raw_account_acquisition_is_atomic_idempotent_and_keeps_trait_impls_ou
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawAccountObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
] {
@@ -222,6 +223,7 @@ fn pre_006_raw_account_additional_observation_is_reference_guarded_cancellation_
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawAccountObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
] {
@@ -408,6 +410,7 @@ fn pre_007_raw_account_pagination_is_keyset_cursor_bound_and_policy_free() {
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawAccountObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
] {
@@ -449,15 +452,17 @@ fn pre_007_raw_retention_is_atomic_compare_and_transition_without_fake_compactio
}
#[test]
fn v0_3_8_pre_005_backend_trait_implementations_cover_exact_twelve_raw_capabilities_in_runtime_bridge() {
fn v0_3_8_pre_009_backend_trait_implementations_cover_exact_fourteen_raw_capabilities_in_runtime_bridge() {
let runtime = include_str!("../src/runtime.rs");
for implementation in [
"impl ksp_store_api::RawAccountObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawTransactionInspectionRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationWrite for PostgresBackend",
"impl ksp_store_api::RawTransactionRead for PostgresBackend",
@@ -467,6 +472,6 @@ fn v0_3_8_pre_005_backend_trait_implementations_cover_exact_twelve_raw_capabilit
] {
assert_eq!(runtime.matches(implementation).count(), 1, "unexpected PostgreSQL RAW capability inventory: {implementation}");
}
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 12);
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 14);
return;
}

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-store-postgres-lib/tests/hardening_completeness.rs
// version: 21
// version: 22
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -302,15 +302,17 @@ fn pre_009_live_raw_transaction_proof_is_opt_in_isolated_and_secret_safe() {
}
#[test]
fn v0_3_8_pre_005_raw_capability_implementation_inventory_is_exactly_twelve() {
fn v0_3_8_pre_009_raw_capability_implementation_inventory_is_exactly_fourteen() {
let runtime = include_str!("../src/runtime.rs");
let capability_impls = [
"impl ksp_store_api::RawAccountObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationRead for PostgresBackend",
"impl ksp_store_api::RawAccountObservationWrite for PostgresBackend",
"impl ksp_store_api::RawAccountStateInspectionRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateRead for PostgresBackend",
"impl ksp_store_api::RawAccountStateWrite for PostgresBackend",
"impl ksp_store_api::RawTransactionInspectionRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationInspectionRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationRead for PostgresBackend",
"impl ksp_store_api::RawTransactionObservationWrite for PostgresBackend",
"impl ksp_store_api::RawTransactionRead for PostgresBackend",
@@ -321,7 +323,7 @@ fn v0_3_8_pre_005_raw_capability_implementation_inventory_is_exactly_twelve() {
for implementation in capability_impls {
assert_eq!(runtime.matches(implementation).count(), 1, "unexpected PostgreSQL capability implementation inventory: {implementation}");
}
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 12);
assert_eq!(runtime.matches("impl ksp_store_api::Raw").count(), 14);
let migration = include_str!("../src/migration.rs");
assert!(migration.contains("raw_account_state"));
assert!(migration.contains("crate::V002_RESOURCES"));
@@ -394,13 +396,77 @@ fn v0_3_8_pre_004_transaction_inspection_sql_is_single_statement_payload_free_co
}
assert!(ascending.contains("ORDER BY transaction_row.slot ASC, transaction_row.signature ASC"));
assert!(descending.contains("ORDER BY transaction_row.slot DESC, transaction_row.signature DESC"));
assert_eq!(source.matches(" OFFSET ").count(), 2);
assert!(source.contains("raw_transaction_inspection_sql_window(query.page())"));
assert!(source.contains("raw_transaction_inspection_offset"));
assert!(source.contains("raw_transaction_inspection_limit"));
return;
}
#[test]
fn v0_3_8_pre_009_observation_inspection_sql_is_counted_random_access_safe_and_family_local() {
let transaction = include_str!("../src/raw_transaction.rs");
let account = include_str!("../src/raw_account.rs");
let transaction_ascending = transaction.lines().find(|line| return line.starts_with("const INSPECT_OBSERVATIONS_ASC_SQL"));
let transaction_ascending = match transaction_ascending {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing ascending transaction-observation inspection SQL"),
};
let transaction_descending = transaction.lines().find(|line| return line.starts_with("const INSPECT_OBSERVATIONS_DESC_SQL"));
let transaction_descending = match transaction_descending {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing descending transaction-observation inspection SQL"),
};
for statement in [transaction_ascending, transaction_descending] {
for required in [
"COUNT(*)::TEXT AS filtered_count_text",
"COUNT(*)::TEXT FROM ksp_raw_transaction_observations",
"LEFT JOIN LATERAL",
"transaction_signature = $1",
"LIMIT $2 OFFSET $3",
"received_at_unix_millis",
"observation_key",
] {
assert!(statement.contains(required), "missing transaction-observation inspection SQL contract: {required}");
}
for forbidden in ["ksp_raw_transactions AS", "payload", "archive_payload", "SELECT *"] {
assert!(!statement.contains(forbidden), "transaction-observation inspection leaked unrelated/raw material: {forbidden}");
}
}
assert!(transaction_ascending.contains("ORDER BY received_at_unix_millis ASC, observation_key ASC"));
assert!(transaction_descending.contains("ORDER BY received_at_unix_millis DESC, observation_key DESC"));
let account_ascending = account.lines().find(|line| return line.starts_with("const INSPECT_ACCOUNT_OBSERVATIONS_ASC_SQL"));
let account_ascending = match account_ascending {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing ascending account-observation inspection SQL"),
};
let account_descending = account.lines().find(|line| return line.starts_with("const INSPECT_ACCOUNT_OBSERVATIONS_DESC_SQL"));
let account_descending = match account_descending {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("missing descending account-observation inspection SQL"),
};
for statement in [account_ascending, account_descending] {
for required in [
"COUNT(*)::TEXT AS filtered_count_text",
"COUNT(*)::TEXT FROM ksp_raw_account_observations",
"LEFT JOIN LATERAL",
"account_pubkey = $1",
"account_slot = $2::TEXT::NUMERIC",
"account_state_hash = $3",
"LIMIT $4 OFFSET $5",
"received_at_unix_millis",
"observation_key",
] {
assert!(statement.contains(required), "missing account-observation inspection SQL contract: {required}");
}
for forbidden in ["ksp_raw_account_states AS", "account_row.data", "SELECT *"] {
assert!(!statement.contains(forbidden), "account-observation inspection leaked unrelated/raw material: {forbidden}");
}
}
assert!(account_ascending.contains("ORDER BY received_at_unix_millis ASC, observation_key ASC"));
assert!(account_descending.contains("ORDER BY received_at_unix_millis DESC, observation_key DESC"));
return;
}
#[test]
fn pre_010_raw_account_private_sql_is_non_destructive_keyset_and_family_local() {
let source = include_str!("../src/raw_account.rs");
@@ -493,6 +559,5 @@ fn v0_3_8_pre_005_raw_account_keyset_sql_remains_offset_free_while_inspection_is
assert!(statement.contains("account_row.pubkey"));
assert!(statement.contains("account_row.state_hash"));
}
assert_eq!(source.matches(" OFFSET ").count(), 2);
return;
}

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-store-postgres-lib/tests/public_api.rs
// version: 16
// version: 17
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -120,8 +120,10 @@ fn pre_005_raw_write_bridge_uses_only_backend_independent_models_and_outcomes()
fn v0_3_8_pre_005_raw_list_and_inspection_bridges_use_only_backend_independent_models() {
let _account_list = ksp_store_postgres_lib::PostgresBackend::list_raw_account_states;
let _account_inspection = ksp_store_postgres_lib::PostgresBackend::inspect_raw_account_states;
let _account_observation_inspection = ksp_store_postgres_lib::PostgresBackend::inspect_raw_account_observations;
let _transaction_list = ksp_store_postgres_lib::PostgresBackend::list_raw_transactions;
let _transaction_inspection = ksp_store_postgres_lib::PostgresBackend::inspect_raw_transactions;
let _transaction_observation_inspection = ksp_store_postgres_lib::PostgresBackend::inspect_raw_transaction_observations;
return;
}
@@ -133,12 +135,14 @@ fn pre_007_raw_retention_write_bridge_uses_backend_independent_transition_and_ou
fn assert_raw_capabilities<T>()
where
T: ksp_store_api::RawAccountObservationRead
T: ksp_store_api::RawAccountObservationInspectionRead
+ ksp_store_api::RawAccountObservationRead
+ ksp_store_api::RawAccountObservationWrite
+ ksp_store_api::RawAccountStateInspectionRead
+ ksp_store_api::RawAccountStateRead
+ ksp_store_api::RawAccountStateWrite
+ ksp_store_api::RawTransactionInspectionRead
+ ksp_store_api::RawTransactionObservationInspectionRead
+ ksp_store_api::RawTransactionObservationRead
+ ksp_store_api::RawTransactionObservationWrite
+ ksp_store_api::RawTransactionRead
@@ -151,7 +155,7 @@ where
}
#[test]
fn v0_3_8_pre_005_postgres_backend_implements_both_inspection_capabilities_as_12_of_12() {
fn v0_3_8_pre_009_postgres_backend_implements_entity_and_observation_inspection_capabilities_as_14_of_14() {
assert_raw_capabilities::<ksp_store_postgres_lib::PostgresBackend>();
return;
}