
     i
                         d Z ddlZddlmZmZ  ej
                  d      Z ej
                  d      Z ej
                  dej                        Z	 ej
                  d      Z
dZd	ed
eee   ef   fdZy)u   
Genesis Persistent Context Architecture — fast_extract
Story 2.03 — Track B

Fast deterministic entity + intent extraction from task payloads.
Pure Python, zero I/O, runs in <1ms. NO LLM calls.
    N)TupleListzG[A-Za-z_][A-Za-z0-9_/\\.]+\.(py|ts|js|json|md|sql|yaml|yml|sh|html|css)z*(?:def|class|function|async\s+def)\s+(\w+)zK\b(redis|postgres|qdrant|telnyx|gemini|openrouter|ghl|n8n|ollama|sunaiva)\bz@\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b   task_payloadreturnc                    g }g }dD ]F  }| j                  |      }t        |t              s%|j                         s6|j	                  |       H dj                  |      }|sg dfS t        j                  |      D ]"  }|j	                  |j                  d             $ t        j                  |      D ]"  }|j	                  |j                  d             $ t        j                  |      D ]0  }|j	                  |j                  d      j                                2 t        j                  |      D ]"  }|j	                  |j                  d             $ t               }g }|D ]E  }	|	j                         |vs|j                  |	j                                |j	                  |	       G d}
dD ]P  }| j                  |      }t        |t              s%|j                         s6|j                         dt         }
 ||
fS  ||
fS )u0  
    Extract entities and intent from a task payload.

    Args:
        task_payload: Dict with optional 'prompt', 'description', 'file', 'code' keys

    Returns:
        (target_entities, intent_string) — both always populated
        Empty list and empty string for cold start / missing fields
    )promptdescriptiontaskcodefilecontext  r      )r	   r
   r   N)get
isinstancestrstripappendjoinFILE_PATH_REfinditergroupFUNCTION_RE
SERVICE_RElowerSESSION_ID_REsetaddMAX_INTENT_LENGTH)r   entitiestext_sourceskeyvalcombined_textmatchseenunique_entitieseintents              1/mnt/e/genesis-system/core/memory/fast_extract.pyfast_extractr-      s    H LK %s#c3CIIK$%
 HH\*MBx &&}5 (A'( %%m4 (A'( $$]3 0A,,./0 ''6 (A'( D!#O &779D HHQWWY""1%& F0 s#c3CIIKYY[!3"34FV$$ V$$    )__doc__retypingr   r   compiler   r   
IGNORECASEr   r   r!   dictr   r-    r.   r,   <module>r6      s    
  rzzdebjjFGRZZfhjhuhuv


^_ 9%t 9%d3in(= 9%r.   