correctover

1.0.1 Not latest — view latest

Correctover — Failure is not fatal. Protocol-level contract validation with automatic verified failover for LLM APIs.

Published
June 24, 2026
9d ago
Package Registry
README badge Customize →
License Sources
SourceLicenseClass
Licensie (detected)
Pending-
PyPI (reported)
Apache-2.0 WITH commercial-restrictionUnknown

License detection is still in progress for this version.

Loading dependencies…
License File
�

��;j`8�
���%SrSSKrSSKrSSKrSSKrSSKrSSKrSSKJrJ	r	 SSK
J
r
Jr SSKJ
r
JrJrJrJr "SS5r\R&\R&\R&\R&\R&\R(\R(\R(\R(S.	r1S	krS
rSr\"SS
55r"SS5rSq\\\S'S\4Sjr\R&S4S\S\S\4Sjjrg)a�
Correctover License & Protection System.

In-software protection: even if source code is visible,
core features require a valid license to operate.

Protection layers:
1. License Key verification (basic features free, advanced requires key)
2. Feature gating (predictive/learner/load_balancer = Pro only)
3. Watermarking (trace leaked licenses)
4. Remote attestation (periodic license validation)
5. Integrity checks (detect tampering)
6. Trial mode (30-day full feature trial)
�N)�	dataclass�field)�datetime�	timedelta)�Any�Dict�List�Optional�Callablec� �\rSrSrSrSrSrSrg)�FeatureTier��free�pro�
enterprise�N)�__name__�
__module__�__qualname__�__firstlineno__�FREE�PRO�
ENTERPRISE�__static_attributes__r�� build/lib/correctover/license.pyr
r
s���D�
�C��Jrr
)	�predictive_engine�flywheel_learner�
load_balancer�advanced_diagnostics�contract_validation�remote_attestation�custom_strategies�sso_integration�
sla_guarantee>�
health_status�jitter_backoff�model_fallback�basic_self_heal�error_diagnosis�basic_observability�i�c���\rSrSr%Sr\\S'\Rr	\\S'Sr
\\S'Sr\\S'Sr\
\S	'Sr\
\S
'Sr\\S'\"\S9r\\\S
'Sr\\S'Sr\\S'\S\4Sj5r\S\4Sj5rSrg)�LicenseInfo�@zLicense information.�license_key�tier��email�organization��	issued_at�
expires_at�
machine_id)�default_factory�features�	watermarkF�is_trial�returnc�h�URS:Xag[R"5UR:�$)NrF)r7�time��selfs r�
is_expired�LicenseInfo.is_expiredNs&���?�?�a����y�y�{�T�_�_�,�,rc�P�UR(+=(a URS:g$)Nr2)rBr0r@s r�is_valid�LicenseInfo.is_validTs���?�?�"�=�t�'7�'7�2�'=�=rrN)rrrr�__doc__�str�__annotations__r
rr1r3r4r6�floatr7r8r�listr:r	r;r<�bool�propertyrBrErrrrr.r.@s������� � �D�#� ��E�3�O��L�#���I�u���J����J�����5�H�d�3�i�5��I�s���H�d��
�-�D�-��-�
�>�$�>��>rr.c�h�\rSrSrSrSrSrS\4SjrS\S\	4Sjr
S\S\4S	jrS\S\4S
jr
S\S\4SjrS\SS
4SjrS\4SjrS\\\4S\\\44SjrSSjrSSjrS\4SjrS\4SjrS\4SjrS\\\44Sjr\S\\	4Sj5r\S\4Sj5r\S\4Sj5rSr Sr!g
)�LicenseManager�YaY
Manages license verification, feature gating, and protection.

Usage:
    from correctover import Correctover
    
    # Free tier (no key needed)
    nb = Correctover(api_key="sk-xxx")
    
    # Pro tier (license key unlocks advanced features)
    nb = Correctover(
        api_key="sk-xxx",
        license_key="NB-PRO-xxxx-xxxx-xxxx"
    )
z&https://api.correctover.dev/v1/licensec���SUlUR5UlSUlSUlSUl0UlSUlSUl[RRS5UlUR5 g)Nr5�Qrz~/.neuralbridge_trial_calls)�_license�_generate_machine_id�_machine_id�_first_run_time�_last_attestation�_attestation_interval�_feature_cache�_integrity_hash�_trial_call_count�os�path�
expanduser�_trial_call_file�_load_trial_call_countr@s r�__init__�LicenseManager.__init__msn��/3��
� $� 9� 9� ;���04���(+���*/��"�/1���.2���&'���%'�W�W�%7�%7�8U�%V����#�#�%rr=c�h�[R[[R"5=(d S5[[	[S5(a[R
"SS5OS5/nSR
U5n[R"UR55R5SS$)z&Generate a unique machine fingerprint.r�pathconf�/�PC_PATH_MAX�|N�)r\�namerH�	cpu_count�hasattrrd�join�hashlib�sha256�encode�	hexdigest)rA�
components�raws   rrT�#LicenseManager._generate_machine_idys|��
�G�G������#�!�$��7�2�z�3J�3J����C��/�PQ�R�
�
�
�h�h�z�"���~�~�c�j�j�l�+�5�5�7���<�<rr0c
��UR5R5nURS5n[U5S:d	USS:wa[	SU35eUSR5nU[R[R4;a[	SU35eURU5(d[	S5eURU5n[[5n[R5HiupgU[R:XaURU5 M,U[R:XdMBU[R:XdMXURU5 Mk [!UUUR"[$R$"5[$R$"5S	-UUS
9UlUR(R+5 UR&$)z�
Activate a license key.

Args:
    license_key: Format "NB-{TIER}-{XXXX}-{XXXX}-{XXXX}"
    
Returns:
    LicenseInfo with activation details
�-�r�NBzInvalid license key format: �zInvalid tier in license key: zLicense key verification failedi�3�)r0r1r8r6r7r:r;)�strip�upper�split�len�
ValueError�lowerr
rr�_verify_checksum�_generate_watermarkrK�
FREE_FEATURES�GATED_FEATURES�items�appendr.rUr?rSrY�clear)rAr0�partsr1r;r:�feat�
required_tiers        r�activate�LicenseManager.activate�sx��"�'�'�)�/�/�1���!�!�#�&���u�:��>�U�1�X��-��;�K�=�I�J�J��Q�x�~�~��������)?�)?�@�@��<�T�F�C�D�D��$�$�[�1�1��>�?�?��,�,�[�9�	��
�&��#1�#7�#7�#9��D��{�-�-�-�����%�����(�]�k�o�o�-M�����%�	$:�$�#���'�'��i�i�k��y�y�{�[�0���
��
�	
���!�!�#��}�}�rc��URS5n[U5S:agUSnSRUSS5nUSnSn[R"UUU3R55R
5SS	R5nXW:H$)
z�
Verify license key integrity using embedded checksum.

Key format: NB-TIER-DATA-CHECKSUM
Where CHECKSUM = sha256(TIER+DATA+SECRET_SALT)[:8]
ru�Frx�������nB_s3lfH3al_2026N�)r{r|rlrmrnrorprz)rAr0r�r1�data�provided_checksum�salt�expecteds        rr�LicenseManager._verify_checksum�s����!�!�#�&���u�:��>���Q�x���x�x��a���$��!�"�I��"���>�>�T�F�4�&���"7�">�">�"@�A�K�K�M�b�q�Q�W�W�Y�� �,�,rc��USURS[R"53n[R"UR	55R5SS$)z'Generate unique watermark for tracking.�:N�)rUr?rmrnrorp)rAr0rrs   rr��"LicenseManager._generate_watermark�sJ���
�Q�t�/�/�0��$�)�)�+��?���~�~�c�j�j�l�+�5�5�7���<�<r�featurec�2�XR;aURU$U[;aSURU'gURbURR(dSURU'gXRR;nX RU'U$)z�
Check if a feature is available under current license.

Args:
    feature: Feature name
    
Returns:
    True if feature is available
TF)rYr�rSrEr:)rAr��	availables   r�
check_feature�LicenseManager.check_feature�s����)�)�)��&�&�w�/�/��m�#�+/�D����(���=�=� ��
�
�(>�(>�+0�D����(���}�}�5�5�5�	�'0���G�$��rNc��URU5(dD[RU[R5n[SUSUR
5S35eg)ze
Require a feature, raise if not available.

Used by gated features to enforce license requirements.
z	Feature 'z' requires z4 license. Upgrade at https://correctover.dev/pricingN)r�r��getr
r�PermissionErrorrz)rAr�r�s   r�require_feature�LicenseManager.require_feature�s_���!�!�'�*�*�*�.�.�w����H�M�!��G�9�K�
�0C�0C�0E�/F�G=�>��
�+rc�R�UR(aURR$g)z*Get current watermark for output tracking.z	free-tier)rSr;r@s r�
get_watermark�LicenseManager.get_watermark�s���=�=��=�=�*�*�*�rr�c���UR(aL[R"URRR	55R5SSUS'U$)zZ
Embed watermark into output data for leak tracking.

Invisible to user, traceable by us.
Nr��_nb_meta)rS�base64�	b64encoder;ro�decode)rAr�s  r�embed_watermark�LicenseManager.embed_watermarksM���=�=�%�/�/��
�
�'�'�.�.�0� ��f�h�r�� �D����rc�V�[RRUR5(aL[	URS5n[UR
5R55UlSSS5 gg!,(df   g=f![[4a
 SUlgf=f)z;Load trial call count from disk (persists across restarts).�rNr)r\r]�existsr_�open�int�readryr[r}�IOError�rA�fs  rr`�%LicenseManager._load_trial_call_count
s{��	'��w�w�~�~�d�3�3�4�4��$�/�/��5��-0�������1A�-B�D�*�6�5�5�5�5���G�$�	'�%&�D�"�	'�s0�AB�-A=�3B�=
B�B�B�B(�'B(c���[URS5nUR[UR55 SSS5 g!,(df   g=f![
a gf=f)z!Persist trial call count to disk.�wN)r�r_�writerHr[r�r�s  r�_save_trial_call_count�%LicenseManager._save_trial_call_countsM��	��d�+�+�S�1�Q�����D�2�2�3�4�2�1�1���	��	�s-�A�%A�A�
A�A�A�
A$�#A$c��UR(agU=RS-
slUR5 UR[:*$)z�
Increment trial call counter. Returns True if under limit, False if exceeded.

Called by engine on every API call when in trial/free mode.
Trx)�is_licensedr[r��TRIAL_MAX_CALLSr@s r�increment_trial_call�#LicenseManager.increment_trial_calls>���������!�#���#�#�%��%�%��8�8rc��UR$)zGet current trial call count.)r[r@s r�get_trial_call_count�#LicenseManager.get_trial_call_count+s���%�%�%rc���SSKJn SSKJn [UR5Vs/sHo3RS5(aMUPM nn[
U5S:aggs snf![[4a gf=f)z~
Verify core module integrity at runtime.

Detects if critical files have been modified.
Returns False if tampering detected.
rx)�engine)�
predictive�_�
FT)	r2r�r��dir�FlywheelEngine�
startswithr|�ImportError�AssertionError)rAr�r��m�
fe_methodss     r�verify_integrity�LicenseManager.verify_integrity/sk��	� �$�&)��)>�)>�%?�Y�%?��|�|�TW�GX�!�%?�J�Y��:���#����	Z��
�^�,�	��	�s(�#A �A�A�A �A � A3�2A3c	�z�URbSURRS.$[RR	S5n[RRU5(aB[
US5n[UR5R55Ul
SSS5 OS[R"5Ul
[
US5nUR[UR55 SSS5 [R"5UR-
S-n[S[U-
5n[S[ UR"-
5nUS:�a US:�aS	[%US
5USSUS
SUS3S.$US::aSOSnSU[%US
5USSUS3S.$!,(df   N�=f!,(df   N�=f)z�
Get trial status for free users.

Returns remaining days, remaining calls, and available features.
Trial grants access to PRO features for 30 days or 1000 calls, whichever comes first.
After trial expires, only FREE tier features remain.
N�licensed)�statusr1z~/.neuralbridge_trialr�r�rRr�trialrx�allzTrial: z.1fz days / z< calls remaining. Upgrade at https://correctover.dev/pricing)r��remaining_days�remaining_callsr:�message�expired�calls_exhausted�	free_onlyzTrial expired (zV). Advanced features require a PRO/ENTERPRISE license. https://correctover.dev/pricing)r��reasonr�r�r:r�)rSr1r\r]r^r�r�rJr�ryrVr?r�rH�max�
TRIAL_DAYSr�r[�round)rA�
trial_filer��elapsed_daysr�r�r�s       r�get_trial_status�LicenseManager.get_trial_statusJs����=�=�$�(�$�-�-�2D�2D�E�E��W�W�'�'�(?�@�
�
�7�7�>�>�*�%�%��j�#�&�!�',�Q�V�V�X�^�^�-=�'>��$�'�&�$(�9�9�;�D� ��j�#�&�!�����D�0�0�1�2�'��	�	��d�&:�&:�:�e�C���Q�
�\� 9�:���a��4�3I�3I�!I�J���A��/�A�"5�!�"'���":�#2�!�$�^�C�$8���@Q�RN�O��
�#1�A�"5�Y�;L�F�#� �"'���":�#2�'�,�V�H�5K�L�
�
�-'�&��'�&�s�6-F�%F,�
F)�,
F:c��UR$)zGet current license info.)rSr@s r�license_info�LicenseManager.license_infows���}�}�rc�X�URSL=(a URR$)z#Check if a valid license is active.N)rSrEr@s rr��LicenseManager.is_licensed|s"���}�}�D�(�C�T�]�]�-C�-C�Crc�p�UR(aURR$[R$)zGet current tier.)rSr1r
rr@s rr1�LicenseManager.tier�s'���=�=��=�=�%�%�%����rc�F�SUlURR5 g)z"Reset license state (for testing).N)rSrYr�r@s r�reset�LicenseManager.reset�s����
����!�!�#r)	rXrYrVrZrWrSrUr[r_)r=N)"rrrrrG�LICENSE_SERVERrarHrTr.r�rLrr�r�r�r�rrr�r`r�r�r�r�r�r�rMr
r�r�r1r�rrrrrOrOYsO���">�N�
&�=�c�=�1�C�1�K�1�f-�C�-�D�-�*=�s�=�s�=�
�S��T��:�s��t���s���D��c��N��t�C��H�~��'��9�d�9�&�c�&��$��6+�$�s�C�x�.�+�Z��h�{�3�����D�T�D��D�� �c� �� �$rrO�_license_managerr=c�0�[c
[5q[$)z(Get the global license manager instance.)r�rOrrr�get_license_managerr��s����)�+���rr2r1r�c�8�SnU(d0[R"5RSSR5n[R
"UUU3R
55R5SSR5nSUR5SUSU3$)zr
Generate a license key (for internal use by Correctover team only).

DO NOT distribute this function in the SDK.
r�Nr�zNB-ru)�uuid�uuid4�hexrzrmrnrorp)r1r�r��checksums    r�generate_license_keyr��s����D���z�z�|�����#�)�)�+���~�~���t�f�T�F�3�:�:�<�=�G�G�I�"�1�M�S�S�U�H�
������a��v�Q�x�j�1�1r) rGrm�jsonr\r?r�r��dataclassesrrrr�typingrrr	r
rr
rrr�r�r�r�r.rOr�rIr�rHr�rrr�<module>r�s��
���	���
�(�(�6�6���%���#��� �_�_�'�O�O�&�?�?�%�0�0�$�/�/�"�-�-� �+�+�
���
��
����>�>��>�0r$�r$�l	.2��(�>�*�1��^��&1�_�_�"�
2�s�
2�C�
2��
2r
Versions
8 versions
VersionLicensePublishedStatus
1.3.1 Latest -Jun 29, 2026 Pending
1.3.0 Proprietary Commercial License (Unverified)Jun 29, 2026 Pending
1.2.0 Proprietary Commercial License (Unverified)Jun 29, 2026 Pending
1.1.0 Proprietary Commercial License (Unverified)Jun 25, 2026 Pending
1.0.2 Proprietary Commercial License (Unverified)Jun 25, 2026 Pending
1.0.1 ViewingApache-2.0 WITH commercial-restriction (Unverified)Jun 24, 2026 Pending
1.0.0 Apache-2.0 WITH commercial-restriction (Unverified)Jun 24, 2026 Pending
0.1.0 Apache-2.0 WITH commercial-restriction (Unverified)Jun 24, 2026 Pending