forked from HAL9000/cleveragents-core
025d379946
Implemented the Backend Abstraction Layer (BAL) for the Advanced Context Management System, following the specification in docs/specification.md Section ACMS > Backend Abstraction Layer and ADR-014. Key additions: - TextBackend protocol with search(query, scope, max_results) returning list[TextResult], and TextResult frozen dataclass (uko_uri, content, score, metadata fields) - VectorBackend protocol with similarity_search(embedding, scope, top_k) returning list[VectorResult], and VectorResult frozen dataclass - GraphBackend protocol with sparql_query(query, scope), get_triples(subject), and traverse(start, depth) methods returning GraphResult frozen dataclass (triples, metadata fields) - In-memory stub backends (InMemoryTextBackend, InMemoryVectorBackend, InMemoryGraphBackend) that validate arguments and return empty results, serving as development placeholders and test doubles - DI container registration as configurable Singletons with provider selection via override_providers() - Behave BDD feature (35 scenarios / 83 steps) covering protocol compliance, argument validation, result immutability, and DI resolution - Robot Framework smoke tests (6 tests) for integration verification - ASV benchmarks for stub query overhead and instantiation time - Reference documentation at docs/reference/acms_backends.md Design decisions: - Used @runtime_checkable Protocol for structural subtyping, consistent with existing ResourceHandler pattern - Used frozen dataclasses (not Pydantic) for result types to minimize overhead in the hot path of context assembly - scope parameter typed as frozenset[str] for immutability and hashability - Stubs registered as default Singletons; production backends swap via DI ISSUES CLOSED: #498
58 lines
2.5 KiB
Plaintext
58 lines
2.5 KiB
Plaintext
*** Settings ***
|
|
Documentation Smoke tests for ACMS Backend Abstraction Layer protocols
|
|
Resource ${CURDIR}/common.resource
|
|
Suite Setup Setup Test Environment
|
|
Suite Teardown Cleanup Test Environment
|
|
|
|
*** Variables ***
|
|
${HELPER} ${CURDIR}/helper_acms_backends.py
|
|
|
|
*** Test Cases ***
|
|
InMemoryTextBackend Protocol Compliance
|
|
[Documentation] Verify InMemoryTextBackend satisfies TextBackend protocol
|
|
${result}= Run Process ${PYTHON} ${HELPER} text-backend cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-text-backend-ok
|
|
|
|
InMemoryVectorBackend Protocol Compliance
|
|
[Documentation] Verify InMemoryVectorBackend satisfies VectorBackend protocol
|
|
${result}= Run Process ${PYTHON} ${HELPER} vector-backend cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-vector-backend-ok
|
|
|
|
InMemoryGraphBackend Protocol Compliance
|
|
[Documentation] Verify InMemoryGraphBackend satisfies GraphBackend protocol
|
|
${result}= Run Process ${PYTHON} ${HELPER} graph-backend cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-graph-backend-ok
|
|
|
|
Result Dataclass Construction
|
|
[Documentation] Verify TextResult, VectorResult, and GraphResult creation
|
|
${result}= Run Process ${PYTHON} ${HELPER} result-types cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-result-types-ok
|
|
|
|
DI Container Backend Resolution
|
|
[Documentation] Verify DI container resolves all three backends
|
|
${result}= Run Process ${PYTHON} ${HELPER} di-resolution cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-di-resolution-ok
|
|
|
|
Backend Argument Validation
|
|
[Documentation] Verify backends reject invalid arguments
|
|
${result}= Run Process ${PYTHON} ${HELPER} validation cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} acms-validation-ok
|