Compare commits

..

2 commits

Author SHA1 Message Date
Jeff Smith
0d9812490a merge: feat/issue-1-confidence-fields (#1) 2026-04-06 16:51:58 -06:00
Jeff Smith
b158809c19 feat(cache): add confidence fields to file and dir cache schemas (#1)
Add optional confidence (float 0.0–1.0) and confidence_reason (str) fields
to both file and dir cache entries. Validation rejects out-of-range values
and wrong types. Fields are not yet required — pure schema instrumentation
for Phase 1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 16:50:48 -06:00

View file

@ -126,6 +126,12 @@ class _CacheManager:
return f"Error: missing required fields: {', '.join(sorted(missing))}"
if "content" in data or "contents" in data or "raw" in data:
return "Error: cache entries must not contain raw file contents."
if "confidence" in data:
c = data["confidence"]
if not isinstance(c, (int, float)) or not (0.0 <= c <= 1.0):
return "Error: confidence must be a float between 0.0 and 1.0"
if "confidence_reason" in data and not isinstance(data["confidence_reason"], str):
return "Error: confidence_reason must be a string"
try:
with open(cache_file, "w") as f:
json.dump(data, f, indent=2)