v0.3.8-pre.009
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-lib/src/lib.rs
|
||||
// version: 11
|
||||
// version: 12
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
@@ -121,8 +121,14 @@ pub use ksp_store_api::MAX_RAW_UNIX_MILLIS;
|
||||
pub use ksp_store_api::Pubkey;
|
||||
/// Persistable acquisition observation linked to one complete canonical RAW account state.
|
||||
pub use ksp_store_api::RawAccountObservation;
|
||||
/// Backend-independent random-access inspection query for RAW account observations.
|
||||
pub use ksp_store_api::RawAccountObservationInspectionQuery;
|
||||
/// Read capability for random-access RAW account-observation inspection.
|
||||
pub use ksp_store_api::RawAccountObservationInspectionRead;
|
||||
/// Read capability for persisted RAW account-state observations.
|
||||
pub use ksp_store_api::RawAccountObservationRead;
|
||||
/// Safe observation summary for one canonical RAW account-state acquisition.
|
||||
pub use ksp_store_api::RawAccountObservationSummary;
|
||||
/// Write capability for additional observations of already persisted RAW account states.
|
||||
pub use ksp_store_api::RawAccountObservationWrite;
|
||||
/// Canonical complete N1 RAW account state independent from acquisition transport.
|
||||
@@ -195,8 +201,14 @@ pub use ksp_store_api::RawTransactionInspectionQuery;
|
||||
pub use ksp_store_api::RawTransactionInspectionRead;
|
||||
/// Persistable acquisition observation linked to one canonical RAW transaction.
|
||||
pub use ksp_store_api::RawTransactionObservation;
|
||||
/// Backend-independent random-access inspection query for RAW transaction observations.
|
||||
pub use ksp_store_api::RawTransactionObservationInspectionQuery;
|
||||
/// Read capability for random-access RAW transaction-observation inspection.
|
||||
pub use ksp_store_api::RawTransactionObservationInspectionRead;
|
||||
/// Read capability for persisted RAW transaction observations.
|
||||
pub use ksp_store_api::RawTransactionObservationRead;
|
||||
/// Safe observation summary for one canonical RAW transaction acquisition.
|
||||
pub use ksp_store_api::RawTransactionObservationSummary;
|
||||
/// Write capability for additional observations of already persisted RAW transactions.
|
||||
pub use ksp_store_api::RawTransactionObservationWrite;
|
||||
/// Backend-independent list query for canonical RAW transactions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-lib/src/store.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
/// Opaque common Store runtime facade.
|
||||
///
|
||||
@@ -116,6 +116,36 @@ impl std::fmt::Debug for Store {
|
||||
}
|
||||
}
|
||||
|
||||
impl ksp_store_api::RawAccountObservationInspectionRead for Store {
|
||||
fn inspect_raw_account_observations<'a>(
|
||||
&'a self,
|
||||
query: &'a ksp_store_api::RawAccountObservationInspectionQuery,
|
||||
) -> ksp_store_api::StoreApiFuture<'a, ksp_store_api::Result<ksp_store_api::RawInspectionPage<ksp_store_api::RawAccountObservationSummary>>> {
|
||||
let network_check = validate_operation_network(&self.network, query.network(), self.backend_kind);
|
||||
if let std::result::Result::Err(error) = network_check {
|
||||
return std::boxed::Box::pin(async move {
|
||||
return std::result::Result::Err(error);
|
||||
});
|
||||
}
|
||||
return std::boxed::Box::pin(async move {
|
||||
#[cfg(feature = "postgres")]
|
||||
{
|
||||
return match &self.runtime {
|
||||
StoreRuntime::Postgres(backend) => {
|
||||
let result = backend.inspect_raw_account_observations(query).await;
|
||||
result.map_err(|error| return map_postgres_error(error, self.backend_kind, self.network.as_str()))
|
||||
},
|
||||
};
|
||||
}
|
||||
#[cfg(not(feature = "postgres"))]
|
||||
{
|
||||
let _ = query;
|
||||
return std::result::Result::Err(unavailable_runtime_error(self.backend_kind));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl ksp_store_api::RawAccountObservationRead for Store {
|
||||
fn get_raw_account_observation<'a>(
|
||||
&'a self,
|
||||
@@ -424,6 +454,36 @@ impl ksp_store_api::RawTransactionWrite for Store {
|
||||
}
|
||||
}
|
||||
|
||||
impl ksp_store_api::RawTransactionObservationInspectionRead for Store {
|
||||
fn inspect_raw_transaction_observations<'a>(
|
||||
&'a self,
|
||||
query: &'a ksp_store_api::RawTransactionObservationInspectionQuery,
|
||||
) -> ksp_store_api::StoreApiFuture<'a, ksp_store_api::Result<ksp_store_api::RawInspectionPage<ksp_store_api::RawTransactionObservationSummary>>> {
|
||||
let network_check = validate_operation_network(&self.network, query.network(), self.backend_kind);
|
||||
if let std::result::Result::Err(error) = network_check {
|
||||
return std::boxed::Box::pin(async move {
|
||||
return std::result::Result::Err(error);
|
||||
});
|
||||
}
|
||||
return std::boxed::Box::pin(async move {
|
||||
#[cfg(feature = "postgres")]
|
||||
{
|
||||
return match &self.runtime {
|
||||
StoreRuntime::Postgres(backend) => {
|
||||
let result = backend.inspect_raw_transaction_observations(query).await;
|
||||
result.map_err(|error| return map_postgres_error(error, self.backend_kind, self.network.as_str()))
|
||||
},
|
||||
};
|
||||
}
|
||||
#[cfg(not(feature = "postgres"))]
|
||||
{
|
||||
let _ = query;
|
||||
return std::result::Result::Err(unavailable_runtime_error(self.backend_kind));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl ksp_store_api::RawTransactionObservationRead for Store {
|
||||
fn get_raw_transaction_observation<'a>(
|
||||
&'a self,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-lib/tests/dependency_boundary.rs
|
||||
// version: 10
|
||||
// version: 11
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
@@ -60,15 +60,17 @@ fn pre_005_facade_exposes_no_physical_postgres_types_or_environment_bypass() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_8_pre_005_facade_dispatches_twelve_raw_capabilities_without_physical_leak() {
|
||||
fn v0_3_8_pre_009_facade_dispatches_fourteen_raw_capabilities_without_physical_leak() {
|
||||
let store = include_str!("../src/store.rs");
|
||||
for required in [
|
||||
"impl ksp_store_api::RawAccountObservationInspectionRead for Store",
|
||||
"impl ksp_store_api::RawAccountObservationRead for Store",
|
||||
"impl ksp_store_api::RawAccountObservationWrite for Store",
|
||||
"impl ksp_store_api::RawAccountStateInspectionRead for Store",
|
||||
"impl ksp_store_api::RawAccountStateRead for Store",
|
||||
"impl ksp_store_api::RawAccountStateWrite for Store",
|
||||
"impl ksp_store_api::RawTransactionInspectionRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationInspectionRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationWrite for Store",
|
||||
"impl ksp_store_api::RawTransactionRead for Store",
|
||||
@@ -81,7 +83,7 @@ fn v0_3_8_pre_005_facade_dispatches_twelve_raw_capabilities_without_physical_lea
|
||||
] {
|
||||
assert!(store.contains(required), "missing pre.008 Store capability dispatch contract: {required}");
|
||||
}
|
||||
assert_eq!(store.matches("impl ksp_store_api::Raw").count(), 12);
|
||||
assert_eq!(store.matches("impl ksp_store_api::Raw").count(), 14);
|
||||
for forbidden in ["tokio_postgres::", "deadpool_postgres::", "CREATE TABLE", "INSERT INTO", "UPDATE ksp_", "DELETE FROM"] {
|
||||
assert!(!store.contains(forbidden), "pre.008 facade leaked physical backend material: {forbidden}");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-lib/tests/hardening_completeness.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
@@ -155,7 +155,10 @@ fn pre_009_facade_modules_and_crate_root_exports_are_exact() {
|
||||
"PostgresTlsMode",
|
||||
"Pubkey",
|
||||
"RawAccountObservation",
|
||||
"RawAccountObservationInspectionQuery",
|
||||
"RawAccountObservationInspectionRead",
|
||||
"RawAccountObservationRead",
|
||||
"RawAccountObservationSummary",
|
||||
"RawAccountObservationWrite",
|
||||
"RawAccountState",
|
||||
"RawAccountStateInspectionQuery",
|
||||
@@ -192,7 +195,10 @@ fn pre_009_facade_modules_and_crate_root_exports_are_exact() {
|
||||
"RawTransactionInspectionQuery",
|
||||
"RawTransactionInspectionRead",
|
||||
"RawTransactionObservation",
|
||||
"RawTransactionObservationInspectionQuery",
|
||||
"RawTransactionObservationInspectionRead",
|
||||
"RawTransactionObservationRead",
|
||||
"RawTransactionObservationSummary",
|
||||
"RawTransactionObservationWrite",
|
||||
"RawTransactionQuery",
|
||||
"RawTransactionRead",
|
||||
@@ -216,7 +222,7 @@ fn pre_009_facade_modules_and_crate_root_exports_are_exact() {
|
||||
];
|
||||
expected.sort_unstable();
|
||||
assert_eq!(actual.as_slice(), expected.as_slice());
|
||||
assert_eq!(actual.len(), 99);
|
||||
assert_eq!(actual.len(), 105);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -292,15 +298,17 @@ fn pre_009_facade_production_sources_keep_config_env_physical_sql_and_backend_ha
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_8_pre_005_facade_raw_capability_inventory_is_exactly_twelve() {
|
||||
fn v0_3_8_pre_009_facade_raw_capability_inventory_is_exactly_fourteen() {
|
||||
let store = include_str!("../src/store.rs");
|
||||
let capability_impls = [
|
||||
"impl ksp_store_api::RawAccountObservationInspectionRead for Store",
|
||||
"impl ksp_store_api::RawAccountObservationRead for Store",
|
||||
"impl ksp_store_api::RawAccountObservationWrite for Store",
|
||||
"impl ksp_store_api::RawAccountStateInspectionRead for Store",
|
||||
"impl ksp_store_api::RawAccountStateRead for Store",
|
||||
"impl ksp_store_api::RawAccountStateWrite for Store",
|
||||
"impl ksp_store_api::RawTransactionInspectionRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationInspectionRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationRead for Store",
|
||||
"impl ksp_store_api::RawTransactionObservationWrite for Store",
|
||||
"impl ksp_store_api::RawTransactionRead for Store",
|
||||
@@ -311,8 +319,8 @@ fn v0_3_8_pre_005_facade_raw_capability_inventory_is_exactly_twelve() {
|
||||
for implementation in capability_impls {
|
||||
assert_eq!(store.matches(implementation).count(), 1, "unexpected Store capability implementation inventory: {implementation}");
|
||||
}
|
||||
assert_eq!(store.matches("impl ksp_store_api::Raw").count(), 12);
|
||||
assert_eq!(store.matches("validate_operation_network(").count(), 16);
|
||||
assert_eq!(store.matches("impl ksp_store_api::Raw").count(), 14);
|
||||
assert_eq!(store.matches("validate_operation_network(").count(), 18);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -322,11 +330,13 @@ fn v0_3_8_pre_005_facade_and_backend_capability_sets_match_with_both_inspection_
|
||||
let backend = include_str!("../../ksp-store-postgres-lib/src/runtime.rs");
|
||||
let store_traits = raw_capability_trait_names(store, " for Store");
|
||||
let backend_traits = raw_capability_trait_names(backend, " for PostgresBackend");
|
||||
assert_eq!(store_traits.len(), 12);
|
||||
assert_eq!(backend_traits.len(), 12);
|
||||
assert_eq!(store_traits.len(), 14);
|
||||
assert_eq!(backend_traits.len(), 14);
|
||||
assert_eq!(store_traits, backend_traits);
|
||||
assert!(store_traits.contains(&"RawTransactionInspectionRead"));
|
||||
assert!(store_traits.contains(&"RawAccountStateInspectionRead"));
|
||||
assert!(store_traits.contains(&"RawTransactionObservationInspectionRead"));
|
||||
assert!(store_traits.contains(&"RawAccountObservationInspectionRead"));
|
||||
for forbidden in ["RawAccountRetentionRead", "RawAccountRetentionWrite", "RawAccountDelete", "RawAccountCompaction"] {
|
||||
assert!(!store_traits.contains(&forbidden), "unexpected account capability added to Store: {forbidden}");
|
||||
assert!(!backend_traits.contains(&forbidden), "unexpected account capability added to PostgreSQL backend: {forbidden}");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-lib/tests/public_api.rs
|
||||
// version: 11
|
||||
// version: 12
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
@@ -79,12 +79,14 @@ fn pre_007_health_and_runtime_snapshot_types_are_portable_crate_root_contracts()
|
||||
|
||||
fn assert_raw_capabilities<T>()
|
||||
where
|
||||
T: ksp_store_lib::RawAccountObservationRead
|
||||
T: ksp_store_lib::RawAccountObservationInspectionRead
|
||||
+ ksp_store_lib::RawAccountObservationRead
|
||||
+ ksp_store_lib::RawAccountObservationWrite
|
||||
+ ksp_store_lib::RawAccountStateInspectionRead
|
||||
+ ksp_store_lib::RawAccountStateRead
|
||||
+ ksp_store_lib::RawAccountStateWrite
|
||||
+ ksp_store_lib::RawTransactionInspectionRead
|
||||
+ ksp_store_lib::RawTransactionObservationInspectionRead
|
||||
+ ksp_store_lib::RawTransactionObservationRead
|
||||
+ ksp_store_lib::RawTransactionObservationWrite
|
||||
+ ksp_store_lib::RawTransactionRead
|
||||
@@ -97,7 +99,7 @@ where
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v0_3_8_pre_005_store_facade_implements_both_inspection_capabilities_as_12_of_12() {
|
||||
fn v0_3_8_pre_009_store_facade_implements_entity_and_observation_inspection_capabilities_as_14_of_14() {
|
||||
assert_raw_capabilities::<ksp_store_lib::Store>();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user