feat(acms): add text, vector, and graph backend protocol implementations #519

Merged
freemo merged 1 commit from feature/m5-acms-backends into master 2026-03-03 03:34:29 +00:00
Owner

Summary

  • Implements the Backend Abstraction Layer (BAL) for the ACMS, adding TextBackend, VectorBackend, and GraphBackend protocols with corresponding frozen result dataclasses (TextResult, VectorResult, GraphResult)
  • Provides in-memory stub backends (InMemoryTextBackend, InMemoryVectorBackend, InMemoryGraphBackend) as development placeholders and test doubles
  • Registers all three backends in the DI container as configurable Singletons with provider override support

Closes #498

Approach

Protocol Design

  • Each backend protocol is a @runtime_checkable Protocol following the structural subtyping pattern established by ResourceHandler in the codebase
  • Result types are frozen dataclass instances (not Pydantic) to minimize construction overhead in the context assembly hot path
  • The scope parameter is typed as frozenset[str] (resource ULIDs) for immutability and hashability, enabling scoped views per the specification's multi-project isolation requirement

Result Dataclasses

  • TextResult and VectorResult: uko_uri, content, score (0.0-1.0), metadata fields with __post_init__ validation
  • GraphResult: triples (list of (subject, predicate, object) tuples), metadata fields

DI Container

  • All three backends registered as providers.Singleton in the Container class
  • Default: in-memory stubs; production backends (Tantivy, FAISS, Blazegraph, etc.) swap via override_providers()

Testing

  • Behave BDD: 35 scenarios / 83 steps covering protocol compliance, argument validation, result immutability, and DI resolution
  • Robot Framework: 6 smoke tests for integration verification
  • ASV Benchmarks: 4 benchmark suites measuring stub query overhead and instantiation time

Module Locations

Module Purpose
src/cleveragents/domain/models/acms/backends.py Protocol definitions and result dataclasses
src/cleveragents/domain/models/acms/stubs.py In-memory stub implementations
src/cleveragents/application/container.py DI container backend registration
docs/reference/acms_backends.md Reference documentation
## Summary - Implements the Backend Abstraction Layer (BAL) for the ACMS, adding `TextBackend`, `VectorBackend`, and `GraphBackend` protocols with corresponding frozen result dataclasses (`TextResult`, `VectorResult`, `GraphResult`) - Provides in-memory stub backends (`InMemoryTextBackend`, `InMemoryVectorBackend`, `InMemoryGraphBackend`) as development placeholders and test doubles - Registers all three backends in the DI container as configurable Singletons with provider override support Closes #498 ## Approach ### Protocol Design - Each backend protocol is a `@runtime_checkable` `Protocol` following the structural subtyping pattern established by `ResourceHandler` in the codebase - Result types are frozen `dataclass` instances (not Pydantic) to minimize construction overhead in the context assembly hot path - The `scope` parameter is typed as `frozenset[str]` (resource ULIDs) for immutability and hashability, enabling scoped views per the specification's multi-project isolation requirement ### Result Dataclasses - `TextResult` and `VectorResult`: `uko_uri`, `content`, `score` (0.0-1.0), `metadata` fields with `__post_init__` validation - `GraphResult`: `triples` (list of (subject, predicate, object) tuples), `metadata` fields ### DI Container - All three backends registered as `providers.Singleton` in the `Container` class - Default: in-memory stubs; production backends (Tantivy, FAISS, Blazegraph, etc.) swap via `override_providers()` ### Testing - **Behave BDD**: 35 scenarios / 83 steps covering protocol compliance, argument validation, result immutability, and DI resolution - **Robot Framework**: 6 smoke tests for integration verification - **ASV Benchmarks**: 4 benchmark suites measuring stub query overhead and instantiation time ### Module Locations | Module | Purpose | |--------|--------| | `src/cleveragents/domain/models/acms/backends.py` | Protocol definitions and result dataclasses | | `src/cleveragents/domain/models/acms/stubs.py` | In-memory stub implementations | | `src/cleveragents/application/container.py` | DI container backend registration | | `docs/reference/acms_backends.md` | Reference documentation |
freemo added this to the v3.4.0 milestone 2026-03-03 00:19:53 +00:00
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-03 03:06:19 +00:00
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-03 03:12:20 +00:00
freemo self-assigned this 2026-03-03 03:12:39 +00:00
freemo force-pushed feature/m5-acms-backends from ac7496f069
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 17s
CI / security (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 39s
CI / unit_tests (pull_request) Successful in 2m1s
CI / docker (pull_request) Successful in 39s
CI / integration_tests (pull_request) Successful in 2m54s
CI / coverage (pull_request) Successful in 3m38s
CI / benchmark-regression (pull_request) Successful in 23m50s
to 7479d57e29
Some checks failed
CI / lint (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / quality (pull_request) Successful in 22s
CI / build (pull_request) Successful in 14s
CI / security (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 51s
CI / unit_tests (pull_request) Successful in 1m53s
CI / docker (pull_request) Successful in 57s
CI / integration_tests (pull_request) Successful in 3m5s
CI / coverage (pull_request) Successful in 3m47s
CI / benchmark-regression (pull_request) Has been cancelled
2026-03-03 03:12:51 +00:00
Compare
freemo force-pushed feature/m5-acms-backends from 7479d57e29
Some checks failed
CI / lint (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / quality (pull_request) Successful in 22s
CI / build (pull_request) Successful in 14s
CI / security (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 51s
CI / unit_tests (pull_request) Successful in 1m53s
CI / docker (pull_request) Successful in 57s
CI / integration_tests (pull_request) Successful in 3m5s
CI / coverage (pull_request) Successful in 3m47s
CI / benchmark-regression (pull_request) Has been cancelled
to 025d379946
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / quality (pull_request) Successful in 17s
CI / build (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 33s
CI / security (pull_request) Successful in 42s
CI / unit_tests (pull_request) Successful in 2m36s
CI / docker (pull_request) Successful in 40s
CI / integration_tests (pull_request) Successful in 3m17s
CI / coverage (pull_request) Successful in 4m21s
CI / lint (push) Successful in 12s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 16s
CI / security (push) Successful in 30s
CI / typecheck (push) Successful in 33s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 2m36s
CI / docker (push) Successful in 40s
CI / integration_tests (push) Successful in 3m57s
CI / coverage (push) Successful in 5m22s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (pull_request) Successful in 25m12s
2026-03-03 03:29:33 +00:00
Compare
freemo merged commit 025d379946 into master 2026-03-03 03:34:29 +00:00
freemo deleted branch feature/m5-acms-backends 2026-03-03 03:34:29 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!519
No description provided.