Skip to content

Commit 82f66d9

Browse files
authored
Merge pull request #79 from QWED-AI/tembo/add-unit-tests-process-guard-coverage90
Add process_guard.py tests
2 parents 89445aa + 9dd060d commit 82f66d9

3 files changed

Lines changed: 388 additions & 18 deletions

File tree

.coverage

-16 KB
Binary file not shown.

src/qwed_new/guards/process_guard.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import re
3+
from decimal import Decimal
34
from typing import List, Dict, Any
45

56
class ProcessVerifier:
@@ -38,9 +39,8 @@ def verify_irac_structure(self, reasoning_trace: str) -> Dict[str, Any]:
3839
else:
3940
missing_steps.append(step)
4041

41-
# Calculate score (0.0 to 1.0)
42-
# 4 steps total
43-
score = (4 - len(missing_steps)) / 4.0
42+
# Calculate score (0 to 1) using Decimal for deterministic arithmetic
43+
score = float(Decimal(4 - len(missing_steps)) / Decimal(4))
4444

4545
return {
4646
"verified": len(missing_steps) == 0,
@@ -73,8 +73,8 @@ def verify_trace(self, text: str, key_middle: List[str]) -> Dict[str, Any]:
7373
kw for kw in key_middle
7474
if re.search(rf"\b{re.escape(kw.lower())}\b", text_lc)
7575
]
76-
process_rate = len(found_milestones) / len(key_middle)
77-
76+
process_rate = float(Decimal(len(found_milestones)) / Decimal(len(key_middle)))
77+
7878
return {
7979
"verified": process_rate == 1.0,
8080
"process_rate": process_rate,

0 commit comments

Comments
 (0)