@@ -143,6 +143,7 @@ def build_deterministic_graph_pack(
143143 concept_bundles = uow .concepts .get_concept_bundles (
144144 repo_id = request .repo_id ,
145145 concept_ids = list (concept_candidates ),
146+ include_evidence = False ,
146147 )
147148 selected_concepts , concept_trace = _select_concepts (
148149 request = request ,
@@ -473,6 +474,22 @@ def _expand_structural_memory_relations(
473474) -> dict [str , Any ]:
474475 """Add canonical structural memory-relation neighbors to recall candidates."""
475476
477+ rows_by_anchor = defaultdict (list )
478+ rows = uow .read_policy .list_structural_memory_relation_rows (
479+ repo_id = request .repo_id ,
480+ include_global = request .include_global ,
481+ anchor_memory_ids = tuple (memory_candidates ),
482+ kinds = request .kinds or list (MATURE_MEMORY_KIND_VALUES ),
483+ predicates = (
484+ * STRUCTURAL_PROBLEM_RELATION_PREDICATES ,
485+ * STRUCTURAL_FACT_UPDATE_RELATION_PREDICATES ,
486+ ),
487+ )
488+ for row in rows :
489+ for anchor_id in {row ["subject_memory_id" ], row ["object_memory_id" ]}:
490+ if anchor_id in memory_candidates :
491+ rows_by_anchor [anchor_id ].append (row )
492+
476493 discovered : list [dict [str , Any ]] = []
477494 for anchor_memory_id in tuple (memory_candidates ):
478495 anchor_entry = memory_candidates [anchor_memory_id ]
@@ -481,13 +498,11 @@ def _expand_structural_memory_relations(
481498 STRUCTURAL_PROBLEM_RELATION_PREDICATES ,
482499 STRUCTURAL_FACT_UPDATE_RELATION_PREDICATES ,
483500 ):
484- rows = uow .read_policy .list_structural_memory_relation_rows (
485- repo_id = request .repo_id ,
486- include_global = request .include_global ,
487- anchor_memory_id = anchor_memory_id ,
488- kinds = request .kinds or list (MATURE_MEMORY_KIND_VALUES ),
489- predicates = predicates ,
490- )
501+ rows = [
502+ row
503+ for row in rows_by_anchor [anchor_memory_id ]
504+ if row ["predicate" ] in predicates
505+ ]
491506 for row in rows :
492507 key = (
493508 row ["subject_memory_id" ],
@@ -578,11 +593,14 @@ def _discover_concepts(
578593 memory_entry ["concept_refs" ].add (concept_id )
579594 memory_entry ["link_roles" ].add (role )
580595
596+ concept_corpus = uow .concept_keyword_retrieval .list_concept_keyword_corpus (
597+ repo_id = request .repo_id
598+ )
581599 for lane in lanes :
582600 query_vector , query_model = embeddings [lane .name ]
583601 seeds = retrieve_concept_seeds (
584602 _lane_request_data (request = request , query = lane .query ),
585- concept_keyword_retrieval = uow . concept_keyword_retrieval ,
603+ concept_corpus = concept_corpus ,
586604 concept_semantic_retrieval = uow .concept_semantic_retrieval ,
587605 query_vector = query_vector ,
588606 query_model = query_model ,
@@ -733,6 +751,7 @@ def _traverse_selected_concepts(
733751 uow .concepts .get_concept_bundles (
734752 repo_id = request .repo_id ,
735753 concept_ids = missing_ids ,
754+ include_evidence = False ,
736755 )
737756 )
738757 for neighbor_id in unique_neighbor_ids :
0 commit comments