fix(cache): write_entry missing validation for Phase 3 completeness field #84

Open
opened 2026-04-18 20:24:16 -06:00 by claude-code · 0 comments
Collaborator

Problem

cache.py:write_entry validates confidence (Phase 1) as float in [0.0, 1.0] and confidence_reason as str. The Phase 3 completeness field — documented in wiki Internals §5.3 as 0.0–1.0 — has no validation at all.

luminos_lib/cache.py:141-146:

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"
# (no completeness check)

Meanwhile the agent's self-rated completeness is used as quality signal in plan_evaluation.json (_write_plan_evaluation in ai.py) and in the per-dir cache entry written by _run_investigation. Invalid values — a string, 2.5, -0.3 — pass through and poison the evaluation report.

Fix

Mirror the confidence validation:

if "completeness" in data:
    c = data["completeness"]
    if not isinstance(c, (int, float)) or not (0.0 <= c <= 1.0):
        return "Error: completeness must be a float between 0.0 and 1.0"

Acceptance

  • completeness validated 0.0–1.0 in write_entry
  • Test case in tests/test_cache.py covers: valid completeness accepted, out-of-range rejected, non-numeric rejected
  • Wiki Internals §5.3 remains accurate (it already documents the range)
## Problem `cache.py:write_entry` validates `confidence` (Phase 1) as float in `[0.0, 1.0]` and `confidence_reason` as str. The Phase 3 `completeness` field — documented in wiki [Internals §5.3](https://forgejo.labbity.unbiasedgeek.com/archeious/luminos/wiki/Internals) as 0.0–1.0 — has no validation at all. `luminos_lib/cache.py:141-146`: ```python 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" # (no completeness check) ``` Meanwhile the agent's self-rated `completeness` is used as quality signal in `plan_evaluation.json` (`_write_plan_evaluation` in `ai.py`) and in the per-dir cache entry written by `_run_investigation`. Invalid values — a string, `2.5`, `-0.3` — pass through and poison the evaluation report. ## Fix Mirror the confidence validation: ```python if "completeness" in data: c = data["completeness"] if not isinstance(c, (int, float)) or not (0.0 <= c <= 1.0): return "Error: completeness must be a float between 0.0 and 1.0" ``` ## Acceptance - [ ] `completeness` validated 0.0–1.0 in `write_entry` - [ ] Test case in `tests/test_cache.py` covers: valid completeness accepted, out-of-range rejected, non-numeric rejected - [ ] Wiki Internals §5.3 remains accurate (it already documents the range)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: archeious/luminos#84
No description provided.