lablup / lablup/backend.ai

Implement existence_checks for the purger spec pattern

Open
#13,025 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

The purger pattern has no declarative precondition mechanism. The docstrings of `execute_purger` and `execute_batch_purger` in `repositories/base/purger.py` tell callers to use existence_checks before invoking the purger, but no such hook exists on purger specs. Today `ExistenceCheck` is only available on `SearchScope` for batch queriers, so purge paths signal a missing target only via a None result or deleted_count, and constraint violations surface as parsed integrity errors without domain mapping.

Add declarative existence checks to the purger specs, mirroring the existing declarative contracts (SearchScope.existence_checks for queriers, CreatorSpec.integrity_error_checks for creators):

- Add an `existence_checks` property to the purger spec surface (`Purger` / `BatchPurgerSpec` and the RBAC variants `RBACEntityPurgerSpec` / `RBACEntityBatchPurgerSpec`) returning a sequence of checks with the domain error to raise on failure.
- Validate the aggregated checks in a single query before deletion inside the purger executors, reusing the `ExistenceCheck` validation approach used by `execute_batch_querier`.
- Migrate one caller (e.g. group purge) to declare its checks on the spec instead of ad-hoc pre-flight SELECTs, as the reference usage.
- Update the executor docstrings so the referenced contract actually exists, and cover the success/failure paths with repository tests.

JIRA Issue: BA-6969

Contributor guide

Open the contributing guide

Research direction

Start in repositories/base/purger.py, reading the Purger and batch purger executor docstrings and the RBAC spec variants. Compare their contracts with SearchScope.existence_checks, execute_batch_querier, and CreatorSpec.integrity_error_checks. Follow the group purge caller and repository tests; done means declarative checks work for success and failure paths, the caller uses them, and the executor documentation matches the available contract.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.