v0.3.3-pre.009-fix.006
This commit is contained in:
@@ -6,7 +6,7 @@ resolver = "3"
|
||||
members = ["crates/ksp-app-config-desk", "crates/ksp-app-solprices-desk", "crates/ksp-app-wallet-desk", "crates/ksp-config-lib", "crates/ksp-core-lib", "crates/ksp-interface-lib", "crates/ksp-logging-lib", "crates/ksp-offchain-transport-lib", "crates/ksp-onchain-transport-lib", "crates/ksp-program-api", "crates/ksp-store-api", "crates/ksp-store-lib", "crates/ksp-store-postgres-lib", "crates/ksp-wallet-lib"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.3.3-pre.9.fix.5"
|
||||
version = "0.3.3-pre.9.fix.6"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://git.sasedev.com/Sasedev/khadhroony-solana-project"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-postgres-lib/src/migration.rs
|
||||
// version: 6
|
||||
// version: 7
|
||||
|
||||
use sha2::Digest; // rust-rules: trait-import
|
||||
|
||||
@@ -557,10 +557,7 @@ async fn verify_or_repair_applied_migrations(
|
||||
crate::SchemaResourceState::Missing => {
|
||||
if !schema_autoupdate {
|
||||
log_schema_resource_block(resource.id, "schema_autoupdate_disabled");
|
||||
return std::result::Result::Err(crate::PostgresBackendError::new(
|
||||
crate::PostgresBackendErrorKind::MigrationFailed,
|
||||
"schema_autoupdate_disabled",
|
||||
));
|
||||
return std::result::Result::Err(schema_autoupdate_disabled_error());
|
||||
}
|
||||
let repair_result = ensure_resource(transaction, resource, SchemaMutationMode::Update, true).await;
|
||||
if let std::result::Result::Err(error) = repair_result {
|
||||
@@ -578,6 +575,10 @@ async fn verify_or_repair_applied_migrations(
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
|
||||
fn schema_autoupdate_disabled_error() -> crate::PostgresBackendError {
|
||||
return crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationMismatch, "schema_autoupdate_disabled");
|
||||
}
|
||||
|
||||
fn validate_embedded_registry(migrations: &[EmbeddedMigration]) -> std::result::Result<(), crate::PostgresBackendError> {
|
||||
if migrations.is_empty() {
|
||||
return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationMismatch, "registry_empty"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-postgres-lib/unit_tests/migration.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
fn applied(version: i64, name: &str, checksum: &str) -> super::AppliedMigration {
|
||||
return super::AppliedMigration { checksum: checksum.to_owned(), name: name.to_owned(), version };
|
||||
@@ -132,3 +132,11 @@ fn pre_003_fix_001_newer_history_is_rejected_without_down_migration() {
|
||||
assert_eq!(result.err().map(|value| return value.kind()), std::option::Option::Some(crate::PostgresBackendErrorKind::SchemaNewer));
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_009_fix_006_missing_applied_resource_with_autoupdate_disabled_is_migration_mismatch() {
|
||||
let error = super::schema_autoupdate_disabled_error();
|
||||
assert_eq!(error.kind(), crate::PostgresBackendErrorKind::MigrationMismatch);
|
||||
assert_eq!(error.phase(), "schema_autoupdate_disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
104
deltas/0.3.3/pre.009-fix.006.md
Normal file
104
deltas/0.3.3/pre.009-fix.006.md
Normal file
@@ -0,0 +1,104 @@
|
||||
<!-- file: deltas/0.3.3/pre.009-fix.006.md -->
|
||||
<!-- version: 1 -->
|
||||
|
||||
# Delta `0.3.3-pre.009-fix.006` — restauration `schema.rs` et classification du drift appliqué
|
||||
|
||||
## 1. Base et diagnostic
|
||||
|
||||
Base opérateur :
|
||||
|
||||
```text
|
||||
0.3.3-pre.9.fix.5
|
||||
```
|
||||
|
||||
Deux faits distincts sont corrigés.
|
||||
|
||||
Premièrement, l'overlay `pre.009-fix.005` a accidentellement tronqué la fin de `crates/ksp-store-postgres-lib/src/schema.rs` lors de la généralisation de la normalisation PostgreSQL. Les éléments privés suivants avaient disparu de l'archive alors qu'ils restent requis :
|
||||
|
||||
```rust
|
||||
fn schema_incompatible<T>(phase: &'static str) -> std::result::Result<T, crate::PostgresBackendError>
|
||||
fn schema_query_error<T>(phase: &'static str) -> std::result::Result<T, crate::PostgresBackendError>
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../unit_tests/schema.rs"]
|
||||
mod tests;
|
||||
```
|
||||
|
||||
L'opérateur les a restaurés et le gate standard est redevenu entièrement propre. `fix.006` réembarque explicitement le fichier complet afin que l'historique d'overlays soit autonome.
|
||||
|
||||
Deuxièmement, le live PostgreSQL 17 progresse maintenant jusqu'au scénario qui supprime volontairement l'index géré puis rouvre le backend avec `schema_autoupdate=false`. Le backend renvoyait `MigrationFailed`, alors que le contrat live attend `MigrationMismatch`.
|
||||
|
||||
## 2. Version
|
||||
|
||||
```text
|
||||
workspace.package.version = 0.3.3-pre.9.fix.6
|
||||
```
|
||||
|
||||
## 3. Classification corrigée
|
||||
|
||||
Dans `verify_or_repair_applied_migrations`, une ressource `Missing` d'une migration déjà présente dans l'historique signifie que l'état physique ne correspond plus au schéma déclaré. Lorsque `schema_autoupdate=false`, KSP ne tente aucune réparation et retourne désormais :
|
||||
|
||||
```text
|
||||
PostgresBackendErrorKind::MigrationMismatch
|
||||
phase = schema_autoupdate_disabled
|
||||
```
|
||||
|
||||
Cette correction est volontairement limitée à ce chemin. Les cas où aucune divergence appliquée n'existe mais où une mutation est interdite par policy, notamment `migration_pending` ou `schema_autocreate_disabled`, restent classés `MigrationFailed`.
|
||||
|
||||
## 4. Canari
|
||||
|
||||
Un helper privé `schema_autoupdate_disabled_error()` centralise la classification et le test unitaire vérifie exactement :
|
||||
|
||||
```text
|
||||
kind = MigrationMismatch
|
||||
phase = schema_autoupdate_disabled
|
||||
```
|
||||
|
||||
## 5. Migrations inchangées
|
||||
|
||||
Aucun SQL V000/V001 n'est modifié. Checksums attendus inchangés :
|
||||
|
||||
```text
|
||||
V000 d29068b8c13b9dc0cc9ef6aaadd0fa12d41e0fe4c56541a1118c4bfc846a1450
|
||||
V001 31488cda2f08f3f46c4cdbdbb6c18c243662fada02eac4487040c8735d72cc51
|
||||
```
|
||||
|
||||
## 6. Scope
|
||||
|
||||
Aucun changement de runtime RawTransaction, pagination/cursor, rétention, Store API, façade, Config ou `RawAccountState`.
|
||||
|
||||
## 7. Fichiers modifiés
|
||||
|
||||
```text
|
||||
Cargo.toml
|
||||
crates/ksp-store-postgres-lib/src/migration.rs
|
||||
crates/ksp-store-postgres-lib/src/schema.rs
|
||||
crates/ksp-store-postgres-lib/unit_tests/migration.rs
|
||||
docs/validation/020-V0_3_3_STORE_POSTGRES_RAW_TRANSACTION.md
|
||||
deltas/0.3.3/pre.009-fix.006.md
|
||||
```
|
||||
|
||||
Aucune suppression.
|
||||
|
||||
## 8. Gate opérateur attendu
|
||||
|
||||
```bash
|
||||
cargo fmt --all
|
||||
python3 scripts/audit_rust_workspace_rules.py
|
||||
python3 scripts/audit_markdown_tables.py README.md RULES.md ROADMAP.md CHANGELOG.md docs prompts crates deltas/0.3.3
|
||||
cargo check --workspace
|
||||
cargo clippy --workspace --all-targets
|
||||
cargo test -p ksp-store-api
|
||||
cargo test -p ksp-store-lib
|
||||
cargo test -p ksp-store-postgres-lib
|
||||
cargo test -p ksp-config-lib
|
||||
cargo check -p ksp-store-lib --no-default-features
|
||||
```
|
||||
|
||||
Puis :
|
||||
|
||||
```bash
|
||||
read -rsp "Dedicated PostgreSQL URI: " KSP_PG_TEST_URI; echo
|
||||
printf '%s\n' "$KSP_PG_TEST_URI" | cargo test -p ksp-store-postgres-lib --test postgres_raw_transaction_live -- --ignored --nocapture --test-threads=1
|
||||
unset KSP_PG_TEST_URI
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- file: docs/validation/020-V0_3_3_STORE_POSTGRES_RAW_TRANSACTION.md -->
|
||||
<!-- version: 19 -->
|
||||
<!-- version: 20 -->
|
||||
|
||||
# Validation `0.3.3` — Store/PostgreSQL RawTransaction vertical slice
|
||||
|
||||
@@ -797,3 +797,14 @@ cargo check -p ksp-store-lib --no-default-features
|
||||
- [PASS statique] les quotes des littéraux texte restent préservées et aucune comparaison métier n'est relâchée ;
|
||||
- [PASS statique] aucune ressource SQL V000/V001 ni checksum de migration n'est modifié ;
|
||||
- [À FAIRE] gate Cargo opérateur complet puis live PostgreSQL `postgres_raw_transaction_live`.
|
||||
|
||||
### `pre.009-fix.006` — restauration du tail `schema.rs` et classification du drift avec auto-update désactivé
|
||||
|
||||
- [PASS opérateur] gate standard `pre.009-fix.005` propre après restauration des helpers privés supprimés accidentellement par l'overlay : `schema_incompatible`, `schema_query_error` et le module de tests `schema` ;
|
||||
- [DIAGNOSTIC LIVE] PostgreSQL 17 applique désormais V001 puis le scénario de preuve atteint `schema_autoupdate_disabled_classification` après suppression volontaire de l'index géré ;
|
||||
- [FIX] une ressource manquante appartenant à une migration déjà enregistrée est classée `MigrationMismatch` lorsque `schema_autoupdate=false`, car le schéma physique diverge de l'historique déclaré ;
|
||||
- [PASS statique] un helper privé centralise cette classification et un test unitaire vérifie le couple exact `MigrationMismatch` / `schema_autoupdate_disabled` ;
|
||||
- [PASS statique] `migration_pending`, `schema_autocreate_disabled` et les autres refus purement policy restent `MigrationFailed` ;
|
||||
- [PASS statique] aucune ressource SQL V000/V001, ordre de ressource ou checksum de migration n'est modifié ;
|
||||
- [À FAIRE] gate Cargo opérateur puis live PostgreSQL `postgres_raw_transaction_live`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user