From 78b9aa12bd80496131295e0f82c4658177d69450 Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Thu, 8 Oct 2026 09:27:07 +0800 Subject: [PATCH] Align native fixtures with captured database scope and exact guards The UN30 facade fixture now supplies its actual per-test database config to full storage assembly, so the rooted Q pool shares the correct database. The forged namespace insertion must match its exact BEFORE INSERT registration guard and roll back, preserving every route/source state assertion. The durable scope-drift test now expects the shared family-selection contract: 502 INTEGRITY_ERROR with retryable=false for both descriptor and renew, before a G/Q repository is selected. It retains stream error/no-END, scope restoration and no-IO assertions. Three owned nightly format/parse and whitespace source checks pass; native execution remains unrun. --- src/api/router/snapshot_session_tests.rs | 13 +++++++------ src/api/router/snapshot_storage_route_tests.rs | 12 ++++++++++-- src/context/un30_readonly.rs | 6 +++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/api/router/snapshot_session_tests.rs b/src/api/router/snapshot_session_tests.rs index 68feb23a..e7f4f734 100644 --- a/src/api/router/snapshot_session_tests.rs +++ b/src/api/router/snapshot_session_tests.rs @@ -1293,11 +1293,12 @@ async fn mst2_durable_http_warm_reads_renew_and_frame_delivery_reject_primary_sc .try_get_by_index(0) .unwrap(); overwrite_primary_scope_for_test(db, uuid::Uuid::new_v4().to_string()).await; + // Family selection rejects physical authority drift as INTEGRITY_ERROR. error( fixture.send("GET", "descriptor", Body::empty()).await, - 500, - "INTERNAL", - true, + 502, + "INTEGRITY_ERROR", + false, ) .await; error( @@ -1314,9 +1315,9 @@ async fn mst2_durable_http_warm_reads_renew_and_frame_delivery_reject_primary_sc ) .await .unwrap(), - 500, - "INTERNAL", - true, + 502, + "INTEGRITY_ERROR", + false, ) .await; assert!( diff --git a/src/api/router/snapshot_storage_route_tests.rs b/src/api/router/snapshot_storage_route_tests.rs index 63b59fc6..e5a0ad42 100644 --- a/src/api/router/snapshot_storage_route_tests.rs +++ b/src/api/router/snapshot_storage_route_tests.rs @@ -483,11 +483,19 @@ async fn mst2_generic_storage_routes_raw_lease_derives_atomically_and_half_rows_ SELECT (jsonb_populate_record(NULL::mst2_lease_storage_route, to_jsonb(r)||jsonb_build_object('lease_id','{lease}'))).* FROM mst2_lease_storage_route r", )).await; - rejected(db, + let txn = db.begin().await.unwrap(); + let error = txn.execute_unprepared( "INSERT INTO mst2_metadata_namespace SELECT (jsonb_populate_record(NULL::mst2_metadata_namespace, to_jsonb(n)||jsonb_build_object('namespace_uuid','00000000-0000-4000-8000-000000000001', 'graph_domain','qualified-v1'))).* FROM mst2_metadata_namespace n", - ).await; + ).await.expect_err("unadmitted qualified namespace must be rejected before commit"); + assert!( + error.to_string().contains( + "qualified namespace registration has no exact admitted rooted family scope and lock set" + ), + "wrong qualified namespace rejection: {error}" + ); + txn.rollback().await.unwrap(); assert_eq!(routes(db).await, original); assert_eq!(sources(db).await, source); } diff --git a/src/context/un30_readonly.rs b/src/context/un30_readonly.rs index ad829a0f..d95a03b6 100644 --- a/src/context/un30_readonly.rs +++ b/src/context/un30_readonly.rs @@ -244,9 +244,9 @@ async fn un30_building_the_read_facade_writes_no_sidebar() { .await .expect("writable connection"), ); - let config = Arc::new(crate::config::testing::isolated_config( - temp.path().join("config"), - )); + let mut config = crate::config::testing::isolated_config(temp.path().join("config")); + config.database = db_config.clone(); + let config = Arc::new(config); assert!( !sidebar_table_exists(&writable).await,