correctover 2.0.0__tar.gz → 2.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: correctover
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: CCS v1.0 - Conformance Protocol for Agentic Runtime Systems
5
5
  Home-page: https://correctover.github.io
6
6
  Author: Guigui Wang
@@ -3,7 +3,7 @@ Correctover - CCS v1.0
3
3
  Conformance Protocol for Agentic Runtime Systems
4
4
  """
5
5
 
6
- __version__ = "2.0.0"
6
+ __version__ = "2.0.2"
7
7
  __author__ = "Guigui Wang"
8
8
  __email__ = "wangguigui@correctover.com"
9
9
 
@@ -8,6 +8,7 @@ from pydantic import BaseModel, Field
8
8
  from datetime import datetime
9
9
  import hashlib
10
10
  import hmac
11
+ import json
11
12
 
12
13
 
13
14
  class ValidationResult(BaseModel):
@@ -41,42 +42,31 @@ class CCSValidator:
41
42
  self.integrity_key = integrity_key or "default-key"
42
43
 
43
44
  def validate(self, output: Dict[str, Any], trace_id: str = None) -> ValidationResult:
44
- """
45
- Validate LLM output against CCS schema
46
-
47
- Args:
48
- output: LLM output dictionary
49
- trace_id: Optional trace ID for audit logging
50
-
51
- Returns:
52
- ValidationResult with is_valid flag and errors/warnings
53
- """
45
+ """Validate LLM output against CCS schema"""
54
46
  errors = []
55
47
  warnings = []
56
48
 
57
- # Check required fields
58
49
  for field in self.required_fields:
59
50
  if field not in output:
60
51
  errors.append(f"Missing required field: {field}")
61
52
 
62
- # Check forbidden fields
63
53
  for field in self.forbidden_fields:
64
54
  if field in output:
65
55
  errors.append(f"Forbidden field present: {field}")
66
56
 
67
- # Check supported fields (warning only)
68
57
  output_fields = set(output.keys())
69
58
  all_allowed = self.required_fields | self.supported_fields
70
59
  unexpected = output_fields - all_allowed - self.forbidden_fields
71
60
  for field in unexpected:
72
61
  warnings.append(f"Unexpected field: {field}")
73
62
 
74
- # Integrity check (if enabled)
75
63
  if self.enable_integrity:
76
- integrity_hash = self._compute_integrity(output)
77
- if "integrity_hash" not in output:
64
+ stored_hash = output.get("integrity_hash")
65
+ computed_hash = self._compute_integrity(output)
66
+
67
+ if stored_hash is None:
78
68
  warnings.append("No integrity hash in output")
79
- elif output["integrity_hash"] != integrity_hash:
69
+ elif stored_hash != computed_hash:
80
70
  errors.append("Integrity hash mismatch")
81
71
 
82
72
  return ValidationResult(
@@ -87,12 +77,12 @@ class CCSValidator:
87
77
  )
88
78
 
89
79
  def _compute_integrity(self, output: Dict[str, Any]) -> str:
90
- """Compute HMAC-based integrity hash"""
91
- # Create deterministic string representation
92
- sorted_items = sorted(output.items())
93
- data_str = str(sorted_items)
80
+ """Compute HMAC-based integrity hash using JSON serialization"""
81
+ # Exclude integrity_hash from computation
82
+ filtered = {k: v for k, v in output.items() if k != "integrity_hash"}
83
+ # Use JSON serialization (sorted keys, no extra spaces)
84
+ data_str = json.dumps(filtered, sort_keys=True, separators=(',', ':'))
94
85
 
95
- # Compute HMAC
96
86
  signature = hmac.new(
97
87
  self.integrity_key.encode(),
98
88
  data_str.encode(),
@@ -104,5 +94,5 @@ class CCSValidator:
104
94
  def add_integrity_hash(self, output: Dict[str, Any]) -> Dict[str, Any]:
105
95
  """Add integrity hash to output"""
106
96
  output_copy = output.copy()
107
- output_copy["integrity_hash"] = self._compute_integrity(output)
97
+ output_copy["integrity_hash"] = self._compute_integrity(output_copy)
108
98
  return output_copy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: correctover
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: CCS v1.0 - Conformance Protocol for Agentic Runtime Systems
5
5
  Home-page: https://correctover.github.io
6
6
  Author: Guigui Wang
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="correctover",
8
- version="2.0.0",
8
+ version="2.0.2",
9
9
  author="Guigui Wang",
10
10
  author_email="wangguigui@correctover.com",
11
11
  description="CCS v1.0 - Conformance Protocol for Agentic Runtime Systems",
File without changes
File without changes
File without changes