xproof 0.2.4__tar.gz → 0.2.5__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.
Files changed (26) hide show
  1. {xproof-0.2.4 → xproof-0.2.5}/PKG-INFO +1 -1
  2. {xproof-0.2.4 → xproof-0.2.5}/pyproject.toml +1 -1
  3. {xproof-0.2.4 → xproof-0.2.5}/xproof/__init__.py +7 -1
  4. {xproof-0.2.4 → xproof-0.2.5}/xproof/client.py +25 -5
  5. {xproof-0.2.4 → xproof-0.2.5}/xproof/models.py +88 -1
  6. {xproof-0.2.4 → xproof-0.2.5}/xproof.egg-info/PKG-INFO +1 -1
  7. {xproof-0.2.4 → xproof-0.2.5}/LICENSE +0 -0
  8. {xproof-0.2.4 → xproof-0.2.5}/README.md +0 -0
  9. {xproof-0.2.4 → xproof-0.2.5}/setup.cfg +0 -0
  10. {xproof-0.2.4 → xproof-0.2.5}/tests/test_client.py +0 -0
  11. {xproof-0.2.4 → xproof-0.2.5}/tests/test_integration.py +0 -0
  12. {xproof-0.2.4 → xproof-0.2.5}/xproof/exceptions.py +0 -0
  13. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/__init__.py +0 -0
  14. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/autogen.py +0 -0
  15. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/crewai.py +0 -0
  16. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/deerflow.py +0 -0
  17. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/fetchai.py +0 -0
  18. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/langchain.py +0 -0
  19. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/llamaindex.py +0 -0
  20. {xproof-0.2.4 → xproof-0.2.5}/xproof/integrations/openai_agents.py +0 -0
  21. {xproof-0.2.4 → xproof-0.2.5}/xproof/py.typed +0 -0
  22. {xproof-0.2.4 → xproof-0.2.5}/xproof/utils.py +0 -0
  23. {xproof-0.2.4 → xproof-0.2.5}/xproof.egg-info/SOURCES.txt +0 -0
  24. {xproof-0.2.4 → xproof-0.2.5}/xproof.egg-info/dependency_links.txt +0 -0
  25. {xproof-0.2.4 → xproof-0.2.5}/xproof.egg-info/requires.txt +0 -0
  26. {xproof-0.2.4 → xproof-0.2.5}/xproof.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xproof
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Python SDK for xProof — blockchain-anchored proof-of-existence for AI agents on MultiversX
5
5
  Author-email: xProof <contact@xproof.app>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xproof"
7
- version = "0.2.4"
7
+ version = "0.2.5"
8
8
  description = "Python SDK for xProof — blockchain-anchored proof-of-existence for AI agents on MultiversX"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -14,6 +14,9 @@ from .models import (
14
14
  BatchResult,
15
15
  BatchResultSummary,
16
16
  Certification,
17
+ ConfidenceTrail,
18
+ ConfidenceTrailStage,
19
+ PolicyViolation,
17
20
  PricingInfo,
18
21
  PricingTier,
19
22
  RegistrationResult,
@@ -21,7 +24,7 @@ from .models import (
21
24
  )
22
25
  from .utils import hash_bytes, hash_file
23
26
 
24
- __version__ = "0.2.3"
27
+ __version__ = "0.2.5"
25
28
 
26
29
  __all__ = [
27
30
  "XProofClient",
@@ -30,6 +33,9 @@ __all__ = [
30
33
  "Certification",
31
34
  "BatchResult",
32
35
  "BatchResultSummary",
36
+ "ConfidenceTrail",
37
+ "ConfidenceTrailStage",
38
+ "PolicyViolation",
33
39
  "PricingInfo",
34
40
  "PricingTier",
35
41
  "RegistrationResult",
@@ -14,10 +14,16 @@ from .exceptions import (
14
14
  ValidationError,
15
15
  XProofError,
16
16
  )
17
- from .models import BatchResult, Certification, PricingInfo, RegistrationResult
17
+ from .models import (
18
+ BatchResult,
19
+ Certification,
20
+ ConfidenceTrail,
21
+ PricingInfo,
22
+ RegistrationResult,
23
+ )
18
24
  from .utils import hash_file
19
25
 
20
- __version__ = "0.2.4"
26
+ __version__ = "0.2.5"
21
27
 
22
28
  DEFAULT_BASE_URL = "https://xproof.app"
23
29
  DEFAULT_TIMEOUT = 30
@@ -232,6 +238,7 @@ class XProofClient:
232
238
  what: Optional[str] = None,
233
239
  when: Optional[str] = None,
234
240
  why: Optional[str] = None,
241
+ reversibility_class: Optional[str] = None,
235
242
  metadata: Optional[Dict[str, Any]] = None,
236
243
  ) -> Certification:
237
244
  """Certify a file using a pre-computed SHA-256 hash.
@@ -253,6 +260,9 @@ class XProofClient:
253
260
  what: 4W — action hash or description.
254
261
  when: 4W — ISO-8601 timestamp.
255
262
  why: 4W — instruction or reason.
263
+ reversibility_class: Governance class — one of ``reversible``,
264
+ ``costly``, or ``irreversible``. Irreversible actions above
265
+ the configured confidence threshold trigger a policy violation.
256
266
  metadata: Arbitrary key-value metadata stored alongside the proof.
257
267
 
258
268
  Returns:
@@ -270,6 +280,8 @@ class XProofClient:
270
280
  proof_metadata["when"] = when
271
281
  if why is not None:
272
282
  proof_metadata["why"] = why
283
+ if reversibility_class is not None:
284
+ proof_metadata["reversibility_class"] = reversibility_class
273
285
 
274
286
  payload: Dict[str, Any] = {
275
287
  "filename": file_name,
@@ -296,6 +308,7 @@ class XProofClient:
296
308
  what: Optional[str] = None,
297
309
  when: Optional[str] = None,
298
310
  why: Optional[str] = None,
311
+ reversibility_class: Optional[str] = None,
299
312
  metadata: Optional[Dict[str, Any]] = None,
300
313
  ) -> Certification:
301
314
  """Certify a file hash with confidence-level anchoring.
@@ -318,6 +331,9 @@ class XProofClient:
318
331
  what: 4W -- action hash or description.
319
332
  when: 4W -- ISO-8601 timestamp.
320
333
  why: 4W -- instruction or reason.
334
+ reversibility_class: Governance class — one of ``reversible``,
335
+ ``costly``, or ``irreversible``. Irreversible actions above
336
+ the configured confidence threshold trigger a policy violation.
321
337
  metadata: Extra key-value metadata stored alongside the proof.
322
338
 
323
339
  Returns:
@@ -349,6 +365,8 @@ class XProofClient:
349
365
  proof_metadata["when"] = when
350
366
  if why is not None:
351
367
  proof_metadata["why"] = why
368
+ if reversibility_class is not None:
369
+ proof_metadata["reversibility_class"] = reversibility_class
352
370
 
353
371
  payload: Dict[str, Any] = {
354
372
  "filename": file_name,
@@ -359,16 +377,18 @@ class XProofClient:
359
377
  data = self._request("POST", "/api/proof", json=payload)
360
378
  return Certification.from_dict(data)
361
379
 
362
- def get_confidence_trail(self, decision_id: str) -> Dict[str, Any]:
380
+ def get_confidence_trail(self, decision_id: str) -> ConfidenceTrail:
363
381
  """Retrieve the full confidence trail for a decision chain.
364
382
 
365
383
  Args:
366
384
  decision_id: The shared identifier linking proofs in the chain.
367
385
 
368
386
  Returns:
369
- A dictionary with ``decision_id``, ``total_anchors``,
387
+ A :class:`ConfidenceTrail` with ``decision_id``, ``total_anchors``,
370
388
  ``current_confidence``, ``current_stage``, ``is_finalized``,
389
+ ``policy_compliant``, ``policy_violations``,
371
390
  and ``stages`` (list of anchor details sorted by confidence).
391
+ Access the raw API dict via ``.raw``.
372
392
  """
373
393
  from urllib.parse import quote
374
394
  data = self._request(
@@ -376,7 +396,7 @@ class XProofClient:
376
396
  f"/api/confidence-trail/{quote(decision_id, safe='')}",
377
397
  auth_required=False,
378
398
  )
379
- return data
399
+ return ConfidenceTrail.from_dict(data)
380
400
 
381
401
  def get_context_drift(self, decision_id: str) -> Dict[str, Any]:
382
402
  """Detect execution context drift across a decision chain.
@@ -1,7 +1,89 @@
1
1
  """Data models for the xProof SDK."""
2
2
 
3
3
  from dataclasses import dataclass, field
4
- from typing import Any, Dict, List, Optional
4
+ from typing import Any, Dict, List, Literal, Optional
5
+
6
+ ReversibilityClass = Literal["reversible", "costly", "irreversible"]
7
+
8
+
9
+ @dataclass
10
+ class PolicyViolation:
11
+ """A single policy violation detected by the server."""
12
+
13
+ rule: str
14
+ message: str
15
+ severity: str = "error"
16
+
17
+ @classmethod
18
+ def from_dict(cls, data: Dict[str, Any]) -> "PolicyViolation":
19
+ return cls(
20
+ rule=data.get("rule", ""),
21
+ message=data.get("message", ""),
22
+ severity=data.get("severity", "error"),
23
+ )
24
+
25
+
26
+ @dataclass
27
+ class ConfidenceTrailStage:
28
+ """One stage anchor in a confidence trail."""
29
+
30
+ proof_id: str
31
+ confidence_level: float
32
+ threshold_stage: str
33
+ reversibility_class: Optional[str] = None
34
+ anchored_at: str = ""
35
+ transaction_hash: str = ""
36
+ transaction_url: str = ""
37
+ policy_violations: List[PolicyViolation] = field(default_factory=list)
38
+
39
+ @classmethod
40
+ def from_dict(cls, data: Dict[str, Any]) -> "ConfidenceTrailStage":
41
+ metadata = data.get("metadata", {})
42
+ violations_raw = data.get("policy_violations", [])
43
+ return cls(
44
+ proof_id=data.get("proof_id", data.get("id", "")),
45
+ confidence_level=data.get("confidence_level", metadata.get("confidence_level", 0.0)),
46
+ threshold_stage=data.get("threshold_stage", metadata.get("threshold_stage", "")),
47
+ reversibility_class=data.get(
48
+ "reversibility_class", metadata.get("reversibility_class")
49
+ ),
50
+ anchored_at=data.get("anchored_at", data.get("created_at", "")),
51
+ transaction_hash=data.get("transaction_hash", ""),
52
+ transaction_url=data.get("transaction_url", ""),
53
+ policy_violations=[PolicyViolation.from_dict(v) for v in violations_raw],
54
+ )
55
+
56
+
57
+ @dataclass
58
+ class ConfidenceTrail:
59
+ """Full confidence trail for a decision chain."""
60
+
61
+ decision_id: str
62
+ total_anchors: int = 0
63
+ current_confidence: float = 0.0
64
+ current_stage: str = ""
65
+ is_finalized: bool = False
66
+ policy_compliant: bool = True
67
+ policy_violations: List[PolicyViolation] = field(default_factory=list)
68
+ stages: List[ConfidenceTrailStage] = field(default_factory=list)
69
+ raw: Dict[str, Any] = field(default_factory=dict)
70
+
71
+ @classmethod
72
+ def from_dict(cls, data: Dict[str, Any]) -> "ConfidenceTrail":
73
+ """Create a ConfidenceTrail from an API response dictionary."""
74
+ stages = [ConfidenceTrailStage.from_dict(s) for s in data.get("stages", [])]
75
+ violations_raw = data.get("policy_violations", [])
76
+ return cls(
77
+ decision_id=data.get("decision_id", ""),
78
+ total_anchors=data.get("total_anchors", len(stages)),
79
+ current_confidence=data.get("current_confidence", 0.0),
80
+ current_stage=data.get("current_stage", ""),
81
+ is_finalized=data.get("is_finalized", False),
82
+ policy_compliant=data.get("policy_compliant", True),
83
+ policy_violations=[PolicyViolation.from_dict(v) for v in violations_raw],
84
+ stages=stages,
85
+ raw=data,
86
+ )
5
87
 
6
88
 
7
89
  @dataclass
@@ -21,11 +103,13 @@ class Certification:
21
103
  is_public: bool = True
22
104
  certificate_url: str = ""
23
105
  verify_url: str = ""
106
+ reversibility_class: Optional[str] = None
24
107
 
25
108
  @classmethod
26
109
  def from_dict(cls, data: Dict[str, Any]) -> "Certification":
27
110
  """Create a Certification from an API response dictionary."""
28
111
  blockchain = data.get("blockchain", {})
112
+ metadata = data.get("metadata", {})
29
113
  return cls(
30
114
  id=data.get("id", data.get("proof_id", "")),
31
115
  file_name=data.get("fileName", data.get("filename", data.get("file_name", ""))),
@@ -46,6 +130,9 @@ class Certification:
46
130
  is_public=data.get("isPublic", data.get("is_public", True)),
47
131
  certificate_url=data.get("certificateUrl", data.get("certificate_url", "")),
48
132
  verify_url=data.get("verifyUrl", data.get("verify_url", "")),
133
+ reversibility_class=data.get(
134
+ "reversibility_class", metadata.get("reversibility_class")
135
+ ),
49
136
  )
50
137
 
51
138
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xproof
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Python SDK for xProof — blockchain-anchored proof-of-existence for AI agents on MultiversX
5
5
  Author-email: xProof <contact@xproof.app>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes