Skip to content

refactor: make delete_metadata a proper backend contract (spec 551)#685

Merged
Muizzkolapo merged 2 commits into
mainfrom
fix/551-delete-metadata-contract
Jun 14, 2026
Merged

refactor: make delete_metadata a proper backend contract (spec 551)#685
Muizzkolapo merged 2 commits into
mainfrom
fix/551-delete-metadata-contract

Conversation

@Muizzkolapo

Copy link
Copy Markdown
Owner

Summary

  • delete_metadata: changed from silent no-op (returns False) to raise NotImplementedError — future backends must implement metadata deletion
  • delete_metadata_prefix: added to StorageBackend base class with raise NotImplementedError
  • clear_batch_state: implemented on the base class using delete_metadata + delete_metadata_prefix, removing the redundant SQLiteBackend override (identical logic)
  • FakeBackend in test_circuit_breaker.py: implements both new required methods

Why

The no-op default meant non-SQLite backends silently failed to delete metadata. RecoveryStateManager.delete() and BatchContextManager.delete_batch_context_map() call delete_metadata directly — stale recovery state would persist and the next run would incorrectly resume recovery.

Verification

  • pytest → 7488 passed, 2 skipped
  • ruff check → all checks passed
  • ruff format --check → 954 files already formatted

Files changed

File Change
storage/backend.py delete_metadata raises, delete_metadata_prefix added, clear_batch_state implemented
storage/backends/sqlite_backend.py Removed redundant clear_batch_state override
tests/unit/workflow/test_circuit_breaker.py FakeBackend implements both methods

- delete_metadata: no-op returning False → raises NotImplementedError
- delete_metadata_prefix: added to base class, raises NotImplementedError
- clear_batch_state: implemented on base class using delete_metadata +
  delete_metadata_prefix, removed redundant SQLite override
- FakeBackend in test_circuit_breaker: implements both methods

Future backends must implement metadata deletion. The silent no-op that
left stale recovery state on non-SQLite backends is eliminated.
Add tests for delete_metadata, delete_metadata_prefix, and clear_batch_state
on the real SQLiteBackend implementation:

- delete_metadata removes key and returns True; False when missing
- delete_metadata_prefix matches prefix via LIKE, returns count; 0 when no match
- clear_batch_state wipes batch_registry, recovery_state, and batch_context keys
  for an action while leaving unrelated keys untouched
- clear_batch_state is idempotent (no-op when action has no state)

These replace the prior synthetic NotImplementedError tautology tests with
actual behavioral coverage of the SQL layer.

Refs: spec 551
@Muizzkolapo Muizzkolapo merged commit 24aae0d into main Jun 14, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant