feat(BA-6628): conditional-bulk repository primitives#12429
Conversation
018dd4f to
87bcc0c
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87bcc0c to
c83c084
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds generic, domain-agnostic repository primitives for gated bulk writes as step 6 of the AppConfigFragment/AppConfig stack (BEP-1052). It introduces Conditional{Creator,Updater,Purger} (a write spec paired with an only_if existence gate) and their BulkConditional* bundles, plus three WriteOps.bulk_conditional_*_partial methods that isolate each item in its own savepoint so gate-rejected, missing, or failed items are reported per-item while the rest proceed. The update/purge ops paths are refactored to delegate to new private _update_one/_purge_one helpers. Two repository errors (ConditionalWriteNotAllowed, ConditionalWriteTargetNotFound) and ops-provider unit tests round it out.
Changes:
- New conditional/bulk-conditional dataclasses in
repositories/basefor create/update/purge. WriteOps.bulk_conditional_*_partialmethods with per-item savepoint isolation, plus_update_one/_purge_oneextracted from the standaloneexecute_*functions.- New
ConditionalWriteNotAllowed/ConditionalWriteTargetNotFounderrors and ops-provider tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ai/backend/manager/repositories/base/creator.py | Adds ConditionalCreator/BulkConditionalCreator; docstring misstates semantics and references a non-existent function. |
| src/ai/backend/manager/repositories/base/updater.py | Adds ConditionalUpdater/BulkConditionalUpdater; docstring misstates semantics and method name. |
| src/ai/backend/manager/repositories/base/purger.py | Adds ConditionalPurger/BulkConditionalPurger; docstring misstates semantics and method name. |
| src/ai/backend/manager/repositories/base/init.py | Exports the new conditional/bulk-conditional types. |
| src/ai/backend/manager/repositories/ops/base/provider.py | Adds the three bulk_conditional_*_partial methods and _update_one/_purge_one helpers; update/purge now delegate to them. |
| src/ai/backend/manager/errors/repository.py | Adds ConditionalWriteNotAllowed / ConditionalWriteTargetNotFound errors. |
| tests/unit/manager/repositories/ops/test_provider.py | Adds tests for the three conditional-bulk ops (all-pass, partial gate failure, empty, missing row). |
| changes/12429.misc.md | Adds the changelog entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c83c084 to
7cda3f9
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7cda3f9 to
614eaf0
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
614eaf0 to
6d69904
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6d69904 to
47fa255
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Generic, domain-agnostic primitives for gated bulk writes (split out of BA-6626): - repositories/base: ConditionalCreator/Updater/Purger and BulkConditionalCreator/Updater/ Purger (a write spec paired with an only_if existence gate). - WriteOps.bulk_conditional_create_partial / _update_partial / _purge_partial — each item runs in its own savepoint for partial success, implemented directly in WriteOps (with private _execute_updater / _execute_purger row helpers; not delegating to the standalone execute_* functions). A rejected gate is recorded as ConditionalMutationForbidden and a missing update/purge target as ObjectNotFound; both are collected per-item, the rest proceed. - Repository error ConditionalMutationForbidden. - Ops-provider unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47fa255 to
0b72350
Compare
Build the app_config_fragment bulk repository on the conditional-bulk primitives (#12429): - AppConfigFragmentCreatorSpec as a plain CreatorSpec with scope-based rank (public < domain < user). - bulk_create / bulk_update / bulk_purge in db_source + repository, returning the AppConfigFragmentBulkWriteResult data type (succeeded + failed[index, message]) — partial success via the WriteOps.bulk_conditional_*_partial primitives. - Single create rewritten to gate + plain create (no next-value); GatedWrite removed. - Repository unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Generic, domain-agnostic repository primitives for gated bulk writes, split out of #12426 (BA-6626) so app_config_fragment — and future domains — build on them. No app_config-specific code.
repositories/base:ConditionalCreator/ConditionalUpdater/ConditionalPurgerandBulkConditional{Creator,Updater,Purger}— a write spec paired with anonly_ifexistence gate.WriteOps.bulk_conditional_create_partial/_update_partial/_purge_partial— each item runs in its own savepoint for partial success (gate-rejected / missing / failed items reported per-item; the rest proceed). Implemented directly inWriteOpswith private_update_one/_purge_onerow helpers (not delegating to the standaloneexecute_*functions).ConditionalWriteNotAllowed/ConditionalWriteTargetNotFound.📚 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.existsfeat(BA-6554): AppConfigFragment service layerfeat(BA-6628): conditional-bulk repository primitives← you are herefeat(BA-6626): app_config_fragment bulk repository layerfeat(BA-6618): AppConfigFragment bulk CRUD service layerfeat(BA-6555): app_config service layerfeat(BA-6556): AppConfig REST v2 API