forked from HAL9000/cleveragents-core
31472b5413
Add Behave feature/step pairs that exercise uncovered branches across handlers, LSP, CLI, and service layers to reach the coverage gate. ISSUES CLOSED: #1232
252 lines
12 KiB
Gherkin
252 lines
12 KiB
Gherkin
Feature: Vector Store Service extended coverage (round 3)
|
|
Exercise ACMS vector store paths, protocol stubs, and internal
|
|
helpers that are not yet covered by the existing feature file.
|
|
|
|
# ------------------------------------------------------------------
|
|
# Protocol body coverage
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Plan store protocol similarity_search_with_score raises NotImplementedError
|
|
Given vscov3 a plan store protocol instance
|
|
When vscov3 I call similarity_search_with_score on the plan protocol
|
|
Then vscov3 the plan protocol should raise NotImplementedError
|
|
|
|
Scenario: Plan store protocol save_local raises NotImplementedError
|
|
Given vscov3 a plan store protocol instance
|
|
When vscov3 I call save_local on the plan protocol
|
|
Then vscov3 the plan protocol should raise NotImplementedError
|
|
|
|
Scenario: Docstore protocol search raises NotImplementedError
|
|
Given vscov3 a docstore protocol instance
|
|
When vscov3 I call search on the docstore protocol
|
|
Then vscov3 the docstore protocol should raise NotImplementedError
|
|
|
|
Scenario: ACMS store protocol add_embeddings raises NotImplementedError
|
|
Given vscov3 an ACMS store protocol instance
|
|
When vscov3 I call add_embeddings on the ACMS protocol
|
|
Then vscov3 the ACMS protocol should raise NotImplementedError
|
|
|
|
Scenario: ACMS store protocol similarity_search_with_score_by_vector raises NotImplementedError
|
|
Given vscov3 an ACMS store protocol instance
|
|
When vscov3 I call similarity_search_with_score_by_vector on the ACMS protocol
|
|
Then vscov3 the ACMS protocol should raise NotImplementedError
|
|
|
|
Scenario: ACMS store protocol delete raises NotImplementedError
|
|
Given vscov3 an ACMS store protocol instance
|
|
When vscov3 I call delete on the ACMS protocol
|
|
Then vscov3 the ACMS protocol should raise NotImplementedError
|
|
|
|
Scenario: ACMS store protocol save_local raises NotImplementedError
|
|
Given vscov3 an ACMS store protocol instance
|
|
When vscov3 I call save_local on the ACMS protocol
|
|
Then vscov3 the ACMS protocol should raise NotImplementedError
|
|
|
|
# ------------------------------------------------------------------
|
|
# _require_faiss when FAISS is None
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Require FAISS raises ConfigurationError when FAISS is not installed
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is patched to None
|
|
When vscov3 I call _require_faiss
|
|
Then vscov3 a ConfigurationError mentioning FAISS should be stored
|
|
|
|
# ------------------------------------------------------------------
|
|
# acms_count
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS count returns total count when project is None
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS store has indexed documents for projects "alpha" and "beta"
|
|
When vscov3 I call acms_count without a project filter
|
|
Then vscov3 the ACMS count should be 2
|
|
|
|
Scenario: ACMS count returns filtered count for a specific project
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS store has indexed documents for projects "alpha" and "beta"
|
|
When vscov3 I call acms_count for project "alpha"
|
|
Then vscov3 the ACMS count should be 1
|
|
|
|
Scenario: ACMS count returns 0 when store is empty
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I call acms_count without a project filter
|
|
Then vscov3 the ACMS count should be 0
|
|
|
|
# ------------------------------------------------------------------
|
|
# acms_index_embedding validations
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS index rejects empty project
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I index an ACMS embedding with an empty project
|
|
Then vscov3 a ValueError mentioning "project" should be stored
|
|
|
|
Scenario: ACMS index rejects empty doc_id
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I index an ACMS embedding with an empty doc_id
|
|
Then vscov3 a ValueError mentioning "doc_id" should be stored
|
|
|
|
Scenario: ACMS index rejects empty embedding list
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I index an ACMS embedding with an empty embedding list
|
|
Then vscov3 a ValueError mentioning "embedding" should be stored
|
|
|
|
Scenario: ACMS index rejects when ACMS is disabled
|
|
Given vscov3 a vector store service with ACMS disabled
|
|
When vscov3 I index an ACMS embedding with valid inputs
|
|
Then vscov3 a ConfigurationError mentioning "disabled" should be stored
|
|
|
|
Scenario: ACMS index uses fallback payload when content is empty
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
When vscov3 I index an embedding with project "p1" doc_id "d1" embedding [0.1] and no content
|
|
Then vscov3 the indexed payload should be "embedding:d1"
|
|
|
|
Scenario: ACMS index adds to existing store and replaces duplicate
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
And vscov3 the ACMS store already has a document "p1::d1"
|
|
When vscov3 I index an embedding with project "p1" doc_id "d1" embedding [0.5] and content "updated"
|
|
Then vscov3 the existing store_id should have been deleted before re-add
|
|
And vscov3 the store should have received add_embeddings
|
|
|
|
# ------------------------------------------------------------------
|
|
# acms_search_by_vector
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS search rejects empty embedding
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I search ACMS with empty embedding
|
|
Then vscov3 a ValueError mentioning "embedding" should be stored
|
|
|
|
Scenario: ACMS search rejects non-positive top_k
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I search ACMS with top_k 0
|
|
Then vscov3 a ValueError mentioning "top_k" should be stored
|
|
|
|
Scenario: ACMS search returns empty when ACMS is disabled
|
|
Given vscov3 a vector store service with ACMS disabled
|
|
When vscov3 I search ACMS with embedding [0.1] and top_k 5
|
|
Then vscov3 the ACMS search results should be empty
|
|
|
|
Scenario: ACMS search returns empty when store is None
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I search ACMS with embedding [0.1] and top_k 5
|
|
Then vscov3 the ACMS search results should be empty
|
|
|
|
Scenario: ACMS search filters by scope
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
And vscov3 the ACMS store has search results with resource_ids "r1" and "r2"
|
|
When vscov3 I search ACMS with embedding [0.1] scope "r1" and top_k 5
|
|
Then vscov3 the ACMS search results should have entries
|
|
|
|
# ------------------------------------------------------------------
|
|
# acms_remove_embedding
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS remove rejects empty project
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I remove an ACMS embedding with an empty project
|
|
Then vscov3 a ValueError mentioning "project" should be stored
|
|
|
|
Scenario: ACMS remove rejects empty doc_id
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I remove an ACMS embedding with an empty doc_id
|
|
Then vscov3 a ValueError mentioning "doc_id" should be stored
|
|
|
|
Scenario: ACMS remove is a no-op when store is None
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I remove ACMS embedding for project "p1" and doc_id "d1"
|
|
Then vscov3 no error should be stored
|
|
|
|
Scenario: ACMS remove keeps store when documents remain
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
And vscov3 the ACMS store has documents "p1::d1" and "p1::d2"
|
|
When vscov3 I remove ACMS embedding for project "p1" and doc_id "d1"
|
|
Then vscov3 the ACMS store should still be set
|
|
And vscov3 save should have been called
|
|
|
|
# ------------------------------------------------------------------
|
|
# _create_acms_embeddings
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS embeddings uses default dimension when dims_value is None
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS embedding config uses provider "fake" with no model and no dimensions
|
|
When vscov3 I call _create_acms_embeddings
|
|
Then vscov3 the embeddings should be FakeEmbeddings with default dimension
|
|
|
|
Scenario: ACMS embeddings with openai provider
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS embedding config uses provider "openai" model "text-embedding-3-small" and dimensions 512
|
|
And vscov3 a stub OpenAI embeddings module is available
|
|
When vscov3 I call _create_acms_embeddings
|
|
Then vscov3 the embeddings should be StubOpenAIEmbeddings with model "text-embedding-3-small"
|
|
|
|
Scenario: ACMS embeddings with openai provider and no dimensions
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS embedding config uses provider "openai" model "text-embedding-3-small" with no dimensions
|
|
And vscov3 a stub OpenAI embeddings module is available
|
|
When vscov3 I call _create_acms_embeddings
|
|
Then vscov3 the embeddings should be StubOpenAIEmbeddings with model "text-embedding-3-small"
|
|
|
|
Scenario: ACMS embeddings with unsupported provider raises error
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 the ACMS embedding config uses provider "unsupported_provider" with no model and no dimensions
|
|
When vscov3 I call _create_acms_embeddings
|
|
Then vscov3 a ConfigurationError mentioning "Unsupported" should be stored
|
|
|
|
# ------------------------------------------------------------------
|
|
# _load_acms_store
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Load ACMS store returns None when files are missing
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I call _load_acms_store
|
|
Then vscov3 the loaded store should be None
|
|
|
|
Scenario: Load ACMS store succeeds when files exist
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
And vscov3 the ACMS store directory has index files
|
|
When vscov3 I call _load_acms_store
|
|
Then vscov3 the loaded store should not be None
|
|
|
|
Scenario: Load ACMS store returns None when load raises ValueError
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 FAISS is mocked for ACMS operations
|
|
And vscov3 the ACMS store directory has index files
|
|
And vscov3 FAISS load_local will raise ValueError
|
|
When vscov3 I call _load_acms_store
|
|
Then vscov3 the loaded store should be None
|
|
|
|
# ------------------------------------------------------------------
|
|
# _acms_store_dir with relative path
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: ACMS store dir resolves relative paths via cwd
|
|
Given vscov3 a vector store service with ACMS dir set to a relative path
|
|
When vscov3 I call _acms_store_dir
|
|
Then vscov3 the returned path should be absolute
|
|
|
|
# ------------------------------------------------------------------
|
|
# _save_acms_store early return
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Save ACMS store is a no-op when internal store is None
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
When vscov3 I call _save_acms_store
|
|
Then vscov3 no error should be stored
|
|
|
|
# ------------------------------------------------------------------
|
|
# _iter_store_metadata
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Iterating store metadata yields id and metadata pairs
|
|
Given vscov3 a vector store service with ACMS enabled
|
|
And vscov3 a mock ACMS store with docstore entries
|
|
When vscov3 I call _iter_store_metadata
|
|
Then vscov3 the iteration should yield 2 entries with string keys and values
|