/ core / attention / __pycache__ / graph_integration.cpython-314.pyc
graph_integration.cpython-314.pyc
  1  +
  2  j@gi�T��a�R&t20tRt^RIt^RIt^RIHtHt^RIHtHt^RI	H
  3  t
  4  ^RIHtH
t
HtHtHtHtHt^RIHt^RIt^RIt^RIHtHt]!RR	44t]!R
  5  R44t]!RR
44t]!RR44t!RR4tRs]^kRRlt ]!R8XEd"]"!R4]!4t#]#PI^R7t%]"!R]%PL24]"!R]%PN24]"!R](!]%PR424]"!R4]%PTPW4Fwt,t-]"!R],R]-24K	]"!R4]%P\PW4Fwt/t-]"!R]/R]-24K	]"!R4]#Pa^4F(t1]"!R]1R ,R!
R"]1R#,R$,R%24K*	R#R#)'uh
  6  Graph Integration Layer
  7  
  8  Connects the Sovereign_Estate graph (atoms, edges, aha moments) with the
  9  Sovereign_OS attention system and server.
 10  
 11  Data flows:
 12      stream_session.py → atoms.jsonl → GraphIntegration → Server endpoints
 13      historical_processor.py → edges.jsonl → GraphIntegration → Correlation
 14      edge_prediction.py → aha events → GraphIntegration → Alert system
 15  
 16  This module:
 17  1. Watches graph data files for changes
 18  2. Streams new atoms/edges to the attention system
 19  3. Exposes graph state via server endpoints
 20  4. Correlates graph events with other sources (Monologue, Comet, artifacts)
 21  N)�	dataclass�field)�datetime�	timedelta)�Path)�Dict�List�Optional�Set�Any�Callable�	Generator)�defaultdict)�detect_signals�SignalDetectionc�a�]tRt^!toRtRt]!]R7t]!]	R7t
 22  ]!]R7tRtRt
]V3RlRl4t]V3RlRl4tV3R	ltR
 23  tVtR#)�	GraphAtomz An atom from the semantic graph.N��default_factoryg�?c� <�V^8�dQhRS[/#���return)�str)�format�
__classdict__s"��C/Users/rcerf/repos/Sovereign_OS/core/attention/graph_integration.py�__annotate__�GraphAtom.__annotate__7s���9�9�#�9�c�:�VPPRR4#)zJGet altitude from meta tags (philosophical/strategic/operational/general).�altitude�general��	meta_tags�get��selfs&rr!�GraphAtom.altitude6s���~�~�!�!�*�i�8�8rc� <�V^8�dQhRS[/#r)�float)rrs"�rrr<s���6�6�5�6rc�L�VPPR4;'gR#)z#Get resonance score from meta tags.�	resonance��?r#r&s&rr,�GraphAtom.resonance;s!���~�~�!�!�+�.�5�5�#�5rc�
 24  <�V^8�dQh/S[;R&S[;R&S[;R&S[;R&S[;R&S[S[,;R&S[S[,;R&S[S[S[3,;R&S[S[S[S[3,,;R	&S[S[,;R
 25  &S[;R&#)r�uuid�content�source_type�
 26  session_id�	timestamp�parent_uuid�visible_tagsr$�edges�signals�weight)rrr	rrrrr*)rrs"�rrr!s������I���L�	�
 27  ����O�
�����#��%���s�)�9���C��H�~�;����S�#�X���=��$�o�
&�-�%�&
��'r�)�__name__�
 28  __module__�__qualname__�__firstlineno__�__doc__r5r�listr6�dictr$r7r8r9�propertyr!r,�__annotate_func__�__static_attributes__�__classdictcell__�rs@rrr!sj����*�"&�K�$�D�9�L� %�d� ;�I�#(��"=�E�*.�G��F�
�9��9��6��6�7�rrc�4a�]tRt^AtoRtRtV3RltRtVtR#)�	GraphEdgezAn edge between atoms.�c�b<�V^8�dQh/S[;R&S[;R&S[;R&S[;R&S[;R&S[;R&#)r�source�target�	edge_type�strength�	formed_at�formation_context)rr*r)rrs"�rr�GraphEdge.__annotate__AsO����
�K��
�K�	�
 29  �N���O�
������rr:N)	r;r<r=r>r?rPrCrDrErFs@rrHrHAs���� � ���rrHc�a�]tRt^LtoRt^t^tRtRt]	!]
 30  R7t]	!]
 31  R7t]	!]
 32  R7t
]	!]R7t]	!]R7tV3RltRtVtR#)�
 33  GraphStatez$Current state of the semantic graph.Nrc�<�V^8�dQh/S[;R&S[;R&S[S[,;R&S[S[,;R&S[S[S[3,;R&S[S[S[3,;R&S[S[S[3,;R&S[S[,;R&S[S[,;R	&#)
 34  r�
 35  atom_count�
 36  edge_count�last_atom_time�last_edge_time�atoms_by_session�atoms_by_altitude�
edges_by_type�high_resonance_atoms�
gravity_wells)�intr	rrrr)rrs"�rr�GraphState.__annotate__Ls����������	�
 37  �X�&�-���X�&�-�
��3��8�n�B���C��H�~�C����S��>�?���s�)�A����9�:�rr:)r;r<r=r>r?rUrVrWrXrrArYrZr[r@r\r]rCrDrErFs@rrSrSLs\����.��J��J�)-�N�)-�N�(-�T�'B��(-�d�(C��$)�$�$?�M�',�D�&A��$�T�:�M��rrSc�0a�]tRt^^toRtV3RltRtVtR#)�
 38  GraphEventz4An event from the graph (new atom, edge, aha, etc.).c�T<�V^8�dQh/S[;R&S[;R&S[S[S[3,;R&#)r�
 39  event_typer4�data)rrrr)rrs"�rr�GraphEvent.__annotate__^s3�����O����	�
 40  �s�C�x�.��rr:N)r;r<r=r>r?rCrDrErFs@rrara^s����>��rrac��a�]tRt^ftoRt]P!4R,t]R,t]R,t	R,V3RlRllt
 41  V3RlR	ltV3R
 42  lRltV3RlR
lt
R-V3RlRlltR.V3RlRlltR.V3RlRlltV3RlRltV3RlRltRtV3RlRltV3RlRltR/V3RlRlltR0V3RlR lltV3R!lR"ltR0V3R#lR$lltR%tR&tR'tR(tR1V3R)lR*lltR+tVt R#)2�GraphIntegrationz�
 43  Integrates the Sovereign_Estate semantic graph with Sovereign_OS.
 44  
 45  Provides:
 46  - Real-time streaming of graph updates
 47  - Query interface for graph state
 48  - Correlation with other data sources
 49  - Event subscription for new atoms/edges/ahas
 50  z!repos/Sovereign_Estate/data/graph�atomsr7Nc�6<�V^8�dQhRS[S[,RS[/#)r�	graph_dir�watch_interval)r	rr*)rrs"�rr�GraphIntegration.__annotate__vs#���>�>��C�=�>��>rc�T�V'd\V4MVPVnVPR,VnVPR,VnW n/Vn.Vn\4Vn	/Vn
 51  /Vn\\4VnRVnRVnR#)rhr7FN)r�DEFAULT_GRAPH_DIRrj�	atoms_dir�	edges_dirrk�_atoms�_edgesrS�_state�_atom_file_positions�_edge_file_positionsrr@�_subscribers�	_watching�
_watch_thread)r'rjrks&&&r�__init__�GraphIntegration.__init__vs���
 52  -6��i��4�;Q�;Q������'�1������'�1���,��-/���')��� �l���57��!�46��!�8C�4�7H������9=��rc�<<�V^8�dQhRS[RS[S[.R3,/#)rrc�callbackN)rrra)rrs"�rrrl�s'���7�7�C�7�8�Z�L�$�<N�3O�7rc�J�VPV,PV4R#)z:Subscribe to graph events (atom, edge, aha, gravity_well).N)rv�append)r'rcr|s&&&r�	subscribe�GraphIntegration.subscribe�s�����*�%�,�,�X�6rc�<<�V^8�dQhRS[RS[S[S[3,/#)rrcrd)rrr)rrs"�rrrl�s#�������4��S��>�rc�x�\V\P!4VR7pVPP	V.4FpV!V4K	VPP	R.4FpV!V4K	R# \
 53  dp\
RT24Rp?K]Rp?ii;i \
 54  dpRp?KJRp?ii;i)zEmit an event to subscribers.)rcr4rdz%[GraphIntegration] Subscriber error: N�all)rar�nowrvr%�	Exception�print)r'rcrd�eventr|�es&&&   r�_emit�GraphIntegration._emit�s����!��l�l�n��
 55  ��
 56  �)�)�-�-�j�"�=�H�
C����>��)�)�-�-�e�R�8�H�
����9��	�
C��=�a�S�A�B�B��
C���
���
�s*�A<�.B#�<B �B�B �#B9�4B9c� <�V^8�dQhRS[/#r)rS)rrs"�rrrl�s�����J�rc�v�\P!4PR4pVPVR2,pVP	4'dVPV4VPVR2,pVP	4'dVPV4VP4VP#)zLoad today's graph data.�%Y-%m-%d�-atoms.jsonl�-edges.jsonl)
 57  rr��strftimero�exists�_load_atoms_filerp�_load_edges_file�
_update_staters)r'�today�
 58  atoms_file�
 59  edges_files&   r�
 60  load_today�GraphIntegration.load_today�s�������'�'�
 61  �3���^�^���|�&<�<�
 62  �������!�!�*�-��^�^���|�&<�<�
 63  �������!�!�*�-������{�{�rc�&<�V^8�dQhRS[RS[/#)r�	days_backr)r^rS)rrs"�rrrl�s�����C��
 64  �rc���\V4F�p\P!4\VR7,
 65  P	R4pVP
 66  VR2,pVP
4'dVPV4VPVR2,pVP
4'gK�VPV4K�	VP4VP#)z!Load graph data for a date range.)�daysr�r�r�)�rangerr�rr�ror�r�rpr�r�rs)r'r��i�dater�r�s&&    r�
 67  load_range�GraphIntegration.load_range�s����y�!�A��L�L�N�Y�A�%6�6�@�@��L�D����T�F�,�*?�?�J�� � �"�"��%�%�j�1����T�F�,�*?�?�J�� � �"�"��%�%�j�1�"�	
�����{�{�rc�,<�V^8�dQhRS[RS[RS[/#�r�filepath�
from_positionr�rr^)rrs"�rrrl�s"���(�(��(�c�(�#�(rc�Z�^p\VR4;_uu_4pV^8�dVPV4VF�pVP4pV'gK\P!V4pVPV4pV'd�VPVP9d�WpPVP&V^,
pVPRRVPRVPR,RVPRVPRVPR	VP/4K�K�K�	VP4VP \#V4&R
 68  R
 69  R
 70  4V# \PdEK;i;i +'giT#;i \$dp\'RT24R
 71  p?T#R
 72  p?ii;i)z5Load atoms from a JSONL file, starting from position.�r�atomr0r1�N��Nr2r!r,�tagsNz([GraphIntegration] Error loading atoms: )�open�seek�strip�json�loads�_parse_atomr0rqr�r1r2r!r,r6�JSONDecodeError�tellrtrr�r�)	r'r�r��	new_atoms�f�linerdr�r�s	&&&      rr��!GraphIntegration._load_atoms_file�sw���	�"	B��h��$�$�� �1�$��F�F�=�)��D��:�:�<�D�� �!�#�z�z�$�/��#�/�/��5���D�I�I�T�[�[�$@�59�K�K��	�	�2�%��N�I�!�J�J�v� &��	�	� )�4�<�<��+=� -�t�/?�/?� *�D�M�M� +�T�^�^� &��(9�(9�
0��%A�4��4<=�6�6�8��)�)�#�h�-�8�=%�F��� �/�/�!� �!��5%�$�F����	B��<�Q�C�@�A�A����	B�s_�F�8E2�.E�BE�.E2�F�E/	�*E2�.E/	�/E2�2F	�=F�F�F*�F%�%F*c�,<�V^8�dQhRS[RS[RS[/#r�r�)rrs"�rrrl�s"���%�%��%�c�%�#�%rc���^p\VR4;_uu_4pV^8�dVPV4VF�pVP4pV'gK\P!V4pVPV4pV'diVPPV4V^,
pVPRRVPRVPRVPRVP/4K�K�	VP4VP\!V4&RRR4V# \PdEKi;i +'giT#;i \"dp\%RT24Rp?T#Rp?ii;i)	zLoad edges from a JSONL file.r��edgerKrL�typerNNz([GraphIntegration] Error loading edges: )r�r�r�r�r��_parse_edgerrr~r�rKrLrMrNr�r�rurr�r�)	r'r�r��	new_edgesr�r�rdr�r�s	&&&      rr��!GraphIntegration._load_edges_file�sL���	�	B��h��$�$�� �1�$��F�F�=�)��D��:�:�<�D�� �!�#�z�z�$�/��#�/�/��5��� �K�K�.�.�t�4�%��N�I�!�J�J�v� (�$�+�+� (�$�+�+� &���� *�D�M�M�	0�� ��.<=�6�6�8��)�)�#�h�-�8�7%�@��� �/�/�!� �!��1%�$�@����	B��<�Q�C�@�A�A����	B�s_�E
�8D9�.D�A&D�&,D9�E
�D6	�1D9�5D6	�6D9�9E
 73  	�E
�
 74  E
�
E1�E,�,E1c�L<�V^8�dQhRS[S[S[3,RS[S[,/#�rrdr)rrrr	r)rrs"�rrrls(������S�#�X���8�I�3F�rc���VPRR4p\P!VPRR44pVPRR7p\TPRR4TPRR4TPR	R
 75  4TPRR4TTPR4TPR
.4TPR/4TPR.4R7	p\
TP4TnTPP^TP,,TnT# \P!4pL�;i \dpRp?R#Rp?ii;i)zParse atom from JSON data.r4rI�Zz+00:00N)�tzinfor0r1r2�unknownr3r5r6r$r7)	r0r1r2r3r4r5r6r$r7)
r%r�
fromisoformat�replacer�rrr1r8�weight_modifierr,r9r�)r'rd�ts_strr4r�r�s&&    rr��GraphIntegration._parse_atoms#��	��X�X�k�2�.�F�
+�$�2�2�6�>�>�#�x�3P�Q�	�%�-�-�T�-�:�	���X�X�f�b�)�����B�/� �H�H�]�I�>��8�8�L�"�5�#� �H�H�]�3�!�X�X�n�b�9��(�(�;��3��h�h�w��+�
 76  �D�*�$�,�,�7�D�L��,�,�6�6�!�d�n�n�:L�M�D�K��K��'
+�$�L�L�N�	��(�	���	�s)�E�8D/�
C!E�/E�E�E!�E!c�L<�V^8�dQhRS[S[S[3,RS[S[,/#r�)rrrr	rH)rrs"�rrrl:s(������S�#�X���8�I�3F�rc�`�VPRR4p\P!V4p\	TPRR4TPRR4TPRR4TPRR4TTPR	R4R
 77  7# \P!4pLz;i R#;i)zParse edge from JSON data.rOrIrKrLrM�
 78  relates_torNr-rP)rKrLrMrNrOrPN)r%rr�r�rH)r'rdr�r4s&&  rr��GraphIntegration._parse_edge:s���	��X�X�k�2�.�F�
+�$�2�2�6�:�	���x�x��"�-��x�x��"�-��(�(�;��=����*�c�2�#�"&�(�(�+>��"C�
�
��
+�$�L�L�N�	��	��s"�B(�B�A B(�B%�#B(�(B-c��\VP4VPn\VP4VPn\
\4VPn\
\4VPn	\
\4VPn
 79  VPP4F�pVPPVPR,;;,^,
uu&VPPVP;;,^,
uu&VP'gK�VPP'd(VPVPP8�gK�VPVPnK�	VPF�pVPPVP ;;,^,
uu&VP"'gKJVPP$'d(VP"VPP$8�gK�VP"VPnK�	\'VPP4RRR7pVR,Uu.uFqDP(NK	upVPn\
\4pVPF?pWRP,;;,^,
uu&WRP.;;,^,
uu&KA	VP14UUu.uFwrgV^
 80  8�gKVNK	uppVPnR#uupiuuppi)zUpdate graph state statistics.:N�Nc��VP#�N�r,��as&r�<lambda>�0GraphIntegration._update_state.<locals>.<lambda>i���!�+�+rT��key�reverse:N�NN)�lenrqrsrUrrrVrr^rYrZr[�valuesr3r!r4rWrMrOrX�sortedr0r\rKrL�itemsr])r'r�r��sorted_atomsr��edge_countsr0�counts&       rr��GraphIntegration._update_stateNs1��!$�T�[�[�!1�����!$�T�[�[�!1�����(3�3�'7����$�(3�C�(8����%�$/��$4����!��K�K�&�&�(�D��K�K�(�(�����)<�=��B�=��K�K�)�)�$�-�-�8�A�=�8��~�~�~�t�{�{�'A�'A�'A�#'�>�>�D�K�K�4N�4N�#N�-1�^�^����*�)��K�K�D��K�K�%�%�d�n�n�5��:�5��~�~�~�t�{�{�'A�'A�'A�#'�>�>�D�K�K�4N�4N�#N�-1�^�^����*�	 ���K�K��� �%��
 81  ��
 82  =I��<M�+N�<M�q�F�F�<M�+N����(�"�#�&���K�K�D����$��)�$����$��)�$� �
 83  %0�$5�$5�$7�%
 84  �$7�[�T���{�
�D�$7�%
 85  ����!��,O��%
 86  s�
M�$M�4Mc�6<�V^8�dQhRS[S[S[3,/#r)rrr)rrs"�rrrl{s���
 87  �
 88  �4��S��>�
 89  rc�^�RVPPRVPPRVPP'd%VPPP	4MRRVPP
 90  'd%VPP
 91  P	4MRR\
VPP4R\
VPP4R\VPP4R	\VPP4/#)
 92  zGet current graph state.rUrVrWNrXrZr[�gravity_well_count�high_resonance_count)rsrUrVrW�	isoformatrXrArZr[r�r]r\r&s&r�	get_state�GraphIntegration.get_state{s���
�$�+�+�0�0��$�+�+�0�0�����Hb�Hb�Hb�d�k�k�8�8�B�B�D�hl�����Hb�Hb�Hb�d�k�k�8�8�B�B�D�hl���d�k�k�&C�&C�!D��T�$�+�+�";�";�<� �#�d�k�k�&?�&?�"@�"�C����(H�(H�$I�	
 93 94  rc�L<�V^8�dQhRS[RS[S[S[S[3,,/#)rr0r)rr	rr)rrs"�rrrl�s(���
 95  �
 96  �S�
 97  �X�d�3��8�n�%=�
 98  rc�n�VPPV4pV'gR#RVPRVPRVPRVP
 99  RVPP4RVPRVPR	VPR
100  VPR\VP4/
101  #)zGet a specific atom by UUID.Nr0r1r2r3r4r!r,r9r6rV)rqr%r0r1r2r3r4r�r!r,r9r6r�r7)r'r0r�s&& r�get_atom�GraphIntegration.get_atom�s����{�{���t�$����
�D�I�I��t�|�|��4�+�+��$�/�/�����1�1�3���
�
������d�k�k��D�-�-��#�d�j�j�/�
102103  rc�h<�V^8�dQhRS[RS[S[,RS[RS[S[S[S[3,,/#)r�limitr2�
104  min_weightr)r^r	rr*rrr)rrs"�rrrl�sD���
105  �
106  ��
107  ��c�]�
108  ��	
109110  
111  �d�3��8�n�	�
112  rc�,�\VPP4RRR7pV'd$VUu.uFqUPV8XgKVNK	ppV^8�d$VUu.uFqUPV8�gKVNK	ppVRVUu.uFzpRVP
113  RVPR,RVPR	VPP4R
114  VPRVPRVPR
VP/NK|	up#uupiuupiuupi)z&Get recent atoms, optionally filtered.c��VP#r��r4r�s&rr��3GraphIntegration.get_recent_atoms.<locals>.<lambda>�r�rTr�Nr0r1�Ni,Nr2r4r!r,r9r�)r�rqr�r2r9r0r1r4r�r!r,r6)r'r�r2r�rhr�s&&&&  r�get_recent_atoms�!GraphIntegration.get_recent_atoms�s����K�K��� �%��
115  ��� %�F��1���+�)E�Q�Q��E�F���>� %�@��1���Z�)?�Q�Q��E�@��6�E�]�
116  �#�������1�9�9�T�?��q�}�}��Q�[�[�2�2�4��A�J�J��Q�[�[��!�(�(�����	
�#�
117118  ��G��A��
119  s�D�D�D�5D�BDc�L<�V^8�dQhRS[RS[S[S[S[3,,/#)rr�r)r^rrrr)rrs"�rrrl�s(���
120  �
121  �c�
122  �4��S�#�X��;O�
123  rc
�
124  �\VPP4RRR7pVRVUu.uFHpRVPRVPR,RVP
125  R	VPR
126  VP/NKJ	up#uupi)z(Get atoms with highest resonance scores.c��VP#r�r�r�s&rr��;GraphIntegration.get_high_resonance_atoms.<locals>.<lambda>�r�rTr�Nr0r1r�r,r!r�)r�rqr�r0r1r,r!r6)r'r�rhr�s&&  r�get_high_resonance_atoms�)GraphIntegration.get_high_resonance_atoms�s�����K�K��� �%��
127  ���6�E�]�	
128  �#��
�����1�9�9�T�?��Q�[�[��A�J�J�����
�#�	
129130  ��	
131  s�ABc�F<�V^8�dQhRS[S[S[S[3,,/#r)rrrr)rrs"�rrrl�s!���>�>�4��S�#�X��#7�>rc�a�.pVPPF�oVPPS4pV'gK(\	V3RlVP
132  44p\	V3RlVP
133  44pVP
RSRVPR,RVRVRW4,R	VP/4K�	\VR
134  R7#)z+Get gravity wells (highly connected nodes).c3�L<"�TFqPS8XgK^x�K	R#5i��N)rL��.0r�r0s& �r�	<genexpr>�5GraphIntegration.get_gravity_wells.<locals>.<genexpr>������J�+�Q���T�9I�q�q�+���$�
135  $c3�L<"�TFqPS8XgK^x�K	R#5ir)rKrs& �rrr	�r
136  rr0r1r��incoming_edges�outgoing_edges�total_edgesr!c��VR,)#)rr:)�ws&rr��4GraphIntegration.get_gravity_wells.<locals>.<lambda>�s��A�m�,<�+<r�r�)
137  rsr]rqr%�sumrrr~r1r!r�)r'�wellsr��incoming�outgoingr0s&    @r�get_gravity_wells�"GraphIntegration.get_gravity_wells�s�������K�K�-�-�D��;�;�?�?�4�(�D��t��J�$�+�+�J�J���J�$�+�+�J�J������D��t�|�|�D�1�$�h�$�h�!�8�#6���
�
�
��.� �e�!<�=�=rc	�R<�V^8�dQhRS[RS[RS[S[S[S[3,,/#)r�queryr�r)rr^rrr)rrs"�rrrl�s/���
138  �
139  �#�
140  �c�
141  �4��S�#�X��;O�
142  rc��VP4p.pVPP4F4pW5PP49gK#VP	V4K6	VPRR7VRVUu.uFJpRVPRVPR,RVPRVPP4/NKL	up#uupi)	z Simple text search across atoms.c�F�VP)\VP43#r�)r9r�r1r�s&rr��/GraphIntegration.search_atoms.<locals>.<lambda>�s��
�X�X�I���	�	�N�$
143  rrNr0r1r�r9r4)
144  �lowerrqr�r1r~�sortr0r9r4r�)r'rr��query_lower�matchesr�r�s&&&    r�search_atoms�GraphIntegration.search_atoms�s����k�k�m�����K�K�&�&�(�D��l�l�0�0�2�2����t�$�)�
145  	���
146  ��	��V�e�_�
147  �%�������1�9�9�T�?��!�(�(��Q�[�[�2�2�4�	
�%�
148  �	
149  ��
150  s�?ACc���VP'dR#RVn\P!VPRR7VnVPP4\
R4R#)z/Start watching for graph updates in background.NT)rL�daemonz/[GraphIntegration] Started watching graph files)rw�	threading�Thread�_watch_looprx�startr�r&s&r�start_watching�GraphIntegration.start_watchingsK���>�>�>�����&�-�-�T�5E�5E�d�S������ � �"�
�?�@rc��RVnVP'dVPP^R7\R4R#)zStop watching for updates.F)�timeoutz#[GraphIntegration] Stopped watchingN)rwrx�joinr�r&s&r�
stop_watching�GraphIntegration.stop_watching
151  s5������������#�#�A�#�.�
�3�4rc��VP'Ed�\P!4PR4pVPVR2,pVP4'dnVPP\V4^4pVP4PpWC8�d)VPW#4pV^8�dVP4VPVR2,pVP4'd~VPP\V4^4pVP4PpWC8�d9VPWc4pV^8�d!VP4VP!4\&P(!TP*4EK�R# \"dp\%RT24Rp?LCRp?ii;i)z*Background loop to watch for file changes.r�r�r�z [GraphIntegration] Watch error: N)rwrr�r�ror�rtr%r�stat�st_sizer�r�rprur��_check_gravity_wellsr�r��time�sleeprk)r'r�r��pos�current_size�newr�r�s&       rr)�GraphIntegration._watch_loopsl���n�n�n�
>� ����/�/�
152  �;��"�^�^���|�.D�D�
153  ��$�$�&�&��3�3�7�7��J���K�C�#-�?�?�#4�#<�#<�L�#�)�"�3�3�J�D����7� �.�.�0�"�^�^���|�.D�D�
154  ��$�$�&�&��3�3�7�7��J���K�C�#-�?�?�#4�#<�#<�L�#�)�"�3�3�J�D����7� �.�.�0�!�5�5�7�
155  
�J�J�t�*�*�+�=��6�
>��8���<�=�=��
>�s&�AF �%BF �>A=F � G�+F>�>Gc
156  �$�\\4pVPF?pWP;;,^,
uu&WP;;,^,
uu&KA	VP4F�wr4V^
157  8�gKW0PP9gK*VPPPV4VPPV4pV'gKtVPRRVRVPR,RV/4K�	R#)z,Check for new gravity wells and emit events.�gravity_wellr0r1r�rVN)
rr^rrrKrLr�rsr]r~rqr%r�r1)r'r�r�r0r�r�s&     rr5�%GraphIntegration._check_gravity_wells3s���!�#�&���K�K�D����$��)�$����$��)�$� �'�,�,�.�K�D���{�t�;�;�+D�+D�D����)�)�0�0��6��{�{���t�,���4��J�J�~���!�4�<�<��#5�$�e�0��/rc�b<�V^8�dQhRS[S[,RS[S[S[S[3,RR3,/#)r�sincerN)r	rr
rrr)rrs"�rrrlEs8�������!��
158  �4��S��>�4��-�	.�rc#�n"�\VPP4RR7pVF�pV'dVPV8:dKRVPRVP
159  RVPRVPP4RVPRVPR	VP/x�K�	R
160  #5i)z7Generator that yields atoms, starting from a timestamp.c��VP#r�r�r�s&rr��/GraphIntegration.stream_atoms.<locals>.<lambda>Js��1�;�;rrr0r1r2r4r!r,r�N)r�rqr�r4r0r1r2r�r!r,r6)r'r@rhr�s&&  r�stream_atoms�GraphIntegration.stream_atomsEs����
161  �t�{�{�)�)�+�1F�G���D�����5�0����	�	��4�<�<��t�/�/��T�^�^�5�5�7��D�M�M��T�^�^���)�)��
�	�s�B3B5)rtrqrurrrsrvrxrwrorprjrk)Ng@)�)�)�2Ng)r�r�)!r;r<r=r>r?r�homern�DEFAULT_ATOMS_DIR�DEFAULT_EDGES_DIRryrr�r�r�r�r�r�r�r�r�r�r�r�rr#r+r0r)r5rDrDrErFs@rrgrgfs�������	�	��&I�I��)�G�3��)�G�3��>�>�47�7���(��"�� (�(�T%�%�N��@��()
162  �Z
163  �
164  �
165  �
166  �&
167  �
168  �B
169  �
170  �&>�>�,
171  �
172  �6A�5� ,�D�$��rrgc�$�V^8�dQhR\/#r)rg)rs"rrr_s����/�rc��\f3\4s\P4\P4\#)z.Get or create the graph integration singleton.)�_graph_integrationrgr�r+r:rr�get_graph_integrationrO_s1���!�-�/���%�%�'��)�)�+��r�__main__z=== Graph Integration ===
173  )r�zAtoms: zEdges: zGravity wells: z
174  Atoms by altitude:z  z: z
175  Edges by type:z
176  High resonance atoms:z  [r,z.2fz] r1:N�<Nz...c�V�V^8�dQh/^\9d\\,;R&#)rrN)�__conditional_annotations__r	rg)rs"rrrs&����t6�5�H�-�.�5�ur)3rSr?r��os�dataclassesrrrr�pathlibr�typingrrr	r
177  rrr
�collectionsrr'r6�signal_wordsrrrrHrSrargrNrOr;r��gir��staterUrVr�r]rZr��altr�r[�etyper�r�r)rSs@r�<module>r^s�����$�	�(�(��F�F�F�#���9��6�6��6�>� � �� ��;�;��;�"�����r�r�l26��5���z��	�
178  '�(�	�	�B��M�M�A�M�&�E�	�G�E�$�$�%�
179  &�'�	�G�E�$�$�%�
180  &�'�	�O�C�� 3� 3�4�5�
181  6�7�	� �"��-�-�3�3�5�
182  ��U�
��3�%�r�%��!�"�6�	����+�+�1�1�3���u�
��5�'��E�7�#�$�4�
183184  #�$��+�+�A�.��
��D��%�c�*�"�T�)�_�S�-A�,B�#�F�G�/�#r