Skip to content

Commit 30a949b

Browse files
jopemachineclaude
andcommitted
refactor(BA-5827): drop single-item Fragment write actions (bulk-only writes)
Writes are bulk-only by design (BEP-1052 §3); single-item create / update / purge actions, service methods, adapter methods, and the matching DTOs were dead weight after the foundation lands. Drop them so the surface area matches what the API exposes. - Remove `actions/{create,update,purge}.py` - Strip the matching service methods + processors registration - Strip the matching adapter methods (and ObjectNotFound import) - Strip `Create/Update/PurgeAppConfigFragmentInput` and matching `Payload` DTOs from `common/dto/manager/v2/app_config_fragment/` Bulk service methods (admin_bulk_* and bulk_*_my) continue to call `admin_repository.create / update / purge` directly, which is the intended split: the repository keeps single-row primitives, the service exposes only bulk operations to upper layers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b338b63 commit 30a949b

9 files changed

Lines changed: 15 additions & 286 deletions

File tree

src/ai/backend/common/dto/manager/v2/app_config_fragment/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,18 @@
88
AppConfigFragmentOrder,
99
BulkCreateMyAppConfigFragmentsInput,
1010
BulkUpdateMyAppConfigFragmentsInput,
11-
CreateAppConfigFragmentInput,
1211
MyAppConfigFragmentItemInput,
13-
PurgeAppConfigFragmentInput,
1412
SearchAppConfigFragmentsInput,
15-
UpdateAppConfigFragmentInput,
1613
)
1714
from .response import (
1815
AdminBulkCreateAppConfigFragmentsPayload,
1916
AdminBulkPurgeAppConfigFragmentsPayload,
2017
AdminBulkUpdateAppConfigFragmentsPayload,
2118
AppConfigFragmentBulkError,
2219
AppConfigFragmentNode,
23-
CreateAppConfigFragmentPayload,
2420
GetAppConfigFragmentPayload,
2521
PurgeAppConfigFragmentKey,
26-
PurgeAppConfigFragmentPayload,
2722
SearchAppConfigFragmentsPayload,
28-
UpdateAppConfigFragmentPayload,
2923
)
3024
from .types import (
3125
AppConfigFragmentOrderField,
@@ -50,16 +44,10 @@
5044
"AppConfigScopeType",
5145
"BulkCreateMyAppConfigFragmentsInput",
5246
"BulkUpdateMyAppConfigFragmentsInput",
53-
"CreateAppConfigFragmentInput",
54-
"CreateAppConfigFragmentPayload",
5547
"GetAppConfigFragmentPayload",
5648
"MyAppConfigFragmentItemInput",
5749
"OrderDirection",
58-
"PurgeAppConfigFragmentInput",
5950
"PurgeAppConfigFragmentKey",
60-
"PurgeAppConfigFragmentPayload",
6151
"SearchAppConfigFragmentsInput",
6252
"SearchAppConfigFragmentsPayload",
63-
"UpdateAppConfigFragmentInput",
64-
"UpdateAppConfigFragmentPayload",
6553
)

src/ai/backend/common/dto/manager/v2/app_config_fragment/request.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
"AppConfigFragmentOrder",
2525
"BulkCreateMyAppConfigFragmentsInput",
2626
"BulkUpdateMyAppConfigFragmentsInput",
27-
"CreateAppConfigFragmentInput",
2827
"MyAppConfigFragmentItemInput",
29-
"PurgeAppConfigFragmentInput",
3028
"SearchAppConfigFragmentsInput",
31-
"UpdateAppConfigFragmentInput",
3229
)
3330

3431

@@ -44,33 +41,6 @@ class AppConfigFragmentKeyInput(BaseRequestModel):
4441
)
4542

4643

47-
class CreateAppConfigFragmentInput(BaseRequestModel):
48-
"""Input for creating a fragment row."""
49-
50-
key: AppConfigFragmentKeyInput = Field(description="Natural-key identifier.")
51-
extra_config: dict[str, Any] = Field(
52-
default_factory=dict,
53-
description="Raw configuration payload for this scope.",
54-
)
55-
56-
57-
class UpdateAppConfigFragmentInput(BaseRequestModel):
58-
"""Input for updating the `extra_config` on a fragment row.
59-
60-
The natural key is fixed; changing any component is a new row, not
61-
an update (BEP-1052 §1).
62-
"""
63-
64-
key: AppConfigFragmentKeyInput = Field(description="Natural-key identifier.")
65-
extra_config: dict[str, Any] = Field(description="Replacement configuration payload.")
66-
67-
68-
class PurgeAppConfigFragmentInput(BaseRequestModel):
69-
"""Input for purging (hard-delete) a fragment row."""
70-
71-
key: AppConfigFragmentKeyInput = Field(description="Natural-key identifier.")
72-
73-
7444
class AppConfigFragmentFilter(BaseRequestModel):
7545
"""Filter for app-config fragment search."""
7646

src/ai/backend/common/dto/manager/v2/app_config_fragment/response.py

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
"AdminBulkUpdateAppConfigFragmentsPayload",
2121
"AppConfigFragmentBulkError",
2222
"AppConfigFragmentNode",
23-
"CreateAppConfigFragmentPayload",
2423
"GetAppConfigFragmentPayload",
2524
"PurgeAppConfigFragmentKey",
26-
"PurgeAppConfigFragmentPayload",
2725
"SearchAppConfigFragmentsPayload",
28-
"UpdateAppConfigFragmentPayload",
2926
)
3027

3128

@@ -43,34 +40,22 @@ class AppConfigFragmentNode(BaseResponseModel):
4340
updated_at: datetime | None = Field(default=None, description="Last update timestamp.")
4441

4542

46-
class CreateAppConfigFragmentPayload(BaseResponseModel):
47-
"""Payload returned after creating a fragment row."""
48-
49-
item: AppConfigFragmentNode = Field(description="Created fragment.")
50-
51-
52-
class UpdateAppConfigFragmentPayload(BaseResponseModel):
53-
"""Payload returned after updating a fragment row."""
54-
55-
item: AppConfigFragmentNode = Field(description="Updated fragment.")
56-
57-
58-
class PurgeAppConfigFragmentPayload(BaseResponseModel):
59-
"""Payload returned after purging a fragment row."""
60-
61-
scope_type: AppConfigScopeType = Field(description="Scope type of the purged fragment.")
62-
scope_id: str = Field(description="Scope id of the purged fragment.")
63-
name: str = Field(description="Policy name of the purged fragment.")
64-
purged: bool = Field(description="Whether a row was actually removed.")
65-
66-
6743
class GetAppConfigFragmentPayload(BaseResponseModel):
6844
"""Payload returned after reading a single fragment by natural key."""
6945

7046
item: AppConfigFragmentNode | None = Field(default=None, description="Fragment data, or null.")
7147

7248

73-
# ── Bulk mutation payloads (BEP-1052 §3) ─────────────────────────
49+
class SearchAppConfigFragmentsPayload(BaseResponseModel):
50+
"""Payload for paginated fragment search results."""
51+
52+
items: list[AppConfigFragmentNode] = Field(description="Fragments matching the filter.")
53+
total_count: int = Field(description="Total number of fragments matching the filter.")
54+
has_next_page: bool = Field(default=False, description="Whether there is a next page.")
55+
has_previous_page: bool = Field(default=False, description="Whether there is a previous page.")
56+
57+
58+
# ── Bulk mutation payloads (BEP-1052 §3, bulk-only writes) ───────
7459

7560

7661
class AppConfigFragmentBulkError(BaseResponseModel):
@@ -119,12 +104,3 @@ class AdminBulkPurgeAppConfigFragmentsPayload(BaseResponseModel):
119104
# `common/dto/manager/v2/app_config/response.py` (added with the
120105
# merged-view DTO in the GQL/REST layer) to keep `AppConfigNode` as the
121106
# single source of truth and avoid a circular import.
122-
123-
124-
class SearchAppConfigFragmentsPayload(BaseResponseModel):
125-
"""Payload for paginated fragment search results."""
126-
127-
items: list[AppConfigFragmentNode] = Field(description="Fragments matching the filter.")
128-
total_count: int = Field(description="Total number of fragments matching the filter.")
129-
has_next_page: bool = Field(default=False, description="Whether there is a next page.")
130-
has_previous_page: bool = Field(default=False, description="Whether there is a previous page.")

src/ai/backend/manager/api/adapters/app_config_fragment.py

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@
99
AppConfigFragmentFilter,
1010
AppConfigFragmentKeyInput,
1111
AppConfigFragmentOrder,
12-
CreateAppConfigFragmentInput,
13-
PurgeAppConfigFragmentInput,
1412
SearchAppConfigFragmentsInput,
15-
UpdateAppConfigFragmentInput,
1613
)
1714
from ai.backend.common.dto.manager.v2.app_config_fragment.response import (
1815
AdminBulkCreateAppConfigFragmentsPayload,
1916
AdminBulkPurgeAppConfigFragmentsPayload,
2017
AdminBulkUpdateAppConfigFragmentsPayload,
2118
AppConfigFragmentBulkError,
2219
AppConfigFragmentNode,
23-
CreateAppConfigFragmentPayload,
2420
GetAppConfigFragmentPayload,
2521
PurgeAppConfigFragmentKey,
26-
PurgeAppConfigFragmentPayload,
2722
SearchAppConfigFragmentsPayload,
28-
UpdateAppConfigFragmentPayload,
2923
)
3024
from ai.backend.common.dto.manager.v2.app_config_fragment.types import (
3125
AppConfigScopeType as DTOAppConfigScopeType,
@@ -41,7 +35,6 @@
4135
AppConfigFragmentKey,
4236
AppConfigScopeType,
4337
)
44-
from ai.backend.manager.errors.common import ObjectNotFound
4538
from ai.backend.manager.models.app_config_fragment.conditions import AppConfigFragmentConditions
4639
from ai.backend.manager.models.app_config_fragment.orders import AppConfigFragmentOrders
4740
from ai.backend.manager.models.app_config_fragment.row import AppConfigFragmentRow
@@ -61,32 +54,21 @@
6154
from ai.backend.manager.services.app_config_fragment.actions.admin_search import (
6255
AdminSearchAppConfigFragmentsAction,
6356
)
64-
from ai.backend.manager.services.app_config_fragment.actions.create import (
65-
CreateAppConfigFragmentAction,
66-
)
6757
from ai.backend.manager.services.app_config_fragment.actions.get import GetAppConfigFragmentAction
68-
from ai.backend.manager.services.app_config_fragment.actions.purge import (
69-
PurgeAppConfigFragmentAction,
70-
)
7158
from ai.backend.manager.services.app_config_fragment.actions.search import (
7259
SearchAppConfigFragmentsAction,
7360
)
74-
from ai.backend.manager.services.app_config_fragment.actions.update import (
75-
UpdateAppConfigFragmentAction,
76-
)
7761

7862
from .base import BaseAdapter
7963

8064

8165
class AppConfigFragmentAdapter(BaseAdapter):
82-
"""Adapter for AppConfigFragment domain operations (BEP-1052 §2)."""
66+
"""Adapter for AppConfigFragment domain operations (BEP-1052 §2).
8367
84-
async def create(self, input: CreateAppConfigFragmentInput) -> CreateAppConfigFragmentPayload:
85-
key = self._input_to_key(input.key)
86-
result = await self._processors.app_config_fragment.create.wait_for_complete(
87-
CreateAppConfigFragmentAction(key=key, extra_config=dict(input.extra_config))
88-
)
89-
return CreateAppConfigFragmentPayload(item=self._data_to_dto(result.fragment))
68+
Writes are bulk-only (BEP-1052 §3); single-item create / update /
69+
purge entry points are intentionally absent. Self-service my_bulk
70+
methods are added with the merged-view DTOs in BA-5829.
71+
"""
9072

9173
async def get(self, key_input: AppConfigFragmentKeyInput) -> GetAppConfigFragmentPayload:
9274
key = self._input_to_key(key_input)
@@ -138,29 +120,6 @@ async def admin_search(
138120
has_previous_page=result.has_previous_page,
139121
)
140122

141-
async def update(self, input: UpdateAppConfigFragmentInput) -> UpdateAppConfigFragmentPayload:
142-
key = self._input_to_key(input.key)
143-
result = await self._processors.app_config_fragment.update.wait_for_complete(
144-
UpdateAppConfigFragmentAction(key=key, extra_config=dict(input.extra_config))
145-
)
146-
if result.fragment is None:
147-
raise ObjectNotFound(
148-
object_name=(f"AppConfigFragment({key.scope_type}:{key.scope_id}:{key.name})"),
149-
)
150-
return UpdateAppConfigFragmentPayload(item=self._data_to_dto(result.fragment))
151-
152-
async def purge(self, input: PurgeAppConfigFragmentInput) -> PurgeAppConfigFragmentPayload:
153-
key = self._input_to_key(input.key)
154-
result = await self._processors.app_config_fragment.purge.wait_for_complete(
155-
PurgeAppConfigFragmentAction(key=key)
156-
)
157-
return PurgeAppConfigFragmentPayload(
158-
scope_type=DTOAppConfigScopeType(result.key.scope_type.value),
159-
scope_id=result.key.scope_id,
160-
name=result.key.name,
161-
purged=result.purged,
162-
)
163-
164123
_PAGINATION_SPEC = PaginationSpec(
165124
forward_order=AppConfigFragmentOrders.created_at(ascending=False),
166125
backward_order=AppConfigFragmentOrders.created_at(ascending=True),

src/ai/backend/manager/services/app_config_fragment/actions/create.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/ai/backend/manager/services/app_config_fragment/actions/purge.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/ai/backend/manager/services/app_config_fragment/actions/update.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)