JuliusBrussee/caveman · error
native runtime: invalid decision record
Error message
native runtime: invalid decision record
What it means
After decoding the stored decision record, ExplainDecision enforces the record's invariants: schema must be caveman.native.decision.v1, the embedded DecisionID must match the requested id, and Action and Reason must be non-empty. Any violation returns this error instead of emitting a partially-populated explanation.
Solutions
- Delete/re-write the offending record with the current runtime so it is serialized under caveman.native.decision.v1 with Action and Reason populated.
- Upgrade the runtime that wrote the record so schema versions match, or add a migration for old schema values.
- Verify no duplicate/colliding decision ids exist in the ccr store.
- Catch this error in runNativeWhy and report the decision as unexplainable rather than crashing the why flow.
Example fix
// before // record written with schema "caveman.native.decision" (v0) // after record.Schema = "caveman.native.decision.v1" // re-persist the decision with the v1 schema before explaining
Defensive patterns
Strategy: try-catch
Validate before calling
// after fetching the record, check invariants yourself
var rec struct{ Schema, DecisionID, Action, Reason string }
if json.Unmarshal(data, &rec) == nil &&
rec.Schema == "caveman.native.decision.v1" && rec.Action != "" && rec.Reason != "" {
// safe to explain
} Type guard
func isV1Decision(data []byte, id string) bool {
var r struct{ Schema, DecisionID, Action, Reason string }
return json.Unmarshal(data, &r) == nil &&
r.Schema == "caveman.native.decision.v1" && r.DecisionID == id && r.Action != "" && r.Reason != ""
} Try / catch
exp, err := nativeruntime.ExplainDecision(store, id)
if err != nil && strings.Contains(err.Error(), "invalid decision record") {
return fmt.Errorf("decision %s stored in an incompatible schema; re-record it", id)
} Prevention
- Always write decisions through the current runtime API
- Migrate old schema versions before explaining historical records
- Refuse manual edits to the ccr SQLite store
When it happens
Trigger: store.FindTaskDecision(decisionID) returns a task-decision object whose JSON data fails one of: wrong record.Schema, record.DecisionID != requested decisionID, empty record.Action, or empty record.Reason.
Common situations: Records written by an older runtime version with a different schema string; corrupted or hand-edited SQLite rows; a record inserted by a test/external tool missing Action/Reason; a store row keyed by one id but containing another's payload after a bad migration or id collision.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- canonical span
- cave_agent_definition_invalid
- cave_context_ir_invalid
- cave_output_schema_mismatch
- cave_output_schema_mismatch
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/0456fe785f76093d.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/internal/nativeruntime/explain.go:58
}
var record struct {
Schema string `json:"schema"`
DecisionID string `json:"decision_id"`
TimestampMS int64 `json:"timestamp_ms"`
Action string `json:"action"`
Reason string `json:"reason"`
InputBasis map[string]any `json:"input_basis"`
AlternativesRejected []string `json:"alternatives_rejected"`
TaskStateBefore string `json:"task_state_before"`
TaskStateAfter string `json:"task_state_after"`
Currentness string `json:"currentness"`
RecoveryRef string `json:"recovery_ref"`
}
if err := json.Unmarshal(object.Data, &record); err != nil {
return DecisionExplanation{}, fmt.Errorf("native runtime: decode decision: %w", err)
}
if record.Schema != "caveman.native.decision.v1" || record.DecisionID != decisionID || record.Action == "" || record.Reason == "" {
return DecisionExplanation{}, errors.New("native runtime: invalid decision record")
}
return DecisionExplanation{
Schema: WhySchema,
DecisionID: record.DecisionID,
SessionID: object.SessionID,
TimestampMS: record.TimestampMS,
Action: record.Action,
Reason: record.Reason,
InputBasis: record.InputBasis,
AlternativesRejected: record.AlternativesRejected,
TaskStateBefore: record.TaskStateBefore,
TaskStateAfter: record.TaskStateAfter,
Currentness: record.Currentness,
RecoveryRef: record.RecoveryRef,
}, nil
}
View on GitHub (pinned to 3ee70a1026)