HKUDS/Vibe-Trading · error · ValueError

unknown evidence_id: {evidence_id}

Error message

unknown evidence_id: {evidence_id}

What it means

A completion audit row cited an evidence_id that does not exist in goal_evidence, or exists but belongs to a different goal. The validator resolves every cited evidence record against the goal being completed.

Source

Thrown at agent/src/goal/store.py:922

        criteria = self.list_criteria(goal.goal_id)
        rows_by_criterion = {row.criterion_id: row for row in audit}
        for criterion in criteria:
            if not criterion.required:
                continue
            row = rows_by_criterion.get(criterion.criterion_id)
            if row is None:
                raise ValueError(f"missing audit row for criterion {criterion.criterion_id}")
            if row.result not in _COMPLETION_RESULTS:
                raise ValueError(f"criterion {criterion.criterion_id} is not satisfied")
            if row.result in {"satisfied", "satisfied_with_caveat"} and not row.evidence_ids:
                raise ValueError("complete goals require verified evidence")
            if row.result == "not_applicable_user_accepted" and not row.notes.strip():
                raise ValueError("not-applicable criteria require acceptance notes")
            has_verified_evidence = False
            for evidence_id in row.evidence_ids:
                evidence = self._get_evidence(evidence_id)
                if evidence is None or evidence.goal_id != goal.goal_id:
                    raise ValueError(f"unknown evidence_id: {evidence_id}")
                if evidence.criterion_id != criterion.criterion_id:
                    raise ValueError(
                        f"evidence {evidence_id} does not match criterion {criterion.criterion_id}"
                    )
                if evidence.verification_status == "verified":
                    has_verified_evidence = True
            if row.result in {"satisfied", "satisfied_with_caveat"} and not has_verified_evidence:
                raise ValueError("complete goals require verified evidence")

    def _get_evidence(self, evidence_id: str) -> EvidenceRecord | None:
        row = self._conn.execute(
            "SELECT * FROM goal_evidence WHERE evidence_id = ?",
            (evidence_id,),
        ).fetchone()
        return self._evidence_from_row(row) if row else None

    @staticmethod
    def _goal_from_row(row: sqlite3.Row) -> GoalRecord:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Append the evidence to this goal first and use the exact returned evidence_id
  2. Cross-check each evidence_id via the store before submitting the audit
  3. Keep evidence and audit construction in the same code path so ids stay consistent

Example fix

// before
AuditRow(criterion_id="c1", result="satisfied", evidence_ids=["ev-123"])
// after
ev = store.append_evidence(session_id, goal_id, criterion_id="c1", ...)
AuditRow(criterion_id="c1", result="satisfied", evidence_ids=[ev.evidence_id])
Defensive patterns

Strategy: validation

Validate before calling

valid = {e.evidence_id for e in store.list_evidence(goal_id)}
bad = [eid for row in audit for eid in row.evidence_ids if eid not in valid]
assert not bad, f"unknown evidence ids: {bad}"

Type guard

def evidence_ids_valid(store, goal_id: str, audit: list) -> bool:
    valid = {e.evidence_id for e in store.list_evidence(goal_id)}
    return all(eid in valid for row in audit for eid in row.evidence_ids)

Try / catch

except ValueError as e: if str(e).startswith('unknown evidence_id'): re-append evidence for the criterion and rebuild the audit

Prevention

When it happens

Trigger: update_status with evidence_ids containing a typo'd id, an id from another goal, or an id from evidence that was never appended.

Common situations: Evidence appended to a different goal (often after goal recreation); truncated/copied ids; evidence append failed silently and the id was assumed.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/ecabbdb964812695. Report an issue: GitHub.