Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fixed issues from qodo and copilot

Sameer630574c093facb62
diff --git a/tests/provenance/test_manager.py b/tests/provenance/test_manager.py
index 4e1fdd91..d1d80131 100644
--- a/tests/provenance/test_manager.py
+++ b/tests/provenance/test_manager.py
@@ -763,9 +763,15 @@ class TestProvenanceManager:
prov_mgr = ProvenanceManager(storage_path=db_path)
chunks = [{"id": f"chk_{i}", "start_index": 0, "end_index": 10} for i in range(5)]
+ # Capture the unpatched bound method first: once `transaction` is patched below,
+ # `prov_mgr.storage.transaction` would resolve to the mock itself, and calling it
+ # from inside failing_tx() would recurse into the mock instead of the real
+ # implementation (RecursionError, not the intended sqlite3.OperationalError).
+ orig_transaction = prov_mgr.storage.transaction
+
@contextmanager
def failing_tx():
- with prov_mgr.storage.transaction() as conn:
+ with orig_transaction() as conn:
yield conn
raise sqlite3.OperationalError("Commit failed")
@@ -775,6 +781,11 @@ class TestProvenanceManager:
assert count == 0
mock_log_error.assert_called_once()
assert "Block-level storage transaction failed in track_chunks_batch" in mock_log_error.call_args[0][0]
+ # Confirm the logged exception is the injected commit failure, not some
+ # other failure mode (e.g. a mocking mistake re-entering the patched mock).
+ logged_exc = mock_log_error.call_args[0][1]
+ assert isinstance(logged_exc, sqlite3.OperationalError)
+ assert str(logged_exc) == "Commit failed"
assert len(prov_mgr.storage.retrieve_all()) == 0
diff --git a/tests/provenance/test_sqlite_storage_performance_807.py b/tests/provenance/test_sqlite_storage_performance_807.py
index faeb24e9..fd488f82 100644
--- a/tests/provenance/test_sqlite_storage_performance_807.py
+++ b/tests/provenance/test_sqlite_storage_performance_807.py
@@ -101,9 +101,13 @@ def test_batch_rollback_does_not_count_unpersisted_entries(tmp_path):
entities = [{"id": f"ent_{i}"} for i in range(10)]
chunks = [{"id": f"chk_{i}", "start_index": 0, "end_index": 10} for i in range(10)]
+ # Capture the unpatched method before patching to avoid infinite recursion:
+ # failing_tx() needs the real transaction() implementation, but patch replaces it.
+ orig_transaction = mgr.storage.transaction
+
@contextmanager
def failing_tx():
- with mgr.storage.transaction() as conn:
+ with orig_transaction() as conn:
yield conn
raise sqlite3.OperationalError("Commit failed")