Team Ai
Apppublic

2008robocode-crypto/code-generation-system

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
runtime_simulator.cpython-314.pyc57 linesDownload Raw Back to __pycache__
1+
2A��iw��J�Rt^RIHtHtHtHt^RIt!RR4tRRltR#)z�3Runtime simulator to validate that generated configs can actually execute.4Simulates app initialization and operation to detect execution errors early.5)�Any�Dict�List�OptionalNc�a�]tRt^6toRtV3RlRltV3RlRltRtV3RlRltR	t	R7t8RtRtR
t
V3RlRltRtVtR#)�RuntimeSimulatorz;Simulates execution of generated application configuration.c�6<�V^8�dQhRS[S[S[3,/#)��config�r�strr)�format�
__classdict__s"��CC:\Users\purav\Downloads\ai intern project\src\runtime_simulator.py�__annotate__�RuntimeSimulator.__annotate__
s���!�!�t�C��H�~�!�c�<�Wn.Vn.Vn.VnR#�N)r9�errors�warnings�simulation_log)�selfr10s&&r�__init__�RuntimeSimulator.__init__
s���������
� ��rc� <�V^8�dQhRS[/#�r	�return)�bool)r
rs"�rrrs���%�%��%rc	�t�VPVPVPVPVPVP11.pVFpV!4K
	\VP4^8H# \d?pTPPTPR\T424Rp?KkRp?ii;i)z/Check if config can be executed without errors.z: N)�_check_database_schema�_check_api_endpoints�_check_ui_pages�_check_authentication�_check_business_logic�_simulate_user_flow�	Exceptionr�append�__name__r�len)r�checks�check�es&   r�validate_executability�'RuntimeSimulator.validate_executabilitys���
�'�'��%�%�� � ��&�&��&�&��$�$�
12���E�
B�����4�;�;��1�$�$���
B����"�"�e�n�n�%5�R��A��x�#@�A�A��
B�s�A.�.B7�93B2�2B7c�P�VPPR.4pV'gVPPR4R#VF^pVP	V4'g\RVPR4R24hVPPRVR,R24K`	R#)	z!Simulate database initialization.�database_schemazNo database schema definedNzCannot create table '�name�'u✓ Database table 'z
' initialized)r13�getrr'�_can_create_table�14ValueErrorr)r�	db_schema�tables&  rr �'RuntimeSimulator._check_database_schema&s����K�K�O�O�$5�r�:�	���M�M� � �!=�>���E��)�)�%�0�0� �#8����6�9J�8K�1�!M�N�N����&�&�)=�e�F�m�_�M�'Z�[�rc�<<�V^8�dQhRS[S[S[3,RS[/#)r	r7r)rrrr)r
rs"�rrr5s#�����t�C��H�~��$�rc�a�.R	Op\;QJdV3RlV4F'dKRM	RM!V3RlV44'gR#\SR,\4'gR#SR,pSR,Uu.uF,p\V\4'dVP	R4MTNK.	ppW59d\RVR24hR#uupi)15z Check if a table can be created.r1�fields�primary_keyc3�,<"�TF	qS9x�K	R#5ir�)�.0�kr7s& �r�	<genexpr>�5RuntimeSimulator._can_create_table.<locals>.<genexpr>8s����0�x�!��:�x�s�FTz
Primary key 'z' not found in fields)r1r;r<)�all�16isinstance�list�dictr3r5)rr7�requiredr<�f�field_namess&f    rr4�"RuntimeSimulator._can_create_table5s����4���s�0�x�0�s�s�s�0�x�0�0�0���%��/�4�0�0���M�*��LQ�RZ�O�\�O�q�17�1�d�(;�(;�q�u�u�V�}��B�O��\��)��}�[�M�9N�O�P�P���]s�;2Cc���VPPR.4pV'gVPPR4R#.ROpVF�p\	V\184'g\
R4hRV9gRV9d\
RV24hVR,V9d\
RVR,24hVPPR	VR,R19VR,R24K�	R#)
zSimulate API initialization.�20api_schemazNo API endpoints definedNzAPI endpoint is not a dict�path�methodz%API endpoint missing path or method: zInvalid HTTP method: u✓ API endpoint '� z' registered)�GET�POST�PUT�DELETE�PATCH)r21r3rr'rDrFr5r)rrL�
valid_methods�endpoints&   rr!�%RuntimeSimulator._check_api_endpointsFs����[�[�_�_�\�2�6�22���M�M� � �!;�<��A�
�"�H��h��-�-� �!=�>�>��X�%���)A� �#H��23�!S�T�T���!��6� �#8��(�9K�8L�!M�N�N����&�&�);�H�X�<N�;O�q�QY�Z`�Qa�Pb�bn�'o�p�#rc���VPPR.4pV'gVPPR4R#VF�p\	V\244'g\
R4hRV9gRV9d\
RV24hRV9g\	VR,\4'g\
R	VR,R2524hVPPRVR,RVR,R
24K�	R#)zSimulate UI initialization.�	ui_schemazNo UI pages definedNzUI page is not a dictrM�titlezUI page missing path or title: �26componentsz	UI page 'z' has no componentsu
✓ UI page 'z' (z) registered)	r27r3rr'rDrFr5rEr)rrY�pages&  rr"� RuntimeSimulator._check_ui_pages\s����K�K�O�O�K��4�	���M�M� � �!6�7���D��d�D�)�)� �!8�9�9��T�!�W�D�%8� �#B�4�&�!I�J�J��4�'�z�$�|�:L�d�/S�/S� �9�T�&�\�N�:M�!N�O�O����&�&��t�F�|�n�C��W�
��Vb�'c�d�rc��VPPR/4pVPPR.4pV'gVPPR4R#RV9d\	R4hV'g\	R4h\4pVFFp\
V\4'dRV9d\	R	V24hVPVR,4KH	VPPR28\V4R24R#)z.Simulate authentication system initialization.�auth_config�roleszNo auth config definedN�typezAuth config missing 'type'z"No roles defined for authorizationr1zInvalid role definition: u+✓ Authentication system initialized with z roles)r29r3rr'r5�setrDrF�addrr))rr_r`�30role_names�roles&    rr#�&RuntimeSimulator._check_authenticationps����k�k�o�o�m�R�8���������,����M�M� � �!9�:����$��9�:�:���A�B�B��U�31��D��d�D�)�)�V�4�-?� �#<�T�F�!C�D�D��N�N�4��<�(��32	
���"�"�%P�QT�UZ�Q[�P\�\b�#c�drc�:�VPPR/4p\V\4'diVP	4F*wr#VeKVP33P
RVR24K,	VPP
R\V4R24R#R#)z$Validate business logic consistency.�business_logicNzBusiness logic 'z	' is Noneu✓ Business logic validated (z rules))	r34r3rDrF�itemsrr'rr))rrh�key�values&   rr$�&RuntimeSimulator._check_business_logic�s��������)9�2�>���n�d�+�+�,�2�2�4�35���=��M�M�(�(�+;�C�5�	�)J�K�5�
���&�&�)G��N�H[�G\�\c�'d�e�,rc�P�VPPR.4p\RV4R4pV'gVPP	R4\RV4R4pV'dVP36P	R4R#VPP	R4R#)zSimulate a typical user flow.rYc3�t"�TF.pRVPRR4P49gK*Vx�K0	R#5i)�loginrM�N�r3�lower�r?�ps& rrA�7RuntimeSimulator._simulate_user_flow.<locals>.<genexpr>�s-���W�h��'�Q�U�U�6�2�=N�=T�=T�=V�2V�1�1�h���'8�378NzNo login page foundc3�t"�TF.pRVPRR4P49gK*Vx�K0	R#5i)�	dashboardrMrpNrqrss& rrAru�s-���Z�X������f�b�@Q�@W�@W�@Y�1Y�!�!�X�rvu,✓ User flow validated: Login → Dashboardz$No dashboard page found in user flow)r38r3�nextrr'r)r�ui_pages�39login_pagerxs&   rr%�$RuntimeSimulator._simulate_user_flow�s���40�;�;�?�?�;��3���W�h�W�Y]�^�41���M�M� � �!6�7��Z�X�Z�\`�a�	�����&�&�'U�V��M�M� � �!G�Hrc�6<�V^8�dQhRS[S[S[3,/#rr)r
rs"�rrr�s���42�43�D��c��N�44rc
��R\VP4^8HRVPRVPRVPR\VP4\VP4,\VP4,/#)zGenerate execution report.�
is_executablerrr�total_checks)r)rrr)rs&r�45get_report�RuntimeSimulator.get_report�sj��
�S����-��2��d�k�k���
�
��d�1�1��C�� 3� 3�4�s�4�;�;�7G�G�#�d�m�m�J\�\�46�	47r)r48rrrN)r(�49__module__�__qualname__�__firstlineno__�__doc__rr-r r4r!r"r#r$r%r��__static_attributes__�__classdictcell__)rs@rrr50sT����E�!�!�%�%�&
\���"q�,e�(e�.	f�I�&51�52rrc��V^8�dQhR\\\3,R\\\\\3,3,/#)r	r53r)rrr�tupler)r
s"rrr�s5��1�1�t�C��H�~�1�%��d�3�PS�8�n�@T�:U�1rc�Z�\V4pVP4pW!P43#)z$Quick check if config is executable.)rr-r�)r54�	simulatorrs&  r�validate_config_executabler��s,�� ��(�I��4�4�6�M��.�.�0�0�0r)	r��typingrrrr�jsonrr�r>rr�<module>r�s'���55-�,��c56�c57�L1r