Skip to content

Commit aefd0c8

Browse files
committed
Enforce strict catalog verification on reads
1 parent 7c878c5 commit aefd0c8

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎src/openstatspec/sql/wide.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ def read_wide_dataset(
10001000
engine = create_engine(database_url)
10011001
normative = normative_catalog(MetaData())
10021002
with engine.connect() as connection:
1003-
_verify_normative_catalog(connection, normative)
1003+
require_verified_catalog(connection)
10041004
dataset_row = _resolve_normative_dataset(connection, normative, dataset_id)
10051005
core_id = str(dataset_row["dataset_id"])
10061006
data_table = Table(
@@ -1331,7 +1331,7 @@ def read_fidelity_events(
13311331
engine = create_engine(database_url)
13321332
normative = normative_catalog(MetaData())
13331333
with engine.connect() as connection:
1334-
_verify_normative_catalog(connection, normative)
1334+
require_verified_catalog(connection)
13351335
dataset = _resolve_normative_dataset(connection, normative, dataset_id)
13361336
events = connection.execute(
13371337
select(normative.fidelity_event)
@@ -1367,6 +1367,7 @@ def _bound_export_audit_transaction(
13671367
audit_relations={normative.operation.name, normative.fidelity_event.name},
13681368
phase=phase,
13691369
) as connection:
1370+
require_verified_catalog(connection)
13701371
yield connection, normative
13711372

13721373

@@ -1464,7 +1465,7 @@ def read_export_operation_state(
14641465
)
14651466
normative = normative_catalog(MetaData())
14661467
with create_engine(database_url).connect() as connection:
1467-
_verify_normative_catalog(connection, normative)
1468+
require_verified_catalog(connection)
14681469
row = _export_operation_row(connection, normative, operation_id)
14691470
classification = {
14701471
"started": "running",

‎tests/test_strict_catalog_review.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ def test_existing_normative_shape_drift_is_rejected(tmp_path):
7575
openstatspec.initialize_catalog(database_url=database)
7676

7777

78+
def test_read_and_export_reject_obsolete_catalog_relations(tmp_path):
79+
path = tmp_path / "obsolete-read.sqlite"
80+
database = f"sqlite:///{path}"
81+
_create(database, "sample")
82+
connection = sqlite3.connect(path)
83+
connection.execute("create table dataset_catalog (dataset_id text primary key)")
84+
connection.commit()
85+
connection.close()
86+
87+
with pytest.raises(UnsupportedOperationError, match="obsolete"):
88+
wide.read_wide_dataset(database_url=database, dataset_id="sample")
89+
with pytest.raises(UnsupportedOperationError, match="obsolete"):
90+
wide.record_export_operation(
91+
database_url=database,
92+
dataset_id="sample",
93+
destination="sample.sav",
94+
allowed_fidelity_events=(),
95+
)
96+
97+
7898
def test_verified_workflow_profile_remains_catalog_owned(tmp_path):
7999
path = tmp_path / "workflow-owned.sqlite"
80100
database = f"sqlite:///{path}"

0 commit comments

Comments
 (0)