refactor(BA-6620): ExistsQuerier ops primitive + AppConfigAllowList.exists#12405
Merged
Conversation
This was referenced Jun 25, 2026
Merged
seedspirit
previously approved these changes
Jun 25, 2026
Base automatically changed from
feat/BA-6619-app-config-scope-type-consolidation
to
main
June 25, 2026 06:25
…st.exists Add a generic ExistsQuerier (SELECT EXISTS(...)) on the read ops and an AppConfigAllowListRepository.exists method built on it. Split out of the AppConfigFragment service PR (BA-6554) — the fragment write-gate consumes this primitive; here it lands as reusable repository infrastructure at the base of the stack. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64c5fb0 to
5c3cbe1
Compare
fregataa
reviewed
Jun 25, 2026
Address PR review: drop the standalone execute_exists function and implement the SELECT EXISTS(...) directly inside ReadOps.exists, and add DBOpsProvider-level unit tests for the exists path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a reusable existence-check repository primitive to the manager's layered DB-access stack, split out of the larger AppConfigFragment service PR (#12358) to keep that change focused. It introduces an ExistsQuerier spec dataclass and an exists operation that runs SELECT EXISTS(SELECT ... WHERE ...) without counting or fetching rows, then wires it through the app_config_allow_list repository so the upcoming fragment write-gate can cheaply check whether an allow-list row is registered.
Changes:
- Adds
ExistsQuerier[TRow]dataclass (row_class+ AND-combinedconditions) inrepositories/base/querier.py, exported frombase/__init__.py. - Adds
ReadOps.existsto the ops provider (also usable fromwrite_ops()sinceWriteOpsextendsReadOps). - Adds
AppConfigAllowListRepository.exists(+ db_source delegation) and real-DB tests for both the ops provider and the repository.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/ai/backend/manager/repositories/base/querier.py |
New ExistsQuerier dataclass spec. |
src/ai/backend/manager/repositories/base/__init__.py |
Exports ExistsQuerier. |
src/ai/backend/manager/repositories/ops/base/provider.py |
New ReadOps.exists; builds the EXISTS query inline (deviates from the execute_* delegation pattern). |
src/ai/backend/manager/repositories/app_config_allow_list/repository.py |
Adds exists delegating to db_source. |
src/ai/backend/manager/repositories/app_config_allow_list/db_source/db_source.py |
Adds exists running via read_ops(). |
tests/unit/manager/repositories/ops/test_provider.py |
Tests matching/absent, ANDed, and empty-conditions cases. |
tests/unit/manager/repositories/app_config_allow_list/test_repository.py |
Parametrized real-DB exists test. |
changes/12405.misc.md |
Changelog entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review: insert the seed row directly in a fixture (`seeded_parent`) instead of calling the create op inline in each test, decoupling the exists tests from create. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fregataa
approved these changes
Jun 25, 2026
jopemachine
added a commit
that referenced
this pull request
Jun 25, 2026
…view) Mirror the BA-6620 review fix on this stacked branch: drop the standalone execute_exists and run SELECT EXISTS(...) directly in ReadOps.exists, so this branch does not reintroduce the removed primitive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
added a commit
that referenced
this pull request
Jun 25, 2026
…view) Mirror the BA-6620 review fix on this stacked branch: drop the standalone execute_exists and run SELECT EXISTS(...) directly in ReadOps.exists, so this branch does not reintroduce the removed primitive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
added a commit
that referenced
this pull request
Jun 25, 2026
…view) Mirror the BA-6620 review fix on this stacked branch: drop the standalone execute_exists and run SELECT EXISTS(...) directly in ReadOps.exists, so this branch does not reintroduce the removed primitive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
added a commit
that referenced
this pull request
Jun 25, 2026
…view) Mirror the BA-6620 review fix on this stacked branch: drop the standalone execute_exists and run SELECT EXISTS(...) directly in ReadOps.exists, so this branch does not reintroduce the removed primitive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the existence-check repository primitive used by the AppConfig fragment write-gate, split out of #12358 to keep that PR small:
ExistsQuerierdataclass +execute_existsinrepositories/base—SELECT EXISTS(SELECT 1 FROM table WHERE ...), no count/fetch.ReadOps.existson the ops provider (so it is available insidewrite_ops()too —WriteOpsextendsReadOps).AppConfigAllowListRepository.exists(+ db_source) built onExistsQuerier.exists.The fragment write-gate (#12358) consumes this; here it lands as reusable infrastructure at the base of the stack.
📚 Stacked PRs
Part of the AppConfigFragment / AppConfig stack under BEP-1052 (epic BA-5781). Merge in order:
feat(BA-6552): app_config_fragments DB model and Alembic migrationfeat(BA-6553): repository layerrefactor(BA-6619): consolidate AppConfigScopeType into common.datarefactor(BA-6620): ExistsQuerier + AppConfigAllowList.exists← you are herefeat(BA-6554): AppConfigFragment service layerfeat(BA-6618): AppConfigFragment bulk CRUD service layerfeat(BA-6555): app_config service layerfeat(BA-6556): AppConfig REST v2 API