Skip to content

feat(BA-6555): add app_config service layer#12359

Draft
jopemachine wants to merge 2 commits into
feat/BA-6618-app-config-fragment-bulk-servicefrom
feat/BA-6555-app-config-merge-engine
Draft

feat(BA-6555): add app_config service layer#12359
jopemachine wants to merge 2 commits into
feat/BA-6618-app-config-fragment-bulk-servicefrom
feat/BA-6555-app-config-merge-engine

Conversation

@jopemachine

@jopemachine jopemachine commented Jun 23, 2026

Copy link
Copy Markdown
Member

📚 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
  5. feat(BA-6554): add app_config_fragment service layer #12358feat(BA-6554): AppConfigFragment service layer
  6. feat(BA-6628): conditional-bulk repository primitives #12429feat(BA-6628): conditional-bulk repository primitives
  7. feat(BA-6626): app_config_fragment bulk repository layer #12426feat(BA-6626): app_config_fragment bulk repository layer
  8. feat(BA-6618): app_config_fragment bulk CRUD service layer #12401feat(BA-6618): AppConfigFragment bulk CRUD service layer
  9. 👉 feat(BA-6555): add app_config service layer #12359feat(BA-6555): app_config service layer ← you are here
  10. feat(BA-6556): AppConfig REST v2 API (raw fragments and merged read/update) #12377feat(BA-6556): AppConfig REST v2 API

Summary

Adds the app_config service layer (BA-6555) — resolving the merged AppConfig for a (user, config_name). This is the read foundation the REST/GQL read endpoints (BA-6556 / BA-6557) build on.

What's included

  • Merge semantics (services/app_config/merge.py): applicable fragments are ordered by rank (low → high) and deep-merged — nested objects recurse, scalars and lists are wholesale-replaced, higher rank wins on conflict. An empty merge result projects to null (clients fall back to built-in defaults).
  • Two read shapes: AppConfigFragment (one raw row) is unchanged; new AppConfigData is the merged per-user view — the ordered contributing fragments plus the deep-merged config.
  • Applicable-fragments query (ApplicableAppConfigScope + repository.list_applicable_fragments): a single join-free, rank-ordered query selecting every public fragment, the user's domain fragment, and the user's own user fragment for the name. No allow-list / policy lookup at read time (per BEP-1052); an unregistered name simply yields an empty merge.
  • Service: resolve action / processor returning the merged AppConfigData.
  • Tests: deep-merge semantics (recurse / replace / null-projection / rank order), the resolve service path, and the applicable-fragments query against a real DB.

Read variants (single is here; self-search / admin cross-user search) and the HTTP surface land in BA-6556 (REST v2) and BA-6557 (GraphQL).

@jopemachine jopemachine force-pushed the feat/BA-6554-app-config-fragments-service branch from b40117b to 870a98b Compare June 23, 2026 02:48
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 296a9a0 to 07bafd2 Compare June 23, 2026 02:53
@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component labels Jun 23, 2026
@jopemachine jopemachine force-pushed the feat/BA-6554-app-config-fragments-service branch 3 times, most recently from 1777f48 to 9dc1da7 Compare June 23, 2026 03:30
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch 2 times, most recently from 47878cb to ae7f25f Compare June 23, 2026 03:34
@jopemachine jopemachine force-pushed the feat/BA-6554-app-config-fragments-service branch from 9dc1da7 to 59a0a70 Compare June 23, 2026 03:38
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch 2 times, most recently from e9f0e1b to 684601c Compare June 23, 2026 03:44
@jopemachine jopemachine force-pushed the feat/BA-6554-app-config-fragments-service branch from 59a0a70 to 7694f19 Compare June 23, 2026 03:48
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 684601c to e5986d3 Compare June 23, 2026 03:49
@jopemachine jopemachine force-pushed the feat/BA-6554-app-config-fragments-service branch from 7694f19 to 02106ca Compare June 23, 2026 04:04
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from e5986d3 to cb34649 Compare June 23, 2026 06:47
@github-actions github-actions Bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Jun 23, 2026
@jopemachine jopemachine changed the title feat(BA-6555): add app_config merge engine (deep-merge across applicable fragments) feat(BA-6555): add app_config service layer Jun 23, 2026
Comment thread src/ai/backend/manager/services/app_config/merge.py Outdated
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 94e2ca4 to 08e919c Compare June 23, 2026 07:17
@github-actions github-actions Bot added size:L 100~500 LoC and removed size:XL 500~ LoC labels Jun 23, 2026
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from fb7af85 to 4b9ce45 Compare June 23, 2026 09:07


@dataclass(frozen=True)
class AppConfigResolveScope:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AppConfigScopeArguments

@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 6d5b0cc to 18135f0 Compare June 25, 2026 03:42
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 2d822bb to 408d923 Compare June 25, 2026 04:06
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 18135f0 to 24c5952 Compare June 25, 2026 04:06
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 7e5ab1d to 847de39 Compare June 25, 2026 07:29
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 704bd3f to 05aeedf Compare June 25, 2026 07:33
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch 2 times, most recently from f3e9bed to cc90dc1 Compare June 25, 2026 10:26
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 05aeedf to 961eeff Compare June 25, 2026 10:31
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch 2 times, most recently from f67bb21 to 25fc7ff Compare June 26, 2026 05:01
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 961eeff to 5c94da3 Compare June 26, 2026 05:26
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 25fc7ff to 2a8bd46 Compare June 26, 2026 07:15
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 5c94da3 to 5499abb Compare June 26, 2026 07:15
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 2a8bd46 to 933610d Compare June 26, 2026 07:28
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 5499abb to 82bc893 Compare June 26, 2026 07:30
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 933610d to 60bf490 Compare June 26, 2026 07:37
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 82bc893 to 14e30cf Compare June 26, 2026 07:37
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 60bf490 to c86a0c7 Compare June 26, 2026 08:03
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 14e30cf to ab5c6fd Compare June 26, 2026 08:03
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from c86a0c7 to ab11cd9 Compare June 26, 2026 08:12
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from ab5c6fd to b0fed49 Compare June 26, 2026 08:12
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from ab11cd9 to 5e78703 Compare June 26, 2026 09:10
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from b0fed49 to 3a9f1a1 Compare June 26, 2026 09:10
@jopemachine jopemachine force-pushed the feat/BA-6618-app-config-fragment-bulk-service branch from 5e78703 to ce8e7a0 Compare June 26, 2026 09:29
@jopemachine jopemachine force-pushed the feat/BA-6555-app-config-merge-engine branch from 3a9f1a1 to 43f39c1 Compare June 26, 2026 09:29
jopemachine and others added 2 commits June 26, 2026 18:50
… fragments)

Adds the read-side AppConfigService.resolve: fetches the fragments visible to a
(domain, user) principal for one config_name (list_visible_fragments, via the
by_*_visibility conditions) and deep-merges them in rank order; AppConfigResolveScope
bundles the principal. Rebased onto the domain/user-keyed scoped_search (BA-6554):
ConfigNameSearchScope is gone, so the merged read relies on the visibility conditions.

Squash of the BA-6555 development history, re-based onto the updated BA-6554.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add AppConfigService.resolve_bulk + ResolveBulkAppConfigAction (USER ScopeAction taking
config_names): resolve several merged AppConfigs for one (domain, user) principal in a
single query. AppConfigFragmentRepository.list_visible_fragments_bulk fetches the visible
fragments of all names at once ((config_name, rank)-ordered); the service groups by name
and deep-merges each, returning one AppConfigData per requested name in order. This is the
bulk-query path (no scoped search over merged AppConfig, per BA-6614).

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:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant