HKUDS/Vibe-Trading · error · ValueError

unknown claim_id: {claim_id}

Error message

unknown claim_id: {claim_id}

What it means

append_evidence referenced a claim_id with no matching row in goal_claims for that goal. Claims must be registered on the goal before evidence can reference them.

Source

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

            SELECT * FROM goal_criteria
            WHERE goal_id = ? AND criterion_id = ?
            """,
            (goal_id, criterion_id),
        ).fetchone()
        if row is None:
            raise ValueError(f"unknown criterion_id: {criterion_id}")
        return self._criterion_from_row(row)

    def _require_claim(self, goal_id: str, claim_id: str) -> GoalClaim:
        row = self._conn.execute(
            """
            SELECT * FROM goal_claims
            WHERE goal_id = ? AND claim_id = ?
            """,
            (goal_id, claim_id),
        ).fetchone()
        if row is None:
            raise ValueError(f"unknown claim_id: {claim_id}")
        return self._claim_from_row(row)

    def _validate_completion_audit(
        self,
        goal: GoalRecord,
        audit: list[AuditRow],
    ) -> None:
        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:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Create the claim through the store first and use the returned claim_id
  2. Verify the claim exists for this goal before appending evidence
  3. Regenerate goals/claims together in tests to keep ids consistent

Example fix

// before
store.append_evidence(..., claim_id="claim-99")
// after
claim = store.add_claim(goal_id, ...)
store.append_evidence(..., claim_id=claim.claim_id)
Defensive patterns

Strategy: validation

Validate before calling

claims = {c.claim_id for c in store.list_claims(goal_id)}
if claim_id not in claims:
    claim = store.add_claim(goal_id, ...)
    claim_id = claim.claim_id

Type guard

def claim_exists(store, goal_id: str, claim_id: str) -> bool:
    return any(c.claim_id == claim_id for c in store.list_claims(goal_id))

Try / catch

except ValueError as e: if str(e).startswith('unknown claim_id'): create the claim or correct the id, then retry the append

Prevention

When it happens

Trigger: Calling append_evidence with a claim_id from another goal, deleted, or never created via the claim-adding API.

Common situations: Claim ids generated client-side instead of via the store; stale claim references after goal recreation; cross-goal id mixups in logs.

Related errors


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