/ core / theory_of_mind / __pycache__ / cognitive_fingerprint.cpython-314.pyc
cognitive_fingerprint.cpython-314.pyc
  1  +
  2  ��fi�=��,�Rt^RIHtHt^RIHtHt^RIHtHtH	t	H
  3  t
  4  HtHt^RI
Ht^RIt!RR]4t]!RR	44t]!R
  5  R44t]!RR
44t]!RR44t]R8XEd�]!R4]!RR7t]P1RR.R>OR7]P1RR.R?OR7]P1RR.R@OR7]P1RR.RAOR7]P3]P4RR7]P3]P6RR7]P3]P8RR7]P;R R!4]P;R"R#4]P;R$R%4]P=R&R'R(7]P=R)R*R(7]!R+4]P?^4F&t ]!R,] PBR-] PDR.
24K(	]!R/4]PG4R0,F0t$]!R,]$PJPLR1]$PNR.
24K2	]!R24](!]PRPU4R3R47Fwt+t,]!R,]+R1],R5
24K	]!R6]P[424]!R74.RBOt.].F#t!]P_]!4t0]!R8]!R9]0R.
24K%	]Pc4t2]Pg]24t4]!R:]4PjR;]6!]4Pn4R<24]!R=4R#R#)Cu�
  6  Cognitive Fingerprint
  7  
  8  Models an operator's characteristic patterns of thinking and attention.
  9  This is the "theory of self" that the system builds over time.
 10  
 11  Key components:
 12  - Gravity Wells: Topics/concepts that consistently attract attention
 13  - Pattern Preferences: Structural preferences (first-principles, narratives, contrarian)
 14  - Altitude Distribution: Where they typically think (operational → philosophical)
 15  - Resonance Triggers: What makes something "stick" for them
 16  )�	dataclass�field)�datetime�	timedelta)�Optional�List�Dict�Any�Set�Tuple)�EnumNc�B�]tRt^tRtRtRtRtRtRt	Rt
 17  RtR	tR
 18  t
RtRtR
#)�PatternTypezTypes of thinking patterns.�first_principles�systems_thinking�
narrative_arc�
 19  contrarian�
 20  analogical�quantitative�	heuristic�
 21  historical�experiential�
philosophical�N)�__name__�
 22  __module__�__qualname__�__firstlineno__�__doc__�FIRST_PRINCIPLES�SYSTEMS_THINKING�
NARRATIVE_ARC�
 23  CONTRARIAN�
 24  ANALOGICAL�QUANTITATIVE�	HEURISTIC�
 25  HISTORICAL�EXPERIENTIAL�
PHILOSOPHICAL�__static_attributes__r��L/Users/rcerf/repos/Sovereign_OS/core/theory_of_mind/cognitive_fingerprint.pyrrs9��%�)��)��#�M��J��J�!�L��I��J�!�L�#�Mr*rc�a�]tRt^#toRtRtRt]!]R7t	]!]
 26  PR7t]!]
 27  PR7t
^tRtRtV3RlRltV3RltR	tVtR
 28  #)�GravityWellz�
 29  A topic or concept that consistently attracts operator attention.
 30  
 31  Gravity wells have mass (how strongly they attract) and
 32  pull radius (how far their influence extends to related topics).
 33  ��?�333333�?��default_factoryc��\P!4VnV;P^,
un\	RVP
 34  R,4VnR#)z*Record an activation of this gravity well.gffffff�?g{�G�z�?N)r�now�last_activated�activation_count�min�mass��selfs&r+�activate�GravityWell.activate6s8��&�l�l�n�������"����d�i�i�$�.�/��	r*c� <�V^8�dQhRS[/#)��days_since_activation)�int)�format�
__classdict__s"�r+�__annotate__�GravityWell.__annotate__=s���7�7�3�7r*c�\�RV,p\RVPV,4VnR#)z'Apply time-based decay to gravity well.g�G�z��?皙�����?N)�maxr7)r9r>�decay_factors&& r+�decay�GravityWell.decay=s&���4�4����T�Y�Y��5�6��	r*c�<�V^8�dQh/S[;R&S[;R&S[;R&S[S[,;R&S[;R&S[;R&S[;R&S[;R&#)	r=�conceptr7�pull_radius�related_concepts�first_detectedr4r5�prediction_accuracy)�str�floatrrr?)r@rAs"�r+rBrC#sp�����L���������3�i�=���B���B�� ��!�"�$�#r*)r4r7N)rrrrrr7rLr�listrMrr3rNr4r5rOr:rH�__annotate_func__r)�__classdictcell__�rAs@r+r-r-#sa������D��K�"'��"=�� %�X�\�\�B�N�$�X�\�\�B�N���!$��0�7�7�5�r*r-c�Ja�]tRt^DtoRtRt]!]R7t^t	V3Rlt
 35  RtVtR#)�PatternPreferencezc
 36  A preferred pattern of thinking.
 37  
 38  Different operators gravitate toward different thinking styles.
 39  r.r0c�Z<�V^8�dQh/S[;R&S[;R&S[S[,;R&S[;R&#)r=�pattern_type�strength�contexts�evidence_count)rrQrrPr?)r@rAs"�r+rB�PatternPreference.__annotate__Ds=�����������3�i�5����r*rN)
rrrrrrZrrRr[r\rSr)rTrUs@r+rWrWDs'������H���5�H��N��r*rWc�Fa�]tRt^QtoRtRt]!]R7tV3Rlt	Rt
 40  VtR#)�ResonanceTriggerzg
 41  A specific trigger that makes content resonate.
 42  
 43  These are the micro-patterns that predict resonance.
 44  r.r0c�Z<�V^8�dQh/S[;R&S[;R&S[;R&S[S[,;R&#)r=�trigger_type�descriptionrZ�examples)rPrQr)r@rAs"�r+rB�ResonanceTrigger.__annotate__Qs=��������������3�i�5�r*rN)rrrrrrZrrRrcrSr)rTrUs@r+r_r_Qs"������H���5�H��r*r_c��a�]tRt^^toRt]!]PR7t]!]PR7t	]!]
 45  R7t]!]
 46  R7t]!RR7t
]!]R7t^t^t^t]V3RlRl4tRV3RlRlltV3R	lR
 47  ltR V3RlRlltR!V3R
lRlltR"V3RlRlltR#V3RlRlltV3RlRltV3RlRltV3RlRltV3RlRlt]V3RlRl4t V3Rlt!Rt"Vt#R#)$�CognitiveFingerprintzv
 48  Complete model of an operator's cognitive patterns.
 49  
 50  This is the "theory of self" that enables resonance prediction.
 51  r0c��RRRRRRRR/#)�operational��?�tactical�	strategicrrrr*r+�<lambda>�CognitiveFingerprint.<lambda>ps���t��D��T���	Mr*c� <�V^8�dQhRS[/#�r=�return)rQ)r@rAs"�r+rB�!CognitiveFingerprint.__annotate__�s���A�A�U�Ar*c�b�VP^8XdR#VPVP,#)zOverall prediction accuracy.r.)�total_predictions�correct_predictionsr8s&r+rO�(CognitiveFingerprint.prediction_accuracys,���!�!�Q�&���'�'�$�*@�*@�@�@r*Nc�R<�V^8�dQhRS[RS[RS[S[S[,,RS[/#)r=rK�initial_massrMrp)rPrQrrr-)r@rAs"�r+rBrq�s<���+�+��+��+�#�4��9�-�	+�
 52  
 53  �+r*c�
 54  �WP9d#VPV,P4M%\TTT;'g.R7VPV&\P!4VnVPV,#)z!Add or strengthen a gravity well.)rKr7rM)�
gravity_wellsr:r-rr3�
 55  updated_at)r9rKrwrMs&&&&r+�add_gravity_well�%CognitiveFingerprint.add_gravity_well�sm���(�(�(����w�'�0�0�2�*5��!�!1�!7�!7�R�+�D���w�'�
 56  #�,�,�.����!�!�'�*�*r*c�&<�V^8�dQhRS[RS[/#)r=rKrp�rPrQ)r@rAs"�r+rBrq�s���'�'�s�'�u�'r*c��a�VP4oRpVPP4F�wr4VP4S9gSVP49dW$P,
pKC\;QJd)V3RlVP
 57  4F'gKRM	RM!V3RlVP
 58  44'gK�W$PVP,,
pK�	\RV4#)zm
 59  Get total gravitational pull for a concept.
 60  
 61  Includes direct gravity wells and influence from nearby wells.
 62  �c3�H<"�TFqP4S9x�K	R#5i�N)�lower)�.0�rel�
concept_lowers& �r+�	<genexpr>�?CognitiveFingerprint.get_gravity_for_concept.<locals>.<genexpr>�s����S�=R�c�Y�Y�[�M�1�=R�s�"TF��?)r�ry�itemsr7�anyrMrLr6)r9rK�
total_gravity�	well_name�wellr�s&&   @r+�get_gravity_for_concept�,CognitiveFingerprint.get_gravity_for_concept�s���� �
�
��
��
�#�1�1�7�7�9�O�I���� �M�1�]�i�o�o�FW�5W����*�
���S�T�=R�=R�S����S�T�=R�=R�S�S�S����T�-=�-=�!=�=�
�
 :��3�
�&�&r*c�<<�V^8�dQhRS[RS[RS[S[,/#)r=rY�strength_delta�context)rrQrrP)r@rAs"�r+rBrq�s-���)�)�!�)��)��#��	)r*c��WP9d\VR7VPV&VPV,p\R\RVPV,44VnV;P
 63  ^,
unV'd,W4P9dVPPV4\P!4Vn
 64  R#)z)Update preference for a thinking pattern.)rYr�r�N)�pattern_preferencesrWrFr6rZr\r[�appendrr3rz)r9rYr�r��prefs&&&& r+�update_pattern_preference�.CognitiveFingerprint.update_pattern_preference�s����7�7�7�5F�)�6�D�$�$�\�2��'�'��5���C��S�$�-�-�.�*H�!I�J��
����q� ���w�m�m�3��M�M� � ��)�"�,�,�.��r*c�&<�V^8�dQhRS[RS[/#)r=�altitude�weightr~)r@rAs"�r+rBrq�s���)�)��)��)r*c�8�RpWP9d�VPFspWA8Xd>^V,
 65  VPV,,W2,,VPV&KFVPV;;,^V^,,
 66  ,uu&Ku	\VPP44pV^8�d;VPP4UUu/uFwrgWgV,bK	uppVn\P
 67  !4VnR#uuppi)zj
 68  Update altitude distribution based on observed behavior.
 69  
 70  Uses exponential moving average for stability.
 71  rEN)�altitude_distribution�sum�valuesr�rr3rz)r9r�r��alpha�alt�total�k�vs&&&     r+�update_altitude_distribution�1CognitiveFingerprint.update_altitude_distribution�s������1�1�1��1�1���?��U��d�&@�&@��&E�E���'��.�.�s�3��.�.�s�3��E�A�I�
�F�3�2���2�2�9�9�;�<�E��q�y�-1�-G�-G�-M�-M�-O�.�-O�T�Q�A�5�y�L�-O�.��*�#�,�,�.����	.s�Dc�<<�V^8�dQhRS[RS[RS[S[,/#)r=rarb�example)rPr)r@rAs"�r+rBrq�s-���)�)��)��)��#��	)r*c	���VPF�pVPV8XgK\RVPR,4VnV'd,W4P9dVPPV4\P!4VnR#	VPP\TTRV'dV.M.R74\P!4VnR#)z&Add or strengthen a resonance trigger.r�皙�����?Nr.)rarbrZrc)
 72  �resonance_triggersrar6rZrcr�rr3rzr_)r9rarbr��triggers&&&& r+�add_resonance_trigger�*CognitiveFingerprint.add_resonance_trigger�s����.�.�G��#�#�|�3�#&�s�G�,<�,<�t�,C�#D�� ��w�.>�.>�>��$�$�+�+�G�4�"*�,�,�.����
/�	
���&�&�'7�%�#��")�g�Y�r�	(
 73  �	�#�,�,�.��r*c�6<�V^8�dQhRS[RS[S[,/#)r=�nrp)r?rr-)r@rAs"�r+rBrq�s �����s��D��4E�r*c�z�\VPP44pVPRRR7VRV#)z Get the strongest gravity wells.c��VP#r�)r7)�ws&r+rl�<CognitiveFingerprint.get_top_gravity_wells.<locals>.<lambda>�s����r*T��key�reverseN)rRryr��sort)r9r��wellss&& r+�get_top_gravity_wells�*CognitiveFingerprint.get_top_gravity_wells�s8���T�'�'�.�.�0�1��
�
 74 75  �'��
 76  �6��R�a�y�r*c�0<�V^8�dQhRS[S[,/#ro)rrW)r@rAs"�r+rBrqs�����T�2C�-D�r*c�t�\VPP44pVPRRR7V#)z Get patterns sorted by strength.c��VP#r�)rZ)�ps&r+rl�BCognitiveFingerprint.get_characteristic_patterns.<locals>.<lambda>s��A�J�Jr*Tr�)rRr�r�r�)r9�patternss& r+�get_characteristic_patterns�0CognitiveFingerprint.get_characteristic_patternss1����0�0�7�7�9�:���
�
�.��
�=��r*c� <�V^8�dQhRS[/#ro)rP)r@rAs"�r+rBrqs���@�@�s�@r*c�Va�\SPP4V3RlR7#)z1Get the altitude where operator spends most time.c�*<�SPV,#r�)r�)r�r9s&�r+rl�<CognitiveFingerprint.get_dominant_altitude.<locals>.<lambda>
 77  s����!;�!;�A�!>r*�r�)rFr��keysr8sfr+�get_dominant_altitude�*CognitiveFingerprint.get_dominant_altitudes&����4�-�-�2�2�4�>�@�	@r*c�&<�V^8�dQhRS[RS[/#)r=�	predicted�actual)�bool)r@rAs"�r+rBrqs���)�)�$�)��)r*c��V;P^,
unW8XdV;P^,
un\P!4VnR#)z1Record a prediction result for accuracy tracking.N)rsrtrr3rz)r9r�r�s&&&r+�record_prediction_result�-CognitiveFingerprint.record_prediction_results7�����!�#�����$�$��)�$�"�,�,�.��r*c�6<�V^8�dQhRS[S[S[3,/#ro�rrPr	)r@rAs"�r+rBrqs���%
 78  �%
 79  ��c�3�h��%
 80  r*c�0�RVPRVPP4RVPP4RVPP4UUu/uFPwrVRVPRVPRVPRVPR	VPR
 81  VP/bKR	uppRVPP4UUu/uF6wr4VPRVPR
VPRVP /bK8	uppRVP"RVP$Uu.uF)pRVP&RVP(RVP/NK+	upR
 82  VPRVP*RVP,/
 83  #uuppiuuppiuupi)zSerialize for storage.�operator_id�
 84  created_atrzryrKr7rLrMr5rOr�rZr\r[r�r��typerbrs�training_sessions)r�r��	isoformatrzryr�rKr7rLrMr5rOr��namerZr\r[r�r�rarbrsr�)r9r�r��ptr��ts&     r+�to_dict�CognitiveFingerprint.to_dicts���
�4�+�+��$�/�/�3�3�5��$�/�/�3�3�5�� $�1�1�7�7�9�
 85  � :�G�D���q�y�y��A�F�F�!�1�=�=�&��(:�(:�&��(:�(:�)�1�+@�+@�
�� :�
 86  �
"�"�5�5�;�;�=�
$�>�E�B������
 87 88  �$�a�&6�&6���
 89 90  ���
 91  >�
$�
$�T�%?�%?� ��0�0�
#�1�A�	�A�N�N�!�1�=�=���
 92 93  ��
 94  1�
#�
"�4�#;�#;���!7�!7���!7�!7�E#
 95  �#	
 96  ��
 97  ��$��#s�AF�<F
�0/Fc�:<�V^8�dQhRS[S[S[3,RR/#)r=�datarprfr�)r@rAs"�r+rBrq;s$�����T�#�s�(�^��0F�r*c�p�V!VR,R7p\P!VR,4Vn\P!VR,4VnVP	R/4P4FVwr4\
VR,VR,VR,VR	,VR
 98  ,VP	RR4R
7VPV&KX	VP	R/4P4FCwrV\V,p\VVR,VR,VR,R7VPV&KE	VP	RVP4VnVP	R^4Vn\VP	RR4VP,4VnVP	R^4VnV#)zDeserialize from storage.r��r�r�rzryrKr7rLrMr5rOr.)rKr7rLrMr5rOr�rZr\r[)rYrZr\r[r�rsr�)r�
fromisoformatr�rz�getr�r-ryrrWr�r�rsr?rtr�)�clsr��fpr��w_data�pt_name�p_datar�s&&      r+�	from_dict�CognitiveFingerprint.from_dict:s{���T�-�0�
1�� �.�.�t�L�/A�B��
� �.�.�t�L�/A�B��
� �H�H�_�b�9�?�?�A�L�D�%0��y�)��F�^�"�=�1�!'�(:�!;�!'�(:�!;�$*�J�J�/D�c�$J�
&�B���T�"�B� $�x�x�(=�r�B�H�H�J�O�G��W�%�B�):���
 99  �+�%�&6�7��
100  �+�	*�B�"�"�2�&� K�$(�8�8�,C�R�E]�E]�#^�� �#�x�x�(;�Q�?���!$�T�X�X�.C�S�%I�B�L`�L`�%`�!a���#�x�x�(;�Q�?����	r*c��<�V^8�dQh/S[;R&S[;R&S[;R&S[S[S[3,;R&S[S[S[3,;R&S[S[S[3,;R&S[S[,;R&S[	;R&S[	;R	&S[	;R
101  &#)r=r�r�rzryr�r�r�rsrtr�)
102  rPrrr-rrWrQrr_r?)r@rAs"�r+rBrq^s���������>���>����[�(�)�G���k�+<�<�=�[��$ ��U�
103  �+��%�4�-�.�L�5�:��;�<� �=�>��?r*)r�rz)r.N)r�N)r�r�)�
104  )$rrrrrrrr3r�rz�dictryr�r�rRr�rsrtr��propertyrOr{r�r�r�r�r�r�r�r�r��classmethodr�rSr)rTrUs@r+rfrf^s�����!����>�J� ����>�J�-2�$�,G�M�AF�VZ�@[��/4�E�/��27�t�1L���� ����
�A��A�+�+�$'�'�()�)�*)�)�B)�)�2����@�@�
105  )�)�%
106  �%
107  �N����{�r*rf�__main__z#=== Cognitive Fingerprint Test ===
108  �rickr��markov_blanketsg�������?)rwrM�architecturegffffff�?�survivalg333333�?�compoundingr/)r�rig�������?�pattern_recognitionz0When a familiar pattern appears in a new context�first_principles_clarityz1When something complex is distilled to essentials�contrarian_wisdomz-When conventional wisdom is revealed as wrongrkg�?)r�rg333333�?zTop Gravity Wells:z  z: mass=z.2fz
109  Characteristic Patterns::N�Nz: z
110  Altitude Distribution:c��V^,)#)�r)�xs&r+rlrl�s��q�QR�t�er*r�z.2%z
111  Dominant Altitude: z
112  Gravity Calculations:z  'z': gravity=z
113  Serialization roundtrip: z, z wellsz
114  === Test Complete ===)�free_energy�
115  boundaries�sovereignty�	emergence)�design�systems�	structurer�)�
116  resilience�persistence�will�
determination)�exponential�growth�leverage�duration)r�zdesign patternszsurvival mindsetzquantum physics)8r�dataclassesrrrr�typingrrrr	r
117  r�enumr�mathrr-rWr_rfr�printr�r{r�rr r#r�r�r�r�rKr7r��patternrYr�rZ�sortedr�r�r�r�r��
test_conceptsr��gravityr�r�r��fp2r��lenryrr*r+�<module>rsk���)�(�8�8���$�$�$��7�7��7�@�	�	��	��	6�	6��	6��z�z��z�|�z��	�
118  0�1�
119  �&�	1�B������R���
120  �����G���
121  �����O���
122  �����J���� � ��!=�!=�c� �R�� � ��!=�!=�d� �S�� � ��!7�!7�� �L�����:�����"�;������7���#�#�K��#�<��#�#�O�C�#�@�
123124  ���(�(��+��
��4�<�<�.���	�	�#��7�8�,�
125126  &�'��1�1�3�B�7�7��
��7�'�'�,�,�-�R��0@�0@��/E�F�G�8�
127128  $�%��b�6�6�<�<�>�O�T���V�
��3�%�r�&���&�'�U�
129  �!�"�":�":�"<�!=�
130  >�?�
131132  #�$�^�M� ���,�,�W�5��
��G�9�K���}�5�6�!�
133  �:�:�<�D�
134  �
135  (�
136  (��
137  .�C�	�'����'8��3�s�?P�?P�;Q�:R�RX�
138  Y�Z�	�
139  #�$�]r*