diff --git a/backend/app/lineage_ingestion.py b/backend/app/lineage_ingestion.py index 6e6212b8c..0e11347ef 100644 --- a/backend/app/lineage_ingestion.py +++ b/backend/app/lineage_ingestion.py @@ -56,6 +56,18 @@ "order by created_at desc, post_id desc limit $3" ).format(eligibility=SOURCE_POST_ELIGIBILITY_SQL.format(alias="source_post")) +_RECONSTRUCTION_SOURCE_SQL = ( + "select post_id, post_title, voc_type_code, created_at, corporate_entity_id, " + "process_unit_id, thread_group_key, secondary_grouping_key " + "from source_post where {eligibility}" +).format(eligibility=SOURCE_POST_ELIGIBILITY_SQL.format(alias="source_post")) + +_VISIBLE_LINEAGE_SOURCE_SQL = ( + "select post_id, post_title, voc_type_code, visibility_code, " + "corporate_entity_id, process_unit_id, thread_group_key, created_at " + "from source_post where {eligibility}" +).format(eligibility=SOURCE_POST_ELIGIBILITY_SQL.format(alias="source_post")) + def estimated_weight_channels(llm: AdjudicationClient | None) -> set[str]: """Return the channels that one live reconstruction can actually use.""" @@ -420,11 +432,7 @@ def __init__(self, active_channels: set[str]) -> None: async def _load_lineage_records(conn: asyncpg.Connection) -> list[Record]: """Load the eligible source snapshot used by one reconstruction.""" - rows = await conn.fetch( - "select post_id, post_title, voc_type_code, created_at, corporate_entity_id, " - "process_unit_id, thread_group_key, secondary_grouping_key " - f"from source_post where {SOURCE_POST_ELIGIBILITY_SQL.format(alias='source_post')}" - ) + rows = await conn.fetch(_RECONSTRUCTION_SOURCE_SQL) return records_from_source_posts(rows) @@ -521,11 +529,7 @@ def _interval_payload(row: Mapping[str, Any]) -> dict[str, Any]: async def _fetch_visible_lineage_rows(conn: asyncpg.Connection, can_see_post): """One ABAC-filtered ``source_post`` scan plus one edge-table read.""" - posts = await conn.fetch( - "select post_id, post_title, voc_type_code, visibility_code, " - "corporate_entity_id, process_unit_id, thread_group_key, created_at " - f"from source_post where {SOURCE_POST_ELIGIBILITY_SQL.format(alias='source_post')}" - ) + posts = await conn.fetch(_VISIBLE_LINEAGE_SOURCE_SQL) visible_all = [row for row in posts if can_see_post(row)] edge_rows = await conn.fetch( "select parent_post_id, child_post_id, fused_score, " diff --git a/backend/app/main.py b/backend/app/main.py index ebbe269d4..7d26c70d6 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -300,7 +300,7 @@ async def lifespan(app: FastAPI): timeout=load_settings().orchestrator_answer_timeout_seconds ), embedding_factory=_embedding_client, - claim_verification_factory=lambda: _claim_verification_client(), + claim_verification_factory=_claim_verification_client, ) ) app.state.global_ask_worker = global_ask_worker