lexgrid 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lexgrid-1.0.0/PKG-INFO +171 -0
- lexgrid-1.0.0/README.md +141 -0
- lexgrid-1.0.0/lexgrid/__init__.py +38 -0
- lexgrid-1.0.0/lexgrid/client.py +872 -0
- lexgrid-1.0.0/lexgrid/exceptions.py +56 -0
- lexgrid-1.0.0/lexgrid/models.py +121 -0
- lexgrid-1.0.0/lexgrid.egg-info/PKG-INFO +171 -0
- lexgrid-1.0.0/lexgrid.egg-info/SOURCES.txt +12 -0
- lexgrid-1.0.0/lexgrid.egg-info/dependency_links.txt +1 -0
- lexgrid-1.0.0/lexgrid.egg-info/requires.txt +4 -0
- lexgrid-1.0.0/lexgrid.egg-info/top_level.txt +1 -0
- lexgrid-1.0.0/pyproject.toml +56 -0
- lexgrid-1.0.0/setup.cfg +4 -0
- lexgrid-1.0.0/tests/test_client.py +166 -0
lexgrid-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lexgrid
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for NovaPixel LexGrid — Sovereign EU Compliance, Regulatory Auditing & Statutory Verification Engine
|
|
5
|
+
Author-email: NovaPixel <lexgrid@novapixel.it>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://lexgrid.novapixel.it
|
|
8
|
+
Project-URL: Documentation, https://lexgrid.novapixel.it/openapi.json
|
|
9
|
+
Project-URL: Compliance & DPO, https://lexgrid.novapixel.it/compliance-policy
|
|
10
|
+
Project-URL: Verification Registry, https://lexgrid.novapixel.it/verify/LG-2026-B81C-9E4F-2A7D
|
|
11
|
+
Keywords: compliance,mcp,ai-agents,vies,anac,altman-z-score,appalti,csrd,gdpr,sovereign-ai,langchain,crewai
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: Intended Audience :: Legal Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Requires-Dist: httpx>=0.25.0; extra == "dev"
|
|
30
|
+
|
|
31
|
+
# LexGrid Python SDK 🏛️⚡
|
|
32
|
+
|
|
33
|
+
> **Official Python Client for NovaPixel LexGrid — Sovereign EU Compliance, Regulatory Auditing & Statutory Verification Engine.**
|
|
34
|
+
|
|
35
|
+
Zero external dependencies (`urllib`-native). Thread-safe. Conforming to **Strict Zero-Data-Retention (ZDR)** and returning verifiable cryptographic **Audit Certificates** (`_audit_meta`) with every execution.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 📦 Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install lexgrid
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
*(Or copy the `lexgrid` directory directly into your project — zero 3rd party runtime dependencies required)*
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🚀 Quickstart
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from lexgrid import LexGridClient, AccountingImbalanceError
|
|
53
|
+
|
|
54
|
+
# 1. Initialize client with your API Key
|
|
55
|
+
client = LexGridClient(api_key="your-api-key")
|
|
56
|
+
|
|
57
|
+
# 2. Check European VAT on VIES with Local Shadow Mirror resilience
|
|
58
|
+
vies = client.eu_tax.verify_vies("IT01234567890", company_name="NovaPixel S.r.l.")
|
|
59
|
+
print("Valid:", vies.data["is_valid"])
|
|
60
|
+
print("Official Certificate ID:", vies.certificate_id)
|
|
61
|
+
print("Verification Link:", vies.verification_url)
|
|
62
|
+
|
|
63
|
+
# 3. Calculate Public Procurement Anomaly Threshold ex D.Lgs. 36/2023 Art. 110
|
|
64
|
+
tender = client.gov_appalti.calculate_anomaly(
|
|
65
|
+
bids=[12.5, 14.2, 10.8, 15.0, 13.9, 11.4],
|
|
66
|
+
method="METODO_A",
|
|
67
|
+
tender_base_price=250000.0,
|
|
68
|
+
)
|
|
69
|
+
print("Exclusion Threshold:", tender.data["anomaly_threshold"])
|
|
70
|
+
print("Normative Reference:", tender.audit_meta.normative_ref)
|
|
71
|
+
|
|
72
|
+
# 4. Altman Z-Score with Pre-Flight Balance Sheet Sanity Guard
|
|
73
|
+
try:
|
|
74
|
+
default_risk = client.fin_esg.predict_default(
|
|
75
|
+
total_assets=1000000.0,
|
|
76
|
+
total_liabilities=600000.0,
|
|
77
|
+
equity=400000.0, # Assets == Liabilities + Equity (Exact balance)
|
|
78
|
+
retained_earnings=150000.0,
|
|
79
|
+
ebit=95000.0,
|
|
80
|
+
revenue=1200000.0,
|
|
81
|
+
)
|
|
82
|
+
print("Z-Score:", default_risk.data["z_score"])
|
|
83
|
+
print("Risk Level:", default_risk.data["risk_band"])
|
|
84
|
+
except AccountingImbalanceError as e:
|
|
85
|
+
# Catches GIGO (Garbage In, Garbage Out) and OCR hallucinations before calculation
|
|
86
|
+
print(f"Audit Blocked: {e.message}")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 🔍 Verifying Statutory Audit Certificates
|
|
92
|
+
|
|
93
|
+
Every response from LexGrid is accompanied by a cryptographic certificate (`_audit_meta`):
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Verify certificate in the statutory registry
|
|
97
|
+
cert = client.get_certificate("LG-2026-B81C-9E4F-2A7D")
|
|
98
|
+
print("Status:", cert.status) # "VALID_OFFICIALLY_ISSUED"
|
|
99
|
+
print("Deterministic Hash:", cert.deterministic_hash)
|
|
100
|
+
print("Digital Seal:", cert.digital_seal)
|
|
101
|
+
|
|
102
|
+
# Download printable HTML Dossier for court or administrative record inclusion
|
|
103
|
+
html_dossier = client.download_dossier_html("LG-2026-B81C-9E4F-2A7D")
|
|
104
|
+
with open("dossier_rup.html", "w", encoding="utf-8") as f:
|
|
105
|
+
f.write(html_dossier)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 🏛️ All 20 Specialized Suites & Shorthand Properties
|
|
111
|
+
|
|
112
|
+
Access any of the 20 vertical domains directly via property names, ergonomic shorthand aliases, or dynamic runner:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# Shorthand aliases or canonical properties:
|
|
116
|
+
client.tax # or client.eu_tax (EU Tax, KYB, VIES & e-Invoicing)
|
|
117
|
+
client.fin # or client.fin_esg (Financial Forensics & CSRD VSME)
|
|
118
|
+
client.sec # or client.net_sec (NetSec, Deliverability & RDAP)
|
|
119
|
+
client.gdpr # or client.web_gdpr (Web GDPR, Cookie CMP & AI Act)
|
|
120
|
+
client.appalti # or client.gov_appalti (ANAC Public Procurement D.Lgs 36/2023)
|
|
121
|
+
client.dora # or client.dora_nis2 (DORA Banking/ICT & NIS2)
|
|
122
|
+
client.dogane # or client.customs_cbam (Customs CBAM, TARIC & Dual-Use)
|
|
123
|
+
client.lavoro # or client.hr_labour (HR Labour Law & IRPEF Simulator)
|
|
124
|
+
client.materials # or client.materials_dpp (Materials DPP & CPR)
|
|
125
|
+
client.energy # or client.energy_epbd (Energy Decarbonization & Case Green EPBD)
|
|
126
|
+
client.pii # or client.sovereign_pii (Sovereign PII Scrubber & AI Act)
|
|
127
|
+
client.xbrl # or client.xbrl_fin (XBRL ESEF & EU Taxonomy)
|
|
128
|
+
client.peppol # or client.einvoice_vida (Universal Peppol BIS 3.0 & ViDA)
|
|
129
|
+
client.grants # or client.grants_funding (EU Grants & Transizione 5.0)
|
|
130
|
+
client.carbon # or client.carbon_factors (Scope 1-2-3 GHG & CSRD)
|
|
131
|
+
client.ted # or client.ted_procurement (TED eForms & CPV Classifier)
|
|
132
|
+
client.reach # or client.chemicals_reach (REACH SVHC & RoHS 3)
|
|
133
|
+
client.aml # or client.aml_compliance (EU AMLA & 6AMLD)
|
|
134
|
+
client.eudr # or client.agri_food_eudr (EUDR Deforestation & FIC Allergens)
|
|
135
|
+
client.mdr # or client.pharma_medical_mdr (EU MDR, IVDR & FMD Serialization)
|
|
136
|
+
|
|
137
|
+
# Or dynamic execution for any tool across all 90 endpoints:
|
|
138
|
+
res = client.suite("dora").call("incident_severity_triage", {
|
|
139
|
+
"incidentType": "system_downtime",
|
|
140
|
+
"affectedUsers": 50000,
|
|
141
|
+
"durationHours": 4.5,
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🤖 AI Agent Framework Integrations (LangChain & CrewAI)
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from langchain.tools import tool
|
|
151
|
+
from lexgrid import LexGridClient
|
|
152
|
+
|
|
153
|
+
client = LexGridClient(api_key="your-api-key")
|
|
154
|
+
|
|
155
|
+
@tool
|
|
156
|
+
def verify_eu_vat(vat_number: str) -> str:
|
|
157
|
+
"""Verifies European VAT on official VIES registry with sanctions screening."""
|
|
158
|
+
res = client.eu_tax.verify_vies(vat_number)
|
|
159
|
+
return (
|
|
160
|
+
f"Valid: {res.data['is_valid']}. "
|
|
161
|
+
f"Certificate: {res.certificate_id} ({res.verification_url})"
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 🛡️ License & Compliance
|
|
168
|
+
|
|
169
|
+
- **License:** MIT License
|
|
170
|
+
- **Zero-Data-Retention:** Strictly stateless in-memory execution in volatile RAM ($< 50\text{ ms}$). No customer payloads saved to disk.
|
|
171
|
+
- **DPO Policy:** [https://lexgrid.novapixel.it/compliance-policy](https://lexgrid.novapixel.it/compliance-policy)
|
lexgrid-1.0.0/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# LexGrid Python SDK 🏛️⚡
|
|
2
|
+
|
|
3
|
+
> **Official Python Client for NovaPixel LexGrid — Sovereign EU Compliance, Regulatory Auditing & Statutory Verification Engine.**
|
|
4
|
+
|
|
5
|
+
Zero external dependencies (`urllib`-native). Thread-safe. Conforming to **Strict Zero-Data-Retention (ZDR)** and returning verifiable cryptographic **Audit Certificates** (`_audit_meta`) with every execution.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 📦 Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install lexgrid
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
*(Or copy the `lexgrid` directory directly into your project — zero 3rd party runtime dependencies required)*
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🚀 Quickstart
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from lexgrid import LexGridClient, AccountingImbalanceError
|
|
23
|
+
|
|
24
|
+
# 1. Initialize client with your API Key
|
|
25
|
+
client = LexGridClient(api_key="your-api-key")
|
|
26
|
+
|
|
27
|
+
# 2. Check European VAT on VIES with Local Shadow Mirror resilience
|
|
28
|
+
vies = client.eu_tax.verify_vies("IT01234567890", company_name="NovaPixel S.r.l.")
|
|
29
|
+
print("Valid:", vies.data["is_valid"])
|
|
30
|
+
print("Official Certificate ID:", vies.certificate_id)
|
|
31
|
+
print("Verification Link:", vies.verification_url)
|
|
32
|
+
|
|
33
|
+
# 3. Calculate Public Procurement Anomaly Threshold ex D.Lgs. 36/2023 Art. 110
|
|
34
|
+
tender = client.gov_appalti.calculate_anomaly(
|
|
35
|
+
bids=[12.5, 14.2, 10.8, 15.0, 13.9, 11.4],
|
|
36
|
+
method="METODO_A",
|
|
37
|
+
tender_base_price=250000.0,
|
|
38
|
+
)
|
|
39
|
+
print("Exclusion Threshold:", tender.data["anomaly_threshold"])
|
|
40
|
+
print("Normative Reference:", tender.audit_meta.normative_ref)
|
|
41
|
+
|
|
42
|
+
# 4. Altman Z-Score with Pre-Flight Balance Sheet Sanity Guard
|
|
43
|
+
try:
|
|
44
|
+
default_risk = client.fin_esg.predict_default(
|
|
45
|
+
total_assets=1000000.0,
|
|
46
|
+
total_liabilities=600000.0,
|
|
47
|
+
equity=400000.0, # Assets == Liabilities + Equity (Exact balance)
|
|
48
|
+
retained_earnings=150000.0,
|
|
49
|
+
ebit=95000.0,
|
|
50
|
+
revenue=1200000.0,
|
|
51
|
+
)
|
|
52
|
+
print("Z-Score:", default_risk.data["z_score"])
|
|
53
|
+
print("Risk Level:", default_risk.data["risk_band"])
|
|
54
|
+
except AccountingImbalanceError as e:
|
|
55
|
+
# Catches GIGO (Garbage In, Garbage Out) and OCR hallucinations before calculation
|
|
56
|
+
print(f"Audit Blocked: {e.message}")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🔍 Verifying Statutory Audit Certificates
|
|
62
|
+
|
|
63
|
+
Every response from LexGrid is accompanied by a cryptographic certificate (`_audit_meta`):
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Verify certificate in the statutory registry
|
|
67
|
+
cert = client.get_certificate("LG-2026-B81C-9E4F-2A7D")
|
|
68
|
+
print("Status:", cert.status) # "VALID_OFFICIALLY_ISSUED"
|
|
69
|
+
print("Deterministic Hash:", cert.deterministic_hash)
|
|
70
|
+
print("Digital Seal:", cert.digital_seal)
|
|
71
|
+
|
|
72
|
+
# Download printable HTML Dossier for court or administrative record inclusion
|
|
73
|
+
html_dossier = client.download_dossier_html("LG-2026-B81C-9E4F-2A7D")
|
|
74
|
+
with open("dossier_rup.html", "w", encoding="utf-8") as f:
|
|
75
|
+
f.write(html_dossier)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🏛️ All 20 Specialized Suites & Shorthand Properties
|
|
81
|
+
|
|
82
|
+
Access any of the 20 vertical domains directly via property names, ergonomic shorthand aliases, or dynamic runner:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
# Shorthand aliases or canonical properties:
|
|
86
|
+
client.tax # or client.eu_tax (EU Tax, KYB, VIES & e-Invoicing)
|
|
87
|
+
client.fin # or client.fin_esg (Financial Forensics & CSRD VSME)
|
|
88
|
+
client.sec # or client.net_sec (NetSec, Deliverability & RDAP)
|
|
89
|
+
client.gdpr # or client.web_gdpr (Web GDPR, Cookie CMP & AI Act)
|
|
90
|
+
client.appalti # or client.gov_appalti (ANAC Public Procurement D.Lgs 36/2023)
|
|
91
|
+
client.dora # or client.dora_nis2 (DORA Banking/ICT & NIS2)
|
|
92
|
+
client.dogane # or client.customs_cbam (Customs CBAM, TARIC & Dual-Use)
|
|
93
|
+
client.lavoro # or client.hr_labour (HR Labour Law & IRPEF Simulator)
|
|
94
|
+
client.materials # or client.materials_dpp (Materials DPP & CPR)
|
|
95
|
+
client.energy # or client.energy_epbd (Energy Decarbonization & Case Green EPBD)
|
|
96
|
+
client.pii # or client.sovereign_pii (Sovereign PII Scrubber & AI Act)
|
|
97
|
+
client.xbrl # or client.xbrl_fin (XBRL ESEF & EU Taxonomy)
|
|
98
|
+
client.peppol # or client.einvoice_vida (Universal Peppol BIS 3.0 & ViDA)
|
|
99
|
+
client.grants # or client.grants_funding (EU Grants & Transizione 5.0)
|
|
100
|
+
client.carbon # or client.carbon_factors (Scope 1-2-3 GHG & CSRD)
|
|
101
|
+
client.ted # or client.ted_procurement (TED eForms & CPV Classifier)
|
|
102
|
+
client.reach # or client.chemicals_reach (REACH SVHC & RoHS 3)
|
|
103
|
+
client.aml # or client.aml_compliance (EU AMLA & 6AMLD)
|
|
104
|
+
client.eudr # or client.agri_food_eudr (EUDR Deforestation & FIC Allergens)
|
|
105
|
+
client.mdr # or client.pharma_medical_mdr (EU MDR, IVDR & FMD Serialization)
|
|
106
|
+
|
|
107
|
+
# Or dynamic execution for any tool across all 90 endpoints:
|
|
108
|
+
res = client.suite("dora").call("incident_severity_triage", {
|
|
109
|
+
"incidentType": "system_downtime",
|
|
110
|
+
"affectedUsers": 50000,
|
|
111
|
+
"durationHours": 4.5,
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🤖 AI Agent Framework Integrations (LangChain & CrewAI)
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from langchain.tools import tool
|
|
121
|
+
from lexgrid import LexGridClient
|
|
122
|
+
|
|
123
|
+
client = LexGridClient(api_key="your-api-key")
|
|
124
|
+
|
|
125
|
+
@tool
|
|
126
|
+
def verify_eu_vat(vat_number: str) -> str:
|
|
127
|
+
"""Verifies European VAT on official VIES registry with sanctions screening."""
|
|
128
|
+
res = client.eu_tax.verify_vies(vat_number)
|
|
129
|
+
return (
|
|
130
|
+
f"Valid: {res.data['is_valid']}. "
|
|
131
|
+
f"Certificate: {res.certificate_id} ({res.verification_url})"
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 🛡️ License & Compliance
|
|
138
|
+
|
|
139
|
+
- **License:** MIT License
|
|
140
|
+
- **Zero-Data-Retention:** Strictly stateless in-memory execution in volatile RAM ($< 50\text{ ms}$). No customer payloads saved to disk.
|
|
141
|
+
- **DPO Policy:** [https://lexgrid.novapixel.it/compliance-policy](https://lexgrid.novapixel.it/compliance-policy)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
LexGrid Official Python SDK.
|
|
3
|
+
Deterministic Sovereign Hub for EU Compliance, Regulatory Auditing & Italian Public Procurement.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .client import LexGridClient
|
|
7
|
+
from .models import (
|
|
8
|
+
AuditMeta,
|
|
9
|
+
ResponseMeta,
|
|
10
|
+
LexGridResponse,
|
|
11
|
+
CertificateVerification,
|
|
12
|
+
)
|
|
13
|
+
from .exceptions import (
|
|
14
|
+
LexGridError,
|
|
15
|
+
LexGridAuthError,
|
|
16
|
+
LexGridRateLimitError,
|
|
17
|
+
AccountingImbalanceError,
|
|
18
|
+
DataIntegrityAlert,
|
|
19
|
+
LexGridNotFoundError,
|
|
20
|
+
LexGridServerError,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__version__ = "1.0.0"
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"LexGridClient",
|
|
27
|
+
"AuditMeta",
|
|
28
|
+
"ResponseMeta",
|
|
29
|
+
"LexGridResponse",
|
|
30
|
+
"CertificateVerification",
|
|
31
|
+
"LexGridError",
|
|
32
|
+
"LexGridAuthError",
|
|
33
|
+
"LexGridRateLimitError",
|
|
34
|
+
"AccountingImbalanceError",
|
|
35
|
+
"DataIntegrityAlert",
|
|
36
|
+
"LexGridNotFoundError",
|
|
37
|
+
"LexGridServerError",
|
|
38
|
+
]
|