Skip to content

refactor(BA-6620): ExistsQuerier ops primitive + AppConfigAllowList.exists#12405

Merged
fregataa merged 4 commits into
mainfrom
feat/BA-6620-exists-querier-allow-list-exists
Jun 25, 2026
Merged

refactor(BA-6620): ExistsQuerier ops primitive + AppConfigAllowList.exists#12405
fregataa merged 4 commits into
mainfrom
feat/BA-6620-exists-querier-allow-list-exists

Conversation

@jopemachine

@jopemachine jopemachine commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Adds the existence-check repository primitive used by the AppConfig fragment write-gate, split out of #12358 to keep that PR small:

  • ExistsQuerier dataclass + execute_exists in repositories/baseSELECT EXISTS(SELECT 1 FROM table WHERE ...), no count/fetch.
  • ReadOps.exists on the ops provider (so it is available inside write_ops() too — WriteOps extends ReadOps).
  • AppConfigAllowListRepository.exists (+ db_source) built on ExistsQuerier.
  • Real-DB repository tests for 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:

  1. feat(BA-6552): add app_config_fragments DB model and Alembic migration #12306feat(BA-6552): app_config_fragments DB model and Alembic migration
  2. feat(BA-6553): add app_config_fragments repository layer #12307feat(BA-6553): repository layer
  3. refactor(BA-6619): consolidate AppConfigScopeType into common.data (single definition) #12403refactor(BA-6619): consolidate AppConfigScopeType into common.data
  4. 👉 refactor(BA-6620): ExistsQuerier ops primitive + AppConfigAllowList.exists #12405refactor(BA-6620): ExistsQuerier + AppConfigAllowList.exists ← you are here
  5. feat(BA-6554): add app_config_fragment service layer #12358feat(BA-6554): AppConfigFragment service layer
  6. feat(BA-6618): app_config_fragment bulk CRUD service layer #12401feat(BA-6618): AppConfigFragment bulk CRUD service layer
  7. feat(BA-6555): add app_config service layer #12359feat(BA-6555): app_config service layer
  8. feat(BA-6556): AppConfig REST v2 API (raw fragments and merged read/update) #12377feat(BA-6556): AppConfig REST v2 API

seedspirit
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
@seedspirit seedspirit dismissed their stale review June 25, 2026 06:25

The base branch was changed.

jopemachine and others added 2 commits June 25, 2026 15:31
…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>
@jopemachine jopemachine force-pushed the feat/BA-6620-exists-querier-allow-list-exists branch from 64c5fb0 to 5c3cbe1 Compare June 25, 2026 06:31
@jopemachine jopemachine requested review from a team and seedspirit June 25, 2026 06:32
Comment thread src/ai/backend/manager/repositories/base/querier.py Outdated
Comment thread src/ai/backend/manager/repositories/ops/base/provider.py
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>
Copilot AI review requested due to automatic review settings June 25, 2026 06:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-combined conditions) in repositories/base/querier.py, exported from base/__init__.py.
  • Adds ReadOps.exists to the ops provider (also usable from write_ops() since WriteOps extends ReadOps).
  • 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.

Comment thread src/ai/backend/manager/repositories/ops/base/provider.py
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>
@jopemachine jopemachine requested review from a team and fregataa June 25, 2026 07:04
@fregataa fregataa merged commit 52e6c41 into main Jun 25, 2026
33 checks passed
@fregataa fregataa deleted the feat/BA-6620-exists-querier-allow-list-exists branch June 25, 2026 07:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants