Orchestrata Ultimate › Tests › Reference › semantic_graph

Tests reference — tests/semantic_graph

tests/semantic_graph — 17 test modules, 294 test functions. Source tree: tests/semantic_graph at commit 8a2cb42ad. Generated from the tests AST snapshot by scripts/gen-data-pages.py.

Prose pending.

Modules

Module Tests Covers
conftest.py 0 2
test_architecture_twin.py 22 7
test_embedder_factory.py 23 2
test_embedders.py 22 2
test_ha_controller_cli.py 11 1
test_ha_replica_health.py 9 1
test_ingestion.py 26 7
test_interfaces.py 1 2
test_main_discovery.py 10 2
test_memgraph_adapter.py 58 4
test_memgraph_ha.py 31 2
test_memory_adapter.py 27 2
test_models.py 10 1
test_repository.py 5 3
test_rerankers.py 7 3
test_spec_trace_enrichment.py 32 7

Module details

tests/semantic_graph/conftest.py

source · 0 tests · 416 lines

Shared fixtures for semantic_graph tests.

Covers: semantic_graph.config, semantic_graph.embedder_factory

tests/semantic_graph/test_architecture_twin.py

source · 22 tests · 632 lines

Tests for semantic_graph.architecture_twin — the Memgraph semantic twin of

Covers: semantic_graph.adapters.memgraph, semantic_graph.adapters.memory, semantic_graph.architecture_twin, semantic_graph.config, semantic_graph.embedders, semantic_graph.interfaces, semantic_graph.models

Kind Name Line Description
function test_build_adr_chunk_assembles_content_with_section_headers 57
function test_build_adr_chunk_skips_empty_and_none_body_fields 88
function test_build_adr_chunk_no_title_no_body_yields_empty_content 104
function test_chunk_design_doc_empty_text_returns_empty_list 118
function test_chunk_design_doc_short_text_is_one_chunk 123
function test_chunk_design_doc_window_overlap_math 142
function test_chunk_design_doc_custom_window_and_overlap 162
function test_chunk_design_doc_rejects_invalid_window 176
function test_chunk_design_doc_rejects_invalid_overlap 181
function test_sync_writes_adr_chunks_into_in_memory_graph 240
function test_sync_reads_design_doc_from_disk_and_skips_missing_file 263
function test_sync_is_idempotent_via_merge 303
function test_sync_prunes_chunks_for_records_no_longer_live 319
function test_sync_prune_never_touches_another_projects_chunks 340 Regression: the chunk label/index are shared across every project
function test_sync_empty_corpus_returns_zero_counts 370
function test_load_design_doc_chunks_skips_row_with_no_path 384
function test_embed_and_store_raises_on_embedder_contract_violation 415
function test_prune_returns_zero_when_graph_lacks_the_capability 445
function test_read_lazily_builds_a_real_repo_when_none_injected 462 No reader=/repo= injected: _read must lazily build a real
function test_memgraph_sync_is_idempotent_via_merge 516
function test_memgraph_sync_prunes_stale_adr_chunk 542
function test_memgraph_retrieval_returns_seeded_chunks_via_local_embedder 568 Retrieval against the real Memgraph vector index, embedded via the

tests/semantic_graph/test_embedder_factory.py

source · 23 tests · 203 lines

Tests for the embedding-backend selection.

Covers: semantic_graph.embedder_factory, semantic_graph.embedders

Kind Name Line Description
class TestSelection 53
method TestSelection.test_the_default_is_the_remote_backend 54 Deliberate: prod's index is 1536-dimensional codestral, and a
method TestSelection.test_the_name_is_read_leniently 60
method TestSelection.test_an_unknown_backend_is_refused 63 Not a fallback: a typo that silently resolved to the paid default
class TestModelAndDimension 70
method TestModelAndDimension.test_local_answers_with_the_local_pair 71
method TestModelAndDimension.test_remote_answers_with_the_remote_pair 77
method TestModelAndDimension.test_the_two_backends_disagree_about_width 83 The reason the dimension travels with the model: an index written
method TestModelAndDimension.test_an_explicit_model_wins 88
method TestModelAndDimension.test_an_explicit_dimension_wins 93
class TestApiKeyNeed 99
method TestApiKeyNeed.test_the_local_backend_needs_no_key 100
method TestApiKeyNeed.test_the_remote_backend_needs_one 103
class TestConstruction 107
method TestConstruction.test_local_builds_the_local_embedder 108
method TestConstruction.test_local_builds_without_an_api_key_at_all 114 The point of the whole change: this machine never needed an account.
method TestConstruction.test_remote_builds_the_remote_embedder 118
method TestConstruction.test_remote_honours_a_redirected_base_url 124 How the tests point embedding traffic at a local server.
method TestConstruction.test_batching_reaches_the_remote_backend 132
class TestTheProfilesWireIt 140 A selector nothing selects is not a delivery (RUL-023).
method TestTheProfilesWireIt.test_the_free_backend_is_what_dev_and_test_use 144
method TestTheProfilesWireIt.test_prod_pins_the_remote_backend_explicitly 149 Explicit rather than implicit, so nobody re-reads the default and
class TestTheVectorSpaceIsNamedAfterWhatFilledIt 157 A label is what says "these vectors are comparable to each other".
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_each_backend_gets_its_own_label 167
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_each_backend_gets_its_own_index 171 A vector index is built at a fixed width, so pointing a 1024-wide
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_the_label_and_the_index_never_disagree_about_the_backend 177
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_an_explicit_label_wins 183
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_an_explicit_index_wins 186
method TestTheVectorSpaceIsNamedAfterWhatFilledIt.test_the_legacy_pins_still_win 191 Deployments pinned to these before the backend became a choice must

tests/semantic_graph/test_embedders.py

source · 22 tests · 327 lines

Tests for semantic graph embedding backends.

Covers: semantic_graph.embedders, semantic_graph.exceptions

Kind Name Line Description
function test_openrouter_embed_empty_list 104
function test_openrouter_embed_single_text 109
function test_openrouter_embed_multiple_texts 116
function test_openrouter_dimension_mismatch 126
function test_openrouter_requires_api_key 134
function test_openrouter_http_error 139
function test_openrouter_http_status_error 147
function test_openrouter_missing_data_key 153
function test_openrouter_count_mismatch 161
function test_openrouter_splits_by_token_limit 171 Large batches are split when estimated tokens exceed the per-batch ceiling.
function test_qwen_embed_empty_list 190
function test_qwen_embed_text_on_gpu 196
function test_qwen_query_vs_document_prompt 207
function test_qwen_custom_query_prompt 222
function test_qwen_document_prompt 228
function test_qwen_fallback_when_no_prompt 234
function test_qwen_dimension_property 257
class TestTransientFailuresAreRetried 279 Which failures get another attempt, and which do not.
method TestTransientFailuresAreRetried.test_a_transient_status_is_retried_until_it_succeeds 290
method TestTransientFailuresAreRetried.test_a_refusal_is_not_retried 300 402 is an answer, not a hiccup.
method TestTransientFailuresAreRetried.test_exhausted_retries_raise_rather_than_retry_forever 309
method TestTransientFailuresAreRetried.test_the_retry_set_excludes_client_refusals 319 Read as a table: the codes that mean "try again", and nothing else.
method TestTransientFailuresAreRetried.test_the_default_budget_is_more_than_one_attempt 325 A default of 1 would silently restore the un-retried behaviour.

tests/semantic_graph/test_ha_controller_cli.py

source · 11 tests · 110 lines

Tests for the Memgraph HA controller CLI parser.

Covers: semantic_graph.ha_controller_cli

Kind Name Line Description
function test_parse_node_equals_format 17
function test_parse_node_equals_format_with_port 25
function test_parse_node_pipe_format 30
function test_parse_node_invalid_spec 37
function test_nodes_from_env_empty 42
function test_nodes_from_env_parses 46
function test_parser_defaults_from_env 59
function test_parser_accepts_nodes 66
function test_main_exits_when_too_few_nodes 79
function test_main_exits_when_no_nodes_provided 85
function test_main_starts_controller_and_uvicorn 91

tests/semantic_graph/test_ha_replica_health.py

source · 9 tests · 64 lines

Tests for MemgraphHAController._replica_is_healthy (the idempotency guard).

Covers: semantic_graph.ha_controller

Kind Name Line Description
function test_unregistered_replica_is_not_healthy 23
function test_empty_data_info_is_not_healthy 28
function test_ready_status_is_healthy 32
function test_recovery_status_is_healthy 36
function test_replicating_status_is_healthy 44
function test_invalid_status_is_not_healthy 48
function test_missing_status_key_is_not_healthy 53
function test_any_unhealthy_db_makes_the_whole_replica_unhealthy 57
function test_non_dict_data_info_value_is_not_healthy 62

tests/semantic_graph/test_ingestion.py

source · 26 tests · 462 lines

Tests for source-code ingestion into the semantic graph.

Covers: semantic_graph.adapters.memgraph, semantic_graph.adapters.memory, semantic_graph.config, semantic_graph.embedders, semantic_graph.ingestion, semantic_graph.models, semantic_graph.rerankers

Kind Name Line Description
function test_chunk_file_creates_line_ranges 90
function test_chunk_file_infers_module_from_parent_directory 105
function test_module_from_path_falls_back_to_empty_string 115
function test_chunk_directory_ignores_non_matching_files 121
function test_chunker_validates_parameters 132
function test_ingester_stores_chunks_with_embeddings 139
function test_ingester_search_with_reranker 161
function test_chunk_file_not_found 188
function test_chunk_directory_not_a_directory 194
function test_chunk_file_too_large_is_skipped 201
function test_chunk_file_read_error_is_skipped 208
function test_chunker_skips_blank_chunks 222
function test_chunk_directory_no_matches 229
function test_ingester_warns_when_no_chunks 236
function test_ingester_raises_on_embedding_count_mismatch 249
function test_ingester_search_empty_embeddings 274
function test_chunk_id_hash_for_long_paths 296
function test_extract_query_terms_splits_camel_and_snake_case 311
function test_extract_query_terms_drops_stopwords_and_short_words 319
function test_extract_query_terms_deduplicates_and_caps 324
function test_reciprocal_rank_fusion_combines_rankings 330
function test_reciprocal_rank_fusion_zero_weight_ignored 340
function test_hybrid_search_prefers_keyword_match_over_vector_tie 346
function test_hybrid_search_module_boost_reorders_ties 370
function test_hybrid_search_prominence_boost_reorders_ties 401
function test_hybrid_search_config_knobs_are_applied 435 A custom config with keyword_weight=0 must disable the keyword pass.

tests/semantic_graph/test_interfaces.py

source · 1 tests · 63 lines

Tests for the semantic graph protocol interfaces.

Covers: semantic_graph.interfaces, semantic_graph.models

Kind Name Line Description
function test_dummy_implements_semantic_graph_protocol 56

tests/semantic_graph/test_main_discovery.py

source · 10 tests · 173 lines

Tests for orchestrata_ultimate.semantic_graph.main_discovery.

Covers: semantic_graph.exceptions, semantic_graph.main_discovery

Kind Name Line Description
class TestResolveMainLiveCluster 57
method TestResolveMainLiveCluster.test_resolves_a_reachable_main_data_instance 58
method TestResolveMainLiveCluster.test_controller_url_set_but_unreachable_falls_through_to_coordinators 80 A configured-but-dead HA controller must not abort discovery --
class TestResolveMainFallback 102
method TestResolveMainFallback.test_falls_back_to_memgraph_uri_when_controller_and_uris_absent 103
method TestResolveMainFallback.test_raises_when_nothing_is_configured 109
method TestResolveMainFallback.test_blank_memgraph_uri_also_raises 113
method TestResolveMainFallback.test_unreachable_coordinators_fall_through_to_memgraph_uri 117 Every coordinator in MEMGRAPH_URIS unreachable -> falls back to
class TestResolveMainCache 130
method TestResolveMainCache.test_cache_returns_same_value_until_reset 131
method TestResolveMainCache.test_cache_false_bypasses_the_cache_entirely 147
class TestAsBoltUri 158
method TestAsBoltUri.test_normalizes_neo4j_scheme_to_bolt 159
method TestAsBoltUri.test_bare_host_port_gets_bolt_scheme 167

tests/semantic_graph/test_memgraph_adapter.py

source · 58 tests · 2046 lines

Integration tests for MemgraphSemanticGraph.

Covers: semantic_graph.adapters.memgraph, semantic_graph.config, semantic_graph.exceptions, semantic_graph.models

Kind Name Line Description
function test_connect 411
function test_execute_with_reconnect_retries_storage_contention 415 A transient storage-access-contention error is retried with backoff, not
function test_execute_with_reconnect_gives_up_after_max_storage_retries 447 Storage-contention retries are bounded — persistent contention still
function test_permanent_unknown_database_is_not_storage_contention 465 A transient-CLASSED but permanent error must not enter the retry storm.
function test_connect_to_nonexistent_database_fails_fast 485 connect() against a provably nonexistent database fails in < 2s.
function test_upsert_and_get_entity 515
function test_upsert_relationship 528
function test_add_chunks_and_search 549
function test_native_vector_index_is_created 566
function test_retrieve_assembles_context 580
function test_relationship_properties_preserved 610
function test_depth_two_hops 640
function test_depth_one_hop_does_not_reach_two 670
function test_custom_chunk_label_isolation 700 A custom chunk label keeps chunks separate from the default Chunk label.
function test_drop_chunk_label_schema_removes_constraint_and_indexes 743 Teardown hygiene on the SHARED cluster: connect() creates a uniqueness
function test_connect_reports_failure_for_unreachable_uri 803
function test_depth_validation 815
function test_retrieve_with_zero_graph_depth 827
function test_retrieve_matches_entity_by_property 858
function test_entity_labels_and_relationship_ids_preserved 888
function test_clear_test_data_removes_prefixed_nodes 913
function test_vector_index_rejects_dimension_mismatch 930 Private label/index: this test deliberately forces a dimension
function test_clear_drops_vector_index 986 Private label/index: clear() drops the WHOLE vector index for this
function test_clear_prefixed_isolates_entities 1025 Private label/index: clear_prefixed() drops the WHOLE vector index
function test_link_chunks_to_modules_creates_module_nodes 1078 Regression (found under this restructuring's baseline run,
function test_write_batch_size_defaults_to_500_and_rejects_non_positive 1156
function test_clear_deletes_every_chunk_in_bounded_batches 1166 batch=2 over 5 chunks: clear() only empties the label by looping
function test_clear_prefixed_deletes_every_chunk_in_bounded_batches 1190
function test_link_chunks_to_modules_links_every_chunk_in_bounded_batches 1209 batch=2 over 5 module-tagged chunks (+1 untagged): every tagged chunk
function test_resolve_uri_uses_controller_response 1252
function test_resolve_uri_falls_back_to_coordinator_discovered_main 1291 No HA controller configured -> falls back to probing config.uris
function test_resolve_uri_falls_back_when_controller_errors 1333
function test_add_empty_chunks_is_noop 1369 Private label: asserts NO vector index exists at all, which only
function test_search_similar_with_empty_embedding 1404
function test_search_similar_returns_fewer_than_top_k 1410 Private label: this asserts fewer results than top_k because ONLY ONE
function test_retrieve_includes_relationships 1458
function test_retrieve_batched_expansion_measured 1510 D1 acceptance: one batched expansion, not a per-entity round-trip storm.
function test_connect_with_empty_uri_returns_false 1688
function test_connect_uses_credentials_when_provided 1701
function test_upsert_empty_entities_and_relationships 1714
function test_loads_existing_vector_index_dimension 1724
function test_operation_raises_when_unreachable 1740
function test_entity_without_labels 1758
function test_entity_with_invalid_labels_defaults_to_empty 1768
function test_search_keyword_counts_distinct_term_matches 1798
function test_search_keyword_empty_terms 1827
function test_matching_module_names 1833
function test_matching_module_names_empty_terms 1853
function test_chunk_prominence_via_belongs_to 1859
function test_chunk_prominence_ignores_entities_without_prominence 1883
function test_chunk_prominence_empty_ids 1902
function test_find_stale_chunk_nodes_scopes_to_orchestrata_shape 1911 A stale node (orchestrata id, no chunk_id, no DERIVED_FROM) is found;
function test_prune_stale_chunk_nodes_dry_run_does_not_delete 1950
function test_prune_stale_chunk_nodes_no_matches_is_noop 1972
function test_chunks_with_id_prefix_finds_matching_chunks 1980
function test_chunks_with_id_prefix_empty_prefixes 2005
function test_delete_chunks_removes_by_exact_id 2011
function test_delete_chunks_empty_ids_is_noop 2042

tests/semantic_graph/test_memgraph_ha.py

source · 31 tests · 632 lines

Tests for the Memgraph HA controller.

Covers: core.graph_factory, semantic_graph.ha_controller

Kind Name Line Description
function test_status_endpoint_reports_single_node 145
function test_main_endpoint_returns_persisted_main 161
function test_state_persists_across_controller_restarts 173
function test_polling_marks_node_healthy 191
function test_failover_endpoint_is_noop_with_single_node 204
function test_set_role_makes_node_main 216
function test_set_role_to_replica_on_unreachable_node 225
function test_reconcile_roles_with_single_node_is_noop 241
function test_perform_failover_with_single_node_is_noop 251
function test_current_main_none_when_persisted_main_unknown 260
function test_check_node_marks_unreachable_node_unhealthy 273
function test_register_replica_against_unreachable_main 294
function test_reconcile_roles_when_main_is_healthy 315
function test_perform_failover_attempts_promotion 336
function test_ensure_replicas_registered_skips_unhealthy 357
function test_ensure_replicas_registered_registers_real_replica 370
function test_demote_stray_mains_demotes_real_stray_main 396
function test_set_role_rejects_unknown_role 417
function test_run_starts_monitoring_loop 427
function test_reconcile_roles_triggers_failover_when_main_unhealthy 437
function test_perform_failover_falls_back_to_main_or_unknown_candidates 473
function test_perform_failover_warns_when_no_candidate 499
function test_perform_failover_promotes_real_node 509
class TestNoteReplicaProgress 546 Pure state-machine tests for the frozen-but-ready replica detector.
method TestNoteReplicaProgress.test_frozen_ready_replica_triggers_at_threshold 570
method TestNoteReplicaProgress.test_trigger_resets_the_counter 577
method TestNoteReplicaProgress.test_advancing_ts_never_triggers 585
method TestNoteReplicaProgress.test_in_sync_replica_resets_tracking 590
method TestNoteReplicaProgress.test_recovery_status_is_exempt 599
method TestNoteReplicaProgress.test_unregistered_replica_resets_tracking 606
method TestNoteReplicaProgress.test_non_int_fields_never_trigger 614
method TestNoteReplicaProgress.test_replicas_are_tracked_independently 626

tests/semantic_graph/test_memory_adapter.py

source · 27 tests · 343 lines

Tests for the in-memory semantic graph adapter.

Covers: semantic_graph.adapters.memory, semantic_graph.models

Kind Name Line Description
function test_connect 22
function test_upsert_and_get_entity 26
function test_upsert_relationship 32
function test_depth_two_hops 49
function test_add_chunks_and_search 68
function test_search_ignores_missing_embeddings 80
function test_retrieve_assembles_context 91
function test_clear 107
function test_relationship_properties_preserved 116
function test_depth_one_hop_does_not_reach_two 141
function test_close_is_noop 162
function test_get_neighbors_depth_zero 166
function test_search_skips_dimension_mismatch 173
function test_cosine_similarity_zero_norm 185
function test_dump_snapshot 196
function test_retrieve_includes_relationships 205
function test_search_keyword_counts_distinct_term_matches 226
function test_search_keyword_empty_terms_returns_empty 243
function test_matching_module_names 250
function test_matching_module_names_empty_terms 261
function test_chunk_prominence_via_belongs_to 267
function test_chunk_prominence_ignores_entities_without_prominence 286
function test_chunk_prominence_empty_ids 297
function test_chunks_with_id_prefix_finds_matching_chunks 301
function test_chunks_with_id_prefix_empty_prefixes 317
function test_delete_chunks_removes_by_exact_id 324
function test_delete_chunks_empty_ids_is_noop 337

tests/semantic_graph/test_models.py

source · 10 tests · 81 lines

Tests for semantic_graph models.

Covers: semantic_graph.models

Kind Name Line Description
function test_entity_construction 15
function test_entity_requires_id 22
function test_relationship_construction 27
function test_relationship_requires_ids 41
function test_relationship_requires_id 46
function test_relationship_requires_type 51
function test_relationship_requires_target_id 56
function test_chunk_construction 61
function test_chunk_requires_id 74
function test_graph_rag_context_is_empty 79

tests/semantic_graph/test_repository.py

source · 5 tests · 55 lines

Tests for the semantic graph repository factory.

Covers: semantic_graph.adapters.memgraph, semantic_graph.adapters.memory, semantic_graph/ (package)

Kind Name Line Description
function test_factory_defaults_to_memgraph 20
function test_factory_selects_memory 29
function test_factory_rejects_unknown_backend 36
function test_memory_factory_graph_is_usable 43
function test_factory_uses_env_config 50

tests/semantic_graph/test_rerankers.py

source · 7 tests · 77 lines

Tests for the OpenRouter reranker.

Covers: semantic_graph.exceptions, semantic_graph.models, semantic_graph.rerankers

Kind Name Line Description
function test_rerank_orders_chunks 21
function test_rerank_empty_chunks 34
function test_rerank_single_chunk 39
function test_reranker_requires_api_key 47
function test_rerank_http_error 52
function test_rerank_http_status_error 61
function test_rerank_with_integer_index_results 68

tests/semantic_graph/test_spec_trace_enrichment.py

source · 32 tests · 749 lines

Tests for spec/trace parsing and semantic graph enrichment.

Covers: semantic_graph._freshness, semantic_graph.adapters.memgraph, semantic_graph.adapters.memory, semantic_graph.config, semantic_graph.spec_trace_enricher, semantic_graph.spec_trace_parser, core.traceability/ (package)

Kind Name Line Description
function test_parse_requirements_file_extracts_ids_and_status 124
function test_parse_requirements_file_returns_empty_for_missing_file 138
function test_parse_requirements_file_infers_spec_from_req_id 142
function test_parse_spec_file_extracts_metadata_and_stories 150
function test_parse_spec_file_returns_none_for_missing_file 169
function test_parse_spec_file_infers_id_from_directory_name 173
function test_parse_all_specs_walks_directory_tree 186
function test_parse_all_specs_raises_for_missing_root 203
function test_collect_code_traces_finds_traces 208
function test_build_trace_index_filters_invalid_reqs 234
function test_enricher_builds_entities_and_relationships 254
function test_enricher_writes_to_in_memory_graph 301
function test_enrich_project_with_specs_and_traces_integration 333
function test_enrichment_summary_to_dict 379
function test_enricher_handles_duplicate_traces_gracefully 400
function test_collect_test_traces_finds_traced_test_function 439
function test_map_test_modules_to_source_matches_convention 458
function test_map_test_modules_to_source_empty_for_missing_root 483
function test_enricher_builds_test_case_entities_and_tests_edges 487
function test_enricher_ignores_test_trace_referencing_unknown_req 538
function test_enricher_builds_test_module_entities_and_tests_edges 554
function test_enricher_skips_test_module_map_entry_with_no_code_elements 586
function test_enrich_project_with_specs_and_traces_with_tests_integration 596
function test_enrich_project_with_specs_and_traces_with_tests_false_skips_scan 650
function test_file_digest_is_stable_and_content_sensitive 692
function test_load_manifest_missing_file_returns_empty 704
function test_load_manifest_corrupt_json_returns_empty 708
function test_load_manifest_non_object_json_returns_empty 713
function test_save_and_load_manifest_roundtrip 718
function test_changed_files_detects_new_modified_and_unchanged 727
function test_changed_files_fails_open_for_unreadable_path 742
function test_default_manifest_path_is_under_plans 748

Support files

Fixtures, package markers and helpers without test functions.